KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > spring > BeanNameAware_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.spring.bean.BeanNameAwareBean;
15
16 /**
17  * Spring singleton test
18  */

19 public class BeanNameAware_Test extends SimpleTransparentTestBase {
20
21   public BeanNameAware_Test() {
22     disableAllUntil("2008-01-01"); //covered by system test
23
}
24
25   protected int getNodeCount() {
26     return 1;
27   }
28
29   protected Class JavaDoc getApplicationClass() {
30     return SingletonApp.class;
31   }
32
33   public static class SingletonApp extends AbstractSimpleTransparentApp {
34     public SingletonApp(String JavaDoc appId, ApplicationConfig cfg, ListenerProvider listenerProvider) {
35       super(appId, cfg, listenerProvider);
36     }
37
38     protected void doIt() {
39       ClassPathXmlApplicationContext ctx1 = new ClassPathXmlApplicationContext(
40
41       "com/tctest/spring/beanfactory-bean-name-aware.xml");
42
43       BeanNameAwareBean singleton1 = (BeanNameAwareBean) ctx1.getBean("aware");
44
45       assertDistributed(ctx1, "aware", singleton1);
46
47       assertEquals("aware", singleton1.getName());
48
49       ctx1.close();
50     }
51
52     public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) {
53       DSOSpringConfigHelper springConfig = new StandardDSOSpringConfigHelper();
54       springConfig.addApplicationNamePattern(SpringTestConstants.APPLICATION_NAME); // app name used by testing framework
55
springConfig.addConfigPattern("*/beanfactory-bean-name-aware.xml");
56       springConfig.addBean("aware");
57
58       config.addDSOSpringConfig(springConfig);
59
60       config.addIncludePattern("com.tctest.spring.bean.SimpleListener", true, true, false);
61       config.addIncludePattern("com.tctest.spring.bean.BeanNameAwareBean", true, true, false);
62
63     }
64
65   }
66 }
67
Popular Tags