KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > spring > SingletonWithInterceptor_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;
5
6 import org.springframework.context.support.ClassPathXmlApplicationContext;
7
8 import com.tc.object.config.ConfigVisitor;
9 import com.tc.object.config.DSOClientConfigHelper;
10 import com.tc.object.config.DSOSpringConfigHelper;
11 import com.tc.object.config.StandardDSOSpringConfigHelper;
12 import com.tc.simulator.app.ApplicationConfig;
13 import com.tc.simulator.listener.ListenerProvider;
14 import com.tctest.TransparentTestBase;
15 import com.tctest.runner.AbstractTransparentApp;
16 import com.tctest.spring.bean.FooService;
17
18 /**
19  * Spring singleton test
20  */

21 public class SingletonWithInterceptor_Test extends TransparentTestBase {
22   private static final int LOOP_ITERATIONS = 1;
23   private static final int EXECUTION_COUNT = 1;
24   private static final int NODE_COUNT = 2;
25
26   public SingletonWithInterceptor_Test() {
27     disableAllUntil("2008-01-01");
28   }
29
30   protected void setUp() throws Exception JavaDoc {
31     super.setUp();
32     getTransparentAppConfig().setClientCount(NODE_COUNT).setApplicationInstancePerClientCount(EXECUTION_COUNT)
33         .setIntensity(LOOP_ITERATIONS);
34     initializeTestRunner();
35   }
36
37   protected Class JavaDoc getApplicationClass() {
38     return SingletonApp.class;
39   }
40
41   public static class SingletonApp extends AbstractTransparentApp {
42     public SingletonApp(String JavaDoc appId, ApplicationConfig cfg, ListenerProvider listenerProvider) {
43       super(appId, cfg, listenerProvider);
44     }
45
46     public void run() {
47       Thread JavaDoc t = Thread.currentThread();
48       ClassLoader JavaDoc cl = t.getContextClassLoader();
49
50       try {
51         t.setContextClassLoader(getClass().getClassLoader());
52
53         ClassPathXmlApplicationContext ctx1 = new ClassPathXmlApplicationContext(
54                                                                                  "com/tctest/spring/beanfactory-interceptor.xml");
55
56         FooService singleton1 = (FooService) ctx1.getBean("service");
57
58         assertEquals("interceptorInvoked", singleton1.serviceMethod());
59
60       } catch (Throwable JavaDoc e) {
61         notifyError(e);
62
63       } finally {
64         t.setContextClassLoader(cl);
65
66       }
67     }
68
69     public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) {
70       DSOSpringConfigHelper springConfig = new StandardDSOSpringConfigHelper();
71       springConfig.addApplicationNamePattern(SpringTestConstants.APPLICATION_NAME); // app name used by testing
72
// framework
73
springConfig.addConfigPattern("*/beanfactory-interceptor.xml");
74       springConfig.addBean("service");
75       config.addDSOSpringConfig(springConfig);
76
77       // config.addIncludePattern("com.tctest.spring.bean.SimpleListener", true, true);
78
// config.addIncludePattern("com.tctest.spring.bean.FooServiceImpl", true, true);
79

80       // config.addIsolatedClass("org.springframework.");
81
// config.addIsolatedClass("com.tctest.spring.");
82
// config.addIsolatedClass("com.tcspring.");
83
}
84
85   }
86 }
87
Popular Tags