Author: manik.surtani(a)jboss.com
Date: 2007-12-21 12:11:56 -0500 (Fri, 21 Dec 2007)
New Revision: 4915
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java
core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java
Log:
Fixed failing unit tests
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-12-21 16:34:38 UTC (rev
4914)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-12-21 17:11:56 UTC (rev
4915)
@@ -48,6 +48,7 @@
import org.jboss.cache.util.CachePrinter;
import org.jboss.cache.util.ThreadGate;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
+import org.jboss.cache.util.reflect.ReflectionUtil;
import org.jgroups.*;
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.RpcDispatcher;
@@ -216,7 +217,7 @@
private void injectDependencies(Notifier notifier, RegionManager regionManager,
TransactionManager transactionManager, Marshaller marshaller,
TransactionTable transactionTable,
StateTransferManager stateTransferManager, NodeFactory nodeFactory,
CacheSPI spi, CacheMessageListener messageListener,
@ComponentName("remoteDelegate")RemoteCacheInvocationDelegate remoteDelegate,
- Interceptor interceptorChain)
+ Interceptor interceptorChain, BuddyManager
buddyManager)
{
this.notifier = notifier;
this.regionManager = regionManager;
@@ -229,6 +230,7 @@
this.remoteDelegate = remoteDelegate;
this.marshaller = marshaller;
this.interceptorChain = interceptorChain;
+ this.buddyManager = buddyManager;
}
public Configuration getConfiguration()
@@ -3587,6 +3589,7 @@
if (channel != null)
{
+ ReflectionUtil.setValue(configuration, "accessible", true);
configuration.setUsingMultiplexer(true);
if (log.isDebugEnabled())
{
Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java 2007-12-21
16:34:38 UTC (rev 4914)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java 2007-12-21
17:11:56 UTC (rev 4915)
@@ -43,6 +43,16 @@
private Integer eventQueueSize;
private EvictionPolicyConfig evictionPolicyConfig;
+ public EvictionRegionConfig()
+ {
+ }
+
+ public EvictionRegionConfig(Fqn regionFqn, EvictionPolicyConfig evictionPolicyConfig)
+ {
+ this.regionFqn = regionFqn;
+ this.evictionPolicyConfig = evictionPolicyConfig;
+ }
+
public EvictionPolicyConfig getEvictionPolicyConfig()
{
return evictionPolicyConfig;
Modified: core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2007-12-21
16:34:38 UTC (rev 4914)
+++ core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2007-12-21
17:11:56 UTC (rev 4915)
@@ -5,17 +5,7 @@
import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;
-import com.sleepycat.je.Cursor;
-import com.sleepycat.je.Database;
-import com.sleepycat.je.DatabaseConfig;
-import com.sleepycat.je.DatabaseEntry;
-import com.sleepycat.je.DeadlockException;
-import com.sleepycat.je.Environment;
-import com.sleepycat.je.EnvironmentConfig;
-import com.sleepycat.je.JEVersion;
-import com.sleepycat.je.LockMode;
-import com.sleepycat.je.OperationStatus;
-import com.sleepycat.je.Transaction;
+import com.sleepycat.je.*;
import net.jcip.annotations.ThreadSafe;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -24,6 +14,7 @@
import org.jboss.cache.Modification;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.loader.AbstractCacheLoader;
+import org.jboss.cache.util.reflect.ReflectionUtil;
import java.io.File;
import java.io.IOException;
@@ -84,17 +75,17 @@
public void create() throws Exception
{
String license =
"\n*************************************************************************************\n"
+
- "Berkeley DB Java Edition version: " +
JEVersion.CURRENT_VERSION.toString() + "\n" +
- "JBoss Cache can use Berkeley DB Java Edition from Oracle
\n" +
-
"(http://www.oracle.com/database/berkeley-db/je/index.html)\n" +
- "for persistent, reliable and transaction-protected data
storage.\n" +
- "If you choose to use Berkeley DB Java Edition with JBoss
Cache, you must comply with the terms\n" +
- "of Oracle's public license, included in the file
LICENSE.txt.\n" +
- "If you prefer not to release the source code for your own
application in order to comply\n" +
- "with the Oracle public license, you may purchase a different
license for use of\n" +
- "Berkeley DB Java Edition with JBoss Cache.\n" +
- "See
http://www.oracle.com/database/berkeley-db/je/index.html
for pricing and license terms\n" +
-
"*************************************************************************************";
+ "Berkeley DB Java Edition version: " +
JEVersion.CURRENT_VERSION.toString() + "\n" +
+ "JBoss Cache can use Berkeley DB Java Edition from Oracle \n" +
+ "(http://www.oracle.com/database/berkeley-db/je/index.html)\n" +
+ "for persistent, reliable and transaction-protected data
storage.\n" +
+ "If you choose to use Berkeley DB Java Edition with JBoss Cache, you
must comply with the terms\n" +
+ "of Oracle's public license, included in the file
LICENSE.txt.\n" +
+ "If you prefer not to release the source code for your own application
in order to comply\n" +
+ "with the Oracle public license, you may purchase a different license
for use of\n" +
+ "Berkeley DB Java Edition with JBoss Cache.\n" +
+ "See
http://www.oracle.com/database/berkeley-db/je/index.html for
pricing and license terms\n" +
+
"*************************************************************************************";
System.out.println(license);
log.trace("Creating BdbjeCacheLoader instance.");
@@ -123,6 +114,7 @@
if (config.getLocation() == null)
{
configStr = System.getProperty("java.io.tmpdir");
+ ReflectionUtil.setValue(config, "accessible", true);
config.setLocation(configStr);
}
@@ -333,7 +325,7 @@
OperationStatus status =
cursor.getSearchKeyRange(keyEntry, dataEntry, null);
if (status != OperationStatus.SUCCESS ||
- !startsWith(keyEntry, prefixEntry))
+ !startsWith(keyEntry, prefixEntry))
{
break;
}
@@ -728,7 +720,7 @@
cursor.delete();
status = cursor.getNext(foundKey, foundData, LockMode.RMW);
if (status == OperationStatus.SUCCESS &&
- !startsWith(foundKey, keyEntry))
+ !startsWith(foundKey, keyEntry))
{
status = OperationStatus.NOTFOUND;
}
@@ -1070,8 +1062,8 @@
/* Write the bytes of the prefix followed by the child name. */
TupleOutput tupleOutput = new TupleOutput();
tupleOutput.writeFast(prefix.getData(),
- prefix.getOffset(),
- prefix.getSize());
+ prefix.getOffset(),
+ prefix.getSize());
tupleOutput.writeString(namePart);
/* Return the tuple as an entry. */
Modified:
core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java 2007-12-21
16:34:38 UTC (rev 4914)
+++
core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java 2007-12-21
17:11:56 UTC (rev 4915)
@@ -13,12 +13,11 @@
import org.jboss.cache.Node;
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
-import org.jboss.cache.config.EvictionPolicyConfig;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.eviction.DummyEvictionConfiguration;
import org.jboss.cache.eviction.EvictedEventNode;
import org.jboss.cache.eviction.NodeEventType;
-import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.factories.InterceptorChainFactory;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
@@ -30,13 +29,15 @@
import org.testng.annotations.Test;
import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
/**
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision: $
*/
-@Test(groups = {"functional"})
+@Test(groups = "functional")
public class EvictionInterceptorTest
{
private static final String fqn1 = "/a/b/c";
@@ -55,53 +56,30 @@
cache = (CacheSPI<Object, Object>) new
DefaultCacheFactory().createCache(false);
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
+ cache.getConfiguration().setCacheMode("LOCAL");
+ EvictionConfig ec = new EvictionConfig();
- regionManager = cache.getRegionManager();
- EvictionPolicyConfig config = new DummyEvictionConfiguration();
- regionManager.setUsingEvictions(true);
+ List<EvictionRegionConfig> ercs = new
LinkedList<EvictionRegionConfig>();
+ ercs.add(new EvictionRegionConfig(Fqn.ROOT, new DummyEvictionConfiguration()));
+ ercs.add(new EvictionRegionConfig(Fqn.fromString("/a/b/c"), new
DummyEvictionConfiguration()));
+ ercs.add(new EvictionRegionConfig(Fqn.fromString("/a/b/c/d"), new
DummyEvictionConfiguration()));
+ ercs.add(new EvictionRegionConfig(Fqn.fromString("/a/b"), new
DummyEvictionConfiguration()));
+ ercs.add(new EvictionRegionConfig(Fqn.fromString("/d/e/f"), new
DummyEvictionConfiguration()));
+ ercs.add(new EvictionRegionConfig(Fqn.fromString("/d/e/g"), new
DummyEvictionConfiguration()));
+ ercs.add(new EvictionRegionConfig(Fqn.fromString("/d/e"), new
DummyEvictionConfiguration()));
- regionManager.getRegion(Fqn.ROOT, true).setEvictionPolicy(config);
-
- regionManager.getRegion("/a/b/c", true).setEvictionPolicy(config);
- regionManager.getRegion("/a/b/c/d", true).setEvictionPolicy(config);
- regionManager.getRegion("/a/b", true).setEvictionPolicy(config);
-
- regionManager.getRegion("/d/e/f", true).setEvictionPolicy(config);
- regionManager.getRegion("/d/e/g", true).setEvictionPolicy(config);
- regionManager.getRegion("/d/e", true).setEvictionPolicy(config);
-
- // make the interceptor chain (separate from the CacheSPI object.
-
- interceptor = new CacheMgmtInterceptor();
-
- TxInterceptor ti = new TxInterceptor();
- interceptor.setNext(ti);
-
- UnlockInterceptor ui = new UnlockInterceptor();
- ti.setNext(ui);
-
- PessimisticLockInterceptor pli = new PessimisticLockInterceptor();
- ui.setNext(pli);
-
- EvictionInterceptor ei = new EvictionInterceptor();
- pli.setNext(ei);
-
- CallInterceptor ci = new CallInterceptor();
- ei.setNext(ci);
-
- cache.getConfiguration().setCacheMode("LOCAL");
+ ec.setEvictionRegionConfigs(ercs);
+ cache.getConfiguration().setEvictionConfig(ec);
cache.start();
- ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
-
-
cr.getComponent(InterceptorChainFactory.class).correctInterceptorChaining(interceptor);
+ interceptor =
TestingUtil.extractComponentRegistry(cache).getComponent(Interceptor.class);
+ regionManager = cache.getRegionManager();
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.removeNode(Fqn.ROOT);
- cache.stop();
+ TestingUtil.killCaches(cache);
}
@SuppressWarnings("unchecked")
Modified:
core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java 2007-12-21
16:34:38 UTC (rev 4914)
+++
core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java 2007-12-21
17:11:56 UTC (rev 4915)
@@ -54,7 +54,7 @@
*
* @since 2.0.0
*/
-@Test(groups = {"functional"})
+@Test(groups = "functional")
public class RemoteCacheListenerTest
{
protected boolean optLocking = false;
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2007-12-21
16:34:38 UTC (rev 4914)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2007-12-21
17:11:56 UTC (rev 4915)
@@ -14,6 +14,7 @@
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.cache.xml.XmlHelper;
@@ -41,7 +42,7 @@
* @author <a href="mailto:{hmesha@novell.com}">{Hany Mesha}</a>
* @version $Id$
*/
-@Test(groups = {"functional"})
+@Test(groups = "functional")
abstract public class PassivationTestsBase
{
@@ -88,10 +89,8 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache.removeNode(Fqn.ROOT);
loader.remove(Fqn.ROOT);
- cache.stop();
- cache.destroy();
+ TestingUtil.killCaches(cache);
}
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java 2007-12-21
16:34:38 UTC (rev 4914)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java 2007-12-21
17:11:56 UTC (rev 4915)
@@ -1,13 +1,14 @@
package org.jboss.cache.passivation;
-import java.io.File;
-import java.io.FileFilter;
-
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.factories.XmlConfigurationParser;
import org.jboss.cache.xml.XmlHelper;
+import org.testng.annotations.Test;
import org.w3c.dom.Element;
+import java.io.File;
+import java.io.FileFilter;
+
/**
* Runs the same tests as {@link PassivationToFileCacheLoaderTest}, but with
* Berkeley DB instead of a file-based CacheLoader
@@ -15,6 +16,7 @@
* @author <a href="mailto:{hmesha@novell.com}">{Hany Mesha}</a>
* @version $Id$
*/
+@Test(groups = "functional")
public class PassivationToBdbjeCacheLoaderTest extends PassivationTestsBase
{
private String tmp_location = System.getProperty("java.io.tmpdir",
"c:\\tmp");
@@ -59,20 +61,20 @@
protected CacheLoaderConfig getCacheLoaderConfig(String loc) throws Exception
{
String xml = " <config>\n" +
- " \n" +
- "
<passivation>true</passivation>\n" +
- " <preload></preload>\n" +
- "\n" +
- " <cacheloader>\n" +
- "
<class>org.jboss.cache.loader.bdbje.BdbjeCacheLoader</class>\n" +
- " <properties>\n" +
- " </properties>\n" +
- " <async>false</async>\n" +
- "
<fetchPersistentState>false</fetchPersistentState>\n" +
- "
<ignoreModifications>false</ignoreModifications>\n" +
- " </cacheloader>\n" +
- " \n" +
- " </config>";
+ " \n" +
+ " <passivation>true</passivation>\n" +
+ " <preload></preload>\n" +
+ "\n" +
+ " <cacheloader>\n" +
+ "
<class>org.jboss.cache.loader.bdbje.BdbjeCacheLoader</class>\n" +
+ " <properties>\n" +
+ " </properties>\n" +
+ " <async>false</async>\n" +
+ "
<fetchPersistentState>false</fetchPersistentState>\n" +
+ "
<ignoreModifications>false</ignoreModifications>\n" +
+ " </cacheloader>\n" +
+ " \n" +
+ " </config>";
Element element = XmlHelper.stringToElement(xml);
return XmlConfigurationParser.parseCacheLoaderConfig(element);
}