You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2012/04/18 18:02:36 UTC

svn commit: r1327556 - /qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java

Author: robbie
Date: Wed Apr 18 16:02:35 2012
New Revision: 1327556

URL: http://svn.apache.org/viewvc?rev=1327556&view=rev
Log:
QPID-3959: ensure the test creates/removes its own ApplicationRegistry with a null AuthenticationManager.

Applied patch from Andrew MacBean <an...@gmail.com>

Modified:
    qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java?rev=1327556&r1=1327555&r2=1327556&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java Wed Apr 18 16:02:35 2012
@@ -22,10 +22,15 @@ package org.apache.qpid.server.security.
 
 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 RMIPasswordAuthenticatorTes
     protected void setUp() throws Exception
     {
         _rmipa = new RMIPasswordAuthenticator();
-        
+
         _credentials = new String[] {USERNAME, PASSWORD};
     }
 
@@ -115,8 +120,19 @@ public class RMIPasswordAuthenticatorTes
     /**
      * 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 RMIPasswordAuthenticatorTes
             assertEquals("Unexpected exception message",
                     RMIPasswordAuthenticator.UNABLE_TO_LOOKUP, se.getMessage());
         }
+        finally
+        {
+            ApplicationRegistry.remove();
+        }
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org