From 6acca39fe427c3a92eb35adbd990e343ce32708f Mon Sep 17 00:00:00 2001 From: Arnaud Simon Date: Thu, 22 May 2008 17:16:20 +0000 Subject: QPID-1079: Updated ...test.client tests for using QpidTestCase + move QpidTestCase in main so it is visible form systests git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@659163 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/java/010ExcludeList | 16 +- qpid/java/010ExcludeList-store | 16 +- qpid/java/08ExcludeList | 4 +- .../org/apache/qpid/testutil/QpidTestCase.java | 456 +++++++++++++++++++++ .../org/apache/qpid/testutil/QpidTestCase.java | 446 -------------------- .../qpid/test/testcases/MessageThroughputPerf.java | 2 +- .../qpid/test/framework/FrameworkBaseCase.java | 12 +- .../qpid/test/framework/LocalCircuitFactory.java | 5 +- .../test/framework/sequencers/CircuitFactory.java | 3 +- .../framework/sequencers/FanOutCircuitFactory.java | 7 +- .../sequencers/InteropCircuitFactory.java | 7 +- .../apache/qpid/test/testcases/FailoverTest.java | 4 +- .../qpid/test/testcases/ImmediateMessageTest.java | 48 +-- .../qpid/test/testcases/MandatoryMessageTest.java | 48 +-- .../apache/qpid/test/testcases/RollbackTest.java | 16 +- 15 files changed, 556 insertions(+), 534 deletions(-) create mode 100644 qpid/java/client/src/main/java/org/apache/qpid/testutil/QpidTestCase.java delete mode 100644 qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java (limited to 'qpid/java') diff --git a/qpid/java/010ExcludeList b/qpid/java/010ExcludeList index 8a38aeaad5..13ae556017 100644 --- a/qpid/java/010ExcludeList +++ b/qpid/java/010ExcludeList @@ -30,4 +30,18 @@ org.apache.qpid.test.client.QueueBrowserNoAckTest#testFailoverWithQueueBrowser org.apache.qpid.test.client.QueueBrowserPreAckTest#testFailoverAsQueueBrowserCreated org.apache.qpid.test.client.QueueBrowserPreAckTest#testFailoverWithQueueBrowser org.apache.qpid.test.client.QueueBrowserTransactedTest#testFailoverAsQueueBrowserCreated -org.apache.qpid.test.client.QueueBrowserTransactedTest#testFailoverWithQueueBrowser \ No newline at end of file +org.apache.qpid.test.client.QueueBrowserTransactedTest#testFailoverWithQueueBrowser +org.apache.qpid.test.testcases.FailoverTest#* +// Those tests are testing 0.8 specific semantics +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsConsumerDisconnectedNoTxP2P +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsConsumerDisconnectedTxP2P +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsNoRouteNoTxP2P +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsNoRouteTxP2P +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsConsumerDisconnectedNoTxPubSub +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsConsumerDisconnectedTxPubSub +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsNoRouteNoTxPubSub +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsNoRouteTxPubSub +org.apache.qpid.test.testcases.MandatoryMessageTest#test_QPID_508_MandatoryFailsNoRouteNoTxP2P +org.apache.qpid.test.testcases.MandatoryMessageTest#test_QPID_508_MandatoryFailsNoRouteTxP2P +org.apache.qpid.test.testcases.MandatoryMessageTest#test_QPID_508_MandatoryFailsNoRouteNoTxPubSub +org.apache.qpid.test.testcases.MandatoryMessageTest#test_QPID_508_MandatoryFailsNoRouteTxPubSub \ No newline at end of file diff --git a/qpid/java/010ExcludeList-store b/qpid/java/010ExcludeList-store index 8b3a9129bf..94777dc44b 100644 --- a/qpid/java/010ExcludeList-store +++ b/qpid/java/010ExcludeList-store @@ -25,4 +25,18 @@ org.apache.qpid.test.client.QueueBrowserNoAckTest#testFailoverWithQueueBrowser org.apache.qpid.test.client.QueueBrowserPreAckTest#testFailoverAsQueueBrowserCreated org.apache.qpid.test.client.QueueBrowserPreAckTest#testFailoverWithQueueBrowser org.apache.qpid.test.client.QueueBrowserTransactedTest#testFailoverAsQueueBrowserCreated -org.apache.qpid.test.client.QueueBrowserTransactedTest#testFailoverWithQueueBrowser \ No newline at end of file +org.apache.qpid.test.client.QueueBrowserTransactedTest#testFailoverWithQueueBrowser +org.apache.qpid.test.testcases.FailoverTest#* +// Those tests are testing 0.8 specific semantics +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsConsumerDisconnectedNoTxP2P +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsConsumerDisconnectedTxP2P +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsNoRouteNoTxP2P +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsNoRouteTxP2P +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsConsumerDisconnectedNoTxPubSub +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsConsumerDisconnectedTxPubSub +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsNoRouteNoTxPubSub +org.apache.qpid.test.testcases.ImmediateMessageTest#test_QPID_517_ImmediateFailsNoRouteTxPubSub +org.apache.qpid.test.testcases.MandatoryMessageTest#test_QPID_508_MandatoryFailsNoRouteNoTxP2P +org.apache.qpid.test.testcases.MandatoryMessageTest#test_QPID_508_MandatoryFailsNoRouteTxP2P +org.apache.qpid.test.testcases.MandatoryMessageTest#test_QPID_508_MandatoryFailsNoRouteNoTxPubSub +org.apache.qpid.test.testcases.MandatoryMessageTest#test_QPID_508_MandatoryFailsNoRouteTxPubSub \ No newline at end of file diff --git a/qpid/java/08ExcludeList b/qpid/java/08ExcludeList index 3541387b17..c97c968816 100644 --- a/qpid/java/08ExcludeList +++ b/qpid/java/08ExcludeList @@ -1,6 +1,6 @@ org.apache.qpid.test.unit.xa.QueueTest#* org.apache.qpid.test.unit.xa.TopicTest#* org.apache.qpid.test.unit.ct.DurableSubscriberTests#* -// This test is not finished +// Those tests are not finished org.apache.qpid.test.testcases.TTLTest#* - +org.apache.qpid.test.testcases.FailoverTest#* diff --git a/qpid/java/client/src/main/java/org/apache/qpid/testutil/QpidTestCase.java b/qpid/java/client/src/main/java/org/apache/qpid/testutil/QpidTestCase.java new file mode 100644 index 0000000000..1fe9a3ae51 --- /dev/null +++ b/qpid/java/client/src/main/java/org/apache/qpid/testutil/QpidTestCase.java @@ -0,0 +1,456 @@ +/* Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.qpid.testutil; + +import junit.framework.TestCase; +import junit.framework.TestResult; + +import javax.jms.Connection; +import javax.naming.InitialContext; +import java.io.*; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import org.apache.qpid.client.transport.TransportConnection; +import org.apache.qpid.client.AMQConnection; +import org.apache.qpid.client.AMQConnectionFactory; + + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * + */ +public class QpidTestCase extends TestCase +{ + + private static final Logger _logger = LoggerFactory.getLogger(QpidTestCase.class); + + /** + * Some tests are excluded when the property test.excludes is set to true. + * An exclusion list is either a file (prop test.excludesfile) which contains one test name + * to be excluded per line or a String (prop test.excludeslist) where tests to be excluded are + * separated by " ". Excluded tests are specified following the format: + * className#testName where className is the class of the test to be + * excluded and testName is the name of the test to be excluded. + * className#* excludes all the tests of the specified class. + */ + static + { + if (Boolean.getBoolean("test.excludes")) + { + _logger.info("Some tests should be excluded, building the exclude list"); + String exclusionListURI = System.getProperties().getProperty("test.excludesfile", ""); + String exclusionListString = System.getProperties().getProperty("test.excludeslist", ""); + File file=new File(exclusionListURI); + List exclusionList = new ArrayList(); + if (file.exists()) + { + _logger.info("Using exclude file: " + exclusionListURI); + try + { + BufferedReader in = new BufferedReader(new FileReader(file)); + String excludedTest = in.readLine(); + do + { + exclusionList.add(excludedTest); + excludedTest = in.readLine(); + } + while (excludedTest != null); + } + catch (IOException e) + { + _logger.warn("Exception when reading exclusion list", e); + } + } + else if( ! exclusionListString.equals("")) + { + _logger.info("Using excludeslist: " + exclusionListString); + // the exclusion list may be specified as a string + StringTokenizer t = new StringTokenizer(exclusionListString, " "); + while (t.hasMoreTokens()) + { + exclusionList.add(t.nextToken()); + } + } + else + { + throw new RuntimeException("Aborting test: Cannot find excludes file nor excludes list"); + } + _exclusionList = exclusionList; + } + } + + private static List _exclusionList; + + // system properties + private static final String BROKER = "broker"; + private static final String BROKER_CLEAN = "broker.clean"; + private static final String BROKER_VERSION = "broker.version"; + private static final String BROKER_READY = "broker.ready"; + + // values + protected static final String VM = "vm"; + private static final String EXTERNAL = "external"; + private static final String VERSION_08 = "0-8"; + private static final String VERSION_010 = "0-10"; + + protected String _broker = System.getProperty(BROKER, VM); + private String _brokerClean = System.getProperty(BROKER_CLEAN, null); + private String _brokerVersion = System.getProperty(BROKER_VERSION, VERSION_08); + + private Process _brokerProcess; + + private InitialContext _initialContext; + private AMQConnectionFactory _connectionFactory; + private boolean _brokerStarted; + + // the connections created for a given test + protected List _connections = new ArrayList(); + + public QpidTestCase(String name) + { + super(name); + } + + public QpidTestCase() + { + super("QpidTestCase"); + } + + public void runBare() throws Throwable + { + String name = getClass().getSimpleName() + "." + getName(); + _logger.info("========== start " + name + " =========="); + startBroker(); + try + { + super.runBare(); + } + finally + { + try + { + stopBroker(); + } + catch (Exception e) + { + _logger.error("exception stopping broker", e); + } + _logger.info("========== stop " + name + " =========="); + } + } + + public void run(TestResult testResult) + { + if( _exclusionList != null && (_exclusionList.contains( getClass().getName() + "#*") || + _exclusionList.contains( getClass().getName() + "#" + getName()))) + { + _logger.info("Test: " + getName() + " is excluded"); + testResult.endTest(this); + } + else + { + super.run(testResult); + } + } + + + private static final class Piper extends Thread + { + + private LineNumberReader in; + private String ready; + private CountDownLatch latch; + + public Piper(InputStream in, String ready) + { + this.in = new LineNumberReader(new InputStreamReader(in)); + this.ready = ready; + if (this.ready != null && !this.ready.equals("")) + { + this.latch = new CountDownLatch(1); + } + else + { + this.latch = null; + } + } + + public Piper(InputStream in) + { + this(in, null); + } + + public boolean await(long timeout, TimeUnit unit) throws InterruptedException + { + if (latch == null) + { + return true; + } + else + { + return latch.await(timeout, unit); + } + } + + public void run() + { + try + { + String line; + while ((line = in.readLine()) != null) + { + System.out.println(line); + if (latch != null && line.contains(ready)) + { + latch.countDown(); + } + } + } + catch (IOException e) + { + // this seems to happen regularly even when + // exits are normal + } + finally + { + if (latch != null) + { + latch.countDown(); + } + } + } + } + + public void startBroker() throws Exception + { + if (_broker.equals(VM)) + { + // create an in_VM broker + TransportConnection.createVMBroker(1); + } + else if (!_broker.equals(EXTERNAL)) + { + _logger.info("starting broker: " + _broker); + ProcessBuilder pb = new ProcessBuilder(_broker.split("\\s+")); + pb.redirectErrorStream(true); + _brokerProcess = pb.start(); + + Piper p = new Piper(_brokerProcess.getInputStream(), + System.getProperty(BROKER_READY)); + + p.start(); + + if (!p.await(30, TimeUnit.SECONDS)) + { + _logger.info("broker failed to become ready"); + cleanBroker(); + throw new RuntimeException("broker failed to become ready"); + } + + try + { + int exit = _brokerProcess.exitValue(); + _logger.info("broker aborted: " + exit); + cleanBroker(); + throw new RuntimeException("broker aborted: " + exit); + } + catch (IllegalThreadStateException e) + { + // this is expect if the broker started succesfully + } + } + _brokerStarted = true; + } + + public void cleanBroker() + { + if (_brokerClean != null) + { + _logger.info("clean: " + _brokerClean); + + try + { + ProcessBuilder pb = new ProcessBuilder(_brokerClean.split("\\s+")); + pb.redirectErrorStream(true); + Process clean = pb.start(); + new Piper(clean.getInputStream()).start(); + + clean.waitFor(); + + _logger.info("clean exited: " + clean.exitValue()); + } + catch (IOException e) + { + throw new RuntimeException(e); + } + catch (InterruptedException e) + { + throw new RuntimeException(e); + } + } + } + + public void stopBroker() throws Exception + { + _logger.info("stopping broker: " + _broker); + if (_brokerProcess != null) + { + _brokerProcess.destroy(); + _brokerProcess.waitFor(); + _logger.info("broker exited: " + _brokerProcess.exitValue()); + _brokerProcess = null; + } + else if (_broker.equals(VM)) + { + TransportConnection.killAllVMBrokers(); + } + _brokerStarted = false; + } + + /** + * Check whether the broker is an 0.8 + * @return true if the broker is an 0_8 version, false otherwise. + */ + public boolean isBroker08() + { + return _brokerVersion.equals(VERSION_08); + } + + public boolean isBroker010() + { + return _brokerVersion.equals(VERSION_010); + } + + public void shutdownServer() throws Exception + { + stopBroker(); + startBroker(); + } + /** + * we assume that the environment is correctly set + * i.e. -Djava.naming.provider.url="..//example010.properties" + * TODO should be a way of setting that through maven + * + * @return an initial context + * @throws Exception if there is an error getting the context + */ + public InitialContext getInitialContext() throws Exception + { + _logger.info("get InitialContext"); + if (_initialContext == null) + { + _initialContext = new InitialContext(); + } + return _initialContext; + } + + /** + * Get the default connection factory for the currently used broker + * Default factory is "local" + * + * @return A conection factory + * @throws Exception if there is an error getting the tactory + */ + public AMQConnectionFactory getConnectionFactory() throws Exception + { + _logger.info("get ConnectionFactory"); + if (_connectionFactory == null) + { + if (_broker.equals(VM)) + { + _connectionFactory = getConnectionFactory("vm"); + } + else + { + _connectionFactory = getConnectionFactory("local"); + } + } + return _connectionFactory; + } + + /** + * Get a connection factory for the currently used broker + * + * @param factoryName The factory name + * @return A conection factory + * @throws Exception if there is an error getting the tactory + */ + public AMQConnectionFactory getConnectionFactory(String factoryName) throws Exception + { + return (AMQConnectionFactory) getInitialContext().lookup(factoryName); + } + + public Connection getConnection() throws Exception + { + return getConnection("guest", "guest"); + } + + /** + * Get a connection (remote or in-VM) + * + * @param username The user name + * @param password The user password + * @return a newly created connection + * @throws Exception if there is an error getting the connection + */ + public Connection getConnection(String username, String password) throws Exception + { + _logger.info("get Connection"); + Connection con = getConnectionFactory().createConnection(username, password); + //add the connection in the lis of connections + _connections.add(con); + return con; + } + + public Connection getConnection(String username, String password, String id) throws Exception + { + _logger.info("get Connection"); + Connection con; + if (_broker.equals(VM)) + { + con = new AMQConnection("vm://:1", username, password, id, "test"); + } + else + { + con = getConnectionFactory().createConnection(username, password); + } + //add the connection in the lis of connections + _connections.add(con); + return con; + } + + protected void tearDown() throws java.lang.Exception + { + // close all the connections used by this test. + if (_brokerStarted) + { + for (Connection c : _connections) + { + c.close(); + } + } + } + +} diff --git a/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java b/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java deleted file mode 100644 index 36278f890b..0000000000 --- a/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java +++ /dev/null @@ -1,446 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.qpid.testutil; - -import junit.framework.TestCase; -import junit.framework.TestResult; - -import javax.jms.Connection; -import javax.naming.InitialContext; -import java.io.*; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.apache.qpid.client.transport.TransportConnection; -import org.apache.qpid.client.AMQConnection; -import org.apache.qpid.client.AMQConnectionFactory; - - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * - */ -public class QpidTestCase extends TestCase -{ - - private static final Logger _logger = LoggerFactory.getLogger(QpidTestCase.class); - - /** - * Some tests are excluded when the property test.excludes is set to true. - * An exclusion list is either a file (prop test.excludesfile) which contains one test name - * to be excluded per line or a String (prop test.excludeslist) where tests to be excluded are - * separated by " ". Excluded tests are specified following the format: - * className#testName where className is the class of the test to be - * excluded and testName is the name of the test to be excluded. - * className#* excludes all the tests of the specified class. - */ - static - { - if (Boolean.getBoolean("test.excludes")) - { - _logger.info("Some tests should be excluded, building the exclude list"); - String exclusionListURI = System.getProperties().getProperty("test.excludesfile", ""); - String exclusionListString = System.getProperties().getProperty("test.excludeslist", ""); - File file=new File(exclusionListURI); - List exclusionList = new ArrayList(); - if (file.exists()) - { - _logger.info("Using exclude file: " + exclusionListURI); - try - { - BufferedReader in = new BufferedReader(new FileReader(file)); - String excludedTest = in.readLine(); - do - { - exclusionList.add(excludedTest); - excludedTest = in.readLine(); - } - while (excludedTest != null); - } - catch (IOException e) - { - _logger.warn("Exception when reading exclusion list", e); - } - } - else if( ! exclusionListString.equals("")) - { - _logger.info("Using excludeslist: " + exclusionListString); - // the exclusion list may be specified as a string - StringTokenizer t = new StringTokenizer(exclusionListString, " "); - while (t.hasMoreTokens()) - { - exclusionList.add(t.nextToken()); - } - } - else - { - throw new RuntimeException("Aborting test: Cannot find excludes file nor excludes list"); - } - _exclusionList = exclusionList; - } - } - - private static List _exclusionList; - - // system properties - private static final String BROKER = "broker"; - private static final String BROKER_CLEAN = "broker.clean"; - private static final String BROKER_VERSION = "broker.version"; - private static final String BROKER_READY = "broker.ready"; - - // values - protected static final String VM = "vm"; - private static final String EXTERNAL = "external"; - private static final String VERSION_08 = "0-8"; - private static final String VERSION_010 = "0-10"; - - protected String _broker = System.getProperty(BROKER, VM); - private String _brokerClean = System.getProperty(BROKER_CLEAN, null); - private String _brokerVersion = System.getProperty(BROKER_VERSION, VERSION_08); - - private Process _brokerProcess; - - private InitialContext _initialContext; - private AMQConnectionFactory _connectionFactory; - private boolean _brokerStarted; - - // the connections created for a given test - protected List _connections = new ArrayList(); - - public void runBare() throws Throwable - { - String name = getClass().getSimpleName() + "." + getName(); - _logger.info("========== start " + name + " =========="); - startBroker(); - try - { - super.runBare(); - } - finally - { - try - { - stopBroker(); - } - catch (Exception e) - { - _logger.error("exception stopping broker", e); - } - _logger.info("========== stop " + name + " =========="); - } - } - - public void run(TestResult testResult) - { - if( _exclusionList != null && (_exclusionList.contains( getClass().getName() + "#*") || - _exclusionList.contains( getClass().getName() + "#" + getName()))) - { - _logger.info("Test: " + getName() + " is excluded"); - testResult.endTest(this); - } - else - { - super.run(testResult); - } - } - - - private static final class Piper extends Thread - { - - private LineNumberReader in; - private String ready; - private CountDownLatch latch; - - public Piper(InputStream in, String ready) - { - this.in = new LineNumberReader(new InputStreamReader(in)); - this.ready = ready; - if (this.ready != null && !this.ready.equals("")) - { - this.latch = new CountDownLatch(1); - } - else - { - this.latch = null; - } - } - - public Piper(InputStream in) - { - this(in, null); - } - - public boolean await(long timeout, TimeUnit unit) throws InterruptedException - { - if (latch == null) - { - return true; - } - else - { - return latch.await(timeout, unit); - } - } - - public void run() - { - try - { - String line; - while ((line = in.readLine()) != null) - { - System.out.println(line); - if (latch != null && line.contains(ready)) - { - latch.countDown(); - } - } - } - catch (IOException e) - { - // this seems to happen regularly even when - // exits are normal - } - finally - { - if (latch != null) - { - latch.countDown(); - } - } - } - } - - public void startBroker() throws Exception - { - if (_broker.equals(VM)) - { - // create an in_VM broker - TransportConnection.createVMBroker(1); - } - else if (!_broker.equals(EXTERNAL)) - { - _logger.info("starting broker: " + _broker); - ProcessBuilder pb = new ProcessBuilder(_broker.split("\\s+")); - pb.redirectErrorStream(true); - _brokerProcess = pb.start(); - - Piper p = new Piper(_brokerProcess.getInputStream(), - System.getProperty(BROKER_READY)); - - p.start(); - - if (!p.await(30, TimeUnit.SECONDS)) - { - _logger.info("broker failed to become ready"); - cleanBroker(); - throw new RuntimeException("broker failed to become ready"); - } - - try - { - int exit = _brokerProcess.exitValue(); - _logger.info("broker aborted: " + exit); - cleanBroker(); - throw new RuntimeException("broker aborted: " + exit); - } - catch (IllegalThreadStateException e) - { - // this is expect if the broker started succesfully - } - } - _brokerStarted = true; - } - - public void cleanBroker() - { - if (_brokerClean != null) - { - _logger.info("clean: " + _brokerClean); - - try - { - ProcessBuilder pb = new ProcessBuilder(_brokerClean.split("\\s+")); - pb.redirectErrorStream(true); - Process clean = pb.start(); - new Piper(clean.getInputStream()).start(); - - clean.waitFor(); - - _logger.info("clean exited: " + clean.exitValue()); - } - catch (IOException e) - { - throw new RuntimeException(e); - } - catch (InterruptedException e) - { - throw new RuntimeException(e); - } - } - } - - public void stopBroker() throws Exception - { - _logger.info("stopping broker: " + _broker); - if (_brokerProcess != null) - { - _brokerProcess.destroy(); - _brokerProcess.waitFor(); - _logger.info("broker exited: " + _brokerProcess.exitValue()); - _brokerProcess = null; - } - else if (_broker.equals(VM)) - { - TransportConnection.killAllVMBrokers(); - } - _brokerStarted = false; - } - - /** - * Check whether the broker is an 0.8 - * @return true if the broker is an 0_8 version, false otherwise. - */ - public boolean isBroker08() - { - return _brokerVersion.equals(VERSION_08); - } - - public boolean isBroker010() - { - return _brokerVersion.equals(VERSION_010); - } - - public void shutdownServer() throws Exception - { - stopBroker(); - startBroker(); - } - /** - * we assume that the environment is correctly set - * i.e. -Djava.naming.provider.url="..//example010.properties" - * TODO should be a way of setting that through maven - * - * @return an initial context - * @throws Exception if there is an error getting the context - */ - public InitialContext getInitialContext() throws Exception - { - _logger.info("get InitialContext"); - if (_initialContext == null) - { - _initialContext = new InitialContext(); - } - return _initialContext; - } - - /** - * Get the default connection factory for the currently used broker - * Default factory is "local" - * - * @return A conection factory - * @throws Exception if there is an error getting the tactory - */ - public AMQConnectionFactory getConnectionFactory() throws Exception - { - _logger.info("get ConnectionFactory"); - if (_connectionFactory == null) - { - if (_broker.equals(VM)) - { - _connectionFactory = getConnectionFactory("vm"); - } - else - { - _connectionFactory = getConnectionFactory("local"); - } - } - return _connectionFactory; - } - - /** - * Get a connection factory for the currently used broker - * - * @param factoryName The factory name - * @return A conection factory - * @throws Exception if there is an error getting the tactory - */ - public AMQConnectionFactory getConnectionFactory(String factoryName) throws Exception - { - return (AMQConnectionFactory) getInitialContext().lookup(factoryName); - } - - public Connection getConnection() throws Exception - { - return getConnection("guest", "guest"); - } - - /** - * Get a connection (remote or in-VM) - * - * @param username The user name - * @param password The user password - * @return a newly created connection - * @throws Exception if there is an error getting the connection - */ - public Connection getConnection(String username, String password) throws Exception - { - _logger.info("get Connection"); - Connection con = getConnectionFactory().createConnection(username, password); - //add the connection in the lis of connections - _connections.add(con); - return con; - } - - public Connection getConnection(String username, String password, String id) throws Exception - { - _logger.info("get Connection"); - Connection con; - if (_broker.equals(VM)) - { - con = new AMQConnection("vm://:1", username, password, id, "test"); - } - else - { - con = getConnectionFactory().createConnection(username, password); - } - //add the connection in the lis of connections - _connections.add(con); - return con; - } - - protected void tearDown() throws java.lang.Exception - { - // close all the connections used by this test. - if (_brokerStarted) - { - for (Connection c : _connections) - { - c.close(); - } - } - } - -} diff --git a/qpid/java/perftests/src/main/java/org/apache/qpid/test/testcases/MessageThroughputPerf.java b/qpid/java/perftests/src/main/java/org/apache/qpid/test/testcases/MessageThroughputPerf.java index 0fcb0a8538..9397db82c9 100644 --- a/qpid/java/perftests/src/main/java/org/apache/qpid/test/testcases/MessageThroughputPerf.java +++ b/qpid/java/perftests/src/main/java/org/apache/qpid/test/testcases/MessageThroughputPerf.java @@ -156,7 +156,7 @@ public class MessageThroughputPerf extends FrameworkBaseCase implements TimingCo CircuitFactory circuitFactory = getCircuitFactory(); // Create the test circuit. This projects the circuit onto the available test nodes and connects it up. - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(null, testProps); // Store the test configuration for the thread. PerThreadSetup setup = new PerThreadSetup(); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java index 1050baaca6..082f3f29bd 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java @@ -23,16 +23,14 @@ package org.apache.qpid.test.framework; import org.apache.log4j.Logger; import org.apache.log4j.NDC; -import org.apache.qpid.server.registry.ApplicationRegistry; import org.apache.qpid.test.framework.BrokerLifecycleAware; import org.apache.qpid.test.framework.sequencers.CircuitFactory; -import org.apache.qpid.client.transport.TransportConnection; -import org.apache.qpid.junit.extensions.AsymptoticTestCase; import org.apache.qpid.junit.extensions.SetupTaskAware; import org.apache.qpid.junit.extensions.SetupTaskHandler; import org.apache.qpid.junit.extensions.util.ParsedProperties; import org.apache.qpid.junit.extensions.util.TestContextProperties; +import org.apache.qpid.testutil.QpidTestCase; import java.util.ArrayList; import java.util.List; @@ -49,7 +47,7 @@ import java.util.List; * Convert failed assertions to error messages. * */ -public class FrameworkBaseCase extends AsymptoticTestCase implements FrameworkTestContext, SetupTaskAware, +public class FrameworkBaseCase extends QpidTestCase implements FrameworkTestContext, SetupTaskAware, BrokerLifecycleAware { /** Used for debugging purposes. */ @@ -194,10 +192,6 @@ public class FrameworkBaseCase extends AsymptoticTestCase implements FrameworkTe NDC.push(getName()); testProps = TestContextProperties.getInstance(MessagingTestConfigProperties.defaults); - - // Process all optional setup tasks. This may include in-vm broker creation, if a decorator has added it. - TransportConnection.createVMBroker(1); - taskHandler.runSetupTasks(); } /** @@ -208,8 +202,6 @@ public class FrameworkBaseCase extends AsymptoticTestCase implements FrameworkTe NDC.pop(); // Process all optional tear down tasks. This may include in-vm broker clean up, if a decorator has added it. - TransportConnection.killVMBroker(1); - ApplicationRegistry.remove(1); taskHandler.runTearDownTasks(); } diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java index 84dd735d0d..41766b9fae 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java @@ -81,7 +81,7 @@ public class LocalCircuitFactory implements CircuitFactory * * @return A test circuit. */ - public Circuit createCircuit(ParsedProperties testProperties) + public Circuit createCircuit(Connection connection, ParsedProperties testProperties) { Circuit result; @@ -94,9 +94,6 @@ public class LocalCircuitFactory implements CircuitFactory // Get a unique offset to append to destination names to make them unique to the connection. long uniqueId = uniqueDestsId.incrementAndGet(); - // Set up the connection. - Connection connection = TestUtils.createConnection(testProperties); - // Add the connection exception listener to assert on exception conditions with. // ExceptionMonitor exceptionMonitor = new ExceptionMonitor(); // connection.setExceptionListener(exceptionMonitor); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/CircuitFactory.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/CircuitFactory.java index fff617c583..0a48d66981 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/CircuitFactory.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/CircuitFactory.java @@ -27,6 +27,7 @@ import org.apache.qpid.util.ConversationFactory; import org.apache.qpid.junit.extensions.util.ParsedProperties; +import javax.jms.Connection; import java.util.List; import java.util.Properties; @@ -62,7 +63,7 @@ public interface CircuitFactory * * @return A test circuit. */ - public Circuit createCircuit(ParsedProperties testProperties); + public Circuit createCircuit(Connection connection, ParsedProperties testProperties); /** * Sets the sender test client to coordinate the test with. diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/FanOutCircuitFactory.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/FanOutCircuitFactory.java index d1c39ff3ff..7f8a821c69 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/FanOutCircuitFactory.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/FanOutCircuitFactory.java @@ -31,10 +31,7 @@ import org.apache.qpid.util.ConversationFactory; import org.apache.qpid.junit.extensions.util.ParsedProperties; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.Session; +import javax.jms.*; import java.util.LinkedList; import java.util.List; @@ -74,7 +71,7 @@ public class FanOutCircuitFactory extends BaseCircuitFactory * @param testProperties The test parameters. * @return A test circuit. */ - public Circuit createCircuit(ParsedProperties testProperties) + public Circuit createCircuit(Connection connection, ParsedProperties testProperties) { log.debug("public Circuit createCircuit(ParsedProperties testProperties): called"); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/InteropCircuitFactory.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/InteropCircuitFactory.java index feb87e7b9c..8604dd7800 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/InteropCircuitFactory.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/InteropCircuitFactory.java @@ -31,10 +31,7 @@ import org.apache.qpid.util.ConversationFactory; import org.apache.qpid.junit.extensions.util.ParsedProperties; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.Session; +import javax.jms.*; import java.util.LinkedList; import java.util.List; @@ -67,7 +64,7 @@ public class InteropCircuitFactory extends BaseCircuitFactory * @param testProperties The test parameters. * @return A test circuit. */ - public Circuit createCircuit(ParsedProperties testProperties) + public Circuit createCircuit(Connection connection, ParsedProperties testProperties) { log.debug("public Circuit createCircuit(ParsedProperties testProperties): called"); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/FailoverTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/FailoverTest.java index 5f41a07949..a0a8894874 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/FailoverTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/FailoverTest.java @@ -73,7 +73,7 @@ public class FailoverTest extends FrameworkBaseCase * * @throws JMSException Allowed to fall through and fail test. */ - public void testTxP2PFailover() throws JMSException + public void testTxP2PFailover() throws Exception { // Set up the test properties to match the test cases requirements. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true); @@ -84,7 +84,7 @@ public class FailoverTest extends FrameworkBaseCase // Create the test circuit from the test configuration parameters. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); // Create an assertion that all messages are received. Assertion allMessagesReceived = testCircuit.getReceiver().allMessagesReceivedAssertion(testProps); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/ImmediateMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/ImmediateMessageTest.java index 767871e25a..69aa6a52ae 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/ImmediateMessageTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/ImmediateMessageTest.java @@ -75,7 +75,7 @@ public class ImmediateMessageTest extends FrameworkBaseCase } /** Check that an immediate message is sent succesfully not using transactions when a consumer is connected. */ - public void test_QPID_517_ImmediateOkNoTxP2P() + public void test_QPID_517_ImmediateOkNoTxP2P() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false); @@ -83,13 +83,13 @@ public class ImmediateMessageTest extends FrameworkBaseCase // Run the default test sequence over the test circuit checking for no errors. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().noExceptionsAssertion(testProps)))); } /** Check that an immediate message is committed succesfully in a transaction when a consumer is connected. */ - public void test_QPID_517_ImmediateOkTxP2P() + public void test_QPID_517_ImmediateOkTxP2P() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true); @@ -97,13 +97,13 @@ public class ImmediateMessageTest extends FrameworkBaseCase // Send one message with no errors. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().noExceptionsAssertion(testProps)))); } /** Check that an immediate message results in no consumers code, not using transactions, when a consumer is disconnected. */ - public void test_QPID_517_ImmediateFailsConsumerDisconnectedNoTxP2P() + public void test_QPID_517_ImmediateFailsConsumerDisconnectedNoTxP2P() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false); @@ -113,7 +113,7 @@ public class ImmediateMessageTest extends FrameworkBaseCase testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false); CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); // Send one message and get a linked no consumers exception. assertNoFailures(testCircuit.test(1, @@ -121,7 +121,7 @@ public class ImmediateMessageTest extends FrameworkBaseCase } /** Check that an immediate message results in no consumers code, in a transaction, when a consumer is disconnected. */ - public void test_QPID_517_ImmediateFailsConsumerDisconnectedTxP2P() + public void test_QPID_517_ImmediateFailsConsumerDisconnectedTxP2P() throws Exception { // Ensure transactional sessions are on. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true); @@ -131,7 +131,7 @@ public class ImmediateMessageTest extends FrameworkBaseCase testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false); CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); // Send one message and get a linked no consumers exception. assertNoFailures(testCircuit.test(1, @@ -139,7 +139,7 @@ public class ImmediateMessageTest extends FrameworkBaseCase } /** Check that an immediate message results in no route code, not using transactions, when no outgoing route is connected. */ - public void test_QPID_517_ImmediateFailsNoRouteNoTxP2P() + public void test_QPID_517_ImmediateFailsNoRouteNoTxP2P() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false); @@ -151,14 +151,14 @@ public class ImmediateMessageTest extends FrameworkBaseCase // Send one message and get a linked no route exception. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps)))); } /** Check that an immediate message results in no route code, upon transaction commit, when no outgoing route is connected. */ - public void test_QPID_517_ImmediateFailsNoRouteTxP2P() + public void test_QPID_517_ImmediateFailsNoRouteTxP2P() throws Exception { // Ensure transactional sessions are on. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true); @@ -170,14 +170,14 @@ public class ImmediateMessageTest extends FrameworkBaseCase // Send one message and get a linked no route exception. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps)))); } /** Check that an immediate message is sent succesfully not using transactions when a consumer is connected. */ - public void test_QPID_517_ImmediateOkNoTxPubSub() + public void test_QPID_517_ImmediateOkNoTxPubSub() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false); @@ -185,14 +185,14 @@ public class ImmediateMessageTest extends FrameworkBaseCase // Send one message with no errors. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps)))); } /** Check that an immediate message is committed succesfully in a transaction when a consumer is connected. */ - public void test_QPID_517_ImmediateOkTxPubSub() + public void test_QPID_517_ImmediateOkTxPubSub() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true); @@ -200,14 +200,14 @@ public class ImmediateMessageTest extends FrameworkBaseCase // Send one message with no errors. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps)))); } /** Check that an immediate message results in no consumers code, not using transactions, when a consumer is disconnected. */ - public void test_QPID_517_ImmediateFailsConsumerDisconnectedNoTxPubSub() + public void test_QPID_517_ImmediateFailsConsumerDisconnectedNoTxPubSub() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false); @@ -220,7 +220,7 @@ public class ImmediateMessageTest extends FrameworkBaseCase testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false); CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); // Send one message and get a linked no consumers exception. assertNoFailures(testCircuit.test(1, @@ -228,7 +228,7 @@ public class ImmediateMessageTest extends FrameworkBaseCase } /** Check that an immediate message results in no consumers code, in a transaction, when a consumer is disconnected. */ - public void test_QPID_517_ImmediateFailsConsumerDisconnectedTxPubSub() + public void test_QPID_517_ImmediateFailsConsumerDisconnectedTxPubSub() throws Exception { // Ensure transactional sessions are on. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true); @@ -241,7 +241,7 @@ public class ImmediateMessageTest extends FrameworkBaseCase testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false); CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); // Send one message and get a linked no consumers exception. assertNoFailures(testCircuit.test(1, @@ -249,7 +249,7 @@ public class ImmediateMessageTest extends FrameworkBaseCase } /** Check that an immediate message results in no route code, not using transactions, when no outgoing route is connected. */ - public void test_QPID_517_ImmediateFailsNoRouteNoTxPubSub() + public void test_QPID_517_ImmediateFailsNoRouteNoTxPubSub() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false); @@ -261,14 +261,14 @@ public class ImmediateMessageTest extends FrameworkBaseCase // Send one message and get a linked no route exception. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps)))); } /** Check that an immediate message results in no route code, upon transaction commit, when no outgoing route is connected. */ - public void test_QPID_517_ImmediateFailsNoRouteTxPubSub() + public void test_QPID_517_ImmediateFailsNoRouteTxPubSub() throws Exception { // Ensure transactional sessions are on. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true); @@ -280,7 +280,7 @@ public class ImmediateMessageTest extends FrameworkBaseCase // Send one message and get a linked no route exception. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps)))); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/MandatoryMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/MandatoryMessageTest.java index d46a866b93..b4c4eb91b4 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/MandatoryMessageTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/MandatoryMessageTest.java @@ -79,7 +79,7 @@ public class MandatoryMessageTest extends FrameworkBaseCase } /** Check that an mandatory message is sent succesfully not using transactions when a consumer is connected. */ - public void test_QPID_508_MandatoryOkNoTxP2P() + public void test_QPID_508_MandatoryOkNoTxP2P() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false); @@ -87,14 +87,14 @@ public class MandatoryMessageTest extends FrameworkBaseCase // Run the default test sequence over the test circuit checking for no errors. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps)))); } /** Check that an mandatory message is committed succesfully in a transaction when a consumer is connected. */ - public void test_QPID_508_MandatoryOkTxP2P() + public void test_QPID_508_MandatoryOkTxP2P() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true); @@ -102,7 +102,7 @@ public class MandatoryMessageTest extends FrameworkBaseCase // Run the default test sequence over the test circuit checking for no errors. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps)))); @@ -112,7 +112,7 @@ public class MandatoryMessageTest extends FrameworkBaseCase * Check that a mandatory message is sent succesfully, not using transactions, when a consumer is disconnected but * the route exists. */ - public void test_QPID_517_MandatoryOkConsumerDisconnectedNoTxP2P() + public void test_QPID_517_MandatoryOkConsumerDisconnectedNoTxP2P() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false); @@ -122,7 +122,7 @@ public class MandatoryMessageTest extends FrameworkBaseCase testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false); CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); // Send one message with no errors. assertNoFailures(testCircuit.test(1, @@ -133,7 +133,7 @@ public class MandatoryMessageTest extends FrameworkBaseCase * Check that a mandatory message is sent succesfully, in a transaction, when a consumer is disconnected but * the route exists. */ - public void test_QPID_517_MandatoryOkConsumerDisconnectedTxP2P() + public void test_QPID_517_MandatoryOkConsumerDisconnectedTxP2P() throws Exception { // Ensure transactional sessions are on. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true); @@ -143,7 +143,7 @@ public class MandatoryMessageTest extends FrameworkBaseCase testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false); CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); // Send one message with no errors. assertNoFailures(testCircuit.test(1, @@ -151,7 +151,7 @@ public class MandatoryMessageTest extends FrameworkBaseCase } /** Check that an mandatory message results in no route code, not using transactions, when no consumer is connected. */ - public void test_QPID_508_MandatoryFailsNoRouteNoTxP2P() + public void test_QPID_508_MandatoryFailsNoRouteNoTxP2P() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false); @@ -163,14 +163,14 @@ public class MandatoryMessageTest extends FrameworkBaseCase // Send one message and get a linked no route exception. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps)))); } /** Check that an mandatory message results in no route code, upon transaction commit, when a consumer is connected. */ - public void test_QPID_508_MandatoryFailsNoRouteTxP2P() + public void test_QPID_508_MandatoryFailsNoRouteTxP2P() throws Exception { // Ensure transactional sessions are on. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true); @@ -182,14 +182,14 @@ public class MandatoryMessageTest extends FrameworkBaseCase // Send one message and get a linked no route exception. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps)))); } /** Check that an mandatory message is sent succesfully not using transactions when a consumer is connected. */ - public void test_QPID_508_MandatoryOkNoTxPubSub() + public void test_QPID_508_MandatoryOkNoTxPubSub() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false); @@ -197,14 +197,14 @@ public class MandatoryMessageTest extends FrameworkBaseCase // Run the default test sequence over the test circuit checking for no errors. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps)))); } /** Check that an mandatory message is committed succesfully in a transaction when a consumer is connected. */ - public void test_QPID_508_MandatoryOkTxPubSub() + public void test_QPID_508_MandatoryOkTxPubSub() throws Exception { // Ensure transactional sessions are on. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true); @@ -212,7 +212,7 @@ public class MandatoryMessageTest extends FrameworkBaseCase // Run the default test sequence over the test circuit checking for no errors. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps)))); @@ -222,7 +222,7 @@ public class MandatoryMessageTest extends FrameworkBaseCase * Check that a mandatory message is sent succesfully, not using transactions, when a consumer is disconnected but * the route exists. */ - public void test_QPID_517_MandatoryOkConsumerDisconnectedNoTxPubSub() + public void test_QPID_517_MandatoryOkConsumerDisconnectedNoTxPubSub() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false); @@ -235,7 +235,7 @@ public class MandatoryMessageTest extends FrameworkBaseCase testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false); CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); // Send one message with no errors. assertNoFailures(testCircuit.test(1, @@ -246,7 +246,7 @@ public class MandatoryMessageTest extends FrameworkBaseCase * Check that a mandatory message is sent succesfully, in a transaction, when a consumer is disconnected but * the route exists. */ - public void test_QPID_517_MandatoryOkConsumerDisconnectedTxPubSub() + public void test_QPID_517_MandatoryOkConsumerDisconnectedTxPubSub() throws Exception { // Ensure transactional sessions are on. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true); @@ -259,7 +259,7 @@ public class MandatoryMessageTest extends FrameworkBaseCase testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false); CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); // Send one message with no errors. assertNoFailures(testCircuit.test(1, @@ -267,7 +267,7 @@ public class MandatoryMessageTest extends FrameworkBaseCase } /** Check that an mandatory message results in no route code, not using transactions, when no consumer is connected. */ - public void test_QPID_508_MandatoryFailsNoRouteNoTxPubSub() + public void test_QPID_508_MandatoryFailsNoRouteNoTxPubSub() throws Exception { // Ensure transactional sessions are off. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false); @@ -279,14 +279,14 @@ public class MandatoryMessageTest extends FrameworkBaseCase // Send one message and get a linked no route exception. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps)))); } /** Check that an mandatory message results in no route code, upon transaction commit, when a consumer is connected. */ - public void test_QPID_508_MandatoryFailsNoRouteTxPubSub() + public void test_QPID_508_MandatoryFailsNoRouteTxPubSub() throws Exception { // Ensure transactional sessions are on. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true); @@ -298,7 +298,7 @@ public class MandatoryMessageTest extends FrameworkBaseCase // Send one message and get a linked no route exception. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps)))); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/RollbackTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/RollbackTest.java index c1a484b2aa..5c8012e700 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/RollbackTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/RollbackTest.java @@ -55,7 +55,7 @@ public class RollbackTest extends FrameworkBaseCase } /** Check messages sent but rolled back are never received. */ - public void testRolledbackMessageNotDelivered() + public void testRolledbackMessageNotDelivered() throws Exception { // Ensure transactional sessions are on. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true); @@ -63,7 +63,7 @@ public class RollbackTest extends FrameworkBaseCase // Run the default test sequence over the test circuit checking for no errors. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().noExceptionsAssertion(testProps), @@ -71,7 +71,7 @@ public class RollbackTest extends FrameworkBaseCase } /** Check messages received but rolled back are redelivered on subsequent receives. */ - public void testRolledbackMessagesSubsequentlyReceived() + public void testRolledbackMessagesSubsequentlyReceived() throws Exception { // Ensure transactional sessions are on. testProps.setProperty(TRANSACTED_RECEIVER_PROPNAME, true); @@ -79,7 +79,7 @@ public class RollbackTest extends FrameworkBaseCase // Run the default test sequence over the test circuit checking for no errors. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().noExceptionsAssertion(testProps), @@ -87,7 +87,7 @@ public class RollbackTest extends FrameworkBaseCase } /** Attempting to rollback outside of a transaction results in an IllegalStateException. */ - public void testRollbackUnavailableOutsideTransactionPublisher() + public void testRollbackUnavailableOutsideTransactionPublisher() throws Exception { // Ensure transactional sessions are on. testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false); @@ -95,13 +95,13 @@ public class RollbackTest extends FrameworkBaseCase // Run the default test sequence over the test circuit checking for no errors. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().channelClosedAssertion(testProps)))); } /** Attempting to rollback outside of a transaction results in an IllegalStateException. */ - public void testRollbackUnavailableOutsideTransactionReceiver() + public void testRollbackUnavailableOutsideTransactionReceiver() throws Exception { // Ensure transactional sessions are on. testProps.setProperty(TRANSACTED_RECEIVER_PROPNAME, false); @@ -109,7 +109,7 @@ public class RollbackTest extends FrameworkBaseCase // Run the default test sequence over the test circuit checking for no errors. CircuitFactory circuitFactory = getCircuitFactory(); - Circuit testCircuit = circuitFactory.createCircuit(testProps); + Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps); assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getReceiver().channelClosedAssertion(testProps)))); } -- cgit v1.2.1