diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2009-04-16 12:29:53 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2009-04-16 12:29:53 +0000 |
| commit | 9fa47e13bc96a3a3ff3dd109eb416655062273b5 (patch) | |
| tree | 95912f217c9438bf4da56fd5d3b358bace9e0e0f | |
| parent | e15bd730236df53aeafe1c61a8beb5aa9814c5f9 (diff) | |
| download | qpid-python-9fa47e13bc96a3a3ff3dd109eb416655062273b5.tar.gz | |
QPID-1813/QPID-1817 : Removed the new properties from the test-provider as this will affect all tests. The NoLocalAfterRecoveryTest now updates a ConnectionURL based on the JNDI data and uses that to start a connection. NLART also provides a default location for the derbyDB store as the DMS class does not correctly attempt to put the store in QPID_WORK. This will be re-addressed when ServerConfiguration is again available from a VHC object. ConnectionTest was updated to remove the literal values for the BrokerDetail options.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@765608 13f79535-47bb-0310-9956-ffa450edef68
5 files changed, 76 insertions, 33 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java b/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java index 20ef80e00e..9695571371 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java +++ b/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java @@ -67,7 +67,7 @@ public class DerbyMessageStore implements MessageStore private static final Logger _logger = Logger.getLogger(DerbyMessageStore.class); - private static final String ENVIRONMENT_PATH_PROPERTY = "environment-path"; + public static final String ENVIRONMENT_PATH_PROPERTY = "environment-path"; private static final String SQL_DRIVER_NAME = "org.apache.derby.jdbc.EmbeddedDriver"; @@ -155,7 +155,7 @@ public class DerbyMessageStore implements MessageStore QueueRegistry queueRegistry = virtualHost.getQueueRegistry(); //Update to pick up QPID_WORK and use that as the default location not just derbyDB - final String databasePath = config.getStoreConfiguration().getString(base + "." + ENVIRONMENT_PATH_PROPERTY, "derbyDB"); + final String databasePath = config.getStoreConfiguration().getString(ENVIRONMENT_PATH_PROPERTY, "derbyDB"); File environmentPath = new File(databasePath); if (!environmentPath.exists()) diff --git a/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java b/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java index 735913146c..dc34915a91 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java @@ -24,8 +24,11 @@ import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQSession; import org.apache.qpid.jms.ConnectionListener; +import org.apache.qpid.jms.BrokerDetails; +import org.apache.qpid.jms.ConnectionURL; import org.apache.qpid.server.registry.ApplicationRegistry; import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry; +import org.apache.qpid.server.store.DerbyMessageStore; import org.apache.commons.configuration.XMLConfiguration; import javax.jms.Connection; @@ -55,25 +58,49 @@ public class NoLocalAfterRecoveryTest extends QpidTestCase implements Connection protected static final int SEND_COUNT = 10; private CountDownLatch _failoverComplete = new CountDownLatch(1); + protected ConnectionURL _connectionURL; + @Override protected void setUp() throws Exception { + XMLConfiguration configuration = new XMLConfiguration(_configFile); configuration.setProperty("virtualhosts.virtualhost.test.store.class", "org.apache.qpid.server.store.DerbyMessageStore"); + configuration.setProperty("virtualhosts.virtualhost.test.store."+ DerbyMessageStore.ENVIRONMENT_PATH_PROPERTY, + System.getProperty("QPID_WORK", System.getProperty("java.io.tmpdir")) + File.separator + "derbyDB-NoLocalAfterRecoveryTest"); File tmpFile = File.createTempFile("configFile", "test"); tmpFile.deleteOnExit(); configuration.save(tmpFile); _configFile = tmpFile; + _connectionURL = getConnectionURL(); + + BrokerDetails details = _connectionURL.getBrokerDetails(0); + + // Due to the problem with SingleServer delaying on all connection + // attempts. So using a high retry value. + if (_broker.equals(VM)) + { + // Local testing suggests InVM restart takes under a second + details.setProperty(BrokerDetails.OPTIONS_RETRY, "5"); + details.setProperty(BrokerDetails.OPTIONS_CONNECT_DELAY, "200"); + } + else + { + // This will attempt to failover for 3 seconds. + // Local testing suggests failover takes 2 seconds + details.setProperty(BrokerDetails.OPTIONS_RETRY, "10"); + details.setProperty(BrokerDetails.OPTIONS_CONNECT_DELAY, "500"); + } + super.setUp(); } public void test() throws Exception { - - Connection connection = getConnection(); + Connection connection = getConnection(_connectionURL); Session session = connection.createSession(true, Session.SESSION_TRANSACTED); Topic topic = (Topic) getInitialContext().lookup("topic"); 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 397fc15b66..a892b3baad 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 @@ -48,28 +48,6 @@ public class ConnectionTest extends QpidTestCase String _broker_NotRunning = "vm://:2"; String _broker_BadDNS = "tcp://hg3sgaaw4lgihjs"; - public BrokerDetails getBroker() - { - try - { - if (getConnectionFactory().getConnectionURL().getBrokerCount() > 0) - { - return getConnectionFactory().getConnectionURL().getBrokerDetails(0); - } - else - { - fail("No broker details are available."); - } - } - catch (NamingException e) - { - fail(e.getMessage()); - } - - //keep compiler happy - return null; - } - public void testSimpleConnection() throws Exception { AMQConnection conn = null; @@ -93,7 +71,7 @@ public class ConnectionTest extends QpidTestCase try { BrokerDetails broker = getBroker(); - broker.setProperty("retries","1"); + broker.setProperty(BrokerDetails.OPTIONS_RETRY, "1"); ConnectionURL url = new AMQConnectionURL("amqp://guest:guest@clientid/test?brokerlist='" + broker + "'&defaultQueueExchange='test.direct'" @@ -160,7 +138,7 @@ public class ConnectionTest extends QpidTestCase try { BrokerDetails broker = getBroker(); - broker.setProperty("retries", "0"); + broker.setProperty(BrokerDetails.OPTIONS_RETRY, "0"); conn = new AMQConnection("amqp://guest:rubbishpassword@clientid/test?brokerlist='" + broker + "'"); fail("Connection should not be established password is wrong."); } @@ -234,7 +212,7 @@ public class ConnectionTest extends QpidTestCase try { BrokerDetails broker = getBroker(); - broker.setProperty("retries", "0"); + broker.setProperty(BrokerDetails.OPTIONS_RETRY, "0"); conn = new AMQConnection("amqp://guest:guest@clientid/rubbishhost?brokerlist='" + broker + "'"); fail("Connection should not be established"); } 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 9fc5a54079..fef3f547d3 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 @@ -25,6 +25,7 @@ import javax.jms.Destination; import javax.jms.Session; import javax.jms.MessageProducer; import javax.jms.Message; +import javax.jms.JMSException; import javax.naming.InitialContext; import javax.naming.NamingException; import java.io.*; @@ -42,6 +43,8 @@ import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQConnectionFactory; import org.apache.qpid.server.registry.ApplicationRegistry; import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry; +import org.apache.qpid.jms.BrokerDetails; +import org.apache.qpid.jms.ConnectionURL; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -584,6 +587,15 @@ public class QpidTestCase extends TestCase return getConnection("guest", "guest"); } + public Connection getConnection(ConnectionURL url) throws JMSException + { + Connection connection = new AMQConnectionFactory(url).createConnection("guest", "guest"); + + _connections.add(connection); + + return connection; + } + /** * Get a connection (remote or in-VM) * @@ -649,4 +661,32 @@ public class QpidTestCase extends TestCase return messages; } + public ConnectionURL getConnectionURL() throws NamingException + { + return getConnectionFactory().getConnectionURL(); + } + + + public BrokerDetails getBroker() + { + try + { + if (getConnectionFactory().getConnectionURL().getBrokerCount() > 0) + { + return getConnectionFactory().getConnectionURL().getBrokerDetails(0); + } + else + { + fail("No broker details are available."); + } + } + catch (NamingException e) + { + fail(e.getMessage()); + } + + //keep compiler happy + return null; + } + } diff --git a/java/test-provider.properties b/java/test-provider.properties index 352a26cbd1..bcbe4866f3 100644 --- a/java/test-provider.properties +++ b/java/test-provider.properties @@ -19,10 +19,8 @@ # # -# Allow the client to reconnect to the broker if the connection is lost, for up to 1second. -# This will allow for persistent tests to bounce the broker. -connectionfactory.default = amqp://username:password@clientid/test?brokerlist='tcp://localhost:5672?retries='5'&connectdelay='200'' -connectionfactory.default.vm = amqp://username:password@clientid/test?brokerlist='vm://:1?retries='5'&connectdelay='200'' +connectionfactory.default = amqp://username:password@clientid/test?brokerlist='tcp://localhost:5672' +connectionfactory.default.vm = amqp://username:password@clientid/test?brokerlist='vm://:1' connectionfactory.ssl = amqp://username:password@clientid/test?brokerlist='tcp://localhost:5671?ssl='true'' connectionfactory.failover = amqp://username:password@clientid/test?brokerlist='tcp://localhost:5673;tcp://localhost:5672'&sync_ack='true'&sync_publish='all'&failover='roundrobin?cyclecount='20'' |
