From jbosscache-commits at lists.jboss.org Mon Nov 26 23:20:25 2007 Content-Type: multipart/mixed; boundary="===============3906599765553472973==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r4779 - core/branches/1.4.X/tests/functional/org/jboss/cache/marshall. Date: Mon, 26 Nov 2007 23:16:25 -0500 Message-ID: --===============3906599765553472973== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: bstansberry(a)jboss.com Date: 2007-11-26 23:16:25 -0500 (Mon, 26 Nov 2007) New Revision: 4779 Added: core/branches/1.4.X/tests/functional/org/jboss/cache/marshall/BuddyBacku= pEnqueingTestCase.java Log: [JBCACHE-1225] TreeCache._enqueueMethodCall must handle buddy backup FQNs Added: core/branches/1.4.X/tests/functional/org/jboss/cache/marshall/BuddyB= ackupEnqueingTestCase.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/1.4.X/tests/functional/org/jboss/cache/marshall/BuddyBack= upEnqueingTestCase.java (rev 0) +++ core/branches/1.4.X/tests/functional/org/jboss/cache/marshall/BuddyBack= upEnqueingTestCase.java 2007-11-27 04:16:25 UTC (rev 4779) @@ -0,0 +1,107 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2006, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.cache.marshall; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.Fqn; +import org.jboss.cache.PropertyConfigurator; +import org.jboss.cache.TreeCache; +import org.jboss.cache.buddyreplication.BuddyManager; + +import junit.framework.TestCase; + +/** + * Test for JBCACHE-1225 -- whether enqueuing of method calls for buddy + * backup regions work. + * = + * @author Brian Stansberry + * @version $Revision: 1.1 $ + */ +public class BuddyBackupEnqueingTestCase extends TestCase +{ + private static final Log log =3D LogFactory.getLog(BuddyBackupEnqueingT= estCase.class); + = + private TreeCache tree; + + protected void setUp() throws Exception + { + super.setUp(); + tree=3Dnew TreeCache(); + PropertyConfigurator config=3Dnew PropertyConfigurator(); + config.configure(tree, "META-INF/replAsync-service.xml"); // read in= generic replAsync xml + tree.setClusterName("Test"); + // Use marshaller + tree.setUseRegionBasedMarshalling(true); + tree.setInactiveOnStartup(true); + tree.createService(); + tree.startService(); + } + + protected void tearDown() throws Exception + { + super.tearDown(); + = + tree.stopService(); + } + = + /** + * Confirms that we get an ISE if we try to enqueue a method call for + * a buddy-backup FQN where no equivalent main tree region exists, and + * that we don't get the ISE any more once the main tree region is crea= ted. + * = + * This test design is based on the fact that _enqueueMethodCall is pub= lic, + * so this is a bit too much of a white-box test. But, oh well. ;) + * = + * @throws Throwable + */ + public void testBuddyBackupEnqueuing() throws Throwable + { + Fqn raw =3D Fqn.fromString("/region/node"); + Fqn group =3D Fqn.fromString("group"); + Fqn fqn =3D new Fqn(group, raw); + fqn =3D new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqn); + JBCMethodCall call =3D MethodCallFactory.create(MethodDeclarations.e= xistsMethod, new Object[]{ fqn } ); + = + try + { + tree._enqueueMethodCall(fqn.toString(), call); + fail("Able to enqueue method call for non-existent region"); + } + catch (IllegalStateException good) {} + = + tree.activateRegion(raw.toString()); + = + try + { + tree._enqueueMethodCall(fqn.toString(), call); = + } + catch (IllegalStateException bad) = + { + String msg =3D "Caught ISE enqueuing method call for " + fqn; + log.error(msg, bad); + fail(msg); + } + } + +} --===============3906599765553472973==--