01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tctest.spring.aop;
05:
06: import org.springframework.aop.framework.ProxyFactory;
07:
08: import junit.framework.TestCase;
09:
10: /**
11: * @author Jonas Bonér
12: */
13: public class AopProxy_Test extends TestCase {
14: public AopProxy_Test(String 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 msg = proxy.writeMessage();
28: assertNotNull(msg);
29: assertEquals("World", msg);
30: }
31:
32: public static void main(String[] 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: }
|