JBoss hornetq SVN: r11861 - in trunk/tests: integration-tests/src/test/java/org/hornetq/tests/integration/client and 7 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2011-12-06 10:02:45 -0500 (Tue, 06 Dec 2011)
New Revision: 11861
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/cluster/reattach/MultiThreadRandomReattachTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ProducerCloseTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ProducerFlowControlTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ProducerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/QueueBrowserTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ReceiveImmediateTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ReceiveTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/RedeliveryConsumerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/OrderReattachTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/core/deployers/impl/QueueDeployerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/paging/PagingCounterTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/PingTest.java
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/MultiThreadConsumerStressTest.java
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageCursorStressTest.java
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageStressTest.java
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/remote/PingStressTest.java
Log:
Remove unnecessary tearDown code
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/cluster/reattach/MultiThreadRandomReattachTestBase.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/cluster/reattach/MultiThreadRandomReattachTestBase.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/cluster/reattach/MultiThreadRandomReattachTestBase.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -44,8 +44,8 @@
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
* @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- *
*
+ *
*/
public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReattachSupport
{
@@ -1198,7 +1198,7 @@
{
return 2;
}
-
+
protected int getNumThreads()
{
return 10;
@@ -1212,21 +1212,6 @@
log.info("************ Starting test " + getName());
}
- @Override
- protected void tearDown() throws Exception
- {
- if (liveServer != null && liveServer.isStarted())
- {
- liveServer.stop();
- }
-
- liveServer = null;
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
private void runTestMultipleThreads(final RunnableT runnable,
final int numThreads,
final boolean failOnCreateConnection) throws Exception
@@ -1252,7 +1237,7 @@
ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"));
locator.setReconnectAttempts(-1);
locator.setConfirmationWindowSize(1024 * 1024);
- return locator;
+ return addServerLocator(locator);
}
@Override
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -119,15 +119,6 @@
locator = createInVMNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- stopComponent(server);
- closeSessionFactory(sf);
- closeServerLocator(locator);
- super.tearDown();
- }
-
public void testPreparePersistent() throws Exception
{
clearData();
@@ -4075,7 +4066,7 @@
PagingStore pgStoreAddress = server.getPagingManager().getPageStore(ADDRESS);
pgStoreAddress.startPaging();
- PagingStore pgStoreDLA = server.getPagingManager().getPageStore(new SimpleString("DLA"));
+ server.getPagingManager().getPageStore(new SimpleString("DLA"));
ClientProducer producer = session.createProducer(PagingTest.ADDRESS);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ProducerCloseTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ProducerCloseTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ProducerCloseTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -16,39 +16,29 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
-import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.HornetQServers;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.tests.util.UnitTestCase;
/**
- *
+ *
* @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
*/
public class ProducerCloseTest extends ServiceTestBase
{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
private HornetQServer server;
-
+ private ClientSessionFactory sf;
private ClientSession session;
private ServerLocator locator;
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
public void testCanNotUseAClosedProducer() throws Exception
{
final ClientProducer producer = session.createProducer(RandomUtil.randomSimpleString());
@@ -79,35 +69,10 @@
Configuration config = createDefaultConfig();
config.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName()));
config.setSecurityEnabled(false);
- server = HornetQServers.newHornetQServer(config, false);
+ server = createServer(false, config);
server.start();
- locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
- sf = locator.createSessionFactory();
+ locator = createInVMNonHALocator();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, true);
}
-
- private ClientSessionFactory sf;
-
- @Override
- protected void tearDown() throws Exception
- {
- session.close();
-
- sf.close();
-
- locator.close();
-
- server.stop();
-
- server = null;
-
- session = null;
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ProducerFlowControlTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ProducerFlowControlTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ProducerFlowControlTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -73,20 +73,6 @@
locator = createFactory(isNetty());
}
- @Override
- protected void tearDown() throws Exception
- {
- if (sf != null)
- {
- sf.close();
- }
- closeServerLocator(locator);
-
- stopComponent(server);
-
- super.tearDown();
- }
-
// TODO need to test crashing a producer with unused credits returns them to the pool
public void testFlowControlSingleConsumer() throws Exception
@@ -240,7 +226,7 @@
locator.setMinLargeMessageSize(minLargeMessageSize);
}
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
session.start();
@@ -377,7 +363,7 @@
locator.setConsumerWindowSize(1024);
locator.setAckBatchSize(1024);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
final SimpleString queueName = new SimpleString("testqueue");
@@ -442,7 +428,7 @@
locator.setConsumerWindowSize(1024);
locator.setAckBatchSize(1024);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
@@ -470,7 +456,7 @@
server.start();
waitForServer(server);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
@@ -534,7 +520,7 @@
server.start();
waitForServer(server);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
@@ -567,7 +553,7 @@
server.start();
waitForServer(server);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
@@ -603,7 +589,7 @@
server.start();
waitForServer(server);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
@@ -636,7 +622,7 @@
server.start();
waitForServer(server);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
@@ -672,7 +658,7 @@
server.start();
waitForServer(server);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
@@ -720,7 +706,7 @@
for (int i = 0; i < 10; i++)
{
- ClientProducer prod = session.createProducer("address" + (i + ClientProducerCreditManagerImpl.MAX_UNREFERENCED_CREDITS_CACHE_SIZE));
+ session.createProducer("address" + (i + ClientProducerCreditManagerImpl.MAX_UNREFERENCED_CREDITS_CACHE_SIZE));
Assert.assertEquals(ClientProducerCreditManagerImpl.MAX_UNREFERENCED_CREDITS_CACHE_SIZE + i + 1,
((ClientSessionInternal)session).getProducerCreditManager().creditsMapSize());
@@ -735,7 +721,7 @@
server.start();
waitForServer(server);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
@@ -760,7 +746,7 @@
server.start();
waitForServer(server);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
@@ -809,7 +795,7 @@
server.start();
waitForServer(server);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ProducerTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ProducerTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ProducerTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -20,8 +20,11 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.Interceptor;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
-import org.hornetq.core.logging.Logger;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.protocol.core.Packet;
import org.hornetq.core.protocol.core.impl.PacketImpl;
import org.hornetq.core.server.HornetQServer;
@@ -33,8 +36,6 @@
*/
public class ProducerTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(ConsumerTest.class);
-
private HornetQServer server;
private final SimpleString QUEUE = new SimpleString("ConsumerTestQueue");
@@ -49,16 +50,6 @@
server.start();
}
- @Override
- protected void tearDown() throws Exception
- {
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
public void testProducerWithSmallWindowSizeAndLargeMessage() throws Exception
{
final CountDownLatch latch = new CountDownLatch(1);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/QueueBrowserTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/QueueBrowserTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/QueueBrowserTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -15,9 +15,12 @@
import junit.framework.Assert;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.*;
-import org.hornetq.core.logging.Logger;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
import org.hornetq.tests.util.ServiceTestBase;
@@ -28,8 +31,6 @@
*/
public class QueueBrowserTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(QueueBrowserTest.class);
-
private HornetQServer server;
private final SimpleString QUEUE = new SimpleString("ConsumerTestQueue");
@@ -48,25 +49,13 @@
locator = createInVMNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
private ClientSessionFactory sf;
public void testSimpleConsumerBrowser() throws Exception
{
locator.setBlockOnNonDurableSend(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
session.createQueue(QUEUE, QUEUE, null, false);
@@ -105,14 +94,13 @@
session.close();
- sf.close();
}
public void testConsumerBrowserWithSelector() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -153,14 +141,13 @@
session.close();
- sf.close();
}
public void testConsumerBrowserWithStringSelector() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -191,14 +178,13 @@
session.close();
- sf.close();
}
public void testConsumerMultipleBrowser() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -229,14 +215,13 @@
}
session.close();
- sf.close();
}
public void testConsumerMultipleBrowserWithSelector() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -275,7 +260,6 @@
session.close();
- sf.close();
}
@@ -291,7 +275,7 @@
private void testConsumerBrowserMessagesArentAcked(final boolean preACK) throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(null, null, false, true, true, preACK, 0);
@@ -321,12 +305,11 @@
session.close();
- sf.close();
}
public void testConsumerBrowserMessageAckDoesNothing() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -358,14 +341,13 @@
session.close();
- sf.close();
}
-
+
public void testBrowseWithZeroConsumerWindowSize() throws Exception
{
locator.setConsumerWindowSize(0);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -376,23 +358,23 @@
final int numMessages = 100;
byte[] bytes = new byte[240];
-
+
for (int i = 0; i < numMessages; i++)
{
ClientMessage message = session.createMessage(false);
-
+
message.getBodyBuffer().writeBytes(bytes);
-
+
message.putIntProperty("foo", i);
-
+
producer.send(message);
}
//Create a normal non browsing consumer
- ClientConsumer consumer = session.createConsumer(QUEUE);
-
+ session.createConsumer(QUEUE);
+
session.start();
-
+
ClientConsumer browser = session.createConsumer(QUEUE, true);
for (int i = 0; i < numMessages; i++)
@@ -403,8 +385,6 @@
}
session.close();
-
- sf.close();
}
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ReceiveImmediateTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ReceiveImmediateTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ReceiveImmediateTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -25,9 +25,7 @@
import org.hornetq.api.core.client.MessageHandler;
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.server.Queue;
import org.hornetq.tests.util.ServiceTestBase;
@@ -37,8 +35,6 @@
*/
public class ReceiveImmediateTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(ReceiveImmediateTest.class);
-
private HornetQServer server;
private final SimpleString QUEUE = new SimpleString("ReceiveImmediateTest.queue");
@@ -53,32 +49,18 @@
super.setUp();
Configuration config = createDefaultConfig(false);
- server = HornetQServers.newHornetQServer(config, false);
-
+ server = createServer(false, config);
server.start();
-
locator = createInVMNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
private ClientSessionFactory sf;
public void testConsumerReceiveImmediateWithNoMessages() throws Exception
{
doConsumerReceiveImmediateWithNoMessages(false);
}
-
+
public void testConsumerReceiveImmediate() throws Exception
{
doConsumerReceiveImmediate(false);
@@ -96,11 +78,10 @@
public void testConsumerReceiveImmediateWithSessionStop() throws Exception
{
-
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnAcknowledge(true);
locator.setAckBatchSize(0);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
session.createQueue(ADDRESS, QUEUE, null, false);
@@ -122,75 +103,70 @@
consumer.close();
session.close();
-
- sf.close();
-
}
-
+
// https://jira.jboss.org/browse/HORNETQ-450
public void testReceivedImmediateFollowedByReceive() throws Exception
{
locator.setBlockOnNonDurableSend(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
session.createQueue(ADDRESS, QUEUE, null, false);
-
+
ClientProducer producer = session.createProducer(ADDRESS);
ClientMessage message = session.createMessage(false);
-
+
producer.send(message);
ClientConsumer consumer = session.createConsumer(QUEUE, null, false);
-
+
session.start();
-
+
ClientMessage received = consumer.receiveImmediate();
assertNotNull(received);
-
+
received.acknowledge();
-
+
received = consumer.receive(1);
-
- assertNull(received);
- session.close();
+ assertNull(received);
- sf.close();
+ session.close();
}
-
+
// https://jira.jboss.org/browse/HORNETQ-450
public void testReceivedImmediateFollowedByAsyncConsume() throws Exception
{
-
+
locator.setBlockOnNonDurableSend(true);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
session.createQueue(ADDRESS, QUEUE, null, false);
-
+
ClientProducer producer = session.createProducer(ADDRESS);
ClientMessage message = session.createMessage(false);
-
+
producer.send(message);
ClientConsumer consumer = session.createConsumer(QUEUE, null, false);
-
+
session.start();
-
+
ClientMessage received = consumer.receiveImmediate();
assertNotNull(received);
-
+
received.acknowledge();
-
+
final AtomicBoolean receivedAsync = new AtomicBoolean(false);
-
+
consumer.setMessageHandler(new MessageHandler()
{
public void onMessage(ClientMessage message)
@@ -198,14 +174,12 @@
receivedAsync.set(true);
}
});
-
+
Thread.sleep(1000);
-
- assertFalse(receivedAsync.get());
- session.close();
+ assertFalse(receivedAsync.get());
- sf.close();
+ session.close();
}
private void doConsumerReceiveImmediateWithNoMessages(final boolean browser) throws Exception
@@ -213,7 +187,7 @@
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnAcknowledge(true);
locator.setAckBatchSize(0);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, false);
@@ -226,8 +200,6 @@
Assert.assertNull(message);
session.close();
-
- sf.close();
}
private void doConsumerReceiveImmediate(final boolean browser) throws Exception
@@ -236,7 +208,7 @@
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnAcknowledge(true);
locator.setAckBatchSize(0);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
session.createQueue(ADDRESS, QUEUE, null, false);
@@ -277,9 +249,6 @@
consumer.close();
session.close();
-
- sf.close();
-
}
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ReceiveTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ReceiveTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ReceiveTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -16,7 +16,13 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.MessageHandler;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
@@ -31,28 +37,20 @@
private ServerLocator locator;
+ private HornetQServer server;
+
@Override
protected void setUp() throws Exception
{
super.setUp();
locator = createInVMNonHALocator();
+ server = createServer(false);
+ server.start();
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- super.tearDown();
- }
-
public void testBasicReceive() throws Exception
{
- HornetQServer server = createServer(false);
- try
- {
- server.start();
ClientSessionFactory cf = locator.createSessionFactory();
ClientSession sendSession = cf.createSession(false, true, true);
ClientProducer cp = sendSession.createProducer(addressA);
@@ -64,22 +62,11 @@
Assert.assertNotNull(cc.receive());
session.close();
sendSession.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
public void testReceiveTimesoutCorrectly() throws Exception
{
- HornetQServer server = createServer(false);
- try
- {
- server.start();
+
ClientSessionFactory cf = locator.createSessionFactory();
ClientSession session = cf.createSession(false, true, true);
session.createQueue(addressA, queueA, false);
@@ -89,23 +76,11 @@
cc.receive(1000);
Assert.assertTrue(System.currentTimeMillis() - time >= 1000);
session.close();
-
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
public void testReceiveOnClosedException() throws Exception
{
- HornetQServer server = createServer(false);
- try
- {
- server.start();
+
ClientSessionFactory cf = locator.createSessionFactory();
ClientSession session = cf.createSession(false, true, true);
session.createQueue(addressA, queueA, false);
@@ -121,24 +96,12 @@
{
Assert.assertEquals(HornetQException.OBJECT_CLOSED, e.getCode());
}
- session.close();
-
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+ session.close();
}
public void testReceiveThrowsExceptionWhenHandlerSet() throws Exception
{
- HornetQServer server = createServer(false);
- try
- {
- server.start();
+
ClientSessionFactory cf = locator.createSessionFactory();
ClientSession session = cf.createSession(false, true, true);
session.createQueue(addressA, queueA, false);
@@ -160,23 +123,11 @@
Assert.assertEquals(HornetQException.ILLEGAL_STATE, e.getCode());
}
session.close();
-
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
public void testReceiveImmediate() throws Exception
{
- HornetQServer server = createServer(false);
- try
- {
- server.start();
+
// forces perfect round robin
locator.setConsumerWindowSize(1);
ClientSessionFactory cf = locator.createSessionFactory();
@@ -199,13 +150,5 @@
}
session.close();
sendSession.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/RedeliveryConsumerTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/RedeliveryConsumerTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/RedeliveryConsumerTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -41,7 +41,7 @@
* A RedeliveryConsumerTest
*
* @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- *
+ *
* Created Feb 17, 2009 6:06:11 PM
*
*
@@ -150,7 +150,7 @@
session.close();
server.stop();
server.start();
- factory = locator.createSessionFactory();
+ factory = createSessionFactory(locator);
session = factory.createSession(false, false, false);
session.start();
consumer = session.createConsumer(ADDRESS);
@@ -173,7 +173,7 @@
session.close();
server.stop();
server.start();
- factory = locator.createSessionFactory();
+ factory = createSessionFactory(locator);
session = factory.createSession(false, false, false);
session.start();
consumer = session.createConsumer(ADDRESS);
@@ -226,7 +226,7 @@
server.start();
- factory = locator.createSessionFactory();
+ factory = createSessionFactory(locator);
session = factory.createSession(false, true, false);
session.start();
@@ -242,7 +242,7 @@
{
internaltestInfiniteDedeliveryMessageOnPersistent(false);
}
-
+
private void internaltestInfiniteDedeliveryMessageOnPersistent(final boolean strict) throws Exception
{
setUp(strict);
@@ -255,7 +255,7 @@
session.commit();
session.close();
-
+
int expectedCount = 1;
for (int i = 0 ; i < 700; i++)
{
@@ -277,9 +277,9 @@
factory.close();
server.stop();
-
+
setUp(false);
-
+
for (int i = 0 ; i < 700; i++)
{
session = factory.createSession(false, false, false);
@@ -293,27 +293,27 @@
server.stop();
-
- JournalImpl journal = new JournalImpl(server.getConfiguration().getJournalFileSize(),
- 2,
+
+ JournalImpl journal = new JournalImpl(server.getConfiguration().getJournalFileSize(),
+ 2,
0,
- 0,
+ 0,
new NIOSequentialFileFactory(server.getConfiguration().getJournalDirectory()),
"hornetq-data",
"hq",
1);
-
-
+
+
final AtomicInteger updates = new AtomicInteger();
-
+
journal.start();
journal.load(new LoaderCallback()
{
-
+
public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> recordsToDelete)
{
}
-
+
public void updateRecord(RecordInfo info)
{
if (info.userRecordType == JournalStorageManager.UPDATE_DELIVERY_COUNT)
@@ -321,23 +321,23 @@
updates.incrementAndGet();
}
}
-
+
public void deleteRecord(long id)
{
}
-
+
public void addRecord(RecordInfo info)
{
}
-
+
public void addPreparedTransaction(PreparedTransactionInfo preparedTransaction)
{
}
});
-
+
journal.stop();
-
-
+
+
assertEquals(7, updates.get());
}
@@ -360,7 +360,7 @@
server.start();
locator = createInVMNonHALocator();
- factory = locator.createSessionFactory();
+ factory = createSessionFactory(locator);
ClientSession session = factory.createSession(false, false, false);
try
@@ -374,30 +374,4 @@
session.close();
}
-
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
- if (factory != null)
- {
- factory.close();
- }
-
- if (server != null && server.isStarted())
- {
- server.stop();
- }
-
- factory = null;
-
- server = null;
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/OrderReattachTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/OrderReattachTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/OrderReattachTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -20,11 +20,16 @@
import java.util.concurrent.TimeUnit;
import junit.framework.Assert;
-import junit.framework.TestSuite;
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.MessageHandler;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.client.impl.ClientSessionInternal;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.protocol.core.impl.RemotingConnectionImpl;
@@ -71,7 +76,7 @@
locator.setConfirmationWindowSize(1024 * 1024);
locator.setBlockOnNonDurableSend(false);
locator.setBlockOnAcknowledge(false);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
final ClientSession session = sf.createSession(false, true, true);
@@ -79,7 +84,7 @@
final CountDownLatch ready = new CountDownLatch(1);
-
+
// this test will use a queue. Whenever the test wants a failure.. it can just send TRUE to failureQueue
// This Thread will be reading the queue
Thread failer = new Thread()
@@ -171,8 +176,6 @@
public void doSend2(final int order, final ClientSessionFactory sf, final LinkedBlockingDeque<Boolean> failureQueue) throws Exception
{
- long start = System.currentTimeMillis();
-
ClientSession s = sf.createSession(false, false, false);
final int numMessages = 500;
@@ -229,7 +232,7 @@
final CountDownLatch latch = new CountDownLatch(1);
volatile int count;
-
+
Exception failure;
public void onMessage(final ClientMessage message)
@@ -239,7 +242,7 @@
failure = new Exception("too many messages");
latch.countDown();
}
-
+
if (message.getIntProperty("count") != count)
{
failure = new Exception("counter " + count + " was not as expected (" + message.getIntProperty("count") + ")");
@@ -278,7 +281,7 @@
boolean ok = handler.latch.await(60000, TimeUnit.MILLISECONDS);
Assert.assertTrue(ok);
-
+
if (handler.failure != null)
{
throw handler.failure;
@@ -306,34 +309,5 @@
}
s.close();
-
- long end = System.currentTimeMillis();
-
}
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- if (server != null && server.isStarted())
- {
- server.stop();
- }
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
\ No newline at end of file
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -23,13 +23,17 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.Interceptor;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ServerLocator;
+import org.hornetq.api.core.client.SessionFailureListener;
import org.hornetq.core.client.impl.ClientSessionFactoryInternal;
import org.hornetq.core.client.impl.ClientSessionInternal;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.protocol.core.Packet;
import org.hornetq.core.protocol.core.impl.wireformat.SessionProducerCreditsMessage;
-import org.hornetq.core.protocol.core.impl.wireformat.SessionSendMessage;
import org.hornetq.core.remoting.impl.invm.InVMConnector;
import org.hornetq.core.remoting.impl.invm.InVMRegistry;
import org.hornetq.core.server.HornetQServer;
@@ -38,11 +42,11 @@
import org.hornetq.tests.util.ServiceTestBase;
/**
- *
+ *
* A ReattachTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
+ *
* Created 4 Nov 2008 16:54:50
*
*
@@ -51,22 +55,10 @@
{
private static final Logger log = Logger.getLogger(ReattachTest.class);
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
private static final SimpleString ADDRESS = new SimpleString("FailoverTestAddress");
-
private HornetQServer service;
-
private ServerLocator locator;
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
/*
* Test failure on connection, but server is still up so should immediately reconnect
*/
@@ -82,7 +74,7 @@
locator.setRetryIntervalMultiplier(retryMultiplier);
locator.setReconnectAttempts(reconnectAttempts);
locator.setConfirmationWindowSize(1024 * 1024);
- ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -168,11 +160,11 @@
public boolean intercept(Packet packet, RemotingConnection connection) throws HornetQException
{
System.out.println("Intercept..." + packet.getClass().getName());
-
+
if (packet instanceof SessionProducerCreditsMessage )
{
SessionProducerCreditsMessage credit = (SessionProducerCreditsMessage)packet;
-
+
System.out.println("Credits: " + credit.getCredits());
if (count.incrementAndGet() == 2)
{
@@ -187,7 +179,7 @@
locator.addInterceptor(intercept);
- ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -215,7 +207,7 @@
}
/*
- * Test failure on connection, simulate failure to create connection for a while, then
+ * Test failure on connection, simulate failure to create connection for a while, then
* allow connection to be recreated
*/
public void testDelayedReattach() throws Exception
@@ -230,7 +222,7 @@
locator.setRetryIntervalMultiplier(retryMultiplier);
locator.setReconnectAttempts(reconnectAttempts);
locator.setConfirmationWindowSize(1024 * 1024);
- ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -320,7 +312,7 @@
locator.setRetryIntervalMultiplier(retryMultiplier);
locator.setReconnectAttempts(reconnectAttempts);
locator.setConfirmationWindowSize(1024 * 1024);
- ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -434,7 +426,7 @@
locator.setRetryIntervalMultiplier(retryMultiplier);
locator.setReconnectAttempts(reconnectAttempts);
locator.setConfirmationWindowSize(1024 * 1024);
- ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -524,7 +516,7 @@
locator.setRetryIntervalMultiplier(retryMultiplier);
locator.setReconnectAttempts(reconnectAttempts);
locator.setConfirmationWindowSize(1024 * 1024);
- final ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ final ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)createSessionFactory(locator);
session = sf.createSession();
@@ -634,7 +626,7 @@
locator.setRetryIntervalMultiplier(retryMultiplier);
locator.setReconnectAttempts(reconnectAttempts);
locator.setConfirmationWindowSize(1024 * 1024);
- final ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ final ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)createSessionFactory(locator);
InVMConnector.failOnCreateConnection = true;
@@ -732,7 +724,7 @@
locator.setRetryIntervalMultiplier(retryMultiplier);
locator.setReconnectAttempts(reconnectAttempts);
locator.setConfirmationWindowSize(1024 * 1024);
- ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -804,7 +796,7 @@
locator.setRetryIntervalMultiplier(retryMultiplier);
locator.setReconnectAttempts(reconnectAttempts);
locator.setConfirmationWindowSize(1024 * 1024);
- ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -871,7 +863,7 @@
locator.setRetryIntervalMultiplier(retryMultiplier);
locator.setReconnectAttempts(reconnectAttempts);
locator.setConfirmationWindowSize(1024 * 1024);
- ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -963,7 +955,7 @@
locator.setRetryIntervalMultiplier(retryMultiplier);
locator.setReconnectAttempts(reconnectAttempts);
locator.setConfirmationWindowSize(1024 * 1024);
- ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -1041,7 +1033,7 @@
locator.setReconnectAttempts(reconnectAttempts);
locator.setMaxRetryInterval(maxRetryInterval);
locator.setConfirmationWindowSize(1024 * 1024);
- ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
+ ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -1127,14 +1119,8 @@
{
InVMConnector.resetFailures();
- locator.close();
-
- service.stop();
-
Assert.assertEquals(0, InVMRegistry.instance.size());
- service = null;
-
super.tearDown();
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/core/deployers/impl/QueueDeployerTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/core/deployers/impl/QueueDeployerTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/core/deployers/impl/QueueDeployerTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -14,7 +14,6 @@
package org.hornetq.tests.integration.core.deployers.impl;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.deployers.DeploymentManager;
import org.hornetq.core.deployers.impl.FileDeploymentManager;
import org.hornetq.core.deployers.impl.QueueDeployer;
@@ -22,9 +21,7 @@
import org.hornetq.core.postoffice.Bindings;
import org.hornetq.core.postoffice.impl.LocalQueueBinding;
import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.impl.HornetQServerImpl;
import org.hornetq.tests.util.ServiceTestBase;
-import org.hornetq.tests.util.UnitTestCase;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -32,7 +29,7 @@
* A QueueDeployerTest
*
* @author <a href="jmesnil(a)redhat.com">Jeff Mesnil</a>
- *
+ *
*/
public class QueueDeployerTest extends ServiceTestBase
{
@@ -45,15 +42,9 @@
private HornetQServer server;
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
public void testParseQueueConfiguration() throws Exception
{
- String xml = "<configuration xmlns='urn:hornetq'>"
+ String xml = "<configuration xmlns='urn:hornetq'>"
+ " <queues>"
+ " <queue name='foo'>"
+ " <address>bar</address>"
@@ -88,24 +79,10 @@
protected void setUp() throws Exception
{
super.setUp();
-
+
server = createServer(true);
DeploymentManager deploymentManager = new FileDeploymentManager(500);
deployer = new QueueDeployer(deploymentManager, server);
server.start();
}
-
- @Override
- protected void tearDown() throws Exception
- {
- deployer = null;
- server.stop();
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/paging/PagingCounterTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/paging/PagingCounterTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/paging/PagingCounterTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -57,7 +57,7 @@
public void testCounter() throws Exception
{
- ClientSessionFactory sf = sl.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(sl);
ClientSession session = sf.createSession();
try
@@ -89,7 +89,7 @@
public void testCleanupCounter() throws Exception
{
- ClientSessionFactory sf = sl.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(sl);
ClientSession session = sf.createSession();
try
@@ -106,25 +106,25 @@
{
counter.increment(tx, 1);
-
+
if (i % 200 == 0)
{
tx.commit();
-
+
storage.waitOnOperations();
assertEquals(i + 1, counter.getValue());
-
+
tx = new TransactionImpl(server.getStorageManager());
}
}
tx.commit();
-
+
storage.waitOnOperations();
-
+
assertEquals(2100, counter.getValue());
-
+
server.stop();
server = newHornetQServer();
@@ -150,7 +150,7 @@
public void testCleanupCounterNonPersistent() throws Exception
{
- ClientSessionFactory sf = sl.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(sl);
ClientSession session = sf.createSession();
try
@@ -158,7 +158,7 @@
Queue queue = server.createQueue(new SimpleString("A1"), new SimpleString("A1"), null, true, false);
PageSubscriptionCounter counter = locateCounter(queue);
-
+
((PageSubscriptionCounterImpl)counter).setPersistent(false);
StorageManager storage = server.getStorageManager();
@@ -169,25 +169,25 @@
{
counter.increment(tx, 1);
-
+
if (i % 200 == 0)
{
tx.commit();
-
+
storage.waitOnOperations();
assertEquals(i + 1, counter.getValue());
-
+
tx = new TransactionImpl(server.getStorageManager());
}
}
tx.commit();
-
+
storage.waitOnOperations();
-
+
assertEquals(2100, counter.getValue());
-
+
server.stop();
server = newHornetQServer();
@@ -288,65 +288,50 @@
storage.waitOnOperations();
assertEquals(0, counter.getValue());
-
+
server.stop();
-
+
server = newHornetQServer();
-
+
server.start();
-
+
storage = server.getStorageManager();
-
+
queue = server.locateQueue(new SimpleString("A1"));
-
+
assertNotNull(queue);
-
+
counter = locateCounter(queue);
-
+
tx = server.getResourceManager().removeTransaction(xid);
-
+
assertNotNull(tx);
-
+
assertEquals(0, counter.getValue());
-
+
tx.commit(false);
-
+
storage.waitOnOperations();
-
+
assertEquals(2000, counter.getValue());
-
-
- }
- // Package protected ---------------------------------------------
- // Protected -----------------------------------------------------
+ }
+
+ @Override
protected void setUp() throws Exception
{
super.setUp();
server = newHornetQServer();
-
server.start();
-
sl = createInVMNonHALocator();
}
- protected void tearDown() throws Exception
- {
- sl.close();
-
- server.stop();
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
private HornetQServer newHornetQServer()
{
-
+
OperationContextImpl.clearContext();
HornetQServer server = super.createServer(true, false);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/PingTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/PingTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/PingTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -22,7 +22,11 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.Interceptor;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.HornetQClient;
+import org.hornetq.api.core.client.ServerLocator;
+import org.hornetq.api.core.client.SessionFailureListener;
import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
import org.hornetq.core.client.impl.ClientSessionFactoryInternal;
import org.hornetq.core.config.Configuration;
@@ -38,10 +42,7 @@
/**
* @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
- *
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
- * @version <tt>$Revision$</tt>
*/
public class PingTest extends ServiceTestBase
{
@@ -70,14 +71,6 @@
server.start();
}
- @Override
- protected void tearDown() throws Exception
- {
- server.stop();
- server = null;
- super.tearDown();
- }
-
class Listener implements SessionFailureListener
{
volatile HornetQException me;
@@ -103,7 +96,7 @@
public void testNoFailureWithPinging() throws Exception
{
TransportConfiguration transportConfig = new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory");
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(transportConfig);
+ ServerLocator locator = addServerLocator(HornetQClient.createServerLocatorWithoutHA(transportConfig));
locator.setClientFailureCheckPeriod(PingTest.CLIENT_FAILURE_CHECK_PERIOD);
locator.setConnectionTTL(PingTest.CLIENT_FAILURE_CHECK_PERIOD * 2);
@@ -165,7 +158,7 @@
public void testNoFailureNoPinging() throws Exception
{
TransportConfiguration transportConfig = new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory");
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(transportConfig);
+ ServerLocator locator = addServerLocator(HornetQClient.createServerLocatorWithoutHA(transportConfig));
locator.setClientFailureCheckPeriod(-1);
locator.setConnectionTTL(-1);
ClientSessionFactory csf = locator.createSessionFactory();
@@ -223,7 +216,7 @@
public void testServerFailureNoPing() throws Exception
{
TransportConfiguration transportConfig = new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory");
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(transportConfig);
+ ServerLocator locator = addServerLocator(HornetQClient.createServerLocatorWithoutHA(transportConfig));
locator.setClientFailureCheckPeriod(PingTest.CLIENT_FAILURE_CHECK_PERIOD);
locator.setConnectionTTL(PingTest.CLIENT_FAILURE_CHECK_PERIOD * 2);
ClientSessionFactoryImpl csf = (ClientSessionFactoryImpl) locator.createSessionFactory();
@@ -318,7 +311,7 @@
});
TransportConfiguration transportConfig = new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory");
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(transportConfig);
+ ServerLocator locator = addServerLocator(HornetQClient.createServerLocatorWithoutHA(transportConfig));
locator.setClientFailureCheckPeriod(PingTest.CLIENT_FAILURE_CHECK_PERIOD);
locator.setConnectionTTL(PingTest.CLIENT_FAILURE_CHECK_PERIOD * 2);
ClientSessionFactory csf = locator.createSessionFactory();
@@ -402,13 +395,4 @@
locator.close();
}
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
\ No newline at end of file
Modified: trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/MultiThreadConsumerStressTest.java
===================================================================
--- trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/MultiThreadConsumerStressTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/MultiThreadConsumerStressTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -20,7 +20,12 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.server.HornetQServer;
@@ -29,7 +34,7 @@
/**
* A MultiThreadConsumerStressTest
- *
+ *
* This test validates consuming / sending messages while compacting is working
*
* @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
@@ -146,25 +151,6 @@
}
- @Override
- protected void tearDown() throws Exception
- {
- try
- {
- if (server != null && server.isStarted())
- {
- server.stop();
- }
- }
- catch (Throwable e)
- {
- e.printStackTrace(System.out); // System.out => junit reports
- }
-
- server = null;
- sf = null;
- }
-
private void setupServer(final JournalType journalType) throws Exception, HornetQException
{
Configuration config = createDefaultConfig(true);
@@ -190,7 +176,7 @@
locator.setBlockOnAcknowledge(false);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession sess = sf.createSession();
@@ -205,7 +191,7 @@
sess.close();
locator.close();
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
}
// Static --------------------------------------------------------
Modified: trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java
===================================================================
--- trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -25,7 +25,12 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.config.impl.ConfigurationImpl;
@@ -77,14 +82,6 @@
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
- stopServer();
- super.tearDown();
- }
-
public void testMultiThreadCompact() throws Throwable
{
setupServer(getJournalType());
@@ -120,11 +117,11 @@
if (i % 2 == 0 && i > 0)
{
System.out.println("DataFiles = " + journal.getDataFilesCount());
-
+
journal.forceMoveNextFile();
journal.debugWait();
journal.checkReclaimStatus();
-
+
if (journal.getDataFilesCount() != 0)
{
System.out.println("DebugJournal:" + journal.debug());
@@ -155,7 +152,7 @@
*/
private void addEmptyTransaction(final Xid xid) throws Exception, XAException
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(true, false, false);
session.start(xid, XAResource.TMNOFLAGS);
session.end(xid, XAResource.TMSUCCESS);
@@ -166,7 +163,7 @@
private void checkEmptyXID(final Xid xid) throws Exception, XAException
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(true, false, false);
Xid[] xids = session.recover(XAResource.TMSTARTRSCAN);
@@ -379,7 +376,7 @@
locator.setBlockOnDurableSend(false);
locator.setBlockOnAcknowledge(false);
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
ClientSession sess = sf.createSession();
Modified: trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageCursorStressTest.java
===================================================================
--- trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageCursorStressTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageCursorStressTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -1121,8 +1121,6 @@
@Override
protected void tearDown() throws Exception
{
- server.stop();
- server = null;
queue = null;
queueList = null;
super.tearDown();
@@ -1133,8 +1131,6 @@
{
super.setUp();
OperationContextImpl.clearContext();
- System.out.println("Tmp:" + getTemporaryDir());
-
queueList = new ArrayList<Queue>();
createServer();
Modified: trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageStressTest.java
===================================================================
--- trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageStressTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageStressTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -47,12 +47,6 @@
private ServerLocator locator;
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
public void testStopDuringDepage() throws Exception
{
Configuration config = createDefaultConfig();
@@ -69,7 +63,7 @@
messagingService = createServer(true, config, 10 * 1024 * 1024, 20 * 1024 * 1024, settings);
messagingService.start();
- ClientSessionFactory factory = locator.createSessionFactory();
+ ClientSessionFactory factory = createSessionFactory(locator);
ClientSession session = null;
try
@@ -130,7 +124,7 @@
messagingService.start();
- factory = locator.createSessionFactory();
+ factory = createSessionFactory(locator);
session = factory.createSession(false, false, false);
@@ -161,13 +155,6 @@
finally
{
session.close();
- try
- {
- messagingService.stop();
- }
- catch (Throwable ignored)
- {
- }
}
}
@@ -185,7 +172,7 @@
messagingService = createServer(true, config, 10 * 1024 * 1024, 20 * 1024 * 1024, settings);
messagingService.start();
- ClientSessionFactory factory = locator.createSessionFactory();
+ ClientSessionFactory factory = createSessionFactory(locator);
ClientSession session = null;
try
@@ -296,9 +283,6 @@
protected void setUp() throws Exception
{
super.setUp();
-
- clearData();
-
locator = createInVMNonHALocator();
locator.setBlockOnAcknowledge(true);
@@ -306,17 +290,4 @@
locator.setBlockOnNonDurableSend(false);
}
-
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/remote/PingStressTest.java
===================================================================
--- trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/remote/PingStressTest.java 2011-12-06 14:04:26 UTC (rev 11860)
+++ trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/remote/PingStressTest.java 2011-12-06 15:02:45 UTC (rev 11861)
@@ -23,7 +23,6 @@
import org.hornetq.api.core.client.ClientSessionFactory;
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.api.core.client.ServerLocator;
-import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.protocol.core.Packet;
@@ -36,7 +35,7 @@
/**
* @author <a href="mailto:clebert.suconic@jboss.com">Clebert Suconic</a>
- *
+ *
* @version <tt>$Revision$</tt>
*/
public class PingStressTest extends ServiceTestBase
@@ -66,17 +65,6 @@
server.start();
}
- @Override
- protected void tearDown() throws Exception
- {
- if (server != null && server.isStarted())
- {
- server.stop();
- server = null;
- }
- super.tearDown();
- }
-
protected int getNumberOfIterations()
{
return 20;
@@ -91,7 +79,6 @@
tearDown();
setUp();
}
- System.out.println("Run " + i);
internalTest();
}
@@ -122,7 +109,7 @@
};
server.getRemotingService().addInterceptor(noPongInterceptor);
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(transportConfig);
+ ServerLocator locator = addServerLocator(HornetQClient.createServerLocatorWithoutHA(transportConfig));
locator.setClientFailureCheckPeriod(PingStressTest.PING_INTERVAL);
locator.setConnectionTTL((long)(PingStressTest.PING_INTERVAL * 1.5));
locator.setCallTimeout(PingStressTest.PING_INTERVAL * 10);
@@ -153,12 +140,12 @@
try
{
- ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(transportConfig);
+ ServerLocator locator = addServerLocator(HornetQClient.createServerLocatorWithoutHA(transportConfig));
locator.setClientFailureCheckPeriod(PingStressTest.PING_INTERVAL);
locator.setConnectionTTL((long)(PingStressTest.PING_INTERVAL * 1.5));
locator.setCallTimeout(PingStressTest.PING_INTERVAL * 10);
- final ClientSessionFactory csf2 = locator.createSessionFactory();
+ final ClientSessionFactory csf2 = createSessionFactory(locator);
// Start all at once to make concurrency worst
flagAligned.countDown();
@@ -186,9 +173,9 @@
Thread.sleep(PingStressTest.PING_INTERVAL * (threadNumber % 3));
session.close();
-
+
csf2.close();
-
+
locator.close();
}
}
@@ -225,19 +212,10 @@
{
throw new Exception("Test Failed", e);
}
-
+
csf1.close();
-
+
locator.close();
}
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
\ No newline at end of file
13 years
JBoss hornetq SVN: r11860 - in branches/HORNETQ-316/tests/integration-tests/src/test: java/org/hornetq/tests/integration/discovery and 2 other directories.
by do-not-reply@jboss.org
Author: igarashitm
Date: 2011-12-06 09:04:26 -0500 (Tue, 06 Dec 2011)
New Revision: 11860
Added:
branches/HORNETQ-316/tests/integration-tests/src/test/resources/test-jgroups-file_ping.xml
branches/HORNETQ-316/tests/integration-tests/src/test/resources/test-jgroups-file_ping_2.xml
branches/HORNETQ-316/tests/integration-tests/src/test/resources/test-jgroups-file_ping_3.xml
Modified:
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/discovery/DiscoveryTest.java
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlTest.java
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlUsingCoreTest.java
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BroadcastGroupControlTest.java
branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ClusterConnectionControlTest.java
Log:
https://issues.jboss.org/browse/HORNETQ-316 bug fixes
Modified: branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java
===================================================================
--- branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java 2011-12-06 13:15:46 UTC (rev 11859)
+++ branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java 2011-12-06 14:04:26 UTC (rev 11860)
@@ -173,7 +173,7 @@
config0.setClustered(true);
ClusterConnectionConfiguration ccc0 =
new ClusterConnectionConfiguration("cluster1", "jms", liveConnector.getName(), -1, false, false, 1, 1,
- null, false);
+ createStaticDiscoveryGroupConfiguration((TransportConfiguration[])null), false);
config0.getClusterConfigurations().add(ccc0);
config0.getConnectorConfigurations().put(liveConnector.getName(), liveConnector);
Modified: branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/discovery/DiscoveryTest.java
===================================================================
--- branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/discovery/DiscoveryTest.java 2011-12-06 13:15:46 UTC (rev 11859)
+++ branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/discovery/DiscoveryTest.java 2011-12-06 14:04:26 UTC (rev 11860)
@@ -1004,7 +1004,7 @@
boolean active) throws Exception
{
return new BroadcastGroupImpl(nodeID, name, active, createBroadcastGroupConfiguration(name,
- localAddress.getHostAddress(),
+ localAddress != null ? localAddress.getHostAddress() : null,
localPort,
groupAddress.getHostAddress(),
groupPort,
Modified: branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlTest.java
===================================================================
--- branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlTest.java 2011-12-06 13:15:46 UTC (rev 11859)
+++ branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlTest.java 2011-12-06 14:04:26 UTC (rev 11860)
@@ -85,7 +85,7 @@
Assert.assertEquals(bridgeConfig.isUseDuplicateDetection(), bridgeControl.isUseDuplicateDetection());
String[] connectorPairData = bridgeControl.getStaticConnectors();
- Assert.assertEquals(bridgeConfig.getStaticConnectors().get(0), connectorPairData[0]);
+ Assert.assertEquals(bridgeConfig.getStaticConnectors().get(0).getName(), connectorPairData[0]);
Assert.assertTrue(bridgeControl.isStarted());
}
Modified: branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlUsingCoreTest.java
===================================================================
--- branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlUsingCoreTest.java 2011-12-06 13:15:46 UTC (rev 11859)
+++ branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BridgeControlUsingCoreTest.java 2011-12-06 14:04:26 UTC (rev 11860)
@@ -91,7 +91,7 @@
((Boolean)proxy.retrieveAttributeValue("useDuplicateDetection")).booleanValue());
Object[] data = (Object[])proxy.retrieveAttributeValue("staticConnectors");
- Assert.assertEquals(bridgeConfig.getStaticConnectors().get(0), data[0]);
+ Assert.assertEquals(bridgeConfig.getStaticConnectors().get(0).getName(), data[0]);
Assert.assertTrue((Boolean)proxy.retrieveAttributeValue("started"));
}
Modified: branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BroadcastGroupControlTest.java
===================================================================
--- branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BroadcastGroupControlTest.java 2011-12-06 13:15:46 UTC (rev 11859)
+++ branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BroadcastGroupControlTest.java 2011-12-06 14:04:26 UTC (rev 11860)
@@ -102,12 +102,12 @@
Assert.assertEquals(1, connectorPairs.length);
System.out.println(connectorPairs);
String connectorPairData = (String)connectorPairs[0];
- Assert.assertEquals(broadcastGroupConfig.getConnectorList().get(0), connectorPairData);
+ Assert.assertEquals(broadcastGroupConfig.getConnectorList().get(0).getName(), connectorPairData);
String jsonString = broadcastGroupControl.getConnectorPairsAsJSON();
Assert.assertNotNull(jsonString);
JSONArray array = new JSONArray(jsonString);
Assert.assertEquals(1, array.length());
- Assert.assertEquals(broadcastGroupConfig.getConnectorList().get(0), array.getString(0));
+ Assert.assertEquals(broadcastGroupConfig.getConnectorList().get(0).getName(), array.getString(0));
Assert.assertTrue(broadcastGroupControl.isStarted());
}
Modified: branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ClusterConnectionControlTest.java
===================================================================
--- branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ClusterConnectionControlTest.java 2011-12-06 13:15:46 UTC (rev 11859)
+++ branches/HORNETQ-316/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ClusterConnectionControlTest.java 2011-12-06 14:04:26 UTC (rev 11860)
@@ -93,15 +93,15 @@
Object[] connectors = clusterConnectionControl.getStaticConnectors();
Assert.assertEquals(1, connectors.length);
String connector = (String)connectors[0];
- Assert.assertEquals(clusterConnectionConfig1.getStaticConnectors().get(0), connector);
+ Assert.assertEquals(clusterConnectionConfig1.getStaticConnectors().get(0).getName(), connector);
String jsonString = clusterConnectionControl.getStaticConnectorsAsJSON();
Assert.assertNotNull(jsonString);
JSONArray array = new JSONArray(jsonString);
Assert.assertEquals(1, array.length());
- Assert.assertEquals(clusterConnectionConfig1.getStaticConnectors().get(0), array.getString(0));
+ Assert.assertEquals(clusterConnectionConfig1.getStaticConnectors().get(0).getName(), array.getString(0));
- Assert.assertNull(clusterConnectionControl.getDiscoveryGroupName());
+ Assert.assertEquals(clusterConnectionConfig1.getDiscoveryGroupConfiguration().getName(), clusterConnectionControl.getDiscoveryGroupName());
Assert.assertTrue(clusterConnectionControl.isStarted());
}
Added: branches/HORNETQ-316/tests/integration-tests/src/test/resources/test-jgroups-file_ping.xml
===================================================================
--- branches/HORNETQ-316/tests/integration-tests/src/test/resources/test-jgroups-file_ping.xml (rev 0)
+++ branches/HORNETQ-316/tests/integration-tests/src/test/resources/test-jgroups-file_ping.xml 2011-12-06 14:04:26 UTC (rev 11860)
@@ -0,0 +1,53 @@
+<config xmlns="urn:org:jgroups"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:org:jgroups file:schema/JGroups-2.8.xsd">
+ <TCP loopback="true"
+ recv_buf_size="20000000"
+ send_buf_size="640000"
+ discard_incompatible_packets="true"
+ max_bundle_size="64000"
+ max_bundle_timeout="30"
+ enable_bundling="true"
+ use_send_queues="false"
+ sock_conn_timeout="300"
+ skip_suspected_members="true"
+
+ thread_pool.enabled="true"
+ thread_pool.min_threads="1"
+ thread_pool.max_threads="10"
+ thread_pool.keep_alive_time="5000"
+ thread_pool.queue_enabled="false"
+ thread_pool.queue_max_size="100"
+ thread_pool.rejection_policy="run"
+
+ oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="1"
+ oob_thread_pool.max_threads="8"
+ oob_thread_pool.keep_alive_time="5000"
+ oob_thread_pool.queue_enabled="false"
+ oob_thread_pool.queue_max_size="100"
+ oob_thread_pool.rejection_policy="run"/>
+
+ <FILE_PING location="file_ping_dir"/>
+ <MERGE2 max_interval="30000"
+ min_interval="10000"/>
+ <FD_SOCK/>
+ <FD timeout="10000" max_tries="5" />
+ <VERIFY_SUSPECT timeout="1500" />
+ <BARRIER />
+ <pbcast.NAKACK
+ use_mcast_xmit="false" gc_lag="0"
+ retransmit_timeout="300,600,1200,2400,4800"
+ discard_delivered_msgs="true"/>
+ <UNICAST timeout="300,600,1200" />
+ <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+ max_bytes="400000"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="3000"
+
+ view_bundling="true"/>
+ <FC max_credits="2000000"
+ min_threshold="0.10"/>
+ <FRAG2 frag_size="60000" />
+ <pbcast.STREAMING_STATE_TRANSFER/>
+ <pbcast.FLUSH timeout="0"/>
+</config>
Added: branches/HORNETQ-316/tests/integration-tests/src/test/resources/test-jgroups-file_ping_2.xml
===================================================================
--- branches/HORNETQ-316/tests/integration-tests/src/test/resources/test-jgroups-file_ping_2.xml (rev 0)
+++ branches/HORNETQ-316/tests/integration-tests/src/test/resources/test-jgroups-file_ping_2.xml 2011-12-06 14:04:26 UTC (rev 11860)
@@ -0,0 +1,53 @@
+<config xmlns="urn:org:jgroups"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:org:jgroups file:schema/JGroups-2.8.xsd">
+ <TCP loopback="true"
+ recv_buf_size="20000000"
+ send_buf_size="640000"
+ discard_incompatible_packets="true"
+ max_bundle_size="64000"
+ max_bundle_timeout="30"
+ enable_bundling="true"
+ use_send_queues="false"
+ sock_conn_timeout="300"
+ skip_suspected_members="true"
+
+ thread_pool.enabled="true"
+ thread_pool.min_threads="1"
+ thread_pool.max_threads="10"
+ thread_pool.keep_alive_time="5000"
+ thread_pool.queue_enabled="false"
+ thread_pool.queue_max_size="100"
+ thread_pool.rejection_policy="run"
+
+ oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="1"
+ oob_thread_pool.max_threads="8"
+ oob_thread_pool.keep_alive_time="5000"
+ oob_thread_pool.queue_enabled="false"
+ oob_thread_pool.queue_max_size="100"
+ oob_thread_pool.rejection_policy="run"/>
+
+ <FILE_PING location="file_ping_dir_2"/>
+ <MERGE2 max_interval="30000"
+ min_interval="10000"/>
+ <FD_SOCK/>
+ <FD timeout="10000" max_tries="5" />
+ <VERIFY_SUSPECT timeout="1500" />
+ <BARRIER />
+ <pbcast.NAKACK
+ use_mcast_xmit="false" gc_lag="0"
+ retransmit_timeout="300,600,1200,2400,4800"
+ discard_delivered_msgs="true"/>
+ <UNICAST timeout="300,600,1200" />
+ <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+ max_bytes="400000"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="3000"
+
+ view_bundling="true"/>
+ <FC max_credits="2000000"
+ min_threshold="0.10"/>
+ <FRAG2 frag_size="60000" />
+ <pbcast.STREAMING_STATE_TRANSFER/>
+ <pbcast.FLUSH timeout="0"/>
+</config>
Added: branches/HORNETQ-316/tests/integration-tests/src/test/resources/test-jgroups-file_ping_3.xml
===================================================================
--- branches/HORNETQ-316/tests/integration-tests/src/test/resources/test-jgroups-file_ping_3.xml (rev 0)
+++ branches/HORNETQ-316/tests/integration-tests/src/test/resources/test-jgroups-file_ping_3.xml 2011-12-06 14:04:26 UTC (rev 11860)
@@ -0,0 +1,53 @@
+<config xmlns="urn:org:jgroups"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:org:jgroups file:schema/JGroups-2.8.xsd">
+ <TCP loopback="true"
+ recv_buf_size="20000000"
+ send_buf_size="640000"
+ discard_incompatible_packets="true"
+ max_bundle_size="64000"
+ max_bundle_timeout="30"
+ enable_bundling="true"
+ use_send_queues="false"
+ sock_conn_timeout="300"
+ skip_suspected_members="true"
+
+ thread_pool.enabled="true"
+ thread_pool.min_threads="1"
+ thread_pool.max_threads="10"
+ thread_pool.keep_alive_time="5000"
+ thread_pool.queue_enabled="false"
+ thread_pool.queue_max_size="100"
+ thread_pool.rejection_policy="run"
+
+ oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="1"
+ oob_thread_pool.max_threads="8"
+ oob_thread_pool.keep_alive_time="5000"
+ oob_thread_pool.queue_enabled="false"
+ oob_thread_pool.queue_max_size="100"
+ oob_thread_pool.rejection_policy="run"/>
+
+ <FILE_PING location="file_ping_dir_3"/>
+ <MERGE2 max_interval="30000"
+ min_interval="10000"/>
+ <FD_SOCK/>
+ <FD timeout="10000" max_tries="5" />
+ <VERIFY_SUSPECT timeout="1500" />
+ <BARRIER />
+ <pbcast.NAKACK
+ use_mcast_xmit="false" gc_lag="0"
+ retransmit_timeout="300,600,1200,2400,4800"
+ discard_delivered_msgs="true"/>
+ <UNICAST timeout="300,600,1200" />
+ <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+ max_bytes="400000"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="3000"
+
+ view_bundling="true"/>
+ <FC max_credits="2000000"
+ min_threshold="0.10"/>
+ <FRAG2 frag_size="60000" />
+ <pbcast.STREAMING_STATE_TRANSFER/>
+ <pbcast.FLUSH timeout="0"/>
+</config>
13 years
JBoss hornetq SVN: r11859 - trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/ra.
by do-not-reply@jboss.org
Author: borges
Date: 2011-12-06 08:15:46 -0500 (Tue, 06 Dec 2011)
New Revision: 11859
Modified:
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/ra/HornetQResourceAdapterConfigTest.java
Log:
Remove sys.out calls.
Modified: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/ra/HornetQResourceAdapterConfigTest.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/ra/HornetQResourceAdapterConfigTest.java 2011-12-06 13:01:30 UTC (rev 11858)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/ra/HornetQResourceAdapterConfigTest.java 2011-12-06 13:15:46 UTC (rev 11859)
@@ -21,6 +21,15 @@
*/
package org.hornetq.tests.unit.ra;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
import org.hornetq.ra.HornetQResourceAdapter;
import org.hornetq.tests.util.UnitTestCase;
import org.w3c.dom.Document;
@@ -29,15 +38,7 @@
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* This test is used to generate the commented out configs in the src/config/ra.xml. If you add a setter to the HornetQResourceAdapter
* this test should fail, if it does paste the new commented out configs into the ra.xml file and in here. dont forget to
@@ -273,18 +274,18 @@
" <config-property-type>long</config-property-type>\n" +
" <config-property-value></config-property-value>\n" +
" </config-property>\n" +
- " <config-property>" +
- " <description></description>" +
- " <config-property-name>TransactionManagerLocatorMethod</config-property-name>" +
- " <config-property-type>java.lang.String</config-property-type>" +
- " <config-property-value></config-property-value>" +
- " </config-property>" +
- " <config-property>" +
- " <description></description>" +
- " <config-property-name>TransactionManagerLocatorClass</config-property-name>" +
- " <config-property-type>java.lang.String</config-property-type>" +
- " <config-property-value></config-property-value>" +
- " </config-property>" +
+ " <config-property>" +
+ " <description></description>" +
+ " <config-property-name>TransactionManagerLocatorMethod</config-property-name>" +
+ " <config-property-type>java.lang.String</config-property-type>" +
+ " <config-property-value></config-property-value>" +
+ " </config-property>" +
+ " <config-property>" +
+ " <description></description>" +
+ " <config-property-name>TransactionManagerLocatorClass</config-property-name>" +
+ " <config-property-type>java.lang.String</config-property-type>" +
+ " <config-property-value></config-property-value>" +
+ " </config-property>" +
" <config-property>\n" +
" <description>How many attempts should be made when connecting the MDB</description>\n" +
" <config-property-name>SetupAttempts</config-property-name>\n" +
@@ -322,10 +323,9 @@
assertEquals(el.toString(), elementsByTagName.getLength(), 1);
Node configPropertyNameNode = elementsByTagName.item(0);
String configPropertyName = configPropertyNameNode.getTextContent();
- System.out.println("configPropertyName = " + configPropertyName);
Method setter = methodList.remove("set" + configPropertyName);
assertNotNull("setter " + configPropertyName + " does not exist", setter);
- Class c = setter.getParameterTypes()[0];
+ Class<?> c = setter.getParameterTypes()[0];
elementsByTagName = el.getElementsByTagName("config-property-type");
assertEquals("setter " + configPropertyName + " has no type set", elementsByTagName.getLength(), 1);
Node configPropertyTypeNode = elementsByTagName.item(0);
@@ -345,12 +345,7 @@
newConfig.append("\" <config-property-value></config-property-value>\" + \n");
newConfig.append("\" </config-property>\" + \n");
}
- System.out.println(newConfig);
fail("methods not shown please see previous and add");
}
- else
- {
- System.out.println(commentedOutConfigs);
- }
}
}
13 years
JBoss hornetq SVN: r11858 - trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution.
by do-not-reply@jboss.org
Author: borges
Date: 2011-12-06 08:01:30 -0500 (Tue, 06 Dec 2011)
New Revision: 11858
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
Log:
Fix list usage.
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2011-12-06 13:01:10 UTC (rev 11857)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2011-12-06 13:01:30 UTC (rev 11858)
@@ -1233,7 +1233,8 @@
Assert.assertTrue(counts.contains(messageCount));
}
- List<LinkedList<Integer>> lists = new ArrayList<LinkedList<Integer>>(consumerIDs.length);
+ @SuppressWarnings("unchecked")
+ LinkedList<Integer>[] lists = new LinkedList[consumerIDs.length];
for (int i = 0; i < messageCounts.length; i++)
{
@@ -1243,7 +1244,7 @@
if (elem == messageCounts[i])
{
- lists.set(i, list);
+ lists[i] = list;
break;
}
@@ -1253,7 +1254,7 @@
for (int messageCount : messageCounts)
{
- LinkedList<Integer> list = lists.get(index);
+ LinkedList<Integer> list = lists[index];
Assert.assertNotNull(list);
13 years
JBoss hornetq SVN: r11857 - trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution.
by do-not-reply@jboss.org
Author: borges
Date: 2011-12-06 08:01:10 -0500 (Tue, 06 Dec 2011)
New Revision: 11857
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/MessageRedistributionTest.java
Log:
Remove unnecessary code.
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/MessageRedistributionTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/MessageRedistributionTest.java 2011-12-06 12:38:34 UTC (rev 11856)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/MessageRedistributionTest.java 2011-12-06 13:01:10 UTC (rev 11857)
@@ -71,19 +71,6 @@
setRedistributionDelay(0);
}
- private void stop() throws Exception
- {
- stopServers();
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- stop();
-
- super.tearDown();
- }
-
protected boolean isNetty()
{
return false;
@@ -296,7 +283,7 @@
ByteBuffer bb = ByteBuffer.wrap(bytes);
- bb.putLong((long)i);
+ bb.putLong(i);
msg.putBytesProperty(MessageImpl.HDR_BRIDGE_DUPLICATE_ID, bytes);
@@ -575,7 +562,7 @@
verifyNotReceive(1);
removeConsumer(1);
- stop();
+ stopServers();
start();
}
@@ -641,7 +628,7 @@
verifyReceiveAll(20, 1);
- stop();
+ stopServers();
start();
}
13 years
JBoss hornetq SVN: r11856 - in trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration: scheduling and 1 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2011-12-06 07:38:34 -0500 (Tue, 06 Dec 2011)
New Revision: 11856
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/RoutingTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ServerLocatorConnectTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/scheduling/ScheduledMessageTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/security/SecurityTest.java
Log:
Delete more unnecessary tearDown() code
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/RoutingTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/RoutingTest.java 2011-12-06 12:03:29 UTC (rev 11855)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/RoutingTest.java 2011-12-06 12:38:34 UTC (rev 11856)
@@ -15,7 +15,12 @@
import junit.framework.Assert;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
@@ -25,39 +30,27 @@
public class RoutingTest extends ServiceTestBase
{
public final SimpleString addressA = new SimpleString("addressA");
-
public final SimpleString queueA = new SimpleString("queueA");
-
public final SimpleString queueB = new SimpleString("queueB");
-
public final SimpleString queueC = new SimpleString("queueC");
private ServerLocator locator;
+ private HornetQServer server;
+ private ClientSessionFactory cf;
@Override
protected void setUp() throws Exception
{
super.setUp();
-
locator = createInVMNonHALocator();
- }
+ server = createServer(false);
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- super.tearDown();
+ server.start();
+ cf = createSessionFactory(locator);
}
public void testRouteToMultipleQueues() throws Exception
{
- HornetQServer server = createServer(false);
-
- try
- {
- server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
ClientSession sendSession = cf.createSession(false, true, true);
sendSession.createQueue(addressA, queueA, false);
sendSession.createQueue(addressA, queueB, false);
@@ -90,24 +83,10 @@
Assert.assertNull(c3.receiveImmediate());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
public void testRouteToSingleNonDurableQueue() throws Exception
{
- HornetQServer server = createServer(false);
-
- try
- {
- server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
ClientSession sendSession = cf.createSession(false, true, true);
sendSession.createQueue(addressA, queueA, false);
int numMessages = 300;
@@ -128,25 +107,11 @@
Assert.assertNull(c1.receiveImmediate());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
public void testRouteToSingleDurableQueue() throws Exception
{
- HornetQServer server = createServer(false);
-
- try
- {
- server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession sendSession = cf.createSession(false, true, true);
+ ClientSession sendSession = cf.createSession(false, true, true);
sendSession.createQueue(addressA, queueA, true);
int numMessages = 300;
ClientProducer p = sendSession.createProducer(addressA);
@@ -166,25 +131,11 @@
Assert.assertNull(c1.receiveImmediate());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
public void testRouteToSingleQueueWithFilter() throws Exception
{
- HornetQServer server = createServer(false);
-
- try
- {
- server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession sendSession = cf.createSession(false, true, true);
+ ClientSession sendSession = cf.createSession(false, true, true);
sendSession.createQueue(addressA, queueA, new SimpleString("foo = 'bar'"), false);
int numMessages = 300;
ClientProducer p = sendSession.createProducer(addressA);
@@ -206,25 +157,11 @@
Assert.assertNull(c1.receiveImmediate());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
public void testRouteToMultipleQueueWithFilters() throws Exception
{
- HornetQServer server = createServer(false);
-
- try
- {
- server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession sendSession = cf.createSession(false, true, true);
+ ClientSession sendSession = cf.createSession(false, true, true);
sendSession.createQueue(addressA, queueA, new SimpleString("foo = 'bar'"), false);
sendSession.createQueue(addressA, queueB, new SimpleString("x = 1"), false);
sendSession.createQueue(addressA, queueC, new SimpleString("b = false"), false);
@@ -269,25 +206,11 @@
Assert.assertNull(c3.receiveImmediate());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
public void testRouteToSingleTemporaryQueue() throws Exception
{
- HornetQServer server = createServer(false);
-
- try
- {
- server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession sendSession = cf.createSession(false, true, true);
+ ClientSession sendSession = cf.createSession(false, true, true);
sendSession.createTemporaryQueue(addressA, queueA);
int numMessages = 300;
ClientProducer p = sendSession.createProducer(addressA);
@@ -307,14 +230,5 @@
Assert.assertNull(c1.receiveImmediate());
sendSession.close();
session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
}
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java 2011-12-06 12:03:29 UTC (rev 11855)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java 2011-12-06 12:38:34 UTC (rev 11856)
@@ -17,7 +17,12 @@
import org.hornetq.api.core.HornetQBuffer;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.RandomUtil;
@@ -28,7 +33,7 @@
* A SelfExpandingBufferTest
*
* @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- *
+ *
* Created Feb 23, 2009 4:27:16 PM
*
*
@@ -80,7 +85,7 @@
ServerLocator locator = createFactory(netty);
- factory = locator.createSessionFactory();
+ factory = createSessionFactory(locator);
ClientSession session = factory.createSession(false, true, true);
@@ -118,9 +123,9 @@
byte[] receivedBytes = new byte[bytes.length];
// log.info("buffer start pos should be at " + PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT);
- //
+ //
// log.info("buffer pos at " + msg2.getBodyBuffer().readerIndex());
- //
+ //
// log.info("buffer length should be " + msg2.getBodyBuffer().readInt(PacketImpl.PACKET_HEADERS_SIZE));
msg2.getBodyBuffer().readBytes(receivedBytes);
@@ -138,7 +143,6 @@
finally
{
session.close();
- locator.close();
}
}
@@ -151,22 +155,4 @@
service = createServer(persistent, createDefaultConfig(netty));
service.start();
}
-
- @Override
- protected void tearDown() throws Exception
- {
- if (service != null && service.isStarted())
- {
- service.stop();
- }
-
- service = null;
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ServerLocatorConnectTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ServerLocatorConnectTest.java 2011-12-06 12:03:29 UTC (rev 11855)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ServerLocatorConnectTest.java 2011-12-06 12:38:34 UTC (rev 11856)
@@ -13,6 +13,9 @@
package org.hornetq.tests.integration.client;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.client.ClientSessionFactory;
import org.hornetq.api.core.client.HornetQClient;
@@ -23,9 +26,6 @@
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
/**
* User: andy
* Date: Sep 15, 2010
@@ -45,16 +45,8 @@
server.start();
}
- @Override
- protected void tearDown() throws Exception
- {
- server.stop();
- super.tearDown();
- }
-
public void testSingleConnectorSingleServer() throws Exception
{
-
ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(0, isNetty())));
ClientSessionFactory csf = locator.createSessionFactory();
csf.close();
@@ -64,7 +56,7 @@
public void testSingleConnectorSingleServerConnect() throws Exception
{
ServerLocatorInternal locator = (ServerLocatorInternal) HornetQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(0, isNetty())));
- ClientSessionFactoryInternal csf = (ClientSessionFactoryInternal) locator.connect();
+ ClientSessionFactoryInternal csf = locator.connect();
assertNotNull(csf);
assertEquals(csf.numConnections(), 1);
locator.close();
@@ -79,7 +71,7 @@
createTransportConfiguration(isNetty(), false, generateParams(3, isNetty())),
createTransportConfiguration(isNetty(), false, generateParams(4, isNetty()))
);
- ClientSessionFactoryInternal csf = (ClientSessionFactoryInternal) locator.connect();
+ ClientSessionFactoryInternal csf = locator.connect();
assertNotNull(csf);
assertEquals(csf.numConnections(), 1);
locator.close();
@@ -95,7 +87,7 @@
createTransportConfiguration(isNetty(), false, generateParams(4, isNetty()))
);
locator.setReconnectAttempts(-1);
- ClientSessionFactoryInternal csf = (ClientSessionFactoryInternal) locator.connect();
+ ClientSessionFactoryInternal csf = locator.connect();
assertNotNull(csf);
assertEquals(csf.numConnections(), 1);
locator.close();
@@ -113,7 +105,7 @@
ClientSessionFactoryInternal csf = null;
try
{
- csf = (ClientSessionFactoryInternal) locator.connect();
+ csf = locator.connect();
}
catch (Exception e)
{
@@ -134,7 +126,6 @@
createTransportConfiguration(isNetty(), false, generateParams(5, isNetty()))
);
locator.setReconnectAttempts(-1);
- ClientSessionFactoryInternal csf = null;
CountDownLatch countDownLatch = new CountDownLatch(1);
Connector target = new Connector(locator, countDownLatch);
Thread t = new Thread(target);
@@ -153,7 +144,7 @@
static class Connector implements Runnable
{
- private ServerLocatorInternal locator;
+ private final ServerLocatorInternal locator;
ClientSessionFactory csf = null;
CountDownLatch latch;
Exception e;
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/scheduling/ScheduledMessageTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/scheduling/ScheduledMessageTest.java 2011-12-06 12:03:29 UTC (rev 11855)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/scheduling/ScheduledMessageTest.java 2011-12-06 12:38:34 UTC (rev 11856)
@@ -22,7 +22,12 @@
import org.hornetq.api.core.Message;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
@@ -72,26 +77,6 @@
locator = createInVMNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- if (server != null)
- {
- try
- {
- server.stop();
- server = null;
- }
- catch (Exception e)
- {
- // ignore
- }
- }
- super.tearDown();
- }
-
public void testRecoveredMessageDeliveredCorrectly() throws Exception
{
testMessageDeliveredCorrectly(true);
@@ -145,7 +130,7 @@
public void testPagedMessageDeliveredCorrectly() throws Exception
{
// then we create a client as normal
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(false, true, false);
session.createQueue(atestq, atestq, null, true);
ClientProducer producer = session.createProducer(atestq);
@@ -181,7 +166,7 @@
qs.setRedeliveryDelay(5000l);
server.getAddressSettingsRepository().addMatch(atestq.toString(), qs);
// then we create a client as normal
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(false, true, false);
session.createQueue(atestq, atestq, null, true);
session.createQueue(atestq, atestq2, null, true);
@@ -230,7 +215,7 @@
qs.setRedeliveryDelay(5000l);
server.getAddressSettingsRepository().addMatch(atestq.toString(), qs);
// then we create a client as normal
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(false, true, false);
session.createQueue(atestq, atestq, null, true);
session.createQueue(atestq, atestq2, null, true);
@@ -260,7 +245,7 @@
server = null;
server = createServer(true, configuration);
server.start();
- sessionFactory = locator.createSessionFactory();
+ sessionFactory = createSessionFactory(locator);
session = sessionFactory.createSession(false, true, true);
consumer = session.createConsumer(atestq);
consumer2 = session.createConsumer(atestq2);
@@ -289,7 +274,7 @@
{
// then we create a client as normal
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(false, true, false);
session.createQueue(atestq, atestq, null, true);
ClientProducer producer = session.createProducer(atestq);
@@ -314,7 +299,7 @@
server = null;
server = createServer(true, configuration);
server.start();
- sessionFactory = locator.createSessionFactory();
+ sessionFactory = createSessionFactory(locator);
session = sessionFactory.createSession(false, true, true);
}
ClientConsumer consumer = session.createConsumer(atestq);
@@ -338,7 +323,7 @@
public void testScheduledMessagesDeliveredCorrectly(final boolean recover) throws Exception
{
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(false, true, false);
session.createQueue(atestq, atestq, null, true);
ClientProducer producer = session.createProducer(atestq);
@@ -373,7 +358,7 @@
server = createServer(true, configuration);
server.start();
- sessionFactory = locator.createSessionFactory();
+ sessionFactory = createSessionFactory(locator);
session = sessionFactory.createSession(false, true, true);
}
@@ -418,7 +403,7 @@
public void testScheduledMessagesDeliveredCorrectlyDifferentOrder(final boolean recover) throws Exception
{
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(false, true, false);
session.createQueue(atestq, atestq, null, true);
ClientProducer producer = session.createProducer(atestq);
@@ -454,7 +439,7 @@
server = createServer(true, configuration);
server.start();
- sessionFactory = locator.createSessionFactory();
+ sessionFactory = createSessionFactory(locator);
session = sessionFactory.createSession(false, true, true);
@@ -500,13 +485,13 @@
public void testManyMessagesSameTime() throws Exception
{
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(false, false, false);
session.createQueue(atestq, atestq, null, true);
ClientProducer producer = session.createProducer(atestq);
long time = System.currentTimeMillis();
time += 1000;
-
+
for (int i = 0; i < 1000; i++)
{
ClientMessage message = session.createMessage(true);
@@ -514,22 +499,22 @@
message.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, time);
producer.send(message);
}
-
+
session.commit();
-
-
+
+
session.start();
ClientConsumer consumer = session.createConsumer(atestq);
-
+
for (int i = 0 ; i < 1000; i++)
{
ClientMessage message = consumer.receive(15000);
assertNotNull(message);
message.acknowledge();
-
+
assertEquals(i, message.getIntProperty("value").intValue());
}
-
+
session.commit();
Assert.assertNull(consumer.receiveImmediate());
@@ -540,7 +525,7 @@
public void testScheduledAndNormalMessagesDeliveredCorrectly(final boolean recover) throws Exception
{
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(false, true, false);
session.createQueue(atestq, atestq, null, true);
ClientProducer producer = session.createProducer(atestq);
@@ -572,7 +557,7 @@
server = createServer(true, configuration);
server.start();
- sessionFactory = locator.createSessionFactory();
+ sessionFactory = createSessionFactory(locator);
session = sessionFactory.createSession(false, true, true);
}
@@ -614,7 +599,7 @@
Xid xid = new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
Xid xid2 = new XidImpl("xa2".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(true, false, false);
session.createQueue(atestq, atestq, null, true);
session.start(xid, XAResource.TMNOFLAGS);
@@ -634,7 +619,7 @@
server = createServer(true, configuration);
server.start();
- sessionFactory = locator.createSessionFactory();
+ sessionFactory = createSessionFactory(locator);
session = sessionFactory.createSession(true, false, false);
}
@@ -660,19 +645,19 @@
Assert.assertNull(consumer.receiveImmediate());
session.close();
}
-
-
+
+
public void testPendingACKOnPrepared() throws Exception
{
-
+
int NUMBER_OF_MESSAGES = 100;
-
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(true, false, false);
session.createQueue(atestq, atestq, null, true);
ClientProducer producer = session.createProducer(atestq);
-
+
long scheduled = System.currentTimeMillis() + 1000;
for (int i = 0 ; i < NUMBER_OF_MESSAGES; i++)
{
@@ -681,51 +666,51 @@
msg.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, scheduled);
producer.send(msg);
}
-
+
session.close();
-
-
+
+
for (int i = 0 ; i < NUMBER_OF_MESSAGES; i++)
{
Xid xid = newXID();
session = sessionFactory.createSession(true, false, false);
-
+
ClientConsumer consumer = session.createConsumer(atestq);
-
+
session.start();
session.start(xid, XAResource.TMNOFLAGS);
-
+
ClientMessage msg = consumer.receive(5000);
assertNotNull(msg);
msg.acknowledge();
session.end(xid, XAResource.TMSUCCESS);
-
+
session.prepare(xid);
-
+
session.close();
}
-
+
sessionFactory.close();
locator.close();
-
+
server.stop();
-
+
startServer();
-
- sessionFactory = locator.createSessionFactory();
-
+
+ sessionFactory = createSessionFactory(locator);
+
session = sessionFactory.createSession(false, false);
-
+
ClientConsumer consumer = session.createConsumer(atestq);
-
+
session.start();
-
+
assertNull(consumer.receive(1000));
-
+
session.close();
-
+
sessionFactory.close();
}
@@ -746,7 +731,7 @@
qs.setRedeliveryDelay(5000l);
server.getAddressSettingsRepository().addMatch(atestq.toString(), qs);
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(false, false, false);
session.createQueue(atestq, atestq, true);
@@ -801,11 +786,12 @@
final AtomicInteger count = new AtomicInteger(0);
Thread t = new Thread()
{
+ @Override
public void run()
{
try
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false);
session.start();
ClientConsumer cons = session.createConsumer(atestq);
@@ -831,7 +817,7 @@
t.start();
- sessionFactory = locator.createSessionFactory();
+ sessionFactory = createSessionFactory(locator);
session = sessionFactory.createSession(true, false, false);
@@ -858,7 +844,7 @@
Xid xid = new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(tx, false, false);
session.createQueue(atestq, atestq, null, true);
ClientProducer producer = session.createProducer(atestq);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/security/SecurityTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/security/SecurityTest.java 2011-12-06 12:03:29 UTC (rev 11855)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/security/SecurityTest.java 2011-12-06 12:38:34 UTC (rev 11856)
@@ -65,6 +65,7 @@
private ServerLocator locator;
+ private Configuration configuration;
@Override
protected void setUp() throws Exception
@@ -74,669 +75,456 @@
locator = createInVMNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- super.tearDown();
- }
-
public void testCreateSessionWithNullUserPass() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
+ HornetQServer server = createServer();
HornetQSecurityManager securityManager = server.getSecurityManager();
securityManager.addUser("guest", "guest");
securityManager.setDefaultUser("guest");
+ server.start();
+ ClientSessionFactory cf = locator.createSessionFactory();
+
try
{
- server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession(false, true, true);
- try
- {
- ClientSession session = cf.createSession(false, true, true);
-
- session.close();
- }
- catch (HornetQException e)
- {
- Assert.fail("should not throw exception");
- }
+ session.close();
}
- finally
+ catch (HornetQException e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.fail("should not throw exception");
}
}
- public void testCreateSessionWithNullUserPassNoGuest() throws Exception
+ /**
+ * @return
+ */
+ private HornetQServer createServer()
{
- Configuration configuration = createDefaultConfig(false);
+ configuration = createDefaultConfig(false);
configuration.setSecurityEnabled(true);
HornetQServer server = createServer(false, configuration);
+ return server;
+ }
+
+ public void testCreateSessionWithNullUserPassNoGuest() throws Exception
+ {
+ HornetQServer server = createServer();
+ server.start();
+ ClientSessionFactory cf = locator.createSessionFactory();
try
{
- server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
- try
- {
- cf.createSession(false, true, true);
- Assert.fail("should throw exception");
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
- }
+ cf.createSession(false, true, true);
+ Assert.fail("should throw exception");
}
- finally
+ catch (HornetQException e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
}
}
public void testCreateSessionWithCorrectUserWrongPass() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
+ HornetQServer server = createServer();
HornetQSecurityManager securityManager = server.getSecurityManager();
securityManager.addUser("newuser", "apass");
+ server.start();
+ ClientSessionFactory cf = locator.createSessionFactory();
+
try
{
- server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
-
- try
- {
- cf.createSession("newuser", "awrongpass", false, true, true, false, -1);
- Assert.fail("should not throw exception");
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
- }
+ cf.createSession("newuser", "awrongpass", false, true, true, false, -1);
+ Assert.fail("should not throw exception");
}
- finally
+ catch (HornetQException e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
}
}
public void testCreateSessionWithCorrectUserCorrectPass() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
+ HornetQServer server = createServer();
HornetQSecurityManager securityManager = server.getSecurityManager();
securityManager.addUser("newuser", "apass");
+ server.start();
+ ClientSessionFactory cf = locator.createSessionFactory();
+
try
{
- server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession("newuser", "apass", false, true, true, false, -1);
- try
- {
- ClientSession session = cf.createSession("newuser", "apass", false, true, true, false, -1);
-
- session.close();
- }
- catch (HornetQException e)
- {
- Assert.fail("should not throw exception");
- }
+ session.close();
}
- finally
+ catch (HornetQException e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.fail("should not throw exception");
}
}
public void testCreateDurableQueueWithRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
-
- try
- {
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- Role role = new Role("arole", false, false, true, false, false, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(role);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
- session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+ HornetQServer server = createServer();
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ Role role = new Role("arole", false, false, true, false, false, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(role);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
+ session.close();
}
public void testCreateDurableQueueWithoutRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
+ HornetQServer server = createServer();
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ Role role = new Role("arole", false, false, false, false, false, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(role);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
try
{
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- Role role = new Role("arole", false, false, false, false, false, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(role);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- try
- {
- session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
- Assert.fail("should throw exception");
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
- }
- session.close();
+ session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
+ Assert.fail("should throw exception");
}
- finally
+ catch (HornetQException e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
}
+ session.close();
}
public void testDeleteDurableQueueWithRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
-
- try
- {
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- Role role = new Role("arole", false, false, true, true, false, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(role);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
- session.deleteQueue(SecurityTest.queueA);
- session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+ HornetQServer server = createServer();
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ Role role = new Role("arole", false, false, true, true, false, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(role);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
+ session.deleteQueue(SecurityTest.queueA);
+ session.close();
}
public void testDeleteDurableQueueWithoutRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
-
+ HornetQServer server = createServer();
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ Role role = new Role("arole", false, false, true, false, false, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(role);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
try
{
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- Role role = new Role("arole", false, false, true, false, false, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(role);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
- try
- {
- session.deleteQueue(SecurityTest.queueA);
- Assert.fail("should throw exception");
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
- }
- session.close();
+ session.deleteQueue(SecurityTest.queueA);
+ Assert.fail("should throw exception");
}
- finally
+ catch (HornetQException e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
}
+ session.close();
}
public void testCreateTempQueueWithRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
+ HornetQServer server = createServer();
- try
- {
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- Role role = new Role("arole", false, false, false, false, true, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(role);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false);
- session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ Role role = new Role("arole", false, false, false, false, true, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(role);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false);
+ session.close();
}
public void testCreateTempQueueWithoutRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
+ HornetQServer server = createServer();
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ Role role = new Role("arole", false, false, false, false, false, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(role);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
try
{
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- Role role = new Role("arole", false, false, false, false, false, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(role);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- try
- {
- session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false);
- Assert.fail("should throw exception");
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
- }
- session.close();
+ session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false);
+ Assert.fail("should throw exception");
}
- finally
+ catch (HornetQException e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
}
+ session.close();
}
public void testDeleteTempQueueWithRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
-
- try
- {
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- Role role = new Role("arole", false, false, false, false, true, true, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(role);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false);
- session.deleteQueue(SecurityTest.queueA);
- session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+ HornetQServer server = createServer();
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ Role role = new Role("arole", false, false, false, false, true, true, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(role);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false);
+ session.deleteQueue(SecurityTest.queueA);
+ session.close();
}
public void testDeleteTempQueueWithoutRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
-
+ HornetQServer server = createServer();
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ Role role = new Role("arole", false, false, false, false, true, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(role);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false);
try
{
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- Role role = new Role("arole", false, false, false, false, true, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(role);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false);
- try
- {
- session.deleteQueue(SecurityTest.queueA);
- Assert.fail("should throw exception");
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
- }
- session.close();
+ session.deleteQueue(SecurityTest.queueA);
+ Assert.fail("should throw exception");
}
- finally
+ catch (HornetQException e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
}
+ session.close();
}
public void testSendWithRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
+ HornetQServer server = createServer();
- try
- {
- server.start();
+ server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
+ securityManager.addUser("auser", "pass");
- Role role = new Role("arole", true, true, true, false, false, false, false);
+ Role role = new Role("arole", true, true, true, false, false, false, false);
- Set<Role> roles = new HashSet<Role>();
+ Set<Role> roles = new HashSet<Role>();
- roles.add(role);
+ roles.add(role);
- securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
+ securityManager.addRole("auser", "arole");
- locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnNonDurableSend(true);
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
+ session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
- ClientProducer cp = session.createProducer(SecurityTest.addressA);
+ ClientProducer cp = session.createProducer(SecurityTest.addressA);
- cp.send(session.createMessage(false));
+ cp.send(session.createMessage(false));
- session.start();
+ session.start();
- ClientConsumer cons = session.createConsumer(queueA);
+ ClientConsumer cons = session.createConsumer(queueA);
- ClientMessage receivedMessage = cons.receive(5000);
+ ClientMessage receivedMessage = cons.receive(5000);
- assertNotNull(receivedMessage);
+ assertNotNull(receivedMessage);
- receivedMessage.acknowledge();
+ receivedMessage.acknowledge();
- role = new Role("arole", false, false, true, false, false, false, false);
+ role = new Role("arole", false, false, true, false, false, false, false);
- roles = new HashSet<Role>();
+ roles = new HashSet<Role>();
- roles.add(role);
+ roles.add(role);
-
- // This was added to validate https://issues.jboss.org/browse/SOA-3363
- securityRepository.addMatch(SecurityTest.addressA, roles);
- boolean failed = false;
- try
- {
- cp.send(session.createMessage(true));
- }
- catch (HornetQException e)
- {
- failed = true;
- }
- // This was added to validate https://issues.jboss.org/browse/SOA-3363 ^^^^^
-
- assertTrue("Failure expected on send after removing the match", failed);
-
-
- session.close();
-
+ // This was added to validate https://issues.jboss.org/browse/SOA-3363
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ boolean failed = false;
+ try
+ {
+ cp.send(session.createMessage(true));
}
- finally
+ catch (HornetQException e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ failed = true;
}
+ // This was added to validate https://issues.jboss.org/browse/SOA-3363 ^^^^^
+
+ assertTrue("Failure expected on send after removing the match", failed);
}
public void testSendWithoutRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
+ HornetQServer server = createServer();
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ Role role = new Role("arole", false, false, true, false, false, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(role);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ locator.setBlockOnNonDurableSend(true);
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
+ ClientProducer cp = session.createProducer(SecurityTest.addressA);
try
{
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- Role role = new Role("arole", false, false, true, false, false, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(role);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- locator.setBlockOnNonDurableSend(true);
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
- ClientProducer cp = session.createProducer(SecurityTest.addressA);
- try
- {
- cp.send(session.createMessage(false));
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
- }
- session.close();
+ cp.send(session.createMessage(false));
}
- finally
+ catch (HornetQException e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
}
+ session.close();
}
public void testNonBlockSendWithoutRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
+ HornetQServer server = createServer();
- try
- {
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- Role role = new Role("arole", false, false, true, false, false, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(role);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
- ClientProducer cp = session.createProducer(SecurityTest.addressA);
- cp.send(session.createMessage(false));
- session.close();
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ Role role = new Role("arole", false, false, true, false, false, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(role);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
+ ClientProducer cp = session.createProducer(SecurityTest.addressA);
+ cp.send(session.createMessage(false));
+ session.close();
- Queue binding = (Queue)server.getPostOffice().getBinding(new SimpleString(SecurityTest.queueA)).getBindable();
- Assert.assertEquals(0, binding.getMessageCount());
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+ Queue binding = (Queue)server.getPostOffice().getBinding(new SimpleString(SecurityTest.queueA)).getBindable();
+ Assert.assertEquals(0, binding.getMessageCount());
}
public void testCreateConsumerWithRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
-
- try
- {
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- securityManager.addUser("guest", "guest");
- securityManager.addRole("guest", "guest");
- securityManager.setDefaultUser("guest");
- Role role = new Role("arole", false, true, false, false, false, false, false);
- Role sendRole = new Role("guest", true, false, true, false, false, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(sendRole);
- roles.add(role);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession senSession = cf.createSession(false, true, true);
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- senSession.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
- ClientProducer cp = senSession.createProducer(SecurityTest.addressA);
- cp.send(session.createMessage(false));
- session.createConsumer(SecurityTest.queueA);
- session.close();
- senSession.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+ HornetQServer server = createServer();
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ securityManager.addUser("guest", "guest");
+ securityManager.addRole("guest", "guest");
+ securityManager.setDefaultUser("guest");
+ Role role = new Role("arole", false, true, false, false, false, false, false);
+ Role sendRole = new Role("guest", true, false, true, false, false, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(sendRole);
+ roles.add(role);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession senSession = cf.createSession(false, true, true);
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ senSession.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
+ ClientProducer cp = senSession.createProducer(SecurityTest.addressA);
+ cp.send(session.createMessage(false));
+ session.createConsumer(SecurityTest.queueA);
+ session.close();
+ senSession.close();
}
public void testCreateConsumerWithoutRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
-
+ HornetQServer server = createServer();
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ securityManager.addUser("guest", "guest");
+ securityManager.addRole("guest", "guest");
+ securityManager.setDefaultUser("guest");
+ Role role = new Role("arole", false, false, false, false, false, false, false);
+ Role sendRole = new Role("guest", true, false, true, false, false, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(sendRole);
+ roles.add(role);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession senSession = cf.createSession(false, true, true);
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ senSession.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
+ ClientProducer cp = senSession.createProducer(SecurityTest.addressA);
+ cp.send(session.createMessage(false));
try
{
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- securityManager.addUser("guest", "guest");
- securityManager.addRole("guest", "guest");
- securityManager.setDefaultUser("guest");
- Role role = new Role("arole", false, false, false, false, false, false, false);
- Role sendRole = new Role("guest", true, false, true, false, false, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(sendRole);
- roles.add(role);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession senSession = cf.createSession(false, true, true);
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- senSession.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
- ClientProducer cp = senSession.createProducer(SecurityTest.addressA);
- cp.send(session.createMessage(false));
- try
- {
- session.createConsumer(SecurityTest.queueA);
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
- }
- session.close();
- senSession.close();
+ session.createConsumer(SecurityTest.queueA);
}
- finally
+ catch (HornetQException e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
}
+ session.close();
+ senSession.close();
}
public void testSendMessageUpdateRoleCached() throws Exception
@@ -745,60 +533,49 @@
configuration.setSecurityEnabled(true);
configuration.setSecurityInvalidationInterval(10000);
HornetQServer server = createServer(false, configuration);
-
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ securityManager.addUser("guest", "guest");
+ securityManager.addRole("guest", "guest");
+ securityManager.setDefaultUser("guest");
+ Role role = new Role("arole", false, false, false, false, false, false, false);
+ Role sendRole = new Role("guest", true, false, true, false, false, false, false);
+ Role receiveRole = new Role("receiver", false, true, false, false, false, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(sendRole);
+ roles.add(role);
+ roles.add(receiveRole);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession senSession = cf.createSession(false, true, true);
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ senSession.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
+ ClientProducer cp = senSession.createProducer(SecurityTest.addressA);
+ cp.send(session.createMessage(false));
try
{
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- securityManager.addUser("guest", "guest");
- securityManager.addRole("guest", "guest");
- securityManager.setDefaultUser("guest");
- Role role = new Role("arole", false, false, false, false, false, false, false);
- Role sendRole = new Role("guest", true, false, true, false, false, false, false);
- Role receiveRole = new Role("receiver", false, true, false, false, false, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(sendRole);
- roles.add(role);
- roles.add(receiveRole);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession senSession = cf.createSession(false, true, true);
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- senSession.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
- ClientProducer cp = senSession.createProducer(SecurityTest.addressA);
- cp.send(session.createMessage(false));
- try
- {
- session.createConsumer(SecurityTest.queueA);
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
- }
+ session.createConsumer(SecurityTest.queueA);
+ }
+ catch (HornetQException e)
+ {
+ Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
+ }
- securityManager.addRole("auser", "receiver");
+ securityManager.addRole("auser", "receiver");
- session.createConsumer(SecurityTest.queueA);
+ session.createConsumer(SecurityTest.queueA);
- // Removing the Role... the check should be cached, so the next createConsumer shouldn't fail
- securityManager.removeRole("auser", "receiver");
+ // Removing the Role... the check should be cached, so the next createConsumer shouldn't fail
+ securityManager.removeRole("auser", "receiver");
- session.createConsumer(SecurityTest.queueA);
+ session.createConsumer(SecurityTest.queueA);
- session.close();
+ session.close();
- senSession.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+ senSession.close();
}
public void testSendMessageUpdateRoleCached2() throws Exception
@@ -808,67 +585,58 @@
configuration.setSecurityInvalidationInterval(0);
HornetQServer server = createServer(false, configuration);
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ securityManager.addUser("guest", "guest");
+ securityManager.addRole("guest", "guest");
+ securityManager.setDefaultUser("guest");
+ Role role = new Role("arole", false, false, false, false, false, false, false);
+ Role sendRole = new Role("guest", true, false, true, false, false, false, false);
+ Role receiveRole = new Role("receiver", false, true, false, false, false, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(sendRole);
+ roles.add(role);
+ roles.add(receiveRole);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession senSession = cf.createSession(false, true, true);
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ senSession.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
+ ClientProducer cp = senSession.createProducer(SecurityTest.addressA);
+ cp.send(session.createMessage(false));
try
{
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- securityManager.addUser("guest", "guest");
- securityManager.addRole("guest", "guest");
- securityManager.setDefaultUser("guest");
- Role role = new Role("arole", false, false, false, false, false, false, false);
- Role sendRole = new Role("guest", true, false, true, false, false, false, false);
- Role receiveRole = new Role("receiver", false, true, false, false, false, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(sendRole);
- roles.add(role);
- roles.add(receiveRole);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession senSession = cf.createSession(false, true, true);
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- senSession.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
- ClientProducer cp = senSession.createProducer(SecurityTest.addressA);
- cp.send(session.createMessage(false));
- try
- {
- session.createConsumer(SecurityTest.queueA);
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
- }
-
- securityManager.addRole("auser", "receiver");
-
session.createConsumer(SecurityTest.queueA);
+ }
+ catch (HornetQException e)
+ {
+ Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
+ }
- // Removing the Role... the check should be cached... but we used setSecurityInvalidationInterval(0), so the
- // next createConsumer should fail
- securityManager.removeRole("auser", "receiver");
+ securityManager.addRole("auser", "receiver");
- try
- {
- session.createConsumer(SecurityTest.queueA);
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
- }
+ session.createConsumer(SecurityTest.queueA);
- session.close();
+ // Removing the Role... the check should be cached... but we used
+ // setSecurityInvalidationInterval(0), so the
+ // next createConsumer should fail
+ securityManager.removeRole("auser", "receiver");
- senSession.close();
+ try
+ {
+ session.createConsumer(SecurityTest.queueA);
}
- finally
+ catch (HornetQException e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
}
+
+ session.close();
+
+ senSession.close();
}
public void testSendMessageUpdateSender() throws Exception
@@ -877,220 +645,176 @@
configuration.setSecurityEnabled(true);
configuration.setSecurityInvalidationInterval(-1);
HornetQServer server = createServer(false, configuration);
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ securityManager.addUser("guest", "guest");
+ securityManager.addRole("guest", "guest");
+ securityManager.setDefaultUser("guest");
+ Role role = new Role("arole", false, false, false, false, false, false, false);
+ System.out.println("guest:" + role);
+ Role sendRole = new Role("guest", true, false, true, false, false, false, false);
+ System.out.println("guest:" + sendRole);
+ Role receiveRole = new Role("receiver", false, true, false, false, false, false, false);
+ System.out.println("guest:" + receiveRole);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(sendRole);
+ roles.add(role);
+ roles.add(receiveRole);
+ securityRepository.addMatch(SecurityTest.addressA, roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession senSession = cf.createSession(false, true, true);
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ senSession.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
+ ClientProducer cp = senSession.createProducer(SecurityTest.addressA);
+ cp.send(session.createMessage(false));
try
{
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- securityManager.addUser("guest", "guest");
- securityManager.addRole("guest", "guest");
- securityManager.setDefaultUser("guest");
- Role role = new Role("arole", false, false, false, false, false, false, false);
- System.out.println("guest:" + role);
- Role sendRole = new Role("guest", true, false, true, false, false, false, false);
- System.out.println("guest:" + sendRole);
- Role receiveRole = new Role("receiver", false, true, false, false, false, false, false);
- System.out.println("guest:" + receiveRole);
- Set<Role> roles = new HashSet<Role>();
- roles.add(sendRole);
- roles.add(role);
- roles.add(receiveRole);
- securityRepository.addMatch(SecurityTest.addressA, roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
-
- ClientSession senSession = cf.createSession(false, true, true);
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- senSession.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
- ClientProducer cp = senSession.createProducer(SecurityTest.addressA);
- cp.send(session.createMessage(false));
- try
- {
- session.createConsumer(SecurityTest.queueA);
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
- }
-
- securityManager.addRole("auser", "receiver");
-
session.createConsumer(SecurityTest.queueA);
+ }
+ catch (HornetQException e)
+ {
+ Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
+ }
- // Removing the Role... the check should be cached... but we used setSecurityInvalidationInterval(0), so the
- // next createConsumer should fail
- securityManager.removeRole("auser", "guest");
+ securityManager.addRole("auser", "receiver");
- ClientSession sendingSession = cf.createSession("auser", "pass", false, false, false, false, 0);
- ClientProducer prod = sendingSession.createProducer(SecurityTest.addressA);
- prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true));
- prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true));
- try
- {
- sendingSession.commit();
- Assert.fail("Expected exception");
- }
- catch (HornetQException e)
- {
- // I would expect the commit to fail, since there were failures registered
- }
+ session.createConsumer(SecurityTest.queueA);
- sendingSession.close();
+ // Removing the Role... the check should be cached... but we used
+ // setSecurityInvalidationInterval(0), so the
+ // next createConsumer should fail
+ securityManager.removeRole("auser", "guest");
- Xid xid = newXID();
+ ClientSession sendingSession = cf.createSession("auser", "pass", false, false, false, false, 0);
+ ClientProducer prod = sendingSession.createProducer(SecurityTest.addressA);
+ prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true));
+ prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true));
+ try
+ {
+ sendingSession.commit();
+ Assert.fail("Expected exception");
+ }
+ catch (HornetQException e)
+ {
+ // I would expect the commit to fail, since there were failures registered
+ }
- sendingSession = cf.createSession("auser", "pass", true, false, false, false, 0);
- sendingSession.start(xid, XAResource.TMNOFLAGS);
+ sendingSession.close();
- prod = sendingSession.createProducer(SecurityTest.addressA);
- prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true));
- prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true));
- sendingSession.end(xid, XAResource.TMSUCCESS);
+ Xid xid = newXID();
- try
- {
- sendingSession.prepare(xid);
- Assert.fail("Exception was expected");
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
+ sendingSession = cf.createSession("auser", "pass", true, false, false, false, 0);
+ sendingSession.start(xid, XAResource.TMNOFLAGS);
- // A prepare shouldn't mark any recoverable resources
- Xid[] xids = sendingSession.recover(XAResource.TMSTARTRSCAN);
- Assert.assertEquals(0, xids.length);
+ prod = sendingSession.createProducer(SecurityTest.addressA);
+ prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true));
+ prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true));
+ sendingSession.end(xid, XAResource.TMSUCCESS);
- session.close();
-
- senSession.close();
-
- sendingSession.close();
+ try
+ {
+ sendingSession.prepare(xid);
+ Assert.fail("Exception was expected");
}
- finally
+ catch (Exception e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ e.printStackTrace();
}
+
+ // A prepare shouldn't mark any recoverable resources
+ Xid[] xids = sendingSession.recover(XAResource.TMSTARTRSCAN);
+ Assert.assertEquals(0, xids.length);
+
+ session.close();
+
+ senSession.close();
+
+ sendingSession.close();
}
public void testSendManagementWithRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
+ HornetQServer server = createServer();
- try
- {
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- Role role = new Role("arole", false, false, false, false, false, false, true);
- Set<Role> roles = new HashSet<Role>();
- roles.add(role);
- securityRepository.addMatch(configuration.getManagementAddress().toString(), roles);
- securityManager.addRole("auser", "arole");
- locator.setBlockOnNonDurableSend(true);
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- ClientProducer cp = session.createProducer(configuration.getManagementAddress());
- cp.send(session.createMessage(false));
- session.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ Role role = new Role("arole", false, false, false, false, false, false, true);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(role);
+ securityRepository.addMatch(configuration.getManagementAddress().toString(), roles);
+ securityManager.addRole("auser", "arole");
+ locator.setBlockOnNonDurableSend(true);
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ ClientProducer cp = session.createProducer(configuration.getManagementAddress());
+ cp.send(session.createMessage(false));
+ session.close();
}
public void testSendManagementWithoutRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
+ HornetQServer server = createServer();
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ Role role = new Role("arole", false, false, true, false, false, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(role);
+ securityRepository.addMatch(configuration.getManagementAddress().toString(), roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ session.createQueue(configuration.getManagementAddress().toString(), SecurityTest.queueA, true);
+ ClientProducer cp = session.createProducer(configuration.getManagementAddress());
+ cp.send(session.createMessage(false));
try
{
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- Role role = new Role("arole", false, false, true, false, false, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(role);
- securityRepository.addMatch(configuration.getManagementAddress().toString(), roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- session.createQueue(configuration.getManagementAddress().toString(), SecurityTest.queueA, true);
- ClientProducer cp = session.createProducer(configuration.getManagementAddress());
cp.send(session.createMessage(false));
- try
- {
- cp.send(session.createMessage(false));
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
- }
- session.close();
}
- finally
+ catch (HornetQException e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
}
+ session.close();
+
}
public void testNonBlockSendManagementWithoutRole() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
+ HornetQServer server = createServer();
- try
- {
- server.start();
- HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
- HornetQSecurityManager securityManager = server.getSecurityManager();
- securityManager.addUser("auser", "pass");
- Role role = new Role("arole", false, false, true, false, false, false, false);
- Set<Role> roles = new HashSet<Role>();
- roles.add(role);
- securityRepository.addMatch(configuration.getManagementAddress().toString(), roles);
- securityManager.addRole("auser", "arole");
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
- session.createQueue(configuration.getManagementAddress().toString(), SecurityTest.queueA, true);
- ClientProducer cp = session.createProducer(configuration.getManagementAddress());
- cp.send(session.createMessage(false));
- session.close();
+ server.start();
+ HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+ HornetQSecurityManager securityManager = server.getSecurityManager();
+ securityManager.addUser("auser", "pass");
+ Role role = new Role("arole", false, false, true, false, false, false, false);
+ Set<Role> roles = new HashSet<Role>();
+ roles.add(role);
+ securityRepository.addMatch(configuration.getManagementAddress().toString(), roles);
+ securityManager.addRole("auser", "arole");
+ ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+ session.createQueue(configuration.getManagementAddress().toString(), SecurityTest.queueA, true);
+ ClientProducer cp = session.createProducer(configuration.getManagementAddress());
+ cp.send(session.createMessage(false));
+ session.close();
- Queue binding = (Queue)server.getPostOffice().getBinding(new SimpleString(SecurityTest.queueA)).getBindable();
- Assert.assertEquals(0, binding.getMessageCount());
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+ Queue binding = (Queue)server.getPostOffice().getBinding(new SimpleString(SecurityTest.queueA)).getBindable();
+ Assert.assertEquals(0, binding.getMessageCount());
+
}
/*
- * basic JAAS tests
- * */
+ * basic JAAS tests
+ */
public void testJaasCreateSessionSucceeds() throws Exception
{
@@ -1111,29 +835,20 @@
Map<String, Object> options = new HashMap<String, Object>();
options.put("authenticated", Boolean.TRUE);
securityManager.setConfiguration(new SimpleConfiguration(domainName, options));
+ server.start();
+ ClientSessionFactory cf = locator.createSessionFactory();
+
try
{
- server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSession session = cf.createSession(false, true, true);
- try
- {
- ClientSession session = cf.createSession(false, true, true);
-
- session.close();
- }
- catch (HornetQException e)
- {
- Assert.fail("should not throw exception");
- }
+ session.close();
}
- finally
+ catch (HornetQException e)
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.fail("should not throw exception");
}
+
}
public void testJaasCreateSessionFails() throws Exception
@@ -1155,9 +870,7 @@
Map<String, Object> options = new HashMap<String, Object>();
options.put("authenticated", Boolean.FALSE);
securityManager.setConfiguration(new SimpleConfiguration(domainName, options));
- try
- {
- server.start();
+ server.start();
ClientSessionFactory cf = locator.createSessionFactory();
try
@@ -1169,24 +882,13 @@
{
Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
}
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+
}
public void testComplexRoles() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
- try
- {
- server.start();
+ HornetQServer server = createServer();
+ server.start();
HornetQSecurityManager securityManager = server.getSecurityManager();
securityManager.addUser("all", "all");
securityManager.addUser("bill", "hornetq");
@@ -1274,16 +976,20 @@
checkUserSendAndReceive(genericQueueName, frankConnection);
checkUserSendAndReceive(genericQueueName, samConnection);
- // Step 11. Check permissions on news.europe.europeTopic for bill: can't send and can't receive
+ // Step 11. Check permissions on news.europe.europeTopic for bill: can't send and can't
+ // receive
checkUserNoSendNoReceive(eurQueueName, billConnection, adminSession);
- // Step 12. Check permissions on news.europe.europeTopic for andrew: can send but can't receive
+ // Step 12. Check permissions on news.europe.europeTopic for andrew: can send but can't
+ // receive
checkUserSendNoReceive(eurQueueName, andrewConnection);
- // Step 13. Check permissions on news.europe.europeTopic for frank: can't send but can receive
+ // Step 13. Check permissions on news.europe.europeTopic for frank: can't send but can
+ // receive
checkUserReceiveNoSend(eurQueueName, frankConnection, adminSession);
- // Step 14. Check permissions on news.europe.europeTopic for sam: can't send but can receive
+ // Step 14. Check permissions on news.europe.europeTopic for sam: can't send but can
+ // receive
checkUserReceiveNoSend(eurQueueName, samConnection, adminSession);
// Step 15. Check permissions on news.us.usTopic for bill: can't send and can't receive
@@ -1307,24 +1013,13 @@
samConnection.close();
adminSession.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+
}
public void _testComplexRoles2() throws Exception
{
- Configuration configuration = createDefaultConfig(false);
- configuration.setSecurityEnabled(true);
- HornetQServer server = createServer(false, configuration);
- try
- {
- server.start();
+ HornetQServer server = createServer();
+ server.start();
HornetQSecurityManager securityManager = server.getSecurityManager();
securityManager.addUser("all", "all");
securityManager.addUser("bill", "hornetq");
@@ -1412,16 +1107,20 @@
checkUserSendAndReceive(genericQueueName, frankConnection);
checkUserSendAndReceive(genericQueueName, samConnection);
- // Step 11. Check permissions on news.europe.europeTopic for bill: can't send and can't receive
+ // Step 11. Check permissions on news.europe.europeTopic for bill: can't send and can't
+ // receive
checkUserNoSendNoReceive(eurQueueName, billConnection, adminSession);
- // Step 12. Check permissions on news.europe.europeTopic for andrew: can send but can't receive
+ // Step 12. Check permissions on news.europe.europeTopic for andrew: can send but can't
+ // receive
checkUserSendNoReceive(eurQueueName, andrewConnection);
- // Step 13. Check permissions on news.europe.europeTopic for frank: can't send but can receive
+ // Step 13. Check permissions on news.europe.europeTopic for frank: can't send but can
+ // receive
checkUserReceiveNoSend(eurQueueName, frankConnection, adminSession);
- // Step 14. Check permissions on news.europe.europeTopic for sam: can't send but can receive
+ // Step 14. Check permissions on news.europe.europeTopic for sam: can't send but can
+ // receive
checkUserReceiveNoSend(eurQueueName, samConnection, adminSession);
// Step 15. Check permissions on news.us.usTopic for bill: can't send and can't receive
@@ -1435,14 +1134,7 @@
// Step 18. Check permissions on news.us.usTopic for same: can't send but can receive
checkUserReceiveNoSend(usQueueName, samConnection, adminSession);
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+
}
// Check the user connection has both send and receive permissions on the queue
@@ -1466,8 +1158,7 @@
}
// Check the user can receive message but cannot send message.
- private void checkUserReceiveNoSend(final String queue,
- final ClientSession connection,
+ private void checkUserReceiveNoSend(final String queue, final ClientSession connection,
final ClientSession sendingConn) throws Exception
{
connection.start();
@@ -1498,8 +1189,7 @@
}
}
- private void checkUserNoSendNoReceive(final String queue,
- final ClientSession connection,
+ private void checkUserNoSendNoReceive(final String queue, final ClientSession connection,
final ClientSession sendingConn) throws Exception
{
connection.start();
@@ -1574,10 +1264,8 @@
return true;
}
- public void initialize(final Subject subject,
- final CallbackHandler callbackHandler,
- final Map<String, ?> sharedState,
- final Map<String, ?> options)
+ public void initialize(final Subject subject, final CallbackHandler callbackHandler,
+ final Map<String, ?> sharedState, final Map<String, ?> options)
{
this.subject = subject;
this.options = options;
@@ -1622,9 +1310,9 @@
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(final String name)
{
- AppConfigurationEntry entry = new AppConfigurationEntry(loginModuleName,
- AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
- options);
+ AppConfigurationEntry entry =
+ new AppConfigurationEntry(loginModuleName, AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
+ options);
return new AppConfigurationEntry[] { entry };
}
13 years
JBoss hornetq SVN: r11855 - trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/remoting/impl/ssl.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-12-06 07:03:29 -0500 (Tue, 06 Dec 2011)
New Revision: 11855
Modified:
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java
Log:
fixed ssl test
Modified: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java 2011-12-06 11:42:23 UTC (rev 11854)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java 2011-12-06 12:03:29 UTC (rev 11855)
@@ -98,7 +98,7 @@
return;
}
- SSLSupport.createServerContext("config/hornetq.keystore", keyStorePassword, trustStorePath, trustStorePassword);
+ SSLSupport.createServerContext("src/test/resources/hornetq.keystore", keyStorePassword, trustStorePath, trustStorePassword);
}
public void testServerContextWithBadKeyStorePassword() throws Exception
13 years
JBoss hornetq SVN: r11854 - in trunk: tests/integration-tests/src/test/java/org/hornetq/tests/integration and 7 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2011-12-06 06:42:23 -0500 (Tue, 06 Dec 2011)
New Revision: 11854
Modified:
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/DuplicateDetectionTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/InterceptorTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DurableQueueTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ExpiryAddressTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/FailureDeadlockTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/HeuristicXATest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/IncompatibleVersionTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCloseOnGCTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateAndDeleteQueueTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateConsumerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateProducerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/NettyReplicatedFailoverTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/PagingFailoverTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SecurityFailoverTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/IsolatedTopologyTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/ExportFormatTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/RolesConfigurationStorageTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/SynchronousCloseTest.java
trunk/tests/soak-tests/src/test/java/org/hornetq/tests/soak/client/SimpleSendReceiveSoakTest.java
trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/CompactingStressTest.java
Log:
Another massive deletion of unnecessary tearDown code.
Modified: trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/hornetq-core/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -516,6 +516,12 @@
return createServer(realFiles, configuration, -1, -1, new HashMap<String, AddressSettings>());
}
+ protected HornetQServer createServer(final Configuration configuration)
+ {
+ return createServer(configuration.isPersistenceEnabled(), configuration, -1, -1,
+ new HashMap<String, AddressSettings>());
+ }
+
protected HornetQServer createInVMFailoverServer(final boolean realFiles,
final Configuration configuration,
final NodeManager nodeManager,
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/DuplicateDetectionTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/DuplicateDetectionTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/DuplicateDetectionTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -23,11 +23,16 @@
import org.hornetq.api.core.Message;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.HornetQClient;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.transaction.impl.XidImpl;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.utils.UUIDGenerator;
@@ -36,7 +41,7 @@
* A DuplicateDetectionTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
+ *
* Created 9 Dec 2008 12:31:48
*
*
@@ -528,7 +533,7 @@
session.start();
final SimpleString queueName = new SimpleString("DuplicateDetectionTestQueue");
-
+
final SimpleString queue2 = new SimpleString("queue2");
session.createQueue(queueName, queueName, null, false);
@@ -541,7 +546,7 @@
SimpleString dupID = new SimpleString("abcdefg");
message.putBytesProperty(Message.HDR_DUPLICATE_DETECTION_ID, dupID.getData());
producer.send(message);
-
+
ClientMessage message2 = createMessage(session,0);
ClientProducer producer2 = session.createProducer(queue2);
producer2.send(message2);
@@ -553,7 +558,7 @@
session = sf.createSession(false, false, false);
session.start();
-
+
ClientConsumer consumer2 = session.createConsumer(queue2);
producer = session.createProducer(queueName);
@@ -570,12 +575,12 @@
message = createMessage(session, 4);
producer.send(message);
-
+
message = consumer2.receive(5000);
assertNotNull(message);
message.acknowledge();
-
+
try
{
session.commit();
@@ -593,13 +598,13 @@
message = consumer.receiveImmediate();
Assert.assertNull(message);
-
-
+
+
message = consumer2.receive(5000);
assertNotNull(message);
-
+
message.acknowledge();
-
+
session.commit();
session.close();
@@ -903,7 +908,7 @@
session.close();
session = sf.createSession(false, false, false);
-
+
session.start();
ClientConsumer consumer = session.createConsumer(queueName);
@@ -1113,7 +1118,7 @@
conf.setIDCacheSize(cacheSize);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1153,7 +1158,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1200,7 +1205,7 @@
conf.setIDCacheSize(theCacheSize);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1236,7 +1241,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1282,7 +1287,7 @@
conf.setIDCacheSize(initialCacheSize);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1320,7 +1325,7 @@
conf.setIDCacheSize(subsequentCacheSize);
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1375,7 +1380,7 @@
conf.setIDCacheSize(initialCacheSize);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1413,7 +1418,7 @@
conf.setIDCacheSize(subsequentCacheSize);
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1423,7 +1428,7 @@
conf.setIDCacheSize(initialCacheSize);
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1477,7 +1482,7 @@
conf.setPersistIDCache(false);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1517,7 +1522,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1564,7 +1569,7 @@
conf.setPersistIDCache(false);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1606,7 +1611,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1653,7 +1658,7 @@
conf.setIDCacheSize(cacheSize);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1699,7 +1704,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1735,7 +1740,7 @@
message = createMessage(session, 2);
message.putBytesProperty(Message.HDR_DUPLICATE_DETECTION_ID, dupID2.getData());
producer.send(message);
-
+
try
{
session.commit();
@@ -1768,7 +1773,7 @@
conf.setPersistIDCache(false);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1812,7 +1817,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1871,7 +1876,7 @@
conf.setIDCacheSize(cacheSize);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -1913,7 +1918,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -1972,7 +1977,7 @@
conf.setIDCacheSize(cacheSize);
- HornetQServer messagingService2 = HornetQServers.newHornetQServer(conf);
+ HornetQServer messagingService2 = createServer(conf);
messagingService2.start();
@@ -2016,7 +2021,7 @@
messagingService2.stop();
- messagingService2 = HornetQServers.newHornetQServer(conf);
+ messagingService2 = createServer(conf);
messagingService2.start();
@@ -2053,7 +2058,7 @@
catch (XAException expected)
{
}
-
+
session.rollback(xid2);
@@ -2087,21 +2092,8 @@
conf.setIDCacheSize(cacheSize);
- messagingService = HornetQServers.newHornetQServer(conf, true);
+ messagingService = createServer(true, conf);
messagingService.start();
}
-
- @Override
- protected void tearDown() throws Exception
- {
- if (messagingService.isStarted())
- {
- messagingService.stop();
- }
-
- messagingService = null;
-
- super.tearDown();
- }
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/InterceptorTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/InterceptorTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/InterceptorTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -18,8 +18,12 @@
import org.hornetq.api.core.Interceptor;
import org.hornetq.api.core.Message;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
-import org.hornetq.core.logging.Logger;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.protocol.core.Packet;
import org.hornetq.core.protocol.core.impl.PacketImpl;
import org.hornetq.core.protocol.core.impl.wireformat.SessionReceiveMessage;
@@ -30,7 +34,7 @@
import org.hornetq.tests.util.ServiceTestBase;
/**
- *
+ *
* A InterceptorTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a> fox
@@ -39,8 +43,6 @@
*/
public class InterceptorTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(InterceptorTest.class);
-
private HornetQServer server;
private final SimpleString QUEUE = new SimpleString("InterceptorTestQueue");
@@ -59,18 +61,6 @@
locator = createInVMNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
private static final String key = "fruit";
private class MyInterceptor1 implements Interceptor
@@ -249,7 +239,7 @@
server.getRemotingService().addInterceptor(interceptor);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true, true);
@@ -309,7 +299,7 @@
locator.setBlockOnNonDurableSend(false);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true, true);
@@ -339,7 +329,7 @@
public void testClientInterceptorChangeProperty() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
MyInterceptor3 interceptor = new MyInterceptor3();
@@ -396,7 +386,7 @@
public void testClientInterceptorRejectPacket() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
MyInterceptor4 interceptor = new MyInterceptor4();
@@ -440,7 +430,7 @@
server.getRemotingService().addInterceptor(interceptor3);
server.getRemotingService().addInterceptor(interceptor4);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true, true);
@@ -524,7 +514,7 @@
MyInterceptor6 interceptor3 = new MyInterceptor6("c", 3);
MyInterceptor6 interceptor4 = new MyInterceptor6("d", 4);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
sf.getServerLocator().addInterceptor(interceptor1);
sf.getServerLocator().addInterceptor(interceptor2);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DurableQueueTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DurableQueueTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DurableQueueTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -16,8 +16,12 @@
import junit.framework.Assert;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
@@ -66,8 +70,6 @@
consumer.close();
session.deleteQueue(queue);
-
- session.close();
}
public void testConsumeFromDurableQueueAfterServerRestart() throws Exception
@@ -96,8 +98,6 @@
consumer.close();
session.deleteQueue(queue);
-
- session.close();
}
public void testProduceAndConsumeFromDurableQueueAfterServerRestart() throws Exception
@@ -127,8 +127,6 @@
consumer.close();
session.deleteQueue(queue);
-
- session.close();
}
// Package protected ---------------------------------------------
@@ -146,33 +144,8 @@
locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
- session = sf.createSession(false, true, true);
+ session = addClientSession(sf.createSession(false, true, true));
}
-
- @Override
- protected void tearDown() throws Exception
- {
- session.close();
-
- locator.close();
-
- server.stop();
-
- sf.close();
-
- session = null;
-
- server = null;
-
- sf = null;
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ExpiryAddressTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ExpiryAddressTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ExpiryAddressTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -14,16 +14,19 @@
import junit.framework.Assert;
-import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.Message;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.HornetQClient;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
@@ -310,49 +313,16 @@
configuration.setSecurityEnabled(false);
TransportConfiguration transportConfig = new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY);
configuration.getAcceptorConfigurations().add(transportConfig);
- server = HornetQServers.newHornetQServer(configuration, false);
+ server = createServer(false, configuration);
// start the server
server.start();
// then we create a client as normal
- locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY));
-
- locator.setBlockOnAcknowledge(true);
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
-// There are assertions over sizes that needs to be done after the ACK
+ locator = createInVMNonHALocator();
+ locator.setBlockOnAcknowledge(true);
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
+ // There are assertions over sizes that needs to be done after the ACK
// was received on server
- clientSession = sessionFactory.createSession(null, null, false, true, true, false, 0);
+ clientSession = addClientSession(sessionFactory.createSession(null, null, false, true, true, false, 0));
}
- @Override
- protected void tearDown() throws Exception
- {
- if (clientSession != null)
- {
- try
- {
- clientSession.close();
- }
- catch (HornetQException e1)
- {
- //
- }
- }
- if (server != null && server.isStarted())
- {
- try
- {
- server.stop();
- }
- catch (Exception e1)
- {
- //
- }
- }
- locator.close();
- server = null;
- clientSession = null;
-
- super.tearDown();
- }
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/FailureDeadlockTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/FailureDeadlockTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/FailureDeadlockTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -23,20 +23,18 @@
import org.hornetq.api.jms.JMSFactoryType;
import org.hornetq.core.client.impl.ClientSessionInternal;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.logging.Logger;
+import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.HornetQServers;
import org.hornetq.jms.client.HornetQConnectionFactory;
import org.hornetq.jms.client.HornetQSession;
import org.hornetq.jms.server.impl.JMSServerManagerImpl;
import org.hornetq.spi.core.protocol.RemotingConnection;
import org.hornetq.tests.integration.jms.server.management.NullInitialContext;
import org.hornetq.tests.util.ServiceTestBase;
-import org.hornetq.tests.util.UnitTestCase;
/**
- *
+ *
* A FailureDeadlockTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -62,9 +60,8 @@
Configuration conf = createDefaultConfig();
conf.setSecurityEnabled(false);
- conf.getAcceptorConfigurations()
- .add(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory"));
- server = HornetQServers.newHornetQServer(conf, false);
+ conf.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName()));
+ server = createServer(false, conf);
jmsServer = new JMSServerManagerImpl(server);
jmsServer.setContext(new NullInitialContext());
jmsServer.start();
@@ -77,36 +74,16 @@
@Override
protected void tearDown() throws Exception
{
- if (jmsServer != null && jmsServer.isStarted())
- {
- jmsServer.stop();
- }
- if (server != null && server.isStarted())
- {
- try
- {
- server.stop();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- }
-
cf1.close();
cf2.close();
-
- server = null;
- jmsServer = null;
+ if (jmsServer != null && jmsServer.isStarted())
+ {
+ jmsServer.stop();
+ }
- cf1 = null;
-
- cf2 = null;
-
super.tearDown();
}
@@ -196,7 +173,7 @@
try
{
- Session sess2 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
fail("should throw exception");
}
catch (JMSException e)
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/HeuristicXATest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/HeuristicXATest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/HeuristicXATest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -23,10 +23,14 @@
import junit.framework.Assert;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.api.core.management.HornetQServerControl;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
import org.hornetq.core.settings.impl.AddressSettings;
@@ -36,17 +40,11 @@
/**
* A HeuristicXATest
- *
* @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- *
- *
*/
public class HeuristicXATest extends ServiceTestBase
{
// Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(HeuristicXATest.class);
-
final SimpleString ADDRESS = new SimpleString("ADDRESS");
final String body = "this is the body";
@@ -69,23 +67,11 @@
configuration.setJMXManagementEnabled(true);
HornetQServer server = createServer(false, configuration, mbeanServer, new HashMap<String, AddressSettings>());
+ server.start();
- try
- {
- server.start();
+ HornetQServerControl jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
- HornetQServerControl jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
-
- Assert.assertFalse(jmxServer.commitPreparedTransaction("Nananananana"));
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
-
+ Assert.assertFalse(jmxServer.commitPreparedTransaction("Nananananana"));
}
public void testHeuristicCommit() throws Exception
@@ -104,93 +90,81 @@
configuration.setJMXManagementEnabled(true);
HornetQServer server = createServer(false, configuration, mbeanServer, new HashMap<String, AddressSettings>());
- try
- {
- server.start();
- Xid xid = newXID();
+ server.start();
+ Xid xid = newXID();
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
- ClientSession session = sf.createSession(true, false, false);
+ ClientSession session = sf.createSession(true, false, false);
- session.createQueue(ADDRESS, ADDRESS, true);
+ session.createQueue(ADDRESS, ADDRESS, true);
- session.start(xid, XAResource.TMNOFLAGS);
+ session.start(xid, XAResource.TMNOFLAGS);
- ClientProducer producer = session.createProducer(ADDRESS);
+ ClientProducer producer = session.createProducer(ADDRESS);
- ClientMessage msg = session.createMessage(true);
+ ClientMessage msg = session.createMessage(true);
- msg.getBodyBuffer().writeString(body);
+ msg.getBodyBuffer().writeString(body);
- producer.send(msg);
+ producer.send(msg);
- session.end(xid, XAResource.TMSUCCESS);
+ session.end(xid, XAResource.TMSUCCESS);
- session.prepare(xid);
+ session.prepare(xid);
- session.close();
+ session.close();
- HornetQServerControl jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
+ HornetQServerControl jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
- String preparedTransactions[] = jmxServer.listPreparedTransactions();
+ String preparedTransactions[] = jmxServer.listPreparedTransactions();
- Assert.assertEquals(1, preparedTransactions.length);
+ Assert.assertEquals(1, preparedTransactions.length);
- System.out.println(preparedTransactions[0]);
+ System.out.println(preparedTransactions[0]);
- Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
- Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
+ Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
+ Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
- if (isCommit)
- {
- jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
- }
- else
- {
- jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
- }
+ if (isCommit)
+ {
+ jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
+ }
+ else
+ {
+ jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
+ }
- Assert.assertEquals(0, jmxServer.listPreparedTransactions().length);
- if (isCommit)
- {
- Assert.assertEquals(1, jmxServer.listHeuristicCommittedTransactions().length);
- Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
- }
- else
- {
- Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
- Assert.assertEquals(1, jmxServer.listHeuristicRolledBackTransactions().length);
- }
+ Assert.assertEquals(0, jmxServer.listPreparedTransactions().length);
+ if (isCommit)
+ {
+ Assert.assertEquals(1, jmxServer.listHeuristicCommittedTransactions().length);
+ Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
+ }
+ else
+ {
+ Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
+ Assert.assertEquals(1, jmxServer.listHeuristicRolledBackTransactions().length);
+ }
- if (isCommit)
- {
- Assert.assertEquals(1, ((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
+ if (isCommit)
+ {
+ Assert.assertEquals(1, ((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
- session = sf.createSession(false, false, false);
+ session = sf.createSession(false, false, false);
- session.start();
- ClientConsumer consumer = session.createConsumer(ADDRESS);
- msg = consumer.receive(1000);
- Assert.assertNotNull(msg);
- msg.acknowledge();
- Assert.assertEquals(body, msg.getBodyBuffer().readString());
+ session.start();
+ ClientConsumer consumer = session.createConsumer(ADDRESS);
+ msg = consumer.receive(1000);
+ Assert.assertNotNull(msg);
+ msg.acknowledge();
+ Assert.assertEquals(body, msg.getBodyBuffer().readString());
- session.commit();
- session.close();
- }
-
- Assert.assertEquals(0, ((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
-
+ session.commit();
+ session.close();
}
- finally
- {
- if (server.isStarted())
- {
- server.stop();
- }
- }
+ Assert.assertEquals(0, ((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
}
public void testHeuristicCommitWithRestart() throws Exception
@@ -209,95 +183,85 @@
configuration.setJMXManagementEnabled(true);
HornetQServer server = createServer(true, configuration, mbeanServer, new HashMap<String, AddressSettings>());
- try
- {
- server.start();
- Xid xid = newXID();
+ server.start();
+ Xid xid = newXID();
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
- ClientSession session = sf.createSession(true, false, false);
+ ClientSession session = sf.createSession(true, false, false);
- session.createQueue(ADDRESS, ADDRESS, true);
+ session.createQueue(ADDRESS, ADDRESS, true);
- session.start(xid, XAResource.TMNOFLAGS);
+ session.start(xid, XAResource.TMNOFLAGS);
- ClientProducer producer = session.createProducer(ADDRESS);
+ ClientProducer producer = session.createProducer(ADDRESS);
- ClientMessage msg = session.createMessage(true);
+ ClientMessage msg = session.createMessage(true);
- msg.getBodyBuffer().writeString(body);
+ msg.getBodyBuffer().writeString(body);
- producer.send(msg);
+ producer.send(msg);
- session.end(xid, XAResource.TMSUCCESS);
+ session.end(xid, XAResource.TMSUCCESS);
- session.prepare(xid);
+ session.prepare(xid);
- session.close();
+ session.close();
- HornetQServerControl jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
+ HornetQServerControl jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
- String preparedTransactions[] = jmxServer.listPreparedTransactions();
+ String preparedTransactions[] = jmxServer.listPreparedTransactions();
- Assert.assertEquals(1, preparedTransactions.length);
- System.out.println(preparedTransactions[0]);
+ Assert.assertEquals(1, preparedTransactions.length);
+ System.out.println(preparedTransactions[0]);
- if (isCommit)
- {
- jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
- }
- else
- {
- jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
- }
+ if (isCommit)
+ {
+ jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
+ }
+ else
+ {
+ jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
+ }
- preparedTransactions = jmxServer.listPreparedTransactions();
- Assert.assertEquals(0, preparedTransactions.length);
+ preparedTransactions = jmxServer.listPreparedTransactions();
+ Assert.assertEquals(0, preparedTransactions.length);
- if (isCommit)
- {
- Assert.assertEquals(1, ((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
+ if (isCommit)
+ {
+ Assert.assertEquals(1, ((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
- session = sf.createSession(false, false, false);
+ session = sf.createSession(false, false, false);
- session.start();
- ClientConsumer consumer = session.createConsumer(ADDRESS);
- msg = consumer.receive(1000);
- Assert.assertNotNull(msg);
- msg.acknowledge();
- Assert.assertEquals(body, msg.getBodyBuffer().readString());
+ session.start();
+ ClientConsumer consumer = session.createConsumer(ADDRESS);
+ msg = consumer.receive(1000);
+ Assert.assertNotNull(msg);
+ msg.acknowledge();
+ Assert.assertEquals(body, msg.getBodyBuffer().readString());
- session.commit();
- session.close();
- }
+ session.commit();
+ session.close();
+ }
- Assert.assertEquals(0, ((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
+ Assert.assertEquals(0, ((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
- server.stop();
+ server.stop();
- server.start();
+ server.start();
- jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
- if (isCommit)
- {
- String[] listHeuristicCommittedTransactions = jmxServer.listHeuristicCommittedTransactions();
- Assert.assertEquals(1, listHeuristicCommittedTransactions.length);
- System.out.println(listHeuristicCommittedTransactions[0]);
- }
- else
- {
- String[] listHeuristicRolledBackTransactions = jmxServer.listHeuristicRolledBackTransactions();
- Assert.assertEquals(1, listHeuristicRolledBackTransactions.length);
- System.out.println(listHeuristicRolledBackTransactions[0]);
- }
+ jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
+ if (isCommit)
+ {
+ String[] listHeuristicCommittedTransactions = jmxServer.listHeuristicCommittedTransactions();
+ Assert.assertEquals(1, listHeuristicCommittedTransactions.length);
+ System.out.println(listHeuristicCommittedTransactions[0]);
}
- finally
+ else
{
- if (server.isStarted())
- {
- server.stop();
- }
+ String[] listHeuristicRolledBackTransactions = jmxServer.listHeuristicRolledBackTransactions();
+ Assert.assertEquals(1, listHeuristicRolledBackTransactions.length);
+ System.out.println(listHeuristicRolledBackTransactions[0]);
}
}
@@ -317,105 +281,95 @@
configuration.setJMXManagementEnabled(true);
HornetQServer server = createServer(true, configuration, mbeanServer, new HashMap<String, AddressSettings>());
- try
- {
- server.start();
- Xid xid = newXID();
+ server.start();
+ Xid xid = newXID();
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
- ClientSession session = sf.createSession(true, false, false);
+ ClientSession session = sf.createSession(true, false, false);
- session.createQueue(ADDRESS, ADDRESS, true);
+ session.createQueue(ADDRESS, ADDRESS, true);
- session.start(xid, XAResource.TMNOFLAGS);
+ session.start(xid, XAResource.TMNOFLAGS);
- ClientProducer producer = session.createProducer(ADDRESS);
+ ClientProducer producer = session.createProducer(ADDRESS);
- ClientMessage msg = session.createMessage(true);
+ ClientMessage msg = session.createMessage(true);
- msg.getBodyBuffer().writeString(body);
+ msg.getBodyBuffer().writeString(body);
- producer.send(msg);
+ producer.send(msg);
- session.end(xid, XAResource.TMSUCCESS);
+ session.end(xid, XAResource.TMSUCCESS);
- session.prepare(xid);
+ session.prepare(xid);
- session.close();
+ session.close();
- HornetQServerControl jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
+ HornetQServerControl jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
- String preparedTransactions[] = jmxServer.listPreparedTransactions();
+ String preparedTransactions[] = jmxServer.listPreparedTransactions();
- Assert.assertEquals(1, preparedTransactions.length);
- System.out.println(preparedTransactions[0]);
+ Assert.assertEquals(1, preparedTransactions.length);
+ System.out.println(preparedTransactions[0]);
- if (heuristicCommit)
- {
- jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
- }
- else
- {
- jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
- }
+ if (heuristicCommit)
+ {
+ jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
+ }
+ else
+ {
+ jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
+ }
- preparedTransactions = jmxServer.listPreparedTransactions();
- Assert.assertEquals(0, preparedTransactions.length);
+ preparedTransactions = jmxServer.listPreparedTransactions();
+ Assert.assertEquals(0, preparedTransactions.length);
- if (heuristicCommit)
- {
- Assert.assertEquals(1, ((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
+ if (heuristicCommit)
+ {
+ Assert.assertEquals(1, ((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
- session = sf.createSession(false, false, false);
+ session = sf.createSession(false, false, false);
- session.start();
- ClientConsumer consumer = session.createConsumer(ADDRESS);
- msg = consumer.receive(1000);
- Assert.assertNotNull(msg);
- msg.acknowledge();
- Assert.assertEquals(body, msg.getBodyBuffer().readString());
+ session.start();
+ ClientConsumer consumer = session.createConsumer(ADDRESS);
+ msg = consumer.receive(1000);
+ Assert.assertNotNull(msg);
+ msg.acknowledge();
+ Assert.assertEquals(body, msg.getBodyBuffer().readString());
- session.commit();
- session.close();
- }
+ session.commit();
+ session.close();
+ }
- Assert.assertEquals(0, ((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
+ Assert.assertEquals(0, ((Queue)server.getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
- server.stop();
+ server.stop();
- server.start();
- //we need to recreate the locator and session factory
- sf = locator.createSessionFactory();
- jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
- if (heuristicCommit)
- {
- String[] listHeuristicCommittedTransactions = jmxServer.listHeuristicCommittedTransactions();
- Assert.assertEquals(1, listHeuristicCommittedTransactions.length);
- System.out.println(listHeuristicCommittedTransactions[0]);
- }
- else
- {
- String[] listHeuristicRolledBackTransactions = jmxServer.listHeuristicRolledBackTransactions();
- Assert.assertEquals(1, listHeuristicRolledBackTransactions.length);
- System.out.println(listHeuristicRolledBackTransactions[0]);
- }
-
- session = sf.createSession(true, false, false);
- Xid[] recoveredXids = session.recover(XAResource.TMSTARTRSCAN);
- Assert.assertEquals(1, recoveredXids.length);
- Assert.assertEquals(xid, recoveredXids[0]);
- Assert.assertEquals(0, session.recover(XAResource.TMENDRSCAN).length);
-
- session.close();
+ server.start();
+ // we need to recreate the locator and session factory
+ sf = createSessionFactory(locator);
+ jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
+ if (heuristicCommit)
+ {
+ String[] listHeuristicCommittedTransactions = jmxServer.listHeuristicCommittedTransactions();
+ Assert.assertEquals(1, listHeuristicCommittedTransactions.length);
+ System.out.println(listHeuristicCommittedTransactions[0]);
}
- finally
+ else
{
- if (server.isStarted())
- {
- server.stop();
- }
+ String[] listHeuristicRolledBackTransactions = jmxServer.listHeuristicRolledBackTransactions();
+ Assert.assertEquals(1, listHeuristicRolledBackTransactions.length);
+ System.out.println(listHeuristicRolledBackTransactions[0]);
}
+
+ session = sf.createSession(true, false, false);
+ Xid[] recoveredXids = session.recover(XAResource.TMSTARTRSCAN);
+ Assert.assertEquals(1, recoveredXids.length);
+ Assert.assertEquals(xid, recoveredXids[0]);
+ Assert.assertEquals(0, session.recover(XAResource.TMENDRSCAN).length);
+
+ session.close();
}
public void testForgetHeuristicCommitAndRestart() throws Exception
@@ -434,90 +388,80 @@
configuration.setJMXManagementEnabled(true);
HornetQServer server = createServer(true, configuration, mbeanServer, new HashMap<String, AddressSettings>());
- try
- {
- server.start();
- Xid xid = newXID();
+ server.start();
+ Xid xid = newXID();
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
- ClientSession session = sf.createSession(true, false, false);
+ ClientSession session = sf.createSession(true, false, false);
- session.createQueue(ADDRESS, ADDRESS, true);
+ session.createQueue(ADDRESS, ADDRESS, true);
- session.start(xid, XAResource.TMNOFLAGS);
+ session.start(xid, XAResource.TMNOFLAGS);
- ClientProducer producer = session.createProducer(ADDRESS);
+ ClientProducer producer = session.createProducer(ADDRESS);
- ClientMessage msg = session.createMessage(true);
+ ClientMessage msg = session.createMessage(true);
- msg.getBodyBuffer().writeBytes(new byte[123]);
+ msg.getBodyBuffer().writeBytes(new byte[123]);
- producer.send(msg);
+ producer.send(msg);
- session.end(xid, XAResource.TMSUCCESS);
+ session.end(xid, XAResource.TMSUCCESS);
- session.prepare(xid);
+ session.prepare(xid);
- HornetQServerControl jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
+ HornetQServerControl jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
- String preparedTransactions[] = jmxServer.listPreparedTransactions();
+ String preparedTransactions[] = jmxServer.listPreparedTransactions();
- Assert.assertEquals(1, preparedTransactions.length);
- System.out.println(preparedTransactions[0]);
+ Assert.assertEquals(1, preparedTransactions.length);
+ System.out.println(preparedTransactions[0]);
- if (heuristicCommit)
- {
- jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
- }
- else
- {
- jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
- }
+ if (heuristicCommit)
+ {
+ jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
+ }
+ else
+ {
+ jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
+ }
- preparedTransactions = jmxServer.listPreparedTransactions();
- Assert.assertEquals(0, preparedTransactions.length);
+ preparedTransactions = jmxServer.listPreparedTransactions();
+ Assert.assertEquals(0, preparedTransactions.length);
- session.forget(xid);
+ session.forget(xid);
- session.close();
+ session.close();
- if (heuristicCommit)
- {
- Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
- }
- else
- {
- Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
- }
+ if (heuristicCommit)
+ {
+ Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
+ }
+ else
+ {
+ Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
+ }
- server.stop();
+ server.stop();
- server.start();
- //we need to recreate the sf
- sf = locator.createSessionFactory();
- session = sf.createSession(true, false, false);
- Xid[] recoveredXids = session.recover(XAResource.TMSTARTRSCAN);
- Assert.assertEquals(0, recoveredXids.length);
- jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
- if (heuristicCommit)
- {
- Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
- }
- else
- {
- Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
- }
-
- session.close();
+ server.start();
+ // we need to recreate the sf
+ sf = createSessionFactory(locator);
+ session = sf.createSession(true, false, false);
+ Xid[] recoveredXids = session.recover(XAResource.TMSTARTRSCAN);
+ Assert.assertEquals(0, recoveredXids.length);
+ jmxServer = ManagementControlHelper.createHornetQServerControl(mbeanServer);
+ if (heuristicCommit)
+ {
+ Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
}
- finally
+ else
{
- if (server.isStarted())
- {
- server.stop();
- }
+ Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
}
+
+ session.close();
}
// Package protected ---------------------------------------------
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -14,8 +14,12 @@
import junit.framework.Assert;
-import org.hornetq.api.core.client.*;
-import org.hornetq.core.logging.Logger;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.protocol.core.impl.PacketImpl;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.RandomUtil;
@@ -24,8 +28,6 @@
public class InVMNonPersistentMessageBufferTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(InVMNonPersistentMessageBufferTest.class);
-
public static final String address = "testaddress";
public static final String queueName = "testqueue";
@@ -232,7 +234,7 @@
ServerLocator locator = createFactory();
- ClientSessionFactory cf = locator.createSessionFactory();
+ ClientSessionFactory cf = createSessionFactory(locator);
session = cf.createSession();
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/IncompatibleVersionTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/IncompatibleVersionTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/IncompatibleVersionTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -14,14 +14,10 @@
package org.hornetq.tests.integration.client;
import static org.hornetq.tests.util.RandomUtil.randomString;
-import org.hornetq.tests.util.SpawnedVMSupport;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Properties;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.TransportConfiguration;
@@ -37,12 +33,12 @@
import org.hornetq.core.protocol.core.Packet;
import org.hornetq.core.protocol.core.impl.wireformat.CreateSessionMessage;
import org.hornetq.core.protocol.core.impl.wireformat.CreateSessionResponseMessage;
-import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.remoting.server.impl.RemotingServiceImpl;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.version.impl.VersionImpl;
import org.hornetq.tests.util.ServiceTestBase;
+import org.hornetq.tests.util.SpawnedVMSupport;
import org.hornetq.utils.VersionLoader;
/**
@@ -77,8 +73,8 @@
server.getConfiguration().setConnectionTTLOverride(500);
server.start();
- locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY));
- ClientSessionFactory csf = locator.createSessionFactory();
+ locator = createInVMNonHALocator();
+ ClientSessionFactory csf = createSessionFactory(locator);
connection = csf.getConnection();
}
@@ -87,10 +83,7 @@
protected void tearDown() throws Exception
{
connection.destroy();
-
- locator.close();
-
- server.stop();
+ super.tearDown();
}
public void testCompatibleClientVersion() throws Exception
@@ -116,7 +109,7 @@
assertFalse(doTestClientVersionCompatibilityWithRealConnection("1-3,5,7-10",4));
assertFalse(doTestClientVersionCompatibilityWithRealConnection("1-3,5,7-10",100));
}
-
+
private void doTestClientVersionCompatibility(boolean compatible) throws Exception
{
Channel channel1 = connection.getChannel(1, -1);
@@ -175,14 +168,14 @@
{
String propFileName = "compatibility-test-hornetq-version.properties";
String serverStartedString = "IncompatibleVersionTest---server---started";
-
+
Properties prop = new Properties();
InputStream in = VersionImpl.class.getClassLoader().getResourceAsStream("hornetq-version.properties");
prop.load(in);
prop.setProperty("hornetq.version.compatibleVersionList", verList);
prop.setProperty("hornetq.version.incrementingVersion", Integer.toString(ver));
prop.store(new FileOutputStream("target/test-classes/" + propFileName), null);
-
+
Process server = null;
boolean result = false;
try
@@ -192,11 +185,11 @@
"server",
serverStartedString);
Thread.sleep(2000);
-
+
Process client = SpawnedVMSupport.spawnVM("org.hornetq.tests.integration.client.IncompatibleVersionTest",
new String[]{"-D" + VersionLoader.VERSION_PROP_FILE_KEY + "=" + propFileName},
"client");
-
+
if(client.waitFor() == 0)
{
result = true;
@@ -213,10 +206,10 @@
catch(Throwable t) {/* ignore */}
}
}
-
+
return result;
}
-
+
private static class ServerStarter
{
public void perform(String startedString) throws Exception
@@ -226,7 +219,7 @@
conf.getAcceptorConfigurations().add(new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory"));
HornetQServer server = HornetQServers.newHornetQServer(conf, false);
server.start();
-
+
log.info("### server: " + startedString);
}
}
@@ -243,7 +236,7 @@
locator.close();
}
}
-
+
public static void main(String[] args) throws Exception
{
if(args[0].equals("server"))
@@ -261,7 +254,7 @@
throw new Exception("args[0] must be \"server\" or \"client\"");
}
}
-
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCloseOnGCTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCloseOnGCTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCloseOnGCTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -20,13 +20,12 @@
import org.hornetq.api.core.client.ClientSessionFactory;
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.tests.util.UnitTestCase;
/**
- *
+ *
* A SessionCloseOnGCTest
*
* @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
@@ -36,10 +35,7 @@
*/
public class SessionCloseOnGCTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(SessionCloseOnGCTest.class);
-
private HornetQServer server;
-
private ServerLocator locator;
@Override
@@ -53,24 +49,10 @@
locator = createInVMNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- //locator.close();
-
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
/** Make sure Sessions are not leaking after closed..
* Also... we want to make sure the SessionFactory will close itself when there are not references into it */
public void testValidateFactoryGC1() throws Exception
{
- try
- {
ClientSessionFactory factory = locator.createSessionFactory();
ClientSession s1 = factory.createSession();
@@ -97,27 +79,12 @@
factory = null;
UnitTestCase.checkWeakReferences(fref, wrs1, wrs2);
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
-
- }
- }
}
public void testValidateFactoryGC2() throws Exception
{
- try
- {
+ locator.setUseGlobalPools(false);
- locator.setUseGlobalPools(false);
-
ClientSessionFactory factory = locator.createSessionFactory();
ClientSession s1 = factory.createSession();
@@ -144,24 +111,10 @@
factory = null;
UnitTestCase.checkWeakReferences(fref, wrs1, wrs2);
- }
- finally
- {
- try
- {
- server.stop();
}
- catch (Throwable ignored)
- {
- }
- }
- }
-
public void testValidateFactoryGC3() throws Exception
{
- try
- {
ClientSessionFactory factory = locator.createSessionFactory();
ClientSession s1 = factory.createSession();
@@ -186,25 +139,11 @@
factory = null;
UnitTestCase.checkWeakReferences(fref, wrs1, wrs2);
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
-
- }
- }
}
public void testValidateFactoryGC4() throws Exception
{
- try
- {
- ClientSessionFactory factory = locator.createSessionFactory();
+ ClientSessionFactory factory = locator.createSessionFactory();
ClientSession s1 = factory.createSession();
ClientSession s2 = factory.createSession();
@@ -225,25 +164,11 @@
factory = null;
UnitTestCase.checkWeakReferences(fref, wrs1, wrs2);
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
-
- }
- }
}
public void testValidateFactoryGC5() throws Exception
{
- try
- {
- ClientSessionFactory factory = locator.createSessionFactory();
+ ClientSessionFactory factory = locator.createSessionFactory();
WeakReference<ClientSessionFactory> fref = new WeakReference<ClientSessionFactory>(factory);
@@ -253,20 +178,8 @@
locator = null;
UnitTestCase.checkWeakReferences(fref);
- }
- finally
- {
- try
- {
- server.stop();
}
- catch (Throwable ignored)
- {
- }
- }
- }
-
public void testCloseOneSessionOnGC() throws Exception
{
ClientSessionFactoryImpl sf = (ClientSessionFactoryImpl) locator.createSessionFactory();
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateAndDeleteQueueTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateAndDeleteQueueTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateAndDeleteQueueTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -41,7 +41,7 @@
public void testDurableFalse() throws Exception
{
- ClientSession session = locator.createSessionFactory().createSession(false, true, true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true, true);
session.createQueue(address, queueName, false);
Binding binding = server.getPostOffice().getBinding(queueName);
Queue q = (Queue)binding.getBindable();
@@ -52,7 +52,7 @@
public void testDurableTrue() throws Exception
{
- ClientSession session = locator.createSessionFactory().createSession(false, true, true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true, true);
session.createQueue(address, queueName, true);
Binding binding = server.getPostOffice().getBinding(queueName);
Queue q = (Queue)binding.getBindable();
@@ -63,7 +63,7 @@
public void testTemporaryFalse() throws Exception
{
- ClientSession session = locator.createSessionFactory().createSession(false, true, true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true, true);
session.createQueue(address, queueName, false);
Binding binding = server.getPostOffice().getBinding(queueName);
Queue q = (Queue)binding.getBindable();
@@ -74,7 +74,7 @@
public void testTemporaryTrue() throws Exception
{
- ClientSession session = locator.createSessionFactory().createSession(false, true, true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true, true);
session.createTemporaryQueue(address, queueName);
Binding binding = server.getPostOffice().getBinding(queueName);
Queue q = (Queue)binding.getBindable();
@@ -85,7 +85,7 @@
public void testcreateWithFilter() throws Exception
{
- ClientSession session = locator.createSessionFactory().createSession(false, true, true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true, true);
SimpleString filterString = new SimpleString("x=y");
session.createQueue(address, queueName, filterString, false);
Binding binding = server.getPostOffice().getBinding(queueName);
@@ -100,7 +100,7 @@
AddressSettings addressSettings = new AddressSettings();
addressSettings.setLastValueQueue(true);
server.getAddressSettingsRepository().addMatch(address.toString(), addressSettings);
- ClientSession session = locator.createSessionFactory().createSession(false, true, true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true, true);
SimpleString filterString = new SimpleString("x=y");
session.createQueue(address, queueName, filterString, false);
Binding binding = server.getPostOffice().getBinding(queueName);
@@ -111,7 +111,7 @@
public void testDeleteQueue() throws Exception
{
- ClientSession session = locator.createSessionFactory().createSession(false, true, true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true, true);
session.createQueue(address, queueName, false);
Binding binding = server.getPostOffice().getBinding(queueName);
Assert.assertNotNull(binding);
@@ -123,7 +123,7 @@
public void testDeleteQueueNotExist() throws Exception
{
- ClientSession session = locator.createSessionFactory().createSession(false, true, true);
+ ClientSession session = createSessionFactory(locator).createSession(false, true, true);
try
{
session.deleteQueue(queueName);
@@ -144,20 +144,4 @@
server.start();
locator = createInVMNonHALocator();
}
-
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- if (server != null && server.isStarted())
- {
- server.stop();
- }
-
- server = null;
-
- super.tearDown();
-
- }
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateConsumerTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateConsumerTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateConsumerTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -45,28 +45,10 @@
locator.setProducerMaxRate(99);
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnNonDurableSend(true);
- cf = locator.createSessionFactory();
- clientSession = (ClientSessionInternal)cf.createSession(false, true, true);
+ cf = createSessionFactory(locator);
+ clientSession = (ClientSessionInternal)addClientSession(cf.createSession(false, true, true));
}
- @Override
- protected void tearDown() throws Exception
- {
- stopComponent(service);
- try
- {
- if (clientSession != null)
- clientSession.close();
- if (cf != null)
- cf.close();
- }
- finally
- {
- closeServerLocator(locator);
- super.tearDown();
- }
- }
-
public void testCreateConsumer() throws Exception
{
clientSession.createQueue(queueName, queueName, false);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateProducerTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateProducerTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/SessionCreateProducerTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -28,98 +28,54 @@
public class SessionCreateProducerTest extends ServiceTestBase
{
private ServerLocator locator;
+ private ClientSessionInternal clientSession;
+ private ClientSessionFactory cf;
@Override
protected void setUp() throws Exception
{
+ super.setUp();
locator = createInVMNonHALocator();
-
- super.setUp();
+ HornetQServer service = createServer(false);
+ service.start();
+ locator.setProducerMaxRate(99);
+ locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnNonDurableSend(true);
+ cf = createSessionFactory(locator);
+ clientSession = (ClientSessionInternal)addClientSession(cf.createSession(false, true, true));
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- super.tearDown();
- }
-
public void testCreateAnonProducer() throws Exception
{
- HornetQServer service = createServer(false);
- try
- {
- service.start();
- locator.setProducerMaxRate(99);
- locator.setBlockOnNonDurableSend(true);
- locator.setBlockOnNonDurableSend(true);
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSessionInternal clientSession = (ClientSessionInternal)cf.createSession(false, true, true);
- ClientProducer producer = clientSession.createProducer();
- Assert.assertNull(producer.getAddress());
- Assert.assertEquals(cf.getServerLocator().getProducerMaxRate(), producer.getMaxRate());
- Assert.assertEquals(cf.getServerLocator().isBlockOnNonDurableSend(), producer.isBlockOnNonDurableSend());
- Assert.assertEquals(cf.getServerLocator().isBlockOnDurableSend(), producer.isBlockOnDurableSend());
- Assert.assertFalse(producer.isClosed());
- clientSession.close();
- }
- finally
- {
- service.stop();
- }
+ ClientProducer producer = clientSession.createProducer();
+ Assert.assertNull(producer.getAddress());
+ Assert.assertEquals(cf.getServerLocator().getProducerMaxRate(), producer.getMaxRate());
+ Assert.assertEquals(cf.getServerLocator().isBlockOnNonDurableSend(), producer.isBlockOnNonDurableSend());
+ Assert.assertEquals(cf.getServerLocator().isBlockOnDurableSend(), producer.isBlockOnDurableSend());
+ Assert.assertFalse(producer.isClosed());
}
public void testCreateProducer1() throws Exception
{
- HornetQServer service = createServer(false);
- try
- {
- service.start();
- locator.setProducerMaxRate(99);
- locator.setBlockOnNonDurableSend(true);
- locator.setBlockOnNonDurableSend(true);
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSessionInternal clientSession = (ClientSessionInternal)cf.createSession(false, true, true);
- ClientProducer producer = clientSession.createProducer("testAddress");
- Assert.assertNotNull(producer.getAddress());
- Assert.assertEquals(cf.getServerLocator().getProducerMaxRate(), producer.getMaxRate());
- Assert.assertEquals(cf.getServerLocator().isBlockOnNonDurableSend(), producer.isBlockOnNonDurableSend());
- Assert.assertEquals(cf.getServerLocator().isBlockOnDurableSend(), producer.isBlockOnDurableSend());
- Assert.assertFalse(producer.isClosed());
- clientSession.close();
- }
- finally
- {
- service.stop();
- }
+ ClientProducer producer = clientSession.createProducer("testAddress");
+ Assert.assertNotNull(producer.getAddress());
+ Assert.assertEquals(cf.getServerLocator().getProducerMaxRate(), producer.getMaxRate());
+ Assert.assertEquals(cf.getServerLocator().isBlockOnNonDurableSend(), producer.isBlockOnNonDurableSend());
+ Assert.assertEquals(cf.getServerLocator().isBlockOnDurableSend(), producer.isBlockOnDurableSend());
+ Assert.assertFalse(producer.isClosed());
}
public void testProducerOnClosedSession() throws Exception
{
- HornetQServer service = createServer(false);
+ clientSession.close();
try
{
- service.start();
- locator.setProducerMaxRate(99);
- locator.setBlockOnNonDurableSend(true);
- locator.setBlockOnNonDurableSend(true);
- ClientSessionFactory cf = locator.createSessionFactory();
- ClientSessionInternal clientSession = (ClientSessionInternal)cf.createSession(false, true, true);
- clientSession.close();
- try
- {
- clientSession.createProducer();
- Assert.fail("should throw exception");
- }
- catch (HornetQException e)
- {
- Assert.assertEquals(e.getCode(), HornetQException.OBJECT_CLOSED);
- }
+ clientSession.createProducer();
+ Assert.fail("should throw exception");
}
- finally
+ catch (HornetQException e)
{
- service.stop();
+ Assert.assertEquals(e.getCode(), HornetQException.OBJECT_CLOSED);
}
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -244,7 +244,7 @@
ClusterConnectionConfiguration cccLive = new ClusterConnectionConfiguration("cluster1", "jms", backupConnector.getName(), -1, false, false, 1, 1,
staticConnectors, false);
backupConfig.getClusterConfigurations().add(cccLive);
- backupServer = createServer(backupConfig);
+ backupServer = createTestableServer(backupConfig);
liveConfig = super.createDefaultConfig();
liveConfig.getAcceptorConfigurations().clear();
@@ -260,7 +260,7 @@
liveConfig.getClusterConfigurations().add(ccc0);
liveConfig.getConnectorConfigurations().put(liveConnector.getName(), liveConnector);
liveConfig.getConnectorConfigurations().put(backupConnector.getName(), backupConnector);
- liveServer = createServer(liveConfig);
+ liveServer = createTestableServer(liveConfig);
}
@Override
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -15,12 +15,10 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import junit.framework.Assert;
-import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.ClientConsumer;
@@ -28,13 +26,13 @@
import org.hornetq.api.core.client.ClientProducer;
import org.hornetq.api.core.client.ClientSession;
import org.hornetq.api.core.client.ClientSessionFactory;
-import org.hornetq.api.core.client.SessionFailureListener;
import org.hornetq.core.client.impl.ClientSessionFactoryInternal;
import org.hornetq.core.client.impl.ServerLocatorInternal;
import org.hornetq.core.config.ClusterConnectionConfiguration;
import org.hornetq.core.server.impl.InVMNodeManager;
import org.hornetq.jms.client.HornetQTextMessage;
import org.hornetq.tests.integration.cluster.util.TestableServer;
+import org.hornetq.tests.util.CountDownSessionFailureListener;
import org.hornetq.tests.util.TransportConfigurationUtils;
/**
@@ -53,24 +51,6 @@
locator = getServerLocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- if (locator != null)
- {
- try
- {
- locator.close();
- }
- catch (Exception e)
- {
- //
- }
- }
- super.tearDown();
- }
-
-
public void testNoAutoFailback() throws Exception
{
locator.setBlockOnNonDurableSend(true);
@@ -78,11 +58,10 @@
locator.setFailoverOnInitialConnection(true);
locator.setReconnectAttempts(-1);
ClientSessionFactoryInternal sf = createSessionFactoryAndWaitForTopology(locator, 2);
- final CountDownLatch latch = new CountDownLatch(1);
ClientSession session = sendAndConsume(sf, true);
- MyListener listener = new MyListener(latch);
+ CountDownSessionFailureListener listener = new CountDownSessionFailureListener(1);
session.addFailureListener(listener);
@@ -92,7 +71,7 @@
backupServer.start();
- assertTrue(latch.await(5, TimeUnit.SECONDS));
+ assertTrue(listener.getLatch().await(5, TimeUnit.SECONDS));
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@@ -104,10 +83,8 @@
session.removeFailureListener(listener);
- final CountDownLatch latch2 = new CountDownLatch(1);
+ listener = new CountDownSessionFailureListener(1);
- listener = new MyListener(latch2);
-
session.addFailureListener(listener);
liveConfig.setAllowAutoFailBack(false);
@@ -122,7 +99,7 @@
backupServer.stop();
- assertTrue(latch2.await(15, TimeUnit.SECONDS));
+ assertTrue(listener.getLatch().await(15, TimeUnit.SECONDS));
message = session.createMessage(true);
@@ -162,7 +139,7 @@
staticConnectors, false);
backupConfig.getClusterConfigurations().add(cccLive);
backupConfig.setAllowAutoFailBack(false);
- backupServer = createServer(backupConfig);
+ backupServer = createTestableServer(backupConfig);
liveConfig = super.createDefaultConfig();
liveConfig.getAcceptorConfigurations().clear();
@@ -178,7 +155,7 @@
liveConfig.getConnectorConfigurations().put(liveConnector.getName(), liveConnector);
liveConfig.getConnectorConfigurations().put(backupConnector.getName(), backupConnector);
liveConfig.setAllowAutoFailBack(false);
- liveServer = createServer(liveConfig);
+ liveServer = createTestableServer(liveConfig);
}
@Override
@@ -252,26 +229,6 @@
message.getBodyBuffer().writeString("message" + i);
}
- class MyListener implements SessionFailureListener
- {
- private final CountDownLatch latch;
-
- public MyListener(CountDownLatch latch)
- {
- this.latch = latch;
- }
-
- public void connectionFailed(final HornetQException me, boolean failedOver)
- {
- latch.countDown();
- }
-
- public void beforeReconnect(HornetQException exception)
- {
- System.out.println("MyListener.beforeReconnect");
- }
- }
-
class ServerStarter implements Runnable
{
private final TestableServer server;
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -129,7 +129,6 @@
}
- @Override
protected TestableServer createTestableServer(Configuration config)
{
return new SameProcessHornetQServer(
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/NettyReplicatedFailoverTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/NettyReplicatedFailoverTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/NettyReplicatedFailoverTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -26,7 +26,7 @@
{
@Override
- protected TestableServer createServer(Configuration config)
+ protected TestableServer createTestableServer(Configuration config)
{
return new SameProcessHornetQServer(createServer(true, config));
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/PagingFailoverTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/PagingFailoverTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/PagingFailoverTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -74,12 +74,9 @@
{
if (session != null)
session.close();
- if (sf != null)
- sf.close();
}
finally
{
- closeServerLocator(locator);
super.tearDown();
}
}
@@ -219,7 +216,7 @@
}
@Override
- protected TestableServer createServer(Configuration config)
+ protected TestableServer createTestableServer(Configuration config)
{
return new SameProcessHornetQServer(createServer(true, config));
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SecurityFailoverTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SecurityFailoverTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SecurityFailoverTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -135,7 +135,7 @@
staticConnectors,
false);
backupConfig.getClusterConfigurations().add(cccLive);
- backupServer = createServer(backupConfig);
+ backupServer = createTestableServer(backupConfig);
HornetQSecurityManager securityManager = installSecurity(backupServer);
@@ -160,7 +160,7 @@
false);
liveConfig.getClusterConfigurations().add(ccc0);
liveConfig.getConnectorConfigurations().put(liveConnector.getName(), liveConnector);
- liveServer = createServer(liveConfig);
+ liveServer = createTestableServer(liveConfig);
installSecurity(liveServer);
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/IsolatedTopologyTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/IsolatedTopologyTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/topology/IsolatedTopologyTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -28,7 +28,6 @@
import org.hornetq.core.remoting.impl.netty.TransportConstants;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
-import org.hornetq.tests.util.UnitTestCase;
/**
* A IsolatedTopologyTest
@@ -40,18 +39,6 @@
public class IsolatedTopologyTest extends ServiceTestBase
{
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
- }
-
- @Override
- public void tearDown() throws Exception
- {
- super.tearDown();
- }
-
public void testIsolatedClusters() throws Exception
{
@@ -59,9 +46,7 @@
HornetQServer server2 = createServer2();
- try
- {
- server1.start();
+ server1.start();
server2.start();
waitForTopology(server1, "cc1", 2, 5000);
@@ -102,26 +87,7 @@
node2,
createInVMTransportConnectorConfig(2, "srv1"),
createInVMTransportConnectorConfig(4, "srv1"));
- }
- finally
- {
Thread.sleep(500);
- try
- {
- server1.stop();
- }
- catch (Throwable ignored)
- {
- }
-
- try
- {
- server2.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
}
private void checkTopology(final HornetQServer serverParameter,
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/ExportFormatTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/ExportFormatTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/ExportFormatTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -72,30 +72,14 @@
"operation@Update,id@16,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAI=\n" +
"#File,JournalFileImpl: (hornetq-data-2.hq id = 2, recordID = 2)";
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- protected void tearDown() throws Exception
- {
-
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
- }
-
public void _testCreateFormat() throws Exception
{
HornetQServer server = createServer(true);
server.start();
-
+
ServerLocator locator = createInVMNonHALocator();
- ClientSessionFactory factory = locator.createSessionFactory();
+ ClientSessionFactory factory = createSessionFactory(locator);
ClientSession session = factory.createSession(false, false, false);
session.createQueue("A1", "A1");
@@ -147,7 +131,7 @@
server.start();
ServerLocator locator = createInVMNonHALocator();
- ClientSessionFactory factory = locator.createSessionFactory();
+ ClientSessionFactory factory = createSessionFactory(locator);
ClientSession session = factory.createSession();
session.start();
@@ -161,10 +145,6 @@
}
session.commit();
-
- locator.close();
-
- server.stop();
}
// Package protected ---------------------------------------------
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -172,23 +172,4 @@
assertEquals(config.getCallTimeout(), cfs.get(0).getConfig().getCallTimeout());
}
-
- /**
- * @param journal
- * @throws Exception
- */
- private void checkSettings() throws Exception
- {
- List<PersistedConnectionFactory> listSetting = jmsJournal.recoverConnectionFactories();
-
- assertEquals(mapExpectedCFs.size(), listSetting.size());
-
- for (PersistedConnectionFactory el : listSetting)
- {
- PersistedConnectionFactory el2 = mapExpectedCFs.get(el.getName());
-
- assertEquals(el, el2);
- }
- }
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/RolesConfigurationStorageTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/RolesConfigurationStorageTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/RolesConfigurationStorageTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -40,14 +40,6 @@
mapExpectedSets = new HashMap<SimpleString, PersistedRoles>();
}
- @Override
- protected void tearDown() throws Exception
- {
- mapExpectedSets = null;
-
- super.tearDown();
- }
-
protected void addSetting(PersistedRoles setting) throws Exception
{
mapExpectedSets.put(setting.getAddressMatch(), setting);
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/SynchronousCloseTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/SynchronousCloseTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/remoting/SynchronousCloseTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -21,14 +21,11 @@
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
-import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
/**
- *
+ *
* A SynchronousCloseTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -38,12 +35,6 @@
public class SynchronousCloseTest extends ServiceTestBase
{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(SynchronousCloseTest.class);
-
- // Attributes ----------------------------------------------------
-
private HornetQServer server;
// Static --------------------------------------------------------
@@ -67,16 +58,6 @@
server.start();
}
- @Override
- protected void tearDown() throws Exception
- {
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
protected boolean isNetty()
{
return false;
@@ -94,7 +75,7 @@
locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY));
}
- return locator.createSessionFactory();
+ return createSessionFactory(locator);
}
/*
@@ -118,9 +99,4 @@
sf.getServerLocator().close();
}
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/soak-tests/src/test/java/org/hornetq/tests/soak/client/SimpleSendReceiveSoakTest.java
===================================================================
--- trunk/tests/soak-tests/src/test/java/org/hornetq/tests/soak/client/SimpleSendReceiveSoakTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/soak-tests/src/test/java/org/hornetq/tests/soak/client/SimpleSendReceiveSoakTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -71,32 +71,22 @@
server.start();
ServerLocator locator = createFactory(IS_NETTY);
-
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
+
ClientSession session = sf.createSession();
session.createQueue(SimpleSendReceiveSoakTest.ADDRESS, SimpleSendReceiveSoakTest.ADDRESS, true);
session.close();
-
- sf.close();
-
}
- @Override
- protected void tearDown() throws Exception
- {
- server.stop();
- server = null;
- }
-
public void testSoakClientTransactions() throws Exception
{
final ServerLocator locator = createFactory(IS_NETTY);
-
- final ClientSessionFactory sf = locator.createSessionFactory();
+ final ClientSessionFactory sf = createSessionFactory(locator);
+
ClientSession session = sf.createSession(true, true);
ClientProducer producer = session.createProducer(ADDRESS);
@@ -127,7 +117,7 @@
msg.getBodyBuffer().writeBytes(new byte[10 * 1024]);
producer.send(msg);
}
-
+
for (int i = 0; i < MIN_MESSAGES_ON_QUEUE; i++)
{
ClientMessage msg = consumer.receive(5000);
@@ -139,18 +129,5 @@
sessionConsumer.close();
session.close();
- sf.close();
- locator.close();
-
}
-
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/CompactingStressTest.java
===================================================================
--- trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/CompactingStressTest.java 2011-12-06 11:41:24 UTC (rev 11853)
+++ trunk/tests/stress-tests/src/test/java/org/hornetq/tests/stress/journal/CompactingStressTest.java 2011-12-06 11:42:23 UTC (rev 11854)
@@ -408,18 +408,6 @@
}
}
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- clearData();
- }
-
- /**
- * @throws Exception
- * @throws HornetQException
- */
private void setupServer(final JournalType journalType) throws Exception, HornetQException
{
Configuration config = createDefaultConfig();
@@ -440,8 +428,8 @@
locator.setBlockOnDurableSend(false);
locator.setBlockOnAcknowledge(false);
- sf = locator.createSessionFactory();
- ClientSession sess = sf.createSession();
+ sf = createSessionFactory(locator);
+ ClientSession sess = addClientSession(sf.createSession());
try
{
@@ -469,40 +457,4 @@
sess.close();
}
-
- @Override
- protected void tearDown() throws Exception
- {
- try
- {
- if (sf != null)
- {
- sf.close();
- }
-
- if (server != null)
- {
- server.stop();
- }
- }
- catch (Exception e)
- {
- e.printStackTrace(); // system.out -> junit reports
- }
-
- server = null;
-
- sf = null;
-
- super.tearDown();
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
13 years
JBoss hornetq SVN: r11853 - in trunk/tests: integration-tests/src/test/java/org/hornetq/tests/integration/cluster/bridge and 4 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2011-12-06 06:41:24 -0500 (Tue, 06 Dec 2011)
New Revision: 11853
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerCloseTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerFilterTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeadLetterAddressTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeliveryOrderTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/scheduling/DelayedMessageTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/BasicXaTest.java
trunk/tests/soak-tests/src/test/java/org/hornetq/tests/soak/client/ClientNonDivertedSoakTest.java
Log:
Mostly deleting unnecessary tearDown code (but also improving tearDown in general)
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerCloseTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerCloseTest.java 2011-12-06 11:40:53 UTC (rev 11852)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerCloseTest.java 2011-12-06 11:41:24 UTC (rev 11853)
@@ -26,7 +26,6 @@
import org.hornetq.api.core.client.MessageHandler;
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
@@ -35,17 +34,13 @@
import org.hornetq.tests.util.UnitTestCase;
/**
- *
+ *
* @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
*/
public class ConsumerCloseTest extends ServiceTestBase
{
- // Constants -----------------------------------------------------
- private static final Logger log = Logger.getLogger(ConsumerCloseTest.class);
-
- // Attributes ----------------------------------------------------
-
+ private ClientSessionFactory sf;
private HornetQServer server;
private ClientSession session;
@@ -156,45 +151,21 @@
Configuration config = createDefaultConfig();
config.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName()));
config.setSecurityEnabled(false);
- server = HornetQServers.newHornetQServer(config, false);
+
+ server = addServer(HornetQServers.newHornetQServer(config, false));
server.start();
address = RandomUtil.randomSimpleString();
queue = RandomUtil.randomSimpleString();
- locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY));
+ locator =
+ addServerLocator(HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(
+ ServiceTestBase.INVM_CONNECTOR_FACTORY)));
- sf = locator.createSessionFactory();
+ sf = createSessionFactory(locator);
- session = sf.createSession(false, true, true);
+ session = addClientSession(sf.createSession(false, true, true));
session.createQueue(address, queue, false);
-
}
- private ClientSessionFactory sf;
-
- @Override
- protected void tearDown() throws Exception
- {
- session.deleteQueue(queue);
-
- session.close();
-
- sf.close();
-
- locator.close();
-
- server.stop();
-
- session = null;
- sf = null;
- server = null;
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerFilterTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerFilterTest.java 2011-12-06 11:40:53 UTC (rev 11852)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerFilterTest.java 2011-12-06 11:41:24 UTC (rev 11853)
@@ -24,7 +24,7 @@
import org.hornetq.tests.util.ServiceTestBase;
/**
- *
+ *
* A ConsumerFilterTest
*
* @author Tim Fox
@@ -36,6 +36,9 @@
private static final Logger log = Logger.getLogger(ConsumerFilterTest.class);
private HornetQServer server;
+ private ClientSession session;
+ private ClientProducer producer;
+ private ClientConsumer consumer;
@Override
protected void setUp() throws Exception
@@ -45,34 +48,23 @@
server = createServer(false);
server.start();
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
- public void testNonMatchingMessagesFollowedByMatchingMessages() throws Exception
- {
ServerLocator locator = createInVMNonHALocator();
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
- ClientSession session = sf.createSession();
+ session = sf.createSession();
session.start();
-
session.createQueue("foo", "foo");
- ClientProducer producer = session.createProducer("foo");
+ producer = session.createProducer("foo");
+ consumer = session.createConsumer("foo", "animal='giraffe'");
+ }
- ClientConsumer consumer = session.createConsumer("foo", "animal='giraffe'");
+ public void testNonMatchingMessagesFollowedByMatchingMessages() throws Exception
+ {
+
ClientMessage message = session.createMessage(false);
message.putStringProperty("animal", "hippo");
@@ -96,30 +88,13 @@
assertEquals("giraffe", received.getStringProperty("animal"));
assertNull(consumer.receiveImmediate());
-
+
session.close();
-
- sf.close();
-
- locator.close();
}
public void testNonMatchingMessagesFollowedByMatchingMessagesMany() throws Exception
{
- ServerLocator locator = createInVMNonHALocator();
- ClientSessionFactory sf = locator.createSessionFactory();
-
- ClientSession session = sf.createSession();
-
- session.start();
-
- session.createQueue("foo", "foo");
-
- ClientProducer producer = session.createProducer("foo");
-
- ClientConsumer consumer = session.createConsumer("foo", "animal='giraffe'");
-
for (int i = 0; i < QueueImpl.MAX_DELIVERIES_IN_LOOP * 2; i++)
{
ClientMessage message = session.createMessage(false);
@@ -148,105 +123,83 @@
assertEquals("giraffe", received.getStringProperty("animal"));
}
-
+
assertNull(consumer.receiveImmediate());
session.close();
-
- sf.close();
-
- locator.close();
}
-
+
public void testTwoConsumers() throws Exception
{
- ServerLocator locator = createInVMNonHALocator();
-
- ClientSessionFactory sf = locator.createSessionFactory();
-
- ClientSession session = sf.createSession();
-
- session.start();
-
- session.createQueue("foo", "foo");
-
- ClientProducer producer = session.createProducer("foo");
-
- ClientConsumer consumer1 = session.createConsumer("foo", "animal='giraffe'");
-
ClientConsumer consumer2 = session.createConsumer("foo", "animal='elephant'");
//Create and consume message that matches the first consumer's filter
-
+
ClientMessage message = session.createMessage(false);
message.putStringProperty("animal", "giraffe");
producer.send(message);
-
- ClientMessage received = consumer1.receive(10000);
-
+
+ ClientMessage received = consumer.receive(10000);
+
assertNotNull(received);
-
+
assertEquals("giraffe", received.getStringProperty("animal"));
-
- assertNull(consumer1.receiveImmediate());
+
+ assertNull(consumer.receiveImmediate());
assertNull(consumer2.receiveImmediate());
-
+
//Create and consume another message that matches the first consumer's filter
message = session.createMessage(false);
message.putStringProperty("animal", "giraffe");
-
+
producer.send(message);
-
- received = consumer1.receive(10000);
-
+
+ received = consumer.receive(10000);
+
assertNotNull(received);
-
+
assertEquals("giraffe", received.getStringProperty("animal"));
-
- assertNull(consumer1.receiveImmediate());
+
+ assertNull(consumer.receiveImmediate());
assertNull(consumer2.receiveImmediate());
-
+
//Create and consume a message that matches the second consumer's filter
-
+
message = session.createMessage(false);
-
+
message.putStringProperty("animal", "elephant");
-
+
producer.send(message);
-
+
received = consumer2.receive(10000);
-
+
assertNotNull(received);
-
+
assertEquals("elephant", received.getStringProperty("animal"));
-
- assertNull(consumer1.receiveImmediate());
+
+ assertNull(consumer.receiveImmediate());
assertNull(consumer2.receiveImmediate());
-
+
//Create and consume another message that matches the second consumer's filter
-
+
message = session.createMessage(false);
-
+
message.putStringProperty("animal", "elephant");
-
+
producer.send(message);
-
+
received = consumer2.receive(1000);
-
+
assertNotNull(received);
-
+
assertEquals("elephant", received.getStringProperty("animal"));
-
- assertNull(consumer1.receiveImmediate());
+
+ assertNull(consumer.receiveImmediate());
assertNull(consumer2.receiveImmediate());
-
+
session.close();
-
- sf.close();
-
- locator.close();
}
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerTest.java 2011-12-06 11:40:53 UTC (rev 11852)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/ConsumerTest.java 2011-12-06 11:41:24 UTC (rev 11853)
@@ -20,8 +20,13 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.Interceptor;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
-import org.hornetq.core.logging.Logger;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.MessageHandler;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.protocol.core.Packet;
import org.hornetq.core.protocol.core.impl.PacketImpl;
import org.hornetq.core.server.HornetQServer;
@@ -35,8 +40,6 @@
*/
public class ConsumerTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(ConsumerTest.class);
-
private HornetQServer server;
private final SimpleString QUEUE = new SimpleString("ConsumerTestQueue");
@@ -49,28 +52,13 @@
super.setUp();
server = createServer(false);
-
server.start();
-
locator = createInVMNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
-
- server.stop();
-
- server = null;
-
- super.tearDown();
- }
-
-
public void testConsumerAckImmediateAutoCommitTrue() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true, true);
@@ -104,7 +92,7 @@
public void testConsumerAckImmediateAutoCommitFalse() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, false, true);
@@ -138,7 +126,7 @@
public void testConsumerAckImmediateAckIgnored() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true, true);
@@ -176,7 +164,7 @@
public void testConsumerAckImmediateCloseSession() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true, true);
@@ -216,7 +204,7 @@
public void testAcksWithSmallSendWindow() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -248,7 +236,7 @@
ServerLocator locator = createInVMNonHALocator();
locator.setConfirmationWindowSize(100);
locator.setAckBatchSize(-1);
- ClientSessionFactory sfReceive = locator.createSessionFactory();
+ ClientSessionFactory sfReceive = createSessionFactory(locator);
ClientSession sessionRec = sfReceive.createSession(false, true, true);
ClientConsumer consumer = sessionRec.createConsumer(QUEUE);
consumer.setMessageHandler(new MessageHandler()
@@ -270,21 +258,21 @@
sessionRec.close();
locator.close();
}
-
+
// https://jira.jboss.org/browse/HORNETQ-410
public void testConsumeWithNoConsumerFlowControl() throws Exception
{
-
+
ServerLocator locator = createInVMNonHALocator();
-
+
locator.setConsumerWindowSize(-1);
-
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
+
ClientSession session = sf.createSession(false, true, true);
session.createQueue(QUEUE, QUEUE, null, false);
-
+
session.start();
ClientProducer producer = session.createProducer(QUEUE);
@@ -296,25 +284,25 @@
ClientMessage message = createTextMessage(session, "m" + i);
producer.send(message);
}
-
+
ClientConsumer consumer = session.createConsumer(QUEUE);
-
+
for (int i = 0; i < numMessages; i++)
{
ClientMessage message = consumer.receive(10000);
assertNotNull(message);
message.acknowledge();
}
-
+
session.close();
sf.close();
locator.close();
-
+
}
public void testClearListener() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -337,7 +325,7 @@
public void testNoReceiveWithListener() throws Exception
{
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
@@ -378,7 +366,7 @@
{
locator.setConsumerWindowSize(10000);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createTransactedSession();
@@ -406,8 +394,6 @@
ClientConsumer consumer = session.createConsumer(QUEUE);
session.start();
- int commited = 0;
- int rollbacked = 0;
for (int i = 0; i < 110; i++)
{
ClientMessage message = consumer.receive();
@@ -419,12 +405,10 @@
if (count % 2 == 0 && !redelivered)
{
session.rollback();
- rollbacked++;
}
else
{
session.commit();
- commited++;
}
}
@@ -439,7 +423,7 @@
locator.setConsumerWindowSize(10000);
locator.setMinLargeMessageSize(1000);
- ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createTransactedSession();
@@ -467,8 +451,6 @@
ClientConsumer consumer = session.createConsumer(QUEUE);
session.start();
- int commited = 0;
- int rollbacked = 0;
for (int i = 0; i < 110; i++)
{
ClientMessage message = consumer.receive();
@@ -480,12 +462,10 @@
if (count % 2 == 0 && !redelivered)
{
session.rollback();
- rollbacked++;
}
else
{
session.commit();
- commited++;
}
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeadLetterAddressTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeadLetterAddressTest.java 2011-12-06 11:40:53 UTC (rev 11852)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeadLetterAddressTest.java 2011-12-06 11:41:24 UTC (rev 11853)
@@ -34,7 +34,6 @@
import org.hornetq.core.config.Configuration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.server.Queue;
import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.tests.util.RandomUtil;
@@ -49,7 +48,6 @@
private static final Logger log = Logger.getLogger(DeadLetterAddressTest.class);
private HornetQServer server;
-
private ClientSession clientSession;
private ServerLocator locator;
@@ -148,10 +146,10 @@
class TestHandler implements MessageHandler
{
- private CountDownLatch latch;
+ private final CountDownLatch latch;
int count = 0;
- private ClientSession clientSession;
+ private final ClientSession clientSession;
public TestHandler(CountDownLatch latch, ClientSession clientSession)
{
@@ -251,7 +249,7 @@
clientSession.createQueue(dla, dlq, null, false);
clientSession.createQueue(qName, qName, null, false);
ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession sendSession = sessionFactory.createSession(false, true, true);
ClientProducer producer = sendSession.createProducer(qName);
Map<String, Long> origIds = new HashMap<String, Long>();
@@ -470,54 +468,13 @@
configuration.setSecurityEnabled(false);
TransportConfiguration transportConfig = new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY);
configuration.getAcceptorConfigurations().add(transportConfig);
- server = HornetQServers.newHornetQServer(configuration, false);
- // start the server
+ server = createServer(false, configuration);
server.start();
// then we create a client as normal
- locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
- clientSession = sessionFactory.createSession(false, true, false);
+ locator =
+ addServerLocator(HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(
+ UnitTestCase.INVM_CONNECTOR_FACTORY)));
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
+ clientSession = addClientSession(sessionFactory.createSession(false, true, false));
}
-
- @Override
- protected void tearDown() throws Exception
- {
- if (clientSession != null)
- {
- try
- {
- clientSession.close();
- }
- catch (HornetQException e1)
- {
- //
- }
- }
- if(locator != null)
- {
- try
- {
- locator.close();
- }
- catch (Exception e)
- {
- //
- }
- }
- if (server != null && server.isStarted())
- {
- try
- {
- server.stop();
- }
- catch (Exception e1)
- {
- //
- }
- }
- server = null;
- clientSession = null;
- super.tearDown();
- }
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeliveryOrderTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeliveryOrderTest.java 2011-12-06 11:40:53 UTC (rev 11852)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/DeliveryOrderTest.java 2011-12-06 11:41:24 UTC (rev 11853)
@@ -20,7 +20,13 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.MessageHandler;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
@@ -39,28 +45,22 @@
private ServerLocator locator;
+ private HornetQServer server;
+
+ private ClientSessionFactory cf;
+
@Override
protected void setUp() throws Exception
{
super.setUp();
locator = createInVMNonHALocator();
+ server = createServer(false);
+ server.start();
+ cf = createSessionFactory(locator);
}
- @Override
- protected void tearDown() throws Exception
- {
- locator.close();
- locator = null;
- super.tearDown();
- }
-
public void testSendDeliveryOrderOnCommit() throws Exception
{
- HornetQServer server = createServer(false);
- try
- {
- server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
ClientSession sendSession = cf.createSession(false, false, true);
ClientProducer cp = sendSession.createProducer(addressA);
int numMessages = 1000;
@@ -85,24 +85,10 @@
Assert.assertEquals(i, cm.getBodyBuffer().readInt());
}
sendSession.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
}
- }
- }
public void testReceiveDeliveryOrderOnRollback() throws Exception
{
- HornetQServer server = createServer(false);
- try
- {
- server.start();
- locator = createInVMNonHALocator();
- ClientSessionFactory cf = locator.createSessionFactory();
ClientSession sendSession = cf.createSession(false, true, false);
ClientProducer cp = sendSession.createProducer(addressA);
int numMessages = 1000;
@@ -131,24 +117,10 @@
Assert.assertEquals(i, cm.getBodyBuffer().readInt());
}
sendSession.close();
- }
- finally
- {
- locator.close();
- if (server.isStarted())
- {
- server.stop();
}
- }
- }
public void testMultipleConsumersMessageOrder() throws Exception
{
- HornetQServer server = createServer(false);
- try
- {
- server.start();
- ClientSessionFactory cf = locator.createSessionFactory();
ClientSession sendSession = cf.createSession(false, true, true);
ClientSession recSession = cf.createSession(false, true, true);
sendSession.createQueue(addressA, queueA, false);
@@ -179,15 +151,7 @@
}
sendSession.close();
recSession.close();
- }
- finally
- {
- if (server.isStarted())
- {
- server.stop();
}
- }
- }
class Receiver implements MessageHandler
{
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java 2011-12-06 11:40:53 UTC (rev 11852)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/bridge/BridgeStartTest.java 2011-12-06 11:41:24 UTC (rev 11853)
@@ -817,19 +817,4 @@
}
}
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- clearData();
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- clearData();
- super.tearDown();
- }
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java 2011-12-06 11:40:53 UTC (rev 11852)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java 2011-12-06 11:41:24 UTC (rev 11853)
@@ -36,7 +36,6 @@
import org.hornetq.core.config.BridgeConfiguration;
import org.hornetq.core.config.CoreQueueConfiguration;
import org.hornetq.core.config.impl.ConfigurationImpl;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.postoffice.DuplicateIDCache;
import org.hornetq.core.postoffice.impl.PostOfficeImpl;
import org.hornetq.core.remoting.impl.invm.TransportConstants;
@@ -63,7 +62,6 @@
*/
public class BridgeTest extends ServiceTestBase
{
- private static final Logger log = Logger.getLogger(BridgeTest.class);
protected boolean isNetty()
{
@@ -1714,19 +1712,4 @@
}
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- clearData();
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- clearData();
- super.tearDown();
- }
-
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-12-06 11:40:53 UTC (rev 11852)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-12-06 11:41:24 UTC (rev 11853)
@@ -129,7 +129,8 @@
}
- protected TestableServer createServer(Configuration config)
+ @Override
+ protected TestableServer createTestableServer(Configuration config)
{
return new SameProcessHornetQServer(
createInVMFailoverServer(true, config, nodeManager, config.isBackup() ? 2 : 1));
@@ -186,7 +187,7 @@
backupConfig.getConnectorConfigurations().put(backupConnector.getName(), backupConnector);
ReplicatedBackupUtils.createClusterConnectionConf(backupConfig, backupConnector.getName(),
liveConnector.getName());
- backupServer = createServer(backupConfig);
+ backupServer = createTestableServer(backupConfig);
liveConfig = super.createDefaultConfig();
liveConfig.getAcceptorConfigurations().clear();
@@ -196,7 +197,7 @@
liveConfig.setClustered(true);
ReplicatedBackupUtils.createClusterConnectionConf(liveConfig, liveConnector.getName());
liveConfig.getConnectorConfigurations().put(liveConnector.getName(), liveConnector);
- liveServer = createServer(liveConfig);
+ liveServer = createTestableServer(liveConfig);
}
protected void createReplicatedConfigs()
@@ -221,11 +222,11 @@
backupConfig.setLargeMessagesDirectory(backupConfig.getLargeMessagesDirectory() + sufix);
backupConfig.setSecurityEnabled(false);
- backupServer = createServer(backupConfig);
+ backupServer = createTestableServer(backupConfig);
liveConfig.getAcceptorConfigurations().clear();
liveConfig.getAcceptorConfigurations().add(getAcceptorTransportConfiguration(true));
- liveServer = createServer(liveConfig);
+ liveServer = createTestableServer(liveConfig);
}
@Override
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/scheduling/DelayedMessageTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/scheduling/DelayedMessageTest.java 2011-12-06 11:40:53 UTC (rev 11852)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/scheduling/DelayedMessageTest.java 2011-12-06 11:41:24 UTC (rev 11853)
@@ -14,7 +14,12 @@
import junit.framework.Assert;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
@@ -44,7 +49,6 @@
protected void setUp() throws Exception
{
super.setUp();
- clearData();
initServer();
}
@@ -67,29 +71,9 @@
locator = createInVMNonHALocator();
}
- @Override
- protected void tearDown() throws Exception
- {
- if (server != null)
- {
- try
- {
- server.getAddressSettingsRepository().removeMatch(qName);
-
- server.stop();
- server = null;
- }
- catch (Exception e)
- {
- // ignore
- }
- }
- super.tearDown();
- }
-
public void testDelayedRedeliveryDefaultOnClose() throws Exception
{
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(false, false, false);
session.createQueue(qName, qName, null, true);
@@ -155,12 +139,12 @@
session3.commit();
session3.close();
- sessionFactory.close();
+
}
public void testDelayedRedeliveryDefaultOnRollback() throws Exception
{
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(false, false, false);
session.createQueue(qName, qName, null, true);
@@ -214,12 +198,12 @@
session2.commit();
session2.close();
- sessionFactory.close();
+
}
public void testDelayedRedeliveryWithStart() throws Exception
{
- ClientSessionFactory sessionFactory = locator.createSessionFactory();
+ ClientSessionFactory sessionFactory = createSessionFactory(locator);
ClientSession session = sessionFactory.createSession(false, false, false);
session.createQueue(qName, qName, null, true);
@@ -251,8 +235,8 @@
// Now rollback
long now = System.currentTimeMillis();
-
+
session2.rollback();
session2.close();
@@ -265,12 +249,12 @@
initServer();
- sessionFactory = locator.createSessionFactory();
+ sessionFactory = createSessionFactory(locator);
session2 = sessionFactory.createSession(false, false, false);
-
+
consumer2 = session2.createConsumer(qName);
-
+
Thread.sleep(3000);
session2.start();
@@ -292,7 +276,7 @@
session2.commit();
session2.close();
- sessionFactory.close();
+
}
// Private -------------------------------------------------------
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/BasicXaTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/BasicXaTest.java 2011-12-06 11:40:53 UTC (rev 11852)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/xa/BasicXaTest.java 2011-12-06 11:41:24 UTC (rev 11853)
@@ -80,73 +80,19 @@
messagingService.start();
locator = createInVMNonHALocator();
- sessionFactory = locator.createSessionFactory();
+ sessionFactory = createSessionFactory(locator);
- clientSession = sessionFactory.createSession(true, false, false);
+ clientSession = addClientSession(sessionFactory.createSession(true, false, false));
clientSession.createQueue(atestq, atestq, null, true);
}
- @Override
- protected void tearDown() throws Exception
- {
- if (clientSession != null)
- {
- try
- {
- clientSession.close();
- }
- catch (HornetQException e1)
- {
- //
- }
- }
- if(sessionFactory != null)
- {
- try
- {
- sessionFactory.close();
- }
- catch (Exception e)
- {
- //
- }
- }
- if(locator != null)
- {
- try
- {
- locator.close();
- }
- catch (Exception e)
- {
- //
- }
- }
- if (messagingService != null && messagingService.isStarted())
- {
- try
- {
- messagingService.stop();
- }
- catch (Exception e1)
- {
- //
- }
- }
- messagingService = null;
- clientSession = null;
-
- super.tearDown();
- }
-
-
public void testSendWithoutXID() throws Exception
{
// Since both resources have same RM, TM will probably use 1PC optimization
ServerLocator locator = createInVMNonHALocator();
- ClientSessionFactory factory = locator.createSessionFactory();
+ ClientSessionFactory factory = createSessionFactory(locator);
ClientSession session = null;
@@ -181,7 +127,7 @@
// Since both resources have same RM, TM will probably use 1PC optimization
- ClientSessionFactory factory = locator.createSessionFactory();
+ ClientSessionFactory factory = createSessionFactory(locator);
ClientSession session = null;
@@ -228,8 +174,6 @@
}
finally
{
- factory.close();
-
session.close();
}
}
@@ -239,7 +183,7 @@
public void testIsSameRM() throws Exception
{
ServerLocator locator = createNettyNonHALocator();
- ClientSessionFactory nettyFactory = locator.createSessionFactory();
+ ClientSessionFactory nettyFactory = createSessionFactory(locator);
validateRM(nettyFactory, nettyFactory);
validateRM(sessionFactory, sessionFactory);
validateRM(nettyFactory, sessionFactory);
@@ -532,7 +476,7 @@
messagingService.start();
- sessionFactory = locator.createSessionFactory();
+ sessionFactory = createSessionFactory(locator);
xid = newXID();
session = sessionFactory.createSession(true, false, false);
@@ -559,7 +503,7 @@
messagingService.start();
- sessionFactory = locator.createSessionFactory();
+ sessionFactory = createSessionFactory(locator);
xid = newXID();
session = sessionFactory.createSession(true, false, false);
@@ -573,7 +517,7 @@
messagingService.start();
// This is not really necessary... But since the server has stopped, I would prefer to keep recreating the factory
- sessionFactory = locator.createSessionFactory();
+ sessionFactory = createSessionFactory(locator);
session = sessionFactory.createSession(true, false, false);
Modified: trunk/tests/soak-tests/src/test/java/org/hornetq/tests/soak/client/ClientNonDivertedSoakTest.java
===================================================================
--- trunk/tests/soak-tests/src/test/java/org/hornetq/tests/soak/client/ClientNonDivertedSoakTest.java 2011-12-06 11:40:53 UTC (rev 11852)
+++ trunk/tests/soak-tests/src/test/java/org/hornetq/tests/soak/client/ClientNonDivertedSoakTest.java 2011-12-06 11:41:24 UTC (rev 11853)
@@ -72,8 +72,8 @@
ServerLocator locator = createFactory(ClientNonDivertedSoakTest.IS_NETTY);
- ClientSessionFactory sf = locator.createSessionFactory();
-
+ ClientSessionFactory sf = createSessionFactory(locator);
+
ClientSession session = sf.createSession();
session.createQueue(ClientNonDivertedSoakTest.ADDRESS, ClientNonDivertedSoakTest.ADDRESS, true);
@@ -81,23 +81,16 @@
session.close();
sf.close();
-
+
locator.close();
}
- @Override
- protected void tearDown() throws Exception
- {
- server.stop();
- server = null;
- }
-
public void testSoakClient() throws Exception
{
ServerLocator locator = createFactory(ClientNonDivertedSoakTest.IS_NETTY);
- final ClientSessionFactory sf = locator.createSessionFactory();
+ final ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, false);
@@ -137,7 +130,7 @@
System.out.println("There are sequence errors in some of the clients, please look at the logs");
break;
}
-
+
System.out.println("count = " + send.msgs);
Thread.sleep(10000);
}
@@ -150,7 +143,7 @@
assertEquals(0, send.getErrorsCount());
assertEquals(0, rec1.getErrorsCount());
-
+
locator.close();
}
13 years
JBoss hornetq SVN: r11852 - trunk/hornetq-core/src/test/java/org/hornetq/tests/util.
by do-not-reply@jboss.org
Author: borges
Date: 2011-12-06 06:40:53 -0500 (Tue, 06 Dec 2011)
New Revision: 11852
Modified:
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
Log:
always clear temporary data
Modified: trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-12-06 10:33:14 UTC (rev 11851)
+++ trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-12-06 11:40:53 UTC (rev 11852)
@@ -1025,7 +1025,7 @@
checkThread = true;
}
-
+ clearData();
super.tearDown();
}
13 years