ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1488946 - in /ace/trunk/org.apache.ace.useradmin.ui.itest: bnd.bnd conf/ src/org/apache/ace/useradmin/ui/test/UserEditorTest.java
Date Mon, 03 Jun 2013 09:57:17 GMT
Author: bramk
Date: Mon Jun  3 09:57:16 2013
New Revision: 1488946

URL: http://svn.apache.org/r1488946
Log:
ACE-339 Cleaned up useradmin.ui.itest / Decoupled from file based conf

Removed:
    ace/trunk/org.apache.ace.useradmin.ui.itest/conf/
Modified:
    ace/trunk/org.apache.ace.useradmin.ui.itest/bnd.bnd
    ace/trunk/org.apache.ace.useradmin.ui.itest/src/org/apache/ace/useradmin/ui/test/UserEditorTest.java

Modified: ace/trunk/org.apache.ace.useradmin.ui.itest/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.useradmin.ui.itest/bnd.bnd?rev=1488946&r1=1488945&r2=1488946&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.useradmin.ui.itest/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.useradmin.ui.itest/bnd.bnd Mon Jun  3 09:57:16 2013
@@ -2,73 +2,48 @@ Test-Cases: ${classes;CONCRETE;EXTENDS;o
 Private-Package: org.apache.ace.useradmin.ui.test
 -runvm: -ea
 -runfw: org.apache.felix.framework;version='[4.0.3,4.0.3]'
--runbundles: \
-	osgi.cmpn,\
+-runbundles: osgi.cmpn,\
 	com.vaadin,\
 	org.apache.felix.configadmin,\
 	org.apache.felix.dependencymanager,\
-	org.apache.felix.dependencymanager.shell,\
 	org.apache.felix.eventadmin,\
-	org.apache.felix.gogo.command,\
-	org.apache.felix.gogo.runtime,\
-	org.apache.felix.gogo.shell,\
 	org.apache.felix.http.jetty,\
 	org.apache.felix.log,\
 	org.apache.felix.prefs,\
 	org.apache.felix.useradmin,\
 	org.apache.felix.useradmin.filestore,\
-	org.apache.ace.authentication.api;version=latest,\
-	org.apache.ace.authentication.impl;version=latest,\
-	org.apache.ace.authentication.processor.password;version=latest,\
-	org.apache.ace.authentication.processor.basicauth;version=latest,\
 	org.apache.ace.client.repository.api;version=latest,\
 	org.apache.ace.client.repository.helper.base;version=latest,\
 	org.apache.ace.client.repository.helper.bundle;version=latest,\
 	org.apache.ace.client.repository.helper.configuration;version=latest,\
 	org.apache.ace.client.repository.impl;version=latest,\
-	org.apache.ace.client.rest;version=latest,\
-	org.apache.ace.configurator.serveruseradmin;version=latest,\
-	org.apache.ace.configurator.useradmin.task;version=latest,\
-	org.apache.ace.configurator.impl;version=latest,\
 	org.apache.ace.connectionfactory;version=latest,\
-	org.apache.ace.consolelogger;version=latest,\
 	org.apache.ace.deployment.provider.api;version=latest,\
-	org.apache.ace.deployment.provider.repositorybased;version=latest,\
-	org.apache.ace.deployment.servlet;version=latest,\
-	org.apache.ace.deployment.streamgenerator;version=latest,\
-	org.apache.ace.verifier.ui;version=latest,\
-	org.apache.ace.verifier.impl;version=latest,\
 	org.apache.ace.discovery.api;version=latest,\
 	org.apache.ace.http.listener;version=latest,\
 	org.apache.ace.log.api;version=latest,\
 	org.apache.ace.log.server.servlet;version=latest,\
-	org.apache.ace.nodelauncher.amazon;version=latest,\
-	org.apache.ace.nodelauncher.api;version=latest,\
-	org.apache.ace.nodelauncher.ui;version=latest,\
-	org.apache.ace.obr.metadata;version=latest,\
-	org.apache.ace.obr.servlet;version=latest,\
-	org.apache.ace.obr.storage;version=latest,\
 	org.apache.ace.range.api;version=latest,\
 	org.apache.ace.repository.api;version=latest,\
 	org.apache.ace.repository.impl;version=latest,\
 	org.apache.ace.repository.servlet;version=latest,\
 	org.apache.ace.resourceprocessor.useradmin;version=latest,\
 	org.apache.ace.scheduler.impl;version=latest,\
-	org.apache.ace.log.server.store.api;version=latest,\
-	org.apache.ace.log.server.store.file;version=latest,\
-	org.apache.ace.log.server.ui;version=latest,\
-	org.apache.ace.tageditor;version=latest,\
-	org.apache.ace.target.mgmt.ui;version=latest,\
 	org.apache.ace.test;version=latest,\
 	org.apache.ace.useradmin.ui;version=latest,\
-	org.apache.ace.webui.vaadin;version=latest
+	org.apache.ace.webui.vaadin;version=latest,\
+	org.apache.ace.configurator.useradmin.task;version=latest,\
+	org.apache.ace.authentication.api;version=latest,\
+	org.apache.ace.log.server.store.api;version=latest
 -buildpath: osgi.core;version='[4.1,5)',\
 	osgi.cmpn,\
 	junit.osgi,\
 	org.mockito.mockito-all,\
 	org.apache.felix.dependencymanager,\
 	org.apache.ace.test;version=latest,\
-	org.apache.ace.useradmin.ui;version=latest
+	org.apache.ace.useradmin.ui;version=latest,\
+	org.apache.ace.repository.api;version=latest,\
+	org.apache.ace.range.api;version=latest
 -runsystempackages: sun.reflect
 -runproperties: org.apache.felix.log.storeDebug=true,\
 	org.apache.felix.eventadmin.Timeout=0,\

Modified: ace/trunk/org.apache.ace.useradmin.ui.itest/src/org/apache/ace/useradmin/ui/test/UserEditorTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.useradmin.ui.itest/src/org/apache/ace/useradmin/ui/test/UserEditorTest.java?rev=1488946&r1=1488945&r2=1488946&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.useradmin.ui.itest/src/org/apache/ace/useradmin/ui/test/UserEditorTest.java
(original)
+++ ace/trunk/org.apache.ace.useradmin.ui.itest/src/org/apache/ace/useradmin/ui/test/UserEditorTest.java
Mon Jun  3 09:57:16 2013
@@ -18,7 +18,10 @@
  */
 package org.apache.ace.useradmin.ui.test;
 
+import java.io.ByteArrayInputStream;
+
 import org.apache.ace.it.IntegrationTestBase;
+import org.apache.ace.repository.Repository;
 import org.apache.ace.useradmin.ui.editor.GroupNotFoundException;
 import org.apache.ace.useradmin.ui.editor.UserAlreadyExistsException;
 import org.apache.ace.useradmin.ui.editor.UserDTO;
@@ -31,23 +34,14 @@ import org.osgi.service.useradmin.User;
 import org.osgi.service.useradmin.UserAdmin;
 
 public class UserEditorTest extends IntegrationTestBase {
-    private volatile UserEditor instance;
-    private volatile UserAdmin useradmin;
-    private static boolean firststart = true;
 
-    public UserEditorTest() {
-    }
-
-    @Override
-    protected void configureProvisionedServices() throws Exception {
-        super.configureProvisionedServices();
-        if (firststart) {
-            Thread.sleep(1000);
-            firststart = false;
-        }
-    }
+    private volatile UserEditor m_userEditor;
+    private volatile Repository m_userRepository;
+    private volatile UserAdmin m_userAdmin;
+    private boolean m_hasBeenSetup = false;
 
     protected org.apache.felix.dm.Component[] getDependencies() {
+
         return new Component[] { createComponent()
             .setImplementation(this)
             .add(createServiceDependency()
@@ -58,73 +52,124 @@ public class UserEditorTest extends Inte
                 .setService(UserAdmin.class)
                 .setRequired(true)
             )
+            .add(createServiceDependency()
+                .setService(Repository.class, "(&(name=users)(customer=apache))")
+                .setRequired(true))
         };
     }
-    
-    // How to test in future? When amount of groups grows, test will fail...
-    // Need something to assert here.
+
+    @Override
+    protected void configureProvisionedServices() throws Exception {
+
+        if (m_hasBeenSetup)
+            return;
+
+        configureFactory("org.apache.ace.server.repository.factory",
+            "name", "users",
+            "customer", "apache",
+            "master", "true");
+        configure("org.apache.ace.configurator.useradmin.task.UpdateUserAdminTask",
+            "repositoryName", "users",
+            "repositoryCustomer", "apache");
+        configure("org.apache.ace.scheduler",
+            "org.apache.ace.configurator.useradmin.task.UpdateUserAdminTask", "100");
+    }
+
+    @Override
+    protected void configureAdditionalServices() throws Exception {
+
+        if (m_hasBeenSetup)
+            return;
+
+        m_hasBeenSetup = true;
+        ByteArrayInputStream bis = new ByteArrayInputStream((
+            "<roles>" +
+                "    <group name=\"TestGroup\">" +
+                "        <properties>" +
+                "            <type>userGroup</type>" +
+                "        </properties>" +
+                "    </group>" +
+                "    <user name=\"TestUser\">" +
+                "        <properties>" +
+                "            <email>testUser@apache.org</email>" +
+                "        </properties>" +
+                "        <credentials>" +
+                "            <password type=\"String\">swordfish</password>"
+
+                "            <certificate type=\"byte[]\">42</certificate>" +
+                "        </credentials>" +
+                "        <memberof>TestGroup</memberof>" +
+                "    </user>" +
+                "</roles>").getBytes());
+
+        assertTrue("Committing test user data failed.", m_userRepository.commit(bis, m_userRepository.getRange().getHigh()));
+        User user = (User) m_userAdmin.getRole("TestUser");
+        int count = 0;
+        while ((user == null) && (count < 60)) {
+            Thread.sleep(100);
+            user = (User) m_userAdmin.getRole("TestUser");
+            count++;
+        }
+        assertNotNull("Failed to load the user", user);
+    }
+
     public void testGetGroups() {
-        assertEquals(6, instance.getGroups().size());
+        assertEquals(1, m_userEditor.getGroups().size());
     }
 
-    // How to test in future? When amount of users grows, test will fail...
-    // Need something to assert here.
     public void testGetUsers() {
-        assertEquals(6, instance.getData().size());
+        assertEquals(1, m_userEditor.getData().size());
     }
 
     public void testGetGroupByUser() {
         User newUser = null;
-        Role newRole = useradmin.createRole((String) "Testuser", Role.USER);
-        Group group = (Group) useradmin.getRole("TestGroup");
+        Role newRole = m_userAdmin.createRole((String) "Testuser", Role.USER);
+        Group group = (Group) m_userAdmin.getRole("TestGroup");
         if (newRole != null && group != null) {
             newUser = (User) newRole;
             newUser.getProperties().put("username", "u");
             newUser.getCredentials().put("password", "p");
             group.addMember(newUser);
         }
-        assertEquals(group, instance.getGroup(newUser));
-        useradmin.removeRole("u");
+        assertEquals(group, m_userEditor.getGroup(newUser));
+        m_userAdmin.removeRole("u");
     }
 
     public void testGetGroupByUserNull() {
-        assertNull(instance.getGroup(null));
+        assertNull(m_userEditor.getGroup(null));
     }
 
     public void testAddUserAndRemove() throws Exception {
         UserDTO userDTO = new UserDTO("tran", "tran", "TestGroup");
-        instance.addUser(userDTO);
-        User user = instance.getUser("tran");
+        m_userEditor.addUser(userDTO);
+        User user = m_userEditor.getUser("tran");
         assertEquals("tran", (String) user.getProperties().get("username"));
-        instance.removeUser(userDTO);
+        m_userEditor.removeUser(userDTO);
     }
 
     public void testAddUserWithEmptyUsername() throws Exception {
         try {
             UserDTO userDTO = new UserDTO("", "tran", "TestGroup");
-            instance.addUser(userDTO);
+            m_userEditor.addUser(userDTO);
         }
         catch (IllegalArgumentException ex) {
             assertEquals("Username, password and groupname cannot be null or \"\"", ex.getMessage());
         }
-
     }
 
     public void testAddUserWithNullUsername() throws Exception {
         try {
             UserDTO userDTO = new UserDTO(null, "tran", "TestGroup");
-            instance.addUser(userDTO);
+            m_userEditor.addUser(userDTO);
         }
         catch (IllegalArgumentException ex) {
             assertEquals("Username, password and groupname cannot be null or \"\"", ex.getMessage());
         }
-
     }
 
     public void testAddUserToNonExistingGroup() throws Exception {
         try {
             UserDTO userDTO = new UserDTO("tran", "bob", "nonexistingGroup");
-            instance.addUser(userDTO);
+            m_userEditor.addUser(userDTO);
         }
         catch (Exception ex) {
             assertEquals("Group: nonexistingGroup not found", ex.getMessage());
@@ -134,7 +179,7 @@ public class UserEditorTest extends Inte
     public void testAddUserToNullGroup() throws Exception {
         try {
             UserDTO userDTO = new UserDTO("tran", "bob", null);
-            instance.addUser(userDTO);
+            m_userEditor.addUser(userDTO);
         }
         catch (IllegalArgumentException ex) {
             assertEquals("Username, password and groupname cannot be null or \"\"", ex.getMessage());
@@ -144,7 +189,7 @@ public class UserEditorTest extends Inte
     public void testAddUserToEmptyGroupname() throws Exception {
         try {
             UserDTO userDTO = new UserDTO("tran", "bob", "");
-            instance.addUser(userDTO);
+            m_userEditor.addUser(userDTO);
         }
         catch (Exception ex) {
             assertEquals("Username, password and groupname cannot be null or \"\"", ex.getMessage());
@@ -153,24 +198,24 @@ public class UserEditorTest extends Inte
 
     public void testEditUserWithValidPassword() throws Exception {
         UserDTO userDTO = new UserDTO("bob", "tran", "TestGroup");
-        instance.addUser(userDTO);
+        m_userEditor.addUser(userDTO);
         userDTO.setPassword("bob");
-        instance.editPassword(userDTO);
-        assertEquals("bob", (String) instance.getUser("bob").getCredentials().get("password"));
-        instance.removeUser(userDTO);
+        m_userEditor.editPassword(userDTO);
+        assertEquals("bob", (String) m_userEditor.getUser("bob").getCredentials().get("password"));
+        m_userEditor.removeUser(userDTO);
     }
 
     public void testEditUserWithNullPassword() throws UserNotFoundException {
         UserDTO userDTO = new UserDTO("tran", "tran", "TestGroup");
 
         try {
-            instance.addUser(userDTO);
+            m_userEditor.addUser(userDTO);
             userDTO.setPassword(null);
-            instance.editPassword(userDTO);
+            m_userEditor.editPassword(userDTO);
         }
         catch (Exception e) {
             assertEquals("Username or Password cannot be null or \"\" ", e.getMessage());
-            instance.removeUser(userDTO);
+            m_userEditor.removeUser(userDTO);
         }
     }
 
@@ -178,13 +223,13 @@ public class UserEditorTest extends Inte
         UserDTO userDTO = new UserDTO("tran", "tran", "TestGroup");
         try {
 
-            instance.addUser(userDTO);
+            m_userEditor.addUser(userDTO);
             userDTO.setPassword("");
-            instance.editPassword(userDTO);
+            m_userEditor.editPassword(userDTO);
         }
         catch (Exception e) {
             assertEquals("Username or Password cannot be null or \"\" ", e.getMessage());
-            instance.removeUser(userDTO);
+            m_userEditor.removeUser(userDTO);
         }
     }
 
@@ -192,7 +237,7 @@ public class UserEditorTest extends Inte
         try {
             UserDTO userDTO = new UserDTO("BOOOOOB", null, null);
             userDTO.setUsername("bob");
-            instance.editUsername(userDTO);
+            m_userEditor.editUsername(userDTO);
         }
         catch (Exception userNotFoundException) {
             assertEquals("User: BOOOOOB not found", userNotFoundException.getMessage());
@@ -201,73 +246,70 @@ public class UserEditorTest extends Inte
 
     public void testEditUsernameWithValidName() throws Exception {
         UserDTO userDTO = new UserDTO("lala", "tran", "TestGroup");
-        instance.addUser(userDTO);
-        useradmin.getUser("username", "lala").getProperties().put("username", "lala1");
-        User user = (User) useradmin.getRole("lala");
+        m_userEditor.addUser(userDTO);
+        m_userAdmin.getUser("username", "lala").getProperties().put("username", "lala1");
+        User user = (User) m_userAdmin.getRole("lala");
         assertEquals("lala", user.getName());
         assertEquals("lala1", (String) user.getProperties().get("username"));
-        user = useradmin.getUser("username", "lala1");
-        userDTO = new UserDTO(user, instance.getGroup(user));
+        user = m_userAdmin.getUser("username", "lala1");
+        userDTO = new UserDTO(user, m_userEditor.getGroup(user));
         assertEquals("lala", user.getName());
         assertEquals("lala1", (String) user.getProperties().get("username"));
-        instance.removeUser(userDTO);
+        m_userEditor.removeUser(userDTO);
     }
 
     public void testEditUsernameWithAlreadyExistingName() throws UserNotFoundException {
         try {
             UserDTO userDTO = new UserDTO("Hank", "password", "TestGroup");
-            instance.addUser(userDTO);
+            m_userEditor.addUser(userDTO);
             userDTO = new UserDTO("Dirk", "password", "TestGroup");
-            instance.addUser(userDTO);
+            m_userEditor.addUser(userDTO);
             userDTO.setUsername("Hank");
-            instance.editUsername(userDTO);
+            m_userEditor.editUsername(userDTO);
         }
         catch (Exception userAlreadyExistsException) {
             assertEquals("User: Hank already exists", userAlreadyExistsException.getMessage());
-            instance.removeUser(new UserDTO("Hank", null, null));
-            instance.removeUser(new UserDTO("Dirk", null, null));
+            m_userEditor.removeUser(new UserDTO("Hank", null, null));
+            m_userEditor.removeUser(new UserDTO("Dirk", null, null));
         }
     }
 
     public void testEditUserNameWithNull() throws GroupNotFoundException, UserAlreadyExistsException,
UserNotFoundException {
         try {
             UserDTO userDTO = new UserDTO("Dirk", "password", "TestGroup");
-            instance.addUser(userDTO);
+            m_userEditor.addUser(userDTO);
             userDTO.setUsername(null);
-            instance.editUsername(userDTO);
+            m_userEditor.editUsername(userDTO);
         }
         catch (Exception invalidArgumentException) {
             assertEquals("oldUsername and newUsername cannot be null or \"\" ", invalidArgumentException.getMessage());
-            instance.removeUser(new UserDTO("Dirk", "password", "TestGroup"));
+            m_userEditor.removeUser(new UserDTO("Dirk", "password", "TestGroup"));
         }
     }
 
     public void testEditUserNameWithEmptyName() throws GroupNotFoundException, UserAlreadyExistsException,
UserNotFoundException {
         try {
             UserDTO userDTO = new UserDTO("Dirk", "password", "TestGroup");
-            instance.addUser(userDTO);
+            m_userEditor.addUser(userDTO);
             userDTO.setUsername("");
-            instance.editUsername(userDTO);
+            m_userEditor.editUsername(userDTO);
         }
         catch (Exception invalidArgumentException) {
             assertEquals("oldUsername and newUsername cannot be null or \"\" ", invalidArgumentException.getMessage());
-            instance.removeUser(new UserDTO("Dirk", "password", "TestGroup"));
+            m_userEditor.removeUser(new UserDTO("Dirk", "password", "TestGroup"));
         }
     }
 
-    // // Broken test, newUser is null at end of method??
-    // public void GetUserBroken() {
-    // User newUser = null;
-    // Role newRole = useradmin.createRole((String) "Testuser", Role.USER);
-    // Group group = (Group) useradmin.getRole("TestGroup");
-    // if (newRole != null && group != null)
-    // {
-    // newUser = (User) newRole;
-    // newUser.getProperties().put("username", "u");
-    // newUser.getCredentials().put("password", "p");
-    // group.addMember(newUser);
-    // }
-    // assertEquals("Testuser", instance.getUser("u").getName());
-    // }
-
+    public void GetUserBroken() {
+        User newUser = null;
+        Role newRole = m_userAdmin.createRole((String) "Testuser", Role.USER);
+        Group group = (Group) m_userAdmin.getRole("TestGroup");
+        if (newRole != null && group != null) {
+            newUser = (User) newRole;
+            newUser.getProperties().put("username", "u");
+            newUser.getCredentials().put("password", "p");
+            group.addMember(newUser);
+        }
+        assertEquals("Testuser", m_userEditor.getUser("u").getName());
+    }
 }



Mime
View raw message