Author: mircea.markus
Date: 2008-06-17 13:03:13 -0400 (Tue, 17 Jun 2008)
New Revision: 5997
Added:
core/trunk/src/test/java/org/jboss/cache/config/parsing/
core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
Removed:
core/trunk/src/test/java/org/jboss/cache/config/XmlConfigurationParserTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheLoadersElementParser.java
core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
Log:
porting existing code to use the new XML parser
Modified:
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheLoadersElementParser.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheLoadersElementParser.java 2008-06-17
15:37:59 UTC (rev 5996)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheLoadersElementParser.java 2008-06-17
17:03:13 UTC (rev 5997)
@@ -75,6 +75,11 @@
if (i > 0) result.append(",");
result.append(fqn2preload);
}
+ //no elements defined for preload so by default load the root
+ if (nodesToPreload.getLength() == 0)
+ {
+ result.append("");
+ }
return result.toString();
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-06-17 15:37:59
UTC (rev 5996)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-06-17 17:03:13
UTC (rev 5997)
@@ -2,17 +2,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeNotExistsException;
+import org.jboss.cache.*;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.CacheLoadersElementParser;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -288,7 +284,7 @@
{
// cache.stop();
cache.destroy();
- cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig(pasv,
"", DummyInMemoryCacheLoader.class.getName(), null, false, false, false,
false));
+ cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig(pasv,
"/", DummyInMemoryCacheLoader.class.getName(), null, false, false, false,
false));
cache.start();
DummyInMemoryCacheLoader loader = (DummyInMemoryCacheLoader)
cache.getCacheLoaderManager().getCacheLoader();
@@ -532,19 +528,20 @@
protected CacheLoaderConfig getSingleCacheLoaderConfig(boolean passivation, String
preload, String cacheloaderClass, String properties, boolean async, boolean
fetchPersistentState, boolean shared, boolean purgeOnStartup) throws Exception
{
- String xml = "<config>\n" +
- "<passivation>" + passivation +
"</passivation>\n" +
- "<preload>" + preload + "</preload>\n" +
- "<cacheloader>\n" +
- "<class>" + cacheloaderClass + "</class>\n"
+
- "<properties>" + properties +
"</properties>\n" +
- "<async>" + async + "</async>\n" +
- "<shared>" + shared + "</shared>\n" +
- "<fetchPersistentState>" + fetchPersistentState +
"</fetchPersistentState>\n" +
- "<purgeOnStartup>" + purgeOnStartup +
"</purgeOnStartup>\n" +
- "</cacheloader>\n" +
- "</config>";
+ String xml =
+ " <cacheLoaders passivation=\"" + passivation +
"\" shared=\"" + shared + "\">\n" +
+ " <preload>\n" +
+ " <node fqn=\"" + preload +
"\"/>\n" +
+ " </preload>\n" +
+ " <cacheLoader class=\"" + cacheloaderClass +
"\" async=\"" + async + "\"
fetchPersistentState=\"" + fetchPersistentState + "\"\n" +
+ " purgeOnStartup=\"" +
purgeOnStartup + "\">\n" +
+ " <properties>\n" +
+ properties +
+ " </properties>\n" +
+ " </cacheLoader>\n" +
+ " </cacheLoaders>";
Element element = XmlConfigHelper.stringToElement(xml);
- return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
+ CacheLoadersElementParser elementParser = new CacheLoadersElementParser();
+ return elementParser.parseCacheLoadersElement(element);
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-06-17
15:37:59 UTC (rev 5996)
+++
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-06-17
17:03:13 UTC (rev 5997)
@@ -13,7 +13,6 @@
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.loader.CacheLoader;
@@ -21,6 +20,8 @@
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.CacheLoadersElementParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
import org.jgroups.Address;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -224,21 +225,16 @@
{
CacheSPI cache = createCache(1, null, useDataGravitation, removeOnFind, false);
- String cloader = "<config>\n" +
- "<passivation>" + passivation +
"</passivation>\n" +
- "<preload></preload>\n" +
-
- "<cacheloader>\n" +
- "<class>" + DummyInMemoryCacheLoader.class.getName() +
"</class>\n" +
- "<async>false</async>\n" +
- "<shared>false</shared>\n" +
- "<fetchPersistentState>" + fetchPersistent +
"</fetchPersistentState>\n" +
- "</cacheloader>\n" +
- "</config>";
-
- Element element = XmlConfigHelper.stringToElement(cloader);
- CacheLoaderConfig cfg = XmlConfigurationParserOld.parseCacheLoaderConfig(element);
- cache.getConfiguration().setCacheLoaderConfig(cfg);
+ String xmlStr = " " +
+ " <cacheLoaders passivation=\"" + passivation +
"\" shared=\"false\">\n" +
+ " <preload/>\n" +
+ " <cacheLoader class=\"" +
DummyInMemoryCacheLoader.class.getName() + "\" async=\"false\"
fetchPersistentState=\""+ fetchPersistent + "\"/>\n" +
+ " </cacheLoaders>";
+ System.out.println("xmlStr = +\n" + xmlStr);
+ Element xmlEl = XmlConfigHelper.stringToElement(xmlStr);
+ CacheLoadersElementParser parser = new CacheLoadersElementParser();
+ CacheLoaderConfig config = parser.parseCacheLoadersElement(xmlEl);
+ cache.getConfiguration().setCacheLoaderConfig(config);
if (start)
{
cache.start();
Deleted: core/trunk/src/test/java/org/jboss/cache/config/XmlConfigurationParserTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/config/XmlConfigurationParserTest.java 2008-06-17
15:37:59 UTC (rev 5996)
+++
core/trunk/src/test/java/org/jboss/cache/config/XmlConfigurationParserTest.java 2008-06-17
17:03:13 UTC (rev 5997)
@@ -1,226 +0,0 @@
-package org.jboss.cache.config;
-
-import org.jboss.cache.config.parsing.XmlConfigurationParser;
-import org.jboss.cache.eviction.LRUConfiguration;
-import org.jboss.cache.eviction.MRUConfiguration;
-import org.jboss.cache.lock.IsolationLevel;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.List;
-
-/**
- * @author Mircea.Markus(a)jboss.com
- * @since 3.0
- */
-@Test(groups = "unit")
-public class XmlConfigurationParserTest
-{
- Configuration config;
-
- @BeforeMethod
- public void setUp()
- {
- XmlConfigurationParser parser = new XmlConfigurationParser();
- config =
parser.parseFile("META-INF/conf-test/parser-test-file-3.x.xml");
- }
-
- public void testTransactionManagerLookupClass()
- {
- assert
config.getTransactionManagerLookupClass().equals("org.jboss.cache.transaction.GenericTransactionManagerLookup");
- }
-
- public void testIsolationLevel()
- {
- assert config.getIsolationLevel().equals(IsolationLevel.REPEATABLE_READ);
- }
-
- public void testCacheMode()
- {
- assert config.getCacheMode().equals(Configuration.CacheMode.REPL_SYNC);
- }
-
- public void testUseReplQueue()
- {
- assert !config.isUseReplQueue();
- }
-
- public void testClusterName()
- {
- assert config.getClusterName().equals("JBossCache-Cluster");
- }
-
- public void testGetClusterConfig()
- {
- assert config.getClusterConfig().indexOf("MERGE2") >= 0;
- }
-
- public void testFetchInMemoryState()
- {
- assert config.isFetchInMemoryState();
- }
-
- public void testStateRetrievalTimeout()
- {
- assert config.getStateRetrievalTimeout() == 15124;
- }
-
- public void testSyncReplTimeout()
- {
- assert config.getSyncReplTimeout() == 15421;
- }
-
- public void testLockAcquisitionTimeout()
- {
- assert config.getLockAcquisitionTimeout() == 10234;
- }
-
- public void testUseLazyDeserialization()
- {
- assert config.isUseLazyDeserialization();
- }
-
- public void testObjectInputStreamPoolSize()
- {
- assert 12 == config.getObjectInputStreamPoolSize();
- }
-
- public void testObjectOutputStreamPoolSize()
- {
- assert 14 == config.getObjectOutputStreamPoolSize();
- }
-
- public void testShutdownHookBehavior()
- {
- assert Configuration.ShutdownHookBehavior.REGISTER ==
config.getShutdownHookBehavior();
- }
-
- public void testSyncRollbackPhase()
- {
- assert config.isSyncRollbackPhase();
- }
-
- public void testSyncCommitPhase()
- {
- assert config.isSyncCommitPhase();
- }
-
- public void testUseReplicationVersion()
- {
- assert config.getReplicationVersion() == 124;
- }
-
- public void testGetMultiplexerStack()
- {
- assert "file_name".equals(config.getMultiplexerStack());
- }
-
- public void testMarshallerClass()
- {
- assert "some.Clazz".equals(config.getMarshallerClass());
- }
-
- public void testLockParentForChildInsertRemove()
- {
- assert config.isLockParentForChildInsertRemove();
- }
-
- public void testInactiveOnStartup()
- {
- assert config.isInactiveOnStartup();
- }
-
- public void testExposeManagementStatistics()
- {
- assert !config.getExposeManagementStatistics();
- }
-
- public void testCacheLoaderConfiguration()
- {
- CacheLoaderConfig clc = config.getCacheLoaderConfig();
- assert null != clc;
- assert clc.isPassivation();
- assert clc.isShared();
- assert "/a/b/c,/f/r/s".equals(clc.getPreload());
- CacheLoaderConfig.IndividualCacheLoaderConfig first =
clc.getFirstCacheLoaderConfig();
- assert
"org.jboss.cache.loader.JDBCCacheLoader".equals(first.getClassName());
- assert first.isAsync();
- assert first.isFetchPersistentState();
- assert first.isIgnoreModifications();
- assert first.isPurgeOnStartup();
- assert
first.getProperties().get("cache.jdbc.table.name").equals("jbosscache");
- assert
first.getProperties().get("cache.jdbc.table.create").equals("true");
- assert
first.getProperties().get("cache.jdbc.table.drop").equals("true");
- }
-
- public void testBuddyReplicationConfig()
- {
- BuddyReplicationConfig brConfig = config.getBuddyReplicationConfig();
- assert brConfig.isEnabled();
- BuddyReplicationConfig.BuddyLocatorConfig locatorConfig =
brConfig.getBuddyLocatorConfig();
- assert
"org.jboss.cache.buddyreplication.NextMemberBuddyLocator".equals(locatorConfig.getBuddyLocatorClass());
- assert
locatorConfig.getBuddyLocatorProperties().get("numBuddies").equals("1");
- assert
locatorConfig.getBuddyLocatorProperties().get("ignoreColocatedBuddies").equals("true");
- assert
brConfig.getBuddyPoolName().equals("myBuddyPoolReplicationGroup");
- assert brConfig.getBuddyCommunicationTimeout() == 2000;
- assert brConfig.isAutoDataGravitation();
- assert brConfig.isDataGravitationRemoveOnFind();
- assert brConfig.isDataGravitationSearchBackupTrees();
- }
-
- public void testUseRegionBasedMarshalling()
- {
- assert config.isUseRegionBasedMarshalling();
- }
-
- public void testEvictionPolicyConfig()
- {
- EvictionConfig evictionConfig = config.getEvictionConfig();
- assert
"org.jboss.cache.eviction.LRUPolicy".equals(evictionConfig.getDefaultEvictionPolicyClass());
- assert 200000 == evictionConfig.getDefaultEventQueueSize();
- assert 5 == evictionConfig.getWakeupIntervalSeconds();
-
- List<EvictionRegionConfig> regionConfigs =
evictionConfig.getEvictionRegionConfigs();
- assert regionConfigs.size() == 3;
-
- EvictionRegionConfig first = regionConfigs.get(0);
- assert first.getRegionName().equals("/_default_");
- assert first.getEvictionPolicyConfig() instanceof LRUConfiguration;
- LRUConfiguration firstConfiguration = (LRUConfiguration)
first.getEvictionPolicyConfig();
- assert firstConfiguration.getMaxAge() <= 0;
- assert firstConfiguration.getTimeToLive() == 1000;
- assert firstConfiguration.getMaxNodes() == 5000;
-
- EvictionRegionConfig second = regionConfigs.get(1);
- LRUConfiguration secondConfiguration = (LRUConfiguration)
second.getEvictionPolicyConfig();
- assert secondConfiguration.getMaxAge() == 0;
- assert secondConfiguration.getTimeToLive() == 1002;
- assert secondConfiguration.getMaxNodes() == 0;
-
- EvictionRegionConfig third = regionConfigs.get(2);
- MRUConfiguration thirdConfiguration = (MRUConfiguration)
third.getEvictionPolicyConfig();
- assert thirdConfiguration.getMaxNodes() == 2103;
- assert thirdConfiguration.getMinTimeToLive() == 22;
- assert third.getEventQueueSize() == 21;
- }
-
- public void testCustomInterceptors()
- {
- List<CustomInterceptorConfig> interceptorConfigs =
config.getCustomInterceptors();
- if (interceptorConfigs.isEmpty()) return; //todo drop this once you drop the old
configuration
- assert interceptorConfigs.size() == 5;
- assert
interceptorConfigs.get(0).getInterceptorClass().equals("com.myCompany.MyInterceptor1");
- assert
interceptorConfigs.get(1).getInterceptorClass().equals("com.myCompany.MyInterceptor2");
- assert
interceptorConfigs.get(2).getInterceptorClass().equals("com.myCompany.MyInterceptor3");
- assert
interceptorConfigs.get(3).getInterceptorClass().equals("com.myCompany.MyInterceptor4");
- assert
interceptorConfigs.get(4).getInterceptorClass().equals("com.myCompany.MyInterceptor5");
- assert interceptorConfigs.get(0).isFirst();
- assert !interceptorConfigs.get(0).isLast();
- assert
interceptorConfigs.get(0).getProperties().get("x").equals("y");
- assert
interceptorConfigs.get(0).getProperties().get("i").equals("10");
- assert interceptorConfigs.get(1).isLast();
- assert interceptorConfigs.get(2).getIndex() == 3;
- assert
interceptorConfigs.get(3).getBeforeClass().equals("org.jboss.cache.interceptors.CallInterceptor");
- assert
interceptorConfigs.get(4).getAfterClass().equals("org.jboss.cache.interceptors.CallInterceptor");
- }
-}
Added:
core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java 2008-06-17
17:03:13 UTC (rev 5997)
@@ -0,0 +1,64 @@
+package org.jboss.cache.config.parsing;
+
+import org.testng.annotations.Test;
+import org.w3c.dom.Element;
+import org.jboss.cache.config.CacheLoaderConfig;
+
+/**
+ * Tester class for {@link CacheLoadersElementParser}
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+@Test(groups = "unit")
+public class CacheLoadersElementParserTest
+{
+ CacheLoadersElementParser parser = new CacheLoadersElementParser();
+
+
+ public void simpleParse() throws Exception
+ {
+
+ String xmlStr = " " +
+ " <cacheLoaders passivation=\"false\"
shared=\"false\">\n" +
+ " <preload>\n" +
+ " <node fqn=\"/\"/>\n" +
+ " </preload>\n" +
+ " <cacheLoader
class=\"org.jboss.cache.loader.JDBCCacheLoader\" async=\"true\"
fetchPersistentState=\"false\"\n" +
+ " ignoreModifications=\"false\"
purgeOnStartup=\"false\">\n" +
+ " <properties>\n" +
+ " cache.jdbc.table.name=jbosscache\n" +
+ " cache.jdbc.table.create=true\n" +
+ " cache.jdbc.table.drop=true\n" +
+ " </properties>\n" +
+ " </cacheLoader>\n" +
+ " </cacheLoaders>";
+ Element element = XmlConfigHelper.stringToElement(xmlStr);
+ CacheLoaderConfig config = parser.parseCacheLoadersElement(element);
+ assert !config.isPassivation();
+ assert !config.isShared();
+ assert config.getPreload().equals("/");
+ assert
config.getFirstCacheLoaderConfig().getClassName().equals("org.jboss.cache.loader.JDBCCacheLoader");
+ assert config.getFirstCacheLoaderConfig().isAsync();
+ assert !config.getFirstCacheLoaderConfig().isFetchPersistentState();
+ assert !config.getFirstCacheLoaderConfig().isIgnoreModifications();
+ assert !config.getFirstCacheLoaderConfig().isPurgeOnStartup();
+ }
+
+ /**
+ * If so an empty preload string should apear.
+ */
+ public void testMissingPreloadNodes() throws Exception
+ {
+ String xmlStr = " " +
+ " <cacheLoaders passivation=\"false\"
shared=\"false\">\n" +
+ " <preload/>\n" +
+ " <cacheLoader
class=\"org.jboss.cache.loader.JDBCCacheLoader\" async=\"true\"
fetchPersistentState=\"false\"\n" +
+ " ignoreModifications=\"false\"
purgeOnStartup=\"false\"/>\n" +
+ " </cacheLoaders>";
+ Element element = XmlConfigHelper.stringToElement(xmlStr);
+ CacheLoaderConfig config = parser.parseCacheLoadersElement(element);
+ assert config.getPreload().length() == 0;
+ }
+
+}
Copied:
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
(from rev 5995,
core/trunk/src/test/java/org/jboss/cache/config/XmlConfigurationParserTest.java)
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-06-17
17:03:13 UTC (rev 5997)
@@ -0,0 +1,227 @@
+package org.jboss.cache.config.parsing;
+
+import org.jboss.cache.config.parsing.XmlConfigurationParser;
+import org.jboss.cache.config.*;
+import org.jboss.cache.eviction.LRUConfiguration;
+import org.jboss.cache.eviction.MRUConfiguration;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+/**
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+@Test(groups = "unit")
+public class XmlConfigurationParserTest
+{
+ Configuration config;
+
+ @BeforeMethod
+ public void setUp()
+ {
+ XmlConfigurationParser parser = new XmlConfigurationParser();
+ config =
parser.parseFile("META-INF/conf-test/parser-test-file-3.x.xml");
+ }
+
+ public void testTransactionManagerLookupClass()
+ {
+ assert
config.getTransactionManagerLookupClass().equals("org.jboss.cache.transaction.GenericTransactionManagerLookup");
+ }
+
+ public void testIsolationLevel()
+ {
+ assert config.getIsolationLevel().equals(IsolationLevel.REPEATABLE_READ);
+ }
+
+ public void testCacheMode()
+ {
+ assert config.getCacheMode().equals(Configuration.CacheMode.REPL_SYNC);
+ }
+
+ public void testUseReplQueue()
+ {
+ assert !config.isUseReplQueue();
+ }
+
+ public void testClusterName()
+ {
+ assert config.getClusterName().equals("JBossCache-Cluster");
+ }
+
+ public void testGetClusterConfig()
+ {
+ assert config.getClusterConfig().indexOf("MERGE2") >= 0;
+ }
+
+ public void testFetchInMemoryState()
+ {
+ assert config.isFetchInMemoryState();
+ }
+
+ public void testStateRetrievalTimeout()
+ {
+ assert config.getStateRetrievalTimeout() == 15124;
+ }
+
+ public void testSyncReplTimeout()
+ {
+ assert config.getSyncReplTimeout() == 15421;
+ }
+
+ public void testLockAcquisitionTimeout()
+ {
+ assert config.getLockAcquisitionTimeout() == 10234;
+ }
+
+ public void testUseLazyDeserialization()
+ {
+ assert config.isUseLazyDeserialization();
+ }
+
+ public void testObjectInputStreamPoolSize()
+ {
+ assert 12 == config.getObjectInputStreamPoolSize();
+ }
+
+ public void testObjectOutputStreamPoolSize()
+ {
+ assert 14 == config.getObjectOutputStreamPoolSize();
+ }
+
+ public void testShutdownHookBehavior()
+ {
+ assert Configuration.ShutdownHookBehavior.REGISTER ==
config.getShutdownHookBehavior();
+ }
+
+ public void testSyncRollbackPhase()
+ {
+ assert config.isSyncRollbackPhase();
+ }
+
+ public void testSyncCommitPhase()
+ {
+ assert config.isSyncCommitPhase();
+ }
+
+ public void testUseReplicationVersion()
+ {
+ assert config.getReplicationVersion() == 124;
+ }
+
+ public void testGetMultiplexerStack()
+ {
+ assert "file_name".equals(config.getMultiplexerStack());
+ }
+
+ public void testMarshallerClass()
+ {
+ assert "some.Clazz".equals(config.getMarshallerClass());
+ }
+
+ public void testLockParentForChildInsertRemove()
+ {
+ assert config.isLockParentForChildInsertRemove();
+ }
+
+ public void testInactiveOnStartup()
+ {
+ assert config.isInactiveOnStartup();
+ }
+
+ public void testExposeManagementStatistics()
+ {
+ assert !config.getExposeManagementStatistics();
+ }
+
+ public void testCacheLoaderConfiguration()
+ {
+ CacheLoaderConfig clc = config.getCacheLoaderConfig();
+ assert null != clc;
+ assert clc.isPassivation();
+ assert clc.isShared();
+ assert "/a/b/c,/f/r/s".equals(clc.getPreload());
+ CacheLoaderConfig.IndividualCacheLoaderConfig first =
clc.getFirstCacheLoaderConfig();
+ assert
"org.jboss.cache.loader.JDBCCacheLoader".equals(first.getClassName());
+ assert first.isAsync();
+ assert first.isFetchPersistentState();
+ assert first.isIgnoreModifications();
+ assert first.isPurgeOnStartup();
+ assert
first.getProperties().get("cache.jdbc.table.name").equals("jbosscache");
+ assert
first.getProperties().get("cache.jdbc.table.create").equals("true");
+ assert
first.getProperties().get("cache.jdbc.table.drop").equals("true");
+ }
+
+ public void testBuddyReplicationConfig()
+ {
+ BuddyReplicationConfig brConfig = config.getBuddyReplicationConfig();
+ assert brConfig.isEnabled();
+ BuddyReplicationConfig.BuddyLocatorConfig locatorConfig =
brConfig.getBuddyLocatorConfig();
+ assert
"org.jboss.cache.buddyreplication.NextMemberBuddyLocator".equals(locatorConfig.getBuddyLocatorClass());
+ assert
locatorConfig.getBuddyLocatorProperties().get("numBuddies").equals("1");
+ assert
locatorConfig.getBuddyLocatorProperties().get("ignoreColocatedBuddies").equals("true");
+ assert
brConfig.getBuddyPoolName().equals("myBuddyPoolReplicationGroup");
+ assert brConfig.getBuddyCommunicationTimeout() == 2000;
+ assert brConfig.isAutoDataGravitation();
+ assert brConfig.isDataGravitationRemoveOnFind();
+ assert brConfig.isDataGravitationSearchBackupTrees();
+ }
+
+ public void testUseRegionBasedMarshalling()
+ {
+ assert config.isUseRegionBasedMarshalling();
+ }
+
+ public void testEvictionPolicyConfig()
+ {
+ EvictionConfig evictionConfig = config.getEvictionConfig();
+ assert
"org.jboss.cache.eviction.LRUPolicy".equals(evictionConfig.getDefaultEvictionPolicyClass());
+ assert 200000 == evictionConfig.getDefaultEventQueueSize();
+ assert 5 == evictionConfig.getWakeupIntervalSeconds();
+
+ List<EvictionRegionConfig> regionConfigs =
evictionConfig.getEvictionRegionConfigs();
+ assert regionConfigs.size() == 3;
+
+ EvictionRegionConfig first = regionConfigs.get(0);
+ assert first.getRegionName().equals("/_default_");
+ assert first.getEvictionPolicyConfig() instanceof LRUConfiguration;
+ LRUConfiguration firstConfiguration = (LRUConfiguration)
first.getEvictionPolicyConfig();
+ assert firstConfiguration.getMaxAge() <= 0;
+ assert firstConfiguration.getTimeToLive() == 1000;
+ assert firstConfiguration.getMaxNodes() == 5000;
+
+ EvictionRegionConfig second = regionConfigs.get(1);
+ LRUConfiguration secondConfiguration = (LRUConfiguration)
second.getEvictionPolicyConfig();
+ assert secondConfiguration.getMaxAge() == 0;
+ assert secondConfiguration.getTimeToLive() == 1002;
+ assert secondConfiguration.getMaxNodes() == 0;
+
+ EvictionRegionConfig third = regionConfigs.get(2);
+ MRUConfiguration thirdConfiguration = (MRUConfiguration)
third.getEvictionPolicyConfig();
+ assert thirdConfiguration.getMaxNodes() == 2103;
+ assert thirdConfiguration.getMinTimeToLive() == 22;
+ assert third.getEventQueueSize() == 21;
+ }
+
+ public void testCustomInterceptors()
+ {
+ List<CustomInterceptorConfig> interceptorConfigs =
config.getCustomInterceptors();
+ if (interceptorConfigs.isEmpty()) return; //todo drop this once you drop the old
configuration
+ assert interceptorConfigs.size() == 5;
+ assert
interceptorConfigs.get(0).getInterceptorClass().equals("com.myCompany.MyInterceptor1");
+ assert
interceptorConfigs.get(1).getInterceptorClass().equals("com.myCompany.MyInterceptor2");
+ assert
interceptorConfigs.get(2).getInterceptorClass().equals("com.myCompany.MyInterceptor3");
+ assert
interceptorConfigs.get(3).getInterceptorClass().equals("com.myCompany.MyInterceptor4");
+ assert
interceptorConfigs.get(4).getInterceptorClass().equals("com.myCompany.MyInterceptor5");
+ assert interceptorConfigs.get(0).isFirst();
+ assert !interceptorConfigs.get(0).isLast();
+ assert
interceptorConfigs.get(0).getProperties().get("x").equals("y");
+ assert
interceptorConfigs.get(0).getProperties().get("i").equals("10");
+ assert interceptorConfigs.get(1).isLast();
+ assert interceptorConfigs.get(2).getIndex() == 3;
+ assert
interceptorConfigs.get(3).getBeforeClass().equals("org.jboss.cache.interceptors.CallInterceptor");
+ assert
interceptorConfigs.get(4).getAfterClass().equals("org.jboss.cache.interceptors.CallInterceptor");
+ }
+}