<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/">
  <channel rdf:about="http://blog.gmane.org/gmane.comp.java.jmock.user">
    <title>gmane.comp.java.jmock.user</title>
    <link>http://blog.gmane.org/gmane.comp.java.jmock.user</link>
    <description/>
    <syn:updatePeriod>hourly</syn:updatePeriod>
    <syn:updateFrequency>1</syn:updateFrequency>
    <syn:updateBase>1901-01-01T00:00+00:00</syn:updateBase>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/2023"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/2020"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/2018"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/2015"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/2004"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1981"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1980"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1979"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1971"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1963"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1952"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1949"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1942"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1932"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1930"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1927"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1910"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1904"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1902"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.java.jmock.user/1900"/>
      </rdf:Seq>
    </items>
    <image rdf:resource="http://gmane.org/img/gmane-25t.png"/>
    <textinput rdf:resource=""/>
  </channel>
  <image rdf:about="http://gmane.org/img/gmane-25t.png">
    <title>Gmane</title>
    <url>http://gmane.org/img/gmane-25t.png</url>
    <link>http://gmane.org</link>
  </image>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/2023">
    <title>how to test property of argument passed to method?</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/2023</link>
    <description>What is the proper way to test a property of an argument passed into a
method of a mock, under JMock 2.5?

Let's say that my CUT would normally be called like:

   myObject.myMethod(arg);

and I'd like to verify that "arg" is of a particular type, and that it has a
particular property set.  I'm trying to do this:

   one(mock).myMethod(with(hasProperty("prop", eq("value"))));

but hasProperty() returns Object, while myMethod() is expecting type
Argument.

I *can* do the following, which works:

   one(mock).myMethod(with(any(Argument.class)));

I've been googling this problem for 2 days now, so any help would be greatly
appreciated, thanks.
</description>
    <dc:creator>Limbic System</dc:creator>
    <dc:date>2008-10-02T03:19:19</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/2020">
    <title>"java.lang.IllegalArgumentException: a mock with name ... already exists" with jmock2.5.0</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/2020</link>
    <description>Hi

I got a problem with jmock2.5.0.

Below is my tests that past under jmock2.2.0. After upgrading jmock to 
2.5.0, these tests got failed with the stack trace below.

    &lt; at &gt;Test
    public void testCollectMissDataRight() throws Exception {
        final Collector  collector0 = context.mock(Collector.class);
        final SocketSession fSession = context.mock(SocketSession.class);

        MaintenanceSession session =
            new MaintenanceSession(null,collector0);

        context.checking(new Expectations() {
            {
                one(collector0).isConnectedSector(with(equal("TACC00")));
                will(returnValue(fSession));
                one(fSession).startCollectLeftData((byte[])with(anything()));

            }
        });
        byte[] data = "0000004820000001234567890123456789012345678999 
TACC00  ".getBytes();
        session.processData(data);
        context.assertIsSatisfied();
    }

    &lt; at &gt;Test
    public void testCollectMissDataWrong() throws Exception {
        final Collector  collector1 = context.mock(Collector.class);
        final SocketSession fSession1 = context.mock(SocketSession.class);

        MaintenanceSession session =
            new MaintenanceSession(null,collector1);

        context.checking(new Expectations() {
            {
                one(collector1).isConnectedSector(with(equal("TACC00")));
                will(returnValue(null));
                never(fSession1).startCollectLeftData((byte[])with(anything()));
                one(collector1).processAPError((String)with(anything()));
            }
        });
        byte[] data = "0000004820000001234567890123456789012345678999 
TACC00  ".getBytes();
        session.processData(data);
        context.assertIsSatisfied();
    }


java.lang.IllegalArgumentException: a mock with name collector already 
exists
 at org.jmock.Mockery.mock(Mockery.java:128)
 at org.jmock.Mockery.mock(Mockery.java:120)
 at 
rae07a.collect.MaintenanceSessionTest.testCollectMissDataWrong(MaintenanceSessionTest.java:45)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
 at 
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
 at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
 at 
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
 at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
 at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
 at 
org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
 at 
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
 at 
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
 at 
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
 at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
 at 
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
 at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
 at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
 at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
 at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
 at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

