1 4 package com.tctest.spring.aop; 5 6 import org.springframework.context.support.ClassPathXmlApplicationContext; 7 8 import com.tc.test.TCTestCase; 9 10 13 16 public class SubclassingProxyAopProxy_Test extends TCTestCase { 17 18 private static final String BEAN_CONFIG = "com/tctest/spring/beanfactory-fastproxy.xml"; 19 20 public SubclassingProxyAopProxy_Test(String name) { 21 super(name); 22 disableAllUntil("2008-09-18"); } 24 25 public static void testBeforeAdvice() { 26 Logger.log = ""; 27 ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(BEAN_CONFIG); 28 SubclassingProxyTarget proxy = (SubclassingProxyTarget) ctx.getBean("testBeforeAdviceSubclassing"); 29 assertNotNull(proxy); 30 proxy.doStuff("fuzzy"); 31 assertEquals("before args(fuzzy) this(" + proxy.getClass().getName() + ") doStuff ", Logger.log); 32 } 33 34 public static void testAfterReturningAdvice() { 35 Logger.log = ""; 36 ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(BEAN_CONFIG); 37 SubclassingProxyTarget proxy = (SubclassingProxyTarget) ctx.getBean("testAfterReturningAdviceSubclassing"); 38 assertNotNull(proxy); 39 String stuff = proxy.returnStuff("fuzzy"); 40 assertEquals("returnStuff after-returning(stuff) args(fuzzy) this(" + proxy.getClass().getName() + ") ", Logger.log); 41 } 42 43 public static void testAfterThrowingAdvice() { 44 Logger.log = ""; 45 ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(BEAN_CONFIG); 46 SubclassingProxyTarget proxy = (SubclassingProxyTarget) ctx.getBean("testAfterThrowingAdviceSubclassing"); 47 assertNotNull(proxy); 48 try { 49 proxy.throwStuff("fuzzy"); 50 } catch (ExpectedException e) { 51 e.printStackTrace(); 52 assertEquals("throwStuff after-throwing(expected) args(fuzzy) this(" + proxy.getClass().getName() + ") ", Logger.log); 53 return; 54 } 55 fail("should have exited with an exception"); 56 } 57 58 public static void testAroundAdvice() { 59 Logger.log = ""; 60 ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(BEAN_CONFIG); 61 SubclassingProxyTarget proxy = (SubclassingProxyTarget) ctx.getBean("testAroundAdviceSubclassing"); 62 assertNotNull(proxy); 63 proxy.doStuff("fuzzy"); 64 assertEquals("before-around args(fuzzy) this(" + proxy.getClass().getName() + ") doStuff after-around ", Logger.log); 65 } 66 67 68 public static void testAroundAdviceChain() { 69 Logger.log = ""; 70 ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(BEAN_CONFIG); 71 SubclassingProxyTarget proxy = (SubclassingProxyTarget) ctx.getBean("testAroundAdviceChainSubclassing"); 72 assertNotNull(proxy); 73 proxy.doStuff("fuzzy"); 74 assertEquals("before-around args(fuzzy) this(" + proxy.getClass().getName() + ") before-around args(fuzzy) this(" + proxy.getClass().getName() + ") doStuff after-around after-around ", Logger.log); 75 } 76 77 public static junit.framework.Test suite() { 79 return new junit.framework.TestSuite(SubclassingProxyAopProxy_Test.class); 80 } 81 82 } 83 84 | Popular Tags |