You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gr...@apache.org on 2010/09/23 12:16:25 UTC

svn commit: r1000394 - in /qpid/branches/0.5.x-dev/qpid/java: broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTest.java

Author: grkvlt
Date: Thu Sep 23 10:16:24 2010
New Revision: 1000394

URL: http://svn.apache.org/viewvc?rev=1000394&view=rev
Log:
QPID-2864: Fixes for failing tests in persistent profile

Modified:
    qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java
    qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTest.java

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java?rev=1000394&r1=1000393&r2=1000394&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java Thu Sep 23 10:16:24 2010
@@ -20,13 +20,15 @@
  */
 package org.apache.qpid.server.registry;
 
-import junit.framework.TestCase;
-import org.apache.qpid.server.util.TestApplicationRegistry;
-
-import java.security.Security;
 import java.security.Provider;
+import java.security.Security;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
-import java.util.LinkedList;
+
+import junit.framework.TestCase;
+
+import org.apache.qpid.server.util.TestApplicationRegistry;
 
 /**
  * QPID-1390 : Test to validate that the AuthenticationManger succesfully unregisters any new SASL providers when
@@ -36,96 +38,59 @@ import java.util.LinkedList;
  */
 public class ApplicationRegistryShutdownTest extends TestCase
 {
-
     IApplicationRegistry _registry;
 
     public void setUp() throws Exception
     {
-        //Highlight that this test will cause a new AR to be created
-        // This must used TestAppRegistry but during the test getInstance()
-        // will be called so we must ensure to do the remove()
         _registry = new TestApplicationRegistry();
     }
 
     @Override
     public void tearDown() throws Exception
     {
-        // Correctly Close the AR we created        
+        // Close in case there was an error during the test
     	ApplicationRegistry.remove();
     }
 
-
     /**
      * QPID-1399 : Ensure that the Authentiction manager unregisters any SASL providers created during
      * ApplicationRegistry initialisation.
-     * 
      */
-    public void testAuthenticationMangerCleansUp()
+    public void testAuthenticationMangerCleansUp() throws Exception
     {
         // Get default providers
-        Provider[] defaultProviders = Security.getProviders();
+        List<Provider> before = Arrays.asList(Security.getProviders());
 
         // Register new providers
-        try
-        {
-            _registry.initialise(ApplicationRegistry.DEFAULT_INSTANCE);
-        }
-        catch (Exception e)
-        {
-            fail(e.getMessage());
-        }
+        ApplicationRegistry.initialise(_registry);
 
         // Get the providers after initialisation
-        Provider[] providersAfterInitialisation = Security.getProviders();
+        List<Provider> after = Arrays.asList(Security.getProviders());
 
         // Find the additions
-        List additions = new LinkedList();
-        for (Provider afterInit : providersAfterInitialisation)
+        List<Provider> additions = new ArrayList<Provider>();
+        for (Provider provider : after)
         {
-            boolean found = false;
-            for (Provider defaultProvider : defaultProviders)
-            {
-                if (defaultProvider == afterInit)
-                {
-                    found=true;
-                    break;
-                }
-            }
-
-            // Record added registies
-            if (!found)
+            if (!before.contains(provider))
             {
-                additions.add(afterInit);
+	            additions.add(provider);
             }
         }
 
-        // Not using isEmpty as that is not in Java 5
-        assertTrue("No new SASL mechanisms added by initialisation.", additions.size() != 0 );
+        assertFalse("No new SASL mechanisms added by initialisation.", additions.isEmpty());
 
         //Close the registry which will perform the close the AuthenticationManager
-        try
-        {
-            _registry.close();
-        }
-        catch (Exception e)
-        {
-            fail(e.getMessage());
-        }
+        ApplicationRegistry.remove(ApplicationRegistry.DEFAULT_INSTANCE);
 
         //Validate that the SASL plugins have been removed.
-        Provider[] providersAfterClose = Security.getProviders();
+        List<Provider> closed = Arrays.asList(Security.getProviders());
 
-        assertTrue("No providers unregistered", providersAfterInitialisation.length > providersAfterClose.length);
+        assertEquals("No providers unregistered", before.size(), closed.size());
 
         //Ensure that the additions are not still present after close().
-        for (Provider afterClose : providersAfterClose)
+        for (Provider provider : closed)
         {
-            assertFalse("Added provider not unregistered", additions.contains(afterClose));
+            assertFalse("Added provider not unregistered: " + provider.getName(), additions.contains(provider));
         }
     }
-
-
-
-
-
 }

Modified: qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTest.java?rev=1000394&r1=1000393&r2=1000394&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTest.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTest.java Thu Sep 23 10:16:24 2010
@@ -125,7 +125,8 @@ public class TransactionTimeoutTest exte
             _exception = e;
         }
         
-        monitor(5, 10);
+        // the presistent store generates more idle messages?
+        monitor(isBrokerStorePersistent() ? 10 : 5, 10);
         
         check(OPEN);
     }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org