summaryrefslogtreecommitdiff
path: root/java/systests/src
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2009-04-16 12:29:53 +0000
committerMartin Ritchie <ritchiem@apache.org>2009-04-16 12:29:53 +0000
commit9fa47e13bc96a3a3ff3dd109eb416655062273b5 (patch)
tree95912f217c9438bf4da56fd5d3b358bace9e0e0f /java/systests/src
parente15bd730236df53aeafe1c61a8beb5aa9814c5f9 (diff)
downloadqpid-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
Diffstat (limited to 'java/systests/src')
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java31
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java28
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java40
3 files changed, 72 insertions, 27 deletions
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;
+ }
+
}