KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > spring > integrationtests > tests > SingletonStateUtil


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tctest.spring.integrationtests.tests;
5
6 import com.tctest.spring.bean.ISingleton;
7 import com.tctest.spring.integrationtests.framework.Server;
8
9 import junit.framework.Assert;
10
11 public class SingletonStateUtil {
12
13   public static void assertSingletonShared(Server server1, Server server2, String JavaDoc remoteServiceName) throws Exception JavaDoc {
14     ISingleton singleton1 = (ISingleton) server1.getProxy(ISingleton.class, remoteServiceName);
15     ISingleton singleton2 = (ISingleton) server2.getProxy(ISingleton.class, remoteServiceName);
16     Assert.assertEquals(singleton1.getCounter(), singleton2.getCounter());
17     singleton1.incrementCounter();
18     Assert.assertEquals("Should be shared", singleton1.getCounter(), singleton2.getCounter());
19     singleton2.incrementCounter();
20     Assert.assertEquals("Should be shared", singleton2.getCounter(), singleton1.getCounter());
21   }
22
23 }
24
Popular Tags