001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tctest.spring.integrationtests.tests;
005:
006: import com.tc.test.server.appserver.deployment.AbstractTwoServerDeploymentTest;
007: import com.tc.test.server.appserver.deployment.DeploymentBuilder;
008: import com.tctest.spring.bean.IMasterBean;
009: import com.tctest.spring.bean.ISingleton;
010: import com.tctest.spring.integrationtests.SpringTwoServerTestSetup;
011:
012: import junit.framework.Test;
013:
014: /**
015: * Test application context loaded from multiple bean configs.
016: *
017: * @author Eugene Kuleshov
018: */
019: public class MultifileContextTest extends
020: AbstractTwoServerDeploymentTest {
021:
022: private static final String REMOTE_SERVICE_NAME = "MasterService";
023:
024: public void testBeanFromMultipleContexts() throws Exception {
025: // server1.start();
026: // server2.start();
027:
028: // try {
029:
030: IMasterBean masterBean1 = (IMasterBean) server0.getProxy(
031: IMasterBean.class, REMOTE_SERVICE_NAME);
032: IMasterBean masterBean2 = (IMasterBean) server1.getProxy(
033: IMasterBean.class, REMOTE_SERVICE_NAME);
034:
035: ISingleton singleton1 = masterBean1.getSingleton();
036: ISingleton singleton2 = masterBean2.getSingleton();
037:
038: assertNotNull(singleton1);
039: assertNotNull(singleton2);
040:
041: // } finally {
042: // server1.stop();
043: // server2.stop();
044: // }
045: }
046:
047: private static class MultipleBeanDefsTestSetup extends
048: SpringTwoServerTestSetup {
049:
050: private MultipleBeanDefsTestSetup() {
051: super (MultifileContextTest.class,
052: "/tc-config-files/multifile-context-tc-config.xml",
053: "test-multifile-context");
054: }
055:
056: // protected void setUp() throws Exception {
057: // super.setUp();
058: //
059: // String tcConfigFile = "/tc-config-files/multifile-context-tc-config.xml";
060: // String context = "test-multifile-context";
061: //
062: // DeploymentBuilder builder = super.makeDeploymentBuilder(context+".war");
063: //
064: // builder.addDirectoryOrJARContainingClass(MultifileContextTest.class);
065: // builder.addDirectoryContainingResource(tcConfigFile);
066: //
067: // builder.addBeanDefinitionFile("/WEB-INF/multifile-context-factory*.xml");
068: //
069: // builder.addResource("/com/tctest/spring", "multifile-context-factory1.xml", "/WEB-INF/");
070: // builder.addResource("/com/tctest/spring", "multifile-context-factory2.xml", "/WEB-INF/");
071: //
072: // builder.addRemoteService(REMOTE_SERVICE_NAME, "distributedMasterBean", IMasterBean.class);
073: //
074: // Deployment warPath = builder.makeDeployment();
075: //
076: // server1 = sm.makeWebApplicationServer(tcConfigFile);
077: // server1.addWarDeployment(warPath, context);
078: //
079: // server2 = sm.makeWebApplicationServer(tcConfigFile);
080: // server2.addWarDeployment(warPath, context);
081: // }
082:
083: protected void configureWar(DeploymentBuilder builder) {
084: builder
085: .addBeanDefinitionFile("/WEB-INF/multifile-context-factory*.xml");
086:
087: builder.addResource("/com/tctest/spring",
088: "multifile-context-factory1.xml", "/WEB-INF/");
089: builder.addResource("/com/tctest/spring",
090: "multifile-context-factory2.xml", "/WEB-INF/");
091:
092: builder.addRemoteService(REMOTE_SERVICE_NAME,
093: "distributedMasterBean", IMasterBean.class);
094: }
095:
096: }
097:
098: public static Test suite() {
099: return new MultipleBeanDefsTestSetup();
100: }
101:
102: }
|