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.integrationtests.tests;
05:
06: import com.tc.test.server.appserver.deployment.AbstractTwoServerDeploymentTest;
07: import com.tc.test.server.appserver.deployment.DeploymentBuilder;
08: import com.tctest.spring.bean.FooService;
09: import com.tctest.spring.integrationtests.SpringTwoServerTestSetup;
10:
11: import junit.framework.Test;
12:
13: /**
14: * Runs a couple of tests within the same JVM
15: *
16: * @author cer
17: */
18: public class ParentChildBeanTest extends
19: AbstractTwoServerDeploymentTest {
20: private static final String REMOTE_SERVICE_NAME = "Foo";
21: private static final String REMOTE_SERVICE_NAME2 = "Foo2";
22: private static final String BEAN_DEFINITION_FILE_FOR_TEST = "classpath:/com/tctest/spring/beanfactory-parent-child.xml";
23: private static final String CONFIG_FILE_FOR_TEST = "/tc-config-files/parent-child-tc-config.xml";
24:
25: private FooService foo1a;
26: private FooService foo2a;
27: private FooService foo1b;
28: private FooService foo2b;
29:
30: protected void setUp() throws Exception {
31: super .setUp();
32:
33: foo1a = (FooService) server0.getProxy(FooService.class,
34: REMOTE_SERVICE_NAME);
35: foo2a = (FooService) server1.getProxy(FooService.class,
36: REMOTE_SERVICE_NAME);
37: foo1b = (FooService) server0.getProxy(FooService.class,
38: REMOTE_SERVICE_NAME2);
39: foo2b = (FooService) server1.getProxy(FooService.class,
40: REMOTE_SERVICE_NAME2);
41: }
42:
43: public void testParentChildBeanDefinitionWithConcreteParent()
44: throws Exception {
45: assertEquals("rawValue-0", foo1a.serviceMethod());
46: assertEquals("rawValue-1", foo2a.serviceMethod());
47: }
48:
49: public void testParentChildBeanDefinitionWithConcreteChild()
50: throws Exception {
51: assertEquals("another-raw-0", foo1b.serviceMethod());
52: assertEquals("another-raw-1", foo2b.serviceMethod());
53: }
54:
55: private static class ParentChildBeanTestSetup extends
56: SpringTwoServerTestSetup {
57:
58: private ParentChildBeanTestSetup() {
59: super (ParentChildBeanTest.class, CONFIG_FILE_FOR_TEST,
60: "test-parent-child");
61: }
62:
63: protected void configureWar(DeploymentBuilder builder) {
64: builder
65: .addBeanDefinitionFile(BEAN_DEFINITION_FILE_FOR_TEST);
66: builder.addRemoteService(REMOTE_SERVICE_NAME, "service1",
67: FooService.class);
68: builder.addRemoteService(REMOTE_SERVICE_NAME2, "service2",
69: FooService.class);
70: }
71: }
72:
73: public static Test suite() {
74: return new ParentChildBeanTestSetup();
75: }
76:
77: }
|