[portal-commits] JBoss Portal SVN: r5839 - in trunk/identity/src/main/org/jboss/portal/test/identity: . db_old ldap

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Wed Dec 13 10:39:32 EST 2006


Author: bdaw
Date: 2006-12-13 10:39:20 -0500 (Wed, 13 Dec 2006)
New Revision: 5839

Added:
   trunk/identity/src/main/org/jboss/portal/test/identity/UserProtoTestCase.java
   trunk/identity/src/main/org/jboss/portal/test/identity/UserTest.java
   trunk/identity/src/main/org/jboss/portal/test/identity/db_old/
   trunk/identity/src/main/org/jboss/portal/test/identity/db_old/DBUserTestCase.java
   trunk/identity/src/main/org/jboss/portal/test/identity/db_old/UserTest.java
Removed:
   trunk/identity/src/main/org/jboss/portal/test/identity/UserTest.java
   trunk/identity/src/main/org/jboss/portal/test/identity/db_old/DBUserTestCase.java
Modified:
   trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java
   trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java
   trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java
   trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java
Log:
refactored identity tests for the new stuff

Added: trunk/identity/src/main/org/jboss/portal/test/identity/UserProtoTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/UserProtoTestCase.java	2006-12-13 15:36:15 UTC (rev 5838)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/UserProtoTestCase.java	2006-12-13 15:39:20 UTC (rev 5839)
@@ -0,0 +1,193 @@
+/*
+* 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.apache.log4j.Appender;
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.SimpleLayout;
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+import org.jboss.portal.identity2.IdentityContextImpl;
+import org.jboss.portal.identity2.IdentityServiceControllerImpl;
+import org.jboss.portal.identity2.IdentityContext;
+import org.jboss.portal.identity2.service.IdentityModuleService;
+import org.jboss.portal.test.framework.TestRuntimeContext;
+import org.jboss.portal.test.framework.embedded.HibernateSupport;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.db.RoleImpl;
+import org.jboss.portal.identity.db.UserImpl;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.EntityMode;
+import org.hibernate.Query;
+import org.hibernate.Transaction;
+
+import javax.naming.InitialContext;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss dot com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 5247 $
+ */
+public class UserProtoTestCase extends junit.framework.TestCase
+{
+
+   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(UserProtoTestCase.class);
+
+   private HibernateSupport hibernate;
+
+   static
+   {
+      Appender appender = new ConsoleAppender(new SimpleLayout());
+      Logger.getRoot().addAppender(appender);
+      Logger.getRoot().setLevel(Level.INFO);
+      Logger.getLogger("org.jboss.portal.identity2").setLevel(Level.DEBUG);
+   }
+
+   /*public static TestSuite createTestSuite(Class clazz) throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("directories.xml");
+      Map parameterMap = new HashMap();
+      parameterMap.put("DirectoryServerConfig", DSConfig.fromXML2(configsURL));
+      POJOJUnitTest abc = new POJOJUnitTest(clazz);
+      JUnitAdapter adapter = new JUnitAdapter(abc);
+      TestSuite suite = new TestSuite();
+      suite.addTest(adapter);
+      return suite;
+   }*/
+
+   public UserProtoTestCase()
+   {
+
+   }
+
+   public HibernateSupport getHibernate()
+   {
+      return hibernate;
+   }
+
+   public void setHibernate(HibernateSupport hibernate)
+   {
+      this.hibernate = hibernate;
+   }
+
+   /*public ConfigurationTestCase(DSConfig dsConfig)
+   {
+      this.directoryServerConfigParameter = dsConfig;
+   }
+
+   private DSConfig directoryServerConfigParameter;
+
+   public String getName()
+   {
+      return super.getName();// + "," + directoryServerConfigParameter.getName() + "," + directoryServerConfigParameter.getDescription();
+   }
+
+   public DSConfig getDirectoryServerConfigParameter()
+   {
+      return directoryServerConfigParameter;
+   }
+
+   public void setDirectoryServerConfigParameter(DSConfig directoryServerConfigParameter)
+   {
+      this.directoryServerConfigParameter = directoryServerConfigParameter;
+   }*/
+
+   IdentityContextImpl context;
+
+
+   public void setUp() throws Exception
+   {
+      TestRuntimeContext runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/proto-beans.xml");
+      runtimeContext.addBean("LDAPTestBean", this);
+      runtimeContext.addBean("HibernateConfig", HibernateSupport.getConfig("proto"));
+      runtimeContext.start();
+      this.context = new IdentityContextImpl();
+      context.start();
+   }
+
+
+   public void testSimle() throws Exception
+   {
+      log.info("I'm here");
+
+      //SessionFactory sf = (SessionFactory)new InitialContext().lookup("java:/TestSessionFactory");
+
+
+      Session es = hibernate.openSession();
+      //Session es = session.getSession(EntityMode.MAP);
+      Map lolo = new HashMap();
+      lolo.put("userName", "lolo");
+      //lolo.put("roles", new HashSet());
+      es.save("PortalUser", lolo);
+      Map dummy = new HashMap();
+      dummy.put("name", "dummy");
+      es.save("PortalRole", dummy);
+
+      Set roles = new HashSet();
+      roles.add(dummy);
+      lolo.put("roles",roles);
+      Map props = new HashMap();
+      props.put("theme", "pp");
+      props.put("signature", "alalala");
+      lolo.put("dynamic", props);
+      es.save("PortalUser", lolo);
+      hibernate.commitTransaction();
+
+      hibernate.openSession();
+      es = hibernate.getCurrentSession();
+      Query query = es.createQuery("from PortalUser where userName=:userName");
+      query.setParameter("userName", "lolo");
+      lolo = (Map)query.uniqueResult();
+      assertNotNull(lolo.get("roles"));
+      assertNotNull(lolo.get("dynamic"));
+      hibernate.commitTransaction();
+
+      //hibernate.openSession();
+
+      //Session es = hibernate.getCurrentSession();
+      /*Session es = sf.openSession();
+      Transaction tx = es.beginTransaction();
+      Map lolo = new HashMap();
+      lolo.put("userName", "lolo");
+      es.save("PortalUser", lolo);
+      Query query = es.createQuery("from PortalUser where userName=:userName");
+      query.setParameter("userName", "lolo");
+      lolo = (Map)query.uniqueResult();
+      tx.commit();
+      //hibernate.commitTransaction();
+
+      
+      es = sf.getCurrentSession();
+      tx = es.beginTransaction();
+      query = es.createQuery("from PortalUser where userName=:userName");
+      query.setParameter("userName", "lolo");
+      lolo = (Map)query.uniqueResult();
+      //hibernate.commitTransaction();
+      tx.commit();*/
+   }
+
+
+}

