KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > spring > aop > DelegatingProxyAopProxy_Test


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tctest.spring.aop;
5
6 import org.springframework.context.support.ClassPathXmlApplicationContext;
7
8 import com.tc.test.TCTestCase;
9
10
11 // FIXME test IntroductionInterceptor
12
// FIXME more complex tests - chained tests etc.
13

14 /**
15  * @author Jonas Bonér
16  */

17 public class DelegatingProxyAopProxy_Test extends TCTestCase {
18
19   private static final String JavaDoc BEAN_CONFIG = "com/tctest/spring/beanfactory-fastproxy.xml";
20
21   public DelegatingProxyAopProxy_Test(String JavaDoc name) {
22     super(name);
23     disableAllUntil("2008-09-18"); // XXX timebombed
24
}
25
26   public static void testBeforeAdvice() {
27     Logger.log = "";
28     ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(BEAN_CONFIG);
29     IDelegatingProxyTarget proxy = (IDelegatingProxyTarget) ctx.getBean("testBeforeAdviceDelegating");
30     assertNotNull(proxy);
31     proxy.doStuff("fuzzy");
32     assertEquals("before args(fuzzy) this(" + proxy.getClass().getName() + ") doStuff ", Logger.log);
33   }
34
35   public static void testAfterReturningAdvice() {
36     Logger.log = "";
37     ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(BEAN_CONFIG);
38     IDelegatingProxyTarget proxy = (IDelegatingProxyTarget) ctx.getBean("testAfterReturningAdviceDelegating");
39     assertNotNull(proxy);
40     String JavaDoc stuff = proxy.returnStuff("fuzzy");
41     assertEquals("returnStuff after-returning(stuff) args(fuzzy) this(" + proxy.getClass().getName() + ") ", Logger.log);
42   }
43
44   public static void testAfterThrowingAdvice() {
45     Logger.log = "";
46     ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(BEAN_CONFIG);
47     IDelegatingProxyTarget proxy = (IDelegatingProxyTarget) ctx.getBean("testAfterThrowingAdviceDelegating");
48     assertNotNull(proxy);
49     try {
50       proxy.throwStuff("fuzzy");
51     } catch (ExpectedException e) {
52       assertEquals("throwStuff after-throwing(expected) args(fuzzy) this(" + proxy.getClass().getName() + ") ",
53           Logger.log);
54       return;
55     }
56     fail("should have exited with an exception");
57   }
58
59   public static void testAroundAdvice() {
60     Logger.log = "";
61     ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(BEAN_CONFIG);
62     IDelegatingProxyTarget proxy = (IDelegatingProxyTarget) ctx.getBean("testAroundAdviceDelegating");
63     assertNotNull(proxy);
64     proxy.doStuff("fuzzy");
65     assertEquals("before-around args(fuzzy) this(" + proxy.getClass().getName() + ") doStuff after-around ", Logger.log);
66   }
67
68   public static void testAroundAdviceChain() {
69     Logger.log = "";
70     ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(BEAN_CONFIG);
71     IDelegatingProxyTarget proxy = (IDelegatingProxyTarget) ctx.getBean("testAroundAdviceChainDelegating");
72     assertNotNull(proxy);
73     proxy.doStuff("fuzzy");
74     assertEquals("before-around args(fuzzy) this(" + proxy.getClass().getName() + ") before-around args(fuzzy) this("
75         + proxy.getClass().getName() + ") doStuff after-around after-around ", Logger.log);
76   }
77
78
79   // XXX use test decorator to activate AW pipeline
80
public static junit.framework.Test suite() {
81     return new junit.framework.TestSuite(DelegatingProxyAopProxy_Test.class);
82   }
83 }
84
Popular Tags