1 3 package org.jmock.core; 4 5 import java.lang.reflect.InvocationHandler ; 6 import java.lang.reflect.Method ; 7 import java.lang.reflect.Proxy ; 8 9 10 public class CoreMock 11 extends AbstractDynamicMock 12 implements InvocationHandler 13 { 14 private Object proxy; 15 16 public CoreMock( Class mockedType, String name ) { 17 this(mockedType, name, new LIFOInvocationDispatcher()); 18 } 19 20 public CoreMock( Class mockedType, 21 String name, 22 InvocationDispatcher invocationDispatcher ) 23 { 24 super(mockedType, name, invocationDispatcher); 25 this.proxy = Proxy.newProxyInstance(mockedType.getClassLoader(), 26 new Class []{mockedType}, 27 this); 28 } 29 30 public Object proxy() { 31 return this.proxy; 32 } 33 34 public Object invoke( Object invokedProxy, Method method, Object [] args ) 35 throws Throwable 36 { 37 Invocation invocation = new Invocation(invokedProxy, method, args); 38 return mockInvocation(invocation); 39 } 40 } 41 | Popular Tags |