Deleted: trunk/identity/src/main/org/jboss/portal/test/identity/UserTest.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/UserTest.java	2006-12-13 15:36:15 UTC (rev 5838)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/UserTest.java	2006-12-13 15:39:20 UTC (rev 5839)
@@ -1,393 +0,0 @@
-/******************************************************************************
- * 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.Assert;
-import org.jboss.portal.common.util.CollectionBuilder;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.Role;
-import org.jboss.portal.identity.RoleModule;
-import org.jboss.portal.identity.User;
-import org.jboss.portal.identity.UserModule;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class UserTest extends Assert
-{
-
-   /** . */
-   private UserModule userModule;
-
-   /** . */
-   private RoleModule roleModule;
-
-   /** . */
-   private Context ctx;
-
-   public void setUserModule(UserModule userModule)
-   {
-      this.userModule = userModule;
-   }
-
-   public void setRoleModule(RoleModule roleModule)
-   {
-      this.roleModule = roleModule;
-   }
-
-   public void setContext(Context ctx)
-   {
-      this.ctx = ctx;
-   }
-
-   public void testFindUsersUsingFilter() throws Exception
-   {
-      ctx.begin();
-      Set set1 = userModule.findUsersFilteredByUserName("user", 0, 10);
-      Set nameSet1 = new HashSet();
-      for (Iterator i = set1.iterator(); i.hasNext();)
-      {
-         User user = (User)i.next();
-         nameSet1.add(user.getUserName());
-      }
-      Set expectedNameSet1 = new HashSet();
-      expectedNameSet1.add("user1");
-      expectedNameSet1.add("user2");
-      assertEquals(expectedNameSet1, nameSet1);
-
-      //
-      Set set2 = userModule.findUsersFilteredByUserName("blah", 0, 10);
-      assertEquals(0, set2.size());
-
-      //
-      Set set3 = userModule.findUsersFilteredByUserName("", 0, 10);
-      Set nameSet3 = new HashSet();
-      for (Iterator i = set3.iterator(); i.hasNext();)
-      {
-         User user = (User)i.next();
-         nameSet3.add(user.getUserName());
-      }
-      Set expectedNameSet3 = new HashSet();
-      expectedNameSet3.add("user1");
-      expectedNameSet3.add("user2");
-      assertEquals(expectedNameSet3, nameSet3);
-
-      //
-      Set set4 = userModule.findUsersFilteredByUserName("user1", 0, 10);
-      Set nameSet4 = new HashSet();
-      for (Iterator i = set4.iterator(); i.hasNext();)
-      {
-         User user = (User)i.next();
-         nameSet4.add(user.getUserName());
-      }
-      Set expectedNameSet4 = new HashSet();
-      expectedNameSet4.add("user1");
-      assertEquals(expectedNameSet4, nameSet4);
-      ctx.commit();
-   }
-
-   public void testFindUser1() throws Exception
-   {
-      ctx.begin();
-      User u1 = userModule.findUserByUserName("user1");
-      assertNotNull(u1);
-      Assert.assertEquals("user1", u1.getUserName());
-      assertNotNull(roleModule.getRoles(u1));
-      Assert.assertEquals(1, roleModule.getRoles(u1).size());
-      Assert.assertEquals("role1", ((Role)roleModule.getRoles(u1).iterator().next()).getName());
-      Assert.assertEquals(u1.getId(), userModule.findUserById(u1.getId()).getId());
-      ctx.commit();
-   }
-
-   public void testFindUser2() throws Exception
-   {
-      ctx.begin();
-      Set roleNames = new HashSet(Arrays.asList(new Object[]{"role1", "role2"}));
-      User u2 = userModule.findUserByUserName("user2");
-      assertNotNull(u2);
-      Assert.assertEquals("user2", u2.getUserName());
-      assertNotNull(roleModule.getRoles(u2));
-      Assert.assertEquals(2, roleModule.getRoles(u2).size());
-      Iterator iterator = roleModule.getRoles(u2).iterator();
-      assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
-      assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
-      Assert.assertEquals(u2.getId(), userModule.findUserById(u2.getId()).getId());
-      ctx.commit();
-   }
-
-   public void testFindUsers() throws Exception
-   {
-      ctx.begin();
-      Set c1 = userModule.findUsers(0, 1);
-      assertNotNull(c1);
-      assertEquals(1, c1.size());
-
-      Set c2 = userModule.findUsers(1, 1);
-      assertNotNull(c2);
-      assertEquals(1, c2.size());
-
-      Set c3 = userModule.findUsers(0, 2);
-      assertNotNull(c3);
-      assertEquals(2, c3.size());
-
-      Set s1 = new HashSet();
-      s1.add(((User)c1.iterator().next()).getUserName());
-      s1.add(((User)c2.iterator().next()).getUserName());
-      Set s2 = new HashSet();
-      Iterator iterator = c3.iterator();
-      s2.add(((User)iterator.next()).getUserName());
-      s2.add(((User)iterator.next()).getUserName());
-      assertEquals(s1, s2);
-      ctx.commit();
-   }
-
-   public void testCreateUser() throws Exception
-   {
-      ctx.begin();
-      User u3 = userModule.createUser("user3", "password", "realemail");
-      Role g1 = roleModule.findRoleByName("role1");
-      roleModule.setRoles(u3, Collections.singleton(g1));
-      Assert.assertEquals("user3", u3.getUserName());
-      assertNotNull(roleModule.getRoles(u3));
-      Assert.assertEquals(1, roleModule.getRoles(u3).size());
-      Assert.assertEquals("role1", ((Role)roleModule.getRoles(u3).iterator().next()).getName());
-      ctx.commit();
-
-      ctx.begin();
-      u3 = userModule.findUserByUserName("user3");
-      assertNotNull(u3);
-      Assert.assertEquals("user3", u3.getUserName());
-      assertNotNull(roleModule.getRoles(u3));
-      Assert.assertEquals(1, roleModule.getRoles(u3).size());
-      Assert.assertEquals("role1", ((Role)roleModule.getRoles(u3).iterator().next()).getName());
-      ctx.commit();
-   }
-
-   //   public void testCreateDuplicateUser() throws Exception
-   //   {
-   //      try
-   //      {
-   //         userModule.createUser("user1");
-   //         fail("Expected exception on duplicate user");
-   //      }
-   //      catch (ModuleException expected)
-   //      {
-   //      }
-   //   }
-
-   public void testCreateRole() throws Exception
-   {
-      ctx.begin();
-      Role g3 = roleModule.createRole("role3", "roleName");
-      Assert.assertEquals("role3", g3.getName());
-      ctx.commit();
-
-      ctx.begin();
-      g3 = roleModule.findRoleByName("role3");
-      assertNotNull(g3);
-      Assert.assertEquals("role3", g3.getName());
-      ctx.commit();
-   }
-
-   //   public void testCreateDuplicateRole() throws Exception
-   //   {
-   //      try
-   //      {
-   //         roleModule.createRole("user1");
-   //         fail("Expected exception on duplicate role");
-   //      }
-   //      catch (ModuleException expected)
-   //      {
-   //      }
-   //   }
-
-   public void testCountUser() throws Exception
-   {
-      ctx.begin();
-      Assert.assertEquals(2, userModule.getUserCount());
-      ctx.commit();
-   }
-
-   public void testRemoveNonExistingRole() throws Exception
-   {
-      ctx.begin();
-      try
-      {
-         roleModule.removeRole(new Long(Long.MAX_VALUE));
-         fail("Expected exception");
-      }
-      catch (IdentityException expected)
-      {
-      }
-      ctx.commit();
-   }
-
-   public void testRemoveRole() throws Exception
-   {
-      ctx.begin();
-      Role g1 = roleModule.findRoleByName("role1");
-      Object id = g1.getId();
-      roleModule.removeRole(id);
-      try
-      {
-         roleModule.findRoleById(id);
-         fail("Expected exception");
-      }
-      catch (IdentityException expected)
-      {
-      }
-      ctx.commit();
-
-      ctx.begin();
-      try
-      {
-         roleModule.findRoleById(id);
-         fail("Expected exception");
-      }
-      catch (IdentityException expected)
-      {
-      }
-      User u1 = userModule.findUserByUserName("user1");
-      assertNotNull(u1);
-      Assert.assertEquals("user1", u1.getUserName());
-      ctx.commit();
-   }
-
-   public void testRemoveUser() throws Exception
-   {
-      ctx.begin();
-      User u1 = userModule.findUserByUserName("user1");
-      Object id = u1.getId();
-      userModule.removeUser(id);
-      try
-      {
-         userModule.findUserById(id);
-         fail("Expected exception");
-      }
-      catch (IdentityException expected)
-      {
-      }
-      ctx.commit();
-
-      ctx.begin();
-      try
-      {
-         userModule.findUserById(id);
-         fail("Expected exception");
-      }
-      catch (IdentityException expected)
-      {
-      }
-      Role g1 = roleModule.findRoleByName("role1");
-      assertNotNull(g1);
-      Assert.assertEquals("role1", g1.getName());
-      Role g2 = roleModule.findRoleByName("role2");
-      assertNotNull(g2);
-      Assert.assertEquals("role2", g2.getName());
-      ctx.commit();
-   }
-
-   public void testFindRoles() throws Exception
-   {
-      ctx.begin();
-      Set roleNames = new HashSet(Arrays.asList(new Object[]{"role1", "role2"}));
-      Set roles = roleModule.findRoles();
-      assertEquals(2, roles.size());
-      Iterator iterator = roles.iterator();
-      assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
-      assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
-      ctx.commit();
-   }
-
-   public void testFindRoleMembers() throws Exception
-   {
-      ctx.begin();
-      Set set1 = roleModule.findRoleMembers("role1", 0, 10, "user");
-      Set nameSet1 = new HashSet();
-      for (Iterator i = set1.iterator(); i.hasNext();)
-      {
-         User user = (User)i.next();
-         nameSet1.add(user.getUserName());
-      }
-      Set expectedNameSet1 = new HashSet();
-      expectedNameSet1.add("user1");
-      expectedNameSet1.add("user2");
-      assertEquals(expectedNameSet1, nameSet1);
-
-      //
-      Set set2 = roleModule.findRoleMembers("role1", 0, 10, "blah");
-      assertEquals(0, set2.size());
-
-      //
-      Set set3 = roleModule.findRoleMembers("role1", 0, 10, "");
-      Set nameSet3 = new HashSet();
-      for (Iterator i = set3.iterator(); i.hasNext();)
-      {
-         User user = (User)i.next();
-         nameSet3.add(user.getUserName());
-      }
-      Set expectedNameSet3 = new HashSet();
-      expectedNameSet3.add("user1");
-      expectedNameSet3.add("user2");
-      assertEquals(expectedNameSet3, nameSet3);
-
-      //
-      Set set4 = roleModule.findRoleMembers("role1", 0, 10, "user1");
-      Set nameSet4 = new HashSet();
-      for (Iterator i = set4.iterator(); i.hasNext();)
-      {
-         User user = (User)i.next();
-         nameSet4.add(user.getUserName());
-      }
-      Set expectedNameSet4 = new HashSet();
-      expectedNameSet4.add("user1");
-      assertEquals(expectedNameSet4, nameSet4);
-      ctx.commit();
-   }
-
-   public void populate() throws Exception
-   {
-      ctx.begin();
-      User u1 = userModule.createUser("user1", "", "");
-      User u2 = userModule.createUser("user2", "", "");
-      Role g1 = roleModule.createRole("role1", "role1");
-      Role g2 = roleModule.createRole("role2", "role2");
-      roleModule.setRoles(u1, Collections.singleton(g1));
-      roleModule.setRoles(u2, new CollectionBuilder().add(g1).add(g2).toHashSet());
-      ctx.commit();
-   }
-
-   public interface Context
-   {
-      void begin();
-
-      void commit();
-   }
-}

