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.beans.factory.BeanCreationException;
07: import org.springframework.context.support.ClassPathXmlApplicationContext;
08:
09: import com.tc.object.config.ConfigVisitor;
10: import com.tc.object.config.DSOClientConfigHelper;
11: import com.tc.object.config.DSOSpringConfigHelper;
12: import com.tc.object.config.StandardDSOSpringConfigHelper;
13: import com.tc.simulator.app.ApplicationConfig;
14: import com.tc.simulator.listener.ListenerProvider;
15:
16: /**
17: * Spring singleton test
18: */
19: public class InvalidBeanDefinition_Test extends
20: SimpleTransparentTestBase {
21:
22: public InvalidBeanDefinition_Test() {
23: //
24: }
25:
26: protected int getNodeCount() {
27: return 1;
28: }
29:
30: protected Class getApplicationClass() {
31: return SingletonApp.class;
32: }
33:
34: public static class SingletonApp extends
35: AbstractSimpleTransparentApp {
36: public SingletonApp(String appId, ApplicationConfig cfg,
37: ListenerProvider listenerProvider) {
38: super (appId, cfg, listenerProvider);
39: }
40:
41: protected void doIt() {
42:
43: try {
44: ClassPathXmlApplicationContext ctx1 = new ClassPathXmlApplicationContext(
45: "com/tctest/spring/beanfactory-interceptor-with-error.xml");
46: assertDistributed(ctx1, "service", ctx1
47: .getBean("service"));
48: fail("expected BeanCreationException");
49: } catch (BeanCreationException e) {
50: // expected
51: }
52: }
53:
54: public static void visitL1DSOConfig(ConfigVisitor visitor,
55: DSOClientConfigHelper config) {
56: DSOSpringConfigHelper springConfig = new StandardDSOSpringConfigHelper();
57: springConfig
58: .addApplicationNamePattern(SpringTestConstants.APPLICATION_NAME); // app name used by testing framework
59: springConfig
60: .addConfigPattern("*/beanfactory-interceptor-with-error.xml");
61: springConfig.addBean("service");
62:
63: config.addDSOSpringConfig(springConfig);
64:
65: config.addIncludePattern(
66: "com.tctest.spring.bean.SimpleListener", true,
67: true, false);
68: config.addIncludePattern(
69: "com.tctest.spring.bean.BarServiceImpl", true,
70: true, false);
71: config.addIncludePattern(
72: "com.tctest.spring.bean.FooServiceImpl", true,
73: true, false);
74:
75: }
76:
77: }
78: }
|