summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2012-04-18 16:02:35 +0000
committerRobert Gemmell <robbie@apache.org>2012-04-18 16:02:35 +0000
commitc7ed8384ffa4ea6c4762389930aa2c5a373aabfa (patch)
tree680877d2f8837044d6374930f17214e97d7cc21c
parent372976bc6de5a176f16069ed552b4c2fec9ee8fc (diff)
downloadqpid-python-c7ed8384ffa4ea6c4762389930aa2c5a373aabfa.tar.gz
QPID-3959: ensure the test creates/removes its own ApplicationRegistry with a null AuthenticationManager.
Applied patch from Andrew MacBean <andymacbean@gmail.com> git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1327556 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java24
1 files changed, 22 insertions, 2 deletions
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java
index 0e2437978c..bef03057ec 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java
@@ -22,10 +22,15 @@ package org.apache.qpid.server.security.auth.rmi;
import junit.framework.TestCase;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
+import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.security.auth.AuthenticationResult;
import org.apache.qpid.server.security.auth.AuthenticationResult.AuthenticationStatus;
import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
+import org.apache.qpid.server.util.TestApplicationRegistry;
import javax.management.remote.JMXPrincipal;
import javax.security.auth.Subject;
@@ -48,7 +53,7 @@ public class RMIPasswordAuthenticatorTest extends TestCase
protected void setUp() throws Exception
{
_rmipa = new RMIPasswordAuthenticator();
-
+
_credentials = new String[] {USERNAME, PASSWORD};
}
@@ -115,8 +120,19 @@ public class RMIPasswordAuthenticatorTest extends TestCase
/**
* Tests case where authentication manager is not set.
*/
- public void testNullAuthenticationManager()
+ public void testNullAuthenticationManager() throws Exception
{
+ ServerConfiguration serverConfig = new ServerConfiguration(new XMLConfiguration());
+ TestApplicationRegistry reg = new TestApplicationRegistry(serverConfig)
+ {
+ @Override
+ protected AuthenticationManager createAuthenticationManager() throws ConfigurationException
+ {
+ return null;
+ }
+ };
+ ApplicationRegistry.initialise(reg);
+
try
{
_rmipa.authenticate(_credentials);
@@ -127,6 +143,10 @@ public class RMIPasswordAuthenticatorTest extends TestCase
assertEquals("Unexpected exception message",
RMIPasswordAuthenticator.UNABLE_TO_LOOKUP, se.getMessage());
}
+ finally
+ {
+ ApplicationRegistry.remove();
+ }
}
/**