Added: trunk/identity/src/main/org/jboss/portal/test/identity/UserTest.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/UserTest.java	2006-12-13 15:36:15 UTC (rev 5838)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/UserTest.java	2006-12-13 15:39:20 UTC (rev 5839)
@@ -0,0 +1,411 @@
+/*
+* 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.Assert;
+import org.jboss.portal.identity2.UserModule;
+import org.jboss.portal.identity2.RoleModule;
+import org.jboss.portal.identity2.User;
+import org.jboss.portal.identity2.Role;
+import org.jboss.portal.identity2.MembershipModule;
+import org.jboss.portal.identity2.UserProfileModule;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.common.util.CollectionBuilder;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Arrays;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class UserTest extends Assert
+{
+
+   /** . */
+   private UserModule userModule;
+
+   /** . */
+   private RoleModule roleModule;
+
+   /** . */
+   private MembershipModule membershipModule;
+
+   /** . */
+   private UserProfileModule userProfileModule;
+
+   
+   /** . */
+   private UserTest.Context ctx;
+
+   public void setUserModule(UserModule userModule)
+   {
+      this.userModule = userModule;
+   }
+
+   public void setRoleModule(RoleModule roleModule)
+   {
+      this.roleModule = roleModule;
+   }
+
+   public void setMembershipModule(MembershipModule membershipModule)
+   {
+      this.membershipModule = membershipModule;
+   }
+
+   public void setUserProfileModule(UserProfileModule userProfileModule)
+   {
+      this.userProfileModule = userProfileModule;
+   }
+
+   public void setContext(UserTest.Context ctx)
+   {
+      this.ctx = ctx;
+   }
+
+   public void testFindUsersUsingFilter() throws Exception
+   {
+      ctx.begin();
+      Set set1 = userModule.findUsersFilteredByUserName("user", 0, 10);
+      Set nameSet1 = new HashSet();
+      for (Iterator i = set1.iterator(); i.hasNext();)
+      {
+         User user = (User)i.next();
+         nameSet1.add(user.getUserName());
+      }
+      Set expectedNameSet1 = new HashSet();
+      expectedNameSet1.add("user1");
+      expectedNameSet1.add("user2");
+      assertEquals(expectedNameSet1, nameSet1);
+
+      //
+      Set set2 = userModule.findUsersFilteredByUserName("blah", 0, 10);
+      assertEquals(0, set2.size());
+
+      //
+      Set set3 = userModule.findUsersFilteredByUserName("", 0, 10);
+      Set nameSet3 = new HashSet();
+      for (Iterator i = set3.iterator(); i.hasNext();)
+      {
+         User user = (User)i.next();
+         nameSet3.add(user.getUserName());
+      }
+      Set expectedNameSet3 = new HashSet();
+      expectedNameSet3.add("user1");
+      expectedNameSet3.add("user2");
+      assertEquals(expectedNameSet3, nameSet3);
+
+      //
+      Set set4 = userModule.findUsersFilteredByUserName("user1", 0, 10);
+      Set nameSet4 = new HashSet();
+      for (Iterator i = set4.iterator(); i.hasNext();)
+      {
+         User user = (User)i.next();
+         nameSet4.add(user.getUserName());
+      }
+      Set expectedNameSet4 = new HashSet();
+      expectedNameSet4.add("user1");
+      assertEquals(expectedNameSet4, nameSet4);
+      ctx.commit();
+   }
+
+   public void testFindUser1() throws Exception
+   {
+      ctx.begin();
+      User u1 = userModule.findUserByUserName("user1");
+      assertNotNull(u1);
+      Assert.assertEquals("user1", u1.getUserName());
+      assertNotNull(membershipModule.getRoles(u1));
+      Assert.assertEquals(1, membershipModule.getRoles(u1).size());
+      Assert.assertEquals("role1", ((Role)membershipModule.getRoles(u1).iterator().next()).getName());
+      Assert.assertEquals(u1.getId(), userModule.findUserById(u1.getId()).getId());
+      ctx.commit();
+   }
+
+   public void testFindUser2() throws Exception
+   {
+      ctx.begin();
+      Set roleNames = new HashSet(Arrays.asList(new Object[]{"role1", "role2"}));
+      User u2 = userModule.findUserByUserName("user2");
+      assertNotNull(u2);
+      Assert.assertEquals("user2", u2.getUserName());
+      assertNotNull(membershipModule.getRoles(u2));
+      Assert.assertEquals(2, membershipModule.getRoles(u2).size());
+      Iterator iterator = membershipModule.getRoles(u2).iterator();
+      assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
+      assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
+      Assert.assertEquals(u2.getId(), userModule.findUserById(u2.getId()).getId());
+      ctx.commit();
+   }
+
+   public void testFindUsers() throws Exception
+   {
+      ctx.begin();
+      Set c1 = userModule.findUsers(0, 1);
+      assertNotNull(c1);
+      assertEquals(1, c1.size());
+
+      Set c2 = userModule.findUsers(1, 1);
+      assertNotNull(c2);
+      assertEquals(1, c2.size());
+
+      Set c3 = userModule.findUsers(0, 2);
+      assertNotNull(c3);
+      assertEquals(2, c3.size());
+
+      Set s1 = new HashSet();
+      s1.add(((User)c1.iterator().next()).getUserName());
+      s1.add(((User)c2.iterator().next()).getUserName());
+      Set s2 = new HashSet();
+      Iterator iterator = c3.iterator();
+      s2.add(((User)iterator.next()).getUserName());
+      s2.add(((User)iterator.next()).getUserName());
+      assertEquals(s1, s2);
+      ctx.commit();
+   }
+
+   public void testCreateUser() throws Exception
+   {
+      ctx.begin();
+      User u3 = userModule.createUser("user3", "password");
+      Role g1 = roleModule.findRoleByName("role1");
+      membershipModule.assignRoles(u3, Collections.singleton(g1));
+      Assert.assertEquals("user3", u3.getUserName());
+      assertNotNull(membershipModule.getRoles(u3));
+      Assert.assertEquals(1, membershipModule.getRoles(u3).size());
+      Assert.assertEquals("role1", ((Role)membershipModule.getRoles(u3).iterator().next()).getName());
+      ctx.commit();
+
+      ctx.begin();
+      u3 = userModule.findUserByUserName("user3");
+      assertNotNull(u3);
+      Assert.assertEquals("user3", u3.getUserName());
+      assertNotNull(membershipModule.getRoles(u3));
+      Assert.assertEquals(1, membershipModule.getRoles(u3).size());
+      Assert.assertEquals("role1", ((Role)membershipModule.getRoles(u3).iterator().next()).getName());
+      ctx.commit();
+   }
+
+   //   public void testCreateDuplicateUser() throws Exception
+   //   {
+   //      try
+   //      {
+   //         userModule.createUser("user1");
+   //         fail("Expected exception on duplicate user");
+   //      }
+   //      catch (ModuleException expected)
+   //      {
+   //      }
+   //   }
+
+   public void testCreateRole() throws Exception
+   {
+      ctx.begin();
+      Role g3 = roleModule.createRole("role3", "roleName");
+      Assert.assertEquals("role3", g3.getName());
+      ctx.commit();
+
+      ctx.begin();
+      g3 = roleModule.findRoleByName("role3");
+      assertNotNull(g3);
+      Assert.assertEquals("role3", g3.getName());
+      ctx.commit();
+   }
+
+   //   public void testCreateDuplicateRole() throws Exception
+   //   {
+   //      try
+   //      {
+   //         roleModule.createRole("user1");
+   //         fail("Expected exception on duplicate role");
+   //      }
+   //      catch (ModuleException expected)
+   //      {
+   //      }
+   //   }
+
+   public void testCountUser() throws Exception
+   {
+      ctx.begin();
+      Assert.assertEquals(2, userModule.getUserCount());
+      ctx.commit();
+   }
+
+   public void testRemoveNonExistingRole() throws Exception
+   {
+      ctx.begin();
+      try
+      {
+         roleModule.removeRole(new Long(Long.MAX_VALUE));
+         fail("Expected exception");
+      }
+      catch (IdentityException expected)
+      {
+      }
+      ctx.commit();
+   }
+
+   public void testRemoveRole() throws Exception
+   {
+      ctx.begin();
+      Role g1 = roleModule.findRoleByName("role1");
+      Object id = g1.getId();
+      roleModule.removeRole(id);
+      try
+      {
+         roleModule.findRoleById(id);
+         fail("Expected exception");
+      }
+      catch (IdentityException expected)
+      {
+      }
+      ctx.commit();
+
+      ctx.begin();
+      try
+      {
+         roleModule.findRoleById(id);
+         fail("Expected exception");
+      }
+      catch (IdentityException expected)
+      {
+      }
+      User u1 = userModule.findUserByUserName("user1");
+      assertNotNull(u1);
+      Assert.assertEquals("user1", u1.getUserName());
+      ctx.commit();
+   }
+
+   public void testRemoveUser() throws Exception
+   {
+      ctx.begin();
+      User u1 = userModule.findUserByUserName("user1");
+      Object id = u1.getId();
+      userModule.removeUser(id);
+      try
+      {
+         userModule.findUserById(id);
+         fail("Expected exception");
+      }
+      catch (IdentityException expected)
+      {
+      }
+      ctx.commit();
+
+      ctx.begin();
+      try
+      {
+         userModule.findUserById(id);
+         fail("Expected exception");
+      }
+      catch (IdentityException expected)
+      {
+      }
+      Role g1 = roleModule.findRoleByName("role1");
+      assertNotNull(g1);
+      Assert.assertEquals("role1", g1.getName());
+      Role g2 = roleModule.findRoleByName("role2");
+      assertNotNull(g2);
+      Assert.assertEquals("role2", g2.getName());
+      ctx.commit();
+   }
+
+   public void testFindRoles() throws Exception
+   {
+      ctx.begin();
+      Set roleNames = new HashSet(Arrays.asList(new Object[]{"role1", "role2"}));
+      Set roles = roleModule.findRoles();
+      assertEquals(2, roles.size());
+      Iterator iterator = roles.iterator();
+      assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
+      assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
+      ctx.commit();
+   }
+
+   public void testFindRoleMembers() throws Exception
+   {
+      ctx.begin();
+      Set set1 = membershipModule.findRoleMembers("role1", 0, 10, "user");
+      Set nameSet1 = new HashSet();
+      for (Iterator i = set1.iterator(); i.hasNext();)
+      {
+         User user = (User)i.next();
+         nameSet1.add(user.getUserName());
+      }
+      Set expectedNameSet1 = new HashSet();
+      expectedNameSet1.add("user1");
+      expectedNameSet1.add("user2");
+      assertEquals(expectedNameSet1, nameSet1);
+
+      //
+      Set set2 = membershipModule.findRoleMembers("role1", 0, 10, "blah");
+      assertEquals(0, set2.size());
+
+      //
+      Set set3 = membershipModule.findRoleMembers("role1", 0, 10, "");
+      Set nameSet3 = new HashSet();
+      for (Iterator i = set3.iterator(); i.hasNext();)
+      {
+         User user = (User)i.next();
+         nameSet3.add(user.getUserName());
+      }
+      Set expectedNameSet3 = new HashSet();
+      expectedNameSet3.add("user1");
+      expectedNameSet3.add("user2");
+      assertEquals(expectedNameSet3, nameSet3);
+
+      //
+      Set set4 = membershipModule.findRoleMembers("role1", 0, 10, "user1");
+      Set nameSet4 = new HashSet();
+      for (Iterator i = set4.iterator(); i.hasNext();)
+      {
+         User user = (User)i.next();
+         nameSet4.add(user.getUserName());
+      }
+      Set expectedNameSet4 = new HashSet();
+      expectedNameSet4.add("user1");
+      assertEquals(expectedNameSet4, nameSet4);
+      ctx.commit();
+   }
+//
+   public void populate() throws Exception
+   {
+      ctx.begin();
+      User u1 = userModule.createUser("user1", "");
+      User u2 = userModule.createUser("user2", "");
+      Role g1 = roleModule.createRole("role1", "role1");
+      Role g2 = roleModule.createRole("role2", "role2");
+      membershipModule.assignRoles(u1, Collections.singleton(g1));
+      membershipModule.assignRoles(u2, new CollectionBuilder().add(g1).add(g2).toHashSet());
+      ctx.commit();
+   }
+
+   public interface Context
+   {
+      void begin();
+
+      void commit();
+   }
+}

