You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(30) |
Sep
(19) |
Oct
(3) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(11) |
Feb
(13) |
Mar
(10) |
Apr
(11) |
May
(7) |
Jun
(8) |
Jul
(5) |
Aug
(16) |
Sep
(14) |
Oct
(3) |
Nov
(9) |
Dec
|
2003 |
Jan
(5) |
Feb
(6) |
Mar
(9) |
Apr
(31) |
May
(25) |
Jun
(22) |
Jul
(28) |
Aug
(27) |
Sep
(19) |
Oct
(4) |
Nov
(7) |
Dec
(26) |
2004 |
Jan
(8) |
Feb
(13) |
Mar
(5) |
Apr
(8) |
May
(8) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(4) |
2005 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2008 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
(3) |
May
|
Jun
|
Jul
(6) |
Aug
|
Sep
(10) |
Oct
(6) |
Nov
|
Dec
(36) |
2009 |
Jan
(3) |
Feb
(14) |
Mar
(13) |
Apr
(18) |
May
(35) |
Jun
(18) |
Jul
(27) |
Aug
(6) |
Sep
(2) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
(6) |
Feb
(1) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
From: Michael H. <mho...@am...> - 2003-10-20 23:59:09
|
> Hi! >=20 > I have a method that modifies two of its arguments (both of them are = lists). > I'd like to use callable decorators (or something) in my mock object = to handle this. >=20 > In http://www.mockobjects.com/wiki/CallableDecorators there is an = example of calling the add() method with a mock object and a note that = it came from Nat's branch. I can't seem to find the correct sources -- = could someone point me in the right direction? >=20 > Thanks > michael CONFIDENTIALITY AND SECURITY NOTICE: This e-mail, including any attachments, may contain confidential and = proprietary information and may be legally privileged or otherwise = protected by law. It may be read and used solely by the intended = recipient(s), and any review, use or distribution by others is strictly = prohibited. If you are not an intended recipient, please notify us = immediately by replying to the sender and delete this e-mail, including = any attachments, from your system immediately without reading, copying = or distributing them. Thank you for your cooperation. Amaranth and its affiliates retain all proprietary rights they may have = in the information. We cannot give any assurances that this e-mail or = any attachments are free of viruses or other harmful code. We reserve = the right to monitor, intercept and block all communications involving = our computer systems. |
From: Joel S. <joe...@ya...> - 2003-10-08 15:39:32
|
Does anyone have mock objects for the java.util.logging.Logger class? Unfortunately, it's not an interface so I can't use DynaMock. -joel __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com |
From: Joel S. <joe...@ya...> - 2003-10-07 03:12:20
|
Well, I found one way, though I would certainly welcome others' solutions. Using NamingManager.setInitialContextFactoryBuilder() as follows: private Mock setupTestJNDI() throws NamingException { final Mock mock = new Mock(Context.class); NamingManager.setInitialContextFactoryBuilder(new InitialContextFactoryBuilder() { public InitialContextFactory createInitialContextFactory(Hashtable environment) throws NamingException { TestFactory.context = (Context)mock.proxy(); TestFactory factory = new TestFactory(); return factory; } }); return mock; } --- Joel Shellman <joe...@ya...> wrote: > How are people testing JNDI lookups and such? I see > a > MockContext class in the mockobjects library, but > nothing about MockInitialContextFactory. > > Ie. if a class calls new InitialContext() what do > you > do to test it by controlling what it recieves? > > I tried to write a quick and dirty mock for > InitialContextFactory but ran into trouble because > it's loaded in a different class loader. So even > setting a static variable on the class did not work. > > So I'm wondering what other people are doing to test > this? > > -joel > > __________________________________ > Do you Yahoo!? > The New Yahoo! Shopping - with improved product > search > http://shopping.yahoo.com > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Mockobjects-java-users mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com |
From: Joel S. <joe...@ya...> - 2003-10-07 02:46:45
|
How are people testing JNDI lookups and such? I see a MockContext class in the mockobjects library, but nothing about MockInitialContextFactory. Ie. if a class calls new InitialContext() what do you do to test it by controlling what it recieves? I tried to write a quick and dirty mock for InitialContextFactory but ran into trouble because it's loaded in a different class loader. So even setting a static variable on the class did not work. So I'm wondering what other people are doing to test this? -joel __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com |
From: <st...@m3...> - 2003-09-27 13:38:29
|
please post an example of a test and its failure. S. On 26 September, 2003, Tony Ennis wrote: > examples. I am getting error messages from mock that I just=20 > don't understand.=20 |
From: Nat P. <nat...@b1...> - 2003-09-24 11:17:12
|
The Callable interface only defines three methods. It's very easy to implement. More details are on the Wiki. Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 ----- Original Message ----- From: "veny" <ve...@p2...> To: "MockObject users (E-mail)" <moc...@li...>; "MockObjects devs (E-mail)" <moc...@li...> Sent: Wednesday, September 24, 2003 3:42 AM Subject: [MO-java-users] Re: A kind of "don't care" Mock? > > Hi, > > I am having the same problem. Any easier way than writing a custom Callable > objects? > or how to easily write a Callable object that fulfils what is required. > > Thanks. > > Veny > > From: Nat Pryce <nat@b1...> > Re: A kind of "don't care" Mock? > 2003-09-23 14:17 > With the dynamic mocks you can write your own Callable objects to match > against any method or in some other custom manner. > > Cheers, > Nat. > > _______________________ > Dr. Nathaniel Pryce > B13media Ltd. > http://www.b13media.com > +44 (0)7712 526 661 > > ----- Original Message ----- > From: "Frederic Donckels" <frederic.donckels@ac...> > To: <mockobjects-java-users@li...> > Sent: Tuesday, September 23, 2003 11:11 AM > Subject: [MO-java-users] A kind of "don't care" Mock? > > > > Hi all, > > > > I must confess I haven't thoroughly searched through either Wiki, > > the lists or the source code (Flame disclaimer :) ) > > > > Is there a way to create a mock with a default 'I don't care' > > behaviour for most of the methods? > > What I mean is that, for some tests, there might be a bunch of > > methods called, for which I don't want to set expectations (because > > sometimes I don't know which methods will be called, how many times, > > ..., or if the mock-proxy is temporarily handled to an outside object > > for which I don''t have the source code, or I just don't care to > > provide an 'implementation' (hashcode, toString, ..)). > > For those methods, I'd just like to set a global default behaviour: > > - match any call, with any args (or no args) > > - return a default value (true or false for boolean, 0 for numeric > > values, null for objects) (with this default value that could be > > changed). > > > > but still to be able to set expectations on methods I care. > > > > In the same way, is there a way to say "this method will be called, > > I don't care how many times, just return always this value" ? > > > > Thanks!! > > > > Regards > > > > Frederic > > |
From: Frederic D. <fre...@ac...> - 2003-09-24 09:19:48
|
Nat Pryce wrote: > With the dynamic mocks you can write your own Callable objects to match > against any method or in some other custom manner. Ok, I roughly see what I should do. In the Wiki, I read: ----- This is sugar for: mock.add( new CallOnceExpectation( new NameMatcher( "methodName", new ArgumentMatcher( expectedArguments, new ReturnStub( result ) ) ) ) ); ----- But there's no add method anywhere in Mock. I guess I could use the expect(InvokableMatcher) method? But this is available on CoreMock, not on Mock. Any hint? best regards, Fr=E9d=E9ric |
From: Nat P. <nat...@b1...> - 2003-09-23 21:17:55
|
With the dynamic mocks you can write your own Callable objects to match against any method or in some other custom manner. Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 ----- Original Message ----- From: "Frederic Donckels" <fre...@ac...> To: <moc...@li...> Sent: Tuesday, September 23, 2003 11:11 AM Subject: [MO-java-users] A kind of "don't care" Mock? > Hi all, > > I must confess I haven't thoroughly searched through either Wiki, > the lists or the source code (Flame disclaimer :) ) > > Is there a way to create a mock with a default 'I don't care' > behaviour for most of the methods? > What I mean is that, for some tests, there might be a bunch of > methods called, for which I don't want to set expectations (because > sometimes I don't know which methods will be called, how many times, > ..., or if the mock-proxy is temporarily handled to an outside object > for which I don''t have the source code, or I just don't care to > provide an 'implementation' (hashcode, toString, ..)). > For those methods, I'd just like to set a global default behaviour: > - match any call, with any args (or no args) > - return a default value (true or false for boolean, 0 for numeric > values, null for objects) (with this default value that could be > changed). > > but still to be able to set expectations on methods I care. > > In the same way, is there a way to say "this method will be called, > I don't care how many times, just return always this value" ? > > Thanks!! > > Regards > > Frederic > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Mockobjects-java-users mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users |
From: Tapi N. <ta...@ho...> - 2003-09-23 14:50:30
|
Hello, Can anyone suggest me MockObjects Framework for testing Web Components? I tested Mockrunner which was quite nice and ok, but in my case it was not suitable for all my purposes. I have to use third party vendor's Web framework where are e.g. own Filter classes that are not implementing javax.servlet.Filter interface. That Web framework contains also other incompatibilities that were not accepted by Mockrunner. I also tried MockCreator but using it for testing Web Components requires me to make Mocks for all Servlet API classes that my servlets, filters and tags are using. So, maybe that is not quite elegant way to do it... at least there would a lot of Mocks to be generated. Can anyone explain me how you have used MockObject products for testing Web Componets? Is there a possibilities to use e.g. Mockrunner with some other Mock tool or how should I handle testing with Mocks? I really like to use this technique. Thanks, tapi _________________________________________________________________ MSN Messenger - kaikki ystävät klikkauksen päässä! Lataa tästä ilmaiseksi. http://www.msn.fi/viestintapalvelut/Messenger |
From: Frederic D. <fre...@ac...> - 2003-09-23 10:12:05
|
Hi all, I must confess I haven't thoroughly searched through either Wiki, the lists or the source code (Flame disclaimer :) ) Is there a way to create a mock with a default 'I don't care' behaviour for most of the methods? What I mean is that, for some tests, there might be a bunch of methods called, for which I don't want to set expectations (because sometimes I don't know which methods will be called, how many times, ..., or if the mock-proxy is temporarily handled to an outside object for which I don''t have the source code, or I just don't care to provide an 'implementation' (hashcode, toString, ..)). For those methods, I'd just like to set a global default behaviour: - match any call, with any args (or no args) - return a default value (true or false for boolean, 0 for numeric values, null for objects) (with this default value that could be changed). but still to be able to set expectations on methods I care. In the same way, is there a way to say "this method will be called, I don't care how many times, just return always this value" ? Thanks!! Regards Frederic |
From: Nat P. <nat...@b1...> - 2003-09-22 12:40:49
|
Create an Constraint[] array with constraint objects in it. e.g. new Constraint[] { C.eq(1), C.eq(2), C.eq(3), C.eq(4) } Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 ----- Original Message ----- From: "veny" <ve...@p2...> To: "MockObject users (E-mail)" <moc...@li...>; "MockObjects devs (E-mail)" <moc...@li...> Sent: Monday, September 22, 2003 12:28 PM Subject: [MO-java-dev] ConstraintsMatcher for more than 3 input arguments? C.args()? > Hi all, > > How to use ConstraintsMatcher to verify method that has 4 input parameters? > Or is there any other way to do that? > By the way, how to use C.args(), C.args(Constraints, Constraints), > C.args(Constraints, Constraints, Constraints) methods? > > Thanks. > > Veny > > ____________________________________________ > P2H > 136 Telok Ayer St. > Singapore. 068601 > www.p2h.com.sg > > > Veny Handoko > Software Developer > > Tel : +65 6372 2473 > > Fax : +65 6225 1023 > > Mobile : +65 9681 8617 > ve...@p2... > > > -------------------------------------------------------------------------- -- > ---- > > Email disclaimer > The email, its content and any files transmitted with it are intended solely > for the addressee(s) and may be legally privileged and/or confidential. > Access by any other party is unauthorised without the express written > permission of the sender. If you received this email in error,you may not > copy or use the contents, attachments or information in any way. Please > destroy it and contact the sender on the number printed above or via email > return. Internet communications are not secure unless protected using strong > cryptography. This email has been prepared using information believed by the > author to be reliable and accurate, but P2H Pte Ltd makes no warranty as to > accuracy or completeness. In particular P2H Pte Ltd does not accept > responsibility for changes made to this email after it was sent. Any > opinions expressed in this document are those of the author and do not > necessarily reflect the opinions of P2H Pte Ltd or its affiliates. > |
From: veny <ve...@p2...> - 2003-09-22 11:28:25
|
Hi all, How to use ConstraintsMatcher to verify method that has 4 input parameters? Or is there any other way to do that? By the way, how to use C.args(), C.args(Constraints, Constraints), C.args(Constraints, Constraints, Constraints) methods? Thanks. Veny ____________________________________________ P2H 136 Telok Ayer St. Singapore. 068601 www.p2h.com.sg Veny Handoko Software Developer Tel : +65 6372 2473 Fax : +65 6225 1023 Mobile : +65 9681 8617 ve...@p2... ---------------------------------------------------------------------------- ---- Email disclaimer The email, its content and any files transmitted with it are intended solely for the addressee(s) and may be legally privileged and/or confidential. Access by any other party is unauthorised without the express written permission of the sender. If you received this email in error,you may not copy or use the contents, attachments or information in any way. Please destroy it and contact the sender on the number printed above or via email return. Internet communications are not secure unless protected using strong cryptography. This email has been prepared using information believed by the author to be reliable and accurate, but P2H Pte Ltd makes no warranty as to accuracy or completeness. In particular P2H Pte Ltd does not accept responsibility for changes made to this email after it was sent. Any opinions expressed in this document are those of the author and do not necessarily reflect the opinions of P2H Pte Ltd or its affiliates. |
From: Steve F. <st...@m3...> - 2003-09-17 07:21:42
|
At that point you might as well write your mocks by hand -- the expectation library will help you do this. We have some ideas about dynmically mocking classes, but haven't had the time to patch them in. S. veny wrote: > What i actually meant was that i want my mock class to take in expectation > of a method being called and verify whether the method has been called at > the end (i.e. when .verify() method is called). I understand > dynamic.Mock.expect(String methodName) does that. I cant use dynamic.Mock as > the dynamic.Mock can only mock an interface, but i need to mock a class > implementation. > > So my issue is how to write my mock class that so that it can perform a > function like dynamic.Mock.expect(String methodName)? Any idea? |
From: veny <ve...@p2...> - 2003-09-17 02:24:56
|
Hi Steve, Thanks for your reply. What i actually meant was that i want my mock class to take in expectation of a method being called and verify whether the method has been called at the end (i.e. when .verify() method is called). I understand dynamic.Mock.expect(String methodName) does that. I cant use dynamic.Mock as the dynamic.Mock can only mock an interface, but i need to mock a class implementation. So my issue is how to write my mock class that so that it can perform a function like dynamic.Mock.expect(String methodName)? Any idea? Thanks lots. Veny -----Original Message----- From: Steve Freeman [mailto:st...@m3...] Sent: Tuesday, September 16, 2003 3:09 PM To: ve...@p2... Cc: 'Francois Beausoleil'; MockObject users (E-mail); MockObjects devs (E-mail) Subject: Re: [MO-java-users] RE: [MO-java-dev] creating a dynamic mock error - com.packagename.classname is not an interface. veny wrote: > I have another question thought. How should i write the equivalent of > methods 'dynamic.Mock.expect(String methodName)' and > 'dynamic.Mock.expectAndReturn(String methodName, java.lang.Object obj)' in > own Mock object? If you mean when writing a mock object using the dynamic libraries, then no. The Dynamic Mock will do the work. If you mean, when writing your own mock objects from scratch, then you should write some kind of expectation, but how you write that is up to you. S. |
From: Steve F. <st...@m3...> - 2003-09-16 07:10:11
|
veny wrote: > I have another question thought. How should i write the equivalent of > methods 'dynamic.Mock.expect(String methodName)' and > 'dynamic.Mock.expectAndReturn(String methodName, java.lang.Object obj)' in > own Mock object? If you mean when writing a mock object using the dynamic libraries, then no. The Dynamic Mock will do the work. If you mean, when writing your own mock objects from scratch, then you should write some kind of expectation, but how you write that is up to you. S. |
From: veny <ve...@p2...> - 2003-09-16 06:37:23
|
Hi Francois, Thanks for your explanation. I have another question thought. How should i write the equivalent of methods 'dynamic.Mock.expect(String methodName)' and 'dynamic.Mock.expectAndReturn(String methodName, java.lang.Object obj)' in own Mock object? Is there any sample available? Thanks lots. Veny -----Original Message----- From: Francois Beausoleil [mailto:fb...@us...] Sent: Tuesday, September 16, 2003 11:43 AM To: ve...@p2... Subject: Re: [MO-java-dev] creating a dynamic mock error - com.packagename.classname is not an interface. As you have noticed, you cannot mock classes. For your information, java.util.List is an interface, not a class. ArrayList and LinkedList are actual implementations of the List interface. To mock concrete classes, you have to resort to the old way: public class ObjectUnderTest { public void method(Object arg) { // Do something } } public class MockObjectUnderTest extends ObjectUnderTest implements Verifiable { private ExpectationValue expectedArg = new ExpectationValue("arg"); public void setExpectedArg(Object arg) { expectedArg.setExpected(arg); } public void method(Object arg) { expectedArg.setActual(arg); // Might call into super class to execute the code for real, or not, // depending on your needs. } public void verify() { // This asserts that all Verifiable objects in this class have their // verify() methods called, and any exceptions thrown up the // call stack Verifier.verifyObject(this); } } That is why most programmers and designers recommend coding against interfaces. This helps because you can then send in a mock implementation. DynaMocks are simpler to setup than old-style Mocks. I sure hope that helps ! If you have other questions, do not hesitate ! François On Tue, 16 Sep 2003 10:06:14 +0800, "veny" <ve...@p2...> said: > Hi all, > > I've been using DynaMock to create mock class from interfaces. It works > great. However, when i tried to mock my classes, there's always this > error: > "com.packagename.classname is not an interface". I've tried to mock java > class (e.g. java.util.List), it works. But why creating of mock of my > custom > class doesn't? Any idea? > > Thanks. > > Veny Developer of Java Gui Builder http://jgb.sourceforge.net/ |
From: veny <ve...@p2...> - 2003-09-16 02:06:56
|
Hi all, I've been using DynaMock to create mock class from interfaces. It works great. However, when i tried to mock my classes, there's always this error: "com.packagename.classname is not an interface". I've tried to mock java class (e.g. java.util.List), it works. But why creating of mock of my custom class doesn't? Any idea? Thanks. Veny |
From: Francois B. <fb...@us...> - 2003-09-12 02:22:46
|
Hello Veny, Here is a bit of information for you: expectAndReturn() Expect a call to the named method using the specified argument or arguments, and return the specified value. It is possible to also throw an Exception instead by using expectAndThrow(). As you have guessed, expectAndReturn() will fail the verification if the method has not been called. matchAndReturn() Stub out a method call. This would be useful in the case where you will be calling a method, but do not care if the method is called once, twice or no time at all. ConstraintMatcher It is possible to specify constraints on the parameters that are received. Let's say you are mocking a List. Lists have a method named Object get(int index). It is possible to ask the expectAndReturn method to assert that the method is called with an appropriate parameter. An example will help: Mock mockList =3D new Mock(List.class); List list =3D (List)mockList.proxy(); mockList.expectAndReturn("get", C.eq(3), "returned object"); // This is where the domain methods call upon the mock classUnderTest.method(list); mockList.verify(); Given the above, the following implementation will fail: public void method(List list) { int index =3D 4; this.object =3D list.get(index); } It will fail because the expectAndReturn() method expected a single parameter, and it must have been equal to 3 (C.eq stands for ConstraintMatcher Shortcuts.equals(3)). Given the above too, this implementation will fail the verify() stage: public void method(List list) { } The Mock expected the get() method to be called with 3 as an argument, but did not receive it. Finally, if you overload your methods, the same principles as Java apply: interface User { addBilling(double x); addBilling(long x); } Mock mockUser =3D new Mock(User.class); User user =3D (User)mockUser.proxy(); user.expect("addBilling", C.eq(new Double(13.2d))); user.expect("addBilling", C.eq(new Long(17l))); classUnderTest.do(user); public void do(User user) { user.addBilling(17); // Passes. Java calls addBilling(long) user.addBilling(13.2f); // Passes. Java calls addBilling(double) } As for your last question, if the method that you expect a call upon accepts a single parameter, and you want to assert equality, Mock implementations allow a shortcut. Instead of this: user.expect("addBilling", C.eq(new Double(13.2d))); You can do this instead: user.expect("addBilling", new Double(13.2d)); Notice that the C.eq() was removed. We are expecting equality, and this will assert it just fine. For documentation, you can try http://www.mockobjects.org/. This will bring you to the MockObjects Wiki. There is information on the wiki about the framework. Not everything is documented, but a good bit of it is available. Have a nice day ! Fran=E7ois On Fri, 12 Sep 2003 09:39:18 +0800, "veny" <ve...@p2...> said: > Hi all, >=20 > I am new to mockobject and looking through the DynaMock class. > Could somebody give me some idea, what does the following methods in > com.mockobjects.dynamic.Mock class do? >=20 > expectAndReturn(java.lang.String methodName, ConstraintMatcher args, > java.lang.Object result) > expectAndReturn(java.lang.String methodName, java.lang.Object > singleEqualArg, boolean result) >=20 > I understand the above methods is setting the return value for the named > method. But some questions: > - How does ConstraintMatcher works? > - For the second method, what is the use of parameter singleEqualArg? > - These methods are name expectAndReturn, does it implies that if the > named > method is not called, it will throw an error? - How bout if the codes > have > methods overloading, how does expectAndReturn know which method i am > referring to? >=20 > matchAndReturn(java.lang.String methodName, java.lang.Object result) > How is this different from expectAndReturn? >=20 > The javadoc has rather limited explanation, any recommendation to sites > that > have sample or more detailed explanation? >=20 > Thanks lots. >=20 > Veny Developer of Java Gui Builder http://jgb.sourceforge.net/ |
From: veny <ve...@p2...> - 2003-09-12 01:39:24
|
Hi all, I am new to mockobject and looking through the DynaMock class. Could somebody give me some idea, what does the following methods in com.mockobjects.dynamic.Mock class do? expectAndReturn(java.lang.String methodName, ConstraintMatcher args, java.lang.Object result) expectAndReturn(java.lang.String methodName, java.lang.Object singleEqualArg, boolean result) I understand the above methods is setting the return value for the named method. But some questions: - How does ConstraintMatcher works? - For the second method, what is the use of parameter singleEqualArg? - These methods are name expectAndReturn, does it implies that if the named method is not called, it will throw an error? - How bout if the codes have methods overloading, how does expectAndReturn know which method i am referring to? matchAndReturn(java.lang.String methodName, java.lang.Object result) How is this different from expectAndReturn? The javadoc has rather limited explanation, any recommendation to sites that have sample or more detailed explanation? Thanks lots. Veny |
From: Nat P. <nat...@b1...> - 2003-09-11 12:41:05
|
From: "veny" <ve...@p2...> > I am writing some test using DynaMock and wondering what is a good practice > in returning a float value using Mock.expectAndReturn(String methodName, > Object obj) method. If there is no explicit overloaded expectAndReturn method for float results, create a new Float object to wrap the primitive value. The underlying proxy API will "unbox" the object to a primitive float when the call to the mocked method returns. E.g. myMock.expectAndReturn( "methodName", new Float(1.0f) ); Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 |
From: veny <ve...@p2...> - 2003-09-11 11:07:39
|
Hi all, I am new to mock object. I am writing some test using DynaMock and wondering what is a good practice in returning a float value using Mock.expectAndReturn(String methodName, Object obj) method. Hope to hear from you soon. Thanks. Veny |
From: Steve F. <st...@m3...> - 2003-09-08 06:58:35
|
There's a constructor in Mock (for the release) and CoreMock (for the=20 CVS head) that allows you to pass in the collection that gathers=20 expectations. I think you can achieve what you want by making both mock=20 implementations share a common expectation collection. We have some ideas about how to specify precedence but we have to do=20 some more clean-up first. S. Fran=E7ois Beausoleil wrote: > I'm using DynaMocks 0.09 and would like to know if one can check the=20 > sequence of calls between more than one mock. >=20 > For example, I am writing tests for an object that should retry=20 > operations once on the object, but must call another one in the mean ti= me: >=20 > public void method() throws FailureException { > try { > obj.operation(); > } catch (FailureException e) { > obj =3D obj2.factory(); > obj.operation(); > } > } >=20 > So, both mocks should cooperate to determine if the correct sequence of= =20 > operations was executed. |
From: Nat P. <nat...@b1...> - 2003-08-28 10:11:39
|
Read this documentation for more info about constraints: http://www.mockobjects.com/wiki/ParameterConstraints Although I would identify methods with lots of parameters as a "code smell" that indicates that you should refactor the parameters into a new class of object. Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 ----- Original Message ----- From: "Guofeng Zhang" <guo...@vi...> To: <moc...@li...> Sent: Thursday, August 28, 2003 6:26 AM Subject: [MO-java-users] How to set expection for a method with a lot of arguments My question is how to set expection for a method with a lot of arguments in a mock object. For example, there is a Timer interface: public interface Timer { int getTime( Type1 arg1, Type2 arg2, Type3 arg3, Type4 arg4, Type5 arg5 ); } In the following test code: Mock mockTimer = new Mock(Timer.class); mockTimer.expectAndReturn("getTime", ???); How to set the above expection. How to express that the getTime() can be invoked 5 times for example. Another question is: What is the difference between C.args() and C.eq(). How Constraint class and ConstraintMacher class are used. Thanks ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Mockobjects-java-users mailing list Moc...@li... https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users |
From: Guofeng Z. <guo...@vi...> - 2003-08-28 05:26:44
|
My question is how to set expection for a method with a lot of = arguments in a mock object. For example, there is a Timer interface: public interface Timer=20 { =20 int getTime( Type1 arg1, Type2 arg2, Type3 arg3, Type4 arg4, Type5 = arg5 ); } In the following test code: Mock mockTimer =3D new Mock(Timer.class); mockTimer.expectAndReturn("getTime", ???);=20 How to set the above expection. How to express that the getTime() can be = invoked 5 times for example. Another question is:=20 What is the difference between C.args() and C.eq(). How Constraint = class and ConstraintMacher class are used. Thanks |
From: <DeS...@em...> - 2003-08-27 13:48:25
|
Nat, > Something like this: > > Mock semanticsMock = new Mock(CallSemantics.class); > Pluxie pluxie = new Pluxie(); > > semanticsMock.expectAndReturn( "configure", C.args(C.same(pluxie)), > pluxie ); Thanks. It worked. However, my main confusion was that I was looking for an API where I could specify an expecation on a method with a specific signature (argument list). How do you handle expectations on overloaded methods, for example, what would your write if the Pluxie interface would have read: public interface CallSemantics { Pluxie configure(Pluxie pluxieToConfigure); Other configure(Other otherToConfigure); } How does the framework distinguishes the expectations between the overloaded methods? Ringo |