### Question:
CglibProxyFactory extends ProxyFactory { @Override @SuppressWarnings("unchecked") public <T> T createProxy(T obj, final InvocationHandler handler) { Class<?> c = obj.getClass(); net.sf.cglib.proxy.InvocationHandler cglibHandler = new net.sf.cglib.proxy.InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return handler.invoke(proxy, method, args); } }; Class<?> proxyClass = createProxyClass(c); Factory proxy = (Factory) newInstance(c, proxyClass); proxy.setCallbacks(new Callback[] { cglibHandler, NoOp.INSTANCE }); return (T) proxy; }  ObjectCreator getObjectCreator(); void setUseObjenesis(boolean useObjenesis); @Override @SuppressWarnings("unchecked") T createProxy(T obj, final InvocationHandler handler);  }### Answer:
@Test public void testObject() { createProxy(new Object()).equals(null); assertEquals("equals = false", buff.toString()); }
@Test public void testProxyOnProxy() { final Object p = createProxy(new Object()); new AssertThrows() { public void test() { createProxy(p); }}; }
@Test public void testJavaUtilRandom() { createProxy(new Random()).nextInt(1); assertEquals("nextInt = 0", buff.toString()); }
@Test public void testStaticInnerClass() { createProxy(new StaticInnerClass()).toString(); assertEquals("toString = StaticInnerClass", buff.toString()); }
@Test public void testPrivateInnerClass() { createProxy(new PrivateInnerClass()).toString(); assertEquals("toString = PrivateInnerClass", buff.toString()); }
@Test public void testPrivateConstructor() { createProxy(PrivateConstructor.getInstance(10)).toString(); assertEquals("toString = PrivateConstructor", buff.toString()); }
@Test public void testPrivateConstructorUsingReflection() { new AssertThrows(new IllegalArgumentException( "Could not create a new proxy instance for the base class " + PrivateConstructor.class.getName() + " (probably because Objenesis is not used)")) { public void test() { createProxy(PrivateConstructor.getInstance(10), true).toString(); }}; }
@Test public void testAnonymousClass() { createProxy(new Object() { public String toString() { return "Anonymous"; }}).toString(); assertEquals("toString = Anonymous", buff.toString()); }
@Test public void testFinalClass() { new AssertThrows(new IllegalArgumentException( "Can not create a proxy for the class " + "org.junit.contrib.assertthrows.proxy.CglibProxyFactoryTest$FinalClass")) { public void test() { createProxy(new FinalClass()); }}; }
@Test public void testClassWithBridgeMethod() throws Exception { createProxy(new ClassWithBridgeMethod()).clone(); assertEquals("clone = ClassWithBridgeMethod", buff.toString()); callCloneMethods(0, new ClassWithBridgeMethod()); callCloneMethods(1, createProxy(new ClassWithBridgeMethod())); }