Package org.jmock.core

Examples of org.jmock.core.DynamicMock


    public Object newDummy(Class dummyType) {
        return newDummy(dummyType, "dummy" + Formatting.classShortName(dummyType));
    }
   
    public Object newDummy( final Class type, final String name ) {
        DynamicMock mock = newCoreMock(type, name);
        InvocationMocker mocker = new InvocationMocker();
       
        mocker.addMatcher(new StatelessInvocationMatcher() {
            public boolean matches( Invocation invocation ) {
                return invocation.invokedMethod.getDeclaringClass() == type;
            }

            public StringBuffer describeTo( StringBuffer buf ) {
                return buf.append("any invokedMethod declared in " + type);
            }
        });
        mocker.setStub(new CustomStub("dummy invokedMethod") {
            public Object invoke( Invocation invocation ) throws Throwable {
                throw new NotImplementedException(invocation.invokedMethod.getName() + " called on " + name);
            }
        });
       
        mock.addInvokable(mocker);

        return mock.proxy();
    }
View Full Code Here

TOP

Related Classes of org.jmock.core.DynamicMock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.