I got into jmock2.50 source and found out this problem has something to do 
with defaultNameFor method which always gives the same name for the same 
class.

    public &lt;T&gt; T mock(Class&lt;T&gt; typeToMock) {
  return mock(typeToMock, namingScheme.defaultNameFor(typeToMock));
 }

Maybe this is supposed to do. Can anybody help me with some answer?

James



----------------------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this e-mail and any
accompanying attachment(s) is intended only for the use of the intended
recipient and may be confidential and/or privileged of Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is not the intended recipient, unauthorized use, forwarding, printing, storing, disclosure or copying is strictly prohibited, and may be unlawful. If you have received this communication in error, please immediately notify the sender by return e-mail, and delete the original message and all copies from your system. Thank you. 
-----------------------------------------------------------------------------------------------

</description>
    <dc:creator>王軍＠Neusoft</dc:creator>
    <dc:date>2008-09-19T01:42:24</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/2018">
    <title>how to test exception condition in Junit</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/2018</link>
    <description>i am trying to write a test case for the exception scenario.
my code looks as below.


*public* ActionForward execute(ActionMapping mapping, ActionForm actionForm,
HttpServletRequest request, HttpServletResponse response) *throws* Exception
{

ActionForward actionforward = *null*;

*try*{

SimpleDateFormat format = *new* SimpleDateFormat(ReportingConstant.*
DATE_FORMAT*);

ReportRequest reportReq = *new* ReportRequest();

String distID = request.getParameter("distId");

String beginDate = request.getParameter("beginDate");

String endDate = request.getParameter("endDate");

*if*(*null* != beginDate){

reportReq.setBeginDate(format.parse(beginDate));

}*else*{

*LOG*.error("Begin date not present in the received form ");

*throw* *new* ReportingException("Begin date not present in the received
form");

}

*if*(*null* != endDate){

reportReq.setEndDate(format.parse(endDate));

}*else*{

*LOG*.error("End date not present in the received form ");

*throw* *new* ReportingException("End date not present in the received form"
);

}

*if*(*null* != distID){

reportReq.setDistributorId(distID);

}*else*{

*LOG*.error("Distributor Id not present in the received form ");

*throw* *new* ReportingException("Distributor Id not present in the received
form ");

}

some code....

}*catch*(Exception e){

*LOG*.error("Error sending XLS file to the client ",e);

actionforward = mapping.findForward("exception");

}

*return* actionforward;

}



now i would like to test a execute method for exception i.e. i am expecting
that if the request obj do not have any parameters set then my code will
throw an exception.

and i need to verify that.

my test case method is like..

*public* *void* testDownloadXLSReportFailure()*throws* Exception{

httpServletRequestMock.expects(once())

.method("getParameter")

.with(eq("distId"))

.will(returnValue(*null*));

request = (HttpServletRequest)httpServletRequestMock.proxy();

*try*{

ActionForward forward = downloadReportAction.execute(actionMapping,
reportForm, request, response);

*fail*("Error ..");

}*catch*(Exception e){

}

}

org.jmock.core.DynamicMockError: mockHttpServletRequest: unexpected
invocation
Invoked: mockHttpServletRequest.getParameter("beginDate")
Allowed:
expected once and has been invoked: getParameter( eq("distId") ), returns
null

 at
org.jmock.core.AbstractDynamicMock.mockInvocation(AbstractDynamicMock.java:58)
 at org.jmock.cglib.CGLIBCoreMock.intercept(CGLIBCoreMock.java:71)
 at
$javax.servlet.http.HttpServletRequest$$EnhancerByCGLIB$$7c120c24.getParameter(&lt;generated&gt;)
 at
com.toro.rebate.reporting.struts.action.DownloadXLSCommercialReportAction.execute(DownloadXLSCommercialReportAction.java:47)
 at
com.toro.rebate.reporting.struts.action.DownloadXLSCommercialReportActionTest.testDownloadXLSReportFailure(DownloadXLSCommercialReportActionTest.java:116)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at junit.framework.TestCase.runTest(TestCase.java:154)
 at org.jmock.core.VerifyingTestCase.runBare(VerifyingTestCase.java:39)
 at junit.framework.TestResult$1.protect(TestResult.java:106)
 at junit.framework.TestResult.runProtected(TestResult.java:124)
 at junit.framework.TestResult.run(TestResult.java:109)
 at junit.framework.TestCase.run(TestCase.java:118)
 at junit.framework.TestSuite.runTest(TestSuite.java:208)
 at junit.framework.TestSuite.run(TestSuite.java:203)
 at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
 at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

can sombody tell me how do i chk the exception condition here?



thanks,

sush
</description>
    <dc:creator>Sushil Dodake</dc:creator>
    <dc:date>2008-09-16T21:44:53</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/2015">
    <title>writing test case for struts action?</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/2015</link>
    <description>Hi All,
i am trying to write a test case for a struts action call.
in the action call i am trying to send a file on the response output stream.
when i get the output stream using response.getOutputstream i get a object
of ServletOurtputStream.
which is a abstract class..
 i then write a byte stream on the output stream and fluch it to close
i am confused as to how to write a test case.
can sombody help me here?
any example?

regards,

Sush
</description>
    <dc:creator>Sushil Dodake</dc:creator>
    <dc:date>2008-09-16T04:21:22</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/2004">
    <title>Can I mock an enum</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/2004</link>
    <description>I was trying to write testcases for a method which takes an enum as parameter.
I dont want to pass any particular value to it.

This enum also contains a few methods that i want to mock.
Is there any way to do so?

Please let me know if my question is not clear.
I will try to post a sample then.

Thanks,
Avinash


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



</description>
    <dc:creator>Avinash Nayak</dc:creator>
    <dc:date>2008-09-12T11:01:07</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1981">
    <title>Mocking Objects</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1981</link>
    <description>Hi,

Pardon me for a not so great subject :). Anyways, my question follows:

Consider src file X.java

Y obj1;
Z obj2 = Y.f();
obj2.g();

Consider the mocking file XMock.java
I am creating 2 mock objects

mock1 = mock object of class Y
mock2 = mock object of class Z;

/* Now, for the code :) */
one(mock1).f();will(returnValue(mock2));
one(mock2).g();

Q: Is this ok ? It throws an exception saying "forgot to mention an
expectation?" on the line "obj2.g()" (in X.java)

Thanks
Vivek
</description>
    <dc:creator>Vivek R</dc:creator>
    <dc:date>2008-08-26T05:56:40</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1980">
    <title>Mocking Objects</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1980</link>
    <description>Hi,

Pardon me for a not so great subject :). Anyways, my question follows:

