1 4 5 package com.tctest.spring.integrationtests.tests; 6 7 import com.tctest.spring.bean.ISingleton; 8 import com.tctest.spring.integrationtests.framework.AbstractDeploymentTest; 9 import com.tctest.spring.integrationtests.framework.Deployment; 10 import com.tctest.spring.integrationtests.framework.Server; 11 12 13 public class StartServersStopDSOStartServersAgainTest extends AbstractDeploymentTest { 14 private static final String REMOTE_SERVICE_NAME = "Singleton"; 15 private static final String BEAN_DEFINITION_FILE_FOR_TEST = "classpath:/com/tctest/spring/beanfactory.xml"; 16 private static final String CONFIG_FILE_FOR_TEST = "/tc-config-files/singleton-tc-config.xml"; 17 18 19 public StartServersStopDSOStartServersAgainTest() { 20 disableAllUntil("2010-03-01"); 21 } 22 23 public void testStartServersStopDSOStartServersAgain() throws Exception { 24 25 Deployment warPath = makeDeploymentBuilder("foo.war") 26 .addBeanDefinitionFile(BEAN_DEFINITION_FILE_FOR_TEST) 27 .addRemoteService(REMOTE_SERVICE_NAME, "singleton", ISingleton.class) 28 .addDirectoryOrJARContainingClass(ISingleton.class) 29 .addDirectoryContainingResource(CONFIG_FILE_FOR_TEST) 30 .makeDeployment(); 31 32 Server server1 = makeWebApplicationServer(CONFIG_FILE_FOR_TEST).addWarDeployment(warPath, "test-singleton"); 33 Server server2 = makeWebApplicationServer(CONFIG_FILE_FOR_TEST).addWarDeployment(warPath, "test-singleton"); 34 server1.start(); 35 logger.info("*** Started server1"); 36 server2.start(); 37 logger.info("*** Started server2"); 38 39 ISingleton singleton1 = (ISingleton) server1.getProxy(ISingleton.class, REMOTE_SERVICE_NAME); 40 ISingleton singleton2 = (ISingleton) server2.getProxy(ISingleton.class, REMOTE_SERVICE_NAME); 41 42 assertCounterShared(singleton1, singleton2); 43 logger.info("*** Assertion1 passed"); 44 45 restartDSO(); 46 logger.info("*** DSO restarted"); 47 48 Server server3 = makeWebApplicationServer(CONFIG_FILE_FOR_TEST).addWarDeployment(warPath, "test-singleton"); 49 server3.start(); 50 logger.info("*** Started server3"); 51 52 Server server4 = makeWebApplicationServer(CONFIG_FILE_FOR_TEST).addWarDeployment(warPath, "test-singleton"); 53 server4.start(); 54 logger.info("*** Started server4"); 55 56 ISingleton singleton3 = (ISingleton) server3.getProxy(ISingleton.class, REMOTE_SERVICE_NAME); 57 ISingleton singleton4 = (ISingleton) server4.getProxy(ISingleton.class, REMOTE_SERVICE_NAME); 58 59 assertCounterShared(singleton3, singleton4); 60 61 logger.info("*** Test completed"); 62 } 63 64 private void assertCounterShared(ISingleton singleton1, ISingleton singleton2) { 65 assertEquals(singleton1.getCounter(), singleton2.getCounter()); 66 67 singleton1.incrementCounter(); 68 assertEquals(singleton1.getCounter(), singleton2.getCounter()); 69 70 singleton2.incrementCounter(); 71 assertEquals(singleton2.getCounter(), singleton1.getCounter()); 72 } 73 74 public boolean isWithPersistentStore() { 75 return true; 76 } 77 78 } 79 80 | Popular Tags |