Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9115/input/javasrc/biz/xsoftware/test/mock2
Modified Files:
TestMockCreator.java TestIgnoredMethods.java
Added Files:
TestVerify.java
Log Message:
Missing returns on expect or ignore are reported to the user. Incorrect return types fail and are reported. Fixed some bugs with MockObject.verify().
--- NEW FILE: TestVerify.java ---
/**
* Copyright (C) 2006 Carrier Access, Corp.
*/
package biz.xsoftware.test.mock2;
import junit.framework.TestCase;
import biz.xsoftware.mock2.MockObject;
import biz.xsoftware.mock2.MockObjectFactory;
/**
*/
public class TestVerify extends TestCase
{
private MockObject mock;
private FakeSystem fake;
private byte zeroByte = 30;
/**
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void setUp() throws Exception
{
mock = MockObjectFactory.createMock(ListenerOne.class);
fake = new FakeSystem((ListenerOne)mock, zeroByte);
}
/**
* @see junit.framework.TestCase#tearDown()
*/
@Override
protected void tearDown() throws Exception
{
super.tearDown();
}
public void testVerifyWithAllMethodsIgnored()
{
//we are expecting this array to be modified so clone it here...
byte[] expected = new byte[] { 4, 5, 6, 7 };
mock.addIgnoredMethod(100, "write");
mock.addIgnoredMethod("callMeLast");
mock.addIgnoredMethod("callMeFirst");
int answer = fake.runSystem(expected);
mock.verify();
assertEquals(100, answer);
}
public void testIncorrectReturnTypeExpected()
{
//we are expecting this array to be modified so clone it here...
byte[] expected = new byte[] { 4, 5, 6, 7 };
mock.addIgnoredMethod(new Object(), "write");
mock.addIgnoredMethod("callMeLast");
mock.addIgnoredMethod("callMeFirst");
try
{
fake.runSystem(expected);
fail("We specified an incorrect return type, so this should have thrown a RuntimeException");
}
catch(RuntimeException e)
{}
}
public void testBoxableReturnType()
{
//we are expecting this array to be modified so clone it here...
byte[] expected = new byte[] { 4, 5, 6, 7 };
mock.addIgnoredMethod(new Integer(100), "write");
mock.addIgnoredMethod("callMeLast");
mock.addIgnoredMethod("callMeFirst");
int answer = fake.runSystem(expected);
mock.verify();
assertEquals(100, answer);
}
}
Index: TestIgnoredMethods.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock2/TestIgnoredMethods.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestIgnoredMethods.java 2 May 2006 23:26:34 -0000 1.1
--- TestIgnoredMethods.java 5 May 2006 15:29:23 -0000 1.2
***************
*** 38,42 ****
}
-
public void testIgnoredMethods()
{
--- 38,41 ----
Index: TestMockCreator.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock2/TestMockCreator.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** TestMockCreator.java 2 May 2006 23:26:34 -0000 1.19
--- TestMockCreator.java 5 May 2006 15:29:23 -0000 1.20
***************
*** 192,195 ****
--- 192,196 ----
t.start();
+ Thread.sleep(4000);
m.verify();
***************
*** 330,334 ****
l.callMeFirst(param1);
m.addIgnoredMethod(methodName1);
- m.setDefaultReturnValue("retval",methodName1);
l.callMeLast(param2);
l.callMeFirst(param1);
--- 331,334 ----
***************
*** 342,351 ****
}
-
-
-
-
-
-
}
--- 342,345 ----
|