1 3 package atest.jmock; 4 5 import org.jmock.MockObjectTestCase; 6 import org.objectweb.asm.ClassWriter; 7 import org.objectweb.asm.Constants; 8 9 10 public class ClassLoaderAcceptanceTest extends MockObjectTestCase 11 { 12 13 static class EmptyInterfaceCreator extends ClassLoader 14 { 15 protected Class findClass( String name ) { 16 ClassWriter writer = new ClassWriter(true); 17 writer.visit(Constants.ACC_PUBLIC | Constants.ACC_INTERFACE, 18 name.replace('.', '/'), 19 "java/lang/Object", 20 null, 21 null ); 22 23 byte[] b = writer.toByteArray(); 24 25 return defineClass(name, b, 0, b.length); 26 } 27 } 28 29 public void testMockingTypeFromOtherClassLoader() throws ClassNotFoundException { 30 ClassLoader interfaceClassLoader = new EmptyInterfaceCreator(); 31 Class interfaceClass = interfaceClassLoader.loadClass("$UniqueTypeName$"); 32 33 mock(interfaceClass); } 35 } 36 | Popular Tags |