Copied: trunk/identity/src/main/org/jboss/portal/test/identity/db_old (from rev 5770, trunk/identity/src/main/org/jboss/portal/test/identity/db)

Deleted: trunk/identity/src/main/org/jboss/portal/test/identity/db_old/DBUserTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/db/DBUserTestCase.java	2006-12-06 09:43:49 UTC (rev 5770)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/db_old/DBUserTestCase.java	2006-12-13 15:39:20 UTC (rev 5839)
@@ -1,326 +0,0 @@
-/******************************************************************************
- * 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.db;
-
-import junit.framework.TestSuite;
-import org.apache.log4j.Appender;
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.SimpleLayout;
-import org.jboss.portal.common.test.junit.POJOJUnitTest;
-import org.jboss.portal.common.test.junit.JUnitAdapter;
-import org.jboss.portal.common.p3p.P3PConstants;
-import org.jboss.portal.identity.ProfileMap;
-import org.jboss.portal.identity.User;
-import org.jboss.portal.identity.db.DBRoleModuleImpl;
-import org.jboss.portal.identity.db.DBUserModuleImpl;
-import org.jboss.portal.test.framework.TestRuntimeContext;
-import org.jboss.portal.test.framework.embedded.DataSourceSupport;
-import org.jboss.portal.test.framework.embedded.HibernateSupport;
-import org.jboss.portal.test.identity.UserTest;
-
-import java.net.URL;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class DBUserTestCase extends junit.framework.TestCase implements UserTest.Context
-{
-
-   static
-   {
-      Appender appender = new ConsoleAppender(new SimpleLayout());
-      Logger.getRoot().addAppender(appender);
-      Logger.getRoot().setLevel(Level.DEBUG);
-      Logger.getLogger("org.hibernate").setLevel(Level.ERROR);
-   }
-
-   public static TestSuite suite() throws Exception
-   {
-      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
-      Map parameterMap = new HashMap();
-      parameterMap.put("DataSourceConfig", DataSourceSupport.Config.fromXML2(configsURL));
-      POJOJUnitTest abc = new POJOJUnitTest(DBUserTestCase.class);
-      JUnitAdapter adapter = new JUnitAdapter(abc, parameterMap);
-      TestSuite suite = new TestSuite();
-      suite.addTest(adapter);
-      return suite;
-   }
-
-   /** . */
-   private DataSourceSupport.Config dataSourceConfigParameter;
-
-   /** . */
-   private TestRuntimeContext runtimeContext;
-
-   /** . */
-   private HibernateSupport hibernate;
-
-   /** . */
-   private UserTest utc;
-
-   /** . */
-   private DBUserModuleImpl userModule;
-
-   /** . */
-   private DBRoleModuleImpl roleModule;
-
-   public DataSourceSupport.Config getDataSourceConfigParameter()
-   {
-      return dataSourceConfigParameter;
-   }
-
-   public void setDataSourceConfigParameter(DataSourceSupport.Config dataSourceConfig)
-   {
-      this.dataSourceConfigParameter = dataSourceConfig;
-   }
-
-   public HibernateSupport getHibernate()
-   {
-      return hibernate;
-   }
-
-   public void setHibernate(HibernateSupport hibernate)
-   {
-      this.hibernate = hibernate;
-   }
-
-   public String getName()
-   {
-      return super.getName() + "," + dataSourceConfigParameter.getName();
-   }
-
-   public void setUp() throws Exception
-   {
-      runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/db-beans.xml");
-      runtimeContext.addBean("DBTestBean", this);
-      runtimeContext.addBean("DataSourceConfig", dataSourceConfigParameter);
-      runtimeContext.addBean("HibernateConfig", HibernateSupport.getConfig(dataSourceConfigParameter.getName()));
-      runtimeContext.start();
-
-      //
-      utc = new UserTest();
-      userModule = new DBUserModuleImpl();
-      userModule.setSessionFactoryJNDIName("java:/SessionFactory");
-      userModule.start();
-
-      //
-      roleModule = new DBRoleModuleImpl();
-      roleModule.setSessionFactoryJNDIName("java:/SessionFactory");
-      roleModule.start();
-
-      //
-      utc.setUserModule(userModule);
-      utc.setRoleModule(roleModule);
-      utc.setContext(this);
-      utc.populate();
-   }
-
-   public void tearDown() throws Exception
-   {
-      utc.setUserModule(null);
-      utc.setRoleModule(null);
-      utc.setContext(null);
-      utc = null;
-
-      //
-      roleModule.destroy();
-      userModule.destroy();
-      roleModule = null;
-      userModule = null;
-
-      //
-      runtimeContext.stop();
-   }
-
-
-   public void begin()
-   {
-      hibernate.openSession();
-   }
-
-   public void commit()
-   {
-      assertTrue(hibernate.commitTransaction());
-   }
-
-   //
-
-   public void testFindUsersUsingFilter() throws Exception
-   {
-      utc.testFindUsersUsingFilter();
-   }
-
-   public void testFindUser1() throws Exception
-   {
-      utc.testFindUser1();
-   }
-
-   public void testFindUser2() throws Exception
-   {
-      utc.testFindUser2();
-   }
-
-   public void testFindUsers() throws Exception
-   {
-      utc.testFindUsers();
-   }
-
-   public void testCreateUser() throws Exception
-   {
-      utc.testCreateUser();
-   }
-
-   public void testCreateRole() throws Exception
-   {
-      utc.testCreateRole();
-   }
-
-   public void testCountUser() throws Exception
-   {
-      utc.testCountUser();
-   }
-
-   public void testRemoveNonExistingRole() throws Exception
-   {
-      utc.testRemoveNonExistingRole();
-   }
-
-   public void testRemoveRole() throws Exception
-   {
-      utc.testRemoveRole();
-   }
-
-   public void testRemoveUser() throws Exception
-   {
-      utc.testRemoveUser();
-   }
-
-   public void testFindRoles() throws Exception
-   {
-      utc.testFindRoles();
-   }
-
-   public void testFindRoleMembers() throws Exception
-   {
-      utc.testFindRoleMembers();
-   }
-
-   public void testDynamicProperty() throws Exception
-   {
-      begin();
-      User user = userModule.createUser("testname", "testpassword", "testemail");
-      ProfileMap map = user.getProfile();
-      assertNull(map.get("foo"));
-      assertFalse(map.isReadOnly("foo"));
-      map.put("foo", "value");
-      assertEquals("value", map.get("foo"));
-      assertFalse(map.isReadOnly("foo"));
-      commit();
-
-      begin();
-      user = userModule.findUserByUserName("testname");
-      map = user.getProfile();
-      assertEquals("value", map.get("foo"));
-      assertFalse(map.isReadOnly("foo"));
-      commit();
-   }
-
-   public void testStaticProperty() throws Exception
-   {
-      begin();
-
-      //
-      User user = userModule.createUser("testname", "testpassword", "testemail");
-      ProfileMap map = user.getProfile();
-      assertEquals("testname", map.get(P3PConstants.INFO_USER_NAME_NICKNAME));
-
-      // Test cannot remove a static property
-      try
-      {
-         map.remove(P3PConstants.INFO_USER_NAME_GIVEN);
-         fail("Should not be capable to remove static property");
-      }
-      catch (IllegalArgumentException expected)
-      {
-      }
-
-      // Test read only property
-      assertTrue(map.isReadOnly(P3PConstants.INFO_USER_NAME_NICKNAME));
-      try
-      {
-         map.put(P3PConstants.INFO_USER_NAME_NICKNAME, "anothername");
-         fail("Should not be capable to modify a read only static property");
-      }
-      catch (IllegalArgumentException expected)
-      {
-      }
-
-      // Test non nullable and writable property
-      try
-      {
-         map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, null);
-         fail("Should not be capable to nullify a non nullable static property");
-      }
-      catch (NullPointerException expected)
-      {
-      }
-      map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "true");
-      assertEquals(true, user.getViewRealEmail());
-
-      // Test boolean property
-      map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "false");
-      assertEquals("false", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
-      assertEquals(false, user.getViewRealEmail());
-      map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "true");
-      assertEquals("true", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
-      assertEquals(true, user.getViewRealEmail());
-      user.setViewRealEmail(false);
-      assertEquals("false", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
-      assertEquals(false, user.getViewRealEmail());
-      user.setViewRealEmail(true);
-      assertEquals("true", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
-      assertEquals(true, user.getViewRealEmail());
-      try
-      {
-         map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "truee");
-         fail("Should not be capable to set a bad value to boolean property");
-      }
-      catch (IllegalArgumentException expected)
-      {
-      }
-
-      // Test date
-      Date date = user.getRegistrationDate();
-      SimpleDateFormat sdf = new SimpleDateFormat();
-      assertEquals(sdf.format(date), map.get(User.INFO_USER_REGISTRATION_DATE));
-
-      commit();
-   }
-}

