[jbosscache-commits] JBoss Cache SVN: r4580 - core/trunk/src/test/java/org/jboss/cache.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Tue Oct 9 10:45:24 EDT 2007
Author: manik.surtani at jboss.com
Date: 2007-10-09 10:45:24 -0400 (Tue, 09 Oct 2007)
New Revision: 4580
Removed:
core/trunk/src/test/java/org/jboss/cache/HungChannelTest.java
Log:
Test made redundant with join & state transfer
Deleted: core/trunk/src/test/java/org/jboss/cache/HungChannelTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/HungChannelTest.java 2007-10-08 23:15:49 UTC (rev 4579)
+++ core/trunk/src/test/java/org/jboss/cache/HungChannelTest.java 2007-10-09 14:45:24 UTC (rev 4580)
@@ -1,152 +0,0 @@
-package org.jboss.cache;
-
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.AssertJUnit.fail;
-
-import java.io.File;
-import java.net.URL;
-
-import org.jgroups.Address;
-import org.jgroups.Channel;
-import org.jgroups.ChannelException;
-import org.jgroups.JChannel;
-import org.jgroups.conf.ProtocolStackConfigurator;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import org.w3c.dom.Element;
-
-/**
- * Tests the behaviour of starting a cache when the JGroups channel is caused to hang.
- *
- * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
- */
-public class HungChannelTest
-{
- private CacheImpl<Object, Object> cache;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
- {
- cache = (CacheImpl<Object, Object>) DefaultCacheFactory.getInstance().createCache(false);
- cache.getConfiguration().setCacheMode("REPL_SYNC");
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown()
- {
- if (cache != null)
- {
- if (cache.channel != null)
- {
- cache.channel.close();
- cache.channel.disconnect();
- cache.channel = null;
- }
- cache.stop();
- cache = null;
- }
- }
-
- @Test(groups = {"functional"})
- public void testFailingStateTransfer()
- {
- try
- {
- cache.create();
- JChannel ch = new FailingStateChannel(cache.getConfiguration().getClusterConfig());
- ch.setOpt(Channel.GET_STATE_EVENTS, Boolean.TRUE);
- ch.setOpt(Channel.AUTO_RECONNECT, Boolean.TRUE);
- ch.setOpt(Channel.AUTO_GETSTATE, Boolean.TRUE);
- cache.getConfiguration().getRuntimeConfig().setChannel(ch);
-
- cache.start();// the state transfer here should fail, leading to an exception being thrown.
- fail("Expecting the startService() method to throw an exception");
- }
- catch (Exception e)
- {
- // normal behaviour
- }
-
- Channel c = cache.channel;// hold a reference to this since stopService will set this to null in the cache.
-
- assertFalse("Channel should not have connected!", c.isConnected());
- assertFalse("Channel should not be open", c.isOpen());
-
- cache.stop();
-
- assertFalse("Channel should not have connected!", c.isConnected());
- assertFalse("Channel should not be open", c.isOpen());
-
- assertNull("Should be null", cache.channel);
- }
-
- @Test(groups = {"functional"})
- public void testSucceedingStateTransfer()
- {
- try
- {
- cache.start();
- }
- catch (Exception e)
- {
- fail("NOT expecting the startService() method to throw an exception");
- }
-
- Channel c = cache.channel;// hold a reference to this since stopService will set this to null in the cache.
-
- assertTrue("Channel should have connected!", c.isConnected());
- assertTrue("Channel should be open", c.isOpen());
-
-
- cache.stop();
-
- assertFalse("Channel should not have connected!", c.isConnected());
- assertFalse("Channel should not be open", c.isOpen());
-
- assertNull("Should be null", cache.channel);
- }
-
- static class FailingStateChannel extends JChannel
- {
-
-
- public FailingStateChannel() throws ChannelException
- {
- super();
- }
-
- public FailingStateChannel(File file) throws ChannelException
- {
- super(file);
- }
-
- public FailingStateChannel(Element element) throws ChannelException
- {
- super(element);
- }
-
- public FailingStateChannel(URL url) throws ChannelException
- {
- super(url);
- }
-
- public FailingStateChannel(String string) throws ChannelException
- {
- super(string);
- }
-
- public FailingStateChannel(ProtocolStackConfigurator protocolStackConfigurator) throws ChannelException
- {
- super(protocolStackConfigurator);
- }
-
- public boolean getState(Address a, long l)
- {
- throw new RuntimeException("Dummy Exception getting state");
- }
- }
-
-}
More information about the jbosscache-commits
mailing list