diff options
Diffstat (limited to 'java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java')
-rw-r--r-- | java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java | 101 |
1 files changed, 24 insertions, 77 deletions
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 f18f365f20..04fc611cd1 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 @@ -20,31 +20,32 @@ */ package org.apache.qpid.test.unit.client.connection; -import javax.jms.Connection; -import javax.jms.QueueSession; -import javax.jms.TopicSession; - import org.apache.qpid.AMQConnectionFailureException; import org.apache.qpid.AMQException; import org.apache.qpid.AMQUnresolvedAddressException; +import org.apache.qpid.server.exchange.Exchange; +import org.apache.qpid.test.utils.QpidBrokerTestCase; +import org.apache.qpid.client.AMQAuthenticationException; import org.apache.qpid.client.AMQConnection; -import org.apache.qpid.client.AMQConnectionURL; import org.apache.qpid.client.AMQQueue; import org.apache.qpid.client.AMQSession; import org.apache.qpid.client.AMQTopic; -import org.apache.qpid.configuration.ClientProperties; +import org.apache.qpid.client.AMQConnectionURL; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.framing.AMQShortString; -import org.apache.qpid.jms.BrokerDetails; -import org.apache.qpid.jms.ConnectionURL; import org.apache.qpid.jms.Session; -import org.apache.qpid.test.utils.QpidBrokerTestCase; +import org.apache.qpid.jms.ConnectionURL; +import org.apache.qpid.jms.BrokerDetails; + +import javax.jms.Connection; +import javax.jms.QueueSession; +import javax.jms.TopicSession; +import javax.naming.NamingException; public class ConnectionTest extends QpidBrokerTestCase { - String _broker_NotRunning = "tcp://localhost:" + findFreePort(); - + String _broker_NotRunning = "vm://:2"; String _broker_BadDNS = "tcp://hg3sgaaw4lgihjs"; public void testSimpleConnection() throws Exception @@ -82,21 +83,21 @@ public class ConnectionTest extends QpidBrokerTestCase + "&temporaryTopicExchange='tmp.topic'"); System.err.println(url.toString()); - conn = new AMQConnection(url); + conn = new AMQConnection(url, null); AMQSession sess = (AMQSession) conn.createSession(false, Session.AUTO_ACKNOWLEDGE); - - sess.declareExchange(new AMQShortString("test.direct"), + + sess.declareExchange(new AMQShortString("test.direct"), ExchangeDefaults.DIRECT_EXCHANGE_CLASS, false); - sess.declareExchange(new AMQShortString("tmp.direct"), + sess.declareExchange(new AMQShortString("tmp.direct"), ExchangeDefaults.DIRECT_EXCHANGE_CLASS, false); - sess.declareExchange(new AMQShortString("tmp.topic"), + sess.declareExchange(new AMQShortString("tmp.topic"), ExchangeDefaults.TOPIC_EXCHANGE_CLASS, false); - sess.declareExchange(new AMQShortString("test.topic"), + sess.declareExchange(new AMQShortString("test.topic"), ExchangeDefaults.TOPIC_EXCHANGE_CLASS, false); QueueSession queueSession = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); @@ -112,7 +113,7 @@ public class ConnectionTest extends QpidBrokerTestCase queueSession.close(); TopicSession topicSession = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); - + AMQTopic topic = (AMQTopic) topicSession.createTopic("silly.topic"); assertEquals(topic.getExchangeName().toString(), "test.topic"); @@ -270,7 +271,7 @@ public class ConnectionTest extends QpidBrokerTestCase } connection.close(); } - + public void testUnsupportedSASLMechanism() throws Exception { BrokerDetails broker = getBroker(); @@ -286,64 +287,10 @@ public class ConnectionTest extends QpidBrokerTestCase } catch (Exception e) { - assertTrue("Unexpected exception message : " + e.getMessage(), - e.getMessage().contains("Client and broker have no SASL mechanisms in common.")); - assertTrue("Unexpected exception message : " + e.getMessage(), - e.getMessage().contains("Client restricted itself to : MY_MECH")); - - } - } - - /** - * Tests that when the same user connects twice with same clientid, the second connection - * fails if the clientid verification feature is enabled (which uses a dummy 0-10 Session - * with the clientid as its name to detect the previous usage of the clientid by the user) - */ - public void testClientIDVerificationForSameUser() throws Exception - { - setTestSystemProperty(ClientProperties.QPID_VERIFY_CLIENT_ID, "true"); - - BrokerDetails broker = getBroker(); - try - { - Connection con = new AMQConnection(broker.toString(), "guest", "guest", - "client_id", "test"); - - Connection con2 = new AMQConnection(broker.toString(), "guest", "guest", - "client_id", "test"); - - fail("The client should throw a ConnectionException stating the" + - " client ID is not unique"); - } - catch (Exception e) - { - assertTrue("Incorrect exception thrown: " + e.getMessage(), - e.getMessage().contains("ClientID must be unique")); - } - } - - /** - * Tests that when different users connects with same clientid, the second connection - * succeeds even though the clientid verification feature is enabled (which uses a dummy - * 0-10 Session with the clientid as its name; these are only verified unique on a - * per-principal basis) - */ - public void testClientIDVerificationForDifferentUsers() throws Exception - { - setTestSystemProperty(ClientProperties.QPID_VERIFY_CLIENT_ID, "true"); - - BrokerDetails broker = getBroker(); - try - { - Connection con = new AMQConnection(broker.toString(), "guest", "guest", - "client_id", "test"); - - Connection con2 = new AMQConnection(broker.toString(), "admin", "admin", - "client_id", "test"); - } - catch (Exception e) - { - fail("Unexpected exception thrown, client id was not unique but usernames were different! " + e.getMessage()); + assertTrue("Incorrect exception thrown", + e.getMessage().contains("The following SASL mechanisms " + + "[MY_MECH]" + + " specified by the client are not supported by the broker")); } } |