diff options
Diffstat (limited to 'java')
8 files changed, 202 insertions, 46 deletions
diff --git a/java/broker/etc/config-systests.xml b/java/broker/etc/config-systests.xml new file mode 100644 index 0000000000..03543642cc --- /dev/null +++ b/java/broker/etc/config-systests.xml @@ -0,0 +1,138 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + - + - 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. + - + --> +<broker> + <prefix>${QPID_HOME}</prefix> + <work>${QPID_WORK}</work> + <conf>${prefix}/etc</conf> + <connector> + <!-- Uncomment out this block and edit the keystorePath and keystorePassword + to enable SSL support + <ssl> + <enabled>true</enabled> + <sslOnly>true</sslOnly> + <keystorePath>/path/to/keystore.ks</keystorePath> + <keystorePassword>keystorepass</keystorePassword> + </ssl>--> + <qpidnio>false</qpidnio> + <protectio> + <enabled>false</enabled> + </protectio> + <transport>nio</transport> + <port>5672</port> + <sslport>8672</sslport> + <socketReceiveBuffer>32768</socketReceiveBuffer> + <socketSendBuffer>32768</socketSendBuffer> + </connector> + <management> + <enabled>false</enabled> + <jmxport>8999</jmxport> + <ssl> + <enabled>false</enabled> + <!-- Update below path to your keystore location, eg ${conf}/qpid.keystore --> + <keyStorePath>${prefix}/../test_resources/ssl/keystore.jks</keyStorePath> + <keyStorePassword>password</keyStorePassword> + </ssl> + </management> + <advanced> + <filterchain enableExecutorPool="true"/> + <enablePooledAllocator>false</enablePooledAllocator> + <enableDirectBuffers>false</enableDirectBuffers> + <framesize>65535</framesize> + <compressBufferOnQueue>false</compressBufferOnQueue> + <enableJMSXUserID>false</enableJMSXUserID> + </advanced> + + <security> + <principal-databases> + <!-- Example use of Base64 encoded MD5 hashes for authentication via CRAM-MD5-Hashed --> + <principal-database> + <name>passwordfile</name> + <class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase</class> + <attributes> + <attribute> + <name>passwordFile</name> + <value>${conf}/passwd</value> + </attribute> + </attributes> + </principal-database> + </principal-databases> + + <access> + <class>org.apache.qpid.server.security.access.plugins.AllowAll</class> + </access> + + <msg-auth>false</msg-auth> + + <jmx> + <access>${conf}/jmxremote.access</access> + <principal-database>passwordfile</principal-database> + </jmx> + </security> + + <virtualhosts> + <directory>${conf}/virtualhosts</directory> + + <virtualhost> + <name>localhost</name> + <localhost> + <store> + <class>org.apache.qpid.server.store.MemoryMessageStore</class> + </store> + + <housekeeping> + <expiredMessageCheckPeriod>20000</expiredMessageCheckPeriod> + </housekeeping> + + </localhost> + </virtualhost> + + <virtualhost> + <name>development</name> + <development> + <store> + <class>org.apache.qpid.server.store.MemoryMessageStore</class> + </store> + </development> + </virtualhost> + + <virtualhost> + <name>test</name> + <test> + <store> + <class>org.apache.qpid.server.store.MemoryMessageStore</class> + </store> + </test> + </virtualhost> + + </virtualhosts> + <heartbeat> + <delay>0</delay> + <timeoutFactor>2.0</timeoutFactor> + </heartbeat> + <queue> + <auto_register>true</auto_register> + </queue> + + <virtualhosts>${conf}/virtualhosts.xml</virtualhosts> +</broker> + + diff --git a/java/module.xml b/java/module.xml index 3bf0f13cc8..4a613b32f8 100644 --- a/java/module.xml +++ b/java/module.xml @@ -251,6 +251,7 @@ <sysproperty key="example.plugin.target" value="${project.root}/build/lib/plugins"/> <sysproperty key="QPID_EXAMPLE_HOME" value="${project.root}/build"/> <sysproperty key="QPID_HOME" value="${project.root}/build"/> + <sysproperty key="QPID_WORK" value="${project.root}/build/work"/> <formatter type="plain"/> <formatter type="xml"/> diff --git a/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java b/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java index 4c123b7a5f..b13170efc9 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java +++ b/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java @@ -46,9 +46,6 @@ public class SyncWaitDelayTest extends QpidTestCase { protected static final Logger _logger = LoggerFactory.getLogger(SyncWaitDelayTest.class); - final String QpidHome = System.getProperty("QPID_HOME"); - final File _configFile = new File(QpidHome, "etc/config.xml"); - private String VIRTUALHOST = "test"; protected long POST_COMMIT_DELAY = 1000L; protected long SYNC_WRITE_TIMEOUT = POST_COMMIT_DELAY + 1000; @@ -77,9 +74,9 @@ public class SyncWaitDelayTest extends QpidTestCase tmpFile.deleteOnExit(); configuration.save(tmpFile); - ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(tmpFile); - - startBroker(1, reg); + _configFile = tmpFile; + + startBroker(1); //Set the syncWrite timeout to be just larger than the delay on the commitTran. setSystemProperty("amqj.default_syncwrite_timeout", String.valueOf(SYNC_WRITE_TIMEOUT)); diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java b/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java index eb51a32166..5a76ff251b 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java +++ b/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java @@ -189,6 +189,7 @@ public class FrameworkBaseCase extends QpidTestCase implements FrameworkTestCont */ protected void setUp() throws Exception { + super.setUp(); NDC.push(getName()); testProps = TestContextProperties.getInstance(MessagingTestConfigProperties.defaults); diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java index 21eaad6d5b..89316b6511 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java +++ b/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java @@ -35,18 +35,6 @@ public class CloseTest extends QpidTestCase { private static final Logger _logger = LoggerFactory.getLogger(CloseTest.class); - private static final String BROKER = "vm://:1"; - - protected void setUp() throws Exception - { - super.setUp(); - } - - protected void tearDown() throws Exception - { - super.setUp(); - } - public void testCloseQueueReceiver() throws Exception { AMQConnection connection = (AMQConnection) getConnection("guest", "guest"); @@ -62,7 +50,7 @@ public class CloseTest extends QpidTestCase _logger.info("About to close consumer"); - consumer.close(); + consumer.close(); _logger.info("Closed Consumer"); connection.close(); diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java index 5147d4a94d..397fc15b66 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java +++ b/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java @@ -30,9 +30,12 @@ import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQQueue; import org.apache.qpid.client.AMQSession; import org.apache.qpid.client.AMQTopic; +import org.apache.qpid.client.AMQConnectionURL; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.jms.Session; +import org.apache.qpid.jms.ConnectionURL; +import org.apache.qpid.jms.BrokerDetails; import javax.jms.Connection; import javax.jms.QueueSession; @@ -45,13 +48,13 @@ public class ConnectionTest extends QpidTestCase String _broker_NotRunning = "vm://:2"; String _broker_BadDNS = "tcp://hg3sgaaw4lgihjs"; - public String getBroker() + public BrokerDetails getBroker() { try { if (getConnectionFactory().getConnectionURL().getBrokerCount() > 0) { - return getConnectionFactory().getConnectionURL().getBrokerDetails(0).toString(); + return getConnectionFactory().getConnectionURL().getBrokerDetails(0); } else { @@ -72,7 +75,7 @@ public class ConnectionTest extends QpidTestCase AMQConnection conn = null; try { - conn = new AMQConnection(getBroker(), "guest", "guest", "fred", "test"); + conn = new AMQConnection(getBroker().toString(), "guest", "guest", "fred", "test"); } catch (Exception e) { @@ -89,13 +92,18 @@ public class ConnectionTest extends QpidTestCase AMQConnection conn = null; try { - conn = new AMQConnection("amqp://guest:guest@clientid/test?brokerlist='" - + getBroker() - + "?retries='1''&defaultQueueExchange='test.direct'" + BrokerDetails broker = getBroker(); + broker.setProperty("retries","1"); + ConnectionURL url = new AMQConnectionURL("amqp://guest:guest@clientid/test?brokerlist='" + + broker + + "'&defaultQueueExchange='test.direct'" + "&defaultTopicExchange='test.topic'" + "&temporaryQueueExchange='tmp.direct'" + "&temporaryTopicExchange='tmp.topic'"); + System.err.println(url.toString()); + conn = new AMQConnection(url, null); + AMQSession sess = (AMQSession) conn.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -151,7 +159,9 @@ public class ConnectionTest extends QpidTestCase AMQConnection conn = null; try { - conn = new AMQConnection("amqp://guest:rubbishpassword@clientid/test?brokerlist='" + getBroker() + "?retries='0''"); + BrokerDetails broker = getBroker(); + broker.setProperty("retries", "0"); + conn = new AMQConnection("amqp://guest:rubbishpassword@clientid/test?brokerlist='" + broker + "'"); fail("Connection should not be established password is wrong."); } catch (AMQConnectionFailureException amqe) @@ -223,7 +233,9 @@ public class ConnectionTest extends QpidTestCase AMQConnection conn = null; try { - conn = new AMQConnection("amqp://guest:guest@clientid/rubbishhost?brokerlist='" + getBroker() + "?retries='0''"); + BrokerDetails broker = getBroker(); + broker.setProperty("retries", "0"); + conn = new AMQConnection("amqp://guest:guest@clientid/rubbishhost?brokerlist='" + broker + "'"); fail("Connection should not be established"); } catch (AMQException amqe) @@ -244,7 +256,7 @@ public class ConnectionTest extends QpidTestCase public void testClientIdCannotBeChanged() throws Exception { - Connection connection = new AMQConnection(getBroker(), "guest", "guest", + Connection connection = new AMQConnection(getBroker().toString(), "guest", "guest", "fred", "test"); try { @@ -266,7 +278,7 @@ public class ConnectionTest extends QpidTestCase public void testClientIdIsPopulatedAutomatically() throws Exception { - Connection connection = new AMQConnection(getBroker(), "guest", "guest", + Connection connection = new AMQConnection(getBroker().toString(), "guest", "guest", null, "test"); try { diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java index c6a953dbc2..cbe25e4f32 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java +++ b/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java @@ -51,16 +51,6 @@ public class DurableSubscriptionTest extends QpidTestCase { private static final Logger _logger = LoggerFactory.getLogger(DurableSubscriptionTest.class); - protected void setUp() throws Exception - { - super.setUp(); - } - - protected void tearDown() throws Exception - { - super.tearDown(); - } - public void testUnsubscribe() throws Exception { AMQConnection con = (AMQConnection) getConnection("guest", "guest"); diff --git a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java b/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java index 00c1da69e9..d75b6276ac 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java +++ b/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java @@ -21,6 +21,10 @@ import junit.framework.TestCase; import junit.framework.TestResult; import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.Session; +import javax.jms.MessageProducer; +import javax.jms.Message; import javax.naming.InitialContext; import javax.naming.NamingException; import java.io.*; @@ -47,6 +51,8 @@ import org.slf4j.LoggerFactory; */ public class QpidTestCase extends TestCase { + protected final String QpidHome = System.getProperty("QPID_HOME"); + protected File _configFile = new File(QpidHome, "etc/config-systests.xml"); private static final Logger _logger = LoggerFactory.getLogger(QpidTestCase.class); @@ -182,7 +188,6 @@ public class QpidTestCase extends TestCase } _logger.info("========== start " + _testName + " =========="); - startBroker(); try { super.runBare(); @@ -209,6 +214,17 @@ public class QpidTestCase extends TestCase } } + @Override + protected void setUp() throws Exception + { + if (!_configFile.exists()) + { + fail("Unable to test without config file:" + _configFile); + } + + startBroker(); + } + public void run(TestResult testResult) { if (_exclusionList != null && (_exclusionList.contains(getClass().getName() + "#*") || @@ -294,12 +310,6 @@ public class QpidTestCase extends TestCase } } - public void startBroker(int port, ApplicationRegistry config) throws Exception - { - ApplicationRegistry.initialise(config, port); - startBroker(port); - } - public void startBroker() throws Exception { startBroker(0); @@ -336,6 +346,7 @@ public class QpidTestCase extends TestCase if (_broker.equals(VM)) { // create an in_VM broker + ApplicationRegistry.initialise(new ConfigurationFileApplicationRegistry(_configFile), port); TransportConnection.createVMBroker(port); } else if (!_broker.equals(EXTERNAL)) @@ -605,4 +616,22 @@ public class QpidTestCase extends TestCase revertSystemProperties(); } + public List<Message> sendMessage(Session session, Destination destination, + int count) throws Exception + { + List<Message> messages = new ArrayList<Message>(count); + + MessageProducer producer = session.createProducer(destination); + + for (int i = 0; i < count; i++) + { + Message next = session.createMessage(); + + producer.send(next); + + messages.add(next); + } + return messages; + } + } |