Consider src file X.java

Y obj1;
Z obj2 = Y.f();
obj2.g();

Consider the mocking file XMock.java
I am creating 2 mock objects

mock1 = mock object of class Y
mock2 = mock object of class Z;

/* Now, for the code :) */
one(mock1).f();will(returnValue(mock2));
one(mock2).g();

Q: Is this ok ? It throws an exception saying "forgot to mention an
expectation?" on the line "obj2.g()" (in X.java)

Thanks
Vivek
</description>
    <dc:creator>Vivek R</dc:creator>
    <dc:date>2008-08-26T05:56:29</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1979">
    <title>2.5.1 Released</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1979</link>
    <description>We've just released jMock 2.5.1, a bug-fix release that improves error messages.

The changelog is at:

http://jira.codehaus.org/secure/ReleaseNote.jspa?projectId=10336&amp;styleName=Html&amp;version=14527

--Nat

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



</description>
    <dc:creator>Nat Pryce</dc:creator>
    <dc:date>2008-08-24T10:20:55</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1971">
    <title>a question on jMock use</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1971</link>
    <description>

Hi, 
      Sorry for inconvenience. I have a question on jMock use. Would you PLS give me some comments?
      I have a class Foo and an interface Goo like below:
       public class Foo {
        private Goo goo;
        private int i;
        
    public Foo (Goo aGoo) {
        goo = aGoo;
      i = goo.getCount();
        } 
        
        public int getI (){
           return i;
        }
        
        public void incre () {
           goo.incre();
           i = goo.getCount();
        }
    
}
 
public interface Goo {
        
        public void incre ();
        
        public int getCount ();
    
}
 
And I set up a test case like below:
public class oneTest extends TestCase {
        
    protected void setUp() throws Exception {
           super.setUp();
    }
    
        protected void tearDown() throws Exception {
        super.tearDown();
        }
    
