1 4 package com.tctest.spring.integrationtests.tests; 5 6 import com.tctest.spring.bean.FooService; 7 import com.tctest.spring.integrationtests.framework.AbstractTwoServerDeploymentTest; 8 import com.tctest.spring.integrationtests.framework.DeploymentBuilder; 9 10 import junit.extensions.TestSetup; 11 import junit.framework.Test; 12 13 18 19 public class ParentChildBeanTest extends AbstractTwoServerDeploymentTest { 20 21 private static final String REMOTE_SERVICE_NAME = "Foo"; 22 private static final String REMOTE_SERVICE_NAME2 = "Foo2"; 23 private static final String BEAN_DEFINITION_FILE_FOR_TEST = "classpath:/com/tctest/spring/beanfactory-parent-child.xml"; 24 private static final String CONFIG_FILE_FOR_TEST = "/tc-config-files/parent-child-tc-config.xml"; 25 26 private static FooService foo1a; 27 private static FooService foo2a; 28 private static FooService foo1b; 29 private static FooService foo2b; 30 31 public void testParentChildBeanDefinitionWithConcreteParent() throws Exception { 32 assertEquals("rawValue-0", foo1a.serviceMethod()); 33 assertEquals("rawValue-1", foo2a.serviceMethod()); 34 } 35 36 public void testParentChildBeanDefinitionWithConcreteChild() throws Exception { 37 assertEquals("another-raw-0", foo1b.serviceMethod()); 38 assertEquals("another-raw-1", foo2b.serviceMethod()); 39 } 40 41 private static class ParentChildBeanTestSetup extends TwoSvrSetup { 42 43 private ParentChildBeanTestSetup() { 44 super(ParentChildBeanTest.class, CONFIG_FILE_FOR_TEST, "test-parent-child"); 45 } 46 47 protected void setUp() throws Exception { 48 super.setUp(); 49 foo1a = (FooService) server1.getProxy(FooService.class, REMOTE_SERVICE_NAME); 50 foo2a = (FooService) server2.getProxy(FooService.class, REMOTE_SERVICE_NAME); 51 foo1b = (FooService) server1.getProxy(FooService.class, REMOTE_SERVICE_NAME2); 52 foo2b = (FooService) server2.getProxy(FooService.class, REMOTE_SERVICE_NAME2); 53 } 54 55 protected void configureWar(DeploymentBuilder builder) { 56 builder.addBeanDefinitionFile(BEAN_DEFINITION_FILE_FOR_TEST); 57 builder.addRemoteService(REMOTE_SERVICE_NAME, "service1", FooService.class); 58 builder.addRemoteService(REMOTE_SERVICE_NAME2, "service2", FooService.class); 59 } 60 } 61 62 65 public static Test suite() { 66 TestSetup setup = new ParentChildBeanTestSetup(); 67 return setup; 68 } 69 70 } 71 | Popular Tags |