mirror of https://github.com/apache/activemq.git
fix and test for: https://issues.apache.org/jira/browse/AMQ-4373
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1456485 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fbe632e968
commit
f87f56294d
|
@ -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;
|
||||
|
|
|
@ -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 SimpleAuthenticationPluginTest extends SecurityTestSupport {
|
|||
} 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();
|
||||
|
|
Loading…
Reference in New Issue