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.SimpleInitializingSingleton;
15:
16: /**
17: * Test for <code>InitializingBean</code>.
18: *
19: * @see org.springframework.beans.factory.InitializingBean
20: */
21: public class InitializingBean2_Test extends SimpleTransparentTestBase {
22:
23: public InitializingBean2_Test() {
24: //
25: }
26:
27: protected int getNodeCount() {
28: return 1;
29: }
30:
31: protected Class getApplicationClass() {
32: return InitializingBeanApp.class;
33: }
34:
35: public static class InitializingBeanApp extends
36: AbstractSimpleTransparentApp {
37:
38: public InitializingBeanApp(String appId, ApplicationConfig cfg,
39: ListenerProvider listenerProvider) {
40: super (appId, cfg, listenerProvider);
41: }
42:
43: protected void doIt() {
44: ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
45: "com/tctest/spring/beanfactory-init2.xml");
46:
47: SimpleInitializingSingleton singleton = (SimpleInitializingSingleton) ctx
48: .getBean("distributedInitBean");
49:
50: assertDistributed(ctx, "distributedInitBean", singleton);
51:
52: assertSame(singleton,
53: SimpleInitializingSingleton.afterPropertiesSetThis);
54:
55: assertNotNull(singleton.getName());
56: }
57:
58: public static void visitL1DSOConfig(ConfigVisitor visitor,
59: DSOClientConfigHelper config) {
60: DSOSpringConfigHelper springConfig = new StandardDSOSpringConfigHelper();
61: springConfig
62: .addApplicationNamePattern(SpringTestConstants.APPLICATION_NAME); // app name used by testing framework
63: springConfig.addConfigPattern("*/beanfactory-init2.xml");
64: springConfig.addBean("recorder");
65: springConfig.addBean("distributedInitBean");
66: config.addDSOSpringConfig(springConfig);
67:
68: config
69: .addIncludePattern(
70: "com.tctest.spring.bean.SimpleInitializingSingleton",
71: true, true, false);
72:
73: }
74:
75: }
76:
77: }
|