You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(30) |
Sep
(19) |
Oct
(3) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(11) |
Feb
(13) |
Mar
(10) |
Apr
(11) |
May
(7) |
Jun
(8) |
Jul
(5) |
Aug
(16) |
Sep
(14) |
Oct
(3) |
Nov
(9) |
Dec
|
2003 |
Jan
(5) |
Feb
(6) |
Mar
(9) |
Apr
(31) |
May
(25) |
Jun
(22) |
Jul
(28) |
Aug
(27) |
Sep
(19) |
Oct
(4) |
Nov
(7) |
Dec
(26) |
2004 |
Jan
(8) |
Feb
(13) |
Mar
(5) |
Apr
(8) |
May
(8) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(4) |
2005 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2008 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
(3) |
May
|
Jun
|
Jul
(6) |
Aug
|
Sep
(10) |
Oct
(6) |
Nov
|
Dec
(36) |
2009 |
Jan
(3) |
Feb
(14) |
Mar
(13) |
Apr
(18) |
May
(35) |
Jun
(18) |
Jul
(27) |
Aug
(6) |
Sep
(2) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
(6) |
Feb
(1) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
From: Nat P. <nat...@b1...> - 2003-08-27 13:40:11
|
Something like this: Mock semanticsMock = new Mock(CallSemantics.class); Pluxie pluxie = new Pluxie(); semanticsMock.expectAndReturn( "configure", C.args(C.same(pluxie)), pluxie ); ... rest of test... Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 ----- Original Message ----- From: <DeS...@em...> To: <moc...@li...> Sent: Wednesday, August 27, 2003 1:10 PM Subject: [MO-java-users] How to express an expected invocation using dynamic mocks? > Hello, > > I must have scanned all documentation on the wiki by now, but I still don't > know how to do something simple like defining an expected invocation of a > method on a dynamic mock. > > I have the following interface: > > public interface CallSemantics { > Pluxie configure(Pluxie pluxieToConfigure); > } > > And I'm testing that following method delegates to a CallSemantics object: > > Pluxie configurePluxie(Pluxie pluxieToConfigure) { > // The 'callSemantics' object is a member. > return callSemantics.configure(pluxieToConfigure); > } > > Well, the real production method has some more lines, but I want to keep my > question simple. > > In my unit test, I define a mock of CallSemantics and mention that it should > expect an invocation of the configure method with a Pluxie object as an > argument. However, I just can't figure out how to write this expectation > using dynamic mocks: > > Mock semanticsMock = new Mock(CallSemantics.class); > // How to define the expectation here? > CallSemantics callSemanticsMock = (CallSemantics) semanticsMock.proxy(); > > What should I write to define that I want one invocation of the method with > signature > > public Pluxie configure(Pluxie) > > Oh, I want the mock to return the given argument unmodified! > > Ringo > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Mockobjects-java-users mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users |
From: Jeff M. <je...@cu...> - 2003-08-27 12:12:27
|
You are correct, using mocks allows you to avoid in-container testing. Some people prefer to run tests in-container but personally I've always found it much easier just to use mocks and have not found any disadvantages in doing so. Some people argue that you need to test in container to verify that your code runs well in the container itself but again i've not had any major issues regarding this and this would probably be more along the lines of system tests rather than unit tests. You can read this page http://jakarta.apache.org/cactus/mock_vs_cactus.html which compares mocks against cactus, although is is quite old and somethings have changed since then http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/helpers/ServletTestHelper.java?rev=HEAD&content-type=text/vnd.viewcvs-markup. Really it's about personal preference, the lightweight approach of mocks or the higher level in-container tests. On Wed, 2003-08-27 at 12:30, Guofeng Zhang wrote: > I am new to mock objects approach. > > I guess that if the classes that the tested unit depends on could be replaced by mock objects, I donot need to do the in-container test, that is, I can only use JUnit framework , and do not need to use Cactus, to do the unit test. > > Could anyone tell me if the decision is correct? Do anyone meet the situation that the Cactus is still required to test some units even if the mock object apprach is used or mock object approach cannot be used? > > thanks. > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Mockobjects-java-users mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users -- Jeff Martin Memetic Engineer http://www.custommonkey.org/ |
From: <DeS...@em...> - 2003-08-27 12:10:51
|
Hello, I must have scanned all documentation on the wiki by now, but I still don't know how to do something simple like defining an expected invocation of a method on a dynamic mock. I have the following interface: public interface CallSemantics { Pluxie configure(Pluxie pluxieToConfigure); } And I'm testing that following method delegates to a CallSemantics object: Pluxie configurePluxie(Pluxie pluxieToConfigure) { // The 'callSemantics' object is a member. return callSemantics.configure(pluxieToConfigure); } Well, the real production method has some more lines, but I want to keep my question simple. In my unit test, I define a mock of CallSemantics and mention that it should expect an invocation of the configure method with a Pluxie object as an argument. However, I just can't figure out how to write this expectation using dynamic mocks: Mock semanticsMock = new Mock(CallSemantics.class); // How to define the expectation here? CallSemantics callSemanticsMock = (CallSemantics) semanticsMock.proxy(); What should I write to define that I want one invocation of the method with signature public Pluxie configure(Pluxie) Oh, I want the mock to return the given argument unmodified! Ringo |
From: Guofeng Z. <guo...@vi...> - 2003-08-27 11:30:46
|
I am new to mock objects approach.=20 I guess that if the classes that the tested unit depends on could be = replaced by mock objects, I donot need to do the in-container test, that = is, I can only use JUnit framework , and do not need to use Cactus, to = do the unit test. Could anyone tell me if the decision is correct? Do anyone meet the = situation that the Cactus is still required to test some units even if = the mock object apprach is used or mock object approach cannot be used? thanks. |
From: Jeff M. <jef...@mk...> - 2003-08-26 09:38:45
|
What's the trouble your having? Have you tried looking at this page http://www.mockobjects.com/wiki/DevelopingJdbcApplicationsTestFirst it's probably a bit out of date but the ideas the same. On Mon, 2003-08-25 at 19:24, J. B. Rainsberger wrote: > Hello, there. >=20 > I'm having trouble writing a simple INSERT test with the JDBC=20 > mock objects. If you're available, can I get a few minutes? I'm=20 > trying to put this good stuff in a book. --=20 jeff martin information technologist mkodo limited mobile: 44 (0) 78 55 478 331 phone: 44 (0) 20 77 29 45 45 email: jef...@mk... www.mkodo.com 73 Leonard St, London, EC2A 4QS. U.K |
From: Jeff M. <je...@cu...> - 2003-08-22 09:16:29
|
Happy to accept anything anyones got to offer. The general proceddure for submissions is to create a patch files cvs diff -u > diff.txt and send it into the dev list with any new files you have. Someone will then look at it and either commit it straight away, commit it with minor alterations or provide feedback as to more significant changes that need to be made before it's commited. As a little note smaller patches submitted more frequently are easier for us to intergrate and six months of work in one huge patch file (release early, release often. small iterations...) On Fri, 2003-08-22 at 07:27, Tony Obermeit wrote: > Out of necessity I've made changes to the MockDatabaseMetaData class and > added implementation for a number of methods..... > > getDatabaseProductName()); > getDatabaseProductVersion()); > getDriverVersion()); > getDriverMajorVersion()); > getDriverMinorVersion()); > getCatalogTerm()); > getSchemaTerm()); > getProcedureTerm()); > getMaxColumnsInTable()); > getMaxColumnsInSelect()); > getMaxColumnNameLength()); > getDriverName()); > getURL()); > getUserName()); > getSearchStringEscape()); > getSQLKeywords()); > getNumericFunctions()); > getStringFunctions()); > getTimeDateFunctions()); > getSystemFunctions()); > > I'm happy and keen to contribute these changes to the project but did not > see any link or suggestions on the home page that tells me how to > contribute or what standards to follow. These methods were simple to > implement however I did provided default values for each of these > properties which means a user of the mock object doesn't necessarily have > to run the setup methods. If that is considered bad form, I'll gladly > remove the defaults. > > If required to be able to contribute, I'm happy to implement more methods > than those listed above, those were just the first ones I needed to use for > my application. > > Additionally, I want to add a setup method that will cause a SQLException > to be thrown if accessing the getDatabaseProductName method which will > allow me to accomplish 100% code coverage of a particular area of my > code. Is such a method acceptable? > > I appreciate the help that has been given me on this list lately, I'm quite > keen to become involved but have stuck to the non dynamic mock objects > because they work a little better for me at the moment. I'm sure I can be > persuaded as time goes on.... > > thanks > > Tony > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: VM Ware > With VMware you can run multiple operating systems on a single machine. > WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines > at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0 > _______________________________________________ > Mockobjects-java-users mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users -- Jeff Martin Memetic Engineer http://www.custommonkey.org/ |
From: Tony O. <to...@co...> - 2003-08-22 06:27:59
|
Out of necessity I've made changes to the MockDatabaseMetaData class and added implementation for a number of methods..... getDatabaseProductName()); getDatabaseProductVersion()); getDriverVersion()); getDriverMajorVersion()); getDriverMinorVersion()); getCatalogTerm()); getSchemaTerm()); getProcedureTerm()); getMaxColumnsInTable()); getMaxColumnsInSelect()); getMaxColumnNameLength()); getDriverName()); getURL()); getUserName()); getSearchStringEscape()); getSQLKeywords()); getNumericFunctions()); getStringFunctions()); getTimeDateFunctions()); getSystemFunctions()); I'm happy and keen to contribute these changes to the project but did not see any link or suggestions on the home page that tells me how to contribute or what standards to follow. These methods were simple to implement however I did provided default values for each of these properties which means a user of the mock object doesn't necessarily have to run the setup methods. If that is considered bad form, I'll gladly remove the defaults. If required to be able to contribute, I'm happy to implement more methods than those listed above, those were just the first ones I needed to use for my application. Additionally, I want to add a setup method that will cause a SQLException to be thrown if accessing the getDatabaseProductName method which will allow me to accomplish 100% code coverage of a particular area of my code. Is such a method acceptable? I appreciate the help that has been given me on this list lately, I'm quite keen to become involved but have stuck to the non dynamic mock objects because they work a little better for me at the moment. I'm sure I can be persuaded as time goes on.... thanks Tony |
From: <ro...@ep...> - 2003-08-22 00:01:56
|
Try having request expect and return (HttpSession)session.proxy() ------------------------------------------------------------------------ ------------------------------------------------------------------------ protected void setUp() throws Exception { action =3D new MyAction();// Struts based action... mapping =3D new ActionMapping();// More struts... form =3D new DynaActionForm();// Isn't struts grand? request =3D new Mock(HttpServletRequest.class); response =3D new Mock(HttpServletResponse.class); session =3D new Mock(HttpSession.class); =20 request.expectAndReturn("getSession", session); } =20 public void testSessionIsInRequest() throws Exception { ActionForward expected =3D new ActionForward("success", "path", false); ActionForward actual =3D action.doExecute(mapping, form, (HttpServletRequest)request.proxy(), (HttpServletResponse)response.proxy()); assertEquals(expected.getName(), actual.getName()); request.verify(); response.verify(); session.verify(); } =20 |
From: Steve F. <st...@m3...> - 2003-08-20 01:21:29
|
Sorry. These methods are currently called match[...]. Tony Obermeit wrote: > Hmmm. Now I'm a bit confused. I've checked the methods in the Mock > object and I can't see any setup methods. The idea of a setup method > rather than an expection, or as you put it, just get the thing working > and don't check the calls sounds great for the type of test I want. > > Thanks > >> The short answer is no, because that's the point of what you're testing. >> That said, you can use setup methods, rather than expectation, if you >> just want to get the thing to work and don't want to check the calls. We >> have some ideas about how to make things more flexible in the dynamic >> mock world. > > -- "A LISP programmer knows the value of everything but the cost of nothing. A C programmer knows the cost of everything but the value of nothing." (Todd Proebsting) |
From: Tony O. <to...@co...> - 2003-08-19 10:37:52
|
Hmmm. Now I'm a bit confused. I've checked the methods in the Mock object and I can't see any setup methods. The idea of a setup method rather than an expection, or as you put it, just get the thing working and don't check the calls sounds great for the type of test I want. Thanks >The short answer is no, because that's the point of what you're testing. > That said, you can use setup methods, rather than expectation, if you >just want to get the thing to work and don't want to check the calls. We >have some ideas about how to make things more flexible in the dynamic >mock world. |
From: Steve F. <st...@m3...> - 2003-08-18 20:01:22
|
Tony Obermeit wrote: > Thanks so much for your quick reply, I really appreciate you taking the > time to respond. > It seems to me that with the Mock HttpServletRequest, I have to predict > all the calls that will be made to the mock object. In the case of the > code above, the calls were made by a utility method that parses > httpRequestParameters and returns the value regardless of case, that is > why the getParameter snippet above had to be called twice. > > Is there any way to avoid having to predict all the calls that will be > made? The short answer is no, because that's the point of what you're testing. That said, you can use setup methods, rather than expectation, if you just want to get the thing to work and don't want to check the calls. We have some ideas about how to make things more flexible in the dynamic mock world. > Additionally, I'd like to contribute my Case Study of using the older > MockHttpServletRequest object along with using the new dynamic Mock in > the same context, what is the protocol within this group for making such > a contribution. Do you simply want me to create my own topic within the > wiki or do you want the entire code from my Case Study possibly put into > an examples package? I have a unit test class that has 9 distinct tests > for the utility parseParameter method I wrote in order to study > implementation of mock objects. Would you like to write it up on the wiki? We don't need all the code, just enough to make the point. Thanks S. |
From: Tony O. <to...@co...> - 2003-08-18 10:05:10
|
Steve, Thanks so much for your quick reply, I really appreciate you taking the time to respond. As it turned out, the expectAndReturn call ended up being slightly different to what you suggested because the return value of getParameterNames is an Enumeration, not an Object array.... Here is the snippet of code that worked for me.... Mock mockRequest = new Mock(javax.servlet.http.HttpServletRequest.class); Hashtable hash = new Hashtable(); hash.put("PARAM1","Value1"); mockRequest.expectAndReturn("getParameter","Param1",null); mockRequest.expectAndReturn("getParameter","PARAM1","value1"); mockRequest.expectAndReturn("getParameterNames", hash.keys()); It seems to me that with the Mock HttpServletRequest, I have to predict all the calls that will be made to the mock object. In the case of the code above, the calls were made by a utility method that parses httpRequestParameters and returns the value regardless of case, that is why the getParameter snippet above had to be called twice. Is there any way to avoid having to predict all the calls that will be made? Additionally, I'd like to contribute my Case Study of using the older MockHttpServletRequest object along with using the new dynamic Mock in the same context, what is the protocol within this group for making such a contribution. Do you simply want me to create my own topic within the wiki or do you want the entire code from my Case Study possibly put into an examples package? I have a unit test class that has 9 distinct tests for the utility parseParameter method I wrote in order to study implementation of mock objects. cheers Tony >>I've used the j2ee v1.2 MockHttpServletRequest and added code to the [..] >>that had methods, if the method you wanted wasn't implemented, you added >>an implementation. > >exactly! > >>Now I'm trying to use the latest j2ee mock objects >>(mockobjects-jdk1.4-j2ee1.3-0.09.jar) which require the use of Dynamic >>Mock objects. I've followed the documentation to be able to test the >>getParameter method but have no idea of how to set up the >>getParameterNames method. > >I woudl guess that you use expectAndReturn("getParameterNames", > new Object[] {"one", "two"}); > >>I cannot find any documentation or examples of dynamic mock objects that >>goes beyond the simple example above and am subsequently stuck. Any help >>is appreciated, otherwise I'll go back to the j2ee 1.2 mock library, I >>was really hoping to move forward with the new dynamic approach but the >>lack of examples and my inexperience with dynamic mocks is holding me up. > >it's still a work in progress, which is why we haven't packaged it up yet. >The basics are quite simple, it tries to match a method call and return a >value if appropriate. If an expectation is set it will check that, >otherwise it'll just match. The rest is a rather messy implementation that >still needs cleanup. |
From: <sea...@ce...> - 2003-08-17 23:34:49
|
Hi all I have just revisited this problem. What I did was to modify the Mock class. I'm not sure if it was the "right" thing to do, but it works for me and it may help someone else. I added these two methods to Mock.java public void expectAndReturn(String methodName, Object singleEqualArg, Callable result) { this.expectAndReturn(methodName, createConstraintMatcher(singleEqualArg), result); } public void expectAndReturn(String methodName, ConstraintMatcher args, Callable stub) { callSequence.addExpect(callFactory.createCallExpectation(callFactory.createCallSignature(methodName, args, stub))); } Now I can do this (using the original example): // Note: final so they can be used by the anonymous inner class final ResultSetHandler resultSetHandler = .... final Mock mockResultSet = new Mock(ResultSet.class); Mock mockSQLExecuter = new Mock(SQLExecuter.class); mockSQLExecuter.expectAndReturn( "execute", C.eq( expectedSQL, expectedBindVariables, resultSetHandler ), (Callable)new ReturnStub() { public Object call(Mock mock, String methodName, Object[] args) throws Throwable { resultSetHandler.handle( (ResultSet)mockResultSet.proxy() ); return super.call( mock, methodName, args ); } } ); What do you think? Sean. >I have just started using Dynamic Mocks in MockObjects v0.09. >On the MockObjects wiki (http://mockobjects.com/wiki/CallableDecorators) >there is a discussion about writing a custom stub when you want to mock a >method that has side-effects. The example given is: >// Note: final so they can be used by the anonymous inner class >final ResultSetHandler resultSetHandler = .... >final Mock mockResultSet = new Mock(ResultSet.class); >Mock mockSQLExecuter = new Mock(SQLExecuter.class); >mockSQLExecuter.add( > new CallOnceExpectation( > new CallSignature( "execute", C.eq( expectedSQL, >expectedBindVariables, resultSetHandler ) ), > new VoidStub() { > public void getDescription() { > return super.getDescription() + " [calls back to >resultSetHandler]"; > } > public Object call( String methodName, Object[] args ) { > resultSetHandler.handle( (ResultSet)mockResultSet.proxy() ); > return super.call( methodName, args ); // stubs the void >result > } > } ) ) ); >I need to do something similar, but this approach does not seem to be >supported. >For example, there is no Mock.add method, or any means to supply a custom >CallStub. >What is the currently recommended approach, or am I missing something? Important: This e-mail is intended for the use of the addressee and may contain information that is confidential, commercially valuable or subject to legal or parliamentary privilege. If you are not the intended recipient you are notified that any review, re-transmission, disclosure, use or dissemination of this communication is strictly prohibited by several Commonwealth Acts of Parliament. If you have received this communication in error please notify the sender immediately and delete all copies of this transmission together with any attachments. |
From: Steve F. <st...@m3...> - 2003-08-17 22:04:08
|
Tony Obermeit wrote: > I've used the j2ee v1.2 MockHttpServletRequest and added code to the > [..] > that had methods, if the method you wanted wasn't implemented, you added > an implementation. exactly! > Now I'm trying to use the latest j2ee mock objects > (mockobjects-jdk1.4-j2ee1.3-0.09.jar) which require the use of Dynamic > Mock objects. I've followed the documentation to be able to test the > getParameter method but have no idea of how to set up the > getParameterNames method. I woudl guess that you use expectAndReturn("getParameterNames", new Object[] {"one", "two"}); > I cannot find any documentation or examples of dynamic mock objects that > goes beyond the simple example above and am subsequently stuck. Any > help is appreciated, otherwise I'll go back to the j2ee 1.2 mock > library, I was really hoping to move forward with the new dynamic > approach but the lack of examples and my inexperience with dynamic mocks > is holding me up. it's still a work in progress, which is why we haven't packaged it up yet. The basics are quite simple, it tries to match a method call and return a value if appropriate. If an expectation is set it will check that, otherwise it'll just match. The rest is a rather messy implementation that still needs cleanup. S. |
From: Tony O. <to...@co...> - 2003-08-16 22:58:26
|
I've used the j2ee v1.2 MockHttpServletRequest and added code to the class to implement new methods that were previously un-implemented. So, I have a degree of familiarity with Mock Objects that do not use the Dynamic Mock pattern, they seemed quite easy to use, just a java class that had methods, if the method you wanted wasn't implemented, you added an implementation. Now I'm trying to use the latest j2ee mock objects (mockobjects-jdk1.4-j2ee1.3-0.09.jar) which require the use of Dynamic Mock objects. I've followed the documentation to be able to test the getParameter method but have no idea of how to set up the getParameterNames method. Mock mockRequest = new Mock(javax.servlet.http.HttpServletRequest.class); mockRequest.expectAndReturn("getParameter", "param1", "value1"); HttpServletRequest _request = (HttpServletRequest)mockRequest.proxy(); System.out.println("param = " + _request.getParameter("param1")); // Works well!!!!! I cannot find any documentation or examples of dynamic mock objects that goes beyond the simple example above and am subsequently stuck. Any help is appreciated, otherwise I'll go back to the j2ee 1.2 mock library, I was really hoping to move forward with the new dynamic approach but the lack of examples and my inexperience with dynamic mocks is holding me up. Tony |
From: <gma...@cl...> - 2003-08-16 16:04:45
|
Thanks for you reply, I did not understand I had to write such kind of initial setup code, now it's clear. Gael |
From: Steve F. <st...@m3...> - 2003-08-16 15:11:53
|
I think we just answered this one. We are not trying to reproduce the servlet request behaviour, we are=20 trying to instrument a stub that will get us through the test and tell=20 us if the right things happened. If you expect to get a header that is=20 not set, then you should call setupAddHeader("header name", null) -- or=20 whatever the call is -- which will confirm that the client code=20 requested the right header field, and then return a preset value, null.=20 How else can we ensure that your target code has not called an=20 unexpected header? S. Ga=EBl Marziou wrote: > Hello, >=20 > I'm new to mockobjects, so I may have got something wrong. >=20 > In MockHttpServletRequest version 1.18 (J2EE 1.3), the > getHeader() method should not throw an AssertFailError > when the requested header is not present because the > javadoc for this method says: >=20 > If the request did not include a header of the specified > name, this method returns null. >=20 > So, with the current behavior I cannot test my code > error handling when request.getHeader() returns null on > not existing header. >=20 > Or maybe there is a way to disable this assertion > checking? >=20 > Thanks for any help >=20 > Ga=EBl >=20 >=20 >=20 >=20 > ------------------------------------------------------- > This SF.Net email sponsored by: Free pre-built ASP.NET sites including > Data Reports, E-commerce, Portals, and Forums are available now. > Download today and enter to win an XBOX or Visual Studio .NET. > http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_0= 1/01 > _______________________________________________ > Mockobjects-java-users mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users |
From: <gma...@cl...> - 2003-08-16 14:13:52
|
Hello, I'm new to mockobjects, so I may have got something wrong. In MockHttpServletRequest version 1.18 (J2EE 1.3), the getHeader() method should not throw an AssertFailError when the requested header is not present because the javadoc for this method says: If the request did not include a header of the specified name, this method returns null. So, with the current behavior I cannot test my code error handling when request.getHeader() returns null on not existing header. Or maybe there is a way to disable this assertion checking? Thanks for any help Ga=EBl |
From: SADER, K. D (Contractor) <KEI...@DF...> - 2003-08-12 16:50:39
|
Greetings. I've got the following test case: //Hand waving declarations... Mock request; Mock response; Mock session; protected void setUp() throws Exception { action =3D new MyAction();// Struts based action... mapping =3D new ActionMapping();// More struts... form =3D new DynaActionForm();// Isn't struts grand? request =3D new Mock(HttpServletRequest.class); response =3D new Mock(HttpServletResponse.class); session =3D new Mock(HttpSession.class); request.expectAndReturn("getSession", session); } public void testSessionIsInRequest() throws Exception { ActionForward expected =3D new ActionForward("success", "path", = false); ActionForward actual =3D action.doExecute(mapping, form, (HttpServletRequest)request.proxy(), = (HttpServletResponse)response.proxy()); assertEquals(expected.getName(), actual.getName()); request.verify(); response.verify(); session.verify(); } // Code under test... public ActionForwad doExecute(ActionMapping mapping, ActionForm form, = HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession sess =3D request.getSession(); return mapping.findForward("success"); } The problem I'm having is that the code in doExecute throws a = ClassCastException on request. java.lang.ClassCastException: com.mockobjects.dynamic.Mock at $Proxy24.getSession()(Unknown Source) ...doExecute() ...testSessionIsInRequest() What am I doing wrong here? By my interpretation of the examples this = code *should* work. What am I missing? thanks, --- Keith Sader Nash Resources Group sub-contracting for Computer Sciences Corporation IAD:TFAS Email:kei...@df... We've got a blind date with destiny, and it looks like she ordered the = lobster. |
From: Zart C. <za...@wa...> - 2003-08-08 10:07:58
|
On vendredi, ao=FB 8, 2003, at 10:55 Europe/Paris, st...@m3... = wrote: > > On 8 August, 2003, Zart Colwin wrote: >> I'm new to Mock-Object and I'm wondering where to found the >> documentation explaining how to setup and use the mockobjects-0.09 >> library. I'm thinking about a tutorial or a cookbook like the ones = you >> can found with JUnit. > > first question. Have you read any of the papers listed at: > > http://www.mockobjects.com/wiki/MocksObjectsPaper Yes, I've read them all. I pretty much understand the theory and =20 benefits of Mock-Objects. Where I'm stuck is when I try to understand the mockobjects-0.09 =20 library itself. For an example, I'm currently in the process of learning the =20 EasyMock1.0RC library, I have no problem so far, I'm reading their, =20 small but instructive, documentation, following their instructions to =20= build my first example. Then, when I need to, I consult their fairly =20 well documented JavaDoc to have more info. Having a step by step cookbook to help me build the first few examples =20= is much more valuable than just having undocumented samples ready to =20 run. A cookbook is actually teaching me something, while the samples =20 are just a proof that the software is working and leave me completely =20= stand still if I don't have enough knowledge to begin with. That leads me directly to the lack of documentation accompanying =20 mockobjects-0.09. mockobjects-0.09 is a complex library with no less than 160 classes and =20= 20 interfaces. The com.mockobjects package, which I suspect is the more important =20 package of the lib, contains more than 15 classes, almost none of them =20= are documented ! How m'I supposed to learn and understand the =20 mechanics of all this ? How do you think beginners are feeling facing =20= such an opaque and hermetic library ? Personally I've switched to EasyMock1.0RC, because I don't have the =20 time nor the willing to decipher the ins and outs of mockobjects-0.09. =20= And, because I'm the tech-leader, in charge to educate my fellows, =20 everybody here will use EasyMock1.0RC instead of mockobjects-0.09. If you want peoples to use mockobjects-0.09, and for it to become a =20 standard like JUnit did, just don't place the entry level 36,000 feet =20= high ! ZC. > > S. > > > ------------------------------------------------------- > This SF.Net email sponsored by: Free pre-built ASP.NET sites including > Data Reports, E-commerce, Portals, and Forums are available now. > Download today and enter to win an XBOX or Visual Studio .NET. > http://aspnet.click-url.com/go/psa00100003ave/=20 > direct;at.aspnet_072303_01/01 > _______________________________________________ > Mockobjects-java-users mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users > |
From: <st...@m3...> - 2003-08-08 08:55:40
|
On 8 August, 2003, Zart Colwin wrote: > I'm new to Mock-Object and I'm wondering where to found the=20 > documentation explaining how to setup and use the mockobjects-0.09=20 > library. I'm thinking about a tutorial or a cookbook like the ones you=20 > can found with JUnit. first question. Have you read any of the papers listed at: http://www.mockobjects.com/wiki/MocksObjectsPaper S. |
From: Zart C. <za...@wa...> - 2003-08-08 08:34:51
|
Hi, I'm new to Mock-Object and I'm wondering where to found the documentation explaining how to setup and use the mockobjects-0.09 library. I'm thinking about a tutorial or a cookbook like the ones you can found with JUnit. The JavaDoc is pretty useless for a beginner as it is, for a very large part, just a catalog of undocumented classes and methods. The examples are not enlightening either due to the lack of comments. According to the list archive, it has been said, back in Wednesday, August 15, 2001, that <<[documentation] is still a work in progress... We are currently working hard on the documentation as we agree with your comment that it is the weak point ...>> Does this work leads to a paper that can help beginners understand the library architecture and philosophy, and help them in writing their first Mock-Objects ? ZC. |
From: <sea...@ce...> - 2003-07-28 01:56:08
|
Hi all I have just started using Dynamic Mocks in MockObjects v0.09. On the MockObjects wiki (http://mockobjects.com/wiki/CallableDecorators) there is a discussion about writing a custom stub when you want to mock a method that has side-effects. The example given is: // Note: final so they can be used by the anonymous inner class final ResultSetHandler resultSetHandler = .... final Mock mockResultSet = new Mock(ResultSet.class); Mock mockSQLExecuter = new Mock(SQLExecuter.class); mockSQLExecuter.add( new CallOnceExpectation( new CallSignature( "execute", C.eq( expectedSQL, expectedBindVariables, resultSetHandler ) ), new VoidStub() { public void getDescription() { return super.getDescription() + " [calls back to resultSetHandler]"; } public Object call( String methodName, Object[] args ) { resultSetHandler.handle( (ResultSet)mockResultSet.proxy() ); return super.call( methodName, args ); // stubs the void result } } ) ) ); I need to do something similar, but this approach does not seem to be supported. For example, there is no Mock.add method, or any means to supply a custom CallStub. What is the currently recommended approach, or am I missing something? Thanks Sean. Important: This e-mail is intended for the use of the addressee and may contain information that is confidential, commercially valuable or subject to legal or parliamentary privilege. If you are not the intended recipient you are notified that any review, re-transmission, disclosure, use or dissemination of this communication is strictly prohibited by several Commonwealth Acts of Parliament. If you have received this communication in error please notify the sender immediately and delete all copies of this transmission together with any attachments. |
From: Praveen S. <pra...@ho...> - 2003-07-21 16:11:08
|
Hi, When I setup rows in the MockMultiRowResultSet and try to retrieve it, the date is getting corrupted. The input is rows[0][0] = new java.sql.Date(2003, 7, 21); but I am getting the output as 3903-08-21 Thanks, Praveen ------------------------- import com.mockobjects.sql.*; public class ProxyDataBase { private static String dateFormat = new String("MM/dd/yyyy HH:mm:ss"); public static void main(String[] args) { try { MockMultiRowResultSet multiResultSet = new MockMultiRowResultSet(); Object[][] rows = new Object[1][3]; rows[0] = new Object[3]; rows[0][0] = new java.sql.Date(2003, 7, 21); rows[0][1] = new Double("1.2"); rows[0][2] = new String("String1"); multiResultSet.setupRows(rows); java.util.Date dt = null; while (multiResultSet.next()) { System.out.println(multiResultSet.getDate(1)); System.out.println(multiResultSet.getDouble(2)); System.out.println(multiResultSet.getString(3)); } } catch (Exception e) { e.printStackTrace(); } } } ------------------------- _________________________________________________________________ Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail |
From: Nat P. <nat...@b1...> - 2003-07-18 13:52:56
|
We've talked about that and I think everybody agrees that it's a good idea. It's just that nobody has implemented it yet. I think that their should be an overloaded version that takes a String that means the same as passing an IsEqual constraint. Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 ----- Original Message ----- From: "Joe Walnes" <jo...@tr...> To: "Nat Pryce" <nat...@b1...> Cc: <moc...@li...> Sent: Friday, July 18, 2003 9:27 AM Subject: Re: [MO-java-users] RegEx-like method names for matchAndReturn? > Not sure if this has been mentioned yet... > > It would be much more flexible if the first argument of all the match > and expect methods (i.e. the name) took a Constraint instead of a String. > > -joe > > Nat Pryce wrote: > > >The MockObjects website has example code that does almost exactly what you > >want. > > > >Look at http://www.mockobjects.com/wiki/CallableDecorators > > > >Cheers, > > Nat. > >_______________________ > >Dr. Nathaniel Pryce > >B13media Ltd. > >http://www.b13media.com > >+44 (0)7712 526 661 > > > >----- Original Message ----- > >From: <mai...@ji...> > >To: <moc...@li...> > >Sent: Thursday, July 17, 2003 7:26 PM > >Subject: [MO-java-users] RegEx-like method names for matchAndReturn? > > > > > > > > > >>Is there any way to have Mock.matchAndReturn() match against method > >>names using wildcards? For example, I'd like to: > >> > >>Mock mock = new Mock( InterfaceWithLotsOfBooleans.class ); > >>mock.matchAndReturn( "is*", false ); > >> > >>Which for any isProperty method call would return false. > >> > >>I figure that some kind of callable subclass is necessary, but with very > >>little in the way of javadocs (and the unit tests aren't helpful here), > >>I don't know where to go. > >> > >>;ted > >> > >> > >> > >>------------------------------------------------------- > >>This SF.net email is sponsored by: VM Ware > >>With VMware you can run multiple operating systems on a single machine. > >>WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the > >>same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 > >>_______________________________________________ > >>Mockobjects-java-users mailing list > >>Moc...@li... > >>https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users > >> > >> > > > > > > > >------------------------------------------------------- > >This SF.net email is sponsored by: VM Ware > >With VMware you can run multiple operating systems on a single machine. > >WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the > >same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 > >_______________________________________________ > >Mockobjects-java-users mailing list > >Moc...@li... > >https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users > > > > > > |