Fix build failure in usermanager.implementation 20/1520/3
authorAlessandro Boch <aboch@cisco.com>
Mon, 30 Sep 2013 18:57:18 +0000 (11:57 -0700)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 30 Sep 2013 19:44:32 +0000 (19:44 +0000)
ISSUE:
Current usermanager.implementation junit code assumes test functions are run in order.
There is a add function and then a remove function to add/remove an object from a map.
In some machines consistently the remove function is invoked by junit first.
This leads to a failure/succes/failure/success... pattern for usermanager.implementation
builds.

Change-Id: Ie5041c6980f9dad0aeb1f11a27c0c3e9bab9dbcf
Signed-off-by: Alessandro Boch <aboch@cisco.com>
opendaylight/usermanager/implementation/src/test/java/org/opendaylight/controller/usermanager/internal/UserManagerImplTest.java

index 67c273b..f2cbe78 100644 (file)
@@ -104,15 +104,9 @@ public class UserManagerImplTest {
         }
     }
 
-    /**
-     * Test method for
-     * {@link org.opendaylight.controller.usermanager.internal.UserManager#addAAAProvider(org.opendaylight.controller.usermanager.IAAAProvider)}
-     * .
-     */
-    @Test
-    public void testAddAAAProvider() {
+    private IAAAProvider getAnonymousAAAProvider(final String providerName) {
         // instantiate an anonymous AAAProvider
-        IAAAProvider a3p = new IAAAProvider() {
+        return new IAAAProvider() {
 
             @Override
             public AuthResponse authService(String userName, String password,
@@ -122,25 +116,26 @@ public class UserManagerImplTest {
 
             @Override
             public String getName() {
-                return "dummyAAAProvider";
+                return providerName;
             }
         };
-
-        um.addAAAProvider(a3p);
-        assertEquals(a3p, um.getAAAProvider("dummyAAAProvider"));
-
     }
 
     /**
      * Test method for
+     * {@link org.opendaylight.controller.usermanager.internal.UserManager#addAAAProvider(org.opendaylight.controller.usermanager.IAAAProvider)}
+     * and for
      * {@link org.opendaylight.controller.usermanager.internal.UserManager#removeAAAProvider(org.opendaylight.controller.usermanager.IAAAProvider)}
-     * and for for
+     * and
      * {@link org.opendaylight.controller.usermanager.internal.UserManager#getAAAProvider(java.lang.String)}
-     * .
      */
     @Test
-    public void testRemoveAAAProvider() {
-        um.removeAAAProvider(um.getAAAProvider("dummyAAAProvider"));
+    public void testAddGetRemoveAAAProvider() {
+        final String providerName = "dummyAAAProvider";
+        IAAAProvider a3p = getAnonymousAAAProvider(providerName);
+        um.addAAAProvider(a3p);
+        assertEquals(a3p, um.getAAAProvider(providerName));
+        um.removeAAAProvider(um.getAAAProvider(providerName));
         assertTrue(um.getAAAProviderNames().isEmpty());
     }