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.BeanDefinitionStoreException;
07: import org.springframework.beans.factory.CannotLoadBeanClassException;
08: import org.springframework.context.support.ClassPathXmlApplicationContext;
09:
10: import com.tc.object.config.ConfigVisitor;
11: import com.tc.object.config.DSOClientConfigHelper;
12: import com.tc.object.config.DSOSpringConfigHelper;
13: import com.tc.object.config.StandardDSOSpringConfigHelper;
14: import com.tc.simulator.app.ApplicationConfig;
15: import com.tc.simulator.listener.ListenerProvider;
16: import com.tctest.TransparentTestBase;
17: import com.tctest.runner.AbstractTransparentApp;
18:
19: /**
20: * Tests for Spring error reporting
21: */
22: public class ErrorReporting_Test extends TransparentTestBase {
23: private static final int LOOP_ITERATIONS = 1;
24: private static final int EXECUTION_COUNT = 1;
25: private static final int NODE_COUNT = 1;
26:
27: public ErrorReporting_Test() {
28: // disableAllUntil("2008-01-01");
29: }
30:
31: protected void setUp() throws Exception {
32: super .setUp();
33: getTransparentAppConfig().setClientCount(NODE_COUNT)
34: .setApplicationInstancePerClientCount(EXECUTION_COUNT)
35: .setIntensity(LOOP_ITERATIONS);
36: initializeTestRunner();
37: }
38:
39: protected Class getApplicationClass() {
40: return ErrorReportingApp.class;
41: }
42:
43: public static class ErrorReportingApp extends
44: AbstractTransparentApp {
45:
46: public ErrorReportingApp(String appId, ApplicationConfig cfg,
47: ListenerProvider listenerProvider) {
48: super (appId, cfg, listenerProvider);
49: }
50:
51: public void run() {
52: testErrorReporting();
53: }
54:
55: private void testErrorReporting() {
56: try {
57: ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
58: "com/tctest/spring/ErrorReporting.xml");
59: ctx.getBean("bean1");
60: fail("Epected to see Spring exception");
61: } catch (CannotLoadBeanClassException e) {
62: // expected
63: } catch (BeanDefinitionStoreException e) {
64: // ignore
65: }
66: }
67:
68: public static void visitL1DSOConfig(ConfigVisitor visitor,
69: DSOClientConfigHelper config) {
70: DSOSpringConfigHelper springConfig = new StandardDSOSpringConfigHelper();
71: springConfig
72: .addApplicationNamePattern(SpringTestConstants.APPLICATION_NAME); // app name used by testing framework
73: springConfig.addConfigPattern("*/ErrorReporting.xml");
74: springConfig.addBean("bean1");
75: springConfig.addBean("bean2");
76: config.addDSOSpringConfig(springConfig);
77: }
78:
79: }
80:
81: }
|