KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > spring > ParentChildBean_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.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     disableAllUntil("2008-01-01");
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           "com/tctest/spring/beanfactory-parent-child.xml");
41
42       FooService singleton1 = (FooService) ctx1.getBean("service");
43
44       assertDistributed(ctx1, "service", singleton1);
45       assertEquals("rawValue", singleton1.serviceMethod());
46
47       ctx1.close();
48     }
49
50     public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) {
51
52       config.addIncludePattern("com.tctest.spring.bean.SimpleListener", true, true, false);
53       config.addIncludePattern("com.tctest.spring.bean.FooServiceImpl", true, true, false);
54
55       {
56         DSOSpringConfigHelper springConfig = new StandardDSOSpringConfigHelper();
57         springConfig.addApplicationNamePattern(SpringTestConstants.APPLICATION_NAME); // app name used by testing framework
58
springConfig.addConfigPattern("*/beanfactory-parent-child.xml");
59         springConfig.addBean("service");
60
61         config.addDSOSpringConfig(springConfig);
62       }
63       
64     }
65
66   }
67 }
68
Popular Tags