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;
05:
06: import org.springframework.context.support.ClassPathXmlApplicationContext;
07:
08: import com.tc.object.config.ConfigVisitor;
09: 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: //
23: }
24:
25: protected int getNodeCount() {
26: return 1;
27: }
28:
29: protected Class getApplicationClass() {
30: return SingletonApp.class;
31: }
32:
33: public static class SingletonApp extends
34: AbstractSimpleTransparentApp {
35: public SingletonApp(String appId, ApplicationConfig cfg,
36: ListenerProvider listenerProvider) {
37: super (appId, cfg, listenerProvider);
38: }
39:
40: protected void doIt() {
41: ClassPathXmlApplicationContext ctx1 = new ClassPathXmlApplicationContext(
42:
43: "com/tctest/spring/beanfactory-bean-name-aware.xml");
44:
45: BeanNameAwareBean singleton1 = (BeanNameAwareBean) ctx1
46: .getBean("aware");
47:
48: assertDistributed(ctx1, "aware", singleton1);
49:
50: assertEquals("aware", singleton1.getName());
51:
52: ctx1.close();
53: }
54:
55: public static void visitL1DSOConfig(ConfigVisitor visitor,
56: DSOClientConfigHelper config) {
57: DSOSpringConfigHelper springConfig = new StandardDSOSpringConfigHelper();
58: springConfig
59: .addApplicationNamePattern(SpringTestConstants.APPLICATION_NAME); // app name used by testing framework
60: springConfig
61: .addConfigPattern("*/beanfactory-bean-name-aware.xml");
62: springConfig.addBean("aware");
63:
64: config.addDSOSpringConfig(springConfig);
65:
66: config.addIncludePattern(
67: "com.tctest.spring.bean.SimpleListener", true,
68: true, false);
69: config.addIncludePattern(
70: "com.tctest.spring.bean.BeanNameAwareBean", true,
71: true, false);
72:
73: }
74:
75: }
76: }
|