[jboss-svn-commits] JBoss Portal SVN: r5430 - trunk/identity/src/main/org/jboss/portal/test/identity

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Oct 12 17:38:56 EDT 2006


Author: bdaw
Date: 2006-10-12 17:38:54 -0400 (Thu, 12 Oct 2006)
New Revision: 5430

Added:
   trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleRoleModuleTestCase.java
   trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleUserModuleTestCase.java
Modified:
   trunk/identity/src/main/org/jboss/portal/test/identity/LDAPTestCase.java
Log:
- updated ldap test cases

Added: trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleRoleModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleRoleModuleTestCase.java	2006-10-12 21:38:12 UTC (rev 5429)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleRoleModuleTestCase.java	2006-10-12 21:38:54 UTC (rev 5430)
@@ -0,0 +1,126 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.test.identity;
+
+import junit.framework.TestSuite;
+
+import java.net.URL;
+import java.util.Map;
+
+import org.jboss.portal.common.junit.metadata.TestCaseMetaData;
+import org.jboss.portal.common.junit.metadata.TestCaseParameterMetaData;
+import org.jboss.portal.common.junit.TestCaseFactory;
+import org.jboss.portal.test.framework.embedded.DSConfig;
+import org.jboss.portal.test.framework.TestRuntimeContext;
+import org.jboss.portal.identity2.RoleModule;
+import org.jboss.portal.identity2.ldap.LDAPRoleModuleImpl;
+import org.jboss.portal.identity2.ldap.LDAPRoleImpl;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPSimpleRoleModuleTestCase extends LDAPTestCase
+{
+   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPSimpleRoleModuleTestCase.class);
+
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("directories.xml");
+      TestCaseMetaData testCaseMD = new TestCaseMetaData();
+      testCaseMD.bindParameter(new TestCaseParameterMetaData("DirectoryServerConfig"), DSConfig.fromXML2(configsURL));
+      TestSuite suite = TestCaseFactory.create(testCaseMD, LDAPSimpleRoleModuleTestCase.class);
+      return suite;
+   }
+
+   public LDAPSimpleRoleModuleTestCase(Map parametrization)
+   {
+      super(parametrization);
+   }
+
+   RoleModule roleModule;
+
+   protected void setUp() throws Exception
+   {
+      runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
+      runtimeContext.addBean("LDAPTestBean", this);
+
+      LDAPRoleModuleImpl roleModule = new LDAPRoleModuleImpl();
+      roleModule.setConnectionContext(createConnectionContext());
+
+      roleModule.setContainerDN("ou=Roles,dc=jboss,dc=org");
+      roleModule.setRidAttributeID("cn");
+
+      this.roleModule = roleModule;
+
+      super.setUp();
+   }
+
+
+   public void testFirstSimple() throws Exception
+   {
+      log.info("test framework works ;]");
+   }
+
+   public void testFindRoleByName() throws Exception
+   {
+      LDAPRoleImpl ldapr = (LDAPRoleImpl)roleModule.findRoleById("Echo");
+      assertEquals(ldapr.getDn(), "cn=Echo,ou=Roles,dc=jboss,dc=org");
+      assertEquals(ldapr.getName(),"Echo");
+   }
+
+   public void testRemoveRole() throws Exception
+   {
+      LDAPRoleImpl ldapr = (LDAPRoleImpl)roleModule.findRoleById("Echo");
+      assertEquals(ldapr.getDn(), "cn=Echo,ou=Roles,dc=jboss,dc=org");
+      assertEquals(ldapr.getName(),"Echo");
+      roleModule.removeRole("Echo");
+      ldapr = (LDAPRoleImpl)roleModule.findRoleById("Echo");
+      assertNull(ldapr);
+   }
+
+   public void testCreateRole() throws Exception
+   {
+      LDAPRoleImpl ldapr = (LDAPRoleImpl)roleModule.createRole("testRole","testDisplayName");
+      assertNotNull(ldapr);
+      assertEquals("testRole",ldapr.getName());
+      //assertEquals("testDisplayName",ldapr.getDisplayName());
+
+      ldapr = (LDAPRoleImpl)roleModule.findRoleById("testRole");
+      assertNotNull(ldapr);
+      roleModule.removeRole("testRole");
+
+      ldapr = (LDAPRoleImpl)roleModule.findRoleById("testRole");
+      assertNull(ldapr);
+
+   }
+
+   public void testgetRoleCount() throws Exception
+   {
+      LDAPRoleImpl ldapr = (LDAPRoleImpl)roleModule.findRoleById("Echo");
+      assertEquals(ldapr.getDn(), "cn=Echo,ou=Roles,dc=jboss,dc=org");
+      assertEquals(ldapr.getName(),"Echo");
+
+      int count = roleModule.getRolesCount();
+      assertEquals(2, count);
+   }
+}