Copied: trunk/identity/src/main/org/jboss/portal/test/identity/db_old/DBUserTestCase.java (from rev 5809, trunk/identity/src/main/org/jboss/portal/test/identity/db/DBUserTestCase.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/db/DBUserTestCase.java	2006-12-12 18:42:45 UTC (rev 5809)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/db_old/DBUserTestCase.java	2006-12-13 15:39:20 UTC (rev 5839)
@@ -0,0 +1,327 @@
+/******************************************************************************
+ * 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.db_old;
+
+import junit.framework.TestSuite;
+import org.apache.log4j.Appender;
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.SimpleLayout;
+import org.jboss.portal.common.test.junit.POJOJUnitTest;
+import org.jboss.portal.common.test.junit.JUnitAdapter;
+import org.jboss.portal.common.p3p.P3PConstants;
+import org.jboss.portal.identity.ProfileMap;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.db.DBRoleModuleImpl;
+import org.jboss.portal.identity.db.DBUserModuleImpl;
+import org.jboss.portal.test.framework.TestRuntimeContext;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.embedded.HibernateSupport;
+import org.jboss.portal.test.identity.db_old.UserTest;
+
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class DBUserTestCase extends junit.framework.TestCase implements UserTest.Context
+{
+
+   static
+   {
+      Appender appender = new ConsoleAppender(new SimpleLayout());
+      Logger.getRoot().addAppender(appender);
+      Logger.getRoot().setLevel(Level.DEBUG);
+      Logger.getLogger("org.hibernate").setLevel(Level.ERROR);
+   }
+
+   public static TestSuite suite() throws Exception
+   {
+      URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+      Map parameterMap = new HashMap();
+      parameterMap.put("DataSourceConfig", DataSourceSupport.Config.fromXML2(configsURL));
+      POJOJUnitTest abc = new POJOJUnitTest(DBUserTestCase.class);
+      JUnitAdapter adapter = new JUnitAdapter(abc, parameterMap);
+      TestSuite suite = new TestSuite();
+      suite.addTest(adapter);
+      return suite;
+   }
+
+   /** . */
+   private DataSourceSupport.Config dataSourceConfigParameter;
+
+   /** . */
+   private TestRuntimeContext runtimeContext;
+
+   /** . */
+   private HibernateSupport hibernate;
+
+   /** . */
+   private UserTest utc;
+
+   /** . */
+   private DBUserModuleImpl userModule;
+
+   /** . */
+   private DBRoleModuleImpl roleModule;
+
+   public DataSourceSupport.Config getDataSourceConfigParameter()
+   {
+      return dataSourceConfigParameter;
+   }
+
+   public void setDataSourceConfigParameter(DataSourceSupport.Config dataSourceConfig)
+   {
+      this.dataSourceConfigParameter = dataSourceConfig;
+   }
+
+   public HibernateSupport getHibernate()
+   {
+      return hibernate;
+   }
+
+   public void setHibernate(HibernateSupport hibernate)
+   {
+      this.hibernate = hibernate;
+   }
+
+   public String getName()
+   {
+      return super.getName() + "," + dataSourceConfigParameter.getName();
+   }
+
+   public void setUp() throws Exception
+   {
+      runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/db_old-beans.xml");
+      runtimeContext.addBean("DBTestBean", this);
+      runtimeContext.addBean("DataSourceConfig", dataSourceConfigParameter);
+      runtimeContext.addBean("HibernateConfig", HibernateSupport.getConfig(dataSourceConfigParameter.getName()));
+      runtimeContext.start();
+
+      //HibernateSupport.getConfig(dataSourceConfigParameter.getName()).
+      //
+      utc = new UserTest();
+      userModule = new DBUserModuleImpl();
+      userModule.setSessionFactoryJNDIName("java:/SessionFactory");
+      userModule.start();
+
+      //
+      roleModule = new DBRoleModuleImpl();
+      roleModule.setSessionFactoryJNDIName("java:/SessionFactory");
+      roleModule.start();
+
+      //
+      utc.setUserModule(userModule);
+      utc.setRoleModule(roleModule);
+      utc.setContext(this);
+      utc.populate();
+   }
+
+   public void tearDown() throws Exception
+   {
+      utc.setUserModule(null);
+      utc.setRoleModule(null);
+      utc.setContext(null);
+      utc = null;
+
+      //
+      roleModule.destroy();
+      userModule.destroy();
+      roleModule = null;
+      userModule = null;
+
+      //
+      runtimeContext.stop();
+   }
+
+
+   public void begin()
+   {
+      hibernate.openSession();
+   }
+
+   public void commit()
+   {
+      assertTrue(hibernate.commitTransaction());
+   }
+
+   //
+
+   public void testFindUsersUsingFilter() throws Exception
+   {
+      utc.testFindUsersUsingFilter();
+   }
+
+   public void testFindUser1() throws Exception
+   {
+      utc.testFindUser1();
+   }
+
+   public void testFindUser2() throws Exception
+   {
+      utc.testFindUser2();
+   }
+
+   public void testFindUsers() throws Exception
+   {
+      utc.testFindUsers();
+   }
+
+   public void testCreateUser() throws Exception
+   {
+      utc.testCreateUser();
+   }
+
+   public void testCreateRole() throws Exception
+   {
+      utc.testCreateRole();
+   }
+
+   public void testCountUser() throws Exception
+   {
+      utc.testCountUser();
+   }
+
+   public void testRemoveNonExistingRole() throws Exception
+   {
+      utc.testRemoveNonExistingRole();
+   }
+
+   public void testRemoveRole() throws Exception
+   {
+      utc.testRemoveRole();
+   }
+
+   public void testRemoveUser() throws Exception
+   {
+      utc.testRemoveUser();
+   }
+
+   public void testFindRoles() throws Exception
+   {
+      utc.testFindRoles();
+   }
+
+   public void testFindRoleMembers() throws Exception
+   {
+      utc.testFindRoleMembers();
+   }
+
+   public void testDynamicProperty() throws Exception
+   {
+      begin();
+      User user = userModule.createUser("testname", "testpassword", "testemail");
+      ProfileMap map = user.getProfile();
+      assertNull(map.get("foo"));
+      assertFalse(map.isReadOnly("foo"));
+      map.put("foo", "value");
+      assertEquals("value", map.get("foo"));
+      assertFalse(map.isReadOnly("foo"));
+      commit();
+
+      begin();
+      user = userModule.findUserByUserName("testname");
+      map = user.getProfile();
+      assertEquals("value", map.get("foo"));
+      assertFalse(map.isReadOnly("foo"));
+      commit();
+   }
+
+   public void testStaticProperty() throws Exception
+   {
+      begin();
+
+      //
+      User user = userModule.createUser("testname", "testpassword", "testemail");
+      ProfileMap map = user.getProfile();
+      assertEquals("testname", map.get(P3PConstants.INFO_USER_NAME_NICKNAME));
+
+      // Test cannot remove a static property
+      try
+      {
+         map.remove(P3PConstants.INFO_USER_NAME_GIVEN);
+         fail("Should not be capable to remove static property");
+      }
+      catch (IllegalArgumentException expected)
+      {
+      }
+
+      // Test read only property
+      assertTrue(map.isReadOnly(P3PConstants.INFO_USER_NAME_NICKNAME));
+      try
+      {
+         map.put(P3PConstants.INFO_USER_NAME_NICKNAME, "anothername");
+         fail("Should not be capable to modify a read only static property");
+      }
+      catch (IllegalArgumentException expected)
+      {
+      }
+
+      // Test non nullable and writable property
+      try
+      {
+         map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, null);
+         fail("Should not be capable to nullify a non nullable static property");
+      }
+      catch (NullPointerException expected)
+      {
+      }
+      map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "true");
+      assertEquals(true, user.getViewRealEmail());
+
+      // Test boolean property
+      map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "false");
+      assertEquals("false", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+      assertEquals(false, user.getViewRealEmail());
+      map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "true");
+      assertEquals("true", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+      assertEquals(true, user.getViewRealEmail());
+      user.setViewRealEmail(false);
+      assertEquals("false", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+      assertEquals(false, user.getViewRealEmail());
+      user.setViewRealEmail(true);
+      assertEquals("true", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+      assertEquals(true, user.getViewRealEmail());
+      try
+      {
+         map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "truee");
+         fail("Should not be capable to set a bad value to boolean property");
+      }
+      catch (IllegalArgumentException expected)
+      {
+      }
+
+      // Test date
+      Date date = user.getRegistrationDate();
+      SimpleDateFormat sdf = new SimpleDateFormat();
+      assertEquals(sdf.format(date), map.get(User.INFO_USER_REGISTRATION_DATE));
+
+      commit();
+   }
+}

