[jboss-svn-commits] JBL Code SVN: r11875 - in labs/jbossesb/workspace/dbevenius/product: core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed May 16 02:11:39 EDT 2007
Author: beve
Date: 2007-05-16 02:11:39 -0400 (Wed, 16 May 2007)
New Revision: 11875
Modified:
labs/jbossesb/workspace/dbevenius/product/.classpath
labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener_ReadOnlyStrategyUnitTest.java
labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListenerTest.java
labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheTestUtil.java
labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/ftpfile_cache_test.xml
Log:
Added test to make sure that the DelteOnEvictTreeCacheListener.
Modified: labs/jbossesb/workspace/dbevenius/product/.classpath
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/.classpath 2007-05-16 04:20:41 UTC (rev 11874)
+++ labs/jbossesb/workspace/dbevenius/product/.classpath 2007-05-16 06:11:39 UTC (rev 11875)
@@ -87,7 +87,7 @@
<classpathentry kind="lib" path="services/jbpm/lib/ext/hibernate3.jar"/>
<classpathentry kind="lib" path="services/jbpm/lib/ext/jbpm-identity.jar"/>
<classpathentry kind="lib" path="services/jbpm/lib/ext/jbpm-jpdl.jar"/>
+ <classpathentry kind="lib" path="lib/ext/jgroups-all.jar"/>
<classpathentry kind="lib" path="lib/ext/cache.jar"/>
- <classpathentry kind="lib" path="lib/ext/jgroups-all.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener_ReadOnlyStrategyUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener_ReadOnlyStrategyUnitTest.java 2007-05-16 04:20:41 UTC (rev 11874)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener_ReadOnlyStrategyUnitTest.java 2007-05-16 06:11:39 UTC (rev 11875)
@@ -23,7 +23,6 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.io.File;
import java.net.MalformedURLException;
@@ -42,7 +41,6 @@
import org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.FtpFileCacheTestUtil;
import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListenerTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListenerTest.java 2007-05-16 04:20:41 UTC (rev 11874)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListenerTest.java 2007-05-16 06:11:39 UTC (rev 11875)
@@ -21,17 +21,25 @@
*/
package org.jboss.soa.esb.listeners.gateway.remotestrategies.cache;
+import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import junit.framework.JUnit4TestAdapter;
+import org.apache.log4j.Logger;
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.TreeCache;
+import org.jboss.cache.eviction.Region;
+import org.jboss.cache.eviction.RegionManager;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.NodeList;
/**
*
@@ -40,10 +48,15 @@
*/
public class DeleteOnEvictTreeCacheListenerTest
{
+ private Logger log = Logger .getLogger( DeleteOnEvictTreeCacheListenerTest.class );
+
private static DeleteOnEvictTreeCacheListener listener;
private static TreeCache treeCache;
private static final String FQN = "test/junit";
+ private String key = "testKey";
+ private String value = "testValue";
+ private Fqn fqnTest = new Fqn ( new String[] { FQN, key, value} );
@Test( expected=IllegalArgumentException.class )
public void constructor()
@@ -54,10 +67,6 @@
@Test
public void nodeEvict() throws CacheException
{
- String key = "testKey";
- String value = "testValue";
- Fqn fqnTest = new Fqn ( new String[] { FQN, key, value} );
-
treeCache.put( FQN, key, value );
Node node = treeCache.get( fqnTest );
assertTrue( "The value should have been added!", treeCache.exists( FQN, key ) );
@@ -70,9 +79,26 @@
assertNull ( "The node should have been removed from the cache store", node );
}
+ @Test
+ public void testCacheRestart() throws Exception
+ {
+ treeCache.put( FQN, key, value );
+ Object valueBeforeCacheShutdown = treeCache.get( FQN, key );
+ treeCache.stop();
+ treeCache.start();
+ Object valueAfterCacheShutdown = treeCache.get( FQN, key );
+ assertEquals( "Objects should be equal even after a treeCache restart", valueBeforeCacheShutdown, valueAfterCacheShutdown );
+ }
+
@BeforeClass
public static void classSetup() throws Exception
{
+ FtpFileCacheTestUtil.startDB();
+ startCache();
+ }
+
+ private static void startCache() throws Exception
+ {
treeCache = new TreeCache();
listener = new DeleteOnEvictTreeCacheListener( treeCache );
treeCache.addTreeCacheListener( listener );
@@ -80,9 +106,53 @@
treeCache.start();
}
+ private static void stopCache()
+ {
+ treeCache.stop();
+ }
+
+ @AfterClass
+ public static void classTearDown() throws Exception
+ {
+ FtpFileCacheTestUtil.stopDB();
+ stopCache();
+ }
+
public static junit.framework.Test suite()
{
return new JUnit4TestAdapter( FtpFileCacheTest.class );
}
+ @SuppressWarnings("unused")
+ private int getMaxAgeSeconds()
+ {
+ int maxAgeSeconds = 0;
+ NodeList elementsByTagName = treeCache.getEvictionPolicyConfig().getElementsByTagName( "region" );
+ for ( int i = elementsByTagName.getLength() ; i-->0 ; )
+ {
+ org.w3c.dom.Node region = elementsByTagName.item( i );
+ NamedNodeMap attributes = region.getAttributes();
+ org.w3c.dom.Node fqnNameNode = attributes.getNamedItem( "name" );
+ if ( fqnNameNode.getNodeValue().equals( "/ftp/cache" ))
+ {
+ NodeList childNodes = region.getChildNodes();
+ for ( int y = 0 ; y < childNodes.getLength() ; y ++ )
+ {
+ org.w3c.dom.Node node = childNodes.item( y );
+ if ( node.getNodeName().equals( "attribute" ))
+ {
+ NamedNodeMap attributes2 = node.getAttributes();
+ org.w3c.dom.Node namedItem = attributes2.getNamedItem( "name" );
+ if ( namedItem.getNodeValue().equals("maxAgeSeconds") )
+ {
+ maxAgeSeconds = Integer.valueOf( node.getTextContent() );
+ break;
+ }
+ }
+ }
+ }
+ }
+ return maxAgeSeconds;
+ }
+
}
Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheTestUtil.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheTestUtil.java 2007-05-16 04:20:41 UTC (rev 11874)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheTestUtil.java 2007-05-16 06:11:39 UTC (rev 11875)
@@ -28,6 +28,7 @@
import org.jboss.cache.ConfigureException;
import org.jboss.cache.PropertyConfigurator;
import org.jboss.cache.TreeCache;
+import org.jboss.soa.esb.testutils.HsqldbUtil;
import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
/**
@@ -68,5 +69,29 @@
PropertyConfigurator configurator = new PropertyConfigurator();
configurator.configure( treeCache, pathToConfigFile );
}
+
+ public static void startDB() throws Exception
+ {
+
+ registerHsqlDriver();
+ HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir() + "build" + File.separator + "hsqltestdb", "ftpcache");
+ }
+
+ private static void registerHsqlDriver()
+ {
+ try
+ {
+ Class.forName( "org.hsqldb.jdbcDriver" );
+ }
+ catch (Exception e)
+ {
+ fail( "ERROR: failed to load JDBC driver." + e.getMessage() );
+ }
+ }
+
+ public static void stopDB() throws Exception
+ {
+ HsqldbUtil.stopHsqldb( "jdbc:hsqldb:hsql://localhost:9001/ftpcache", "sa", "" );
+ }
}
Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/ftpfile_cache_test.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/ftpfile_cache_test.xml 2007-05-16 04:20:41 UTC (rev 11874)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/ftpfile_cache_test.xml 2007-05-16 06:11:39 UTC (rev 11875)
@@ -84,8 +84,8 @@
<attribute name="wakeUpIntervalSeconds">30</attribute>
<!-- Cache wide default -->
<region name="/_default_">
- <attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLiveSeconds">1000</attribute>
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLiveSeconds">1000</attribute>
</region>
<region name="/ftp/cache">
<attribute name="maxNodes">5000</attribute>
More information about the jboss-svn-commits
mailing list