[jboss-cvs] JBossAS SVN: r64881 - trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Aug 25 14:18:07 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-08-25 14:18:07 -0400 (Sat, 25 Aug 2007)
New Revision: 64881
Added:
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/CacheListenerUnitTestCase.java
Log:
Add tests of Fqn manipulation
Added: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/CacheListenerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/CacheListenerUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/CacheListenerUnitTestCase.java 2007-08-25 18:18:07 UTC (rev 64881)
@@ -0,0 +1,125 @@
+/*
+ * 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.test.cluster.defaultcfg.simpleweb.test;
+
+import junit.framework.TestCase;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.web.tomcat.service.session.CacheListener;
+import org.jboss.web.tomcat.service.session.CacheListenerBase;
+import org.jboss.web.tomcat.service.session.JBossCacheService;
+
+/**
+ * A CacheListenerUnitTestCase.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class CacheListenerUnitTestCase extends TestCase
+{
+ private static final String DATA_OWNER = "localhost_12345";
+
+ public void testIsBuddyFqn()
+ {
+ assertFalse("ROOT is not buddy", CacheListenerBase.isBuddyFqn(Fqn.ROOT));
+
+ Fqn test = new Fqn(new Object[]{"random", BuddyManager.BUDDY_BACKUP_SUBTREE});
+ assertFalse("Random is not buddy", CacheListenerBase.isBuddyFqn(test));
+
+ test = JBossCacheService.getSessionFqn("localhost", "webapp", "123");
+ assertFalse("Normal is not buddy", CacheListenerBase.isBuddyFqn(test));
+
+ test = JBossCacheService.getSessionFqn(DATA_OWNER, "localhost", "webapp", "123");
+ assertTrue("Buddy is a buddy", CacheListenerBase.isBuddyFqn(test));
+ }
+
+ public void testGetBuddyBackupOwner()
+ {
+ Fqn test = JBossCacheService.getSessionFqn(DATA_OWNER, "localhost", "webapp", "123");
+ assertEquals("Got correct owner", DATA_OWNER, CacheListenerBase.getBuddyOwner(test));
+ }
+
+ public void testIsFqnSessionRootSized()
+ {
+ Fqn test = JBossCacheService.getSessionFqn("localhost", "webapp", "123");
+ assertTrue("Non-buddy session root correct", CacheListenerBase.isFqnSessionRootSized(test, false));
+ assertFalse("Non-buddy session root correct with wrong isBuddy", CacheListenerBase.isFqnSessionRootSized(test, true));
+
+ test = JBossCacheService.getSessionFqn(DATA_OWNER, "localhost", "webapp", "123");
+ assertTrue("Buddy session root correct", CacheListenerBase.isFqnSessionRootSized(test, true));
+ assertFalse("Buddy session root correct with wrong isBuddy", CacheListenerBase.isFqnSessionRootSized(test, false));
+
+ test = JBossCacheService.getAttributeFqn("localhost", "webapp", "123");
+ assertFalse("Non-buddy non-session root correct", CacheListenerBase.isFqnSessionRootSized(test, false));
+
+ test = JBossCacheService.getSessionFqn(DATA_OWNER, "localhost", "webapp", "123");
+ test = new Fqn(test, JBossCacheService.ATTRIBUTE);
+ assertFalse("Buddy non-session root correct", CacheListenerBase.isFqnSessionRootSized(test, true));
+ }
+
+ public void testIsFqnPojoKeySized()
+ {
+ Fqn test = JBossCacheService.getSessionFqn("localhost", "webapp", "123");
+ assertFalse("Non-buddy session root correct", CacheListener.isFqnPojoKeySized(test, false));
+
+ test = JBossCacheService.getSessionFqn(DATA_OWNER, "localhost", "webapp", "123");
+ assertFalse("Buddy session root correct", CacheListener.isFqnPojoKeySized(test, true));
+
+ test = JBossCacheService.getAttributeFqn("localhost", "webapp", "123");
+ assertFalse("Non-buddy ATTRIBUTE fqn correct", CacheListener.isFqnPojoKeySized(test, false));
+
+ test = JBossCacheService.getSessionFqn(DATA_OWNER, "localhost", "webapp", "123");
+ test = new Fqn(test, JBossCacheService.ATTRIBUTE);
+ assertFalse("Buddy ATTRIBUTE fqn correct", CacheListener.isFqnPojoKeySized(test, true));
+
+ test = JBossCacheService.getFieldFqn("localhost", "webapp", "123", "person");
+ assertTrue("Non-buddy pojo root correct", CacheListener.isFqnPojoKeySized(test, false));
+ assertFalse("Non-buddy pojo root correct with wrong isBuddy", CacheListener.isFqnPojoKeySized(test, true));
+
+ test = JBossCacheService.getSessionFqn(DATA_OWNER, "localhost", "webapp", "123");
+ test = new Fqn(test, JBossCacheService.ATTRIBUTE);
+ test = new Fqn(test, "person");
+ assertTrue("Buddy session root correct", CacheListener.isFqnPojoKeySized(test, true));
+ assertFalse("Buddy session root correct with wrong isBuddy", CacheListener.isFqnPojoKeySized(test, false));
+ }
+
+ public void testGetPojoKeyFromFqn()
+ {
+ Fqn test = JBossCacheService.getFieldFqn("localhost", "webapp", "123", "person");
+ assertEquals("Non-buddy pojo field correct", "person", CacheListener.getPojoKeyFromFqn(test, false));
+
+ test = JBossCacheService.getFieldFqn("localhost", "webapp", "123", "person");
+ test = new Fqn(test, "subobject");
+ assertEquals("Non-buddy pojo field correct with subobject", "person", CacheListener.getPojoKeyFromFqn(test, false));
+
+ test = JBossCacheService.getSessionFqn(DATA_OWNER, "localhost", "webapp", "123");
+ test = new Fqn(test, JBossCacheService.ATTRIBUTE);
+ test = new Fqn(test, "person");
+ assertEquals("Buddy pojo field correct", "person", CacheListener.getPojoKeyFromFqn(test, true));
+
+ test = new Fqn(test, "subobject");
+ assertEquals("Buddy pojo field correct with subobject", "person", CacheListener.getPojoKeyFromFqn(test, true));
+
+ }
+}
Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/CacheListenerUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list