package jmock.example.tests; import jmock.example.MockMe; import junit.framework.TestCase; import org.jmock.Expectations; import org.jmock.Mockery; import org.jmock.lib.legacy.ClassImposteriser; public class MockMeTest extends TestCase { private Mockery context = new Mockery() {{ setImposteriser(ClassImposteriser.INSTANCE); }}; public void testCreateMockMe() throws Exception { final MockMe task = context.mock(MockMe.class); final MockMe value = context.mock(MockMe.class); context.checking(new Expectations() {{ one(task).createMockMe();will(returnValue(value)); }}); assertEquals(value, task.createMockMe()); } public void testCreateString() throws Exception { final MockMe task = context.mock(MockMe.class); context.checking(new Expectations() {{ one(task).createString();will(returnValue(null)); }}); assertEquals(null, task.createString()); } public void testCreateList() throws Exception { final MockMe task = context.mock(MockMe.class); context.checking(new Expectations() {{ one(task).createList();will(returnValue(null)); }}); assertEquals(null, task.createList()); } }