From: Rob H. <rob...@us...> - 2006-04-20 13:07:19
|
Update of /cvsroot/springframework/spring/tiger/test/org/springframework/aop/aspectj/annotation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4412/tiger/test/org/springframework/aop/aspectj/annotation Modified Files: AspectProxyFactoryTests.java Log Message: Added addAspect(Object) to AspectJProxyFactory Index: AspectProxyFactoryTests.java =================================================================== RCS file: /cvsroot/springframework/spring/tiger/test/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AspectProxyFactoryTests.java 19 Apr 2006 14:56:23 -0000 1.1 --- AspectProxyFactoryTests.java 20 Apr 2006 13:06:27 -0000 1.2 *************** *** 20,24 **** import org.springframework.aop.aspectj.autoproxy.MultiplyReturnValue; import org.springframework.aop.aspectj.autoproxy.PerThisAspect; - import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; import org.springframework.beans.ITestBean; import org.springframework.beans.TestBean; --- 20,23 ---- *************** *** 40,44 **** } ! public void testWithSimpleAspect() throws Exception { TestBean bean = new TestBean(); bean.setAge(2); --- 39,43 ---- } ! public void testWithSimpleAspect() throws Exception { TestBean bean = new TestBean(); bean.setAge(2); *************** *** 67,69 **** --- 66,102 ---- assertEquals(2, proxy1.getAge()); } + + public void testWithInstanceWithNonAspect() throws Exception { + new AssertThrows(IllegalArgumentException.class) { + public void test() throws Exception { + AspectJProxyFactory pf = new AspectJProxyFactory(); + pf.addAspect(new TestBean()); + } + }.runTest(); + } + + public void testWithInstance() throws Exception { + MultiplyReturnValue aspect = new MultiplyReturnValue(); + int multiple = 3; + aspect.setMultiple(multiple); + + TestBean target = new TestBean(); + target.setAge(24); + + AspectJProxyFactory proxyFactory = new AspectJProxyFactory(target); + proxyFactory.addAspect(aspect); + + ITestBean proxy = proxyFactory.getProxy(); + + assertEquals(target.getAge() * multiple, proxy.getAge()); + } + + public void testWithNonSingletonAspectInstance() throws Exception { + new AssertThrows(IllegalArgumentException.class) { + public void test() throws Exception { + AspectJProxyFactory pf = new AspectJProxyFactory(); + pf.addAspect(new PerThisAspect()); + } + }.runTest(); + } } |