Code example for ProxyFactory

Methods: getProxy, addAdvisor, setProxyTargetClass

0
	private void testAdvice(Advisor advisor, LogUserAdvice logAdvice, TestService target, String message, 
			boolean proxyTargetClass) throws Exception { 
 
		logAdvice.reset(); 
 
		ProxyFactory factory = new ProxyFactory(target); 
		factory.setProxyTargetClass(proxyTargetClass); 
		factory.addAdvisor(advisor); 
		TestService bean = (TestService) factory.getProxy(); 
 
		assertEquals(0, logAdvice.getCountThrows()); 
		try { 
			bean.sayHello(); 
			fail("Expected exception"); 
		} 
		catch (TestException ex) { 
			assertEquals(message, ex.getMessage()); 
		} 
		assertEquals(1, logAdvice.getCountThrows()); 
	}