Function: JDK 代理单测 @author crossoverJie Date: 23/12/2017 22:40 @since JDK 1.8
| 15 | * @since JDK 1.8 |
| 16 | */ |
| 17 | public class JDKProxyTest { |
| 18 | |
| 19 | @Test |
| 20 | public void test(){ |
| 21 | CustomizeHandle handle = new CustomizeHandle(ISubjectImpl.class) ; |
| 22 | ISubject subject = (ISubject) Proxy.newProxyInstance(JDKProxyTest.class.getClassLoader(), new Class[]{ISubject.class}, handle); |
| 23 | subject.execute() ; |
| 24 | } |
| 25 | |
| 26 | @Test |
| 27 | public void clazzTest(){ |
| 28 | // byte[] proxyClassFile = ProxyGenerator.generateProxyClass( |
| 29 | // "$Proxy1", new Class[]{ISubject.class}, 1); |
| 30 | // try { |
| 31 | // FileOutputStream out = new FileOutputStream("/Users/chenjie/Documents/$Proxy1.class") ; |
| 32 | // out.write(proxyClassFile); |
| 33 | // out.close(); |
| 34 | // } catch (FileNotFoundException e) { |
| 35 | // e.printStackTrace(); |
| 36 | // } catch (IOException e) { |
| 37 | // e.printStackTrace(); |
| 38 | // } |
| 39 | } |
| 40 | } |
nothing calls this directly
no outgoing calls
no test coverage detected