Copied: trunk/identity/src/main/org/jboss/portal/test/identity/db_old/UserTest.java (from rev 5770, trunk/identity/src/main/org/jboss/portal/test/identity/UserTest.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/UserTest.java	2006-12-06 09:43:49 UTC (rev 5770)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/db_old/UserTest.java	2006-12-13 15:39:20 UTC (rev 5839)
@@ -0,0 +1,393 @@
+/******************************************************************************
+ * 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.db_old;
+
+import junit.framework.Assert;
+import org.jboss.portal.common.util.CollectionBuilder;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserModule;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class UserTest extends Assert
+{
+
+   /** . */
+   private UserModule userModule;
+
+   /** . */
+   private RoleModule roleModule;
+
+   /** . */
+   private Context ctx;
+
+   public void setUserModule(UserModule userModule)
+   {
+      this.userModule = userModule;
+   }
+
+   public void setRoleModule(RoleModule roleModule)
+   {
+      this.roleModule = roleModule;
+   }
+
+   public void setContext(Context ctx)
+   {
+      this.ctx = ctx;
+   }
+
+   public void testFindUsersUsingFilter() throws Exception
+   {
+      ctx.begin();
+      Set set1 = userModule.findUsersFilteredByUserName("user", 0, 10);
+      Set nameSet1 = new HashSet();
+      for (Iterator i = set1.iterator(); i.hasNext();)
+      {
+         User user = (User)i.next();
+         nameSet1.add(user.getUserName());
+      }
+      Set expectedNameSet1 = new HashSet();
+      expectedNameSet1.add("user1");
+      expectedNameSet1.add("user2");
+      assertEquals(expectedNameSet1, nameSet1);
+
+      //
+      Set set2 = userModule.findUsersFilteredByUserName("blah", 0, 10);
+      assertEquals(0, set2.size());
+
+      //
+      Set set3 = userModule.findUsersFilteredByUserName("", 0, 10);
+      Set nameSet3 = new HashSet();
+      for (Iterator i = set3.iterator(); i.hasNext();)
+      {
+         User user = (User)i.next();
+         nameSet3.add(user.getUserName());
+      }
+      Set expectedNameSet3 = new HashSet();
+      expectedNameSet3.add("user1");
+      expectedNameSet3.add("user2");
+      assertEquals(expectedNameSet3, nameSet3);
+
+      //
+      Set set4 = userModule.findUsersFilteredByUserName("user1", 0, 10);
+      Set nameSet4 = new HashSet();
+      for (Iterator i = set4.iterator(); i.hasNext();)
+      {
+         User user = (User)i.next();
+         nameSet4.add(user.getUserName());
+      }
+      Set expectedNameSet4 = new HashSet();
+      expectedNameSet4.add("user1");
+      assertEquals(expectedNameSet4, nameSet4);
+      ctx.commit();
+   }
+
+   public void testFindUser1() throws Exception
+   {
+      ctx.begin();
+      User u1 = userModule.findUserByUserName("user1");
+      assertNotNull(u1);
+      Assert.assertEquals("user1", u1.getUserName());
+      assertNotNull(roleModule.getRoles(u1));
+      Assert.assertEquals(1, roleModule.getRoles(u1).size());
+      Assert.assertEquals("role1", ((Role)roleModule.getRoles(u1).iterator().next()).getName());
+      Assert.assertEquals(u1.getId(), userModule.findUserById(u1.getId()).getId());
+      ctx.commit();
+   }
+
+   public void testFindUser2() throws Exception
+   {
+      ctx.begin();
+      Set roleNames = new HashSet(Arrays.asList(new Object[]{"role1", "role2"}));
+      User u2 = userModule.findUserByUserName("user2");
+      assertNotNull(u2);
+      Assert.assertEquals("user2", u2.getUserName());
+      assertNotNull(roleModule.getRoles(u2));
+      Assert.assertEquals(2, roleModule.getRoles(u2).size());
+      Iterator iterator = roleModule.getRoles(u2).iterator();
+      assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
+      assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
+      Assert.assertEquals(u2.getId(), userModule.findUserById(u2.getId()).getId());
+      ctx.commit();
+   }
+
+   public void testFindUsers() throws Exception
+   {
+      ctx.begin();
+      Set c1 = userModule.findUsers(0, 1);
+      assertNotNull(c1);
+      assertEquals(1, c1.size());
+
+      Set c2 = userModule.findUsers(1, 1);
+      assertNotNull(c2);
+      assertEquals(1, c2.size());
+
+      Set c3 = userModule.findUsers(0, 2);
+      assertNotNull(c3);
+      assertEquals(2, c3.size());
+
+      Set s1 = new HashSet();
+      s1.add(((User)c1.iterator().next()).getUserName());
+      s1.add(((User)c2.iterator().next()).getUserName());
+      Set s2 = new HashSet();
+      Iterator iterator = c3.iterator();
+      s2.add(((User)iterator.next()).getUserName());
+      s2.add(((User)iterator.next()).getUserName());
+      assertEquals(s1, s2);
+      ctx.commit();
+   }
+
+   public void testCreateUser() throws Exception
+   {
+      ctx.begin();
+      User u3 = userModule.createUser("user3", "password", "realemail");
+      Role g1 = roleModule.findRoleByName("role1");
+      roleModule.setRoles(u3, Collections.singleton(g1));
+      Assert.assertEquals("user3", u3.getUserName());
+      assertNotNull(roleModule.getRoles(u3));
+      Assert.assertEquals(1, roleModule.getRoles(u3).size());
+      Assert.assertEquals("role1", ((Role)roleModule.getRoles(u3).iterator().next()).getName());
+      ctx.commit();
+
+      ctx.begin();
+      u3 = userModule.findUserByUserName("user3");
+      assertNotNull(u3);
+      Assert.assertEquals("user3", u3.getUserName());
+      assertNotNull(roleModule.getRoles(u3));
+      Assert.assertEquals(1, roleModule.getRoles(u3).size());
+      Assert.assertEquals("role1", ((Role)roleModule.getRoles(u3).iterator().next()).getName());
+      ctx.commit();
+   }
+
+   //   public void testCreateDuplicateUser() throws Exception
+   //   {
+   //      try
+   //      {
+   //         userModule.createUser("user1");
+   //         fail("Expected exception on duplicate user");
+   //      }
+   //      catch (ModuleException expected)
+   //      {
+   //      }
+   //   }
+
+   public void testCreateRole() throws Exception
+   {
+      ctx.begin();
+      Role g3 = roleModule.createRole("role3", "roleName");
+      Assert.assertEquals("role3", g3.getName());
+      ctx.commit();
+
+      ctx.begin();
+      g3 = roleModule.findRoleByName("role3");
+      assertNotNull(g3);
+      Assert.assertEquals("role3", g3.getName());
+      ctx.commit();
+   }
+
+   //   public void testCreateDuplicateRole() throws Exception
+   //   {
+   //      try
+   //      {
+   //         roleModule.createRole("user1");
+   //         fail("Expected exception on duplicate role");
+   //      }
+   //      catch (ModuleException expected)
+   //      {
+   //      }
+   //   }
+
+   public void testCountUser() throws Exception
+   {
+      ctx.begin();
+      Assert.assertEquals(2, userModule.getUserCount());
+      ctx.commit();
+   }
+
+   public void testRemoveNonExistingRole() throws Exception
+   {
+      ctx.begin();
+      try
+      {
+         roleModule.removeRole(new Long(Long.MAX_VALUE));
+         fail("Expected exception");
+      }
+      catch (IdentityException expected)
+      {
+      }
+      ctx.commit();
+   }
+
+   public void testRemoveRole() throws Exception
+   {
+      ctx.begin();
+      Role g1 = roleModule.findRoleByName("role1");
+      Object id = g1.getId();
+      roleModule.removeRole(id);
+      try
+      {
+         roleModule.findRoleById(id);
+         fail("Expected exception");
+      }
+      catch (IdentityException expected)
+      {
+      }
+      ctx.commit();
+
+      ctx.begin();
+      try
+      {
+         roleModule.findRoleById(id);
+         fail("Expected exception");
+      }
+      catch (IdentityException expected)
+      {
+      }
+      User u1 = userModule.findUserByUserName("user1");
+      assertNotNull(u1);
+      Assert.assertEquals("user1", u1.getUserName());
+      ctx.commit();
+   }
+
+   public void testRemoveUser() throws Exception
+   {
+      ctx.begin();
+      User u1 = userModule.findUserByUserName("user1");
+      Object id = u1.getId();
+      userModule.removeUser(id);
+      try
+      {
+         userModule.findUserById(id);
+         fail("Expected exception");
+      }
+      catch (IdentityException expected)
+      {
+      }
+      ctx.commit();
+
+      ctx.begin();
+      try
+      {
+         userModule.findUserById(id);
+         fail("Expected exception");
+      }
+      catch (IdentityException expected)
+      {
+      }
+      Role g1 = roleModule.findRoleByName("role1");
+      assertNotNull(g1);
+      Assert.assertEquals("role1", g1.getName());
+      Role g2 = roleModule.findRoleByName("role2");
+      assertNotNull(g2);
+      Assert.assertEquals("role2", g2.getName());
+      ctx.commit();
+   }
+
+   public void testFindRoles() throws Exception
+   {
+      ctx.begin();
+      Set roleNames = new HashSet(Arrays.asList(new Object[]{"role1", "role2"}));
+      Set roles = roleModule.findRoles();
+      assertEquals(2, roles.size());
+      Iterator iterator = roles.iterator();
+      assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
+      assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
+      ctx.commit();
+   }
+
+   public void testFindRoleMembers() throws Exception
+   {
+      ctx.begin();
+      Set set1 = roleModule.findRoleMembers("role1", 0, 10, "user");
+      Set nameSet1 = new HashSet();
+      for (Iterator i = set1.iterator(); i.hasNext();)
+      {
+         User user = (User)i.next();
+         nameSet1.add(user.getUserName());
+      }
+      Set expectedNameSet1 = new HashSet();
+      expectedNameSet1.add("user1");
+      expectedNameSet1.add("user2");
+      assertEquals(expectedNameSet1, nameSet1);
+
+      //
+      Set set2 = roleModule.findRoleMembers("role1", 0, 10, "blah");
+      assertEquals(0, set2.size());
+
+      //
+      Set set3 = roleModule.findRoleMembers("role1", 0, 10, "");
+      Set nameSet3 = new HashSet();
+      for (Iterator i = set3.iterator(); i.hasNext();)
+      {
+         User user = (User)i.next();
+         nameSet3.add(user.getUserName());
+      }
+      Set expectedNameSet3 = new HashSet();
+      expectedNameSet3.add("user1");
+      expectedNameSet3.add("user2");
+      assertEquals(expectedNameSet3, nameSet3);
+
+      //
+      Set set4 = roleModule.findRoleMembers("role1", 0, 10, "user1");
+      Set nameSet4 = new HashSet();
+      for (Iterator i = set4.iterator(); i.hasNext();)
+      {
+         User user = (User)i.next();
+         nameSet4.add(user.getUserName());
+      }
+      Set expectedNameSet4 = new HashSet();
+      expectedNameSet4.add("user1");
+      assertEquals(expectedNameSet4, nameSet4);
+      ctx.commit();
+   }
+
+   public void populate() throws Exception
+   {
+      ctx.begin();
+      User u1 = userModule.createUser("user1", "", "");
+      User u2 = userModule.createUser("user2", "", "");
+      Role g1 = roleModule.createRole("role1", "role1");
+      Role g2 = roleModule.createRole("role2", "role2");
+      roleModule.setRoles(u1, Collections.singleton(g1));
+      roleModule.setRoles(u2, new CollectionBuilder().add(g1).add(g2).toHashSet());
+      ctx.commit();
+   }
+
+   public interface Context
+   {
+      void begin();
+
+      void commit();
+   }
+}


