<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>tag:old.nabble.com,2006:forum-2665</id>
	<title>Nabble - jMock - User</title>
	<updated>2009-12-01T01:50:29Z</updated>
	<link rel="self" type="application/atom+xml" href="http://old.nabble.com/jMock---User-f2665.xml" />
	<link rel="alternate" type="text/html" href="http://old.nabble.com/jMock---User-f2665.html" />
	<subtitle type="html"></subtitle>
	
<entry>
	<id>tag:old.nabble.com,2006:post-26588111</id>
	<title>Re: Mocking Static Methods using JMock</title>
	<published>2009-12-01T01:50:29Z</published>
	<updated>2009-12-01T01:50:29Z</updated>
	<author>
		<name>Siddhi B</name>
	</author>
	<content type="html">Thanks for your quick reply Steve.
&lt;br&gt;The above code snippet was just a simple example. The code that I am working on contains complex logic in the static function.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Steve Freeman-2 wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;We don't support mocking of static methods since there is almost &amp;nbsp;
&lt;br&gt;always a better way. That might mean testing it directly in an &amp;nbsp;
&lt;br&gt;integration test or writing a thin layer above the static method and &amp;nbsp;
&lt;br&gt;testing against /that/.
&lt;br&gt;&lt;br&gt;If your method is as simple as getName() it might be better to just &amp;nbsp;
&lt;br&gt;call the method.
&lt;br&gt;S.
&lt;br&gt;&lt;br&gt;On 1 Dec 2009, at 03:37, Siddhi B &amp;lt;borkar.siddhi@gmail.com&amp;gt; wrote:
&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I need a way of mocking a static class using JMock. Consider the &amp;nbsp;
&lt;br&gt;&amp;gt; following
&lt;br&gt;&amp;gt; code snippet.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; public class A {
&lt;br&gt;&amp;gt; &amp;nbsp; void functionX() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; String name = &amp;nbsp;ClassB.getName(); // Static function
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; public class ClassB {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;static String getName() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return 'ABC'
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I need a way of mocking the static function 'getName'.Please note &amp;nbsp;
&lt;br&gt;&amp;gt; that I do
&lt;br&gt;&amp;gt; not have rights to modify the legacy code.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Any help would be highly appreciated.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks,
&lt;br&gt;&amp;gt; Siddhi
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://old.nabble.com/Mocking-Static-Methods-using-JMock-tp26585954p26585954.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://old.nabble.com/Mocking-Static-Methods-using-JMock-tp26585954p26585954.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the jMock - User mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ---------------------------------------------------------------------
&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Mocking-Static-Methods-using-JMock-tp26585954p26588111.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26587856</id>
	<title>Re: Mocking Static Methods using JMock</title>
	<published>2009-11-30T23:51:52Z</published>
	<updated>2009-11-30T23:51:52Z</updated>
	<author>
		<name>Steve Freeman-2</name>
	</author>
	<content type="html">We don't support mocking of static methods since there is almost &amp;nbsp;
&lt;br&gt;always a better way. That might mean testing it directly in an &amp;nbsp;
&lt;br&gt;integration test or writing a thin layer above the static method and &amp;nbsp;
&lt;br&gt;testing against /that/.
&lt;br&gt;&lt;br&gt;If your method is as simple as getName() it might be better to just &amp;nbsp;
&lt;br&gt;call the method.
&lt;br&gt;S.
&lt;br&gt;&lt;br&gt;On 1 Dec 2009, at 03:37, Siddhi B &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26587856&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;borkar.siddhi@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I need a way of mocking a static class using JMock. Consider the &amp;nbsp;
&lt;br&gt;&amp;gt; following
&lt;br&gt;&amp;gt; code snippet.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; public class A {
&lt;br&gt;&amp;gt; &amp;nbsp; void functionX() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; String name = &amp;nbsp;ClassB.getName(); // Static function
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; public class ClassB {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;static String getName() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return 'ABC'
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I need a way of mocking the static function 'getName'.Please note &amp;nbsp;
&lt;br&gt;&amp;gt; that I do
&lt;br&gt;&amp;gt; not have rights to modify the legacy code.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Any help would be highly appreciated.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks,
&lt;br&gt;&amp;gt; Siddhi
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://old.nabble.com/Mocking-Static-Methods-using-JMock-tp26585954p26585954.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://old.nabble.com/Mocking-Static-Methods-using-JMock-tp26585954p26585954.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the jMock - User mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ---------------------------------------------------------------------
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Mocking-Static-Methods-using-JMock-tp26585954p26587856.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26585954</id>
	<title>Mocking Static Methods using JMock</title>
	<published>2009-11-30T19:37:33Z</published>
	<updated>2009-11-30T19:37:33Z</updated>
	<author>
		<name>Siddhi B</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;I need a way of mocking a static class using JMock. Consider the following code snippet.
&lt;br&gt;&lt;br&gt;public class A {
&lt;br&gt;&amp;nbsp; &amp;nbsp;void functionX() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;String name = &amp;nbsp;ClassB.getName(); // Static function
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;public class ClassB {
&lt;br&gt;&amp;nbsp; &amp;nbsp; static String getName() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 'ABC'
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;I need a way of mocking the static function 'getName'.Please note that I do not have rights to modify the legacy code.
&lt;br&gt;&lt;br&gt;Any help would be highly appreciated.
&lt;br&gt;&lt;br&gt;Thanks,
&lt;br&gt;Siddhi</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Mocking-Static-Methods-using-JMock-tp26585954p26585954.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26584651</id>
	<title>Re: Peculiar expectation error</title>
	<published>2009-11-30T16:28:11Z</published>
	<updated>2009-11-30T16:28:11Z</updated>
	<author>
		<name>Sam-186</name>
	</author>
	<content type="html">Problem solved. Moved test fixture to @BeforeMethod annotated method and create
&lt;br&gt;new Mockery object before any fixture code executed.
&lt;br&gt;&lt;br&gt;Cheers,
&lt;br&gt;Sam 
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Peculiar-expectation-error-tp26582905p26584651.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26584032</id>
	<title>Re: Peculiar expectation error</title>
	<published>2009-11-30T15:28:35Z</published>
	<updated>2009-11-30T15:28:35Z</updated>
	<author>
		<name>Sam-186</name>
	</author>
	<content type="html">Steve,
&lt;br&gt;&lt;br&gt;We're using TestNG here and perhaps my lack of familiarity with it is causing
&lt;br&gt;some issues. However if you could shed some light on the following issue I think
&lt;br&gt;that might go some way towards solving my other issue. I've been receiving the
&lt;br&gt;following error:
&lt;br&gt;&lt;br&gt;java.lang.IllegalArgumentException: a mock with name &amp;quot;object name&amp;quot; already exists
&lt;br&gt;&lt;br&gt;As a work around I've been &amp;nbsp;putting my test fixture in a method called setUp
&lt;br&gt;which was annotated with @BeforeClass. I thought @BeforeMethod annotation would
&lt;br&gt;be more appropriate but that didn't prevent the above error. But given that a
&lt;br&gt;new context object should be created for each test in a test class, I should not
&lt;br&gt;receive the above message, correct?
&lt;br&gt;&lt;br&gt;I'm using the following code to set up the each unit test class (yes, I'm
&lt;br&gt;mocking concrete classes) :
&lt;br&gt;&lt;br&gt;private Mockery context = new Mockery() {{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setImposteriser(ClassImposteriser.INSTANCE);
&lt;br&gt;&amp;nbsp; &amp;nbsp; }};
&lt;br&gt;&lt;br&gt;&lt;br&gt;Again, my understanding is that if I have N tests in a class, each test should
&lt;br&gt;receive its own context object. If that is correct then I should only receive
&lt;br&gt;the above error if within the same test I create two or more mock objects with
&lt;br&gt;the same identifier?
&lt;br&gt;&lt;br&gt;Thanks for your help.
&lt;br&gt;Sam 
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Peculiar-expectation-error-tp26582905p26584032.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26583787</id>
	<title>Re: Peculiar expectation error</title>
	<published>2009-11-30T15:08:22Z</published>
	<updated>2009-11-30T15:08:22Z</updated>
	<author>
		<name>Sam-186</name>
	</author>
	<content type="html">Hi Steve,
&lt;br&gt;&lt;br&gt;Here's an example - there's nothing untoward about it as far as I can tell:
&lt;br&gt;&lt;br&gt;public void isForCMAndTotalCommissionGreaterThanMaxCommissionAllowed() {
&lt;br&gt;float expectedCommission &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= 60f;
&lt;br&gt;final float baseCostPlusTaxValue &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= 300.0f;
&lt;br&gt;final float maxAllowableCommission &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= 70.0f;
&lt;br&gt;final float baseCost &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= 254.0f;
&lt;br&gt;final float retailPerSegmentAmount &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= 5.0f;
&lt;br&gt;final int numberOfSegmentsFlown &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = 4;
&lt;br&gt;&lt;br&gt;context.checking(new Expectations() {{
&lt;br&gt;&amp;nbsp; &amp;nbsp;allowing(clientServices);
&lt;br&gt;&amp;nbsp; &amp;nbsp;oneOf(itin).isOpaque(); will(returnValue(false));
&lt;br&gt;&amp;nbsp; &amp;nbsp;oneOf(carrier).isUnknown(); will(returnValue(false));
&lt;br&gt;&amp;nbsp; &amp;nbsp;oneOf(calculator).calculate(itin, carrier); 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;will(returnValue(commissionVO));
&lt;br&gt;&amp;nbsp; &amp;nbsp;oneOf(commissionVO).getBaseCommission(); 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;will(returnValue(10.0f));
&lt;br&gt;&amp;nbsp; &amp;nbsp;oneOf(commissionVO).getPlatingCarrier(); 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;will(returnValue(carrier));
&lt;br&gt;}});
&lt;br&gt;&lt;br&gt;airCommCalc = new AirCommissionCalculator(baseCommissionCalc, commission);
&lt;br&gt;assertEquals(expectedCommission, 
&lt;br&gt;this.airCommCalc.calculate(itin, carrier, true));
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;Cheers,
&lt;br&gt;Sam 
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Peculiar-expectation-error-tp26582905p26583787.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26582961</id>
	<title>Re: Peculiar expectation error</title>
	<published>2009-11-30T14:11:39Z</published>
	<updated>2009-11-30T14:11:39Z</updated>
	<author>
		<name>Steve Freeman-2</name>
	</author>
	<content type="html">Odd. It implies there's something static going on either in the code or the tests.
&lt;br&gt;&lt;br&gt;What do your expectations look like?
&lt;br&gt;&lt;br&gt;S.
&lt;br&gt;&lt;br&gt;On 30 Nov 2009, at 22:09, Sam wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I'm experiencing a peculiar error with the expectations in my unit tests - it's
&lt;br&gt;&amp;gt; as if expectations from previously run unit tests (run in the same process) are
&lt;br&gt;&amp;gt; being 'remembered' and included in the expectations of other tests. Thus the
&lt;br&gt;&amp;gt; unit tests for an entire unit test class are failing when executed as a whole
&lt;br&gt;&amp;gt; but pass when executed individually - i.e. expectations from other tests cannot
&lt;br&gt;&amp;gt; bleed over into the current, individual test. Now this shouldn't happen because
&lt;br&gt;&amp;gt; of the creation of the anonymous inner class, correct?:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; context.checking(new Expectations() {{
&lt;br&gt;&amp;gt; &amp;nbsp; expectation1;
&lt;br&gt;&amp;gt; &amp;nbsp; expectation2;
&lt;br&gt;&amp;gt; }});
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I really have no idea what's going on - hopefully someone else does!
&lt;/div&gt;&lt;br&gt;&lt;br&gt;Steve Freeman
&lt;br&gt;&lt;br&gt;Winner of the Agile Alliance Gordon Pask award 2006
&lt;br&gt;Book: &lt;a href=&quot;http://www.growing-object-oriented-software.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.growing-object-oriented-software.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;+44 (0) 797 179 4105
&lt;br&gt;M3P Limited. &amp;nbsp;&lt;a href=&quot;http://www.m3p.co.uk&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.m3p.co.uk&lt;/a&gt;&lt;br&gt;Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ. 
&lt;br&gt;Company registered in England &amp; Wales. Number 03689627
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Peculiar-expectation-error-tp26582905p26582961.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26582905</id>
	<title>Peculiar expectation error</title>
	<published>2009-11-30T14:09:06Z</published>
	<updated>2009-11-30T14:09:06Z</updated>
	<author>
		<name>Sam-186</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;I'm experiencing a peculiar error with the expectations in my unit tests - it's
&lt;br&gt;as if expectations from previously run unit tests (run in the same process) are
&lt;br&gt;being 'remembered' and included in the expectations of other tests. Thus the
&lt;br&gt;unit tests for an entire unit test class are failing when executed as a whole
&lt;br&gt;but pass when executed individually - i.e. expectations from other tests cannot
&lt;br&gt;bleed over into the current, individual test. Now this shouldn't happen because
&lt;br&gt;of the creation of the anonymous inner class, correct?:
&lt;br&gt;&lt;br&gt;context.checking(new Expectations() {{
&lt;br&gt;&amp;nbsp; &amp;nbsp;expectation1;
&lt;br&gt;&amp;nbsp; &amp;nbsp;expectation2;
&lt;br&gt;}});
&lt;br&gt;&lt;br&gt;I really have no idea what's going on - hopefully someone else does!
&lt;br&gt;&lt;br&gt;Thanks,
&lt;br&gt;Sam 
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Peculiar-expectation-error-tp26582905p26582905.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26476068</id>
	<title>Re: JMock doesn't seem to be invoked when mocking a  concrete class</title>
	<published>2009-11-23T03:07:30Z</published>
	<updated>2009-11-23T03:07:30Z</updated>
	<author>
		<name>Viggo Navarsete</name>
	</author>
	<content type="html">well, you&amp;#39;re partially right. The problem is that the VirtualInstanceContextHolder contains a private constructor,an the way that class is used is by invoking a &lt;br&gt;VirtualInstanceContextHolder.getContext() which would return a VirtualInstanceContext object. &lt;br&gt;
The bottom line is: I want to return a DTOFactory from my metod getDTOFactory in the Service class. Can I do that without setting up mock of all the things that the getDTOFactory is using?&lt;br&gt;&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;Viggo&lt;br&gt;
&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Mon, Nov 23, 2009 at 11:15 AM, Julian Hall &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26476068&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jules@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
&lt;div class=&quot;im&quot;&gt;Viggo Navarsete wrote:&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
I&amp;#39;m having a unit test which is supposed to test a Service. The Service in turn calls another class. I want to mock the invocations to the class the Service uses.&lt;br&gt;
&lt;br&gt;
MyTest--&amp;gt;Service--&amp;gt;AConcreteClass&lt;br&gt;
&lt;br&gt;
So, MyTest executes a method on Service, which in turn execute a method on a concrete class, AConcreteClass.&lt;br&gt;
I want to mock the execution on the AConcreteClass in Service, but it doesn&amp;#39;t seem to mock it.&lt;br&gt;
&lt;br&gt;
Some code:&lt;br&gt;
&lt;br&gt;
************************************************************************************************************************************************************************************************&lt;br&gt;
MyTest:&lt;br&gt;
&lt;br&gt;
@Test&lt;br&gt;
public void testDataLoad() throws Exception {&lt;br&gt;
&lt;br&gt;
        Mockery context = new Mockery() {{&lt;br&gt;
            setImposteriser( ClassImposteriser.INSTANCE );&lt;br&gt;
        }};&lt;br&gt;
&lt;br&gt;
        final VirtualInstanceContextHolder vich = context.mock( VirtualInstanceContextHolder.class );&lt;br&gt;
        final VirtualInstanceContext vic = context.mock( VirtualInstanceContext.class );&lt;br&gt;
        final ApplicationContext ac = context.mock( ApplicationContext.class );&lt;br&gt;
        final Persistence persistence = context.mock( Persistence.class );&lt;br&gt;
        final Map&amp;lt;String, String&amp;gt; emMap = new HashMap&amp;lt;String, String&amp;gt;();&lt;br&gt;
&lt;br&gt;
        context.checking( new Expectations() {{&lt;br&gt;
            allowing( vich );&lt;br&gt;
                will( returnValue( new VirtualInstanceContext()));&lt;br&gt;
&lt;/blockquote&gt;&lt;/div&gt;
Shouldn&amp;#39;t this be returning vic?&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
---------------------------------------------------------------------&lt;br&gt;
To unsubscribe from this list, please visit:&lt;br&gt;
&lt;br&gt;
   &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;br clear=&quot;all&quot;&gt;&lt;br&gt;-- &lt;br&gt;Viggo Navarsete&lt;br&gt;Senior Developer&lt;br&gt;TraceTracker AS&lt;br&gt;&lt;br&gt;Øvre Slottsgt.4, 4th floor, N-0157 Oslo, Norway&lt;br&gt;Central number: +47 47 70 44 00&lt;br&gt;Direct number: +47 92 43 14 90&lt;br&gt;
E-mail: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26476068&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;viggo@...&lt;/a&gt;&lt;br&gt;&lt;br&gt;TraceTracker was selected Technology Pioneer 2009 by the World Economic Forum.&lt;br&gt;&lt;br&gt;This is a confidential business communication. If you have received it in error please notify the sender and delete it. Any unauthorized use of this communication is prohibited.Copyright 2009 TraceTracker AS, Oslo - Norway&lt;br&gt;

</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/JMock-doesn%27t-seem-to-be-invoked-when-mocking-a-concrete-class-tp26475158p26476068.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26476012</id>
	<title>RE [jmock-user] JMock doesn't seem to be invoked when mocking a concrete class</title>
	<published>2009-11-23T03:01:49Z</published>
	<updated>2009-11-23T03:01:49Z</updated>
	<author>
		<name>ar92</name>
	</author>
	<content type="html">
&lt;br&gt;&lt;font size=2 face=&quot;sans-serif&quot;&gt;Looks like you have a static method
(&lt;/font&gt;&lt;font size=3&gt;VirtualInstanceContextHolder.getContext()&lt;/font&gt;&lt;font size=2 face=&quot;sans-serif&quot;&gt;),
and you can't mock static methods because they're not polymorphic.&lt;/font&gt;
&lt;br&gt;&lt;font size=2 face=&quot;sans-serif&quot;&gt;There are some hacks to get around this
(though the ideal solution is to refactor so vic is injected - i.e. passed
as an argument into either the service's constructor or the method call).
&amp;nbsp;&lt;/font&gt;
&lt;br&gt;&lt;font size=2 face=&quot;sans-serif&quot;&gt;If you can set the singleton value returned
by &lt;/font&gt;&lt;font size=3&gt;VirtualInstanceContextHolder.getContext()&lt;/font&gt;&lt;font size=2 face=&quot;sans-serif&quot;&gt;
to vic, your problem is solved (it seems to be set to null in your test,
currently). &amp;nbsp;Or you could move the static call into&lt;/font&gt;
&lt;br&gt;&lt;font size=2 face=&quot;sans-serif&quot;&gt;a protected method of the service (call
it &amp;quot;getVIContext()&amp;quot; or something like that) and then run your
test on a subclass of the service which overrides this method to return
an instance&lt;/font&gt;
&lt;br&gt;&lt;font size=2 face=&quot;sans-serif&quot;&gt;received in its constructor or a setter,
where you inject the object vic in your test code. &amp;nbsp;&lt;/font&gt;
&lt;br&gt;&lt;font size=2 face=&quot;sans-serif&quot;&gt;-Alan&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;table width=100%&gt;
&lt;tr valign=top&gt;
&lt;td width=40%&gt;&lt;font size=1 face=&quot;sans-serif&quot;&gt;&lt;b&gt;Viggo Navarsete &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26476012&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;viggo@...&lt;/a&gt;&amp;gt;&lt;/b&gt;
&lt;/font&gt;
&lt;p&gt;&lt;font size=1 face=&quot;sans-serif&quot;&gt;23/11/2009 10:52&lt;/font&gt;
&lt;table border&gt;
&lt;tr valign=top&gt;
&lt;td bgcolor=white&gt;
&lt;div align=center&gt;&lt;font size=1 face=&quot;sans-serif&quot;&gt;Veuillez répondre à&lt;br&gt;
&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26476012&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;user@...&lt;/a&gt;&lt;/font&gt;&lt;/div&gt;&lt;/table&gt;
&lt;br&gt;
&lt;td width=59%&gt;
&lt;table width=100%&gt;
&lt;tr valign=top&gt;
&lt;td&gt;
&lt;div align=right&gt;&lt;font size=1 face=&quot;sans-serif&quot;&gt;A&lt;/font&gt;&lt;/div&gt;
&lt;td&gt;&lt;font size=1 face=&quot;sans-serif&quot;&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26476012&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;user@...&lt;/a&gt;&lt;/font&gt;
&lt;tr valign=top&gt;
&lt;td&gt;
&lt;div align=right&gt;&lt;font size=1 face=&quot;sans-serif&quot;&gt;cc&lt;/font&gt;&lt;/div&gt;
&lt;td&gt;
&lt;tr valign=top&gt;
&lt;td&gt;
&lt;div align=right&gt;&lt;font size=1 face=&quot;sans-serif&quot;&gt;Objet&lt;/font&gt;&lt;/div&gt;
&lt;td&gt;&lt;font size=1 face=&quot;sans-serif&quot;&gt;[jmock-user] JMock doesn't seem to be
invoked when mocking a concrete class&lt;/font&gt;&lt;/table&gt;
&lt;br&gt;
&lt;table&gt;
&lt;tr valign=top&gt;
&lt;td&gt;
&lt;td&gt;&lt;/table&gt;
&lt;br&gt;&lt;/table&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;&lt;font size=3&gt;I'm having a unit test which is supposed to test a Service.
The Service in turn calls another class. I want to mock the invocations
to the class the Service uses.&lt;br&gt;
&lt;br&gt;
MyTest--&amp;gt;Service--&amp;gt;AConcreteClass&lt;br&gt;
&lt;br&gt;
So, MyTest executes a method on Service, which in turn execute a method
on a concrete class, AConcreteClass.&lt;br&gt;
I want to mock the execution on the AConcreteClass in Service, but it doesn't
seem to mock it.&lt;br&gt;
&lt;br&gt;
Some code:&lt;br&gt;
&lt;br&gt;
************************************************************************************************************************************************************************************************&lt;br&gt;
MyTest:&lt;br&gt;
&lt;br&gt;
@Test&lt;br&gt;
public void testDataLoad() throws Exception {&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Mockery context = new Mockery() {{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; setImposteriser(
ClassImposteriser.INSTANCE );&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }};&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; final VirtualInstanceContextHolder
vich = context.mock( VirtualInstanceContextHolder.class );&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; final VirtualInstanceContext vic
= context.mock( VirtualInstanceContext.class );&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; final ApplicationContext ac = context.mock(
ApplicationContext.class );&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; final Persistence persistence = context.mock(
Persistence.class );&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; final Map&amp;lt;String, String&amp;gt; emMap
= new HashMap&amp;lt;String, String&amp;gt;();&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; context.checking( new Expectations()
{{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; allowing( vich
);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
will( returnValue( new VirtualInstanceContext()));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; allowing( vic
).getApplicationContext();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
will( returnValue( new AutowiringXmlWebApplicationContext() ));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; allowing( ac ).getParent();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; allowing( ac ).getBean(
&amp;quot;SecureDTOFactory&amp;quot; );&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
will( returnValue( new DTOFactory() ) );&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; allowing( persistence).createEntityManagerFactory(
&amp;quot;epcisTIXPU&amp;quot;, emMap );&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
will( returnValue( Persistence.createEntityManagerFactory( &amp;quot;epcisTIXPU&amp;quot;
).createEntityManager()));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }});&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; results = service.simpleEventQuery(new
QueryParams()); // execute the actual method on Service&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
************************************************************************************************************************************************************************************************&lt;br&gt;
Service:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; public List&amp;lt;EventDetailsDTO&amp;gt; simpleEventQuery( QueryParams
queryParam) {&lt;br&gt;
&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DTOFactory dtoFactory = getDTOFactory();
// I want to mock the method invocations in the private getDTOFactory!!&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; private DTOFactory getDTOFactory() {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; VirtualInstanceContext vic = VirtualInstanceContextHolder.getContext();
// I get back an object here&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ApplicationContext ac = vic.getApplicationContext();
// This one returns null and is what I want to figure out why!!&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ApplicationContext acParent = ac.getParent();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; DTOFactory dtoFactory = (DTOFactory)
acParent.getBean( &amp;quot;SecureDTOFactory&amp;quot; );&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return dtoFactory;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
My environment:&lt;br&gt;
- Maven 2.0.9&lt;br&gt;
- JUnit 4.4&lt;br&gt;
- JDK 1.6.0_16&lt;br&gt;
&lt;/font&gt;
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/JMock-doesn%27t-seem-to-be-invoked-when-mocking-a-concrete-class-tp26475158p26476012.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26475436</id>
	<title>Re: JMock doesn't seem to be invoked when mocking a concrete class</title>
	<published>2009-11-23T02:15:41Z</published>
	<updated>2009-11-23T02:15:41Z</updated>
	<author>
		<name>Julian Hall-2</name>
	</author>
	<content type="html">Viggo Navarsete wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I'm having a unit test which is supposed to test a Service. The 
&lt;br&gt;&amp;gt; Service in turn calls another class. I want to mock the invocations to 
&lt;br&gt;&amp;gt; the class the Service uses.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; MyTest--&amp;gt;Service--&amp;gt;AConcreteClass
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; So, MyTest executes a method on Service, which in turn execute a 
&lt;br&gt;&amp;gt; method on a concrete class, AConcreteClass.
&lt;br&gt;&amp;gt; I want to mock the execution on the AConcreteClass in Service, but it 
&lt;br&gt;&amp;gt; doesn't seem to mock it.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Some code:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ************************************************************************************************************************************************************************************************
&lt;br&gt;&amp;gt; MyTest:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; @Test
&lt;br&gt;&amp;gt; public void testDataLoad() throws Exception {
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Mockery context = new Mockery() {{
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setImposteriser( ClassImposteriser.INSTANCE );
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }};
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final VirtualInstanceContextHolder vich = context.mock( 
&lt;br&gt;&amp;gt; VirtualInstanceContextHolder.class );
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final VirtualInstanceContext vic = context.mock( 
&lt;br&gt;&amp;gt; VirtualInstanceContext.class );
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final ApplicationContext ac = context.mock( 
&lt;br&gt;&amp;gt; ApplicationContext.class );
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final Persistence persistence = context.mock( Persistence.class );
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final Map&amp;lt;String, String&amp;gt; emMap = new HashMap&amp;lt;String, String&amp;gt;();
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; context.checking( new Expectations() {{
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; allowing( vich );
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; will( returnValue( new VirtualInstanceContext()));
&lt;/div&gt;Shouldn't this be returning vic?
&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/JMock-doesn%27t-seem-to-be-invoked-when-mocking-a-concrete-class-tp26475158p26475436.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26475158</id>
	<title>JMock doesn't seem to be invoked when mocking a concrete class</title>
	<published>2009-11-23T01:51:46Z</published>
	<updated>2009-11-23T01:51:46Z</updated>
	<author>
		<name>Viggo Navarsete</name>
	</author>
	<content type="html">I&amp;#39;m having a unit test which is supposed to test a Service. The Service in turn calls another class. I want to mock the invocations to the class the Service uses.&lt;br&gt;&lt;br&gt;MyTest--&amp;gt;Service--&amp;gt;AConcreteClass&lt;br&gt;&lt;br&gt;So, MyTest executes a method on Service, which in turn execute a method on a concrete class, AConcreteClass.&lt;br&gt;
I want to mock the execution on the AConcreteClass in Service, but it doesn&amp;#39;t seem to mock it.&lt;br&gt;&lt;br&gt;Some code:&lt;br&gt;&lt;br&gt;************************************************************************************************************************************************************************************************&lt;br&gt;
MyTest:&lt;br&gt;&lt;br&gt;@Test&lt;br&gt;public void testDataLoad() throws Exception {&lt;br&gt;&lt;br&gt;        Mockery context = new Mockery() {{&lt;br&gt;            setImposteriser( ClassImposteriser.INSTANCE );&lt;br&gt;        }};&lt;br&gt;&lt;br&gt;        final VirtualInstanceContextHolder vich = context.mock( VirtualInstanceContextHolder.class );&lt;br&gt;
        final VirtualInstanceContext vic = context.mock( VirtualInstanceContext.class );&lt;br&gt;        final ApplicationContext ac = context.mock( ApplicationContext.class );&lt;br&gt;        final Persistence persistence = context.mock( Persistence.class );&lt;br&gt;
        final Map&amp;lt;String, String&amp;gt; emMap = new HashMap&amp;lt;String, String&amp;gt;();&lt;br&gt;&lt;br&gt;        context.checking( new Expectations() {{&lt;br&gt;            allowing( vich );&lt;br&gt;                will( returnValue( new VirtualInstanceContext()));&lt;br&gt;
            allowing( vic ).getApplicationContext();&lt;br&gt;                will( returnValue( new AutowiringXmlWebApplicationContext() ));&lt;br&gt;            allowing( ac ).getParent();&lt;br&gt;            allowing( ac ).getBean( &amp;quot;SecureDTOFactory&amp;quot; );&lt;br&gt;
                will( returnValue( new DTOFactory() ) );&lt;br&gt;            allowing( persistence).createEntityManagerFactory( &amp;quot;epcisTIXPU&amp;quot;, emMap );&lt;br&gt;                will( returnValue( Persistence.createEntityManagerFactory( &amp;quot;epcisTIXPU&amp;quot; ).createEntityManager()));&lt;br&gt;
        }});&lt;br&gt;&lt;br&gt;&lt;br&gt;       results = service.simpleEventQuery(new QueryParams()); // execute the actual method on Service&lt;br&gt;&lt;br&gt;&lt;br&gt;************************************************************************************************************************************************************************************************&lt;br&gt;
Service:&lt;br&gt;&lt;br&gt;   public List&amp;lt;EventDetailsDTO&amp;gt; simpleEventQuery( QueryParams queryParam) {&lt;br&gt; &lt;br&gt;       DTOFactory dtoFactory = getDTOFactory(); // I want to mock the method invocations in the private getDTOFactory!!&lt;br&gt;
   }&lt;br&gt;&lt;br&gt;    private DTOFactory getDTOFactory() {&lt;br&gt;        VirtualInstanceContext vic = VirtualInstanceContextHolder.getContext(); // I get back an object here&lt;br&gt;        ApplicationContext ac = vic.getApplicationContext(); // This one returns null and is what I want to figure out why!!&lt;br&gt;
        ApplicationContext acParent = ac.getParent();&lt;br&gt;        DTOFactory dtoFactory = (DTOFactory) acParent.getBean( &amp;quot;SecureDTOFactory&amp;quot; );&lt;br&gt;        return dtoFactory;&lt;br&gt;    }&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
My environment:&lt;br&gt;- Maven 2.0.9&lt;br&gt;- JUnit 4.4&lt;br&gt;- JDK 1.6.0_16&lt;br&gt;&lt;br&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/JMock-doesn%27t-seem-to-be-invoked-when-mocking-a-concrete-class-tp26475158p26475158.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26471134</id>
	<title>Checkstyle check for @RunWith(JMock)</title>
	<published>2009-11-22T16:33:34Z</published>
	<updated>2009-11-22T16:33:34Z</updated>
	<author>
		<name>Stephen Smith-2</name>
	</author>
	<content type="html">Hi
&lt;br&gt;&lt;br&gt;I'm thinking of writing a Checkstyle custom check that checks a class containing 
&lt;br&gt;a Mockery field is annotated with @RunWith(JMock).
&lt;br&gt;&lt;br&gt;Can anyone think of a scenario where you might want a Mockery field and not use 
&lt;br&gt;the JMock TestRunner implementation?
&lt;br&gt;&lt;br&gt;Thanks
&lt;br&gt;&lt;br&gt;S
&lt;br&gt;-- 
&lt;br&gt;Stephen Smith
&lt;br&gt;&lt;a href=&quot;http://www.stephen-smith.co.uk/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.stephen-smith.co.uk/&lt;/a&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Checkstyle-check-for-%40RunWith%28JMock%29-tp26471134p26471134.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26444758</id>
	<title>Re: error message with custom matcher</title>
	<published>2009-11-20T06:59:10Z</published>
	<updated>2009-11-20T06:59:10Z</updated>
	<author>
		<name>Steve Freeman-2</name>
	</author>
	<content type="html">More...
&lt;br&gt;&lt;br&gt;You might also want to look at samePropertyValuesAs().
&lt;br&gt;&lt;br&gt;And you don't need to declare @Factory on the factory method, that's just for code generating the Matchers class.
&lt;br&gt;&lt;br&gt;&lt;br&gt;On 20 Nov 2009, at 06:07, John Sanda wrote:
&lt;br&gt;&lt;br&gt;&amp;gt; I writing a test using a custom matcher. The custom matcher seems to be working, but the error message in the failure seems off. Here is roughly what my test looks like,
&lt;br&gt;&lt;br&gt;S.
&lt;br&gt;&lt;br&gt;Steve Freeman
&lt;br&gt;&lt;br&gt;Winner of the Agile Alliance Gordon Pask award 2006
&lt;br&gt;Book: &lt;a href=&quot;http://www.growing-object-oriented-software.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.growing-object-oriented-software.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;+44 (0) 797 179 4105
&lt;br&gt;M3P Limited. &amp;nbsp;&lt;a href=&quot;http://www.m3p.co.uk&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.m3p.co.uk&lt;/a&gt;&lt;br&gt;Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ. 
&lt;br&gt;Company registered in England &amp; Wales. Number 03689627
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/error-message-with-custom-matcher-tp26443846p26444758.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26444710</id>
	<title>Re: error message with custom matcher</title>
	<published>2009-11-20T06:56:13Z</published>
	<updated>2009-11-20T06:56:13Z</updated>
	<author>
		<name>Steve Freeman-2</name>
	</author>
	<content type="html">describeTo() describes the /matcher/, what you expected not what you got.
&lt;br&gt;&lt;br&gt;to report the actual value, you need to implement a mismatch description. Look at TypeSafeDiagnosingMatche. If you can't find it, you probably need to upgrade to the next version of Hamcrest.
&lt;br&gt;&lt;br&gt;S
&lt;br&gt;&lt;br&gt;&lt;br&gt;On 20 Nov 2009, at 06:07, John Sanda wrote:
&lt;br&gt;&amp;gt; I writing a test using a custom matcher. The custom matcher seems to be working, but the error message in the failure seems off. Here is roughly what my test looks like,
&lt;br&gt;&lt;br&gt;Steve Freeman
&lt;br&gt;&lt;br&gt;Winner of the Agile Alliance Gordon Pask award 2006
&lt;br&gt;Book: &lt;a href=&quot;http://www.growing-object-oriented-software.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.growing-object-oriented-software.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;+44 (0) 797 179 4105
&lt;br&gt;M3P Limited. &amp;nbsp;&lt;a href=&quot;http://www.m3p.co.uk&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.m3p.co.uk&lt;/a&gt;&lt;br&gt;Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ. 
&lt;br&gt;Company registered in England &amp; Wales. Number 03689627
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/error-message-with-custom-matcher-tp26443846p26444710.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26443846</id>
	<title>error message with custom matcher</title>
	<published>2009-11-20T06:07:04Z</published>
	<updated>2009-11-20T06:07:04Z</updated>
	<author>
		<name>John Sanda-3</name>
	</author>
	<content type="html">I writing a test using a custom matcher. The custom matcher seems to be working, but the error message in the failure seems off. Here is roughly what my test looks like,&lt;br&gt;&lt;br&gt;ConfigurationFacet facet = context.mock(ConfigurationFacet.class)&lt;br&gt;
ConfigurationService configService = context.mock(ConfigurationService.class);&lt;br&gt;&lt;br&gt;context.checking(new Expectations() {{&lt;br&gt;    oneOf(facet).updateResourceConfiguration(with(any(ConfigurationUpdateReport.class)));&lt;br&gt;
    atLeast(1).of(configService).completeConfigurationUpdate(with(matchingResponse(expectedResponse)));&lt;br&gt;}});&lt;br&gt;&lt;br&gt;expectedResponse is an instance of ConfigurationUpdateResponse and matchingResponse is my custom matcher that does a property comparison. The code for it is,&lt;br&gt;
&lt;br&gt;public class ConfigurationUpdateResponseMatcher extends TypeSafeMatcher&amp;lt;ConfigurationUpdateResponse&amp;gt; {&lt;br&gt;        @Factory&lt;br&gt;        public static Matcher&amp;lt;ConfigurationUpdateResponse&amp;gt; matchingResponse(ConfigurationUpdateResponse expected) {&lt;br&gt;
            return new ConfigurationUpdateResponseMatcher(expected);&lt;br&gt;        }&lt;br&gt;&lt;br&gt;        private ConfigurationUpdateResponse expected;&lt;br&gt;&lt;br&gt;        public ConfigurationUpdateResponseMatcher(ConfigurationUpdateResponse response) {&lt;br&gt;
            expected = response;&lt;br&gt;        }&lt;br&gt;&lt;br&gt;        public boolean matchesSafely(ConfigurationUpdateResponse actual) {&lt;br&gt;            return propertyEquals(expected.getConfiguration(), actual.getConfiguration()) &amp;amp;&amp;amp;&lt;br&gt;
                      propertyEquals(expected.getConfigurationUpdateId(), actual.getConfigurationUpdateId()) &amp;amp;&amp;amp;&lt;br&gt;                      propertyEquals(expected.getErrorMessage(), actual.getErrorMessage()) &amp;amp;&amp;amp;&lt;br&gt;
                      propertyEquals(expected.getStatus(), actual.getStatus());&lt;br&gt;        }&lt;br&gt;&lt;br&gt;        private boolean propertyEquals(Object expected, Object actual) {&lt;br&gt;            if (expected == null &amp;amp;&amp;amp; actual == null) {&lt;br&gt;
                return true;&lt;br&gt;            }&lt;br&gt;&lt;br&gt;            if (expected == null &amp;amp;&amp;amp; actual != null) {&lt;br&gt;                return false;&lt;br&gt;            }&lt;br&gt;            return expected.equals(actual);&lt;br&gt;        }&lt;br&gt;
&lt;br&gt;        public void describeTo(Description description) {&lt;br&gt;            description.appendText(&amp;quot;A &amp;quot; + ConfigurationUpdateResponse.class.getSimpleName() + &amp;quot; matching &amp;quot; +&lt;br&gt;
                    expected);&lt;br&gt;        }&lt;br&gt;}&lt;br&gt;&lt;br&gt;I thought that the error message I would see when my custom matcher returns false would be the description it creates in its describeTo() method. Instead, I see,&lt;br&gt;
&lt;br&gt;un&lt;br&gt;Expected :ConfigurationUpdateResponse[configurationUpdateId=-1, ConfigurationUpdateStatus=Failure, configuration=Configuration[id=0]]&lt;br&gt;Actual   :org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport@50269997&lt;br&gt;
)&lt;br&gt;&lt;br&gt;I used values to trigger the failure as a way to verify that my custom matcher is working, but the error reporting is wrong. The object it is reporting as expected appears to be from,&lt;br&gt;&lt;br&gt;oneOf(facet).updateResourceConfiguration(with(any(ConfigurationUpdateReport.class)))&lt;br&gt;
&lt;br&gt;but the custom matcher takes an instance of ConfigurationUpdateResponse. Is there something that I can do to alter the error message that is reported?&lt;br&gt;&lt;br&gt;Thanks&lt;br clear=&quot;all&quot;&gt;&lt;br&gt;- John&lt;br&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/error-message-with-custom-matcher-tp26443846p26443846.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26400958</id>
	<title>Re: javax.xml package</title>
	<published>2009-11-17T17:29:44Z</published>
	<updated>2009-11-17T17:29:44Z</updated>
	<author>
		<name>Sam-186</name>
	</author>
	<content type="html">Thanks Steve, appreciate it. 
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/javax.xml-package-tp26344773p26400958.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26387239</id>
	<title>Re: Advice on testing my classes that has many third party API calls.</title>
	<published>2009-11-17T02:05:22Z</published>
	<updated>2009-11-17T02:05:22Z</updated>
	<author>
		<name>LadyCoconut</name>
	</author>
	<content type="html">&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Steve Freeman-2 wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;On 27 Oct 2009, at 10:36, LadyCoconut wrote:
&lt;br&gt;&amp;gt; My questions are:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 1. in my test I am using the matchers with(any(OpertionOptions.class),
&lt;br&gt;&amp;gt; with(any(Profile.class) and such....should I be mocking these concrete
&lt;br&gt;&amp;gt; classes using the ClassImposteriser and setting them up and checking &amp;nbsp;
&lt;br&gt;&amp;gt; the
&lt;br&gt;&amp;gt; exact expectations of these? It feels a bit wrong. All I want to &amp;nbsp;
&lt;br&gt;&amp;gt; test is
&lt;br&gt;&amp;gt; that a call to the service is made and that I get back an expected &amp;nbsp;
&lt;br&gt;&amp;gt; type with
&lt;br&gt;&amp;gt; some parameters in it?
&lt;br&gt;&lt;br&gt;You want to check, for example, that the ObjectIdentitySet has been &amp;nbsp;
&lt;br&gt;set up correctly? You could write a more precise matcher that checks &amp;nbsp;
&lt;br&gt;the values within the ObjectIdSet that was passed in. Something like:
&lt;br&gt;&lt;br&gt;oneOf(objectService).get(with(objectIdentitySetWithId(1)), ...
&lt;br&gt;&lt;br&gt;If you just want to let the call go through, then the any() clauses &amp;nbsp;
&lt;br&gt;are fine--that's your intention. You can simplify it further, if &amp;nbsp;
&lt;br&gt;there's only one call to an object:
&lt;br&gt;&lt;br&gt;allowing(objectService); will(returnValue(dataPackage));
&lt;br&gt;&lt;br&gt;if that's all you care about. (Remember: Stub Queries, Expect Actions)
&lt;br&gt;&lt;br&gt;&amp;gt; 2. Should I be spending my time skinning and wrapping the API for &amp;nbsp;
&lt;br&gt;&amp;gt; testing?
&lt;br&gt;&amp;gt; As its rather a small project at the moment, I managed to create a &amp;nbsp;
&lt;br&gt;&amp;gt; stub
&lt;br&gt;&amp;gt; service initially that returns some duff data.
&lt;br&gt;&lt;br&gt;That depends :) At the least, I'd have some kind of interface in my &amp;nbsp;
&lt;br&gt;domain code that protected me from the library, so there were no &amp;nbsp;
&lt;br&gt;references.
&lt;br&gt;&lt;br&gt;S.
&lt;br&gt;&lt;br&gt;Steve Freeman
&lt;br&gt;&lt;br&gt;Winner of the Agile Alliance Gordon Pask award 2006
&lt;br&gt;Book: &lt;a href=&quot;http://www.growing-object-oriented-software.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.growing-object-oriented-software.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;+44 (0) 797 179 4105
&lt;br&gt;M3P Limited. &amp;nbsp;&lt;a href=&quot;http://www.m3p.co.uk&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.m3p.co.uk&lt;/a&gt;&lt;br&gt;Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ.
&lt;br&gt;Company registered in England &amp; Wales. Number 03689627
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
&lt;br&gt;Thanks for the advice and the reply. 
&lt;br&gt;Got your book in the post yesterday, looking forward to reading it. 
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Advice-on-testing-my-classes-that-has-many-third-party-API-calls.-tp26075443p26387239.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26370101</id>
	<title>Re: javax.xml package</title>
	<published>2009-11-16T03:04:11Z</published>
	<updated>2009-11-16T03:04:11Z</updated>
	<author>
		<name>Steve Freeman-2</name>
	</author>
	<content type="html">Sorry for the delay in responding. My first instinct is to write my domain code against interfaces that describes what I want from JAXB, which I can mock in my tests. What happens after that depends on what I want to prove and how hard it is to work with the third-party library. For a case like this, it might be best to test the adaptor code directly against the jaxb library and see what XML comes out. Whether any of that testing involves mocks depends on how complex the adaption is and how accommodating the design of java.xml is.
&lt;br&gt;&lt;br&gt;S.
&lt;br&gt;&lt;br&gt;On 13 Nov 2009, at 22:48, Sam wrote:
&lt;br&gt;&amp;gt; I'm writing code which uses the javax.xml package. Is the correct approach, and
&lt;br&gt;&amp;gt; I use the phrase lightly, that I create domain appropriate interfaces and the
&lt;br&gt;&amp;gt; relevant adaptors for the package? Or should I use the api directly and mock
&lt;br&gt;&amp;gt; classes such as JAXBContext.java for testing purposes?
&lt;br&gt;&lt;br&gt;Steve Freeman
&lt;br&gt;&lt;br&gt;Winner of the Agile Alliance Gordon Pask award 2006
&lt;br&gt;Book: &lt;a href=&quot;http://www.growing-object-oriented-software.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.growing-object-oriented-software.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;+44 (0) 797 179 4105
&lt;br&gt;M3P Limited. &amp;nbsp;&lt;a href=&quot;http://www.m3p.co.uk&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.m3p.co.uk&lt;/a&gt;&lt;br&gt;Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ. 
&lt;br&gt;Company registered in England &amp; Wales. Number 03689627
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/javax.xml-package-tp26344773p26370101.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26344773</id>
	<title>javax.xml package</title>
	<published>2009-11-13T14:48:50Z</published>
	<updated>2009-11-13T14:48:50Z</updated>
	<author>
		<name>Sam-186</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;I'm writing code which uses the javax.xml package. Is the correct approach, and
&lt;br&gt;I use the phrase lightly, that I create domain appropriate interfaces and the
&lt;br&gt;relevant adaptors for the package? Or should I use the api directly and mock
&lt;br&gt;classes such as JAXBContext.java for testing purposes?
&lt;br&gt;&lt;br&gt;Any thoughts would be greatly appreciated.
&lt;br&gt;&lt;br&gt;Cheers,
&lt;br&gt;Sam 
&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/javax.xml-package-tp26344773p26344773.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26258696</id>
	<title>Ability to use jMock through the Rule mechanism</title>
	<published>2009-11-08T14:26:27Z</published>
	<updated>2009-11-08T14:26:27Z</updated>
	<author>
		<name>Ivan Yatskevich</name>
	</author>
	<content type="html">Hello everybody!
&lt;br&gt;&lt;br&gt;As all of you probably know a new feature, Rule mechanism, has been
&lt;br&gt;added to JUnit 4.7.
&lt;br&gt;After the discussion with David Saff (main JUnit contributor) and Nat
&lt;br&gt;Pryce it comes out that it is better to use jMock through the Rule
&lt;br&gt;mechanism and not through the runner:
&lt;br&gt;&lt;br&gt;public class JMockRuleTest {
&lt;br&gt;&amp;nbsp; @Rule public Verifier jmock = new JMockVerifier();
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;This approach will allow to use jMock with a custom JUnit runner like
&lt;br&gt;Theories or your favorite one.
&lt;br&gt;&lt;br&gt;I'm going to implement this feature and want to know your valuable
&lt;br&gt;opinion on what kind of API you expect.
&lt;br&gt;Personally I think that this new API will be similar to the current
&lt;br&gt;Mockery's one.
&lt;br&gt;&lt;br&gt;I've already created a new issue in JIRA -
&lt;br&gt;&lt;a href=&quot;http://jira.codehaus.org/browse/JMOCK-237&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://jira.codehaus.org/browse/JMOCK-237&lt;/a&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Best regards,
&lt;br&gt;Ivan Yatskevich
&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Ability-to-use-jMock-through-the-Rule-mechanism-tp26258696p26258696.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26131106</id>
	<title>Re: Advice on testing my classes that has many third party API calls.</title>
	<published>2009-10-30T07:33:28Z</published>
	<updated>2009-10-30T07:33:28Z</updated>
	<author>
		<name>Steve Freeman-2</name>
	</author>
	<content type="html">On 27 Oct 2009, at 10:36, LadyCoconut wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; My questions are:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 1. in my test I am using the matchers with(any(OpertionOptions.class),
&lt;br&gt;&amp;gt; with(any(Profile.class) and such....should I be mocking these concrete
&lt;br&gt;&amp;gt; classes using the ClassImposteriser and setting them up and checking &amp;nbsp;
&lt;br&gt;&amp;gt; the
&lt;br&gt;&amp;gt; exact expectations of these? It feels a bit wrong. All I want to &amp;nbsp;
&lt;br&gt;&amp;gt; test is
&lt;br&gt;&amp;gt; that a call to the service is made and that I get back an expected &amp;nbsp;
&lt;br&gt;&amp;gt; type with
&lt;br&gt;&amp;gt; some parameters in it?
&lt;/div&gt;&lt;br&gt;You want to check, for example, that the ObjectIdentitySet has been &amp;nbsp;
&lt;br&gt;set up correctly? You could write a more precise matcher that checks &amp;nbsp;
&lt;br&gt;the values within the ObjectIdSet that was passed in. Something like:
&lt;br&gt;&lt;br&gt;oneOf(objectService).get(with(objectIdentitySetWithId(1)), ...
&lt;br&gt;&lt;br&gt;If you just want to let the call go through, then the any() clauses &amp;nbsp;
&lt;br&gt;are fine--that's your intention. You can simplify it further, if &amp;nbsp;
&lt;br&gt;there's only one call to an object:
&lt;br&gt;&lt;br&gt;allowing(objectService); will(returnValue(dataPackage));
&lt;br&gt;&lt;br&gt;if that's all you care about. (Remember: Stub Queries, Expect Actions)
&lt;br&gt;&lt;br&gt;&amp;gt; 2. Should I be spending my time skinning and wrapping the API for &amp;nbsp;
&lt;br&gt;&amp;gt; testing?
&lt;br&gt;&amp;gt; As its rather a small project at the moment, I managed to create a &amp;nbsp;
&lt;br&gt;&amp;gt; stub
&lt;br&gt;&amp;gt; service initially that returns some duff data.
&lt;br&gt;&lt;br&gt;That depends :) At the least, I'd have some kind of interface in my &amp;nbsp;
&lt;br&gt;domain code that protected me from the library, so there were no &amp;nbsp;
&lt;br&gt;references.
&lt;br&gt;&lt;br&gt;S.
&lt;br&gt;&lt;br&gt;Steve Freeman
&lt;br&gt;&lt;br&gt;Winner of the Agile Alliance Gordon Pask award 2006
&lt;br&gt;Book: &lt;a href=&quot;http://www.growing-object-oriented-software.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.growing-object-oriented-software.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;+44 (0) 797 179 4105
&lt;br&gt;M3P Limited. &amp;nbsp;&lt;a href=&quot;http://www.m3p.co.uk&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.m3p.co.uk&lt;/a&gt;&lt;br&gt;Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ.
&lt;br&gt;Company registered in England &amp; Wales. Number 03689627
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Advice-on-testing-my-classes-that-has-many-third-party-API-calls.-tp26075443p26131106.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26099734</id>
	<title>Re: Differences between jMock &amp; Mockito</title>
	<published>2009-10-28T11:27:52Z</published>
	<updated>2009-10-28T11:27:52Z</updated>
	<author>
		<name>Steve Freeman-2</name>
	</author>
	<content type="html">&lt;div class='shrinkable-quote'&gt;&amp;gt; Julian Hall wrote:
&lt;br&gt;&amp;gt;&amp;gt; isaiah perumalla wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Jmock will highlight badly designed communication protocols &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; between object under test and its collaborators. On the other &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; hand, frameworks like mockito by default ignore all calls between &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; the object under test and it's mocked collaborator(s) and only &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; verifies calls you explicitly specify.
&lt;br&gt;&amp;gt;&amp;gt; There is, of course, a halfway ground to consider. &amp;nbsp;When I'm &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; working in .NET, I tend to use Rhino.Mocks. &amp;nbsp;This has the &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; interesting facility that if you call MockRepository.CreateMock to &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; create your mock, you end up with something that behaves like JMock &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; does, but if you call MockRepository.DynamicMock you end up with a &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; stub implementation that ignores unexpected calls, or you can use &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; MockRepository.PartialMock when mocking a concrete class to get a &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; stub that passes calls to the original implementation by default. &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; It's still a &amp;quot;set expectations before running your code&amp;quot; style of &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; interaction rather than the &amp;quot;verify what happened after you've done &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; it&amp;quot; style you use with Mockito, but it's a little more flexible &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; than JMock.
&lt;/div&gt;&lt;br&gt;Actually, JMock does the first two without have to choose when &amp;nbsp;
&lt;br&gt;declaring the mock. The third is just a bad idea unless it's an &amp;nbsp;
&lt;br&gt;emergency :)
&lt;br&gt;&lt;br&gt;S.
&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Differences-between-jMock---Mockito-tp26023576p26099734.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26098892</id>
	<title>Re: Differences between jMock &amp; Mockito</title>
	<published>2009-10-28T10:37:18Z</published>
	<updated>2009-10-28T10:37:18Z</updated>
	<author>
		<name>Rick Fisk-2</name>
	</author>
	<content type="html">&lt;br&gt;PowerMock works a bit like this. It allows you to create partial mocks 
&lt;br&gt;and to mock static objects. Unfortunately if you're testing spring 
&lt;br&gt;managers or controllers there are issues to workaround with bean 
&lt;br&gt;definitions. It has interfaces to mockito and EasyMock also.
&lt;br&gt;&lt;br&gt;Julian Hall wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; isaiah perumalla wrote:
&lt;br&gt;&amp;gt;&amp;gt; Jmock will highlight badly designed communication protocols between 
&lt;br&gt;&amp;gt;&amp;gt; object under test and its collaborators. On the other hand, 
&lt;br&gt;&amp;gt;&amp;gt; frameworks like mockito by default ignore all calls between the 
&lt;br&gt;&amp;gt;&amp;gt; object under test and it's mocked collaborator(s) and only verifies 
&lt;br&gt;&amp;gt;&amp;gt; calls you explicitly specify.
&lt;br&gt;&amp;gt; There is, of course, a halfway ground to consider. &amp;nbsp;When I'm working 
&lt;br&gt;&amp;gt; in .NET, I tend to use Rhino.Mocks. &amp;nbsp;This has the interesting facility 
&lt;br&gt;&amp;gt; that if you call MockRepository.CreateMock to create your mock, you 
&lt;br&gt;&amp;gt; end up with something that behaves like JMock does, but if you call 
&lt;br&gt;&amp;gt; MockRepository.DynamicMock you end up with a stub implementation that 
&lt;br&gt;&amp;gt; ignores unexpected calls, or you can use MockRepository.PartialMock 
&lt;br&gt;&amp;gt; when mocking a concrete class to get a stub that passes calls to the 
&lt;br&gt;&amp;gt; original implementation by default. &amp;nbsp;It's still a &amp;quot;set expectations 
&lt;br&gt;&amp;gt; before running your code&amp;quot; style of interaction rather than the &amp;quot;verify 
&lt;br&gt;&amp;gt; what happened after you've done it&amp;quot; style you use with Mockito, but 
&lt;br&gt;&amp;gt; it's a little more flexible than JMock.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; (The API's also a little cleaner, but that's because .NET allows a 
&lt;br&gt;&amp;gt; cleaner API than Java does, largely due to having proper generic types)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ---------------------------------------------------------------------
&lt;br&gt;&amp;gt; To unsubscribe from this list, please visit:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Differences-between-jMock---Mockito-tp26023576p26098892.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26075443</id>
	<title>Advice on testing my classes that has many third party API calls.</title>
	<published>2009-10-27T03:36:33Z</published>
	<updated>2009-10-27T03:36:33Z</updated>
	<author>
		<name>LadyCoconut</name>
	</author>
	<content type="html">Hello Everyone, 
&lt;br&gt;&lt;br&gt;I have some experience in jMock. Currently using it with JUnit 3 (long story). 
&lt;br&gt;&lt;br&gt;Anyway, I've had to develop a little application that depends heavily on third party libraries. The libraries are basically &amp;nbsp;used for pulling documents from a repository. Some of the classes have interfaces (not many) and there are many concrete classes. 
&lt;br&gt;&lt;br&gt;Assume the following test code:
&lt;br&gt;&lt;br&gt;&lt;b&gt;final IObjectService objectService = mock(IObjectService.class);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;final DataPackage dataPackage = createDataPackage();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;checking(new Expectations() {{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oneOf (serviceContext).getIdentityCount(); will(returnValue(1));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oneOf (serviceContext).setProfile(with(any(Profile.class)));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oneOf (serviceFactory).getLocalService(with(IObjectService.class), 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 		with(serviceContext)); will(returnValue(objectService));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 		
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oneOf (objectService).get(with(any(ObjectIdentitySet.class)), 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 		with(any(OperationOptions.class))); will(returnValue(dataPackage));
&lt;br&gt;}});
&lt;br&gt;&lt;br&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;Now here is the code that it is testing (bit ugly) but bear with me...
&lt;br&gt;&lt;br&gt;&lt;b&gt;if(serviceContext.getIdentityCount() == 0) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; serviceContext.addIdentity(repositoryIdentity);
&lt;br&gt;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;ObjectId id = new ObjectId(objectId);
&lt;br&gt;ObjectIdentity&amp;lt;ObjectId&amp;gt; objectIdentity = new ObjectIdentity&amp;lt;ObjectId&amp;gt;(id, repositoryIdentity.getRepositoryName());
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;ObjectIdentitySet objectIdSet = new ObjectIdentitySet();
&lt;br&gt;objectIdSet.addIdentity(objectIdentity);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;ContentTransferProfile transferProfile = new ContentTransferProfile();
&lt;br&gt;transferProfile.setTransferMode(ContentTransferMode.MTOM);
&lt;br&gt;transferProfile.setCachedContentTransferAllowed(true);
&lt;br&gt;transferProfile.setAsyncContentTransferAllowed(true);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;serviceContext.setProfile(transferProfile);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;IObjectService objectService = serviceFactory.getLocalService(IObjectService.class, serviceContext);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;OperationOptions operationsOptions = getOperationsOptionsProfile();
&lt;br&gt;DataPackage dataPackage = objectService.get(objectIdSet, operationsOptions);
&lt;br&gt;Content content = dataPackage.getDataObjects().get(0).getContents().get(0); //check&lt;/b&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;My questions are:
&lt;br&gt;&lt;br&gt;&amp;nbsp;1. in my test I am using the matchers with(any(OpertionOptions.class), with(any(Profile.class) and such....should I be mocking these concrete classes using the ClassImposteriser and setting them up and checking the exact expectations of these? It feels a bit wrong. All I want to test is that a call to the service is made and that I get back an expected type with some parameters in it? &amp;nbsp; 
&lt;br&gt;&lt;br&gt;&amp;nbsp;2. Should I be spending my time skinning and wrapping the API for testing? As its rather a small project at the moment, I managed to create a stub service initially that returns some duff data. 
&lt;br&gt;&lt;br&gt;Any thoughts would be welcome. 
&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; </content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Advice-on-testing-my-classes-that-has-many-third-party-API-calls.-tp26075443p26075443.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26060153</id>
	<title>Re: Differences between jMock &amp; Mockito</title>
	<published>2009-10-26T06:51:29Z</published>
	<updated>2009-10-26T06:51:29Z</updated>
	<author>
		<name>Steve Freeman-2</name>
	</author>
	<content type="html">With tests like this, there's not much difference, although both tests &amp;nbsp;
&lt;br&gt;could be made more compact. It's mostly stubbing, since there's no &amp;nbsp;
&lt;br&gt;external change in state. There's a bit of duplication in the mockito &amp;nbsp;
&lt;br&gt;version for the verification but, as you point out, it's not &amp;nbsp;
&lt;br&gt;interesting here. Even easymock could be made to work for these tests.
&lt;br&gt;&lt;br&gt;I think the differences (if any) will become more apparent when the &amp;nbsp;
&lt;br&gt;code deals in more behaviour than values. Here's an example from the &amp;nbsp;
&lt;br&gt;book (hope it doesn't get mangled by line-wrapping):
&lt;br&gt;&lt;br&gt;public class SniperLauncherTest {
&lt;br&gt;&amp;nbsp; &amp;nbsp;private final States auctionState = context.states(&amp;quot;auction state&amp;quot;)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .startsAs(&amp;quot;not joined&amp;quot;);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;@Test public void addsNewSniperToCollectorAndThenJoinsAuction() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;final String itemId = &amp;quot;item 123&amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;context.checking(new Expectations() {{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;allowing(auctionHouse).auctionFor(itemId); will(returnValue 
&lt;br&gt;(auction));
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;oneOf(sniperCollector).addSniper(with(sniperForItem(item)));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;when(auctionState.is(&amp;quot;not &amp;nbsp;
&lt;br&gt;joined&amp;quot;)); &amp;nbsp; &amp;nbsp; &amp;nbsp; 	
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;oneOf(auction).addAuctionEventListener(with(sniperForItem 
&lt;br&gt;(itemId)));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;when(auctionState.is(&amp;quot;not &amp;nbsp;
&lt;br&gt;joined&amp;quot;));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;one(auction).join(); then(auctionState.is(&amp;quot;joined&amp;quot;));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}});
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;launcher.joinAuction(itemId);
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;which describes the relationships between a &amp;quot;launcher&amp;quot;, an &amp;quot;auction&amp;quot;, &amp;nbsp;
&lt;br&gt;and a &amp;quot;sniperCollector&amp;quot;. This is about protocols between objects, not &amp;nbsp;
&lt;br&gt;just method calls, and maps nicely onto a state-transition diagram we &amp;nbsp;
&lt;br&gt;drew to describe these relationships. We don't need this all the time, &amp;nbsp;
&lt;br&gt;but when we do, we really do.
&lt;br&gt;&lt;br&gt;S.
&lt;br&gt;&lt;br&gt;On 25 Oct 2009, at 23:56, Neil Swingler wrote:
&lt;br&gt;&amp;gt; I have just given myself a 30 minute crash course in jmock2 by &amp;nbsp;
&lt;br&gt;&amp;gt; converting one of jmock's very own unit tests to Mockito. OK I only &amp;nbsp;
&lt;br&gt;&amp;gt; chose the first test but I think it gives a flavour of the &amp;nbsp;
&lt;br&gt;&amp;gt; differences. The full compiling class is attached but here is the &amp;nbsp;
&lt;br&gt;&amp;gt; interesting bit. Personally I would probably skip the verify steps &amp;nbsp;
&lt;br&gt;&amp;gt; in the mockito version but kept them in for completeness.
&lt;br&gt;&amp;gt; [...]
&lt;br&gt;&lt;br&gt;Steve Freeman
&lt;br&gt;&lt;br&gt;Winner of the Agile Alliance Gordon Pask award 2006
&lt;br&gt;Book: &lt;a href=&quot;http://www.growing-object-oriented-software.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.growing-object-oriented-software.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;+44 (0) 797 179 4105
&lt;br&gt;M3P Limited. &amp;nbsp;&lt;a href=&quot;http://www.m3p.co.uk&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.m3p.co.uk&lt;/a&gt;&lt;br&gt;Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ.
&lt;br&gt;Company registered in England &amp; Wales. Number 03689627
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Differences-between-jMock---Mockito-tp26023576p26060153.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26055560</id>
	<title>Re: Differences between jMock &amp; Mockito</title>
	<published>2009-10-26T00:50:09Z</published>
	<updated>2009-10-26T00:50:09Z</updated>
	<author>
		<name>Neil Swingler</name>
	</author>
	<content type="html">&lt;br&gt;Well here the stub part is being separated from the expectation part. I
&lt;br&gt;&lt;br&gt;think this is not a bad thing. As I said I would personally delete the
&lt;br&gt;&lt;br&gt;verification calls as they duplicate the checking done by the asserts at
&lt;br&gt;&lt;br&gt;the end anyway. I just left them in to demonstrate mockito.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;- Neil
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;On Mon, 26 Oct 2009 07:05:14 +0000, Nat Pryce &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26055560&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;nat.pryce@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;br&gt;&amp;gt; They look not too different apart from Mockito makes you duplicate
&lt;br&gt;&lt;br&gt;&amp;gt; expectations a bit.
&lt;br&gt;&lt;br&gt;&amp;gt; 
&lt;br&gt;&lt;br&gt;&amp;gt; An interesting comparison might be a test that uses jMock's States
&lt;br&gt;&lt;br&gt;&amp;gt; mechanism to control ordering and vary the behaviour of mocked calls.
&lt;br&gt;&lt;br&gt;&amp;gt; 
&lt;br&gt;&lt;br&gt;&amp;gt; --Nat
&lt;br&gt;&lt;br&gt;&amp;gt; 
&lt;br&gt;&lt;br&gt;&amp;gt; On Sunday, October 25, 2009, Neil Swingler &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26055560&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;neil@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; I have just given myself a 30 minute crash course in jmock2 by
&lt;br&gt;&lt;br&gt;converting
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; one of jmock's very own unit tests to Mockito. OK I only chose the first
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; test but I think it gives a flavour of the differences. The full
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; compiling class is attached but here is the interesting bit. Personally
&lt;br&gt;&lt;br&gt;I
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; would probably skip the verify steps in the mockito version but kept
&lt;br&gt;&lt;br&gt;them
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; in for completeness.
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;  public void testLoadsObjectThatIsNotCachedWithJmock() {
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      Mockery context = new Mockery() {{
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;         
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;setExpectationErrorTranslator(JUnit3ErrorTranslator.INSTANCE);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      }};
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      final Clock clock = context.mock(Clock.class);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      final ObjectLoader loader = context.mock(ObjectLoader.class,
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;&amp;quot;loader&amp;quot;);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      ReloadPolicy reloadPolicy = context.mock(ReloadPolicy.class);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      TimedCache cache = new TimedCache(loader, clock,
&lt;br&gt;&lt;br&gt;reloadPolicy);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      context.checking(new Expectations() {{
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;          allowing (clock).time(); will(returnValue(loadTime));
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;          oneOf (loader).load(&amp;quot;key1&amp;quot;); will(returnValue(VALUE1));
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;          oneOf (loader).load(&amp;quot;key2&amp;quot;); will(returnValue(VALUE2));
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      }});
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      Object actualValue1 = cache.lookup(&amp;quot;key1&amp;quot;);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      Object actualValue2 = cache.lookup(&amp;quot;key2&amp;quot;);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;            context.assertIsSatisfied();
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      assertEquals(&amp;quot;lookup with key1&amp;quot;, VALUE1, actualValue1);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      assertEquals(&amp;quot;lookup with key2&amp;quot;, VALUE2, actualValue2);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;  }
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;  public void testLoadsObjectThatIsNotCachedWithMockito() {
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      Clock clock = mock(Clock.class);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      ObjectLoader loader = mock(ObjectLoader.class, &amp;quot;loader&amp;quot;);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      ReloadPolicy reloadPolicy = mock(ReloadPolicy.class);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      TimedCache cache = new TimedCache(loader, clock,
&lt;br&gt;&lt;br&gt;reloadPolicy);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      when(clock.time()).thenReturn(loadTime);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      when(loader.load(eq(&amp;quot;key1&amp;quot;))).thenReturn(VALUE1);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      when(loader.load(eq(&amp;quot;key2&amp;quot;))).thenReturn(VALUE2);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      Object actualValue1 = cache.lookup(&amp;quot;key1&amp;quot;);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      Object actualValue2 = cache.lookup(&amp;quot;key2&amp;quot;);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;            verify(loader).load(&amp;quot;key1&amp;quot;);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      verify(loader).load(&amp;quot;key2&amp;quot;);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;            verifyNoMoreInteractions(loader);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      assertEquals(&amp;quot;lookup with key1&amp;quot;, VALUE1, actualValue1);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;      assertEquals(&amp;quot;lookup with key2&amp;quot;, VALUE2, actualValue2);
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;  }
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; - Neil
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Differences-between-jMock---Mockito-tp26023576p26055560.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26055231</id>
	<title>Re: Differences between jMock &amp; Mockito</title>
	<published>2009-10-26T00:05:14Z</published>
	<updated>2009-10-26T00:05:14Z</updated>
	<author>
		<name>Nat Pryce</name>
	</author>
	<content type="html">They look not too different apart from Mockito makes you duplicate
&lt;br&gt;expectations a bit.
&lt;br&gt;&lt;br&gt;An interesting comparison might be a test that uses jMock's States
&lt;br&gt;mechanism to control ordering and vary the behaviour of mocked calls.
&lt;br&gt;&lt;br&gt;--Nat
&lt;br&gt;&lt;br&gt;On Sunday, October 25, 2009, Neil Swingler &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26055231&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;neil@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I have just given myself a 30 minute crash course in jmock2 by converting one of jmock's very own unit tests to Mockito. OK I only chose the first test but I think it gives a flavour of the differences. The full compiling class is attached but here is the interesting bit. Personally I would probably skip the verify steps in the mockito version but kept them in for completeness.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;  public void testLoadsObjectThatIsNotCachedWithJmock() {
&lt;br&gt;&amp;gt; &amp;nbsp;      Mockery context = new Mockery() {{
&lt;br&gt;&amp;gt; &amp;nbsp;          setExpectationErrorTranslator(JUnit3ErrorTranslator.INSTANCE);
&lt;br&gt;&amp;gt; &amp;nbsp;      }};
&lt;br&gt;&amp;gt; &amp;nbsp;      final Clock clock = context.mock(Clock.class);
&lt;br&gt;&amp;gt; &amp;nbsp;      final ObjectLoader loader = context.mock(ObjectLoader.class, &amp;quot;loader&amp;quot;);
&lt;br&gt;&amp;gt; &amp;nbsp;      ReloadPolicy reloadPolicy = context.mock(ReloadPolicy.class);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;      TimedCache cache = new TimedCache(loader, clock, reloadPolicy);
&lt;br&gt;&amp;gt; &amp;nbsp;      context.checking(new Expectations() {{
&lt;br&gt;&amp;gt; &amp;nbsp;          allowing (clock).time(); will(returnValue(loadTime));
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;          oneOf (loader).load(&amp;quot;key1&amp;quot;); will(returnValue(VALUE1));
&lt;br&gt;&amp;gt; &amp;nbsp;          oneOf (loader).load(&amp;quot;key2&amp;quot;); will(returnValue(VALUE2));
&lt;br&gt;&amp;gt; &amp;nbsp;      }});
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;      Object actualValue1 = cache.lookup(&amp;quot;key1&amp;quot;);
&lt;br&gt;&amp;gt; &amp;nbsp;      Object actualValue2 = cache.lookup(&amp;quot;key2&amp;quot;);
&lt;br&gt;&amp;gt; &amp;nbsp;            context.assertIsSatisfied();
&lt;br&gt;&amp;gt; &amp;nbsp;      assertEquals(&amp;quot;lookup with key1&amp;quot;, VALUE1, actualValue1);
&lt;br&gt;&amp;gt; &amp;nbsp;      assertEquals(&amp;quot;lookup with key2&amp;quot;, VALUE2, actualValue2);
&lt;br&gt;&amp;gt; &amp;nbsp;  }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;  public void testLoadsObjectThatIsNotCachedWithMockito() {
&lt;br&gt;&amp;gt; &amp;nbsp;      Clock clock = mock(Clock.class);
&lt;br&gt;&amp;gt; &amp;nbsp;      ObjectLoader loader = mock(ObjectLoader.class, &amp;quot;loader&amp;quot;);
&lt;br&gt;&amp;gt; &amp;nbsp;      ReloadPolicy reloadPolicy = mock(ReloadPolicy.class);
&lt;br&gt;&amp;gt; &amp;nbsp;      TimedCache cache = new TimedCache(loader, clock, reloadPolicy);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;      when(clock.time()).thenReturn(loadTime);
&lt;br&gt;&amp;gt; &amp;nbsp;      when(loader.load(eq(&amp;quot;key1&amp;quot;))).thenReturn(VALUE1);
&lt;br&gt;&amp;gt; &amp;nbsp;      when(loader.load(eq(&amp;quot;key2&amp;quot;))).thenReturn(VALUE2);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;      Object actualValue1 = cache.lookup(&amp;quot;key1&amp;quot;);
&lt;br&gt;&amp;gt; &amp;nbsp;      Object actualValue2 = cache.lookup(&amp;quot;key2&amp;quot;);
&lt;br&gt;&amp;gt; &amp;nbsp;            verify(loader).load(&amp;quot;key1&amp;quot;);
&lt;br&gt;&amp;gt; &amp;nbsp;      verify(loader).load(&amp;quot;key2&amp;quot;);
&lt;br&gt;&amp;gt; &amp;nbsp;            verifyNoMoreInteractions(loader);
&lt;br&gt;&amp;gt; &amp;nbsp;      assertEquals(&amp;quot;lookup with key1&amp;quot;, VALUE1, actualValue1);
&lt;br&gt;&amp;gt; &amp;nbsp;      assertEquals(&amp;quot;lookup with key2&amp;quot;, VALUE2, actualValue2);
&lt;br&gt;&amp;gt; &amp;nbsp;  }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; - Neil
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.natpryce.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.natpryce.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Differences-between-jMock---Mockito-tp26023576p26055231.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26052709</id>
	<title>Re: Differences between jMock &amp; Mockito</title>
	<published>2009-10-25T15:56:17Z</published>
	<updated>2009-10-25T15:56:17Z</updated>
	<author>
		<name>Neil Swingler</name>
	</author>
	<content type="html">I have just given myself a 30 minute crash course in jmock2 by 
&lt;br&gt;converting one of jmock's very own unit tests to Mockito. OK I only 
&lt;br&gt;chose the first test but I think it gives a flavour of the differences. 
&lt;br&gt;The full compiling class is attached but here is the interesting bit. 
&lt;br&gt;Personally I would probably skip the verify steps in the mockito version 
&lt;br&gt;but kept them in for completeness.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; public void testLoadsObjectThatIsNotCachedWithJmock() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Mockery context = new Mockery() {{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setExpectationErrorTranslator(JUnit3ErrorTranslator.INSTANCE);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }};
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final Clock clock = context.mock(Clock.class);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final ObjectLoader loader = context.mock(ObjectLoader.class, 
&lt;br&gt;&amp;quot;loader&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ReloadPolicy reloadPolicy = context.mock(ReloadPolicy.class);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TimedCache cache = new TimedCache(loader, clock, reloadPolicy);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; context.checking(new Expectations() {{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; allowing (clock).time(); will(returnValue(loadTime));
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oneOf (loader).load(&amp;quot;key1&amp;quot;); will(returnValue(VALUE1));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oneOf (loader).load(&amp;quot;key2&amp;quot;); will(returnValue(VALUE2));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }});
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Object actualValue1 = cache.lookup(&amp;quot;key1&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Object actualValue2 = cache.lookup(&amp;quot;key2&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; context.assertIsSatisfied();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; assertEquals(&amp;quot;lookup with key1&amp;quot;, VALUE1, actualValue1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; assertEquals(&amp;quot;lookup with key2&amp;quot;, VALUE2, actualValue2);
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; public void testLoadsObjectThatIsNotCachedWithMockito() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Clock clock = mock(Clock.class);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ObjectLoader loader = mock(ObjectLoader.class, &amp;quot;loader&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ReloadPolicy reloadPolicy = mock(ReloadPolicy.class);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TimedCache cache = new TimedCache(loader, clock, reloadPolicy);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; when(clock.time()).thenReturn(loadTime);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; when(loader.load(eq(&amp;quot;key1&amp;quot;))).thenReturn(VALUE1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; when(loader.load(eq(&amp;quot;key2&amp;quot;))).thenReturn(VALUE2);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Object actualValue1 = cache.lookup(&amp;quot;key1&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Object actualValue2 = cache.lookup(&amp;quot;key2&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; verify(loader).load(&amp;quot;key1&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; verify(loader).load(&amp;quot;key2&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; verifyNoMoreInteractions(loader);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; assertEquals(&amp;quot;lookup with key1&amp;quot;, VALUE1, actualValue1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; assertEquals(&amp;quot;lookup with key2&amp;quot;, VALUE2, actualValue2);
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;- Neil
&lt;br&gt;&lt;br /&gt;/* &amp;nbsp;Copyright (c) 2000-2004 jMock.org
&lt;br&gt;&amp;nbsp;*/
&lt;br&gt;package org.jmock.example.timedcache;
&lt;br&gt;&lt;br&gt;import static org.mockito.Matchers.eq;
&lt;br&gt;import static org.mockito.Mockito.mock;
&lt;br&gt;import static org.mockito.Mockito.verify;
&lt;br&gt;import static org.mockito.Mockito.verifyNoMoreInteractions;
&lt;br&gt;import static org.mockito.Mockito.when;
&lt;br&gt;&lt;br&gt;import java.util.Calendar;
&lt;br&gt;import java.util.Date;
&lt;br&gt;&lt;br&gt;import junit.framework.TestCase;
&lt;br&gt;&lt;br&gt;import org.jmock.Expectations;
&lt;br&gt;import org.jmock.Mockery;
&lt;br&gt;import org.jmock.integration.junit3.JUnit3ErrorTranslator;
&lt;br&gt;&lt;br&gt;&lt;br&gt;public class TimedCacheTests extends TestCase {
&lt;br&gt;&amp;nbsp; &amp;nbsp; private Date loadTime = time(1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; final Object VALUE1 = &amp;quot;value1&amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; final Object VALUE2 = &amp;quot;value2&amp;quot;;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; public void testLoadsObjectThatIsNotCachedWithJmock() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Mockery context = new Mockery() {{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setExpectationErrorTranslator(JUnit3ErrorTranslator.INSTANCE);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }};
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final Clock clock = context.mock(Clock.class);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final ObjectLoader loader = context.mock(ObjectLoader.class, &amp;quot;loader&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ReloadPolicy reloadPolicy = context.mock(ReloadPolicy.class);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TimedCache cache = new TimedCache(loader, clock, reloadPolicy);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; context.checking(new Expectations() {{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; allowing (clock).time(); will(returnValue(loadTime));
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oneOf (loader).load(&amp;quot;key1&amp;quot;); will(returnValue(VALUE1));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oneOf (loader).load(&amp;quot;key2&amp;quot;); will(returnValue(VALUE2));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }});
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Object actualValue1 = cache.lookup(&amp;quot;key1&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Object actualValue2 = cache.lookup(&amp;quot;key2&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; context.assertIsSatisfied();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; assertEquals(&amp;quot;lookup with key1&amp;quot;, VALUE1, actualValue1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; assertEquals(&amp;quot;lookup with key2&amp;quot;, VALUE2, actualValue2);
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; public void testLoadsObjectThatIsNotCachedWithMockito() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Clock clock = mock(Clock.class);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ObjectLoader loader = mock(ObjectLoader.class, &amp;quot;loader&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ReloadPolicy reloadPolicy = mock(ReloadPolicy.class);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TimedCache cache = new TimedCache(loader, clock, reloadPolicy);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; when(clock.time()).thenReturn(loadTime);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; when(loader.load(eq(&amp;quot;key1&amp;quot;))).thenReturn(VALUE1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; when(loader.load(eq(&amp;quot;key2&amp;quot;))).thenReturn(VALUE2);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Object actualValue1 = cache.lookup(&amp;quot;key1&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Object actualValue2 = cache.lookup(&amp;quot;key2&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; verify(loader).load(&amp;quot;key1&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; verify(loader).load(&amp;quot;key2&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; verifyNoMoreInteractions(loader);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; assertEquals(&amp;quot;lookup with key1&amp;quot;, VALUE1, actualValue1);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; assertEquals(&amp;quot;lookup with key2&amp;quot;, VALUE2, actualValue2);
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; private Date time(int i) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Calendar calendar = Calendar.getInstance();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; calendar.clear();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; calendar.set(Calendar.DAY_OF_YEAR, i);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return calendar.getTime();
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;&lt;br /&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Differences-between-jMock---Mockito-tp26023576p26052709.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26051793</id>
	<title>Re: Differences between jMock &amp; Mockito</title>
	<published>2009-10-25T14:03:47Z</published>
	<updated>2009-10-25T14:03:47Z</updated>
	<author>
		<name>Steve Freeman-2</name>
	</author>
	<content type="html">&amp;gt; I agree Nat. I'm just trying to counter the opinion that mockito &amp;nbsp;
&lt;br&gt;&amp;gt; will hide a bad design.
&lt;br&gt;&lt;br&gt;I would love to see if using mockito/jmock actually has any effect on &amp;nbsp;
&lt;br&gt;design. So far, I've peeked into as many as 3 codebases that use &amp;nbsp;
&lt;br&gt;mockito and not been hugely impressed with 2 of them (no, I don't have &amp;nbsp;
&lt;br&gt;any data for jmock).
&lt;br&gt;&lt;br&gt;It would be neat, for example, to run Keith's measure on different &amp;nbsp;
&lt;br&gt;projects and see if there's a significant difference.
&lt;br&gt;&lt;br&gt;S.
&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Differences-between-jMock---Mockito-tp26023576p26051793.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26051240</id>
	<title>Re: Differences between jMock &amp; Mockito</title>
	<published>2009-10-25T13:01:17Z</published>
	<updated>2009-10-25T13:01:17Z</updated>
	<author>
		<name>Nat Pryce</name>
	</author>
	<content type="html">2009/10/25 &amp;quot;Günther, Rene - Innflow AG&amp;quot; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26051240&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;rene.guenther@...&lt;/a&gt;&amp;gt;:
&lt;br&gt;&amp;gt; Thats interesting. Normally that applies to our objects as well (one or two
&lt;br&gt;&amp;gt; mocks). But our main object (a financial document) has references to almost
&lt;br&gt;&amp;gt; all other objects. The documentManager is interacting with 10-15 other
&lt;br&gt;&amp;gt; managers (to be mocked). Would you recommend to split that manager? Maybe
&lt;br&gt;&amp;gt; you know of some pattern which would help simplify that manager?
&lt;br&gt;&lt;br&gt;I'd consider the fact that it has 10 to 15 dependencies a smell. Also
&lt;br&gt;a smell is the fact that it has a vague word like &amp;quot;manager&amp;quot; in its
&lt;br&gt;name. &amp;nbsp;I'd try to look at what its responsibilities are and divide it
&lt;br&gt;up into objects that perform those responsibilities and are have more
&lt;br&gt;evocative / concrete names.
&lt;br&gt;&lt;br&gt;Exactly what patterns I'd use I cannot say without knowing about the
&lt;br&gt;system and domain.
&lt;br&gt;&lt;br&gt;--Nat
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.natpryce.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.natpryce.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Differences-between-jMock---Mockito-tp26023576p26051240.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26050319</id>
	<title>AW: Differences between jMock &amp; Mockito</title>
	<published>2009-10-25T11:10:56Z</published>
	<updated>2009-10-25T11:10:56Z</updated>
	<author>
		<name>Rene Guenther</name>
	</author>
	<content type="html">Thats interesting. Normally that applies to our objects as well (one or two
&lt;br&gt;mocks). But our main object (a financial document) has references to almost
&lt;br&gt;all other objects. The documentManager is interacting with 10-15 other
&lt;br&gt;managers (to be mocked). Would you recommend to split that manager? Maybe
&lt;br&gt;you know of some pattern which would help simplify that manager?
&lt;br&gt;&lt;br&gt;Thanks
&lt;br&gt;Rene
&lt;br&gt;&lt;br&gt;-----Ursprüngliche Nachricht-----
&lt;br&gt;Von: Nat Pryce [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26050319&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;nat.pryce@...&lt;/a&gt;] 
&lt;br&gt;Gesendet: Sonntag, 25. Oktober 2009 15:01
&lt;br&gt;An: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26050319&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;user@...&lt;/a&gt;
&lt;br&gt;Betreff: Re: [jmock-user] Differences between jMock &amp; Mockito
&lt;br&gt;&lt;br&gt;2009/10/24 Neil Swingler &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26050319&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;neil@...&lt;/a&gt;&amp;gt;:
&lt;br&gt;&amp;gt; setting up a lot of mocks is still a pain whichever framework you use.
&lt;br&gt;&lt;br&gt;Our opinion (and jMock is 'opinionated software') is that is your
&lt;br&gt;tests telling you that your object under test has too many
&lt;br&gt;dependencies. &amp;nbsp;A test shouldn't create more than a handful of mocks.
&lt;br&gt;Most tests I see create one or two.
&lt;br&gt;&lt;br&gt;--Nat
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.natpryce.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.natpryce.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Differences-between-jMock---Mockito-tp26023576p26050319.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26049245</id>
	<title>Re: Differences between jMock &amp; Mockito</title>
	<published>2009-10-25T09:19:39Z</published>
	<updated>2009-10-25T09:19:39Z</updated>
	<author>
		<name>Nat Pryce</name>
	</author>
	<content type="html">Mockito won't hide that, I agree.
&lt;br&gt;&lt;br&gt;But it will hide complex inter-object protocols by, for example,
&lt;br&gt;hiding that there are lots of get-calls between objects.
&lt;br&gt;&lt;br&gt;--Nat
&lt;br&gt;&lt;br&gt;2009/10/25 Neil Swingler &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26049245&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;neil@...&lt;/a&gt;&amp;gt;:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I agree Nat. I'm just trying to counter the opinion that mockito will hide a
&lt;br&gt;&amp;gt; bad design.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; - Neil
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On 25 Oct 2009, at 15:00, Nat Pryce &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26049245&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;nat.pryce@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; 2009/10/24 Neil Swingler &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26049245&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;neil@...&lt;/a&gt;&amp;gt;:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; setting up a lot of mocks is still a pain whichever framework you use.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Our opinion (and jMock is 'opinionated software') is that is your
&lt;br&gt;&amp;gt;&amp;gt; tests telling you that your object under test has too many
&lt;br&gt;&amp;gt;&amp;gt; dependencies.  A test shouldn't create more than a handful of mocks.
&lt;br&gt;&amp;gt;&amp;gt; Most tests I see create one or two.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; --Nat
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; --
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://www.natpryce.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.natpryce.com&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; ---------------------------------------------------------------------
&lt;br&gt;&amp;gt;&amp;gt; To unsubscribe from this list, please visit:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;   &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ---------------------------------------------------------------------
&lt;br&gt;&amp;gt; To unsubscribe from this list, please visit:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;   &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.natpryce.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.natpryce.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Differences-between-jMock---Mockito-tp26023576p26049245.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26048637</id>
	<title>Re: Differences between jMock &amp; Mockito</title>
	<published>2009-10-25T07:13:06Z</published>
	<updated>2009-10-25T07:13:06Z</updated>
	<author>
		<name>Neil Swingler</name>
	</author>
	<content type="html">I agree Nat. I'm just trying to counter the opinion that mockito will &amp;nbsp;
&lt;br&gt;hide a bad design.
&lt;br&gt;&lt;br&gt;- Neil
&lt;br&gt;&lt;br&gt;On 25 Oct 2009, at 15:00, Nat Pryce &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26048637&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;nat.pryce@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; 2009/10/24 Neil Swingler &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26048637&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;neil@...&lt;/a&gt;&amp;gt;:
&lt;br&gt;&amp;gt;&amp;gt; setting up a lot of mocks is still a pain whichever framework you &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; use.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Our opinion (and jMock is 'opinionated software') is that is your
&lt;br&gt;&amp;gt; tests telling you that your object under test has too many
&lt;br&gt;&amp;gt; dependencies. &amp;nbsp;A test shouldn't create more than a handful of mocks.
&lt;br&gt;&amp;gt; Most tests I see create one or two.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --Nat
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.natpryce.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.natpryce.com&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ---------------------------------------------------------------------
&lt;br&gt;&amp;gt; To unsubscribe from this list, please visit:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Differences-between-jMock---Mockito-tp26023576p26048637.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26049389</id>
	<title>Re: Differences between jMock &amp; Mockito</title>
	<published>2009-10-25T07:00:55Z</published>
	<updated>2009-10-25T07:00:55Z</updated>
	<author>
		<name>Nat Pryce</name>
	</author>
	<content type="html">2009/10/24 Neil Swingler &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26049389&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;neil@...&lt;/a&gt;&amp;gt;:
&lt;br&gt;&amp;gt; setting up a lot of mocks is still a pain whichever framework you use.
&lt;br&gt;&lt;br&gt;Our opinion (and jMock is 'opinionated software') is that is your
&lt;br&gt;tests telling you that your object under test has too many
&lt;br&gt;dependencies. &amp;nbsp;A test shouldn't create more than a handful of mocks.
&lt;br&gt;Most tests I see create one or two.
&lt;br&gt;&lt;br&gt;--Nat
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://www.natpryce.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.natpryce.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Differences-between-jMock---Mockito-tp26023576p26049389.html" />
</entry>

</feed>
