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.FooService;
15:
16: /**
17: * Verifies that BeanNameAware works when bean name is stored in a distributed field
18: */
19: public class ParentChildBean_Test extends SimpleTransparentTestBase {
20:
21: public ParentChildBean_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: "com/tctest/spring/beanfactory-parent-child.xml");
43:
44: FooService singleton1 = (FooService) ctx1
45: .getBean("service");
46:
47: assertDistributed(ctx1, "service", singleton1);
48: assertEquals("rawValue", singleton1.serviceMethod());
49:
50: ctx1.close();
51: }
52:
53: public static void visitL1DSOConfig(ConfigVisitor visitor,
54: DSOClientConfigHelper config) {
55:
56: config.addIncludePattern(
57: "com.tctest.spring.bean.SimpleListener", true,
58: true, false);
59: config.addIncludePattern(
60: "com.tctest.spring.bean.FooServiceImpl", true,
61: true, false);
62:
63: {
64: DSOSpringConfigHelper springConfig = new StandardDSOSpringConfigHelper();
65: springConfig
66: .addApplicationNamePattern(SpringTestConstants.APPLICATION_NAME); // app name used by testing framework
67: springConfig
68: .addConfigPattern("*/beanfactory-parent-child.xml");
69: springConfig.addBean("service");
70:
71: config.addDSOSpringConfig(springConfig);
72: }
73:
74: }
75:
76: }
77: }
|