Property changes on: trunk/identity/src/main/org/jboss/portal/test/identity/db_old/UserTest.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java	2006-12-13 15:36:15 UTC (rev 5838)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java	2006-12-13 15:39:20 UTC (rev 5839)
@@ -85,7 +85,7 @@
 
       IdentityServiceControllerImpl controller = new IdentityServiceControllerImpl();
       controller.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
-      controller.setDefaultConfigFile("identityconfig/standardidentity-config.xml");
+      controller.setDefaultConfigFile("test/config/standardidentity-config.xml");
       controller.setRegisterMBeans(false);
       controller.start();
       identityContext = controller.getIdentityContext();

Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java	2006-12-13 15:36:15 UTC (rev 5838)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java	2006-12-13 15:39:20 UTC (rev 5839)
@@ -83,7 +83,7 @@
 
       IdentityServiceControllerImpl controller = new IdentityServiceControllerImpl();
       controller.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
-      controller.setDefaultConfigFile("identityconfig/standardidentity-config.xml");
+      controller.setDefaultConfigFile("test/config/standardidentity-config.xml");
       controller.setRegisterMBeans(false);
       controller.start();
       identityContext = controller.getIdentityContext();
@@ -120,7 +120,7 @@
 
    public void testCreateUser() throws Exception
    {
-      LDAPUserImpl ldapu = (LDAPUserImpl)userModule.createUser("testUser", "testPassword", "email");
+      LDAPUserImpl ldapu = (LDAPUserImpl)userModule.createUser("testUser", "testPassword");
       assertNotNull(ldapu);
       assertEquals("testUser", ldapu.getUserName());
 

Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java	2006-12-13 15:36:15 UTC (rev 5838)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java	2006-12-13 15:39:20 UTC (rev 5839)
@@ -79,7 +79,7 @@
 
       IdentityServiceControllerImpl controller = new IdentityServiceControllerImpl();
       controller.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
-      controller.setDefaultConfigFile("identityconfig/standardidentity-config.xml");
+      controller.setDefaultConfigFile("test/config/standardidentity-config.xml");
       controller.setRegisterMBeans(false);
       controller.start();
       identityContext = controller.getIdentityContext();

Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java	2006-12-13 15:36:15 UTC (rev 5838)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java	2006-12-13 15:39:20 UTC (rev 5839)
@@ -76,7 +76,7 @@
 
       IdentityServiceControllerImpl controller = new IdentityServiceControllerImpl();
       controller.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
-      controller.setDefaultConfigFile("identityconfig/standardidentity-config.xml");
+      controller.setDefaultConfigFile("test/config/standardidentity-config.xml");
       controller.setRegisterMBeans(false);
       controller.start();
       identityContext = controller.getIdentityContext();




More information about the portal-commits mailing list