You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(13) |
Aug
(151) |
Sep
(21) |
Oct
(6) |
Nov
(70) |
Dec
(8) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(47) |
Feb
(66) |
Mar
(23) |
Apr
(115) |
May
(24) |
Jun
(53) |
Jul
(10) |
Aug
(279) |
Sep
(84) |
Oct
(149) |
Nov
(138) |
Dec
(52) |
2003 |
Jan
(22) |
Feb
(20) |
Mar
(29) |
Apr
(106) |
May
(170) |
Jun
(122) |
Jul
(70) |
Aug
(64) |
Sep
(27) |
Oct
(71) |
Nov
(49) |
Dec
(9) |
2004 |
Jan
(7) |
Feb
(38) |
Mar
(3) |
Apr
(9) |
May
(22) |
Jun
(4) |
Jul
(1) |
Aug
(2) |
Sep
(2) |
Oct
|
Nov
(15) |
Dec
(2) |
2005 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
(1) |
May
(28) |
Jun
(3) |
Jul
(11) |
Aug
(5) |
Sep
(1) |
Oct
(5) |
Nov
(2) |
Dec
(3) |
2006 |
Jan
(8) |
Feb
(3) |
Mar
(8) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Jeff M. <cus...@us...> - 2004-01-31 06:37:14
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16408/src/j2ee/1.3/com/mockobjects/servlet Modified Files: MockHttpSession.java Log Message: Added support fo getId Index: MockHttpSession.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpSession.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MockHttpSession.java 1 May 2003 09:19:25 -0000 1.5 +++ MockHttpSession.java 29 Jan 2004 14:08:32 -0000 1.6 @@ -14,6 +14,7 @@ private Enumeration attributeNames; private ServletContext servletContext; + private final ReturnValue id = new ReturnValue("id"); public Object getAttribute(String anAttributeName) { return myAttributeValues.getNextReturnObject(anAttributeName); @@ -33,8 +34,11 @@ } public String getId() { - notImplemented(); - return null; + return (String)id.getValue(); + } + + public void setupGetId(String id) { + this.id.setValue(id); } public long getLastAccessedTime() { |
From: Jeff Martin<je...@cu...> - 2004-01-31 01:25:01
|
Project: mockobjects State: Failed URL: http://gump.dotnot.org/mockobjects/mockobjects.html RSS: http://gump.dotnot.org/mockobjects/mockobjects.rss Atom: http://gump.dotnot.org/mockobjects/mockobjects.atom ------------------------------------------------- G U M P Y Annotations: - Info - Made directory [/var/gump/mockobjects/out/core/classes] - Info - Made directory [/var/gump/mockobjects/out/jdk/classes] - Error - Failed with reason build failed ------------------------------------------------- G U M P Y Work Type: Build State: Failed Elapsed: 0 hours, 0 minutes, 10 seconds Command Line: java -Djava.awt.headless=true -Xbootclasspath/p:/var/gump/xml-xerces2/java/build/xercesImpl.jar:/var/gump/xml-xerces2/java/build/xmlParserAPIs.jar org.apache.tools.ant.Main -Dbuild.clonevm=true -Dgump.merge=/home/gump/jakarta-gump/work/merge.xml -Dbuild.sysclasspath=only -Dproject.version=20040129 CWD: /var/gump/mockobjects --------------------------------------------- [javac] symbol : class Arguments [javac] location: interface com.mockobjects.dynamic.InvocationMatcher [javac] InvocationMatcher.Arguments matcher = new InvocationMatcher.Arguments(new Constraint[0]); [javac] ^ [javac] /var/gump/mockobjects/src/core/test/mockobjects/dynamic/InvocationMatcherTest.java:51: cannot resolve symbol [javac] symbol : class Arguments [javac] location: interface com.mockobjects.dynamic.InvocationMatcher [javac] InvocationMatcher.Arguments matcher = new InvocationMatcher.Arguments(new Constraint[0]); [javac] ^ [javac] /var/gump/mockobjects/src/core/test/mockobjects/dynamic/InvocationMatcherTest.java:51: cannot resolve symbol [javac] symbol : class Arguments [javac] location: interface com.mockobjects.dynamic.InvocationMatcher [javac] InvocationMatcher.Arguments matcher = new InvocationMatcher.Arguments(new Constraint[0]); [javac] ^ [javac] /var/gump/mockobjects/src/core/test/mockobjects/dynamic/InvocationMatcherTest.java:57: cannot resolve symbol [javac] symbol : class Arguments [javac] location: interface com.mockobjects.dynamic.InvocationMatcher [javac] InvocationMatcher.Arguments matcher = [javac] ^ [javac] /var/gump/mockobjects/src/core/test/mockobjects/dynamic/InvocationMatcherTest.java:58: cannot resolve symbol [javac] symbol : class Arguments [javac] location: interface com.mockobjects.dynamic.InvocationMatcher [javac] new InvocationMatcher.Arguments( [javac] ^ [javac] /var/gump/mockobjects/src/core/test/mockobjects/dynamic/InvocationMatcherTest.java:65: cannot resolve symbol [javac] symbol : class Arguments [javac] location: interface com.mockobjects.dynamic.InvocationMatcher [javac] InvocationMatcher.Arguments matcher = [javac] ^ [javac] /var/gump/mockobjects/src/core/test/mockobjects/dynamic/InvocationMatcherTest.java:66: cannot resolve symbol [javac] symbol : class Arguments [javac] location: interface com.mockobjects.dynamic.InvocationMatcher [javac] new InvocationMatcher.Arguments( [javac] ^ [javac] /var/gump/mockobjects/src/core/test/mockobjects/dynamic/InvocationMatcherTest.java:73: cannot resolve symbol [javac] symbol : class Arguments [javac] location: interface com.mockobjects.dynamic.InvocationMatcher [javac] InvocationMatcher.Arguments matcher = [javac] ^ [javac] /var/gump/mockobjects/src/core/test/mockobjects/dynamic/InvocationMatcherTest.java:74: cannot resolve symbol [javac] symbol : class Arguments [javac] location: interface com.mockobjects.dynamic.InvocationMatcher [javac] new InvocationMatcher.Arguments( [javac] ^ [javac] 23 errors BUILD FAILED /var/gump/mockobjects/build.xml:121: Compile failed; see the compiler error output for details. Total time: 9 seconds --------------------------------------------- -- Gump http://jakarta.apache.org/gump [nyx.stonecobra.com] |
From: <kma...@rs...> - 2004-01-27 14:58:36
|
The message cannot be represented in 7-bit ASCII encoding and has been sent as a binary attachment. |
From: shivaken <shi...@e-...> - 2004-01-21 05:55:18
|
Hi, When I was using MockHttpSession (mockobjects-jdk1.4-j2ee1.3-0.09.jar ), I noticed MockHttpSession is not implemented. To test my applications, I had to use that method. So, I wrote a patch for that. It contains setupGetId() and getId(). -- -- shivaken antshell: Ant command line front end http://www.antshell.org |
From: Steve F. <st...@m3...> - 2003-12-13 18:05:49
|
I've been through your example and can't see anything obvious. Can you include the MO source code and use your debugger to see what's in the Mock? One of the annoying things about a cast exception is that it doesn't tell you what the actual class of the object is. Steve p.s. what were your problems with the mailing list? |
From: Cruz, E. J. <e....@ra...> - 2003-12-11 20:44:41
|
Hi, First I apologize for sending this to this list but the user list keeps bouncing the message. I have an interface described below. interface AccountBusiness { public UserTo authenticateUser(AccountTo account); } interface AccountDao { public AccountBusiness getAccount(account); } I have a method that uses this interface below: public UserTo authenticateUser(AccountTo account) { AccountBusiness accountBusiness = null; accountBusiness = getAccount(account); /** Some more stuff to perform authentication */ } private AccountBusiness getAccount(accounTo account) { AccountBusiness accountBusiness = null; try { defaultDaoManager.startTransaction(); /** This is the line that causes the error */ accountBusiness = accountDao.getAccount(account); defaultDaoManager.commitTransaction(); } catch (DaoException de) { try { defaultDaoManager.rollbackTransaction(); } catch (DaoException de2) { log.error(de.getMessage(), de); throw new ResourceException(de); } return accountBusiness; } I am trying to test this method using Mock Objects. I have the following code to test this: public class AccountAppServiceTest extends TestCase { private AccountAppService accountAppService = null; private AccountTo account = null; private DaoManager defaultDaoManager = null; private Mock accountDao = null; protected void setUp() throws Exception { super.setUp(); defaultDaoManager = new DaoManagerMock(); accountDao = new Mock(AccountDAO.class); accountAppService = new AccountAppService (defaultDaoManager, (AccountDAO)accountDao.proxy()); account = new AccountTo(); account.setUsername("ecruz"); account.setPassword("testing"); account.setStatus("Active"); account.setBadPasswordCounter(2); account.setDatePasswordChanged(new Date()); account.setFirstLogin(true); } public void testAuthenticateUser() { //Setup Mock returnMock = new Mock(AccountBusiness.class); UserTo expectedUser = new UserTo(account.getUsername()); List expectedRoles = new ArrayList(); expectedRoles.add("test"); expectedRoles.add("test1"); AccountBusiness returnVal = (AccountBusiness)returnMock.proxy(); /** Here I tell it to expect the call to the accountDao getAccount method and to return the AccountBusiness Mock proxy but I receive the error below.*/ accountDao.expectAndReturn("getAccount", C.eq(account), (AccountBusiness)returnMock.proxy()); returnMock.expectAndReturn("authenticateUser", C.eq(account), expectedUser); accountDao.expectAndReturn("getAccountRoles", C.eq(account), expectedRoles); UserTo actualUser = null; //Run try { actualUser = accountAppService.authenticateUser(account); } catch (Exception e) { e.printStackTrace(); this.fail("Unexpected Exception reported " + e.toString()); } //Validate this.assertEquals("Unexpected UserName: ", expectedUser.getUserName(), actualUser.getUserName()); this.assertEquals("Unexpected Roles: ", expectedRoles, actualUser.getRoles()); accountDao.verify(); returnMock.verify(); } protected void tearDown() throws Exception { // Set everything to null } } I receive this error when the accountDao.getAccount(account) method is called above in the private getAccount method of the AccountAppService. I use the same type of return value in the expect in another test case and I do not get any errors. Any Suggestions on what this may be? [junit] ------------- Standard Error ----------------- [junit] java.lang.ClassCastException [junit] at $Proxy0.getAccount(Unknown Source) [junit] at gov.wos.domain.account.AccountAppService.getAccount(Unknown Source) [junit] at gov.wos.domain.account.AccountAppService.authenticateUser(Unknown Source) [junit] at gov.wos.domain.account.AccountAppServiceTest.testAuthenticateUser(Unknown Source) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) [junit] at java.lang.reflect.Method.invoke(Method.java:324) [junit] at junit.framework.TestCase.runTest(TestCase.java:154) [junit] at junit.framework.TestCase.runBare(TestCase.java:127) [junit] at junit.framework.TestResult$1.protect(TestResult.java:106) [junit] at junit.framework.TestResult.runProtected(TestResult.java:124) [junit] at junit.framework.TestResult.run(TestResult.java:109) [junit] at junit.framework.TestCase.run(TestCase.java:118) [junit] at junit.framework.TestSuite.runTest(TestSuite.java:208) [junit] at junit.framework.TestSuite.run(TestSuite.java:203) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRu nner.java:325) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestR unner.java:524) [junit] ------------- ---------------- --------------- [junit] Testcase: testAuthenticateUser(gov.wos.domain.account.AccountAppServiceTest): FAILED [junit] Unexpected Exception reported java.lang.ClassCastException [junit] junit.framework.AssertionFailedError: Unexpected Exception reported java.lang.ClassCastException [junit] at gov.wos.domain.account.AccountAppServiceTest.testAuthenticateUser(Unknown Source) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) Jamie Cruz Software Engineering e....@ra... (301)688-1430 ------_=_NextPart_000_01C3C025.C3736B30 Content-Type: application/octet-stream; name="Cruz, Edward J..vcf" Content-Disposition: attachment; filename="Cruz, Edward J..vcf" BEGIN:VCARD VERSION:2.1 N:Cruz;Edward FN:Cruz, Edward J. ADR;WORK:;Ops3 LABEL;WORK:Ops3 KEY;X509;ENCODING=BASE64: MIIEMzCCA5ygAwIBAgIDAnL2MA0GCSqGSIb3DQEBBQUAMGQxCzAJBgNVBAYTAlVTMRgwFgYD VQQKEw9VLlMuIEdvdmVybm1lbnQxDDAKBgNVBAsTA0RvRDEMMAoGA1UECxMDUEtJMR8wHQYD VQQDExZET0QgQ0xBU1MgMyBFTUFJTCBDQS0zMB4XDTAyMDMyMjIxMzAyN1oXDTA1MDMyMjIx MzAyN1oweDELMAkGA1UEBhMCVVMxGDAWBgNVBAoTD1UuUy4gR292ZXJubWVudDEMMAoGA1UE CxMDRG9EMQwwCgYDVQQLEwNQS0kxEDAOBgNVBAsTB05TQS9DU1MxITAfBgNVBAMTGENydXou RWR3YXJkLkouMDUxNDEwMTI2MjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA9MUBKNyq 6pcDEkrbH+sv05Roqv7PG6uL+atAiRgpUlqRuzuj8wPFBJLGGH4e+70Z9blnzGY/4vn6EXkw f7jB/MLHtEHrLgDQ200/U6rQdzylekHX3EDDdDLKHGfNvs7i8jV1IgllKEpegdEFB1KxDiVV zAT42fYkCBcvSpJ9UjkCAwEAAaOCAd0wggHZMA4GA1UdDwEB/wQEAwIFIDAfBgNVHSMEGDAW gBTsE1u8IYxmmwqLfwdfJbAU+RD1mzAdBgNVHQ4EFgQU4R9f7AAY4dzqNl3NcNrCUSiE0Y8w FgYDVR0gBA8wDTALBglghkgBZQIBCwUwIQYDVR0RBBowGIEWZS5jcnV6QHJhZGl1bS5uY3Nj Lm1pbDCBjwYDVR0SBIGHMIGEhoGBbGRhcDovL2VtYWlsLWRzLTMuYzNwa2kuY2hhbWIuZGlz YS5taWwvY24lM2RET0QlMjBDTEFTUyUyMDMlMjBFTUFJTCUyMENBLTMlMmNvdSUzZFBLSSUy Y291JTNkRG9EJTJjbyUzZFUuUy4lMjBHb3Zlcm5tZW50JTJjYyUzZFVTMIG5BgNVHR8EgbEw ga4wgauggaiggaWGgaJsZGFwOi8vZW1haWwtZHMtMy5jM3BraS5jaGFtYi5kaXNhLm1pbC9j biUzZERPRCUyMENMQVNTJTIwMyUyMEVNQUlMJTIwQ0EtMyUyY291JTNkUEtJJTJjb3UlM2RE b0QlMmNvJTNkVS5TLiUyMEdvdmVybm1lbnQlMmNjJTNkVVM/Y2VydGlmaWNhdGVyZXZvY2F0 aW9ubGlzdDtiaW5hcnkwDQYJKoZIhvcNAQEFBQADgYEADoL06sLf+jTdyMlDO68NbiOBlRQY rGF9ZJ+KpegMRpjSvb1Ep+B5GDBy5efWAm0fS24lhjDgzaeZ3F8VvSmM/on8Bg/lC2C7KM9P gTU4EljALhxUNpOKik+evQDApe+6FhGj0XrsjDIpcUMDoufhhO/nxl6A0qfi+P3l5brwzec= EMAIL;PREF;INTERNET:e....@ra... REV:20020409T180834Z END:VCARD ------_=_NextPart_000_01C3C025.C3736B30-- |
From: Steve F. <st...@m3...> - 2003-12-03 14:21:25
|
If we get to where we want to be, we should be able to provide ordered mocks with some sugar code. (promises, promises) S. chris cottee wrote: > I think you are right to go down the route of the API since if we still > want to keep our OrderedMocks we will probably just hide the use of the > API inside our own OrderedMock class, allowing us the best of both worlds. |
From: chris c. <drc...@ya...> - 2003-12-03 13:30:10
|
Hi Nat, I'm surprised that you found ordered Mocks brittle and unhelpful. In our code base we have 16 uses of OrderedMocks compared to 330 Mocks. This is a small percentage but I'd be loathe to give them up. We use OrderedMocks in "transactional type" code, that is in our transaction manager, and in our streaming code. We have n't found the tests were brittle and we (rewrote the error messages to be helpful )but looking at the code now this is plainly because the order that each of the methods is called always matters in these cases. I think you are right to go down the route of the API since if we still want to keep our OrderedMocks we will probably just hide the use of the API inside our own OrderedMock class, allowing us the best of both worlds. Cheers, Chris |
From: Nat P. <nat...@b1...> - 2003-12-02 17:22:25
|
The current dynamic mock class has explicit code to support returning the mock's name from a call to getMockName on the PROXY! I am confused about what this is needed for and how it is meant to work in practice. When would you need to get the mock name by calling the proxy? And to get the mock name through the proxy, you would have to add a method called getMockName to the interface being mocked. Why on earth would one want to do this? It's late in the day, so perhaps I am suffering from brain fade, but is this actually useful? I'll rip it out if there's no need for it. Cheers, Nat. |
From: Steve F. <st...@m3...> - 2003-12-02 04:14:44
|
eu wrote: > I see. That is sounds reasonable. In other words you are going to add > chaining of expectations but not through invocation handler. Basically > expectation on to be called after some other expectation. I can imagine > something like that. > > exp1 = mock.expect( "method1", C.args(...)); > exp2 = mock.expect( "method1", C.after( exp1, C.args(...))); > exp2 = mock.expect( "method1", C.after( exp2, C.args(...))); exactly. > PS: what about the 1.0 release? Is anybody know the answer yet? no promises, but we might have a little time just before xmas. S. |
From: eu <eu...@md...> - 2003-12-01 15:22:38
|
Nat Pryce wrote: >> I faced that issue too. But my understanding was that I can and should >>use "match" for such calls. So all "expect"-like calls will be in order >>and all "match"-like calls can appear anywhere. Otherwise it will be just >>not possible to handle different returns for the sequential calls >>without or with the same parameters. >> >> >The issue with an ordered InvocationDispatcher is that it makes tests >too brittle. In general, one needs to specify that some calls are >stubbed (matched in the 0.09 parlance), some are expected after others >and some are expected but not in any order. Requiring that *all* calls >are expected in a fixed order makes tests easy to break when code is >changed over time. It is also quite a rare case -- I've only needed it >when testing some quite baroque event announcement code. And even then >it broke tests later! > >Our new approach is to provide an API that is used to specify that one >invocation is expected to occur after another. This has the benefits >that it highlights the ordering in the test and allows *partial* >ordering, which gives much needed flexibility to the test code. > > I see. That is sounds reasonable. In other words you are going to add chaining of expectations but not through invocation handler. Basically expectation on to be called after some other expectation. I can imagine something like that. exp1 = mock.expect( "method1", C.args(...)); exp2 = mock.expect( "method1", C.after( exp1, C.args(...))); exp2 = mock.expect( "method1", C.after( exp2, C.args(...))); ... This should be great. regards, Eugene PS: what about the 1.0 release? Is anybody know the answer yet? |
From: Nat P. <nat...@b1...> - 2003-12-01 14:20:15
|
On Mon, 2003-12-01 at 05:53, Eugene Kuleshov wrote: > Nat Pryce wrote: > I faced that issue too. But my understanding was that I can and should > use "match" for such calls. So all "expect"-like calls will be in order > and all "match"-like calls can appear anywhere. Otherwise it will be just > not possible to handle different returns for the sequential calls > without or with the same parameters. The issue with an ordered InvocationDispatcher is that it makes tests too brittle. In general, one needs to specify that some calls are stubbed (matched in the 0.09 parlance), some are expected after others and some are expected but not in any order. Requiring that *all* calls are expected in a fixed order makes tests easy to break when code is changed over time. It is also quite a rare case -- I've only needed it when testing some quite baroque event announcement code. And even then it broke tests later! Our new approach is to provide an API that is used to specify that one invocation is expected to occur after another. This has the benefits that it highlights the ordering in the test and allows *partial* ordering, which gives much needed flexibility to the test code. Cheers, Nat. |
From: Eugene K. <eu...@md...> - 2003-12-01 05:53:31
|
Nat Pryce wrote: >Sure, post patches to the SF patch manager. Support for cglib is one of the >goals after the 1.0 release. > > Ok. I'll will do it this week. There are some minor/low-level issue that I'd like to investigate more. By the way, what is the timeframe for release 1.0? I really curious what kind of cglib support are you planning? New version of cglib have no dependency on heavy BCEL and using ASM instead, the beta I've used in that hack is quite stable. >As for the OrderedInvocationDispatcher, experience has shown us that it is >not a good idea. No matter what ordering constraints are expected in the >test, there are methods that can be called on an object at any time, such as >toString. Often these are called within the test framework when creating >error messages and such. If an OrderedInvocationDispatcher is used, calling >these "out-of-order" methods will create obscure error messages. If the >method was called while generating an error message, the final error message >will hide the actual error, making it hard to detect what went wrong with >the code. So, our approach now is to use an unordered invocation dispatcher >and to explicitly define which expected calls have a required ordering. The >definition of call order is not yet implemented, but will be very soon! > > I faced that issue too. But my understanding was that I can and should use "match" for such calls. So all "expect"-like calles will be in order and all "match"-like calls can apper anywhere. Otherwise it will be just not possible to handle differerent returns fir the sequential calls without or with the same parameters. regards, Eugene >Cheers, > Nat. >_______________________ >Dr. Nathaniel Pryce >B13media Ltd. >http://www.b13media.com >+44 (0)7712 526 661 > >----- Original Message ----- >From: "Eugene Kuleshov" <eu...@md...> >Cc: "'Mockobjects-Java-Dev'" <moc...@li...>; >"'Mockobjects-Java-Users'" <moc...@li...> >Sent: Sunday, November 30, 2003 4:10 PM >Subject: [MO-java-dev] Cretion of the dynamic mocks for classes vs. >interfaces > >>i, >> >> I've implemented a feature that allows to pass class to Mock object >>constructor (present functionality was only working for interfaces) and >>even use non default constructor. That was possible because of cglib. >>The affected class is Mock, and I've added CoreInstanceMock and >>OrderedInvocationDispatcher. >> >> Is anyone interesed? >> >> regards, >> Eugene >> >> |
From: Nat P. <nat...@b1...> - 2003-11-30 19:27:09
|
Sure, post patches to the SF patch manager. Support for cglib is one of the goals after the 1.0 release. As for the OrderedInvocationDispatcher, experience has shown us that it is not a good idea. No matter what ordering constraints are expected in the test, there are methods that can be called on an object at any time, such as toString. Often these are called within the test framework when creating error messages and such. If an OrderedInvocationDispatcher is used, calling these "out-of-order" methods will create obscure error messages. If the method was called while generating an error message, the final error message will hide the actual error, making it hard to detect what went wrong with the code. So, our approach now is to use an unordered invocation dispatcher and to explicitly define which expected calls have a required ordering. The definition of call order is not yet implemented, but will be very soon! Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 ----- Original Message ----- From: "Eugene Kuleshov" <eu...@md...> Cc: "'Mockobjects-Java-Dev'" <moc...@li...>; "'Mockobjects-Java-Users'" <moc...@li...> Sent: Sunday, November 30, 2003 4:10 PM Subject: [MO-java-dev] Cretion of the dynamic mocks for classes vs. interfaces > Hi, > > I've implemented a feature that allows to pass class to Mock object > constructor (present functionality was only working for interfaces) and > even use non default constructor. That was possible because of cglib. > The affected class is Mock, and I've added CoreInstanceMock and > OrderedInvocationDispatcher. > > Is anyone interesed? > > regards, > Eugene > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev |
From: Eugene K. <eu...@md...> - 2003-11-30 16:10:45
|
Hi, I've implemented a feature that allows to pass class to Mock object constructor (present functionality was only working for interfaces) and even use non default constructor. That was possible because of cglib. The affected class is Mock, and I've added CoreInstanceMock and OrderedInvocationDispatcher. Is anyone interesed? regards, Eugene |
From: Joe W. <jo...@tr...> - 2003-11-30 13:27:17
|
Hi mock objects people, Java Open Source Programming, is now available to buy. I'm mentioning it here because one of the main focal points of the book is test-driven-development with mock objects. As well as explaining the motivation and advantages of using mock objects, and of course how to use the Java mock objects library, it illustrates how to use the process behind mocks to drive the design of real world code, including with an MVC framework and persistence layer. Buy the book here: http://www.amazon.com/exec/obidos/tg/detail/-/0471463620/ And see a review here: http://www.theserverside.com/resources/article.jsp?l=JavaOpenSourceProgrammingBookReview I apologise if you regard this message as spam - I consider it very on-topic ;) cheers -Joe Walnes (co-author) |
From: Steve F. <sm...@us...> - 2003-11-23 21:12:08
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv20697/src/core/com/mockobjects/dynamic Modified Files: CoreMock.java InvocationMocker.java Log Message: Improved error reporting and toString() Index: CoreMock.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CoreMock.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- CoreMock.java 18 Nov 2003 23:12:51 -0000 1.15 +++ CoreMock.java 23 Nov 2003 21:12:05 -0000 1.16 @@ -5,7 +5,6 @@ import junit.framework.AssertionFailedError; - public class CoreMock implements DynamicMock { private InvocationDispatcher invocationDispatcher; private Object proxy; @@ -15,6 +14,7 @@ this.proxy = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { mockedClass }, this); this.name = name; this.invocationDispatcher = invocationDispatcher; + add(new InvocationMocker("toString", C.args(), new ReturnStub(name))); } public Object proxy() { Index: InvocationMocker.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/InvocationMocker.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- InvocationMocker.java 18 Nov 2003 23:12:51 -0000 1.9 +++ InvocationMocker.java 23 Nov 2003 21:12:05 -0000 1.10 @@ -7,6 +7,8 @@ import java.util.Iterator; import java.util.List; +import junit.framework.AssertionFailedError; + import com.mockobjects.dynamic.matchers.MethodNameMatcher; public class InvocationMocker implements Invokable { @@ -52,9 +54,15 @@ } public void verify() { - Iterator i = matchers.iterator(); - while( i.hasNext() ) { - ((InvocationMatcher)i.next()).verify(); + try { + Iterator i = matchers.iterator(); + while (i.hasNext()) { + ((InvocationMatcher) i.next()).verify(); + } + } catch (AssertionFailedError error) { + AssertionFailedError newError = new AssertionFailedError(error.getMessage() + " " + toString()); + newError.fillInStackTrace(); + throw newError; } } @@ -68,11 +76,16 @@ } public StringBuffer writeTo(StringBuffer buffer) { + buffer.append("("); Iterator it = matchers.iterator(); while (it.hasNext()) { ((InvocationMatcher)it.next()).writeTo(buffer).append(", "); } stub.writeTo(buffer); return buffer.append("\n"); + } + + public String toString() { + return writeTo(new StringBuffer()).toString(); } } |
From: Steve F. <sm...@us...> - 2003-11-23 21:12:08
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/matchers In directory sc8-pr-cvs1:/tmp/cvs-serv20697/src/core/com/mockobjects/dynamic/matchers Modified Files: CallOnceMatcher.java Log Message: Improved error reporting and toString() Index: CallOnceMatcher.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/matchers/CallOnceMatcher.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CallOnceMatcher.java 18 Nov 2003 23:12:51 -0000 1.2 +++ CallOnceMatcher.java 23 Nov 2003 21:12:05 -0000 1.3 @@ -20,7 +20,7 @@ } public void verify() { - Assert.assertTrue("Should have been invoked", wasInvoked); + Assert.assertTrue("Should have been called", wasInvoked); } public StringBuffer writeTo(StringBuffer buffer) { |
From: Chris C. <drc...@us...> - 2003-11-19 22:14:53
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/constraint In directory sc8-pr-cvs1:/tmp/cvs-serv29295/com/mockobjects/constraint Modified Files: IsEqual.java Log Message: fixed null pointer bug in IsEquals Index: IsEqual.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/constraint/IsEqual.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- IsEqual.java 18 May 2003 20:59:40 -0000 1.3 +++ IsEqual.java 19 Nov 2003 22:14:49 -0000 1.4 @@ -27,6 +27,9 @@ if(arg instanceof Object[]) { arg = Arrays.asList((Object[])arg); } + if(arg == null){ + return arg==_object; + } return arg.equals(_object); } |
From: Chris C. <drc...@us...> - 2003-11-19 22:14:52
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/constraint In directory sc8-pr-cvs1:/tmp/cvs-serv29295/test/mockobjects/constraint Modified Files: ConstraintsTest.java Log Message: fixed null pointer bug in IsEquals Index: ConstraintsTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/constraint/ConstraintsTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ConstraintsTest.java 18 May 2003 20:59:40 -0000 1.2 +++ ConstraintsTest.java 19 Nov 2003 22:14:49 -0000 1.3 @@ -56,6 +56,15 @@ assertTrue( !p.eval(i2) ); } + public void testIsEqualNull() { + Integer i1 = new Integer(1); + Constraint p = new IsEqual(i1); + assertTrue( !p.eval(null) ); + Constraint nullEquals = new IsEqual(null); + assertTrue(nullEquals.eval(null)); + assertTrue(!nullEquals.eval(i1)); + } + public void testIsEqualObjectArray() { String[] s1 = new String[] { "a", "b" }; String[] s2 = new String[] { "a", "b" }; @@ -81,6 +90,10 @@ AssertMo.assertIncludes("Should get resolved toString() with no expectation error", "MockName", p.toString()); } + public void testIsEqualNullToString() { + assertEquals("Should print toString even if argument is null", + " = null", new IsEqual(null).toString()); + } public void testIsEqualEquals() throws Exception { assertEquals("Should be equal", new IsEqual("a"), new IsEqual("a")); |
From: Chris C. <drc...@us...> - 2003-11-19 22:14:52
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv29295/com/mockobjects/dynamic Modified Files: DynamicUtil.java Log Message: fixed null pointer bug in IsEquals Index: DynamicUtil.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/DynamicUtil.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DynamicUtil.java 11 Aug 2003 21:12:55 -0000 1.6 +++ DynamicUtil.java 19 Nov 2003 22:14:49 -0000 1.7 @@ -75,6 +75,9 @@ } public static String proxyToString(Object element) { + if (element == null){ + return "null"; + } if (Proxy.isProxyClass(element.getClass())) { try { Method mockNameMethod = CoreMock.class.getDeclaredMethod("getMockName", new Class[0]); |
From: Steve F. <sm...@us...> - 2003-11-18 23:12:58
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/support In directory sc8-pr-cvs1:/tmp/cvs-serv345/src/core/test/mockobjects/dynamic/support Modified Files: MockCallable.java MockInvokable.java MockInvocationDispatcher.java Log Message: Added better error reporting. Shows invocation and invokables. Index: MockCallable.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/support/MockCallable.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockCallable.java 23 Sep 2003 23:04:33 -0000 1.1 +++ MockCallable.java 18 Nov 2003 23:12:52 -0000 1.2 @@ -94,4 +94,8 @@ public String toString() { return "MockCallable " + name; } + + public StringBuffer writeTo(StringBuffer buffer) { + throw new AssertionError("should implement writeTo"); + } } Index: MockInvokable.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/support/MockInvokable.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockInvokable.java 23 Sep 2003 23:04:33 -0000 1.1 +++ MockInvokable.java 18 Nov 2003 23:12:52 -0000 1.2 @@ -45,5 +45,9 @@ public void verifyExpectations() { Verifier.verifyObject(this); } + + public StringBuffer writeTo(StringBuffer buffer) { + throw new AssertionError("should implement writeTo"); + } } Index: MockInvocationDispatcher.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/support/MockInvocationDispatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockInvocationDispatcher.java 23 Sep 2003 23:04:33 -0000 1.1 +++ MockInvocationDispatcher.java 18 Nov 2003 23:12:52 -0000 1.2 @@ -55,4 +55,8 @@ public void verifyExpectations() { super.verify(); } + + public void writeTo(StringBuffer buffer) { + throw new AssertionError("should implement writeTo"); + } } |
From: Steve F. <sm...@us...> - 2003-11-18 23:12:56
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/matchers In directory sc8-pr-cvs1:/tmp/cvs-serv345/src/core/test/mockobjects/dynamic/matchers Modified Files: InvocationMatcherTest.java CallOnceMatcherTest.java Log Message: Added better error reporting. Shows invocation and invokables. Index: InvocationMatcherTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/matchers/InvocationMatcherTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- InvocationMatcherTest.java 29 Oct 2003 22:11:36 -0000 1.1 +++ InvocationMatcherTest.java 18 Nov 2003 23:12:52 -0000 1.2 @@ -12,10 +12,10 @@ public class InvocationMatcherTest extends TestCaseMo { private Invocation emptyInvocation = - new Invocation("example", new Class[0], Void.class, new Object[0] ); + new Invocation(Void.class, "example", new Class[0], Void.class, new Object[0] ); private Invocation exampleInvocation = - new Invocation("example", new Class[] { String.class }, Void.class, + new Invocation(Void.class, "example", new Class[] { String.class }, Void.class, new Object[] { "arg1", "arg2" } ); public InvocationMatcherTest(String name) { Index: CallOnceMatcherTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/matchers/CallOnceMatcherTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- CallOnceMatcherTest.java 29 Oct 2003 22:11:36 -0000 1.1 +++ CallOnceMatcherTest.java 18 Nov 2003 23:12:52 -0000 1.2 @@ -11,7 +11,7 @@ public class CallOnceMatcherTest extends TestCase { private Invocation emptyInvocation = - new Invocation("example", new Class[0], Void.class, new Object[0] ); + new Invocation(Void.class, "example", new Class[0], Void.class, new Object[0] ); private CallOnceMatcher matcher = new CallOnceMatcher(); public void testWillMatchIfNotYetInvoked() { |
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv345/src/core/test/mockobjects/dynamic Modified Files: InvocationTest.java InvocationMockerTest.java StubTest.java CoreMockTest.java Removed Files: DynamicMockErrorTest.java Log Message: Added better error reporting. Shows invocation and invokables. Index: InvocationTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/InvocationTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- InvocationTest.java 29 Oct 2003 22:11:35 -0000 1.2 +++ InvocationTest.java 18 Nov 2003 23:12:52 -0000 1.3 @@ -19,6 +19,7 @@ return "hello, world"; } + final Class DECLARING_CLASS = Void.class; final String METHOD_NAME = "exampleMethod"; final Class[] ARG_TYPES = { int.class, boolean.class }; final Class RETURN_TYPE = String.class; @@ -30,7 +31,7 @@ } public void testCanBeConstructedWithExplicitCallDetails() { - Invocation call = new Invocation( METHOD_NAME, ARG_TYPES, + Invocation call = new Invocation( DECLARING_CLASS, METHOD_NAME, ARG_TYPES, RETURN_TYPE, ARG_VALUES ); assertEquals( "name", METHOD_NAME, call.getMethodName() ); @@ -58,7 +59,7 @@ } public void testConstructorInterpretsNullParameterValueArrayAsZeroArguments() { - Invocation call = new Invocation( METHOD_NAME, new Class[0], + Invocation call = new Invocation( DECLARING_CLASS, METHOD_NAME, new Class[0], RETURN_TYPE, null ); assertEquals( "expected no parameters values", @@ -66,22 +67,22 @@ } public void testTestsForEqualityOnMethodSignatureAndArguments() { - Invocation call1 = new Invocation( + Invocation call1 = new Invocation(DECLARING_CLASS, METHOD_NAME, ARG_TYPES, RETURN_TYPE, ARG_VALUES ); - Invocation call2 = new Invocation( + Invocation call2 = new Invocation( DECLARING_CLASS, METHOD_NAME, ARG_TYPES, RETURN_TYPE, ARG_VALUES ); - Invocation differentName = new Invocation( + Invocation differentName = new Invocation( DECLARING_CLASS, "other" + METHOD_NAME, ARG_TYPES, RETURN_TYPE, ARG_VALUES ); - Invocation differentReturnType = new Invocation( + Invocation differentReturnType = new Invocation( DECLARING_CLASS, "other" + METHOD_NAME, ARG_TYPES, int.class, ARG_VALUES ); - Invocation differentArgTypes = new Invocation( + Invocation differentArgTypes = new Invocation( DECLARING_CLASS, "other" + METHOD_NAME, new Class[]{double.class}, RETURN_TYPE, ARG_VALUES ); - Invocation differentArgValues = new Invocation( + Invocation differentArgValues = new Invocation( DECLARING_CLASS, "other" + METHOD_NAME, ARG_TYPES, RETURN_TYPE, new Object[] { new Integer(1), Boolean.FALSE } ); @@ -102,10 +103,10 @@ } public void testFollowsEqualsHashcodeProtocol() { - Invocation call1 = new Invocation( + Invocation call1 = new Invocation( DECLARING_CLASS, METHOD_NAME, ARG_TYPES, RETURN_TYPE, ARG_VALUES ); - Invocation call2 = new Invocation( + Invocation call2 = new Invocation( DECLARING_CLASS, METHOD_NAME, ARG_TYPES, RETURN_TYPE, ARG_VALUES ); @@ -115,7 +116,7 @@ public void testToStringWithTwoArguments() throws Exception { Invocation invocation = - new Invocation("methodName", new Class[] { String.class, String.class} , void.class, + new Invocation(DECLARING_CLASS, "methodName", new Class[] { String.class, String.class} , void.class, new Object[] { "arg1", "arg2" } ); String result = invocation.toString(); @@ -126,7 +127,7 @@ public void testToStringWithStringArray() throws Exception { Invocation invocation = - new Invocation("methodName", new Class[] { String[].class} , void.class, + new Invocation(DECLARING_CLASS, "methodName", new Class[] { String[].class} , void.class, new Object[] { new String[] { "arg1", "arg2" } } ); String result = invocation.toString(); @@ -136,7 +137,7 @@ public void testToStringWithPrimitiveArray() throws Exception { Invocation invocation = - new Invocation("methodName", new Class[] { long[].class} , void.class, + new Invocation(DECLARING_CLASS, "methodName", new Class[] { long[].class} , void.class, new Object[] { new long[] { 1, 2 } } ); String result = invocation.toString(); @@ -148,7 +149,7 @@ Mock mockDummyInterface = new Mock(DummyInterface.class, "DummyMock"); Invocation invocation = - new Invocation("methodName", new Class[] { String.class, DummyInterface.class} , void.class, + new Invocation(DECLARING_CLASS, "methodName", new Class[] { String.class, DummyInterface.class} , void.class, new Object[] { "arg1", mockDummyInterface.proxy() } ); String result = invocation.toString(); @@ -159,7 +160,7 @@ public void testMethodToStringWithNullArg() throws Exception { Invocation invocation = - new Invocation("methodName", new Class[] { String.class }, void.class, + new Invocation(DECLARING_CLASS, "methodName", new Class[] { String.class }, void.class, new Object[] { null }); String result = invocation.toString(); Index: InvocationMockerTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/InvocationMockerTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- InvocationMockerTest.java 11 Nov 2003 06:47:07 -0000 1.7 +++ InvocationMockerTest.java 18 Nov 2003 23:12:52 -0000 1.8 @@ -18,11 +18,11 @@ public boolean matches(Invocation invocation) { return true; } + public StringBuffer writeTo(StringBuffer buffer) { return buffer.append("match all"); } }; private InvocationMatcher matchNone = new StatelessInvocationMatcher() { - public boolean matches(Invocation invocation) { - return false; - } + public boolean matches(Invocation invocation) { return false; } + public StringBuffer writeTo(StringBuffer buffer) { return buffer.append("match none"); } }; public class MockInvocationMatcher implements InvocationMatcher { @@ -37,6 +37,8 @@ public void invoked(Invocation invocation) { this.invocation.setActual(invocation); } + + public StringBuffer writeTo(StringBuffer buffer) { return buffer.append("Mock matcher"); } public void verify() { verifyCalls.inc(); @@ -54,10 +56,14 @@ public String getDescription() { return "MockStub"; } + + public StringBuffer writeTo(StringBuffer buffer) { + throw new AssertionError("should implement writeTo"); + } }; private Invocation exampleInvocation = - new Invocation("example", new Class[] { String.class, String.class }, Void.class, + new Invocation(Void.class, "example", new Class[] { String.class, String.class }, Void.class, new Object[] { "arg1", "arg2"} ); Index: StubTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/StubTest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- StubTest.java 29 Oct 2003 22:11:36 -0000 1.8 +++ StubTest.java 18 Nov 2003 23:12:52 -0000 1.9 @@ -15,7 +15,7 @@ super(name); } - Invocation invocation = new Invocation("ignoredName", new Class[0], void.class, new Object[0]); + Invocation invocation = new Invocation(Void.class, "ignoredName", new Class[0], void.class, new Object[0]); public void testReturnStub() throws Throwable { final String RESULT = "result"; Index: CoreMockTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CoreMockTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- CoreMockTest.java 2 Oct 2003 22:55:32 -0000 1.9 +++ CoreMockTest.java 18 Nov 2003 23:12:52 -0000 1.10 @@ -94,7 +94,7 @@ mockDispatcher.dispatchResult = new Boolean(false); mockDispatcher.dispatchInvocation.setExpected( - new Invocation("equals", new Class[] { Object.class }, boolean.class, + new Invocation(Void.class, "equals", new Class[] { Object.class }, boolean.class, new Object[] { "not a proxy" })); assertFalse("Should handle proxy inequality by calling through", proxy.equals("not a proxy")); @@ -104,7 +104,7 @@ public void testProxyEqualityWithNull() throws Exception { mockDispatcher.dispatchResult = new Boolean(true); mockDispatcher.dispatchInvocation.setExpected( - new Invocation("equals", new Class[] { Object.class }, boolean.class, + new Invocation(Void.class, "equals", new Class[] { Object.class }, boolean.class, new Object[] { null })); assertTrue("Proxy should handle null equality", proxy.equals(null)); --- DynamicMockErrorTest.java DELETED --- |
From: Steve F. <sm...@us...> - 2003-11-18 23:12:56
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/functional/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv345/src/core/functional/test/mockobjects/dynamic Added Files: ErrorReportingTest.java Log Message: Added better error reporting. Shows invocation and invokables. --- NEW FILE: ErrorReportingTest.java --- /* * copyright mockobjects.com 04-Oct-2003 */ package functional.test.mockobjects.dynamic; import com.mockobjects.dynamic.C; import com.mockobjects.dynamic.DynamicMockError; import com.mockobjects.dynamic.Mock; import com.mockobjects.util.AssertMo; import com.mockobjects.util.TestCaseMo; public class ErrorReportingTest extends TestCaseMo { public ErrorReportingTest(String name) { super(name); } public interface OneMethod { void oneParam(int val); } public void testErrorMessageIncludesNameExpectationsAndInvocationDetails() { Mock mock = new Mock(OneMethod.class, "target mock"); mock.expectAndReturn("oneReturn", "wrong param", "a result"); mock.expect("twoParams", C.eq("one", "two")); try { ((OneMethod)mock.proxy()).oneParam(-1); } catch (DynamicMockError err) { String message = err.getMessage(); AssertMo.assertIncludes("Should have name", "target mock", message); AssertMo.assertIncludes("Should have type name", "OneMethod", message); AssertMo.assertIncludes("Should have method name", "oneParam", message); AssertMo.assertIncludes("Should have parameter value", "-1", message); AssertMo.assertIncludes("Should have expectation preamble", "in:", message); AssertMo.assertIncludes("Should have expected method name", "oneReturn", message); AssertMo.assertIncludes("Should have expected method param", "wrong param", message); AssertMo.assertIncludes("Should have expected method result", "a result", message); AssertMo.assertIncludes("Should have expected method name", "twoParams", message); AssertMo.assertIncludes("Should have expected method param", "one", message); AssertMo.assertIncludes("Should have expected method param", "two", message); AssertMo.assertIncludes("Should have expected method result", "void", message); } } } |