[jbosscache-commits] JBoss Cache SVN: r5322 - in core/trunk/src: main/java/org/jboss/cache/factories and 2 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Thu Feb 7 09:14:03 EST 2008
Author: manik.surtani at jboss.com
Date: 2008-02-07 09:14:03 -0500 (Thu, 07 Feb 2008)
New Revision: 5322
Modified:
core/trunk/src/main/java/org/jboss/cache/RegionManager.java
core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
core/trunk/src/main/java/org/jboss/cache/marshall/io/ObjectStreamPool.java
core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
Log:
Fixed broken tests
Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-02-07 13:36:10 UTC (rev 5321)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-02-07 14:14:03 UTC (rev 5322)
@@ -330,7 +330,7 @@
{
//r.activate();
r.setStatus(Region.Status.ACTIVATING);
- if (cache.getConfiguration().isFetchInMemoryState())
+ if (configuration.isFetchInMemoryState())
{
activateRegion(r.getFqn(), suppressRegionNotEmptyException);
}
@@ -343,7 +343,7 @@
r = getRegion(fqn, true);
// FIXME - persistent state transfer counts too!
r.setStatus(Region.Status.ACTIVATING);
- if (cache.getConfiguration().isFetchInMemoryState())
+ if (configuration.isFetchInMemoryState())
{
activateRegion(r.getFqn(), suppressRegionNotEmptyException);
}
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-02-07 13:36:10 UTC (rev 5321)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-02-07 14:14:03 UTC (rev 5322)
@@ -89,6 +89,11 @@
registerComponent(configuration, Configuration.class);
}
+ public State getOverallState()
+ {
+ return overallState;
+ }
+
/**
* This is hard coded for now, since scanning the classpath for factories annotated with {@link org.jboss.cache.factories.annotations.DefaultFactoryFor}
* does not work with all class loaders. This is a temporary solution until a more elegant one can be designed.
@@ -637,7 +642,7 @@
/**
* Represents the state of a component
*/
- enum State
+ public enum State
{
DESTROYED, STOPPED, CONSTRUCTED, WIRED, STARTED;
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/io/ObjectStreamPool.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/io/ObjectStreamPool.java 2008-02-07 13:36:10 UTC (rev 5321)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/io/ObjectStreamPool.java 2008-02-07 14:14:03 UTC (rev 5322)
@@ -31,13 +31,13 @@
}
@Inject
- public void injectDependencies(Configuration configuration)
+ void injectDependencies(Configuration configuration)
{
this.configuration = configuration;
}
@Start
- public void start() throws InterruptedException, IOException
+ void start() throws InterruptedException, IOException
{
if (configuration != null)
{
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java 2008-02-07 13:36:10 UTC (rev 5321)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java 2008-02-07 14:14:03 UTC (rev 5322)
@@ -10,23 +10,21 @@
*/
public abstract class AbstractVersionAwareMarshallerTest
{
- protected VersionAwareMarshaller createVAM(String replVersion)
+ protected ComponentRegistry cr;
+
+ protected VersionAwareMarshaller createVAMandRestartCache(String replVersion)
{
- Configuration c = new Configuration();
+ Configuration c = cr.getComponent(Configuration.class);
c.setReplVersionString(replVersion);
- return createVAM(c, new RegionManager());
+ return createVAMandRestartCache(new RegionManager());
}
- protected VersionAwareMarshaller createVAM(Configuration c, RegionManager rm)
+ protected VersionAwareMarshaller createVAMandRestartCache(RegionManager rm)
{
- ComponentRegistry cr = new ComponentRegistry(c);
cr.registerComponent(rm, RegionManager.class);
- c.setReplVersionString(c.getReplVersionString());
- VersionAwareMarshaller vam = new VersionAwareMarshaller();
-
- cr.wireDependencies(vam);
- vam.init();
- vam.initReplicationVersions();
+ VersionAwareMarshaller vam = (VersionAwareMarshaller) cr.getComponent(Marshaller.class);
+ if (cr.getOverallState() == ComponentRegistry.State.STARTED) cr.stop();
+ cr.start();
return vam;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java 2008-02-07 13:36:10 UTC (rev 5321)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java 2008-02-07 14:14:03 UTC (rev 5322)
@@ -31,7 +31,8 @@
public class ActiveInactiveTest extends AbstractVersionAwareMarshallerTest
{
RegionManager rman;
- CacheSPI c;
+ CacheSPI cache;
+ Configuration c;
Fqn<String> A = Fqn.fromString("/a");
Fqn<String> I = Fqn.fromString("/i");
Fqn<String> A_B = new Fqn<String>(A, "b");
@@ -39,20 +40,22 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- c = (CacheSPI) new DefaultCacheFactory().createCache(false);
- c.getConfiguration().setUseRegionBasedMarshalling(true);
- c.getConfiguration().setFetchInMemoryState(false);
- c.start();
- rman = TestingUtil.extractComponentRegistry(c).getComponent(RegionManager.class);
+ cache = (CacheSPI) new DefaultCacheFactory().createCache(false);
+ c = cache.getConfiguration();
+ c.setUseRegionBasedMarshalling(true);
+ c.setFetchInMemoryState(false);
+ cache.start();
+ cr = TestingUtil.extractComponentRegistry(cache);
+ rman = TestingUtil.extractComponentRegistry(cache).getComponent(RegionManager.class);
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- if (c != null)
+ if (cache != null)
{
- c.stop();
- c = null;
+ cache.stop();
+ cache = null;
rman = null;
}
}
@@ -163,10 +166,10 @@
Region region_A = rman.getRegion(A, true);
region_A.registerContextClassLoader(this.getClass().getClassLoader());
assertFalse("New regions created should be inactive by default", region_A.isActive());
- Configuration c = new Configuration();
+ cache.stop();
c.setUseRegionBasedMarshalling(true);
c.setInactiveOnStartup(true);
- VersionAwareMarshaller testee = createVAM(c, rman);
+ VersionAwareMarshaller testee = createVAMandRestartCache(rman);
byte[] callBytes = testee.objectToByteBuffer(replicate);
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-02-07 13:36:10 UTC (rev 5321)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-02-07 14:14:03 UTC (rev 5322)
@@ -10,7 +10,6 @@
import org.jboss.cache.RegionManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.marshall.io.ObjectStreamPool;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -37,12 +36,9 @@
c.setUseRegionBasedMarshalling(false);
c.setInactiveOnStartup(false);
c.setReplVersionString(currentVersion);
+ cr = new ComponentRegistry(c);
//c.setUseReferenceCounting(true);
- marshaller = createVAM(c, regionManager);
- ObjectStreamPool pool = new ObjectStreamPool();
- ComponentRegistry reg = new ComponentRegistry(c);
- marshaller.injectComponents(reg, pool);
- pool.start();
+ marshaller = createVAMandRestartCache(regionManager);
}
@AfterMethod(alwaysRun = true)
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2008-02-07 13:36:10 UTC (rev 5321)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2008-02-07 14:14:03 UTC (rev 5322)
@@ -7,8 +7,13 @@
package org.jboss.cache.marshall;
import org.jboss.cache.Version;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.marshall.io.ObjectStreamPool;
+import org.jboss.cache.misc.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.ObjectInputStream;
@@ -21,60 +26,64 @@
@Test(groups = {"functional"})
public class VersionAwareMarshallerTest extends AbstractVersionAwareMarshallerTest
{
+ @BeforeMethod
+ public void setUp()
+ {
+ cr = new ComponentRegistry(new Configuration());
+ }
+
+ @AfterMethod
+ public void tearDown()
+ {
+ cr = null;
+ }
+
public void testMarshallerSelection()
{
- VersionAwareMarshaller marshaller = createVAM("2.1.0.GA");
+ VersionAwareMarshaller marshaller = createVAMandRestartCache("2.1.0.GA");
assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
- marshaller = createVAM("2.0.0.GA");
+ marshaller = createVAMandRestartCache("2.0.0.GA");
assertEquals(CacheMarshaller200.class, marshaller.defaultMarshaller.getClass());
- marshaller = createVAM("1.4.0.GA");
+ marshaller = createVAMandRestartCache("1.4.0.GA");
assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
- marshaller = createVAM("1.5.0.GA");
+ marshaller = createVAMandRestartCache("1.5.0.GA");
assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
- marshaller = createVAM("1.3.0.GA");
+ marshaller = createVAMandRestartCache("1.3.0.GA");
assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
- marshaller = createVAM("1.3.0.SP2");
+ marshaller = createVAMandRestartCache("1.3.0.SP2");
assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
- marshaller = createVAM("1.3.1.GA");
+ marshaller = createVAMandRestartCache("1.3.1.GA");
assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
- marshaller = createVAM("1.2.4.SP2");
+ marshaller = createVAMandRestartCache("1.2.4.SP2");
assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
- marshaller = createVAM("1.2.3");
+ marshaller = createVAMandRestartCache("1.2.3");
assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
}
public void testVersionHeaderDefaultCurrent() throws Exception
{
- ObjectStreamPool pool = new ObjectStreamPool();
- pool.start();
+ VersionAwareMarshaller marshaller = createVAMandRestartCache(Version.getVersionString(Version.getVersionShort()));
- VersionAwareMarshaller marshaller = createVAM(Version.getVersionString(Version.getVersionShort()));
- marshaller.injectComponents(null, pool);
-
byte[] bytes = marshaller.objectToByteBuffer("Hello");
-
+ ObjectStreamPool pool = (ObjectStreamPool) TestingUtil.extractField(marshaller, "pool");
ObjectInputStream in = pool.getInputStream(bytes);
assertEquals("Version header short should be '21'", 21, in.readShort());
}
public void testVersionHeader200() throws Exception
{
- ObjectStreamPool pool = new ObjectStreamPool();
- pool.start();
+ VersionAwareMarshaller marshaller = createVAMandRestartCache("2.0.0.GA");
- VersionAwareMarshaller marshaller = createVAM("2.0.0.GA");
- marshaller.injectComponents(null, pool);
-
byte[] bytes = marshaller.objectToByteBuffer("Hello");
-
+ ObjectStreamPool pool = (ObjectStreamPool) TestingUtil.extractField(marshaller, "pool");
ObjectInputStream in = pool.getInputStream(bytes);
assertEquals("Version header short should be '20'", 20, in.readShort());
}
More information about the jbosscache-commits
mailing list