Author: manik.surtani(a)jboss.com
Date: 2008-08-18 16:05:38 -0400 (Mon, 18 Aug 2008)
New Revision: 6576
Modified:
core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java
core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplacementTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
core/trunk/src/test/resources/configs/string-property-replaced.xml
Log:
Fixed more broken tests
Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 2008-08-18
19:46:56 UTC (rev 6575)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 2008-08-18
20:05:38 UTC (rev 6576)
@@ -23,6 +23,9 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.eviction.DefaultEvictionActionPolicy;
+import org.jboss.cache.eviction.EvictionAlgorithm;
+import org.jboss.cache.eviction.EvictionPolicy;
+import org.jboss.cache.util.Util;
import java.util.LinkedList;
import java.util.List;
@@ -51,6 +54,8 @@
@Dynamic
private List<EvictionRegionConfig> evictionRegionConfigs;
private EvictionRegionConfig defaultEvictionRegionConfig;
+ @Deprecated
+ private String defaultEvictionPolicyClass;
public EvictionConfig()
{
@@ -115,7 +120,7 @@
@Deprecated
public String getDefaultEvictionPolicyClass()
{
- throw new ConfigurationException("Please use getDefaultEvictionRegionConfig()
instead.");
+ return defaultEvictionPolicyClass;
}
/**
@@ -124,7 +129,17 @@
@Deprecated
public void setDefaultEvictionPolicyClass(String defaultEvictionPolicyClass)
{
- throw new ConfigurationException("Please use setDefaultEvictionRegionConfig()
instead.");
+ try
+ {
+ EvictionPolicy policy = (EvictionPolicy)
Util.getInstance(defaultEvictionPolicyClass);
+ EvictionAlgorithm ea = policy.getEvictionAlgorithm();
+
defaultEvictionRegionConfig.setEvictionAlgorithmConfig(Util.getInstance(ea.getConfigurationClass()));
+ this.defaultEvictionPolicyClass = defaultEvictionPolicyClass;
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException(e);
+ }
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java 2008-08-18
19:46:56 UTC (rev 6575)
+++
core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java 2008-08-18
20:05:38 UTC (rev 6576)
@@ -14,7 +14,7 @@
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
-import org.jboss.cache.eviction.LRUPolicy;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
@@ -61,7 +61,7 @@
assertEquals(4, ec2.getDefaultEvictionRegionConfig().getEventQueueSize());
assertEquals(45000, ec2.getWakeupInterval());
- assertEquals(LRUPolicy.class.getName(), ec2.getDefaultEvictionPolicyClass());
+ assert ec2.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig()
instanceof LRUAlgorithmConfig;
List<EvictionRegionConfig> ercs1 = ec1.getEvictionRegionConfigs();
List<EvictionRegionConfig> ercs2 = ec2.getEvictionRegionConfigs();
@@ -108,8 +108,8 @@
assertEquals(erc1.getRegionFqn(), erc2.getRegionFqn());
assertEquals(erc1.getEventQueueSize(), erc2.getEventQueueSize());
- EvictionPolicyConfig epc1 = erc1.getEvictionPolicyConfig();
- EvictionPolicyConfig epc2 = erc2.getEvictionPolicyConfig();
+ EvictionAlgorithmConfig epc1 = erc1.getEvictionAlgorithmConfig();
+ EvictionAlgorithmConfig epc2 = erc2.getEvictionAlgorithmConfig();
assertFalse(epc1 == epc2);
assertEquals(epc1, epc2);
Modified:
core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplacementTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplacementTest.java 2008-08-18
19:46:56 UTC (rev 6575)
+++
core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplacementTest.java 2008-08-18
20:05:38 UTC (rev 6576)
@@ -7,16 +7,12 @@
package org.jboss.cache.config;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertTrue;
-
import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.eviction.LRUConfiguration;
-import org.jboss.cache.eviction.LRUPolicy;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
+import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -24,25 +20,25 @@
/**
* Tests that string property replacement works properly when parsing
* a config file. JBCACHE-1218
- *
+ *
* @author Brian Stansberry
*/
@Test(groups = {"functional"})
public class StringPropertyReplacementTest
{
public static final String STRING_REPLACED_FILE =
"configs/string-property-replaced.xml";
-
+
private static final String PROP_BASE = "test.property.";
private static final String SYNC_COMMIT_PROP = PROP_BASE +
"SyncCommitPhase";
private static final String NUM_BUDDIES_PROP = PROP_BASE +
"BuddyReplicationConfig.numBuddies";
private static final String MAX_NODES_PROP = PROP_BASE +
"EvictionPolicyConfig.maxNodes";
private static final String BUDDY_POOL_PROP = PROP_BASE +
"BuddyReplicationConfig.buddyPoolName";
-
+
private String numBuddies;
private String syncCommitPhase;
private String maxNodes;
private String buddyPoolName;
-
+
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
@@ -51,7 +47,7 @@
maxNodes = System.getProperty(MAX_NODES_PROP);
buddyPoolName = System.getProperty(BUDDY_POOL_PROP);
}
-
+
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
@@ -73,35 +69,35 @@
if (buddyPoolName == null)
System.clearProperty(BUDDY_POOL_PROP);
else
- System.setProperty(BUDDY_POOL_PROP, buddyPoolName);
+ System.setProperty(BUDDY_POOL_PROP, buddyPoolName);
}
-
+
public void testStringPropertyReplacement() throws Exception
{
System.setProperty(NUM_BUDDIES_PROP, "3");
System.setProperty(SYNC_COMMIT_PROP, "false");
System.setProperty(MAX_NODES_PROP, "1000");
System.setProperty(BUDDY_POOL_PROP, "replaced");
-
+
Configuration cfg = new XmlConfigurationParser().parseFile(STRING_REPLACED_FILE);
-
+
assertEquals(NodeLockingScheme.OPTIMISTIC, cfg.getNodeLockingScheme());
assertFalse(cfg.isSyncCommitPhase());
assertTrue(cfg.isSyncRollbackPhase());
assertEquals(15000, cfg.getLockAcquisitionTimeout());
String clusterCfg = cfg.getClusterConfig();
assertTrue(clusterCfg == null || clusterCfg.length() == 0);
-
+
EvictionConfig ec = cfg.getEvictionConfig();
- assertEquals(LRUPolicy.class.getName(), ec.getDefaultEvictionPolicyClass());
- EvictionRegionConfig erc = ec.getEvictionRegionConfigs().get(0);
- LRUConfiguration epc = (LRUConfiguration) erc.getEvictionPolicyConfig();
+ assert ec.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig() instanceof
LRUAlgorithmConfig;
+ EvictionRegionConfig erc = ec.getDefaultEvictionRegionConfig();
+ LRUAlgorithmConfig epc = (LRUAlgorithmConfig) erc.getEvictionAlgorithmConfig();
assertEquals(1000, epc.getMaxNodes());
-
+
CacheLoaderConfig clc = cfg.getCacheLoaderConfig();
IndividualCacheLoaderConfig iclc = clc.getFirstCacheLoaderConfig();
assertEquals(System.getProperty("java.io.tmpdir"),
iclc.getProperties().get("location"));
-
+
BuddyReplicationConfig brc = cfg.getBuddyReplicationConfig();
assertTrue(brc.isEnabled());
assertEquals("replaced", brc.getBuddyPoolName());
Modified:
core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java 2008-08-18
19:46:56 UTC (rev 6575)
+++
core/trunk/src/test/java/org/jboss/cache/config/parsing/SampleConfigFilesCorrectnessTest.java 2008-08-18
20:05:38 UTC (rev 6576)
@@ -21,17 +21,15 @@
*/
package org.jboss.cache.config.parsing;
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.AfterTest;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
-import org.jboss.cache.config.parsing.XmlConfigurationSchemaTest;
-import org.jboss.cache.config.parsing.XmlConfigurationParser;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
import java.io.File;
import java.io.FilenameFilter;
Modified:
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-08-18
19:46:56 UTC (rev 6575)
+++
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-08-18
20:05:38 UTC (rev 6576)
@@ -218,7 +218,7 @@
EvictionRegionConfig second = regionConfigs.get(0);
LRUAlgorithmConfig secondConfiguration = (LRUAlgorithmConfig)
second.getEvictionAlgorithmConfig();
- assert secondConfiguration.getMaxAge() == 0;
+ assert secondConfiguration.getMaxAge() == -1;
assert secondConfiguration.getTimeToLive() == 1002;
assert secondConfiguration.getMaxNodes() == 0;
Modified: core/trunk/src/test/resources/configs/string-property-replaced.xml
===================================================================
--- core/trunk/src/test/resources/configs/string-property-replaced.xml 2008-08-18 19:46:56
UTC (rev 6575)
+++ core/trunk/src/test/resources/configs/string-property-replaced.xml 2008-08-18 20:05:38
UTC (rev 6576)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:noNamespaceSchemaLocation="http://www.jboss.org/jbosscache/jboss...
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking
lockAcquisitionTimeout="${test.property.LockAcquisitionTimeout:15000}"
nodeLockingScheme="${test.property.NodeLockingScheme:OPTIMISTIC}"/>
<transaction syncCommitPhase="${test.property.SyncCommitPhase:true}"
syncRollbackPhase="true"/>