    public void testSth () {
        Mockery mockery = new Mockery();
    final Goo mockGoo = mockery.mock(Goo.class, "MockGoo");
        
    mockery.checking(new Expectations() {
               {
                one(mockGoo).incre();
                   one(mockGoo).getCount();
                    will(returnValue(1));
               }
        });
        
        Foo aFoo = new Foo(mockGoo);
        
    aFoo.incre();
        
    mockery.assertIsSatisfied();
        }
    
}
 
But after I run the test case I get below error. And if I remove “i = goo.getCount();” from Foo’s constructor, it is OK. Does it means that we should not use the mock objects (in my code is Goo)’ method in the constructor of the class (in my code is Foo) to be tested?
 
Thank you very much!
-         Wei Yang
 
Error:
unexpected invocation: MockGoo.getCount()expectations: expected once, already invoked 1 time: MockGoo.incre(); returns a default value expected once, already invoked 1 time: MockGoo.getCount(); returns &lt;1&gt;what happened before this: MockGoo.getCount() MockGoo.incre() at org.jmock.internal.InvocationDispatcher.dispatch(InvocationDispatcher.java:56) at 
org.jmock.Mockery.dispatch(Mockery.java:218) at 
org.jmock.Mockery.access$000(Mockery.java:43) at 
org.jmock.Mockery$MockObject.invoke(Mockery.java:258) at 
org.jmock.internal.InvocationDiverter.invoke(InvocationDiverter.java:27) at 
org.jmock.internal.FakeObjectMethods.invoke(FakeObjectMethods.java:38) at org.jmock.lib.JavaReflectionImposteriser$1.invoke(JavaReflectionImposteriser.java:33) at 
$Proxy45.getCount(Unknown Source) at myTest.Foo.incre(Foo.java:18) at 
myTest.oneTest.testSth(oneTest.java:32) at 
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
_________________________________________________________________
一点即聊，MSN推出新功能“点我！”
http://im.live.cn/click/</description>
    <dc:creator>杨威</dc:creator>
    <dc:date>2008-08-20T07:29:39</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1963">
    <title>How to obtain current state of state-machine?</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1963</link>
    <description>
Hi.

Firstly; I'm very new to jMock so I apologize for any obvious oversights.

I'm using States but I can find no way to verify the final state at the end
of the test?  The only workaround I have found is declaring an (irrelevant)
method call in the desired state and making that call at the end of the test
to force a failure if the state is incorrect.

Thoughts?
</description>
    <dc:creator>MSanchez</dc:creator>
    <dc:date>2008-08-04T11:54:16</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1952">
    <title>JMock 2.5.0 maven artifacts uploaded</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1952</link>
    <description>Hi,

I've uploaded maven artifacts for release 2.5.0

Just follow instructions from http://jmock.org/maven.html replacing 
2.4.0 -&gt; 2.5.0.

Note that new module jmock-script has been added.

Any issues with it please let me know.

Cheers


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



</description>
    <dc:creator>Mauro Talevi</dc:creator>
    <dc:date>2008-07-21T19:04:56</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1949">
    <title>problem downloading jmock dependencies using maven2</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1949</link>
    <description>i'm encountering some problems downloading the jmock jars using the
