1 4 package com.tctest.spring.integrationtests.tests; 5 6 import com.tctest.spring.bean.ISingleton; 7 import com.tctest.spring.integrationtests.framework.AbstractTwoServerDeploymentTest; 8 import com.tctest.spring.integrationtests.framework.DeploymentBuilder; 9 10 import junit.framework.Test; 11 12 15 public class AppCtxMatchingTest extends AbstractTwoServerDeploymentTest { 16 private static final String REMOTE_SERVICE_NAME = "Singleton"; 17 private static final String CONFIG_FILE_FOR_TEST = "/tc-config-files/app-ctx-matching-tc-config.xml"; 18 19 static ISingleton singleton1; 20 static ISingleton singleton2; 21 22 public void testThatSingletonBeanIsNotDistributed() throws Exception { 23 assertEquals(0, singleton1.getCounter()); 24 assertEquals(0, singleton2.getCounter()); 25 26 singleton1.incrementCounter(); 27 assertEquals(1, singleton1.getCounter()); 28 assertEquals(1, singleton2.getCounter()); 29 30 singleton2.incrementCounter(); 31 assertEquals(2, singleton1.getCounter()); 32 assertEquals(2, singleton2.getCounter()); 33 } 34 35 private static class SingletonTestSetup extends TwoSvrSetup { 36 SingletonTestSetup() { 37 super(AppCtxMatchingTest.class, CONFIG_FILE_FOR_TEST, "test-singleton"); 38 } 39 40 protected void setUp() throws Exception { 41 super.setUp(); 42 43 singleton1 = (ISingleton) server1.getProxy(ISingleton.class, REMOTE_SERVICE_NAME); 44 singleton2 = (ISingleton) server2.getProxy(ISingleton.class, REMOTE_SERVICE_NAME); 45 } 46 47 protected void configureWar(DeploymentBuilder builder) { 48 builder.addBeanDefinitionFile("classpath:/com/tctest/spring/beanfactory.xml"); 49 builder.addRemoteService(REMOTE_SERVICE_NAME, "singleton", ISingleton.class); 51 } 52 53 } 54 55 58 public static Test suite() { 59 return new SingletonTestSetup(); 60 } 61 62 } 63 | Popular Tags |