View Javadoc
1 /* Copyright (c) 2000-2003, jMock.org. See bundled LICENSE.txt */ 2 package org.jmock.dynamic; 3 4 import org.jmock.InvocationMatcher; 5 import org.jmock.matcher.CallOnceMatcher; 6 import org.jmock.stub.ReturnStub; 7 import org.jmock.stub.ThrowStub; 8 import org.jmock.stub.VoidStub; 9 10 public class InvokableFactory { 11 12 public Invokable createReturnStub(String methodName, InvocationMatcher arguments, Object result) { 13 return new InvocationMocker(methodName, arguments, new ReturnStub(result)); 14 } 15 16 public Invokable createReturnExpectation(String methodName, InvocationMatcher arguments, Object result) { 17 return callOnce(new InvocationMocker(methodName, arguments, new ReturnStub(result))); 18 } 19 20 public Invokable createThrowableStub(String methodName, InvocationMatcher arguments, Throwable throwable) { 21 return new InvocationMocker(methodName, arguments, new ThrowStub(throwable)); 22 } 23 24 public Invokable createThrowableExpectation(String methodName, InvocationMatcher arguments, Throwable throwable) { 25 return callOnce(new InvocationMocker(methodName, arguments, new ThrowStub(throwable))); 26 } 27 28 public Invokable createVoidStub(String methodName, InvocationMatcher arguments) { 29 return new InvocationMocker(methodName, arguments, new VoidStub()); 30 } 31 32 public Invokable createVoidExpectation(String methodName, InvocationMatcher arguments) { 33 return callOnce(new InvocationMocker(methodName, arguments, new VoidStub())); 34 } 35 36 private Invokable callOnce(InvocationMocker mocker) { 37 return mocker.addMatcher(new CallOnceMatcher()); 38 } 39 }

This page was automatically generated by Maven