KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > spring > aop > AopProxy_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.aop.framework.ProxyFactory;
7
8 import junit.framework.TestCase;
9
10 /**
11  * @author Jonas Bonér
12  */

13 public class AopProxy_Test extends TestCase {
14   public AopProxy_Test(String JavaDoc name) {
15     super(name);
16   }
17   
18   public static void testBeforeAdvice() {
19     MessageWriter target = new MessageWriter();
20     ProxyFactory pf = new ProxyFactory();
21     pf.addAdvice(new SimpleBeforeAdvice());
22     pf.setTarget(target);
23     
24     MessageWriter proxy = (MessageWriter) pf.getProxy();
25     assertNotNull(proxy);
26     
27     String JavaDoc msg = proxy.writeMessage();
28     assertNotNull(msg);
29     assertEquals("World", msg);
30   }
31
32   public static void main(String JavaDoc[] args) {
33     junit.textui.TestRunner.run(suite());
34   }
35
36   public static junit.framework.Test suite() {
37     return new junit.framework.TestSuite(AopProxy_Test.class);
38   }
39 }
40
Popular Tags