activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1456485 - in /activemq/trunk: activemq-client/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java activemq-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginTest.java
Date Thu, 14 Mar 2013 15:38:02 GMT
Author: tabish
Date: Thu Mar 14 15:38:01 2013
New Revision: 1456485

URL: http://svn.apache.org/r1456485
Log:
fix and test for: https://issues.apache.org/jira/browse/AMQ-4373

Modified:
    activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java
    activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginTest.java

Modified: activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java?rev=1456485&r1=1456484&r2=1456485&view=diff
==============================================================================
--- activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java
(original)
+++ activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java
Thu Mar 14 15:38:01 2013
@@ -17,6 +17,7 @@
 package org.apache.activemq.util;
 
 import javax.jms.JMSException;
+import javax.jms.JMSSecurityException;
 import javax.jms.MessageEOFException;
 import javax.jms.MessageFormatException;
 
@@ -46,7 +47,12 @@ public final class JMSExceptionSupport {
         if (msg == null || msg.length() == 0) {
             msg = cause.toString();
         }
-        JMSException exception = new JMSException(msg);
+        JMSException exception;
+        if (cause instanceof SecurityException) {
+            exception = new JMSSecurityException(msg);
+        } else {
+            exception = new JMSException(msg);
+        }
         exception.initCause(cause);
         return exception;
     }
@@ -59,7 +65,12 @@ public final class JMSExceptionSupport {
         if (msg == null || msg.length() == 0) {
             msg = cause.toString();
         }
-        JMSException exception = new JMSException(msg);
+        JMSException exception;
+        if (cause instanceof SecurityException) {
+            exception = new JMSSecurityException(msg);
+        } else {
+            exception = new JMSException(msg);
+        }
         exception.setLinkedException(cause);
         exception.initCause(cause);
         return exception;

Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginTest.java?rev=1456485&r1=1456484&r2=1456485&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginTest.java
(original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginTest.java
Thu Mar 14 15:38:01 2013
@@ -20,6 +20,7 @@ import java.net.URI;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
+import javax.jms.JMSSecurityException;
 import javax.jms.Message;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
@@ -104,6 +105,19 @@ public class SimpleAuthenticationPluginT
         } catch (Exception ignore) {}
     }
 
+    public void testConnectionStartThrowsJMSSecurityException() throws Exception {
+
+        Connection connection = factory.createConnection("badUser", "password");
+        try {
+            connection.start();
+            fail("Should throw JMSSecurityException");
+        } catch (JMSSecurityException jmsEx) {
+        } catch (Exception e) {
+            LOG.info("Expected JMSSecurityException but was: {}", e.getClass());
+            fail("Should throw JMSSecurityException");
+        }
+    }
+
     public void testSecurityContextClearedOnPurge() throws Exception {
 
         connection.close();



Mime
View raw message