From jbosscache-commits at lists.jboss.org Thu May 29 10:49:11 2008 Content-Type: multipart/mixed; boundary="===============0292028291953150500==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r5917 - core/branches/2.1.X/src/test/java/org/jboss/cache/buddyreplication. Date: Thu, 29 May 2008 10:49:10 -0400 Message-ID: --===============0292028291953150500== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: manik.surtani(a)jboss.com Date: 2008-05-29 10:49:10 -0400 (Thu, 29 May 2008) New Revision: 5917 Added: core/branches/2.1.X/src/test/java/org/jboss/cache/buddyreplication/Empty= RegionTest.java Log: Added test for JBCACHE-1349 Added: core/branches/2.1.X/src/test/java/org/jboss/cache/buddyreplication/E= mptyRegionTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/branches/2.1.X/src/test/java/org/jboss/cache/buddyreplication/Empt= yRegionTest.java (rev 0) +++ core/branches/2.1.X/src/test/java/org/jboss/cache/buddyreplication/Empt= yRegionTest.java 2008-05-29 14:49:10 UTC (rev 5917) @@ -0,0 +1,88 @@ +package org.jboss.cache.buddyreplication; + +import org.jboss.cache.CacheSPI; +import org.jboss.cache.DefaultCacheFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.Region; +import org.jboss.cache.misc.TestingUtil; +import org.jboss.cache.notifications.annotation.BuddyGroupChanged; +import org.jboss.cache.notifications.annotation.CacheListener; +import org.jboss.cache.notifications.event.Event; +import org.jboss.cache.util.CachePrinter; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +/** + * To test http://jira.jboss.org/jira/browse/JBCACHE-1349 + * + * @author Manik Surtani (manik(a)jbo= ss.org) + */ +(a)Test(groups =3D "functional", enabled =3D false) +// disabled since there is no intention to fix this in this branch. +public class EmptyRegionTest extends BuddyReplicationTestsBase +{ + CacheSPI c1, c2; + Fqn regionFqn =3D Fqn.fromString("/a/b/c"); + Fqn region2Fqn =3D Fqn.fromString("/d/e/f"); + Region region, region2; + CountDownLatch buddyJoinLatch =3D new CountDownLatch(1); + + @BeforeTest + public void setUp() throws Exception + { + c1 =3D createCache(1, null, false, false, false); + c1.getConfiguration().setUseRegionBasedMarshalling(true); + c1.getConfiguration().setFetchInMemoryState(true); + c2 =3D (CacheSPI) new DefaultCacheFactory().createCache(c1.getConfig= uration().clone(), false); + c1.start(); + region =3D c1.getRegion(regionFqn, true); + region2 =3D c1.getRegion(region2Fqn, true); + region.registerContextClassLoader(getClass().getClassLoader()); + c1.put(region2Fqn, "key", "value"); + + c2.create(); + c2.addCacheListener(new BuddyJoinListener()); + } + + @AfterTest + public void tearDown() + { + TestingUtil.killCaches(c1, c2); + } + + public void testEmptyRegion() throws InterruptedException + { + // region on c1 is empty - with no root node. + assert c1.getNode(regionFqn) =3D=3D null : "Node should not exist"; + assert c1.getRegion(regionFqn, false) !=3D null : "Region should exi= st"; + assert c1.getRegion(regionFqn, false).isActive() : "Region should be= active"; + + // now start c2 + c2.start(); + + // wait for buddy join notifications to complete. + buddyJoinLatch.await(60, TimeUnit.SECONDS); + + // should not throw any exceptions!! + + System.out.println("Cache1 " + CachePrinter.printCacheDetails(c1)); + System.out.println("Cache2 " + CachePrinter.printCacheDetails(c2)); + + // make sure region2 stuff did get transmitted! + assert c2.peek(BuddyManager.getBackupFqn(c1.getLocalAddress(), regio= n2Fqn), false) !=3D null : "Region2 state should have transferred!"; + } + + @CacheListener + public class BuddyJoinListener + { + @BuddyGroupChanged + public void buddyJoined(Event e) + { + buddyJoinLatch.countDown(); + } + } +} --===============0292028291953150500==--