From 93a511331449099ae89f52bcef626beb1d0586f9 Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Wed, 6 Mar 2013 22:20:23 +0000 Subject: QPID-3396 Added a test case to verify that if mech needs user password and if they are not supplied and exception is thrown. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1453594 13f79535-47bb-0310-9956-ffa450edef68 --- .../unit/client/connection/ConnectionTest.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'java') 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 375626a2fa..eda5eb3f0a 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 @@ -351,4 +351,28 @@ public class ConnectionTest extends QpidBrokerTestCase { return new junit.framework.TestSuite(ConnectionTest.class); } + + public void testExceptionWhenUserPassIsRequired() throws Exception + { + AMQConnection conn = null; + try + { + BrokerDetails broker = getBroker(); + String url = "amqp:///test?brokerlist='" + broker + "'&sasl_mech='PLAIN'"; + conn = new AMQConnection(url); + conn.close(); + fail("Exception should be thrown as user name and password is required"); + } + catch (Exception e) + { + if (!e.getMessage().contains("Username and Password is required for the selected mechanism")) + { + if (conn != null && !conn.isClosed()) + { + conn.close(); + } + fail("Incorrect Exception thrown! The exception thrown is : " + e.getMessage()); + } + } + } } -- cgit v1.2.1