1 /* Copyright (c) 2000-2003, jMock.org. See bundled LICENSE.txt */ 2 package org.jmock.dynamic; 3 4 import junit.framework.TestCase; 5 import org.jmock.InvocationMatcher; 6 import org.jmock.Stub; 7 import org.jmock.expectation.ExpectationValue; 8 import org.jmock.expectation.Verifier; 9 import org.jmock.stub.ReturnStub; 10 import org.jmock.stub.ThrowStub; 11 import org.jmock.stub.VoidStub; 12 13 public class InvocationMockerBuilderTest extends TestCase { 14 public class MockInvocationMocker extends InvocationMocker { 15 public MockInvocationMocker() { 16 super(new InvocationMatcher[0], new VoidStub()); 17 } 18 19 public ExpectationValue setStubType = new ExpectationValue("setStub type"); 20 21 public void setStub(Stub stub) { 22 setStubType.setActual(stub.getClass()); 23 } 24 25 public void verifyExpectations() { 26 Verifier.verifyObject(this); 27 } 28 } 29 30 31 private MockInvocationMocker mocker = new MockInvocationMocker(); 32 private InvocationMockerBuilder builder = new InvocationMockerBuilder(mocker); 33 34 public void testIsVoidSetsVoidStub() { 35 mocker.setStubType.setExpected(VoidStub.class); 36 37 assertNotNull("Should be expectation builder", builder.isVoid()); 38 39 mocker.verifyExpectations(); 40 } 41 42 public void testReturnsSetsReturnStub() { 43 mocker.setStubType.setExpected(ReturnStub.class); 44 45 assertNotNull("Should be expectation builder", builder.returns("return value")); 46 47 mocker.verifyExpectations(); 48 } 49 50 public void testThrowsSetsThrowStub() { 51 mocker.setStubType.setExpected(ThrowStub.class); 52 53 assertNotNull("Should be expectation builder", builder.willThrow(new Exception("thrown value"))); 54 55 mocker.verifyExpectations(); 56 } 57 }

This page was automatically generated by Maven