specified maven configuration (http://www.jmock.org/maven.html).for some
reason, the .pom and the .sha1 files get downloaded into my local
repository, but the jar files don't. i'm using repo1.maven.org as the
download location for the dependency. i can see the jar files on the site (
http://repo1.maven.org/maven2/org/jmock/jmock-junit4/2.5.0-RC1/) but they
don't get downloaded. i'm using maven 2.0.9.
is there some other repository that i should be using instead?
cheers,
owen.
</description>
    <dc:creator>Owen Rogers</dc:creator>
    <dc:date>2008-07-17T20:47:04</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1942">
    <title>mocking concrete classes with final toString method</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1942</link>
    <description>Hi there,

I'm using jmock 2.5.0RC1. When trying to mock concrete classes with final 
toString methods, I'm getting:

java.lang.IllegalArgumentException: 
ClassNameHere has a final toString method

Looking through jira and the changelogs, this is a direct result of this 
bug:
 http://jira.codehaus.org/browse/JMOCK-150
and was implemented in changeset:
 http://fisheye.codehaus.org/changelog/jmock?cs=1152

Is there a middle ground somewhere? I'm working with 3rd party classes 
where I have no control over their class structure. JMOCK-150 seems like 
squashing a bug with a hammer.

The original bug reporter mentioned that:

 * an un-expected exception during the assertIsSatisfied() check
           (got the exception when tring to describe the mocked class using
           the final toString() which uses other methods from the original
           class)

Could the code in Mockery.assertIsSatisfied() look for the fact that a 
ClassImposteriser is being used and to bypass the toString method in case 
it is final? pseudo-code follows:

new ExpectationError("not all expectations were satisfied",
 !toStringMethodIsFinalAndUsingClassImposteriser(dispatcher) ?
 dispatcher :
 dispatcher.getClass().getName()
);

Cheers,
--
Haroon Rafique
&lt;haroon.rafique-H217xnMUJC0sA/PxXw9srA&lt; at &gt;public.gmane.org&gt;


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



</description>
    <dc:creator>Haroon Rafique</dc:creator>
    <dc:date>2008-07-16T18:39:04</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1932">
    <title>JMock 2.5.0 Released</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1932</link>
    <description>JMock 2.5.0 has been released.

The full changelog is at:

http://jira.codehaus.org/secure/ReleaseNote.jspa?projectId=10336&amp;styleName=Html&amp;version=13840


--Nat

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



</description>
    <dc:creator>Nat Pryce</dc:creator>
    <dc:date>2008-07-14T11:06:00</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1930">
    <title>JMock implementation</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1930</link>
    <description>Hi,
I just wanted to know, why JMock cannot mock a class that doesn't have an
interface ? I mean, I know if you specify
mockery.setImposteriser(ClassImposteriser.INSTANCE);, it would actually be
able to. But why is it designed in such a way that you have to specify this
to mock a class ?
Just out of curiosity, I thought every mock class would be implemented as an
extension to the original class. Could anyone throw more light on this ?

-Vivek
</description>
    <dc:creator>Vivek R</dc:creator>
    <dc:date>2008-07-14T09:20:42</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1927">
    <title>Problem facing during mocking of a Concrete Class</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1927</link>
    <description>Hi,
I am facing a prob while mocking a concrete class.
I am giving a simplified version of the prob.
In the given testcase,
 its trying to run the method, when i call mockery.checking().
Is it an expected behaviour?
Because of this,
 i am not able to use mocking of a concrete class.
I am using JMock 2.4.0.

Thanks,
avinash


package com.nayak;

public class OpClass {
public final void execute(boolean validate) {
System.out.println("In execute() : " + validate);
if (validate)
validate();
}

private void validate() {
// No Validations done
System.out.println("In validate()");
}
}

package com.nayak;

import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.lib.action.VoidAction;
import org.jmock.lib.legacy.ClassImposteriser;

import junit.framework.TestCase;

public class OpClassUTEST extends TestCase {
public void testExecute() {
Mockery mockery = new Mockery();
mockery.setImposteriser(ClassImposteriser.INSTANCE);
final OpClass opClass = mockery.mock(OpClass.class);

mockery.checking(new Expectations() {
{
one(opClass).execute(with(any(Boolean.class)));
will(VoidAction.INSTANCE);
}
});
mockery.assertIsSatisfied();
}
}

Output : "In execute() : false"


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



</description>
    <dc:creator>Avinash Nayak</dc:creator>
    <dc:date>2008-07-14T05:23:14</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1910">
    <title>Question about expectation</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1910</link>
    <description>Hi,

I'm using JMock for testing with JUnit. Everything works fine, and I've defined number of test,
but now I have one wierd problem when testing Struts actions. So I have like this in my testing class :

public class MyTestingClass {

PersonService service = context.mock(PersonService.class);
Person person = new Person();
// fill person object

&lt; at &gt;Test 
public void testMethod() throws Exception {

context.checking(new Expectations() {{
            one (service).findByUsername(person.getUsername()); will(returnValue(person));
        }});

}

// set service
// run action

}
and when this line of code is called in my class, like this:

public MainClass {

PersonService service;

get/set methods

public method() {
    person = service.findByUsername(username);

}

}

 I get this exception:
"unexpected invocation: service.findByUsername(username); 

It seems like that JMock doesn't recognize this method, but I don't get any syntax errors. What is the problem here ?

--
Thx, Milan



      </description>
    <dc:creator>Milan Milanovic</dc:creator>
    <dc:date>2008-07-11T19:11:30</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1904">
    <title>Test equals and hashCode method</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1904</link>
    <description>Hello,

I'm using latest Jmock stable version and I want to use equals and
hashCode methods on mock objects.
But, I notice that theses method are handled in a special way in the
ProxiedObjectIdentity class.

Could you explain the reason of that? Finally, is it possible to use
these methods on mock objects?

Thanks in advance.

</description>
    <dc:creator>Gueze Thomas</dc:creator>
    <dc:date>2008-07-11T11:26:37</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1902">
    <title>First Test with JMock</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1902</link>
    <description>hello there

I'm trying to make a first little program with JMock  work
but cannot make it, so I searching for some help

here is my code, could someone explain what's wrong with it?

in fact, the test succeed every time I launch it, yet it shoudnt as I have a
change in the Math class, so it should fail as it isnt anymore an addition

thanks in advance

package test.jmock;

public class Math {

public int doCalculation(int a, int b){

  return a-b;

}
}

package test.jmock;

import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.jmock.lib.legacy.ClassImposteriser;
import org.junit.Test;
import org.junit.runner.RunWith;


&lt; at &gt;RunWith(JMock.class)
public class FirstJMock {

Mockery context = new
JUnit4Mockery(){{setImposteriser(ClassImposteriser.INSTANCE); }};
    Math mockUpdate = context.mock(Math.class);
    
    &lt; at &gt;Test 
public void doMathTest()  {
    
    context.checking(new Expectations() {{
            one (mockUpdate).doCalculation(4, 3); will(returnValue(7));
         }});
      
        mockUpdate.doCalculation(4, 3);
       
 context.assertIsSatisfied();
 
     }
}



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



</description>
    <dc:creator>bekeffy zoltan</dc:creator>
    <dc:date>2008-07-10T16:13:17</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1900">
    <title>2.5.0-RC2 release</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1900</link>
    <description>I've pushed a release of 2.5.0-RC2.  This fixes a class-loader issue
that stopped jMock working in Eclipse Plug-In tests (JMOCK-124). It
also adds a new expectation function "oneOf" that means the same as
"one" but makes the entire expectation read more clearly (JMOCK-181).

If nobody has any issues with the class-loader change, then I'll
publish a final release early next week.

--Nat

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



</description>
    <dc:creator>Nat Pryce</dc:creator>
    <dc:date>2008-07-07T09:51:09</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.java.jmock.user/1898">
    <title>Asserts are suddenly ambiguous</title>
    <link>http://comments.gmane.org/gmane.comp.java.jmock.user/1898</link>
    <description>Hi all -

I've been using JMock for years.  Suddenly I'm having trouble.

I'm on 2.4, and have just realized that I should be using the
JUnit-4-specific classes in JMock (the JUnit4Mockery, and the JMock test
runner).

I am running inside of Eclipse.

Previously I was using the JUnit jar that Eclipse furnishes you with for
your classpath - 4_4.3.1.  When I added the RunWith annotation to my test
case, Eclipse began to complain that the JUnit4ClassRunner class was
unreachable.  So I removed this item from the classpath and added the real
JUnit 4.4 jar. That msg went away, but now I have this for many of my
assertions:

"The method assertEquals(Object, Object) is ambiguous for the type ..."

I don't get it on every assert, but many of them.

Before I hit the sack, I'm posting this, maybe someone has a clue?

Larry Edelstein
Principal Software Engineer
LiveVox
ribs-HInyCGIudOg&lt; at &gt;public.gmane.org
</description>
    <dc:creator>Larry Edelstein</dc:creator>
    <dc:date>2008-07-07T09:24:48</dc:date>
  </item>
  <textinput rdf:about="http://search.gmane.org/?group=$group=gmane.comp.java.jmock.user">
    <title>Search Engine</title>
    <description>Search the mailing list at Gmane</description>
    <name>query</name>
    <link>http://search.gmane.org/?group=$group=gmane.comp.java.jmock.user</link>
  </textinput>
</rdf:RDF>