Added: trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleUserModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleUserModuleTestCase.java	2006-10-12 21:38:12 UTC (rev 5429)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/LDAPSimpleUserModuleTestCase.java	2006-10-12 21:38:54 UTC (rev 5430)
@@ -0,0 +1,125 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.test.identity;
+
+import org.jboss.portal.identity2.UserModule;
+import org.jboss.portal.identity2.ldap.LDAPUserModuleImpl;
+import org.jboss.portal.identity2.ldap.LDAPUserImpl;
+import org.jboss.portal.common.junit.metadata.TestCaseMetaData;
+import org.jboss.portal.common.junit.metadata.TestCaseParameterMetaData;
+import org.jboss.portal.common.junit.TestCaseFactory;
+import org.jboss.portal.test.framework.embedded.DSConfig;
+import org.jboss.portal.test.framework.TestRuntimeContext;
+
+import java.util.Map;
+import java.net.URL;
+
+import junit.framework.TestSuite;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPSimpleUserModuleTestCase extends LDAPTestCase
+{
+   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPSimpleUserModuleTestCase.class);
+
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("directories.xml");
+      TestCaseMetaData testCaseMD = new TestCaseMetaData();
+      testCaseMD.bindParameter(new TestCaseParameterMetaData("DirectoryServerConfig"), DSConfig.fromXML2(configsURL));
+      TestSuite suite = TestCaseFactory.create(testCaseMD, LDAPSimpleUserModuleTestCase.class);
+      return suite;
+   }
+
+   public LDAPSimpleUserModuleTestCase(Map parametrization)
+   {
+      super(parametrization);
+   }
+
+   UserModule userModule;
+
+   protected void setUp() throws Exception
+   {
+      runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
+      runtimeContext.addBean("LDAPTestBean", this);
+
+      LDAPUserModuleImpl userModule = new LDAPUserModuleImpl(); 
+      userModule.setConnectionContext(createConnectionContext());
+
+      userModule.setContainerDN("ou=People,dc=jboss,dc=org");
+      userModule.setUidAttributeID("uid");
+
+      this.userModule = userModule;
+
+      super.setUp();
+   }
+
+
+   public void testFirstSimple() throws Exception
+   {
+      log.info("test framework works ;]");
+   }
+
+   public void testFindUserByName() throws Exception
+   {
+      LDAPUserImpl ldapu = (LDAPUserImpl)userModule.findUserById("jduke");
+      assertEquals(ldapu.getDn(), "uid=jduke,ou=People,dc=jboss,dc=org");
+      assertEquals(ldapu.getUserName(),"jduke");
+   }
+
+   public void testRemoveUser() throws Exception
+   {
+      LDAPUserImpl ldapu = (LDAPUserImpl)userModule.findUserById("jduke");
+      assertNotNull(ldapu);
+      assertEquals(ldapu.getDn(), "uid=jduke,ou=People,dc=jboss,dc=org");
+      userModule.removeUser("jduke");
+      ldapu = (LDAPUserImpl)userModule.findUserById("jduke");
+      assertNull(ldapu);
+   }
+
+   public void testCreateUser() throws Exception
+   {
+      LDAPUserImpl ldapu = (LDAPUserImpl)userModule.createUser("testUser","testPassword","email");
+      assertNotNull(ldapu);
+      assertEquals("testUser",ldapu.getUserName());
+
+      ldapu = (LDAPUserImpl)userModule.findUserById("testUser");
+      assertNotNull(ldapu);
+      userModule.removeUser("testUser");
+
+      ldapu = (LDAPUserImpl)userModule.findUserById("testUser");
+      assertNull(ldapu);
+
+   }
+
+   public void testgetUserCount() throws Exception
+   {
+      LDAPUserImpl ldapu = (LDAPUserImpl)userModule.findUserById("jduke");
+      assertEquals(ldapu.getDn(), "uid=jduke,ou=People,dc=jboss,dc=org");
+      assertEquals(ldapu.getUserName(),"jduke");
+
+      int count = userModule.getUserCount();
+      assertEquals(5, count);
+   }
+}

Modified: trunk/identity/src/main/org/jboss/portal/test/identity/LDAPTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/LDAPTestCase.java	2006-10-12 21:38:12 UTC (rev 5429)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/LDAPTestCase.java	2006-10-12 21:38:54 UTC (rev 5430)
@@ -56,6 +56,7 @@
       Appender appender = new ConsoleAppender(new SimpleLayout());
       Logger.getRoot().addAppender(appender);
       Logger.getRoot().setLevel(Level.INFO);
+      Logger.getLogger("org.jboss.portal.identity2.ldap").setLevel(Level.DEBUG);
    }
 
    public LDAPTestCase()




More information about the jboss-svn-commits mailing list