You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(5) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(17) |
Feb
(7) |
Mar
(2) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
|
Nov
(6) |
Dec
(4) |
2007 |
Jan
(1) |
Feb
|
Mar
(10) |
Apr
(3) |
May
(4) |
Jun
(7) |
Jul
|
Aug
(5) |
Sep
|
Oct
|
Nov
|
Dec
(3) |
2008 |
Jan
|
Feb
|
Mar
(1) |
Apr
(3) |
May
(8) |
Jun
(7) |
Jul
(12) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
(3) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Ziem, T. <Tho...@t-...> - 2008-05-23 07:45:37
|
Hi Daniel, that sounds good. What's your suggestion for non-default constructors? Perhaps another function like that: Object getInstanceByConstructor(Constructor constructor) Regards, Thomas > -----Ursprüngliche Nachricht----- > Von: rmo...@li... > [mailto:rmo...@li...] Im Auftrag > von Daniel Brolund > Gesendet: Donnerstag, 22. Mai 2008 19:42 > An: rmo...@li... > Betreff: Re: [Rmock-users] RMock and Java Reflection API > > The variables "name" and "className" should of course be the > same, my bad. > > Cheers > Daniel > > On Thu, May 22, 2008 at 7:39 PM, Daniel Brolund > <dan...@gm...> wrote: > > Hi Thomas, > > > > Javas reflection classes are generally not "mockable". > > > > What I have done successfully in several project was to create a > > facade with the needed functionality. > > > > public class ReflectionStuff { > > Class getClassByName(String name) { > > try { > > return Class.forName(className); > > } catch(EveryExceptionKnownToMan e) { > > //handle nicely by throwing e.g. a runtime exception } } Object > > getInstanceByName(String name) { return > > getClassByName(name).newInstance(); // You need to catch a > few more > > here :-P } } > > > > Then you can mock that class (or create an interface in the same > > manner if you prefer that) and inject into the class you > are testing. > > > > A good bonus is that you will handle all of the meaningless > exceptions > > Java might throw when reflecting in one place in the code. > > > > Did that help? > > > > Cheers > > Daniel > > > > On Thu, May 22, 2008 at 6:29 PM, Ziem, Thomas > <Tho...@t-...> wrote: > >> Hi all, > >> > >> I want to test a class which loads classes using the Java > Reflection > >> API: > >> > >> Class.forName(className).newInstance(); > >> > >> The value of className comes from a configuration property. > >> Is there any way that the class under test uses a mocked > object instead? > >> > >> Thank's, > >> Thomas > >> > >> > --------------------------------------------------------------------- > >> ---- This SF.net email is sponsored by: Microsoft Defy all > >> challenges. Microsoft(R) Visual Studio 2008. > >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > >> _______________________________________________ > >> Rmock-users mailing list > >> Rmo...@li... > >> https://lists.sourceforge.net/lists/listinfo/rmock-users > >> > > > > > > > > -- > > __________________________ > > Dan...@Gm... > > > > > > -- > __________________________ > Dan...@Gm... > > -------------------------------------------------------------- > ----------- > This SF.net email is sponsored by: Microsoft Defy all > challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Rmock-users mailing list > Rmo...@li... > https://lists.sourceforge.net/lists/listinfo/rmock-users > |
From: Daniel B. <dan...@gm...> - 2008-05-22 17:42:07
|
The variables "name" and "className" should of course be the same, my bad. Cheers Daniel On Thu, May 22, 2008 at 7:39 PM, Daniel Brolund <dan...@gm...> wrote: > Hi Thomas, > > Javas reflection classes are generally not "mockable". > > What I have done successfully in several project was to create a > facade with the needed functionality. > > public class ReflectionStuff { > Class getClassByName(String name) { > try { > return Class.forName(className); > } catch(EveryExceptionKnownToMan e) { > //handle nicely by throwing e.g. a runtime exception > } > } > Object getInstanceByName(String name) { > return getClassByName(name).newInstance(); // You need to catch a > few more here :-P > } > } > > Then you can mock that class (or create an interface in the same > manner if you prefer that) and inject into the class you are testing. > > A good bonus is that you will handle all of the meaningless exceptions > Java might throw when reflecting in one place in the code. > > Did that help? > > Cheers > Daniel > > On Thu, May 22, 2008 at 6:29 PM, Ziem, Thomas <Tho...@t-...> wrote: >> Hi all, >> >> I want to test a class which loads classes using the Java Reflection >> API: >> >> Class.forName(className).newInstance(); >> >> The value of className comes from a configuration property. >> Is there any way that the class under test uses a mocked object instead? >> >> Thank's, >> Thomas >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Microsoft >> Defy all challenges. Microsoft(R) Visual Studio 2008. >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >> _______________________________________________ >> Rmock-users mailing list >> Rmo...@li... >> https://lists.sourceforge.net/lists/listinfo/rmock-users >> > > > > -- > __________________________ > Dan...@Gm... > -- __________________________ Dan...@Gm... |
From: Daniel B. <dan...@gm...> - 2008-05-22 17:40:02
|
Hi Thomas, Javas reflection classes are generally not "mockable". What I have done successfully in several project was to create a facade with the needed functionality. public class ReflectionStuff { Class getClassByName(String name) { try { return Class.forName(className); } catch(EveryExceptionKnownToMan e) { //handle nicely by throwing e.g. a runtime exception } } Object getInstanceByName(String name) { return getClassByName(name).newInstance(); // You need to catch a few more here :-P } } Then you can mock that class (or create an interface in the same manner if you prefer that) and inject into the class you are testing. A good bonus is that you will handle all of the meaningless exceptions Java might throw when reflecting in one place in the code. Did that help? Cheers Daniel On Thu, May 22, 2008 at 6:29 PM, Ziem, Thomas <Tho...@t-...> wrote: > Hi all, > > I want to test a class which loads classes using the Java Reflection > API: > > Class.forName(className).newInstance(); > > The value of className comes from a configuration property. > Is there any way that the class under test uses a mocked object instead? > > Thank's, > Thomas > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Rmock-users mailing list > Rmo...@li... > https://lists.sourceforge.net/lists/listinfo/rmock-users > -- __________________________ Dan...@Gm... |
From: Ziem, T. <Tho...@t-...> - 2008-05-22 16:30:36
|
Hi all, I want to test a class which loads classes using the Java Reflection API: Class.forName(className).newInstance(); The value of className comes from a configuration property. Is there any way that the class under test uses a mocked object instead? Thank's, Thomas |
From: Helgi K. <hel...@gm...> - 2008-04-25 07:39:04
|
Hi I am getting the following stacktrace when I attempt to mock one of my interfaces. Any ideas? java.lang.NoClassDefFoundError: EDU/oswego/cs/dl/util/concurrent/ConcurrentReaderHashMap at org.jgroups.Message.<clinit>(Message.java:63) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:164) at com.enecto.pf.visitsmonitor.jobs.ClusteredJoblistMock.CGLIB$STATICHOOK1(<generated>) at com.enecto.pf.visitsmonitor.jobs.ClusteredJoblistMock.<clinit>(<generated>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at net.sf.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java:616) at net.sf.cglib.proxy.Enhancer.setThreadCallbacks(Enhancer.java:609) at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:631) at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:538) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:220) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) -- Mvh Helgi Kristjansson mailto:hel...@gm... http://www.linkedin.com/in/helgik |
From: Bartolomeo C. <thr...@iw...> - 2008-03-19 09:06:18
|
God dag, +-------------------------------------------+ Warning! This letter contains a virus which has been successfully detected and cured. We strongly recommend deleting this letter and avoid clicking any links. +-------------------------------------------+ [RBN Networks Antivirus] With every fibre of her being, for another man corduroy breeches. she was ready she was waiting tramp round her. If you'd like to kill me, pray for turning up unexpectedly. But now, toni, supposing violent passion i ever was in i either learnt to stick to it. And fourth, that germany is a for the lower people. Fancy articles find no sale. Only son. He went into the navyall the chandlers to be transported quite outside the world. It we look at the number of rocks and reefs and dangers by sorrow not at all like a man conscious of great reserved compartments there. And in the other blubber. Turtle flesh forms one of the principal that approbation, and he had considerable reliance jane think about it? Enquired the doctor, gazing. |
From: Hargis H. <pi...@ca...> - 2007-12-13 21:20:44
|
Hey,=09 =20 Virus found in this message, please delete it without futher reading=20 And remembered that he was to dine with mr. Wetterman with a kind shake of the hand. He was a man of fine example of a similar kind is that of maeshow. |
From: Lajoie G. <int...@ri...> - 2007-12-13 12:44:46
|
Guten Tag, =20 Virus found in this message, please delete it without futher reading=20 =20 =20 =09He nodded. Keep quite quiet, though, and don't to expand into that territory to the north and here?' 'no murder ever took place here,' said. |
From: Kruzan S. <cab...@ri...> - 2007-12-13 00:51:43
|
Goedendag, =20 Virus found in this message, please delete it without futher reading =09Instead of the night before, but, happening to to see if her lover was coming. She was rewarded, any weight with you, i trust that you will do. |
From: Daniel B. <dan...@gm...> - 2007-08-27 20:24:01
|
Hello Mark! Thanks for the somewhat "abstracted" question ;-) You generally want to apply the "Hollywood principle": "Don't call us, we'll call you". If the class that needs the session creates it, you generally have a problem when you want to test the class. You then have a hardwired dependency on that constructor. Instead, you want to be able to configure the class with the session (a set-method or a constructor argument). Preferably, the session object is an interface, and when you test the class, you mock that interface and pass it to the class. Ok, sooner or later you actually have to instantiate something, but that is usually best left to some dependency-injection framework, like Spring, Pico-container or other. Cheers Daniel When you test it then, you On 8/27/07, Mark Faine <mar...@gm...> wrote: > Java 1.4.2, Junit 3.8.1 rMock 2.0 > > I'm a newbie to rMock and unit testing in general at this level so > forgive me for asking what are probably simple questions but I have to > learn somehow :) > > I have a method that I'd like to test that requires that a session to > a back-end document management system first be established. I'd > really like to test the method in isolation, without requiring an > active session but I can't figure out how to do it. I can post the > code if necessary. I tried mocking the session object but since the > class under test is retrieving the session and is not mocked it just > throws a npe. > > I'd also appreciate any pointers to good references on unit testing, > especially using mock objects and especially using rmock. > > Thanks, > -Mark > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Rmock-users mailing list > Rmo...@li... > https://lists.sourceforge.net/lists/listinfo/rmock-users > -- __________________________ Dan...@Gm... |
From: Mark F. <mar...@gm...> - 2007-08-27 13:44:00
|
Java 1.4.2, Junit 3.8.1 rMock 2.0 I'm a newbie to rMock and unit testing in general at this level so forgive me for asking what are probably simple questions but I have to learn somehow :) I have a method that I'd like to test that requires that a session to a back-end document management system first be established. I'd really like to test the method in isolation, without requiring an active session but I can't figure out how to do it. I can post the code if necessary. I tried mocking the session object but since the class under test is retrieving the session and is not mocked it just throws a npe. I'd also appreciate any pointers to good references on unit testing, especially using mock objects and especially using rmock. Thanks, -Mark |
From: Daniel B. <dan...@gm...> - 2007-08-26 19:46:44
|
Then I think you should just create an instance of it: IDoctypeSBO sbo = new IDoctypeSBO(); set up the expected mocks: IDfSysObject mockObj = (IDfSysObject) mock(IDfSysObject.class); mockObj.setACLName("newacl"); mockObj.setACLDomain("newdomain"); call the sbo-method after startVerification(); sbo.changeACL("docbasename", mockObj, "newdomain", "newacl"); Then rmock will verify that sbo made those calls that you expect (i.e. thet set methods). I also removed the empty try catches and moved the exception to the test-method, since that code at best is unnecessary, and in the worst case it will hide an exception thrown. The test: public final void testChangeACL() throws DfException { IDoctypeSBO sbo = new IDoctypeSBO(); /* Set up Mock objects */ IDfSysObject mockObj = (IDfSysObject) mock(IDfSysObject.class); /* Expectations */ mockObj.setACLName("newacl"); mockObj.setACLDomain("newdomain"); /* Verification */ startVerification(); sbo.changeACL("docbasename", mockObj, "newdomain", "newacl"); } Cheers Daniel On 8/26/07, Mark Faine <mar...@gm...> wrote: > It is the class referenced by "sbo" > > IDoctypeSBO sbo = (IDoctypeSBO) mock(IDoctypeSBO.class); > > It takes an object of type IDfSysObject and modifies attributes of > that object. I basically need to know that it has done this to know > the test is accurate. > > Thanks, > -Mark > > On 8/26/07, Daniel Brolund <dan...@gm...> wrote: > > Hello Mark! > > Which class is the class under test? > > > > Cheers > > Daniel > > > > On 8/26/07, Mark Faine <mar...@gm...> wrote: > > > rMock with JUnit 3.81 and Java 1.4.2 > > > > > > I have an implemented method of an interface that changes the ACL of > > > an object in a document management system: > > > > > > void changeACL(String docbase, IDfSysObject reference, String > > > aclDomain, String aclName) throws DfServiceException > > > > > > I have a test method: > > > > > > public final void testChangeACL() { > > > /* Set up Mock objects */ > > > IDfSysObject mockObj = (IDfSysObject) mock(IDfSysObject.class); > > > IDoctypeSBO sbo = (IDoctypeSBO) mock(IDoctypeSBO.class); > > > > > > /* Expectations */ > > > try { > > > sbo.changeACL("docbasename", mockObj, > > > "newdomain", "newacl"); > > > mockObj.getACLName(); > > > mockObj.getACLDomain(); > > > } catch (DfException dfe) { > > > } > > > > > > /* Verification */ > > > startVerification(); > > > try { > > > sbo.changeACL("docbasename", mockObj, "newdomain", "newacl"); > > > assertThat(mockObj.getACLName(), is.eq("newacl")); > > > assertThat(mockObj.getACLDomain(), is.eq("newdomain")); > > > } catch (DfException dfe) { > > > } > > > } > > > > > > The problem is that the assertions fail with: > > > > > > com.agical.rmock.core.exception.RMockAssertionFailedException: > > > ASSERTION FAILED! > > > <null> > > > does not pass the expression: > > > <eq(<newacl>)> > > > ... > > > > > > I think this is because mockObj.getACLName() is returning null because > > > it is not affected by the changeACL method. How can I make the > > > changeACL method have an affect, i.e. change attributes of the mocked > > > object? > > > > > > thanks, > > > -Mark > > > > > > ------------------------------------------------------------------------- > > > This SF.net email is sponsored by: Splunk Inc. > > > Still grepping through log files to find problems? Stop. > > > Now Search log events and configuration files using AJAX and a browser. > > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > > _______________________________________________ > > > Rmock-users mailing list > > > Rmo...@li... > > > https://lists.sourceforge.net/lists/listinfo/rmock-users > > > > > > > > > -- > > __________________________ > > Dan...@Gm... > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and a browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > _______________________________________________ > > Rmock-users mailing list > > Rmo...@li... > > https://lists.sourceforge.net/lists/listinfo/rmock-users > > > -- __________________________ Dan...@Gm... |
From: Daniel B. <dan...@gm...> - 2007-08-26 19:17:19
|
Hello Mark! Which class is the class under test? Cheers Daniel On 8/26/07, Mark Faine <mar...@gm...> wrote: > rMock with JUnit 3.81 and Java 1.4.2 > > I have an implemented method of an interface that changes the ACL of > an object in a document management system: > > void changeACL(String docbase, IDfSysObject reference, String > aclDomain, String aclName) throws DfServiceException > > I have a test method: > > public final void testChangeACL() { > /* Set up Mock objects */ > IDfSysObject mockObj = (IDfSysObject) mock(IDfSysObject.class); > IDoctypeSBO sbo = (IDoctypeSBO) mock(IDoctypeSBO.class); > > /* Expectations */ > try { > sbo.changeACL("docbasename", mockObj, > "newdomain", "newacl"); > mockObj.getACLName(); > mockObj.getACLDomain(); > } catch (DfException dfe) { > } > > /* Verification */ > startVerification(); > try { > sbo.changeACL("docbasename", mockObj, "newdomain", "newacl"); > assertThat(mockObj.getACLName(), is.eq("newacl")); > assertThat(mockObj.getACLDomain(), is.eq("newdomain")); > } catch (DfException dfe) { > } > } > > The problem is that the assertions fail with: > > com.agical.rmock.core.exception.RMockAssertionFailedException: > ASSERTION FAILED! > <null> > does not pass the expression: > <eq(<newacl>)> > ... > > I think this is because mockObj.getACLName() is returning null because > it is not affected by the changeACL method. How can I make the > changeACL method have an affect, i.e. change attributes of the mocked > object? > > thanks, > -Mark > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Rmock-users mailing list > Rmo...@li... > https://lists.sourceforge.net/lists/listinfo/rmock-users > -- __________________________ Dan...@Gm... |
From: Mark F. <mar...@gm...> - 2007-08-26 18:19:01
|
rMock with JUnit 3.81 and Java 1.4.2 I have an implemented method of an interface that changes the ACL of an object in a document management system: void changeACL(String docbase, IDfSysObject reference, String aclDomain, String aclName) throws DfServiceException I have a test method: public final void testChangeACL() { /* Set up Mock objects */ IDfSysObject mockObj = (IDfSysObject) mock(IDfSysObject.class); IDoctypeSBO sbo = (IDoctypeSBO) mock(IDoctypeSBO.class); /* Expectations */ try { sbo.changeACL("docbasename", mockObj, "newdomain", "newacl"); mockObj.getACLName(); mockObj.getACLDomain(); } catch (DfException dfe) { } /* Verification */ startVerification(); try { sbo.changeACL("docbasename", mockObj, "newdomain", "newacl"); assertThat(mockObj.getACLName(), is.eq("newacl")); assertThat(mockObj.getACLDomain(), is.eq("newdomain")); } catch (DfException dfe) { } } The problem is that the assertions fail with: com.agical.rmock.core.exception.RMockAssertionFailedException: ASSERTION FAILED! <null> does not pass the expression: <eq(<newacl>)> ... I think this is because mockObj.getACLName() is returning null because it is not affected by the changeACL method. How can I make the changeACL method have an affect, i.e. change attributes of the mocked object? thanks, -Mark |
From: David C. <dc...@ma...> - 2007-06-11 14:27:32
|
On Monday 11 June 2007 07:42, SMITH Neil wrote: I'd like to append a little side-comment to this thread. It is very difficult to (for me anyway) to test a class A that collaborates with B & C where B & C are mocks, if in fact C is at some point an argument to a B method. On the surface, this seems to me because I have to mock out equals and maybe hashCode on C or it fails and if it does fail it wants to call "toString" which isn't mocked out either. Not sure if it's viable, but default implementations for all of these Object methods would be a good thing. -- David Corbin Abolish the IRS - http://www.fairtax.org |
From: SMITH N. <nei...@un...> - 2007-06-11 14:26:45
|
Thanks for your rapid response! I'm sorry, I didn't give you enough information... But it's solved! In fact, the getCourse() is to create another object (it's a bit complicated...). If a course is full, it creates a RegistrationWaitingList object (which is quite similar to a registration). This is then used to keep a waiting list of registrations. This object is always created, because I test if the person is already registered to the course (in waiting list or not). So this should not interfere with my tests. I when wrong with the setCourse(course1)... It was there because I was trying to set my course to my course mock... That should be done by using the bit of code you provided, I understand that now. Thanks again!!! Best regards Neil. -----Original Message----- From: joa...@gm... [mailto:joa...@gm...] On Behalf Of Joakim Ohlrogge Sent: lundi, 11. juin 2007 13:57 To: SMITH Neil Cc: rmo...@li... Subject: Re: [Rmock-users] A mock as an attribute of another mock There is a way to do this. In your case I'm not sure, I would have to see the testcase and perhaps some source but from your error it looks like you've got an automatically created mock back from one of the two getCourse calls and that one is used instead of your manually created "course1" mock. >From your expected setCourse(course1) invocation I suspect that you might have expected the value to actually be set as a property and not only expected but there is no way I can be sure. If I'm right you could solve it in one of two ways: 1) Course course1 =3D (Course)mock(Course.class); Registration registration =3D (Registration)mock(Registration.class); registration.getCourse(); modify().returnValue(course1); startVerification(); 2) Registration registration =3D (Registration)mock(Registration.class); Course course1 =3D registration.getCourse(); startVerification(); Both are equivalent. In the second case RMock automates mock(Course.class) and modify().returnValue(course1); This a bit of a stab in the dark since I lack some information but I hope it helps. /Joakim Ohlrogge On 6/11/07, SMITH Neil <nei...@un...> wrote: > Hello! > > I'm having a little trouble working this one out and I don't know if=20 > it is possible. > > Here is what I have: > 3 classes, Person, Registration and Course > > Registration concerns a Course (1 and only 1) > Person has a set of Registrations > > > When I test my Person class, I want to have a mock of my Registration=20 > classe to isolate it properly, but to do that, I also have to mock my=20 > Course classe, so I have a mock (mockReg) that has a property of=20 > Course type that contains a mock. > > I hope this is all clear up to now... > > When I test my Person class, I'm having touble setting up the=20 > expectations on my Course mock. For example > > mockCourse.countRegistrations(); > modify().returnValue(0); > > And when I run the program, I get the error > > com.agical.rmock.core.exception.UnexpectedInvocationException: > UNEXPECTED! > No expectation matched: course1$.countRegistrations() > ----------------------------------------------------------------- > 3 expectation(s) have not yet been matched > (indicated by '->' in the listing below) > ----------------------------------------------------------------- > Unordered section:root { > Unordered section:main { > 1(1)=20 > registrationInt1.setRegsistered(eq(<ch.unifr.sdis.isweb.business.Sport > sm > an@5cfa9339>)) > 1(1) registrationInt1.setCourse(eq(<course1>)) > -> 0(1) course1.getMaximumParticipants() > -> 0(1) course1.countRegistrations() > -> 0(1) course1.addRegistration(eq(<registrationInt1>)) > 1(1) registrationInt1.getRegsistered() > 1(1) registrationInt1.getRegistrationDate() > 1(1) registrationInt1.getRegistrator() > 2(2) registrationInt1.getCourse() > 1(1) registrationInt1.getCourseDetail() > 1(1) registrationInt1.getPhone() > 1(1) registrationInt1.getEmail() > 1(1) registrationInt1.getNote() > 1(1) registrationInt1.getRentedEquipment() > 1(1) registrationInt1.getRegistrationDisciplineLevel() > } > Unordered section:defaults { > } > } > > As you can see, my course1.countRegistrations() is not matched, and=20 > the > course1$.countRegistration() is an unexpected invocation... > > How can I setup the expectations for my mock in the mock? Is there a=20 > way to do this or not? > > > Thanks in advance! > > Take care > Neil. > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Rmock-users mailing list > Rmo...@li... > https://lists.sourceforge.net/lists/listinfo/rmock-users > |
From: Joakim O. <joa...@ag...> - 2007-06-11 11:57:18
|
There is a way to do this. In your case I'm not sure, I would have to see the testcase and perhaps some source but from your error it looks like you've got an automatically created mock back from one of the two getCourse calls and that one is used instead of your manually created "course1" mock. >From your expected setCourse(course1) invocation I suspect that you might have expected the value to actually be set as a property and not only expected but there is no way I can be sure. If I'm right you could solve it in one of two ways: 1) Course course1 = (Course)mock(Course.class); Registration registration = (Registration)mock(Registration.class); registration.getCourse(); modify().returnValue(course1); startVerification(); 2) Registration registration = (Registration)mock(Registration.class); Course course1 = registration.getCourse(); startVerification(); Both are equivalent. In the second case RMock automates mock(Course.class) and modify().returnValue(course1); This a bit of a stab in the dark since I lack some information but I hope it helps. /Joakim Ohlrogge On 6/11/07, SMITH Neil <nei...@un...> wrote: > Hello! > > I'm having a little trouble working this one out and I don't know if it > is possible. > > Here is what I have: > 3 classes, Person, Registration and Course > > Registration concerns a Course (1 and only 1) > Person has a set of Registrations > > > When I test my Person class, I want to have a mock of my Registration > classe to isolate it properly, but to do that, I also have to mock my > Course classe, so I have a mock (mockReg) that has a property of Course > type that contains a mock. > > I hope this is all clear up to now... > > When I test my Person class, I'm having touble setting up the > expectations on my Course mock. > For example > > mockCourse.countRegistrations(); > modify().returnValue(0); > > And when I run the program, I get the error > > com.agical.rmock.core.exception.UnexpectedInvocationException: > UNEXPECTED! > No expectation matched: course1$.countRegistrations() > ----------------------------------------------------------------- > 3 expectation(s) have not yet been matched > (indicated by '->' in the listing below) > ----------------------------------------------------------------- > Unordered section:root { > Unordered section:main { > 1(1) > registrationInt1.setRegsistered(eq(<ch.unifr.sdis.isweb.business.Sportsm > an@5cfa9339>)) > 1(1) registrationInt1.setCourse(eq(<course1>)) > -> 0(1) course1.getMaximumParticipants() > -> 0(1) course1.countRegistrations() > -> 0(1) course1.addRegistration(eq(<registrationInt1>)) > 1(1) registrationInt1.getRegsistered() > 1(1) registrationInt1.getRegistrationDate() > 1(1) registrationInt1.getRegistrator() > 2(2) registrationInt1.getCourse() > 1(1) registrationInt1.getCourseDetail() > 1(1) registrationInt1.getPhone() > 1(1) registrationInt1.getEmail() > 1(1) registrationInt1.getNote() > 1(1) registrationInt1.getRentedEquipment() > 1(1) registrationInt1.getRegistrationDisciplineLevel() > } > Unordered section:defaults { > } > } > > As you can see, my course1.countRegistrations() is not matched, and the > course1$.countRegistration() is an unexpected invocation... > > How can I setup the expectations for my mock in the mock? Is there a way > to do this or not? > > > Thanks in advance! > > Take care > Neil. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Rmock-users mailing list > Rmo...@li... > https://lists.sourceforge.net/lists/listinfo/rmock-users > |
From: SMITH N. <nei...@un...> - 2007-06-11 11:42:49
|
Hello! I'm having a little trouble working this one out and I don't know if it is possible. Here is what I have: 3 classes, Person, Registration and Course Registration concerns a Course (1 and only 1) Person has a set of Registrations When I test my Person class, I want to have a mock of my Registration classe to isolate it properly, but to do that, I also have to mock my Course classe, so I have a mock (mockReg) that has a property of Course type that contains a mock. I hope this is all clear up to now... When I test my Person class, I'm having touble setting up the expectations on my Course mock. For example mockCourse.countRegistrations(); modify().returnValue(0); And when I run the program, I get the error com.agical.rmock.core.exception.UnexpectedInvocationException:=20 UNEXPECTED! No expectation matched: course1$.countRegistrations() ----------------------------------------------------------------- 3 expectation(s) have not yet been matched (indicated by '->' in the listing below) ----------------------------------------------------------------- Unordered section:root { Unordered section:main { 1(1) registrationInt1.setRegsistered(eq(<ch.unifr.sdis.isweb.business.Sportsm an@5cfa9339>)) 1(1) registrationInt1.setCourse(eq(<course1>)) -> 0(1) course1.getMaximumParticipants() -> 0(1) course1.countRegistrations() -> 0(1) course1.addRegistration(eq(<registrationInt1>)) 1(1) registrationInt1.getRegsistered() 1(1) registrationInt1.getRegistrationDate() 1(1) registrationInt1.getRegistrator() 2(2) registrationInt1.getCourse() 1(1) registrationInt1.getCourseDetail() 1(1) registrationInt1.getPhone() 1(1) registrationInt1.getEmail() 1(1) registrationInt1.getNote() 1(1) registrationInt1.getRentedEquipment() 1(1) registrationInt1.getRegistrationDisciplineLevel() } Unordered section:defaults { } } As you can see, my course1.countRegistrations() is not matched, and the course1$.countRegistration() is an unexpected invocation... How can I setup the expectations for my mock in the mock? Is there a way to do this or not? Thanks in advance! Take care Neil. |
From: Joakim O. <joa...@ag...> - 2007-06-08 19:51:52
|
Hi Markus, Thanks for your questions I feel I don't answer much but rather ask more questions. I try to communicate where I come from when reading your questions. I want to help but I fear I don't have much experience with what you want to do so I try to half tell you what I do and half comment on what I think can be done with RMock to meet your needs whether I believe it's a good idea or not. I hope this helps some and feel free to ask more. > I started an evaluation of mocking tools comparing rMock and jMock. What > I have seen - and understood - so far is very interesting, but still > little. Interesting, we would really like to know how the tool is perceived by others so if you want to share what you've found on the list or offline we would be very happy to hear about it. > > Now we are trying to mock an object without a junit suite, that is > without extending RMockTestCase > > The motivation is this: > > the program is calling a backend system through a Connection-object. > This 'border'-object we want to mock and then stuff it into objects > using Connection via dependency injection > > > MockConnection mockConnection implements IConnection > > Actor actor = new Actor(mockConnection); > >From that description and the code above I can not see why creating the mocks from a TestCase would be a problem. I'm sure I've missed something important such as what you are using to inject the dependencies. Personally I use RMock a bit inside out compared to what you want to do. I test interactions between objects "inside" the system instead of putting the mocks at the border of the system. This is what RMock was designed to do but that doesn't mean it cannot be used for other things. > > I found a Proxy class in your library, but no hint how to use it. I saw > this was possible in jMock, so I guess this is possible with Rmock too. > The proxy class is used behind the scenes in RMock, it's not intended to be used directly. Simply put, RMock does not support what you want to do in any simple way. We toyed around a bit with the framework for JUnit 4 wich by design sort of requires what you're requesting. We managed to do it but it required a bit of voodoo and quite frankly was a bit fragile (due to RMocks internal design centered around a hub) > > The next question is based on this: > > When the backend system is changing, in particular the form or order of > replies, we have to update the mock (otherwise we would mock 'the > past'). Because there is a huge number of request/reply pairs, we must > automate this. The idea is to have a switch like "record" that would > write out the requests and its replies, from where we could generate a > new Mock. > The order of calls should be unimportant unless you specify to use an ordered section. By using some obscure features in RMock (forEach(expression).in(all.methodsOf(class))... and a custom action that would print out the calls you could accomplish this. However, I think that rMock is the most useful when driving the design of units with TDD. I found that retrofitting RMock to test an already built system or testing something that is bigger than one or a few classes at a time tends to create more hedaches than be of help. We use as a rule of thumb that if you need more than 10 expectations to test something with rMock you're testing too much at the time. Sometimes that means breaking stuff up with the single responsibility principle as a guideline. Of course feel free to ignore this rule, the important thing is that your test communicates your intentions clearly and that you feel that RMock is a better choice than some other tool you can think of for the job. > Did anybody try this and has a suggestion? > > > Thanks for help > > Markus > > P.S. I googled the Internet for hours to find more documentation or > examples, but didn't find anything. The documentation is addressing > people that know a lot how the program works, but for newbies it is not > suited (I learned how to mock with jMock documentation, which is not > good as well , but a bit better. That's a pity because it does not ease > the access to the tool. (I even started to write my own documentation > including a testsuite with examples showing the different use cases and > I guess such a suite with simple example might be handy for other users > too. At least here it was...) > > Is there anybody out there, who has or found some more documentation? > Did you check out the users guide? http://rmock.sourceforge.net/documentation/docbook/pdf/rmock.pdf It is very reference oriented. Please share what type of documentation would help you get started and we will see what we can do (although we have had less time than we would have liked for RMock lately for private reasons mostly) > > This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please notify the sender urgently and then immediately delete the message and any copies of it from your system. Please also immediately destroy any hardcopies of the message. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. The sender's company reserves the right to monitor all e-mail communications through their networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorised to state them to be the views of the sender's company. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Rmock-users mailing list > Rmo...@li... > https://lists.sourceforge.net/lists/listinfo/rmock-users > |
From: Baumgartner M. <Mar...@sw...> - 2007-06-08 15:17:05
|
Hi all, I started an evaluation of mocking tools comparing rMock and jMock. What I have seen - and understood - so far is very interesting, but still little. Now we are trying to mock an object without a junit suite, that is without extending RMockTestCase The motivation is this:=20 the program is calling a backend system through a Connection-object. This 'border'-object we want to mock and then stuff it into objects using Connection via dependency injection MockConnection mockConnection implements IConnection Actor actor =3D new Actor(mockConnection); I found a Proxy class in your library, but no hint how to use it. I saw this was possible in jMock, so I guess this is possible with Rmock too. The next question is based on this:=20 When the backend system is changing, in particular the form or order of replies, we have to update the mock (otherwise we would mock 'the past'). Because there is a huge number of request/reply pairs, we must automate this. The idea is to have a switch like "record" that would write out the requests and its replies, from where we could generate a new Mock.=20 Did anybody try this and has a suggestion? Thanks for help Markus P.S. I googled the Internet for hours to find more documentation or examples, but didn't find anything. The documentation is addressing people that know a lot how the program works, but for newbies it is not suited (I learned how to mock with jMock documentation, which is not good as well , but a bit better. That's a pity because it does not ease the access to the tool. (I even started to write my own documentation including a testsuite with examples showing the different use cases and I guess such a suite with simple example might be handy for other users too. At least here it was...) Is there anybody out there, who has or found some more documentation? =20 =20 This message is for the named person's use only. It may contain = confidential, proprietary or legally privileged information. No = confidentiality or privilege is waived or lost by any mistransmission. = If you receive this message in error, please notify the sender urgently = and then immediately delete the message and any copies of it from your = system. Please also immediately destroy any hardcopies of the message. = You must not, directly or indirectly, use, disclose, distribute, print, = or copy any part of this message if you are not the intended recipient. = The sender's company reserves the right to monitor all e-mail = communications through their networks. Any views expressed in this = message are those of the individual sender, except where the message = states otherwise and the sender is authorised to state them to be the = views of the sender's company. |
From: Daniel B. <dan...@gm...> - 2007-06-01 20:20:00
|
Hello! There is now a RMock 2.0.2 in the maven2 repo. Try that one and get back to us if anything fails. Please disregard the 2.0.1, I was a bit trigger-happy there. ;-) If you want to download it directly it resides at: http://www.ibiblio.org/maven2/com/agical/rmock/rmock/2.0.2/ We're sorry for the embarrassing delay in this matter. One good thing is that we've made great improvements to the maven deployment process, so hopefully future updates will arrive more frequently. Cheers Daniel On 5/24/07, David Corbin <dc...@al...> wrote: > We've recently started running into a errors because we don't have unique ids > specified. I think the default mock() method should simply choose unique ids > (by appending a sequenceNumber to them). > > David. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Rmock-users mailing list > Rmo...@li... > https://lists.sourceforge.net/lists/listinfo/rmock-users > -- __________________________ Dan...@Gm... |
From: David C. <dc...@al...> - 2007-05-24 17:23:13
|
We've recently started running into a errors because we don't have unique ids specified. I think the default mock() method should simply choose unique ids (by appending a sequenceNumber to them). David. |
From: Daniel B. <dan...@gm...> - 2007-05-20 11:17:01
|
Hello all! RMock 2.0.0 is now in the Maven2 repository! We had some problems with the upload process, but it seems to be fixed now. Hopefully we will be able to push out new releases more easily and frequently in the future! Please, let us know if you have any problems. Cheers Daniel and the RMock team -- __________________________ Dan...@Gm... |
From: Joakim O. <joa...@ag...> - 2007-05-18 18:24:46
|
Hi David, No, there is no such expression yet. If you create one we would be happy for to include it in the next RMock delivery. I have also thought about creating an "equalByToString" expression that would consider two objects to be equal if their toString methods return the same string. I think that could save some HashCode and equals implementing. It's nice to hear that users out there are creating their own expressions and pushing the framework. Let us know if you come up with other ideas that would make RMock Easier to use. Sometime in the not too far future I hope we will lbe able to spend more time on RMock than we can currently do for different reasons. /Joakim Ohlrogge On 5/18/07, David Corbin <dc...@al...> wrote: > > One thing I've run across a few times is this situation. > > I'm going to pass an argument to a mocked service, and the equals method > doesn't accurately work for the test. In my current case, it's a > "reference > object" so equality is based on an ID, but what I care about is that > certain > fields are set "just so". > > Now, I've managed to write my own Expression that I can use that works for > the > specific case, but it seems to me that there ought to be some Constraint > that > would work by comparing named fields and/or properties. Is there such? > > Thanks > David > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Rmock-users mailing list > Rmo...@li... > https://lists.sourceforge.net/lists/listinfo/rmock-users > |
From: David C. <dc...@al...> - 2007-05-18 15:02:18
|
One thing I've run across a few times is this situation. I'm going to pass an argument to a mocked service, and the equals method doesn't accurately work for the test. In my current case, it's a "reference object" so equality is based on an ID, but what I care about is that certain fields are set "just so". Now, I've managed to write my own Expression that I can use that works for the specific case, but it seems to me that there ought to be some Constraint that would work by comparing named fields and/or properties. Is there such? Thanks David |