Author: bdaw
Date: 2009-04-02 18:19:30 -0400 (Thu, 02 Apr 2009)
New Revision: 419
Added:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPTestCase.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossTestCase.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java
Removed:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APIJBossUnitTest.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPJBossUnitTest.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java
Modified:
idm/branches/proto/idm/pom.xml
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/IdentityTestPOJO.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationJBossUnitTest.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPJBossUnitTest.java
idm/branches/proto/idm/src/test/resources/jboss-unit.xml
Log:
proto
Modified: idm/branches/proto/idm/pom.xml
===================================================================
--- idm/branches/proto/idm/pom.xml 2009-04-02 21:11:13 UTC (rev 418)
+++ idm/branches/proto/idm/pom.xml 2009-04-02 22:19:30 UTC (rev 419)
@@ -216,57 +216,67 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <skip>true</skip>
+ <!--<skip>true</skip>-->
+ <systemProperties>
+ <property>
+ <name>dataSourceName</name>
+ <value>${dataSourceName}</value>
+ </property>
+ <property>
+ <name>directoryName</name>
+ <value>${directoryName}</value>
+ </property>
+ </systemProperties>
</configuration>
</plugin>
- <plugin>
- <groupId>org.jboss.unit</groupId>
- <artifactId>jboss-unit-tooling-maven2</artifactId>
- <executions>
- <execution>
- <phase>test</phase>
- <goals>
- <goal>execute</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
+ <!--<plugin>-->
+ <!--<groupId>org.jboss.unit</groupId>-->
+
<!--<artifactId>jboss-unit-tooling-maven2</artifactId>-->
+ <!--<executions>-->
+ <!--<execution>-->
+ <!--<phase>test</phase>-->
+ <!--<goals>-->
+ <!--<goal>execute</goal>-->
+ <!--</goals>-->
+ <!--</execution>-->
+ <!--</executions>-->
+ <!--<configuration>-->
<!--<jpda>true</jpda>-->
- <jpdaPort>5005</jpdaPort>
- <jpdaSuspend>true</jpdaSuspend>
+ <!--<jpdaPort>5005</jpdaPort>-->
+ <!--<jpdaSuspend>true</jpdaSuspend>-->
- <failOnError>true</failOnError>
+ <!--<failOnError>true</failOnError>-->
- <testsuites>
- <testsuite>
- <config>jboss-unit.xml</config>
- <parameters>
- <parameter>
- <name>dataSourceName</name>
- <values>
- <value>hsqldb</value>
+ <!--<testsuites>-->
+ <!--<testsuite>-->
+ <!--<config>jboss-unit.xml</config>-->
+ <!--<parameters>-->
+ <!--<parameter>-->
+ <!--<name>dataSourceName</name>-->
+ <!--<values>-->
+ <!--<value>hsqldb</value>-->
<!--<value>mysql5</value>-->
<!--<value>mysql4</value>-->
<!--<value>postgresql8</value>-->
<!--<value>sqlserver</value>-->
<!--<value>oracle9i</value>-->
<!--<value>oracle10g</value>-->
- </values>
- </parameter>
- </parameters>
+ <!--</values>-->
+ <!--</parameter>-->
+ <!--</parameters>-->
- </testsuite>
- </testsuites>
+ <!--</testsuite>-->
+ <!--</testsuites>-->
- <reports>
- <xml>idm/target/tests/reports/xml</xml>
- <html>idm/target/tests/reports/html</html>
- </reports>
- </configuration>
- </plugin>
+ <!--<reports>-->
+ <!--<xml>idm/target/tests/reports/xml</xml>-->
+
<!--<html>idm/target/tests/reports/html</html>-->
+ <!--</reports>-->
+ <!--</configuration>-->
+ <!--</plugin>-->
</plugins>
</build>
Modified:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/IdentityTestPOJO.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/IdentityTestPOJO.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/IdentityTestPOJO.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -56,21 +56,23 @@
import java.util.Hashtable;
import java.io.File;
+import junit.framework.TestCase;
+
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
*/
-public class IdentityTestPOJO
+public class IdentityTestPOJO extends TestCase
{
- private String identityConfig;
+ private String identityConfig = "organization-test-jboss-unit-config.xml";
private String realmName;
- private String dataSourceName;
+ private String dataSourceName = "hsqldb";
- private String hibernateConfig;
+ private String hibernateConfig = "datasources/hibernates.xml";
private String datasources = "datasources/datasources.xml";
@@ -88,6 +90,8 @@
public void start() throws Exception
{
+ overrideFromProperties();
+
jndiSupport = new JNDISupport();
jndiSupport.start();
transactonManagerSupport = new TransactionManagerSupport();
@@ -143,6 +147,17 @@
}
+ public void overrideFromProperties() throws Exception
+ {
+ String dsName =System.getProperties().getProperty("dataSourceName");
+
+ if (dsName != null)
+ {
+ setDataSourceName(dsName);
+ }
+
+ }
+
public SessionFactory getSessionFactory()
{
return getHibernateSupport().getSessionFactory();
@@ -222,4 +237,6 @@
}
+
+
}
Modified:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -44,7 +44,7 @@
public class LDAPTestPOJO extends IdentityTestPOJO
{
- private String directoryName;
+ private String directoryName = "EmbeddedOpenDS";
public static final String LDAP_HOST = "localhost";
@@ -90,6 +90,19 @@
}
+ public void overrideFromProperties() throws Exception
+ {
+ super.overrideFromProperties();
+
+ String dirName =System.getProperties().getProperty("directoryName");
+
+ if (dirName != null && !dirName.startsWith("$"))
+ {
+ setDirectoryName(dirName);
+ }
+
+ }
+
@Parameter
public void setDirectoryName(String directoryName)
{
Deleted:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APIJBossUnitTest.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APIJBossUnitTest.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APIJBossUnitTest.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -1,107 +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.identity.idm.impl.api;
-
-import junit.framework.TestCase;
-import org.jboss.identity.idm.impl.HibernateTestSupport;
-import org.jboss.identity.idm.impl.IdentityTestPOJO;
-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.jboss.unit.api.pojo.annotations.Create;
-import org.jboss.unit.api.pojo.annotations.Destroy;
-import org.jboss.unit.api.pojo.annotations.Test;
-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 APIJBossUnitTest extends IdentityTestPOJO implements APITestContext
-{
-
- PersistenceManagerTest persistenceManagerTest;
-
- RelationshipManagerTest relationshipManagerTest;
-
- RoleManagerTest roleManagerTest;
-
- IdentitySessionFactory identitySessionFactory;
-
- @Create
- public void start() throws Exception
- {
- super.start();
- persistenceManagerTest = new PersistenceManagerTest(this);
- relationshipManagerTest = new RelationshipManagerTest(this);
- roleManagerTest = new RoleManagerTest(this);
-
-
- identitySessionFactory = new IdentityConfigurationImpl().
- configure(getIdentityConfig()).buildIdentitySessionFactory();
- }
-
- @Destroy
- public void stop() throws Exception
- {
- super.stop();
- }
-
- public IdentitySessionFactory getIdentitySessionFactory()
- {
- return identitySessionFactory;
- }
-
- @Test
- public void testPersistenceManager() throws Exception
- {
- persistenceManagerTest.testMethods(getRealmName());
- }
-
- @Test
- public void testRelationshipManager() throws Exception
- {
- relationshipManagerTest.testMethods(getRealmName());
- }
-
- @Test
- public void testRelationshipManagerMergedRoleAssociations() throws Exception
- {
- relationshipManagerTest.testMergedRoleAssociations(getRealmName());
- }
-
- @Test
- public void testRoleManager() throws Exception
- {
- roleManagerTest.testMethods(getRealmName());
- }
-}
\ No newline at end of file
Deleted:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPJBossUnitTest.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPJBossUnitTest.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPJBossUnitTest.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -1,110 +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.identity.idm.impl.api;
-
-import junit.framework.TestCase;
-import org.jboss.identity.idm.impl.HibernateTestSupport;
-import org.jboss.identity.idm.impl.IdentityTestPOJO;
-import org.jboss.identity.idm.impl.LDAPTestPOJO;
-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.jboss.unit.api.pojo.annotations.Create;
-import org.jboss.unit.api.pojo.annotations.Destroy;
-import org.jboss.unit.api.pojo.annotations.Test;
-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 APILDAPJBossUnitTest extends LDAPTestPOJO implements APITestContext
-{
-
- PersistenceManagerTest persistenceManagerTest;
-
- RelationshipManagerTest relationshipManagerTest;
-
- RoleManagerTest roleManagerTest;
-
- IdentitySessionFactory identitySessionFactory;
-
- @Create
- public void start() throws Exception
- {
- super.start();
- persistenceManagerTest = new PersistenceManagerTest(this);
- relationshipManagerTest = new RelationshipManagerTest(this);
- roleManagerTest = new RoleManagerTest(this);
-
- populateClean();
-
-
- identitySessionFactory = new IdentityConfigurationImpl().
- configure(getIdentityConfig()).buildIdentitySessionFactory();
- }
-
- @Destroy
- public void stop() throws Exception
- {
- super.stop();
- }
-
- public IdentitySessionFactory getIdentitySessionFactory()
- {
- return identitySessionFactory;
- }
-
- @Test
- public void testPersistenceManager() throws Exception
- {
- persistenceManagerTest.testMethods(getRealmName());
- }
-
- @Test
- public void testRelationshipManager() throws Exception
- {
- relationshipManagerTest.testMethods(getRealmName());
- }
-
- @Test
- public void testRelationshipManagerMergedRoleAssociations() throws Exception
- {
- relationshipManagerTest.testMergedRoleAssociations(getRealmName());
- }
-
- @Test
- public void testRoleManager() throws Exception
- {
- roleManagerTest.testMethods(getRealmName());
- }
-}
\ No newline at end of file
Copied:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPTestCase.java
(from rev 418,
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPJBossUnitTest.java)
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPTestCase.java
(rev 0)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPTestCase.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -0,0 +1,112 @@
+/*
+* 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.IdentityTestPOJO;
+import org.jboss.identity.idm.impl.LDAPTestPOJO;
+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.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Test;
+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 APILDAPTestCase extends LDAPTestPOJO implements APITestContext
+{
+
+ PersistenceManagerTest persistenceManagerTest;
+
+ RelationshipManagerTest relationshipManagerTest;
+
+ RoleManagerTest roleManagerTest;
+
+ IdentitySessionFactory identitySessionFactory;
+
+ @Create
+ public void setUp() throws Exception
+ {
+ super.start();
+ persistenceManagerTest = new PersistenceManagerTest(this);
+ relationshipManagerTest = new RelationshipManagerTest(this);
+ roleManagerTest = new RoleManagerTest(this);
+
+ setRealmName("realm://RedHat/DB_LDAP");
+
+ populateClean();
+
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(getIdentityConfig()).buildIdentitySessionFactory();
+ }
+
+ @Destroy
+ public void tearDown() throws Exception
+ {
+ super.stop();
+ }
+
+ public IdentitySessionFactory getIdentitySessionFactory()
+ {
+ return identitySessionFactory;
+ }
+
+ @Test
+ public void testPersistenceManager() throws Exception
+ {
+ persistenceManagerTest.testMethods(getRealmName());
+ }
+
+ @Test
+ public void testRelationshipManager() throws Exception
+ {
+ relationshipManagerTest.testMethods(getRealmName());
+ }
+
+ @Test
+ public void testRelationshipManagerMergedRoleAssociations() throws Exception
+ {
+ relationshipManagerTest.testMergedRoleAssociations(getRealmName());
+ }
+
+ @Test
+ public void testRoleManager() throws Exception
+ {
+ roleManagerTest.testMethods(getRealmName());
+ }
+}
\ No newline at end of file
Deleted:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -1,165 +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.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);
-// }
-//
-// public void begin()
-// {
-//
-// }
-//
-// public void commit()
-// {
-//
-// }
-//}
\ No newline at end of file
Deleted:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -1,144 +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.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 APITestCase extends APITestBase
-//{
-//
-// PersistenceManagerTest persistenceManagerTest;
-//
-// RelationshipManagerTest relationshipManagerTest;
-//
-// RoleManagerTest roleManagerTest;
-//
-// protected void setUp() throws Exception
-// {
-// super.setUp();
-// persistenceManagerTest = new PersistenceManagerTest(this);
-// relationshipManagerTest = new RelationshipManagerTest(this);
-// roleManagerTest = new RoleManagerTest(this);
-// }
-//
-// protected void tearDown() throws Exception
-// {
-// super.tearDown();
-// }
-//
-// public void testDBPersistenceManager() throws Exception
-// {
-// identitySessionFactory = new IdentityConfigurationImpl().
-// configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-//
-// persistenceManagerTest.testMethods("realm://RedHat/DB");
-// }
-//
-// public void testLDAPMixedPersistenceManager() throws Exception
-// {
-// populateClean();
-//
-// identitySessionFactory = new IdentityConfigurationImpl().
-// configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-//
-//
-// persistenceManagerTest.testMethods("realm://RedHat/DB_LDAP");
-// }
-//
-// public void testDBRelationshipManager() throws Exception
-// {
-// identitySessionFactory = new IdentityConfigurationImpl().
-// configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-//
-// relationshipManagerTest.testMethods("realm://RedHat/DB");
-// }
-//
-// public void testLDAPMixedRelationshipManager() throws Exception
-// {
-// populateClean();
-//
-// identitySessionFactory = new IdentityConfigurationImpl().
-// configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-//
-//
-// relationshipManagerTest.testMethods("realm://RedHat/DB_LDAP");
-// }
-//
-// public void testDBRelationshipManagerMergedRoleAssociations() throws Exception
-// {
-// identitySessionFactory = new IdentityConfigurationImpl().
-// configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-//
-//
relationshipManagerTest.testMergedRoleAssociations("realm://RedHat/DB");
-// }
-//
-// public void testLDAPMixedRelationshipManagerMergedRoleAssociations() throws
Exception
-// {
-// populateClean();
-//
-// identitySessionFactory = new IdentityConfigurationImpl().
-// configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-//
-//
-//
relationshipManagerTest.testMergedRoleAssociations("realm://RedHat/DB_LDAP");
-// }
-//
-// public void testDBRoleManager() throws Exception
-// {
-// identitySessionFactory = new IdentityConfigurationImpl().
-// configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-//
-// roleManagerTest.testMethods("realm://RedHat/DB");
-// }
-//
-// public void testLDAPMixedRoleManager() throws Exception
-// {
-// populateClean();
-//
-// identitySessionFactory = new IdentityConfigurationImpl().
-// configure(new
File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-//
-//
-// roleManagerTest.testMethods("realm://RedHat/DB_LDAP");
-// }
-//
-//}
-//
Copied:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
(from rev 418,
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APIJBossUnitTest.java)
===================================================================
--- idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
(rev 0)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -0,0 +1,109 @@
+/*
+* 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.IdentityTestPOJO;
+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.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Test;
+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 APITestCase extends IdentityTestPOJO implements APITestContext
+{
+
+ PersistenceManagerTest persistenceManagerTest;
+
+ RelationshipManagerTest relationshipManagerTest;
+
+ RoleManagerTest roleManagerTest;
+
+ IdentitySessionFactory identitySessionFactory;
+
+ @Create
+ public void setUp() throws Exception
+ {
+ super.start();
+ persistenceManagerTest = new PersistenceManagerTest(this);
+ relationshipManagerTest = new RelationshipManagerTest(this);
+ roleManagerTest = new RoleManagerTest(this);
+
+ setRealmName("realm://RedHat/DB");
+
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(getIdentityConfig()).buildIdentitySessionFactory();
+ }
+
+ @Destroy
+ public void tearDown() throws Exception
+ {
+ super.stop();
+ }
+
+ public IdentitySessionFactory getIdentitySessionFactory()
+ {
+ return identitySessionFactory;
+ }
+
+ @Test
+ public void testPersistenceManager() throws Exception
+ {
+ persistenceManagerTest.testMethods(getRealmName());
+ }
+
+ @Test
+ public void testRelationshipManager() throws Exception
+ {
+ relationshipManagerTest.testMethods(getRealmName());
+ }
+
+ @Test
+ public void testRelationshipManagerMergedRoleAssociations() throws Exception
+ {
+ relationshipManagerTest.testMergedRoleAssociations(getRealmName());
+ }
+
+ @Test
+ public void testRoleManager() throws Exception
+ {
+ roleManagerTest.testMethods(getRealmName());
+ }
+}
\ No newline at end of file
Modified:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationJBossUnitTest.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationJBossUnitTest.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationJBossUnitTest.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -40,13 +40,13 @@
private IdentitySessionFactory identitySessionFactory;
- private String samplePortalRealmName;
+ private String samplePortalRealmName = "realm://portal/SamplePortal/DB";
- private String sampleOrganizationRealmName;
+ private String sampleOrganizationRealmName = "realm://RedHat/DB";
@Create
- public void start() throws Exception
+ public void setUp() throws Exception
{
super.start();
@@ -57,7 +57,7 @@
}
@Destroy
- public void stop() throws Exception
+ public void tearDown() throws Exception
{
super.stop();
}
Modified:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPJBossUnitTest.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPJBossUnitTest.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPJBossUnitTest.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -41,13 +41,13 @@
private IdentitySessionFactory identitySessionFactory;
- private String samplePortalRealmName;
+ private String samplePortalRealmName =
"realm://portal/SamplePortal/DB_LDAP";
- private String sampleOrganizationRealmName;
+ private String sampleOrganizationRealmName = "realm://RedHat/DB_LDAP";
@Create
- public void start() throws Exception
+ public void setUp() throws Exception
{
super.start();
@@ -60,7 +60,7 @@
}
@Destroy
- public void stop() throws Exception
+ public void tearDown() throws Exception
{
super.stop();
}
Deleted:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -1,104 +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.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
Deleted:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -1,297 +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.identity.idm.impl.store.hibernate;
-
-import org.jboss.identity.idm.spi.model.IdentityObject;
-import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.idm.spi.store.IdentityStore;
-import org.jboss.identity.idm.spi.store.IdentityStoreSession;
-import
org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
-import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
-import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContextRegistry;
-import org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl;
-import org.jboss.identity.idm.impl.store.IdentityTypeEnum;
-import org.jboss.identity.idm.impl.store.CommonIdentityStoreTest;
-import org.jboss.identity.idm.impl.store.IdentityStoreTestContext;
-import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
-import org.jboss.identity.idm.impl.configuration.IdentityStoreConfigurationContextImpl;
-import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
-import org.jboss.identity.idm.impl.api.SimpleAttribute;
-import org.jboss.identity.idm.impl.IdentityTestPOJO;
-import org.jboss.identity.idm.exception.IdentityException;
-import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
-import org.jboss.unit.api.pojo.annotations.Create;
-import org.jboss.unit.api.pojo.annotations.Test;
-import static org.jboss.unit.api.Assert.*;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-
-import java.util.Map;
-import java.io.File;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
- * @version : 0.1 $
- */
-public class HibernateIdentityStoreJBossUnitTest extends IdentityTestPOJO implements
IdentityStoreTestContext
-{
-
- protected HibernateIdentityStoreImpl store;
-
- protected IdentityStoreInvocationContext ctx;
-
- protected CommonIdentityStoreTest commonTest;
-
- public HibernateIdentityStoreJBossUnitTest()
- {
-
- }
-
- @Create
- public void start() throws Exception
- {
- super.start();
-
- commonTest = new CommonIdentityStoreTest(this);
-
- IdentityConfigurationMetaData configurationMD = JAXB2IdentityConfiguration
- .createConfigurationMetaData(getIdentityConfig());
-
- IdentityConfigurationContextRegistry identityConfiguration =
(IdentityConfigurationContextRegistry)
- new IdentityConfigurationImpl().configure(configurationMD);
-
- IdentityStoreConfigurationMetaData storeMD = null;
-
- for (IdentityStoreConfigurationMetaData metaData :
configurationMD.getIdentityStores())
- {
- if (metaData.getId().equals("HibernateTestStore"))
- {
- storeMD = metaData;
- break;
- }
- }
-
- IdentityStoreConfigurationContext context =
- new IdentityStoreConfigurationContextImpl(configurationMD,
identityConfiguration, storeMD);
-
- store = new HibernateIdentityStoreImpl("HibernateTestStore")
- {
-
- @Override
- protected Session getHibernateSession(IdentityStoreInvocationContext ctx)
- {
- return getHibernateSupport().getSessionFactory().getCurrentSession();
- }
-
- @Override
- protected SessionFactory
bootstrapHibernateSessionFactory(IdentityStoreConfigurationContext configurationContext)
throws IdentityException
- {
- return getHibernateSupport().getSessionFactory();
- }
-
- };
-
- store.bootstrap(context);
-
-
- ctx = new IdentityStoreInvocationContext()
- {
- public IdentityStoreSession getIdentityStoreSession()
- {
- return null;
- }
-
- public String getRealmId()
- {
- return "testRealm";
- }
- };
-
-
- }
-
- public void begin()
- {
- getHibernateSupport().openSession();
- }
-
- public void commit()
- {
- assertTrue(getHibernateSupport().commitTransaction());
- }
-
- public void flush() throws Exception
- {
-
- getHibernateSupport().getSessionFactory().getCurrentSession().flush();
- }
-
- public IdentityStore getStore()
- {
- return store;
- }
-
- public IdentityStoreInvocationContext getCtx()
- {
- return ctx;
- }
-
- // Tests
-
- @Test
- public void testStorePersistence() throws Exception
- {
-
- commonTest.testStorePersistence();
-
- }
-
- @Test
- public void testFindMethods() throws Exception
- {
-
- commonTest.testFindMethods();
-
- }
-
- @Test
- public void testAttributes() throws Exception
- {
-
- begin();
-
- IdentityObject user1 = store.createIdentityObject(ctx, "Adam",
IdentityTypeEnum.USER);
- IdentityObject user2 = store.createIdentityObject(ctx, "Eva",
IdentityTypeEnum.USER);
-
- flush();
-
- IdentityObjectAttribute[] attrs = new IdentityObjectAttribute[]{
- new SimpleAttribute("key1", new String[]{"val1",
"val2", "val3"}),
- new SimpleAttribute("key2", new String[]{"val1",
"val2", "val3", "val4"})
- };
-
- store.addAttributes(ctx, user1, attrs);
-
- flush();
-
- Map<String, IdentityObjectAttribute> persistedAttrs =
store.getAttributes(ctx, user1);
-
- assertEquals(2, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("key1"));
- assertEquals(3, persistedAttrs.get("key1").getSize());
-
- assertTrue(persistedAttrs.containsKey("key2"));
- assertEquals(4, persistedAttrs.get("key2").getSize());
-
- flush();
-
- attrs = new IdentityObjectAttribute[]{
- new SimpleAttribute("key3", new String[]{"val1"})
- };
-
-
- store.addAttributes(ctx, user1, attrs);
-
- flush();
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("key1"));
- assertEquals(3, persistedAttrs.get("key1").getSize());
-
- assertTrue(persistedAttrs.containsKey("key2"));
- assertEquals(4, persistedAttrs.get("key2").getSize());
-
- assertTrue(persistedAttrs.containsKey("key3"));
- assertEquals(1, persistedAttrs.get("key3").getSize());
-
- flush();
-
- attrs = new IdentityObjectAttribute[]{
- new SimpleAttribute("key3", new String[]{"val2"})
- };
-
- store.addAttributes(ctx, user1, attrs);
-
- flush();
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("key3"));
- assertEquals(2, persistedAttrs.get("key3").getSize());
-
- flush();
-
- store.updateAttributes(ctx, user1, attrs);
-
- flush();
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("key3"));
- assertEquals(1, persistedAttrs.get("key3").getSize());
-
- flush();
-
- store.removeAttributes(ctx, user1, new String[] {"key3"});
-
- flush();
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(2, persistedAttrs.keySet().size());
-
-
- commit();
-
- }
-
- @Test
- public void testRelationships() throws Exception
- {
- commonTest.testRelationships();
- }
-
- @Test
- public void testCredentials() throws Exception
- {
- commonTest.testPasswordCredential();
- commonTest.testBinaryCredential();
- }
-
- @Test
- public void testControls() throws Exception
- {
- commonTest.testControls();
- }
-
-}
\ No newline at end of file
Deleted:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -1,291 +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.identity.idm.impl.store.hibernate;
-//
-//import org.jboss.identity.idm.spi.model.IdentityObject;
-//import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
-//import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
-//import org.jboss.identity.idm.spi.store.IdentityStore;
-//import org.jboss.identity.idm.spi.store.IdentityStoreSession;
-//import
org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-//import
org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
-//import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
-//import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContextRegistry;
-//import org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl;
-//import org.jboss.identity.idm.impl.store.hibernate.HibernateTestBase;
-//import org.jboss.identity.idm.impl.store.IdentityTypeEnum;
-//import org.jboss.identity.idm.impl.store.CommonIdentityStoreTest;
-//import org.jboss.identity.idm.impl.store.IdentityStoreTestContext;
-//import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
-//import
org.jboss.identity.idm.impl.configuration.IdentityStoreConfigurationContextImpl;
-//import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
-//import org.jboss.identity.idm.impl.api.SimpleAttribute;
-//import org.jboss.identity.idm.exception.IdentityException;
-//import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
-//import org.hibernate.Session;
-//import org.hibernate.SessionFactory;
-//
-//import java.util.Map;
-//import java.io.File;
-//
-///**
-// * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
-// * @version : 0.1 $
-// */
-//public class HibernateIdentityStoreTestCase extends HibernateTestBase implements
IdentityStoreTestContext
-//{
-//
-// protected HibernateIdentityStoreImpl store;
-//
-// protected IdentityStoreInvocationContext ctx;
-//
-// protected CommonIdentityStoreTest commonTest;
-//
-// public HibernateIdentityStoreTestCase(String testName)
-// {
-// super(testName);
-// commonTest = new CommonIdentityStoreTest(this);
-// }
-//
-//
-//
-// @Override
-// protected void setUp() throws Exception
-// {
-// super.setUp();
-//
-// IdentityConfigurationMetaData configurationMD = JAXB2IdentityConfiguration
-// .createConfigurationMetaData(new
File("src/test/resources/store-test-config.xml"));
-//
-// IdentityConfigurationContextRegistry identityConfiguration =
(IdentityConfigurationContextRegistry)
-// new IdentityConfigurationImpl().configure(configurationMD);
-//
-//
-//
-// IdentityStoreConfigurationMetaData storeMD = null;
-//
-// for (IdentityStoreConfigurationMetaData metaData :
configurationMD.getIdentityStores())
-// {
-// if (metaData.getId().equals("HibernateTestStore"))
-// {
-// storeMD = metaData;
-// break;
-// }
-// }
-//
-// IdentityStoreConfigurationContext context =
-// new IdentityStoreConfigurationContextImpl(configurationMD,
identityConfiguration, storeMD);
-//
-// store = new HibernateIdentityStoreImpl("HibernateTestStore")
-// {
-//
-// @Override
-// protected Session getHibernateSession(IdentityStoreInvocationContext ctx)
-// {
-// return sessionFactory.getCurrentSession();
-// }
-//
-// @Override
-// protected SessionFactory
bootstrapHibernateSessionFactory(IdentityStoreConfigurationContext configurationContext)
throws IdentityException
-// {
-// return sessionFactory;
-// }
-//
-// };
-//
-// store.bootstrap(context);
-//
-//
-// ctx = new IdentityStoreInvocationContext()
-// {
-// public IdentityStoreSession getIdentityStoreSession()
-// {
-// return null;
-// }
-//
-// public String getRealmId()
-// {
-// return "testRealm";
-// }
-// };
-//
-//
-// }
-//
-// public void begin() throws Exception
-// {
-// sessionFactory.getCurrentSession().getTransaction().begin();
-//
-// }
-//
-// public void commit() throws Exception
-// {
-// sessionFactory.getCurrentSession().getTransaction().commit();
-// }
-//
-// public void flush() throws Exception
-// {
-// sessionFactory.getCurrentSession().flush();
-// }
-//
-// public IdentityStore getStore()
-// {
-// return store;
-// }
-//
-// public IdentityStoreInvocationContext getCtx()
-// {
-// return ctx;
-// }
-//
-// // Tests
-//
-// public void testStorePersistence() throws Exception
-// {
-//
-// commonTest.testStorePersistence();
-//
-// }
-//
-// public void testFindMethods() throws Exception
-// {
-//
-// commonTest.testFindMethods();
-//
-// }
-//
-// public void testAttributes() throws Exception
-// {
-//
-// begin();
-//
-// IdentityObject user1 = store.createIdentityObject(ctx, "Adam",
IdentityTypeEnum.USER);
-// IdentityObject user2 = store.createIdentityObject(ctx, "Eva",
IdentityTypeEnum.USER);
-//
-// sessionFactory.getCurrentSession().flush();
-//
-// IdentityObjectAttribute[] attrs = new IdentityObjectAttribute[]{
-// new SimpleAttribute("key1", new String[]{"val1",
"val2", "val3"}),
-// new SimpleAttribute("key2", new String[]{"val1",
"val2", "val3", "val4"})
-// };
-//
-// store.addAttributes(ctx, user1, attrs);
-//
-// sessionFactory.getCurrentSession().flush();
-//
-// Map<String, IdentityObjectAttribute> persistedAttrs =
store.getAttributes(ctx, user1);
-//
-// assertEquals(2, persistedAttrs.keySet().size());
-//
-// assertTrue(persistedAttrs.containsKey("key1"));
-// assertEquals(3, persistedAttrs.get("key1").getSize());
-//
-// assertTrue(persistedAttrs.containsKey("key2"));
-// assertEquals(4, persistedAttrs.get("key2").getSize());
-//
-// sessionFactory.getCurrentSession().flush();
-//
-// attrs = new IdentityObjectAttribute[]{
-// new SimpleAttribute("key3", new String[]{"val1"})
-// };
-//
-//
-// store.addAttributes(ctx, user1, attrs);
-//
-// sessionFactory.getCurrentSession().flush();
-//
-// persistedAttrs = store.getAttributes(ctx, user1);
-//
-// assertEquals(3, persistedAttrs.keySet().size());
-//
-// assertTrue(persistedAttrs.containsKey("key1"));
-// assertEquals(3, persistedAttrs.get("key1").getSize());
-//
-// assertTrue(persistedAttrs.containsKey("key2"));
-// assertEquals(4, persistedAttrs.get("key2").getSize());
-//
-// assertTrue(persistedAttrs.containsKey("key3"));
-// assertEquals(1, persistedAttrs.get("key3").getSize());
-//
-// sessionFactory.getCurrentSession().flush();
-//
-// attrs = new IdentityObjectAttribute[]{
-// new SimpleAttribute("key3", new String[]{"val2"})
-// };
-//
-// store.addAttributes(ctx, user1, attrs);
-//
-// sessionFactory.getCurrentSession().flush();
-//
-// persistedAttrs = store.getAttributes(ctx, user1);
-//
-// assertEquals(3, persistedAttrs.keySet().size());
-//
-// assertTrue(persistedAttrs.containsKey("key3"));
-// assertEquals(2, persistedAttrs.get("key3").getSize());
-//
-// sessionFactory.getCurrentSession().flush();
-//
-// store.updateAttributes(ctx, user1, attrs);
-//
-// sessionFactory.getCurrentSession().flush();
-//
-// persistedAttrs = store.getAttributes(ctx, user1);
-//
-// assertEquals(3, persistedAttrs.keySet().size());
-//
-// assertTrue(persistedAttrs.containsKey("key3"));
-// assertEquals(1, persistedAttrs.get("key3").getSize());
-//
-// sessionFactory.getCurrentSession().flush();
-//
-// store.removeAttributes(ctx, user1, new String[] {"key3"});
-//
-// sessionFactory.getCurrentSession().flush();
-//
-// persistedAttrs = store.getAttributes(ctx, user1);
-//
-// assertEquals(2, persistedAttrs.keySet().size());
-//
-//
-// sessionFactory.getCurrentSession().getTransaction().commit();
-//
-// }
-//
-// public void testRelationships() throws Exception
-// {
-// commonTest.testRelationships();
-// }
-//
-// public void testCredentials() throws Exception
-// {
-// commonTest.testPasswordCredential();
-// commonTest.testBinaryCredential();
-// }
-//
-// public void testControls() throws Exception
-// {
-// commonTest.testControls();
-// }
-//
-//}
Copied:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java
(from rev 418,
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java)
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java
(rev 0)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -0,0 +1,305 @@
+/*
+* 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.store.hibernate;
+
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.idm.spi.store.IdentityStore;
+import org.jboss.identity.idm.spi.store.IdentityStoreSession;
+import
org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
+import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContextRegistry;
+import org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl;
+import org.jboss.identity.idm.impl.store.IdentityTypeEnum;
+import org.jboss.identity.idm.impl.store.CommonIdentityStoreTest;
+import org.jboss.identity.idm.impl.store.IdentityStoreTestContext;
+import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
+import org.jboss.identity.idm.impl.configuration.IdentityStoreConfigurationContextImpl;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
+import org.jboss.identity.idm.impl.api.SimpleAttribute;
+import org.jboss.identity.idm.impl.IdentityTestPOJO;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Test;
+import static org.jboss.unit.api.Assert.*;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+
+import java.util.Map;
+import java.io.File;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class HibernateIdentityStoreTestCase extends IdentityTestPOJO implements
IdentityStoreTestContext
+{
+
+ protected HibernateIdentityStoreImpl store;
+
+ protected IdentityStoreInvocationContext ctx;
+
+ protected CommonIdentityStoreTest commonTest;
+
+ public HibernateIdentityStoreTestCase()
+ {
+
+ }
+
+ @Create
+ public void setUp() throws Exception
+ {
+ super.start();
+
+ setIdentityConfig("store-test-config.xml");
+
+ commonTest = new CommonIdentityStoreTest(this);
+
+ IdentityConfigurationMetaData configurationMD = JAXB2IdentityConfiguration
+ .createConfigurationMetaData(getIdentityConfig());
+
+ IdentityConfigurationContextRegistry identityConfiguration =
(IdentityConfigurationContextRegistry)
+ new IdentityConfigurationImpl().configure(configurationMD);
+
+ IdentityStoreConfigurationMetaData storeMD = null;
+
+ for (IdentityStoreConfigurationMetaData metaData :
configurationMD.getIdentityStores())
+ {
+ if (metaData.getId().equals("HibernateTestStore"))
+ {
+ storeMD = metaData;
+ break;
+ }
+ }
+
+ IdentityStoreConfigurationContext context =
+ new IdentityStoreConfigurationContextImpl(configurationMD,
identityConfiguration, storeMD);
+
+ store = new HibernateIdentityStoreImpl("HibernateTestStore")
+ {
+
+ @Override
+ protected Session getHibernateSession(IdentityStoreInvocationContext ctx)
+ {
+ return getHibernateSupport().getSessionFactory().getCurrentSession();
+ }
+
+ @Override
+ protected SessionFactory
bootstrapHibernateSessionFactory(IdentityStoreConfigurationContext configurationContext)
throws IdentityException
+ {
+ return getHibernateSupport().getSessionFactory();
+ }
+
+ };
+
+ store.bootstrap(context);
+
+
+ ctx = new IdentityStoreInvocationContext()
+ {
+ public IdentityStoreSession getIdentityStoreSession()
+ {
+ return null;
+ }
+
+ public String getRealmId()
+ {
+ return "testRealm";
+ }
+ };
+
+
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.stop();
+ }
+
+ public void begin()
+ {
+ getHibernateSupport().openSession();
+ }
+
+ public void commit()
+ {
+ assertTrue(getHibernateSupport().commitTransaction());
+ }
+
+ public void flush() throws Exception
+ {
+
+ getHibernateSupport().getSessionFactory().getCurrentSession().flush();
+ }
+
+ public IdentityStore getStore()
+ {
+ return store;
+ }
+
+ public IdentityStoreInvocationContext getCtx()
+ {
+ return ctx;
+ }
+
+ // Tests
+
+ @Test
+ public void testStorePersistence() throws Exception
+ {
+
+ commonTest.testStorePersistence();
+
+ }
+
+ @Test
+ public void testFindMethods() throws Exception
+ {
+
+ commonTest.testFindMethods();
+
+ }
+
+ @Test
+ public void testAttributes() throws Exception
+ {
+
+ begin();
+
+ IdentityObject user1 = store.createIdentityObject(ctx, "Adam",
IdentityTypeEnum.USER);
+ IdentityObject user2 = store.createIdentityObject(ctx, "Eva",
IdentityTypeEnum.USER);
+
+ flush();
+
+ IdentityObjectAttribute[] attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("key1", new String[]{"val1",
"val2", "val3"}),
+ new SimpleAttribute("key2", new String[]{"val1",
"val2", "val3", "val4"})
+ };
+
+ store.addAttributes(ctx, user1, attrs);
+
+ flush();
+
+ Map<String, IdentityObjectAttribute> persistedAttrs =
store.getAttributes(ctx, user1);
+
+ assertEquals(2, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("key1"));
+ assertEquals(3, persistedAttrs.get("key1").getSize());
+
+ assertTrue(persistedAttrs.containsKey("key2"));
+ assertEquals(4, persistedAttrs.get("key2").getSize());
+
+ flush();
+
+ attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("key3", new String[]{"val1"})
+ };
+
+
+ store.addAttributes(ctx, user1, attrs);
+
+ flush();
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("key1"));
+ assertEquals(3, persistedAttrs.get("key1").getSize());
+
+ assertTrue(persistedAttrs.containsKey("key2"));
+ assertEquals(4, persistedAttrs.get("key2").getSize());
+
+ assertTrue(persistedAttrs.containsKey("key3"));
+ assertEquals(1, persistedAttrs.get("key3").getSize());
+
+ flush();
+
+ attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("key3", new String[]{"val2"})
+ };
+
+ store.addAttributes(ctx, user1, attrs);
+
+ flush();
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("key3"));
+ assertEquals(2, persistedAttrs.get("key3").getSize());
+
+ flush();
+
+ store.updateAttributes(ctx, user1, attrs);
+
+ flush();
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("key3"));
+ assertEquals(1, persistedAttrs.get("key3").getSize());
+
+ flush();
+
+ store.removeAttributes(ctx, user1, new String[] {"key3"});
+
+ flush();
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(2, persistedAttrs.keySet().size());
+
+
+ commit();
+
+ }
+
+ @Test
+ public void testRelationships() throws Exception
+ {
+ commonTest.testRelationships();
+ }
+
+ @Test
+ public void testCredentials() throws Exception
+ {
+ commonTest.testPasswordCredential();
+ commonTest.testBinaryCredential();
+ }
+
+ @Test
+ public void testControls() throws Exception
+ {
+ commonTest.testControls();
+ }
+
+}
\ No newline at end of file
Copied:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossTestCase.java
(from rev 418,
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java)
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossTestCase.java
(rev 0)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossTestCase.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -0,0 +1,341 @@
+/*
+* 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.store.hibernate;
+
+import
org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateRealm;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute;
+import org.jboss.identity.idm.impl.IdentityTestPOJO;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Test;
+import org.hibernate.Session;
+import org.hibernate.Query;
+import static org.jboss.unit.api.Assert.*;
+
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class HibernateModelJBossTestCase extends IdentityTestPOJO
+{
+ public HibernateModelJBossTestCase()
+ {
+ }
+
+
+ @Create
+ public void setUp() throws Exception
+ {
+ super.start();
+ }
+
+ @Destroy
+ public void tearDown() throws Exception
+ {
+ super.stop();
+ }
+
+ @Test
+ public void testPersistence() {
+
+
+ begin();
+ Session session = getSessionFactory().getCurrentSession();
+
+
+ HibernateRealm realm = new HibernateRealm("default");
+ session.persist(realm);
+
+ //
+
+ HibernateIdentityObjectType iot = new HibernateIdentityObjectType();
+ iot.setName("User");
+
+ session.persist(iot);
+ assertTrue(session.contains(iot));
+
+
+ HibernateIdentityObject io = new HibernateIdentityObject();
+ io.setName("John Kowalski");
+ io.setRealm(realm);
+ io.setIdentityType(iot);
+
+ session.persist(io);
+ assertTrue(session.contains(io));
+
+ session.delete(io);
+ assertFalse(session.contains(io));
+
+ //
+
+
+
+ //
+
+ HibernateIdentityObjectRelationshipType iort = new
HibernateIdentityObjectRelationshipType();
+ iort.setName("Member");
+
+ session.persist(iort);
+ assertTrue(session.contains(iort));
+
+ //
+
+// JPAIdentityObjectRelationship ior = new JPAIdentityObjectRelationship();
+// ior.setType(iort);
+//
+// em.persist(ior);
+// assertTrue(em.contains(ior));
+
+// em.remove(ior);
+// assertFalse(em.contains(ior));
+
+ //
+
+ assertTrue(session.contains(iort));
+
+ session.delete(iort);
+ assertFalse(session.contains(iort));
+
+ commit();
+
+
+ }
+
+ @Test
+ public void testRelationships()
+ {
+ begin();
+
+
+ Session session = getSessionFactory().getCurrentSession();
+
+
+ HibernateRealm realm = new HibernateRealm("default");
+ session.persist(realm);
+
+ HibernateIdentityObjectType groupType = new
HibernateIdentityObjectType("Group");
+ session.persist(groupType);
+ HibernateIdentityObjectType userType = new
HibernateIdentityObjectType("User");
+ session.persist(userType);
+
+ HibernateIdentityObject user1 = new HibernateIdentityObject("user1",
userType, realm);
+ session.persist(user1);
+ HibernateIdentityObject user2 = new HibernateIdentityObject("user2",
userType, realm);
+ session.persist(user2);
+ HibernateIdentityObject user3 = new HibernateIdentityObject("user3",
userType, realm);
+ session.persist(user3);
+
+ HibernateIdentityObject group1 = new HibernateIdentityObject("group1",
groupType, realm);
+ session.persist(group1);
+ HibernateIdentityObject group2 = new HibernateIdentityObject("group2",
groupType, realm);
+ session.persist(group2);
+ HibernateIdentityObject group3 = new HibernateIdentityObject("group3",
groupType, realm);
+ session.persist(group3);
+
+ HibernateIdentityObjectRelationshipType memberType = new
HibernateIdentityObjectRelationshipType("member");
+ session.persist(memberType);
+
+ HibernateIdentityObjectRelationship relationship = new
HibernateIdentityObjectRelationship(memberType, group1, user1);
+ session.persist(relationship);
+ relationship = new HibernateIdentityObjectRelationship(memberType, group1, user2);
+ session.persist(relationship);
+ relationship = new HibernateIdentityObjectRelationship(memberType, group2, user3);
+ session.persist(relationship);
+ relationship = new HibernateIdentityObjectRelationship(memberType, group2,
group1);
+ session.persist(relationship);
+
+ commit();
+
+ //
+
+
+ begin();
+
+ session = getSessionFactory().getCurrentSession();
+
+ Query ioQuery = session.createQuery("select o from HibernateIdentityObject o
where o.name like :name");
+
+ group1 = (HibernateIdentityObject)ioQuery.setParameter("name",
"group1").uniqueResult();
+ assertEquals(2, group1.getFromRelationships().size());
+ assertEquals(1, group1.getToRelationships().size());
+ group2 = (HibernateIdentityObject)ioQuery.setParameter("name",
"group2").uniqueResult();
+ assertEquals(2, group2.getFromRelationships().size());
+ assertEquals(0, group2.getToRelationships().size());
+
+ user3 = (HibernateIdentityObject)ioQuery.setParameter("name",
"user3").uniqueResult();
+ assertEquals(1, user3.getToRelationships().size());
+ assertEquals(0, user3.getFromRelationships().size());
+ assertEquals("group2",
user3.getToRelationships().iterator().next().getFromIdentityObject().getName());
+ commit();
+
+ }
+
+ @Test
+ public void testNameTypeConstraint() throws Exception
+ {
+
+ begin();
+ Session session = getSessionFactory().getCurrentSession();
+
+
+
+ HibernateRealm realm = new HibernateRealm("default");
+ session.persist(realm);
+
+ HibernateIdentityObjectType groupType = new
HibernateIdentityObjectType("Group");
+ session.persist(groupType);
+ HibernateIdentityObjectType userType = new
HibernateIdentityObjectType("User");
+ session.persist(userType);
+
+ HibernateIdentityObject user1 = new HibernateIdentityObject("user1",
userType, realm);
+ session.persist(user1);
+ HibernateIdentityObject user2 = new HibernateIdentityObject("user2",
userType, realm);
+ session.persist(user2);
+
+ commit();
+
+
+
+ begin();
+
+ session = getSessionFactory().getCurrentSession();
+
+ try
+ {
+
+ HibernateIdentityObject user3 = new HibernateIdentityObject("user2",
userType, realm);
+ session.persist(user3);
+
+ // Should fail
+ fail();
+ }
+ catch (Exception e)
+ {
+ //expected
+ getHibernateSupport().commitTransaction();
+ }
+
+
+
+ begin();
+
+ session = getSessionFactory().getCurrentSession();
+
+
+ HibernateIdentityObject user4 = new HibernateIdentityObject("group1",
userType, realm);
+ session.persist(user4);
+
+
+ HibernateIdentityObject group1 = new HibernateIdentityObject("group1",
groupType, realm);
+ session.persist(group1);
+ HibernateIdentityObject group2 = new HibernateIdentityObject("group2",
groupType, realm);
+ session.persist(group2);
+
+ //session.flush();
+
+ try
+ {
+
+ HibernateIdentityObject group3 = new HibernateIdentityObject("group2",
groupType, realm);
+ session.persist(group3);
+
+ // Should fail
+ fail();
+ }
+ catch (Exception e)
+ {
+ //expected
+ getHibernateSupport().commitTransaction();
+ }
+
+
+
+ begin();
+
+ session = getSessionFactory().getCurrentSession();
+
+ HibernateIdentityObject group4 = new HibernateIdentityObject("user1",
groupType, realm);
+ session.persist(group4);
+
+ session.flush();
+
+ commit();
+
+
+
+
+
+ }
+
+ @Test
+ public void testAttributes() throws Exception
+ {
+ begin();
+
+ Session session = getSessionFactory().getCurrentSession();
+
+
+
+
+ HibernateRealm realm = new HibernateRealm("default");
+ session.persist(realm);
+
+ HibernateIdentityObjectType userType = new
HibernateIdentityObjectType("User");
+ session.persist(userType);
+ HibernateIdentityObject user1 = new HibernateIdentityObject("user1",
userType, realm);
+ session.persist(user1);
+
+// Set<String> values1 = new HashSet<String>();
+// values1.add("Val1");
+// values1.add("Val2");
+// values1.add("Val3");
+
+
+ user1.getAttributes().add(new HibernateIdentityObjectTextAttribute(user1,
"simple1", new String[]{"Val1", "Val2",
"Val3"}));
+ user1.getAttributes().add(new HibernateIdentityObjectTextAttribute(user1,
"simple2", new String[]{"Val1", "Val2",
"Val3"}));
+
+
+ commit();
+
+
+
+ begin();
+
+ session = getSessionFactory().getCurrentSession();
+
+ user1 = (HibernateIdentityObject)session.get(HibernateIdentityObject.class, new
Long(user1.getId()));
+ assertEquals(2, user1.getAttributes().size() );
+// assertNotNull(user1.getProfileAttributes().get("simple1"));
+// assertEquals(3, user1.getProfileAttributes().get("simple1").length);
+
+
+ commit();
+
+ }
+
+}
\ No newline at end of file
Deleted:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -1,341 +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.identity.idm.impl.store.hibernate;
-
-import
org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
-import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject;
-import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType;
-import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship;
-import org.jboss.identity.idm.impl.model.hibernate.HibernateRealm;
-import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute;
-import org.jboss.identity.idm.impl.IdentityTestPOJO;
-import org.jboss.unit.api.pojo.annotations.Destroy;
-import org.jboss.unit.api.pojo.annotations.Create;
-import org.jboss.unit.api.pojo.annotations.Test;
-import org.hibernate.Session;
-import org.hibernate.Query;
-import static org.jboss.unit.api.Assert.*;
-
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
- * @version : 0.1 $
- */
-public class HibernateModelJBossUnitTest extends IdentityTestPOJO
-{
- public HibernateModelJBossUnitTest()
- {
- }
-
-
- @Create
- public void start() throws Exception
- {
- super.start();
- }
-
- @Destroy
- public void stop() throws Exception
- {
- super.stop();
- }
-
- @Test
- public void testPersistence() {
-
-
- begin();
- Session session = getSessionFactory().getCurrentSession();
-
-
- HibernateRealm realm = new HibernateRealm("default");
- session.persist(realm);
-
- //
-
- HibernateIdentityObjectType iot = new HibernateIdentityObjectType();
- iot.setName("User");
-
- session.persist(iot);
- assertTrue(session.contains(iot));
-
-
- HibernateIdentityObject io = new HibernateIdentityObject();
- io.setName("John Kowalski");
- io.setRealm(realm);
- io.setIdentityType(iot);
-
- session.persist(io);
- assertTrue(session.contains(io));
-
- session.delete(io);
- assertFalse(session.contains(io));
-
- //
-
-
-
- //
-
- HibernateIdentityObjectRelationshipType iort = new
HibernateIdentityObjectRelationshipType();
- iort.setName("Member");
-
- session.persist(iort);
- assertTrue(session.contains(iort));
-
- //
-
-// JPAIdentityObjectRelationship ior = new JPAIdentityObjectRelationship();
-// ior.setType(iort);
-//
-// em.persist(ior);
-// assertTrue(em.contains(ior));
-
-// em.remove(ior);
-// assertFalse(em.contains(ior));
-
- //
-
- assertTrue(session.contains(iort));
-
- session.delete(iort);
- assertFalse(session.contains(iort));
-
- commit();
-
-
- }
-
- @Test
- public void testRelationships()
- {
- begin();
-
-
- Session session = getSessionFactory().getCurrentSession();
-
-
- HibernateRealm realm = new HibernateRealm("default");
- session.persist(realm);
-
- HibernateIdentityObjectType groupType = new
HibernateIdentityObjectType("Group");
- session.persist(groupType);
- HibernateIdentityObjectType userType = new
HibernateIdentityObjectType("User");
- session.persist(userType);
-
- HibernateIdentityObject user1 = new HibernateIdentityObject("user1",
userType, realm);
- session.persist(user1);
- HibernateIdentityObject user2 = new HibernateIdentityObject("user2",
userType, realm);
- session.persist(user2);
- HibernateIdentityObject user3 = new HibernateIdentityObject("user3",
userType, realm);
- session.persist(user3);
-
- HibernateIdentityObject group1 = new HibernateIdentityObject("group1",
groupType, realm);
- session.persist(group1);
- HibernateIdentityObject group2 = new HibernateIdentityObject("group2",
groupType, realm);
- session.persist(group2);
- HibernateIdentityObject group3 = new HibernateIdentityObject("group3",
groupType, realm);
- session.persist(group3);
-
- HibernateIdentityObjectRelationshipType memberType = new
HibernateIdentityObjectRelationshipType("member");
- session.persist(memberType);
-
- HibernateIdentityObjectRelationship relationship = new
HibernateIdentityObjectRelationship(memberType, group1, user1);
- session.persist(relationship);
- relationship = new HibernateIdentityObjectRelationship(memberType, group1, user2);
- session.persist(relationship);
- relationship = new HibernateIdentityObjectRelationship(memberType, group2, user3);
- session.persist(relationship);
- relationship = new HibernateIdentityObjectRelationship(memberType, group2,
group1);
- session.persist(relationship);
-
- commit();
-
- //
-
-
- begin();
-
- session = getSessionFactory().getCurrentSession();
-
- Query ioQuery = session.createQuery("select o from HibernateIdentityObject o
where o.name like :name");
-
- group1 = (HibernateIdentityObject)ioQuery.setParameter("name",
"group1").uniqueResult();
- assertEquals(2, group1.getFromRelationships().size());
- assertEquals(1, group1.getToRelationships().size());
- group2 = (HibernateIdentityObject)ioQuery.setParameter("name",
"group2").uniqueResult();
- assertEquals(2, group2.getFromRelationships().size());
- assertEquals(0, group2.getToRelationships().size());
-
- user3 = (HibernateIdentityObject)ioQuery.setParameter("name",
"user3").uniqueResult();
- assertEquals(1, user3.getToRelationships().size());
- assertEquals(0, user3.getFromRelationships().size());
- assertEquals("group2",
user3.getToRelationships().iterator().next().getFromIdentityObject().getName());
- commit();
-
- }
-
- @Test
- public void testNameTypeConstraint() throws Exception
- {
-
- begin();
- Session session = getSessionFactory().getCurrentSession();
-
-
-
- HibernateRealm realm = new HibernateRealm("default");
- session.persist(realm);
-
- HibernateIdentityObjectType groupType = new
HibernateIdentityObjectType("Group");
- session.persist(groupType);
- HibernateIdentityObjectType userType = new
HibernateIdentityObjectType("User");
- session.persist(userType);
-
- HibernateIdentityObject user1 = new HibernateIdentityObject("user1",
userType, realm);
- session.persist(user1);
- HibernateIdentityObject user2 = new HibernateIdentityObject("user2",
userType, realm);
- session.persist(user2);
-
- commit();
-
-
-
- begin();
-
- session = getSessionFactory().getCurrentSession();
-
- try
- {
-
- HibernateIdentityObject user3 = new HibernateIdentityObject("user2",
userType, realm);
- session.persist(user3);
-
- // Should fail
- fail();
- }
- catch (Exception e)
- {
- //expected
- getHibernateSupport().commitTransaction();
- }
-
-
-
- begin();
-
- session = getSessionFactory().getCurrentSession();
-
-
- HibernateIdentityObject user4 = new HibernateIdentityObject("group1",
userType, realm);
- session.persist(user4);
-
-
- HibernateIdentityObject group1 = new HibernateIdentityObject("group1",
groupType, realm);
- session.persist(group1);
- HibernateIdentityObject group2 = new HibernateIdentityObject("group2",
groupType, realm);
- session.persist(group2);
-
- //session.flush();
-
- try
- {
-
- HibernateIdentityObject group3 = new HibernateIdentityObject("group2",
groupType, realm);
- session.persist(group3);
-
- // Should fail
- fail();
- }
- catch (Exception e)
- {
- //expected
- getHibernateSupport().commitTransaction();
- }
-
-
-
- begin();
-
- session = getSessionFactory().getCurrentSession();
-
- HibernateIdentityObject group4 = new HibernateIdentityObject("user1",
groupType, realm);
- session.persist(group4);
-
- session.flush();
-
- commit();
-
-
-
-
-
- }
-
- @Test
- public void testAttributes() throws Exception
- {
- begin();
-
- Session session = getSessionFactory().getCurrentSession();
-
-
-
-
- HibernateRealm realm = new HibernateRealm("default");
- session.persist(realm);
-
- HibernateIdentityObjectType userType = new
HibernateIdentityObjectType("User");
- session.persist(userType);
- HibernateIdentityObject user1 = new HibernateIdentityObject("user1",
userType, realm);
- session.persist(user1);
-
-// Set<String> values1 = new HashSet<String>();
-// values1.add("Val1");
-// values1.add("Val2");
-// values1.add("Val3");
-
-
- user1.getAttributes().add(new HibernateIdentityObjectTextAttribute(user1,
"simple1", new String[]{"Val1", "Val2",
"Val3"}));
- user1.getAttributes().add(new HibernateIdentityObjectTextAttribute(user1,
"simple2", new String[]{"Val1", "Val2",
"Val3"}));
-
-
- commit();
-
-
-
- begin();
-
- session = getSessionFactory().getCurrentSession();
-
- user1 = (HibernateIdentityObject)session.get(HibernateIdentityObject.class, new
Long(user1.getId()));
- assertEquals(2, user1.getAttributes().size() );
-// assertNotNull(user1.getProfileAttributes().get("simple1"));
-// assertEquals(3, user1.getProfileAttributes().get("simple1").length);
-
-
- commit();
-
- }
-
-}
\ No newline at end of file
Deleted:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -1,304 +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.identity.idm.impl.store.hibernate;
-//
-//import org.jboss.identity.idm.impl.store.hibernate.HibernateTestBase;
-//import
org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
-//import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject;
-//import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType;
-//import
org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship;
-//import org.jboss.identity.idm.impl.model.hibernate.HibernateRealm;
-//import
org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute;
-//import org.hibernate.Session;
-//import org.hibernate.Query;
-//
-///**
-// * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
-// * @version : 0.1 $
-// */
-//public class HibernateModelTestCase extends HibernateTestBase
-//{
-// public HibernateModelTestCase(String testName)
-// {
-// super(testName);
-// }
-//
-// public void testPersistence() {
-//
-// Session session = sessionFactory.getCurrentSession();
-// session.getTransaction().begin();
-//
-// HibernateRealm realm = new HibernateRealm("default");
-// session.persist(realm);
-//
-// //
-//
-// HibernateIdentityObjectType iot = new HibernateIdentityObjectType();
-// iot.setName("User");
-//
-// session.persist(iot);
-// assertTrue(session.contains(iot));
-//
-//
-// HibernateIdentityObject io = new HibernateIdentityObject();
-// io.setName("John Kowalski");
-// io.setRealm(realm);
-// io.setIdentityType(iot);
-//
-// session.persist(io);
-// assertTrue(session.contains(io));
-//
-// session.delete(io);
-// assertFalse(session.contains(io));
-//
-// //
-//
-//
-//
-// //
-//
-// HibernateIdentityObjectRelationshipType iort = new
HibernateIdentityObjectRelationshipType();
-// iort.setName("Member");
-//
-// session.persist(iort);
-// assertTrue(session.contains(iort));
-//
-// //
-//
-//// JPAIdentityObjectRelationship ior = new JPAIdentityObjectRelationship();
-//// ior.setType(iort);
-////
-//// em.persist(ior);
-//// assertTrue(em.contains(ior));
-//
-//// em.remove(ior);
-//// assertFalse(em.contains(ior));
-//
-// //
-//
-// assertTrue(session.contains(iort));
-//
-// session.delete(iort);
-// assertFalse(session.contains(iort));
-//
-// session.getTransaction().commit();
-//
-//
-// }
-//
-// public void testRelationships()
-// {
-// Session session = sessionFactory.getCurrentSession();
-//
-// session.getTransaction().begin();
-//
-// HibernateRealm realm = new HibernateRealm("default");
-// session.persist(realm);
-//
-// HibernateIdentityObjectType groupType = new
HibernateIdentityObjectType("Group");
-// session.persist(groupType);
-// HibernateIdentityObjectType userType = new
HibernateIdentityObjectType("User");
-// session.persist(userType);
-//
-// HibernateIdentityObject user1 = new HibernateIdentityObject("user1",
userType, realm);
-// session.persist(user1);
-// HibernateIdentityObject user2 = new HibernateIdentityObject("user2",
userType, realm);
-// session.persist(user2);
-// HibernateIdentityObject user3 = new HibernateIdentityObject("user3",
userType, realm);
-// session.persist(user3);
-//
-// HibernateIdentityObject group1 = new HibernateIdentityObject("group1",
groupType, realm);
-// session.persist(group1);
-// HibernateIdentityObject group2 = new HibernateIdentityObject("group2",
groupType, realm);
-// session.persist(group2);
-// HibernateIdentityObject group3 = new HibernateIdentityObject("group3",
groupType, realm);
-// session.persist(group3);
-//
-// HibernateIdentityObjectRelationshipType memberType = new
HibernateIdentityObjectRelationshipType("member");
-// session.persist(memberType);
-//
-// HibernateIdentityObjectRelationship relationship = new
HibernateIdentityObjectRelationship(memberType, group1, user1);
-// session.persist(relationship);
-// relationship = new HibernateIdentityObjectRelationship(memberType, group1,
user2);
-// session.persist(relationship);
-// relationship = new HibernateIdentityObjectRelationship(memberType, group2,
user3);
-// session.persist(relationship);
-// relationship = new HibernateIdentityObjectRelationship(memberType, group2,
group1);
-// session.persist(relationship);
-//
-// session.getTransaction().commit();
-//
-// //
-// session = sessionFactory.getCurrentSession();
-//
-// session.getTransaction().begin();
-//
-// Query ioQuery = session.createQuery("select o from HibernateIdentityObject o
where o.name like :name");
-//
-// group1 = (HibernateIdentityObject)ioQuery.setParameter("name",
"group1").uniqueResult();
-// assertEquals(2, group1.getFromRelationships().size());
-// assertEquals(1, group1.getToRelationships().size());
-// group2 = (HibernateIdentityObject)ioQuery.setParameter("name",
"group2").uniqueResult();
-// assertEquals(2, group2.getFromRelationships().size());
-// assertEquals(0, group2.getToRelationships().size());
-//
-// user3 = (HibernateIdentityObject)ioQuery.setParameter("name",
"user3").uniqueResult();
-// assertEquals(1, user3.getToRelationships().size());
-// assertEquals(0, user3.getFromRelationships().size());
-// assertEquals("group2",
user3.getToRelationships().iterator().next().getFromIdentityObject().getName());
-// session.getTransaction().commit();
-//
-// }
-//
-// public void testNameTypeConstraint() throws Exception
-// {
-//
-// Session session = sessionFactory.getCurrentSession();
-//
-// session.getTransaction().begin();
-//
-// HibernateRealm realm = new HibernateRealm("default");
-// session.persist(realm);
-//
-// HibernateIdentityObjectType groupType = new
HibernateIdentityObjectType("Group");
-// session.persist(groupType);
-// HibernateIdentityObjectType userType = new
HibernateIdentityObjectType("User");
-// session.persist(userType);
-//
-// HibernateIdentityObject user1 = new HibernateIdentityObject("user1",
userType, realm);
-// session.persist(user1);
-// HibernateIdentityObject user2 = new HibernateIdentityObject("user2",
userType, realm);
-// session.persist(user2);
-//
-// session.getTransaction().commit();
-//
-// session = sessionFactory.getCurrentSession();
-//
-// session.getTransaction().begin();
-//
-// try
-// {
-//
-// HibernateIdentityObject user3 = new HibernateIdentityObject("user2",
userType, realm);
-// session.persist(user3);
-//
-// // Should fail
-// fail();
-// }
-// catch (Exception e)
-// {
-// //expected
-// session.getTransaction().rollback();
-// }
-//
-// session = sessionFactory.getCurrentSession();
-//
-// session.getTransaction().begin();
-//
-//
-// HibernateIdentityObject user4 = new HibernateIdentityObject("group1",
userType, realm);
-// session.persist(user4);
-//
-//
-// HibernateIdentityObject group1 = new HibernateIdentityObject("group1",
groupType, realm);
-// session.persist(group1);
-// HibernateIdentityObject group2 = new HibernateIdentityObject("group2",
groupType, realm);
-// session.persist(group2);
-//
-// //session.flush();
-//
-// try
-// {
-//
-// HibernateIdentityObject group3 = new
HibernateIdentityObject("group2", groupType, realm);
-// session.persist(group3);
-//
-// // Should fail
-// fail();
-// }
-// catch (Exception e)
-// {
-// //expected
-// session.getTransaction().rollback();
-// }
-//
-// session = sessionFactory.getCurrentSession();
-//
-// session.getTransaction().begin();
-//
-// HibernateIdentityObject group4 = new HibernateIdentityObject("user1",
groupType, realm);
-// session.persist(group4);
-//
-// session.flush();
-//
-// session.getTransaction().commit();
-//
-//
-//
-//
-//
-// }
-//
-//
-// public void testAttributes() throws Exception
-// {
-// Session session = sessionFactory.getCurrentSession();
-//
-//
-// session.getTransaction().begin();
-//
-// HibernateRealm realm = new HibernateRealm("default");
-// session.persist(realm);
-//
-// HibernateIdentityObjectType userType = new
HibernateIdentityObjectType("User");
-// session.persist(userType);
-// HibernateIdentityObject user1 = new HibernateIdentityObject("user1",
userType, realm);
-// session.persist(user1);
-//
-//// Set<String> values1 = new HashSet<String>();
-//// values1.add("Val1");
-//// values1.add("Val2");
-//// values1.add("Val3");
-//
-//
-// user1.getAttributes().add(new HibernateIdentityObjectTextAttribute(user1,
"simple1", new String[]{"Val1", "Val2",
"Val3"}));
-// user1.getAttributes().add(new HibernateIdentityObjectTextAttribute(user1,
"simple2", new String[]{"Val1", "Val2",
"Val3"}));
-//
-//
-// session.getTransaction().commit();
-//
-// session = sessionFactory.getCurrentSession();
-//
-// session.getTransaction().begin();
-//
-// user1 = (HibernateIdentityObject)session.get(HibernateIdentityObject.class, new
Long(user1.getId()));
-// assertEquals(2, user1.getAttributes().size() );
-//// assertNotNull(user1.getProfileAttributes().get("simple1"));
-//// assertEquals(3, user1.getProfileAttributes().get("simple1").length);
-//
-//
-// session.getTransaction().commit();
-//
-// }
-//
-//}
Deleted:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -1,64 +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.identity.idm.impl.store.hibernate;
-//
-//import junit.framework.TestCase;
-//
-//import java.util.logging.Logger;
-//
-//import org.hibernate.SessionFactory;
-//import org.jboss.identity.idm.impl.HibernateTestSupport;
-//
-///**
-// * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
-// * @version : 0.1 $
-// */
-//public abstract class HibernateTestBase extends TestCase
-//{
-// private static Logger logger =
Logger.getLogger(HibernateModelTestCase.class.getName());
-//
-// private HibernateTestSupport hibernateSupport =
-// new HibernateTestSupport("unit-testing-jpa",
"hibernate-jboss-identity-classes.cfg.xml");
-//
-// protected SessionFactory sessionFactory;
-//
-//
-//
-//
-// public HibernateTestBase(String testName) {
-// super(testName);
-// }
-//
-// @Override
-// protected void setUp() throws Exception {
-// super.setUp();
-// hibernateSupport.start();
-// sessionFactory = hibernateSupport.getSessionFactory();
-// }
-//
-// @Override
-// protected void tearDown() throws Exception {
-// super.tearDown();
-// hibernateSupport.stop();
-// }
-//}
Deleted:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java 2009-04-02
21:11:13 UTC (rev 418)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -1,437 +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.identity.idm.impl.store.ldap;
-
-import junit.framework.TestCase;
-import org.jboss.identity.idm.opends.OpenDSService;
-import org.jboss.identity.idm.spi.store.IdentityStore;
-import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.idm.spi.store.IdentityStoreSession;
-import org.jboss.identity.idm.spi.model.IdentityObject;
-import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
-import
org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContextRegistry;
-import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
-import org.jboss.identity.idm.impl.store.IdentityTypeEnum;
-import org.jboss.identity.idm.impl.store.CommonIdentityStoreTest;
-import org.jboss.identity.idm.impl.store.IdentityStoreTestContext;
-import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
-import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
-import org.jboss.identity.idm.impl.configuration.IdentityStoreConfigurationContextImpl;
-import org.jboss.identity.idm.impl.api.SimpleAttribute;
-import org.jboss.identity.idm.impl.LDAPTestPOJO;
-import org.jboss.identity.idm.exception.IdentityException;
-import org.jboss.unit.api.pojo.annotations.Create;
-import org.jboss.unit.api.pojo.annotations.Destroy;
-import org.jboss.unit.api.pojo.annotations.Test;
-import org.opends.server.tools.LDAPModify;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.NamingEnumeration;
-import javax.naming.Binding;
-import javax.naming.directory.DirContext;
-import javax.naming.ldap.LdapContext;
-import javax.naming.ldap.InitialLdapContext;
-import java.util.Hashtable;
-import java.util.Map;
-import java.io.File;
-import static org.jboss.unit.api.Assert.*;
-
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
- * @version : 0.1 $
- */
-public class
- LDAPIdentityStoreJBossUnitTest extends LDAPTestPOJO implements
IdentityStoreTestContext
-{
-
- CommonIdentityStoreTest commonTest;
-
- IdentityStoreInvocationContext ctx;
-
- IdentityStore store;
-
- public LDAPIdentityStoreJBossUnitTest()
- {
-
- }
-
- @Create
- public void start() throws Exception
- {
- super.start();
-
- commonTest = new CommonIdentityStoreTest(this);
-
- IdentityConfigurationMetaData configurationMD = JAXB2IdentityConfiguration
- .createConfigurationMetaData(getIdentityConfig());
-
- IdentityConfigurationContextRegistry registry =
(IdentityConfigurationContextRegistry) new IdentityConfigurationImpl().
- configure(configurationMD);
-
- IdentityStoreConfigurationMetaData storeMD = null;
-
- for (IdentityStoreConfigurationMetaData metaData :
configurationMD.getIdentityStores())
- {
- if (metaData.getId().equals("LDAPTestStore"))
- {
- storeMD = metaData;
- break;
- }
- }
-
- IdentityStoreConfigurationContext context = new
IdentityStoreConfigurationContextImpl(configurationMD, registry, storeMD);
-
- ctx = new IdentityStoreInvocationContext()
- {
- public IdentityStoreSession getIdentityStoreSession()
- {
- return new IdentityStoreSession(){
-
- public Object getSessionContext() throws IdentityException
- {
- try
- {
- return getLdapContext();
- }
- catch (Exception e)
- {
- throw new IdentityException("Failed to obtain LDAP connection:
", e);
- }
- }
-
- public void close() throws IdentityException
- {
-
- }
-
- public void save() throws IdentityException
- {
-
- }
-
- public void clear() throws IdentityException
- {
-
- }
-
- public boolean isOpen()
- {
- return false;
- }
-
- public boolean isTransactionSupported()
- {
- return false;
- }
-
- public void startTransaction()
- {
-
- }
-
- public void commitTransaction()
- {
-
- }
-
- public void rollbackTransaction()
- {
-
- }
-
- public boolean isTransactionActive()
- {
- return false;
- }
- };
- }
-
- public String getRealmId()
- {
- return "testRealm";
- }
- };
-
- //populate();
-
- store = new LDAPIdentityStoreImpl("LDAPTestStore");
-
- store.bootstrap(context);
- }
-
- @Destroy
- public void stop() throws Exception
- {
- super.stop();
- }
-
-
- public void flush() throws Exception
- {
- //nothing
- }
-
- public IdentityStore getStore()
- {
- return store;
- }
-
- public IdentityStoreInvocationContext getCtx()
- {
- return ctx;
- }
-
-
- // Tests
-
-// Just test if OpenDS is running and was populated...
- @Test
- public void testSimple() throws Exception
- {
- populate();
-
- Hashtable<String,String> env = new Hashtable<String,String>();
- 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);
-
- LdapContext ldapCtx = null;
- try
- {
- ldapCtx = new InitialLdapContext(env, null);
-
-// Do something ...
- System.out.println("Attributes: " +
ldapCtx.getAttributes("o=test,dc=portal,dc=example,dc=com"));
-
- }
- catch (NamingException e)
- {
- e.printStackTrace();
- }
- finally
- {
- try
- {
- if (ldapCtx != null)
- {
- ldapCtx.close();
- }
- }
- catch (NamingException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- @Test
- public void testIdentityObjectCount() throws Exception
- {
- populate();
-
- assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.USER));
- assertEquals(5, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.ROLE));
- assertEquals(2, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.GROUP));
- }
-
- @Test
- public void testFindCreateRemove() throws Exception
- {
- populate();
-
- assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.USER));
-
- IdentityObject io = store.findIdentityObject(ctx, "admin",
IdentityTypeEnum.USER);
- assertEquals("admin", io.getName());
- assertEquals("uid=admin,ou=People,o=test,dc=portal,dc=example,dc=com",
io.getId().toString());
-
- //
-
- store.removeIdentityObject(ctx, io);
-
- assertEquals(6, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.USER));
-
- store.createIdentityObject(ctx, "newUserA", IdentityTypeEnum.USER);
-
- assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.USER));
-
- //
-
- assertEquals(2, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.GROUP));
-
- store.createIdentityObject(ctx, "newGroupA", IdentityTypeEnum.GROUP);
-
- assertEquals(3, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.GROUP));
-
- //
-
- io = store.findIdentityObject(ctx,
"cn=newGroupA,ou=Groups,o=test,dc=portal,dc=example,dc=com");
- assertEquals("newGroupA", io.getName());
-
- }
-
- @Test
- public void testAttributes() throws Exception{
-
- populate();
-
- IdentityObject user1 = store.createIdentityObject(ctx, "Adam",
IdentityTypeEnum.USER);
- IdentityObject user2 = store.createIdentityObject(ctx, "Eva",
IdentityTypeEnum.USER);
-
- //
-
- IdentityObjectAttribute[] attrs = new IdentityObjectAttribute[]{
- new SimpleAttribute("phone", new String[]{"val1",
"val2", "val3"}),
- new SimpleAttribute("description", new String[]{"val1",
"val2", "val3", "val4"}),
-
- };
-
- store.addAttributes(ctx, user1, attrs);
-
- //
-
- Map<String, IdentityObjectAttribute> persistedAttrs =
store.getAttributes(ctx, user1);
-
- assertEquals(2, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("phone"));
- assertEquals(3, persistedAttrs.get("phone").getSize());
-
- assertTrue(persistedAttrs.containsKey("description"));
- assertEquals(4, persistedAttrs.get("description").getSize());
-
- //
-
- attrs = new IdentityObjectAttribute[]{
- new SimpleAttribute("carLicense", new String[]{"val1"})
- };
-
- store.addAttributes(ctx, user1, attrs);
-
- //
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("phone"));
- assertEquals(3, persistedAttrs.get("phone").getSize());
-
- assertTrue(persistedAttrs.containsKey("description"));
- assertEquals(4, persistedAttrs.get("description").getSize());
-
- assertTrue(persistedAttrs.containsKey("carLicense"));
- assertEquals(1, persistedAttrs.get("carLicense").getSize());
-
- attrs = new IdentityObjectAttribute[]{
- new SimpleAttribute("carLicense", new String[]{"val2"})
- };
-
- store.addAttributes(ctx, user1, attrs);
-
- //
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("carLicense"));
- assertEquals(2, persistedAttrs.get("carLicense").getSize());
-
- //
-
- store.updateAttributes(ctx, user1, attrs);
-
- //
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("carLicense"));
- assertEquals(1, persistedAttrs.get("carLicense").getSize());
-
- //
-
- String[] names = new String[]{"carLicense"};
- store.removeAttributes(ctx, user1, names);
-
- //
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(2, persistedAttrs.keySet().size());
-
- }
-
- @Test
- public void testRelationships() throws Exception
- {
- populateClean();
-
- commonTest.testRelationships();
-
- }
-
- @Test
- public void testStorePersistence() throws Exception
- {
- populateClean();
-
- commonTest.testStorePersistence();
-
- }
-
- @Test
- public void testFindMethods() throws Exception
- {
- populateClean();
-
- commonTest.testFindMethods();
-
- }
-
- @Test
- public void testControls() throws Exception
- {
- populateClean();
-
- commonTest.testControls();
- }
-
-
- @Test
- public void testCredentials() throws Exception
- {
- populateClean();
-
- commonTest.testPasswordCredential();
- }
-
-}
Copied:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java
(from rev 418,
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java)
===================================================================
---
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java
(rev 0)
+++
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java 2009-04-02
22:19:30 UTC (rev 419)
@@ -0,0 +1,438 @@
+/*
+* 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.store.ldap;
+
+import junit.framework.TestCase;
+import org.jboss.identity.idm.opends.OpenDSService;
+import org.jboss.identity.idm.spi.store.IdentityStore;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.idm.spi.store.IdentityStoreSession;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import
org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContextRegistry;
+import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
+import org.jboss.identity.idm.impl.store.IdentityTypeEnum;
+import org.jboss.identity.idm.impl.store.CommonIdentityStoreTest;
+import org.jboss.identity.idm.impl.store.IdentityStoreTestContext;
+import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
+import org.jboss.identity.idm.impl.configuration.IdentityStoreConfigurationContextImpl;
+import org.jboss.identity.idm.impl.api.SimpleAttribute;
+import org.jboss.identity.idm.impl.LDAPTestPOJO;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Test;
+import org.opends.server.tools.LDAPModify;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+import javax.naming.Binding;
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.InitialLdapContext;
+import java.util.Hashtable;
+import java.util.Map;
+import java.io.File;
+import static org.jboss.unit.api.Assert.*;
+
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class LDAPIdentityStoreTestCase extends LDAPTestPOJO implements
IdentityStoreTestContext
+{
+
+ CommonIdentityStoreTest commonTest;
+
+ IdentityStoreInvocationContext ctx;
+
+ IdentityStore store;
+
+ public LDAPIdentityStoreTestCase()
+ {
+
+ }
+
+ @Create
+ public void setUp() throws Exception
+ {
+ super.start();
+
+ setIdentityConfig("store-test-config.xml");
+
+ commonTest = new CommonIdentityStoreTest(this);
+
+ IdentityConfigurationMetaData configurationMD = JAXB2IdentityConfiguration
+ .createConfigurationMetaData(getIdentityConfig());
+
+ IdentityConfigurationContextRegistry registry =
(IdentityConfigurationContextRegistry) new IdentityConfigurationImpl().
+ configure(configurationMD);
+
+ IdentityStoreConfigurationMetaData storeMD = null;
+
+ for (IdentityStoreConfigurationMetaData metaData :
configurationMD.getIdentityStores())
+ {
+ if (metaData.getId().equals("LDAPTestStore"))
+ {
+ storeMD = metaData;
+ break;
+ }
+ }
+
+ IdentityStoreConfigurationContext context = new
IdentityStoreConfigurationContextImpl(configurationMD, registry, storeMD);
+
+ ctx = new IdentityStoreInvocationContext()
+ {
+ public IdentityStoreSession getIdentityStoreSession()
+ {
+ return new IdentityStoreSession(){
+
+ public Object getSessionContext() throws IdentityException
+ {
+ try
+ {
+ return getLdapContext();
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Failed to obtain LDAP connection:
", e);
+ }
+ }
+
+ public void close() throws IdentityException
+ {
+
+ }
+
+ public void save() throws IdentityException
+ {
+
+ }
+
+ public void clear() throws IdentityException
+ {
+
+ }
+
+ public boolean isOpen()
+ {
+ return false;
+ }
+
+ public boolean isTransactionSupported()
+ {
+ return false;
+ }
+
+ public void startTransaction()
+ {
+
+ }
+
+ public void commitTransaction()
+ {
+
+ }
+
+ public void rollbackTransaction()
+ {
+
+ }
+
+ public boolean isTransactionActive()
+ {
+ return false;
+ }
+ };
+ }
+
+ public String getRealmId()
+ {
+ return "testRealm";
+ }
+ };
+
+ //populate();
+
+ store = new LDAPIdentityStoreImpl("LDAPTestStore");
+
+ store.bootstrap(context);
+ }
+
+ @Destroy
+ public void tearDown() throws Exception
+ {
+ super.stop();
+ }
+
+
+ public void flush() throws Exception
+ {
+ //nothing
+ }
+
+ public IdentityStore getStore()
+ {
+ return store;
+ }
+
+ public IdentityStoreInvocationContext getCtx()
+ {
+ return ctx;
+ }
+
+
+ // Tests
+
+// Just test if OpenDS is running and was populated...
+ @Test
+ public void testSimple() throws Exception
+ {
+ populate();
+
+ Hashtable<String,String> env = new Hashtable<String,String>();
+ 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);
+
+ LdapContext ldapCtx = null;
+ try
+ {
+ ldapCtx = new InitialLdapContext(env, null);
+
+// Do something ...
+ System.out.println("Attributes: " +
ldapCtx.getAttributes("o=test,dc=portal,dc=example,dc=com"));
+
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ try
+ {
+ if (ldapCtx != null)
+ {
+ ldapCtx.close();
+ }
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Test
+ public void testIdentityObjectCount() throws Exception
+ {
+ populate();
+
+ assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.USER));
+ assertEquals(5, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.ROLE));
+ assertEquals(2, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.GROUP));
+ }
+
+ @Test
+ public void testFindCreateRemove() throws Exception
+ {
+ populate();
+
+ assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.USER));
+
+ IdentityObject io = store.findIdentityObject(ctx, "admin",
IdentityTypeEnum.USER);
+ assertEquals("admin", io.getName());
+ assertEquals("uid=admin,ou=People,o=test,dc=portal,dc=example,dc=com",
io.getId().toString());
+
+ //
+
+ store.removeIdentityObject(ctx, io);
+
+ assertEquals(6, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.USER));
+
+ store.createIdentityObject(ctx, "newUserA", IdentityTypeEnum.USER);
+
+ assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.USER));
+
+ //
+
+ assertEquals(2, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.GROUP));
+
+ store.createIdentityObject(ctx, "newGroupA", IdentityTypeEnum.GROUP);
+
+ assertEquals(3, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.GROUP));
+
+ //
+
+ io = store.findIdentityObject(ctx,
"cn=newGroupA,ou=Groups,o=test,dc=portal,dc=example,dc=com");
+ assertEquals("newGroupA", io.getName());
+
+ }
+
+ @Test
+ public void testAttributes() throws Exception{
+
+ populate();
+
+ IdentityObject user1 = store.createIdentityObject(ctx, "Adam",
IdentityTypeEnum.USER);
+ IdentityObject user2 = store.createIdentityObject(ctx, "Eva",
IdentityTypeEnum.USER);
+
+ //
+
+ IdentityObjectAttribute[] attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("phone", new String[]{"val1",
"val2", "val3"}),
+ new SimpleAttribute("description", new String[]{"val1",
"val2", "val3", "val4"}),
+
+ };
+
+ store.addAttributes(ctx, user1, attrs);
+
+ //
+
+ Map<String, IdentityObjectAttribute> persistedAttrs =
store.getAttributes(ctx, user1);
+
+ assertEquals(2, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("phone"));
+ assertEquals(3, persistedAttrs.get("phone").getSize());
+
+ assertTrue(persistedAttrs.containsKey("description"));
+ assertEquals(4, persistedAttrs.get("description").getSize());
+
+ //
+
+ attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("carLicense", new String[]{"val1"})
+ };
+
+ store.addAttributes(ctx, user1, attrs);
+
+ //
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("phone"));
+ assertEquals(3, persistedAttrs.get("phone").getSize());
+
+ assertTrue(persistedAttrs.containsKey("description"));
+ assertEquals(4, persistedAttrs.get("description").getSize());
+
+ assertTrue(persistedAttrs.containsKey("carLicense"));
+ assertEquals(1, persistedAttrs.get("carLicense").getSize());
+
+ attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("carLicense", new String[]{"val2"})
+ };
+
+ store.addAttributes(ctx, user1, attrs);
+
+ //
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("carLicense"));
+ assertEquals(2, persistedAttrs.get("carLicense").getSize());
+
+ //
+
+ store.updateAttributes(ctx, user1, attrs);
+
+ //
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("carLicense"));
+ assertEquals(1, persistedAttrs.get("carLicense").getSize());
+
+ //
+
+ String[] names = new String[]{"carLicense"};
+ store.removeAttributes(ctx, user1, names);
+
+ //
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(2, persistedAttrs.keySet().size());
+
+ }
+
+ @Test
+ public void testRelationships() throws Exception
+ {
+ populateClean();
+
+ commonTest.testRelationships();
+
+ }
+
+ @Test
+ public void testStorePersistence() throws Exception
+ {
+ populateClean();
+
+ commonTest.testStorePersistence();
+
+ }
+
+ @Test
+ public void testFindMethods() throws Exception
+ {
+ populateClean();
+
+ commonTest.testFindMethods();
+
+ }
+
+ @Test
+ public void testControls() throws Exception
+ {
+ populateClean();
+
+ commonTest.testControls();
+ }
+
+
+ @Test
+ public void testCredentials() throws Exception
+ {
+ populateClean();
+
+ commonTest.testPasswordCredential();
+ }
+
+}
Modified: idm/branches/proto/idm/src/test/resources/jboss-unit.xml
===================================================================
--- idm/branches/proto/idm/src/test/resources/jboss-unit.xml 2009-04-02 21:11:13 UTC (rev
418)
+++ idm/branches/proto/idm/src/test/resources/jboss-unit.xml 2009-04-02 22:19:30 UTC (rev
419)
@@ -27,31 +27,31 @@
<!--Without LDAP-->
<test >
- <class
name="org.jboss.identity.idm.impl.api.APIJBossUnitTest"/>
+ <class name="org.jboss.identity.idm.impl.api.APITestCase"/>
<parameter name="realmName"
value="realm://RedHat/DB"/>
</test>
<!--With LDAP-->
<test >
- <class
name="org.jboss.identity.idm.impl.api.APILDAPJBossUnitTest"/>
+ <class
name="org.jboss.identity.idm.impl.api.APILDAPTestCase"/>
<parameter name="directoryName"
value="EmbeddedOpenDS"/>
<parameter name="realmName"
value="realm://RedHat/DB_LDAP"/>
</test>
<!--Without LDAP-->
<test >
- <class
name="org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreJBossUnitTest"/>
+ <class
name="org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreTestCase"/>
<parameter name="identityConfig"
value="store-test-config.xml"/>
</test>
<!--Without LDAP-->
<test >
- <class
name="org.jboss.identity.idm.impl.store.hibernate.HibernateModelJBossUnitTest"/>
+ <class
name="org.jboss.identity.idm.impl.store.hibernate.HibernateModelJBossTestCase"/>
</test>
<!--With LDAP-->
<test >
- <class
name="org.jboss.identity.idm.impl.store.ldap.LDAPIdentityStoreJBossUnitTest"/>
+ <class
name="org.jboss.identity.idm.impl.store.ldap.LDAPIdentityStoreTestCase"/>
<parameter name="directoryName"
value="EmbeddedOpenDS"/>
<parameter name="identityConfig"
value="store-test-config.xml"/>
</test>