KickJava   Java API By Example, From Geeks To Geeks.

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

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