Author: bdaw
Date: 2009-03-18 11:20:34 -0400 (Wed, 18 Mar 2009)
New Revision: 378
Added:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
Log:
- More test cases and bug fixes
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-03-17
21:38:45 UTC (rev 377)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-03-18
15:20:34 UTC (rev 378)
@@ -203,7 +203,7 @@
}
- protected IdentityObjectType getIdentityObjectType()
+ protected IdentityObjectType getUserObjectType()
{
return getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java 2009-03-17
21:38:45 UTC (rev 377)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java 2009-03-18
15:20:34 UTC (rev 378)
@@ -126,7 +126,7 @@
public User createUser(String identityName) throws IdentityException
{
- IdentityObjectType iot = getIdentityObjectType();
+ IdentityObjectType iot = getUserObjectType();
IdentityObject identityObject =
getRepository().createIdentityObject(getInvocationContext(), identityName, iot);
@@ -173,7 +173,7 @@
public int getUserCount() throws IdentityException
{
- IdentityObjectType iot = getIdentityObjectType();
+ IdentityObjectType iot = getUserObjectType();
return getRepository().getIdentityObjectsCount(getInvocationContext(), iot);
}
@@ -187,19 +187,14 @@
public User findUser(String name) throws IdentityException
{
- return createUser(getRepository().findIdentityObject(getInvocationContext(), name,
getIdentityObjectType()));
+ return createUser(getRepository().findIdentityObject(getInvocationContext(), name,
getUserObjectType()));
}
- public User findUserById(String id) throws IdentityException
- {
- return createUser(getRepository().findIdentityObject(getInvocationContext(), id));
- }
-
public Collection<User> findUser(IdentitySearchControl[] controls) throws
IdentityException
{
- Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), getIdentityObjectType(),
convertSearchControls(controls));
+ Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), getUserObjectType(),
convertSearchControls(controls));
List<User> identities = new LinkedList<User>();
for (Iterator<IdentityObject> iterator = ios.iterator();
iterator.hasNext();)
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-17
21:38:45 UTC (rev 377)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-18
15:20:34 UTC (rev 378)
@@ -472,11 +472,14 @@
Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(group),
MEMBER, true, convertSearchControls(controls));
- //TODO: filter out groups....
+ String userTypeName = getUserObjectType().getName();
for (IdentityObject io : ios)
{
- identities.add(createUser(io));
+ if (io.getIdentityType().getName().equals(userTypeName))
+ {
+ identities.add(createUser(io));
+ }
}
return identities;
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java 2009-03-17
21:38:45 UTC (rev 377)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java 2009-03-18
15:20:34 UTC (rev 378)
@@ -727,7 +727,10 @@
// Simple
- Fqn fqn = Fqn.fromElements(RELATIONSHIPS_SEARCH_SIMPLE_NODE, fromName, toName,
relationshipType.getName());
+// Fqn fqn = Fqn.fromElements(RELATIONSHIPS_SEARCH_SIMPLE_NODE, fromName, toName,
relationshipType.getName());
+// getCache().getRoot().removeChild(fqn);
+
+ Fqn fqn = createRelationshipsSimpleSearchFqn(fromIdentity, toIdentity,
relationshipType);
getCache().getRoot().removeChild(fqn);
// Complex
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-03-17
21:38:45 UTC (rev 377)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-03-18
15:20:34 UTC (rev 378)
@@ -260,8 +260,12 @@
String relationshipName,
boolean createNames) throws
IdentityException
{
+ invalidateCachedRelationshipSearches(fromIdentity, toIdentity, relationshipType,
relationshipName);
+
return identityStore.createRelationship(invocationCxt,
fromIdentity, toIdentity, relationshipType, relationshipName, createNames);
+
+
}
public void removeRelationship(IdentityStoreInvocationContext invocationCxt,
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-03-17
21:38:45 UTC (rev 377)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-03-18
15:20:34 UTC (rev 378)
@@ -1341,7 +1341,6 @@
//TODO: impl lacks support for rel type
relationships.add(new LDAPIdentityObjectRelationshipImpl(null,
ldapFromIO, ldapToIO));
}
- break;
}
}
Copied: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java (from
rev 377, idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java)
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java
(rev 0)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java 2009-03-18
15:20:34 UTC (rev 378)
@@ -0,0 +1,157 @@
+/*
+* 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.identity.idm.impl.api;
+
+import junit.framework.TestCase;
+import org.jboss.identity.idm.impl.HibernateTestSupport;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
+import org.jboss.identity.idm.opends.OpenDSService;
+import org.opends.server.tools.LDAPModify;
+
+import javax.naming.directory.DirContext;
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.Binding;
+import javax.naming.ldap.InitialLdapContext;
+import java.util.Hashtable;
+import java.io.File;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class APITestBase extends TestCase implements APITestContext
+{
+ HibernateTestSupport hibernateSupport =
+ new HibernateTestSupport("unit-testing-jpa1",
"hibernate-jboss-identity-classes.cfg.xml");
+
+ IdentitySessionFactory identitySessionFactory;
+
+ public static final String LDAP_HOST = "localhost";
+
+ public static final String LDAP_PORT = "10389";
+
+ public static final String LDAP_PROVIDER_URL = "ldap://" + LDAP_HOST +
":" + LDAP_PORT;
+
+ public static final String LDAP_PRINCIPAL = "cn=Directory Manager";
+
+ public static final String LDAP_CREDENTIALS = "password";
+
+ static Hashtable<String,String> env = new Hashtable<String,String>();
+
+ static
+ {
+ env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
+ env.put(Context.PROVIDER_URL, LDAP_PROVIDER_URL);
+ env.put(Context.SECURITY_AUTHENTICATION, "simple");
+ env.put(Context.SECURITY_PRINCIPAL, LDAP_PRINCIPAL);
+ env.put(Context.SECURITY_CREDENTIALS, LDAP_CREDENTIALS);
+ }
+
+ OpenDSService openDSService = new
OpenDSService("target/test-classes/opends");
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ hibernateSupport.start();
+ openDSService.start();
+
+ }
+
+ protected void tearDown() throws Exception
+ {
+ hibernateSupport.stop();
+
+ cleanUp(new InitialLdapContext(env, null));
+
+ openDSService.stop();
+ }
+
+ public IdentitySessionFactory getIdentitySessionFactory()
+ {
+ return identitySessionFactory;
+ }
+
+ public void populate() throws Exception
+ {
+ populateLDIF("target/test-classes/ldap/initial-opends.ldif");
+ }
+
+ public void populateClean() throws Exception
+ {
+ populateLDIF("target/test-classes/ldap/initial-empty-opends.ldif");
+ }
+
+ public void populateLDIF(String ldifRelativePath) throws Exception
+ {
+ File ldif = new File(ldifRelativePath);
+
+ System.out.println("LDIF: " + ldif.getAbsolutePath());
+
+ String[] cmd = new String[] {"-h", LDAP_HOST,
+ "-p", LDAP_PORT,
+ "-D", LDAP_PRINCIPAL,
+ "-w", LDAP_CREDENTIALS,
+ "-a", "-f", ldif.getPath()};
+
+ System.out.println("Populate success: " + (LDAPModify.mainModify(cmd,
false, System.out, System.err) == 0));
+
+ }
+
+ protected void cleanUp(DirContext ldapCtx) throws Exception
+ {
+ try
+ {
+ String dn = "dc=portal,dc=example,dc=com";
+
+ System.out.println("Removing: " + dn);
+
+ removeContext(ldapCtx, dn);
+ }
+ catch (Exception e)
+ {
+ //
+ }
+ }
+
+ //subsequent remove of javax.naming.Context
+ protected void removeContext(Context mainCtx, String name) throws Exception
+ {
+ Context deleteCtx = (Context)mainCtx.lookup(name);
+ NamingEnumeration subDirs = mainCtx.listBindings(name);
+
+ while (subDirs.hasMoreElements())
+ {
+ Binding binding = (Binding)subDirs.nextElement();
+ String subName = binding.getName();
+
+ removeContext(deleteCtx, subName);
+ }
+
+ mainCtx.unbind(name);
+ }
+
+
+}
\ No newline at end of file
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-03-17
21:38:45 UTC (rev 377)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-03-18
15:20:34 UTC (rev 378)
@@ -42,159 +42,62 @@
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
*/
-public class APITestCase extends TestCase implements APITestContext
+public class APITestCase extends APITestBase
{
- HibernateTestSupport hibernateSupport =
- new HibernateTestSupport("unit-testing-jpa1",
"hibernate-jboss-identity-classes.cfg.xml");
- OrganizationTest orgTest;
+ PersistenceManagerTest persistenceManagerTest;
- IdentitySessionFactory identitySessionFactory;
+ RelationshipManagerTest relationshipManagerTest;
- public static final String LDAP_HOST = "localhost";
-
- public static final String LDAP_PORT = "10389";
-
- public static final String LDAP_PROVIDER_URL = "ldap://" + LDAP_HOST +
":" + LDAP_PORT;
-
- public static final String LDAP_PRINCIPAL = "cn=Directory Manager";
-
- public static final String LDAP_CREDENTIALS = "password";
-
- static Hashtable<String,String> env = new Hashtable<String,String>();
-
- static
- {
- env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
- env.put(Context.PROVIDER_URL, LDAP_PROVIDER_URL);
- env.put(Context.SECURITY_AUTHENTICATION, "simple");
- env.put(Context.SECURITY_PRINCIPAL, LDAP_PRINCIPAL);
- env.put(Context.SECURITY_CREDENTIALS, LDAP_CREDENTIALS);
- }
-
- OpenDSService openDSService = new
OpenDSService("target/test-classes/opends");
-
protected void setUp() throws Exception
{
super.setUp();
- hibernateSupport.start();
- orgTest = new OrganizationTest(this);
- openDSService.start();
-
+ persistenceManagerTest = new PersistenceManagerTest(this);
+ relationshipManagerTest = new RelationshipManagerTest(this);
}
protected void tearDown() throws Exception
{
- hibernateSupport.stop();
-
- cleanUp(new InitialLdapContext(env, null));
-
- openDSService.stop();
+ super.tearDown();
}
- public void testDBOrganization() throws Exception
+ public void testDBPersistenceManager() throws Exception
{
identitySessionFactory = new IdentityConfigurationImpl().
configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
- orgTest.testRedHatOrganization("realm://RedHat/DB");
+ persistenceManagerTest.testMethods("realm://RedHat/DB");
}
- public void testDBSamplePortal() throws Exception
+ public void testLDAPMixedPersistenceManager() throws Exception
{
+ populateClean();
identitySessionFactory = new IdentityConfigurationImpl().
configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
- orgTest.testSamplePortal("realm://portal/SamplePortal/DB");
+
+ persistenceManagerTest.testMethods("realm://RedHat/DB_LDAP");
}
- public void testLDAPMixedOrganization() throws Exception
+ public void testDBRelationshipManager() throws Exception
{
- populateClean();
-
identitySessionFactory = new IdentityConfigurationImpl().
configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-
- orgTest.testRedHatOrganization("realm://RedHat/DB_LDAP");
+ relationshipManagerTest.testMethods("realm://RedHat/DB");
}
- public void testLDAPMixedSamplePortal() throws Exception
+ public void testLDAPMixedRelationshipManager() throws Exception
{
populateClean();
identitySessionFactory = new IdentityConfigurationImpl().
configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-
- orgTest.testSamplePortal("realm://portal/SamplePortal/DB_LDAP");
- }
- public IdentitySessionFactory getIdentitySessionFactory()
- {
- return identitySessionFactory;
+ relationshipManagerTest.testMethods("realm://RedHat/DB_LDAP");
}
- public void populate() throws Exception
- {
- populateLDIF("target/test-classes/ldap/initial-opends.ldif");
- }
-
- public void populateClean() throws Exception
- {
- populateLDIF("target/test-classes/ldap/initial-empty-opends.ldif");
- }
-
- public void populateLDIF(String ldifRelativePath) throws Exception
- {
- File ldif = new File(ldifRelativePath);
-
- System.out.println("LDIF: " + ldif.getAbsolutePath());
-
- String[] cmd = new String[] {"-h", LDAP_HOST,
- "-p", LDAP_PORT,
- "-D", LDAP_PRINCIPAL,
- "-w", LDAP_CREDENTIALS,
- "-a", "-f", ldif.getPath()};
-
- System.out.println("Populate success: " + (LDAPModify.mainModify(cmd,
false, System.out, System.err) == 0));
-
- }
-
- protected void cleanUp(DirContext ldapCtx) throws Exception
- {
- try
- {
- String dn = "dc=portal,dc=example,dc=com";
-
- System.out.println("Removing: " + dn);
-
- removeContext(ldapCtx, dn);
- }
- catch (Exception e)
- {
- //
- }
- }
-
- //subsequent remove of javax.naming.Context
- protected void removeContext(Context mainCtx, String name) throws Exception
- {
- Context deleteCtx = (Context)mainCtx.lookup(name);
- NamingEnumeration subDirs = mainCtx.listBindings(name);
-
- while (subDirs.hasMoreElements())
- {
- Binding binding = (Binding)subDirs.nextElement();
- String subName = binding.getName();
-
- removeContext(deleteCtx, subName);
- }
-
- mainCtx.unbind(name);
- }
-
-
}
Copied:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java
(from rev 377,
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java)
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java
(rev 0)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java 2009-03-18
15:20:34 UTC (rev 378)
@@ -0,0 +1,102 @@
+/*
+* 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.identity.idm.impl.api;
+
+import junit.framework.TestCase;
+import org.jboss.identity.idm.impl.HibernateTestSupport;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
+import org.jboss.identity.idm.opends.OpenDSService;
+import org.opends.server.tools.LDAPModify;
+
+import javax.naming.directory.DirContext;
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.Binding;
+import javax.naming.ldap.InitialLdapContext;
+import java.util.Hashtable;
+import java.io.File;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class OrganizationTestCase extends APITestBase
+{
+ OrganizationTest orgTest;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ orgTest = new OrganizationTest(this);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public void testDBOrganization() throws Exception
+ {
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+
+ orgTest.testRedHatOrganization("realm://RedHat/DB");
+ }
+
+ public void testDBSamplePortal() throws Exception
+ {
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+
+ orgTest.testSamplePortal("realm://portal/SamplePortal/DB");
+ }
+
+ public void testLDAPMixedOrganization() throws Exception
+ {
+ populateClean();
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+
+
+ orgTest.testRedHatOrganization("realm://RedHat/DB_LDAP");
+ }
+
+ public void testLDAPMixedSamplePortal() throws Exception
+ {
+ populateClean();
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+
+
+ orgTest.testSamplePortal("realm://portal/SamplePortal/DB_LDAP");
+ }
+
+
+
+
+}
\ No newline at end of file
Added:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
(rev 0)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java 2009-03-18
15:20:34 UTC (rev 378)
@@ -0,0 +1,165 @@
+/*
+* 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.identity.idm.impl.api;
+
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.User;
+import org.jboss.identity.idm.api.RoleType;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.api.AttributeDescription;
+import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.p3p.P3PConstants;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Random;
+import java.util.Arrays;
+
+import junit.framework.Assert;
+
+/**
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class PersistenceManagerTest extends Assert
+{
+ //TODO:
+ //TODO: - force in removeGroup (NYI)
+ //TODO: - exception handling
+ //TODO: - search controls
+ //TODO: - features description
+
+ APITestContext ctx;
+
+ private String ORGANIZATION = "ORGANIZATION";
+ private String ORGANIZATION_UNIT = "ORGANIZATION_UNIT";
+ private String DIVISION = "DIVISION";
+ private String DEPARTMENT = "DEPARTMENT";
+ private String PROJECT = "PROJECT";
+ private String PEOPLE = "PEOPLE";
+
+ public PersistenceManagerTest(APITestContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public void setCtx(APITestContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public APITestContext getCtx()
+ {
+ return ctx;
+ }
+
+ public void testMethods(String realmName) throws Exception
+ {
+ IdentitySessionFactory factory = ctx.getIdentitySessionFactory();
+
+ IdentitySession session = factory.createIdentitySession(realmName);
+
+
+
+ session.getTransaction().start();
+
+ // Create / Remove
+
+ // Group
+ Group group1 = session.getPersistenceManager().createGroup("groupName1",
ORGANIZATION);
+
+ assertNotNull(group1);
+ assertEquals(group1.getGroupType(), ORGANIZATION);
+ assertEquals(group1.getName(), "groupName1");
+
+
+ String group1Id =
session.getPersistenceManager().createGroupId("groupName1", ORGANIZATION);
+
+ assertEquals(group1Id, group1.getId());
+
+ session.getPersistenceManager().createGroup("groupName2", ORGANIZATION);
+ session.getPersistenceManager().createGroup("groupName3", PROJECT);
+
+ assertEquals(2, session.getPersistenceManager().getGroupTypeCount(ORGANIZATION));
+ assertEquals(1, session.getPersistenceManager().getGroupTypeCount(PROJECT));
+ assertEquals(0, session.getPersistenceManager().getGroupTypeCount(DEPARTMENT));
+
+ assertEquals(2, session.getPersistenceManager().findGroup(ORGANIZATION).size());
+ assertEquals(1, session.getPersistenceManager().findGroup(PROJECT).size());
+ assertEquals(0, session.getPersistenceManager().findGroup(DEPARTMENT).size());
+
+ session.getPersistenceManager().removeGroup(group1, false);
+ String id = session.getPersistenceManager().createGroupId("groupName2",
ORGANIZATION);
+ session.getPersistenceManager().removeGroup(id, false);
+ id = session.getPersistenceManager().createGroupId("groupName3",
PROJECT);
+ session.getPersistenceManager().removeGroup(id, false);
+
+ assertEquals(0, session.getPersistenceManager().findGroup(ORGANIZATION,
(IdentitySearchControl[])null).size());
+ assertEquals(0, session.getPersistenceManager().findGroup(PROJECT).size());
+ assertEquals(0, session.getPersistenceManager().findGroup(DEPARTMENT).size());
+
+ assertEquals(0, session.getPersistenceManager().getGroupTypeCount(ORGANIZATION));
+ assertEquals(0, session.getPersistenceManager().getGroupTypeCount(PROJECT));
+ assertEquals(0, session.getPersistenceManager().getGroupTypeCount(DEPARTMENT));
+
+
+ //User
+
+ User u1 = session.getPersistenceManager().createUser("olo");
+
+ assertNotNull(u1);
+ assertEquals(u1.getName(), "olo");
+
+ session.getPersistenceManager().createUser("anna");
+
+ assertEquals(2, session.getPersistenceManager().getUserCount());
+
+ assertNotNull(session.getPersistenceManager().findUser("olo"));
+ assertNotNull(session.getPersistenceManager().findUser("anna"));
+
+ //TODO: this should throw some meaningfull exception or simply return null
+ //assertNull(session.getPersistenceManager().findUser("olaf"));
+
+ assertEquals(2,
session.getPersistenceManager().findUser((IdentitySearchControl[])null).size());
+
+ session.getPersistenceManager().removeUser(u1, false);
+
+ assertEquals(1, session.getPersistenceManager().getUserCount());
+
+ session.getPersistenceManager().removeUser("anna", false);
+
+ assertEquals(0, session.getPersistenceManager().getUserCount());
+
+ assertEquals(0,
session.getPersistenceManager().findUser((IdentitySearchControl[])null).size());
+
+
+ session.getTransaction().commit();
+
+ }
+
+
+
+}
\ No newline at end of file
Added:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
(rev 0)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java 2009-03-18
15:20:34 UTC (rev 378)
@@ -0,0 +1,322 @@
+/*
+* 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.identity.idm.impl.api;
+
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.User;
+import org.jboss.identity.idm.api.RoleType;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.api.AttributeDescription;
+import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.p3p.P3PConstants;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Random;
+import java.util.Arrays;
+import java.util.LinkedList;
+
+import junit.framework.Assert;
+
+/**
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class RelationshipManagerTest extends Assert
+{
+ //TODO:
+ //TODO: - inheritence in find methods
+ //TODO: - creating forbidden associations
+ //TODO: - exception handling
+ //TODO: - search controls
+ //TODO: - features description
+
+ APITestContext ctx;
+
+ private String ORGANIZATION = "ORGANIZATION";
+ private String ORGANIZATION_UNIT = "ORGANIZATION_UNIT";
+ private String DIVISION = "DIVISION";
+ private String DEPARTMENT = "DEPARTMENT";
+ private String PROJECT = "PROJECT";
+ private String PEOPLE = "PEOPLE";
+
+ public RelationshipManagerTest(APITestContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public void setCtx(APITestContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public APITestContext getCtx()
+ {
+ return ctx;
+ }
+
+ public void testMethods(String realmName) throws Exception
+ {
+ IdentitySessionFactory factory = ctx.getIdentitySessionFactory();
+
+ IdentitySession session = factory.createIdentitySession(realmName);
+
+ session.getTransaction().start();
+
+ // Create stuff
+ User user1 = session.getPersistenceManager().createUser("user1");
+ User user2 = session.getPersistenceManager().createUser("user2");
+ User user3 = session.getPersistenceManager().createUser("user3");
+ User user4 = session.getPersistenceManager().createUser("user4");
+
+ Group group1 = session.getPersistenceManager().createGroup("group1",
ORGANIZATION);
+ Group group2 = session.getPersistenceManager().createGroup("group2",
ORGANIZATION_UNIT);
+ Group group3 = session.getPersistenceManager().createGroup("group3",
ORGANIZATION_UNIT);
+ Group group4 = session.getPersistenceManager().createGroup("group4",
DEPARTMENT);
+ Group group5 = session.getPersistenceManager().createGroup("group5",
DEPARTMENT);
+
+
+ // Associate groups
+
+ session.getRelationshipManager().associateGroups(group1, group2);
+ session.getRelationshipManager().associateGroups(group1, group3);
+
+ // Assert
+
+ // isAssociated
+
+ assertTrue(session.getRelationshipManager().isAssociated(group1, group2));
+ assertTrue(session.getRelationshipManager().isAssociated(group1, group3));
+ assertFalse(session.getRelationshipManager().isAssociated(group1, group4));
+ assertFalse(session.getRelationshipManager().isAssociated(group2, group1));
+ assertFalse(session.getRelationshipManager().isAssociated(group2, group3));
+
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1),
Arrays.asList(group2, group3)));
+ assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group1,
group2), Arrays.asList(group2, group3)));
+ assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group2,
group3), Arrays.asList(group1)));
+
+ assertTrue(session.getRelationshipManager().isAssociatedByIds(group1.getId(),
group2.getId()));
+ assertTrue(session.getRelationshipManager().isAssociatedByIds(group1.getId(),
group3.getId()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group1.getId(),
group4.getId()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group2.getId(),
group1.getId()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group2.getId(),
group3.getId()));
+
+ assertTrue(session.getRelationshipManager().
+ isAssociatedByIds(Arrays.asList(group1.getId()), Arrays.asList(group2.getId(),
group3.getId())));
+ assertFalse(session.getRelationshipManager().
+ isAssociatedByIds(Arrays.asList(group1.getId(), group2.getId()),
Arrays.asList(group2.getId(), group3.getId())));
+ assertFalse(session.getRelationshipManager().
+ isAssociatedByIds(Arrays.asList(group2.getId(), group3.getId()),
Arrays.asList(group1.getId())));
+
+
+ // Associate groups - other methods
+
+ // First disassociate and assert
+ session.getRelationshipManager().disassociateGroups(Arrays.asList(group1),
Arrays.asList(group2, group3));
+
+ assertFalse(session.getRelationshipManager().isAssociated(group1, group2));
+ assertFalse(session.getRelationshipManager().isAssociated(group1, group3));
+
+ // reassociate #1
+ session.getRelationshipManager().associateGroups(Arrays.asList(group1),
Arrays.asList(group2, group3));
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1),
Arrays.asList(group2, group3)));
+
+
session.getRelationshipManager().disassociateGroupsByIds(Arrays.asList(group1.getId()),
Arrays.asList(group2.getId(), group3.getId()));
+
+ // reassociate #2
+
session.getRelationshipManager().associateGroupsByIds(Arrays.asList(group1.getId()),
Arrays.asList(group2.getId(), group3.getId()));
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1),
Arrays.asList(group2, group3)));
+
+ session.getRelationshipManager().disassociateGroups(Arrays.asList(group1),
Arrays.asList(group2, group3));
+
+ // reassociate #3
+ session.getRelationshipManager().associateGroupsByIds(group1.getId(),
group2.getId());
+ session.getRelationshipManager().associateGroupsByIds(group1.getId(),
group3.getId());
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1),
Arrays.asList(group2, group3)));
+
+ session.getRelationshipManager().disassociateGroups(Arrays.asList(group1),
Arrays.asList(group2, group3));
+
+
+ // Associate Group and Users
+
+ session.getRelationshipManager().associateUsers(group1, user1);
+ session.getRelationshipManager().associateUsers(group1, user2);
+
+ // isAssociated
+
+ assertTrue(session.getRelationshipManager().isAssociated(group1, user1));
+ assertTrue(session.getRelationshipManager().isAssociated(group1, user2));
+ assertFalse(session.getRelationshipManager().isAssociated(group1, user3));
+ assertFalse(session.getRelationshipManager().isAssociated(group2, user1));
+ assertFalse(session.getRelationshipManager().isAssociated(group2, user3));
+
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1),
Arrays.asList(user1, user2)));
+ assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group1,
group2), Arrays.asList(user1, user2)));
+ assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group2),
Arrays.asList(user3)));
+
+ assertTrue(session.getRelationshipManager().isAssociatedByIds(group1.getId(),
user1.getName()));
+ assertTrue(session.getRelationshipManager().isAssociatedByIds(group1.getId(),
user2.getName()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group1.getId(),
user3.getName()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group2.getId(),
user1.getName()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group2.getId(),
user3.getName()));
+
+ assertTrue(session.getRelationshipManager().
+ isAssociatedByIds(Arrays.asList(group1.getId()), Arrays.asList(user1.getName(),
user2.getName())));
+ assertFalse(session.getRelationshipManager().
+ isAssociatedByIds(Arrays.asList(group1.getId(), group2.getId()),
Arrays.asList(user1.getName(), user2.getName())));
+ assertFalse(session.getRelationshipManager().
+ isAssociatedByIds(Arrays.asList(group2.getId(), group3.getId()),
Arrays.asList(user1.getName())));
+
+
+ // Associate groups / users - other methods
+
+ // First disassociate and assert
+ session.getRelationshipManager().disassociateUsers(Arrays.asList(group1),
Arrays.asList(user1, user2));
+
+ assertFalse(session.getRelationshipManager().isAssociated(group1, user1));
+ assertFalse(session.getRelationshipManager().isAssociated(group1, user2));
+
+ // reassociate #1
+ session.getRelationshipManager().associateUsers(Arrays.asList(group1),
Arrays.asList(user1, user2));
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1),
Arrays.asList(user1, user2)));
+
+ session.getRelationshipManager().disassociateUsers(Arrays.asList(group1),
Arrays.asList(user1, user2));
+
+ // reassociate #2
+ session.getRelationshipManager().associateUsersByIds(Arrays.asList(group1.getId()),
Arrays.asList(user1.getName(), user2.getName()));
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1),
Arrays.asList(user1, user2)));
+
+
session.getRelationshipManager().disassociateUsersByIds(Arrays.asList(group1.getId()),
Arrays.asList(user1.getName(), user2.getName()));
+
+ // reassociate #3
+ session.getRelationshipManager().associateUsersByIds(group1.getId(),
user1.getName());
+ session.getRelationshipManager().associateUsersByIds(group1.getId(),
user2.getName());
+
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1),
Arrays.asList(user1, user2)));
+
+ session.getRelationshipManager().disassociateUsers(Arrays.asList(group1),
Arrays.asList(user1, user2));
+
+
+ session.getTransaction().commit();
+
+ session.getTransaction().start();
+
+
+ // Find methods - prepopulate
+
+ session.getRelationshipManager().associateUsers(Arrays.asList(group1),
Arrays.asList(user1, user2, user3));
+ session.getRelationshipManager().associateUsers(Arrays.asList(group3),
Arrays.asList(user2, user3));
+ session.getRelationshipManager().associateGroups(Arrays.asList(group2),
Arrays.asList(group3, group4, group5));
+
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1),
Arrays.asList(user1, user2, user3)));
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group2),
Arrays.asList(group3, group4, group5)));
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group3),
Arrays.asList(user2, user3)));
+
+ session.getTransaction().commit();
+ session.getTransaction().start();
+
+ // Find users
+ //TODO: check if collections contain correct objects (not only size)
+
+ assertEquals(3, session.getRelationshipManager().findAssociatedUsers(group1,
false).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedUsers(group2,
false).size());
+
+ assertEquals(3, session.getRelationshipManager().findAssociatedUsers(group1, false,
null).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedUsers(group2, false,
null).size());
+
+ assertEquals(3,
session.getRelationshipManager().findAssociatedUsers(group1.getId(), false,
null).size());
+ assertEquals(0,
session.getRelationshipManager().findAssociatedUsers(group2.getId(), false,
null).size());
+
+ // Find groups
+
+ // #1
+ assertEquals(2, session.getRelationshipManager().findAssociatedGroups(group2,
DEPARTMENT, true, false).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(group2,
ORGANIZATION_UNIT, true, false).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(group2,
ORGANIZATION, true, false).size());
+
+ // #1
+ assertEquals(2,
session.getRelationshipManager().findAssociatedGroups(group2.getId(), DEPARTMENT, true,
false, null).size());
+ assertEquals(1,
session.getRelationshipManager().findAssociatedGroups(group2.getId(), ORGANIZATION_UNIT,
true, false, null).size());
+ assertEquals(0,
session.getRelationshipManager().findAssociatedGroups(group2.getId(), ORGANIZATION, true,
false, null).size());
+
+ // #3
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(group3,
ORGANIZATION_UNIT, false, false).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(group4,
ORGANIZATION_UNIT, false, false).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(group2,
ORGANIZATION, false, false).size());
+
+ // #4
+ assertEquals(1,
session.getRelationshipManager().findAssociatedGroups(group3.getId(), ORGANIZATION_UNIT,
false, false, null).size());
+ assertEquals(1,
session.getRelationshipManager().findAssociatedGroups(group4.getId(), ORGANIZATION_UNIT,
false, false, null).size());
+ assertEquals(0,
session.getRelationshipManager().findAssociatedGroups(group2.getId(), ORGANIZATION, false,
false, null).size());
+
+ // #5
+ assertEquals(1,
session.getRelationshipManager().findAssociatedGroups(user1).size());
+ assertEquals(2,
session.getRelationshipManager().findAssociatedGroups(user2).size());
+ assertEquals(2,
session.getRelationshipManager().findAssociatedGroups(user3).size());
+ assertEquals(0,
session.getRelationshipManager().findAssociatedGroups(user4).size());
+
+ // #6
+ assertEquals(1,
session.getRelationshipManager().findAssociatedGroups(user1.getName(), null).size());
+ assertEquals(2,
session.getRelationshipManager().findAssociatedGroups(user2.getName(), null).size());
+ assertEquals(2,
session.getRelationshipManager().findAssociatedGroups(user3.getName(), null).size());
+ assertEquals(0,
session.getRelationshipManager().findAssociatedGroups(user4.getName(), null).size());
+
+ // #7
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user1,
ORGANIZATION).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user1,
ORGANIZATION_UNIT).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2,
ORGANIZATION).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2,
ORGANIZATION_UNIT).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user3,
ORGANIZATION).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user3,
ORGANIZATION_UNIT).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4,
ORGANIZATION).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4,
ORGANIZATION_UNIT).size());
+
+ // #7
+ assertEquals(1,
session.getRelationshipManager().findAssociatedGroups(user1.getName(), ORGANIZATION,
null).size());
+ assertEquals(0,
session.getRelationshipManager().findAssociatedGroups(user1.getName(), ORGANIZATION_UNIT,
null).size());
+ assertEquals(1,
session.getRelationshipManager().findAssociatedGroups(user2.getName(), ORGANIZATION,
null).size());
+ assertEquals(1,
session.getRelationshipManager().findAssociatedGroups(user2.getName(), ORGANIZATION_UNIT,
null).size());
+ assertEquals(1,
session.getRelationshipManager().findAssociatedGroups(user3.getName(), ORGANIZATION,
null).size());
+ assertEquals(1,
session.getRelationshipManager().findAssociatedGroups(user3.getName(), ORGANIZATION_UNIT,
null).size());
+ assertEquals(0,
session.getRelationshipManager().findAssociatedGroups(user4.getName(), ORGANIZATION,
null).size());
+ assertEquals(0,
session.getRelationshipManager().findAssociatedGroups(user4.getName(), ORGANIZATION_UNIT,
null).size());
+
+ // Cleanup and check
+ session.getRelationshipManager().disassociateUsers(Arrays.asList(group1),
Arrays.asList(user1, user2, user3));
+ session.getRelationshipManager().disassociateUsers(Arrays.asList(group3),
Arrays.asList(user2, user3));
+ session.getRelationshipManager().disassociateGroups(Arrays.asList(group2),
Arrays.asList(group3, group4));
+
+ assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group1),
Arrays.asList(user1, user2, user3)));
+ assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group2),
Arrays.asList(group3, group4, group5)));
+ assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group3),
Arrays.asList(user2, user3)));
+
+ session.getTransaction().commit();
+
+ }
+
+
+
+}
\ No newline at end of file
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-17
21:38:45 UTC (rev 377)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-18
15:20:34 UTC (rev 378)
@@ -143,16 +143,7 @@
User findUser(String name) throws IdentityException;
/**
- * Find identity with a given id
*
- * @param id
- * @return
- * @throws org.jboss.identity.idm.exception.IdentityException
- */
- User findUserById(String id) throws IdentityException;
-
- /**
- *
* @param controls
* @return
* @throws IdentityException