JBoss Identity SVN: r420 - in idm/branches/proto/idm/src/test: resources and 1 other directory.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-04-02 18:33:10 -0400 (Thu, 02 Apr 2009)
New Revision: 420
Added:
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPTestCase.java
idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java
Removed:
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
Modified:
idm/branches/proto/idm/src/test/resources/jboss-unit.xml
Log:
proto
Deleted: 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 22:19:30 UTC (rev 419)
+++ idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationJBossUnitTest.java 2009-04-02 22:33:10 UTC (rev 420)
@@ -1,106 +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 org.jboss.identity.idm.impl.IdentityTestPOJO;
-import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
-import org.jboss.identity.idm.api.IdentitySessionFactory;
-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.jboss.unit.api.pojo.annotations.Parameter;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class OrganizationJBossUnitTest extends IdentityTestPOJO implements APITestContext
-{
- private OrganizationTest orgTest;
-
- private IdentitySessionFactory identitySessionFactory;
-
- private String samplePortalRealmName = "realm://portal/SamplePortal/DB";
-
- private String sampleOrganizationRealmName = "realm://RedHat/DB";
-
-
- @Create
- public void setUp() throws Exception
- {
- super.start();
-
- orgTest = new OrganizationTest(this);
-
- identitySessionFactory = new IdentityConfigurationImpl().
- configure(getIdentityConfig()).buildIdentitySessionFactory();
- }
-
- @Destroy
- public void tearDown() throws Exception
- {
- super.stop();
- }
-
- public IdentitySessionFactory getIdentitySessionFactory()
- {
- return identitySessionFactory;
- }
-
- @Test
- public void testOrganization() throws Exception
- {
-
- orgTest.testRedHatOrganization(getSampleOrganizationRealmName());
- }
-
- @Test
- public void testSamplePortal() throws Exception
- {
-
- orgTest.testSamplePortal(getSamplePortalRealmName());
-
- }
-
- public String getSamplePortalRealmName()
- {
- return samplePortalRealmName;
- }
-
- @Parameter
- public void setSamplePortalRealmName(String samplePortalRealmName)
- {
- this.samplePortalRealmName = samplePortalRealmName;
- }
-
- public String getSampleOrganizationRealmName()
- {
- return sampleOrganizationRealmName;
- }
-
- @Parameter
- public void setSampleOrganizationRealmName(String sampleOrganizationRealmName)
- {
- this.sampleOrganizationRealmName = sampleOrganizationRealmName;
- }
-}
\ No newline at end of file
Deleted: 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 22:19:30 UTC (rev 419)
+++ idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPJBossUnitTest.java 2009-04-02 22:33:10 UTC (rev 420)
@@ -1,109 +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 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.unit.api.pojo.annotations.Create;
-import org.jboss.unit.api.pojo.annotations.Destroy;
-import org.jboss.unit.api.pojo.annotations.Test;
-import org.jboss.unit.api.pojo.annotations.Parameter;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class OrganizationLDAPJBossUnitTest extends LDAPTestPOJO implements APITestContext
-{
- private OrganizationTest orgTest;
-
- private IdentitySessionFactory identitySessionFactory;
-
- private String samplePortalRealmName = "realm://portal/SamplePortal/DB_LDAP";
-
- private String sampleOrganizationRealmName = "realm://RedHat/DB_LDAP";
-
-
- @Create
- public void setUp() throws Exception
- {
- super.start();
-
- orgTest = new OrganizationTest(this);
-
- populateClean();
-
- identitySessionFactory = new IdentityConfigurationImpl().
- configure(getIdentityConfig()).buildIdentitySessionFactory();
- }
-
- @Destroy
- public void tearDown() throws Exception
- {
- super.stop();
- }
-
- public IdentitySessionFactory getIdentitySessionFactory()
- {
- return identitySessionFactory;
- }
-
- @Test
- public void testOrganization() throws Exception
- {
-
- orgTest.testRedHatOrganization(getSampleOrganizationRealmName());
- }
-
- @Test
- public void testSamplePortal() throws Exception
- {
-
- orgTest.testSamplePortal(getSamplePortalRealmName());
-
- }
-
- public String getSamplePortalRealmName()
- {
- return samplePortalRealmName;
- }
-
- @Parameter
- public void setSamplePortalRealmName(String samplePortalRealmName)
- {
- this.samplePortalRealmName = samplePortalRealmName;
- }
-
- public String getSampleOrganizationRealmName()
- {
- return sampleOrganizationRealmName;
- }
-
- @Parameter
- public void setSampleOrganizationRealmName(String sampleOrganizationRealmName)
- {
- this.sampleOrganizationRealmName = sampleOrganizationRealmName;
- }
-}
\ No newline at end of file
Copied: idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPTestCase.java (from rev 419, 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/OrganizationLDAPTestCase.java (rev 0)
+++ idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPTestCase.java 2009-04-02 22:33:10 UTC (rev 420)
@@ -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 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.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Test;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class OrganizationLDAPTestCase extends LDAPTestPOJO implements APITestContext
+{
+ private OrganizationTest orgTest;
+
+ private IdentitySessionFactory identitySessionFactory;
+
+ private String samplePortalRealmName = "realm://portal/SamplePortal/DB_LDAP";
+
+ private String sampleOrganizationRealmName = "realm://RedHat/DB_LDAP";
+
+
+ @Create
+ public void setUp() throws Exception
+ {
+ super.start();
+
+ orgTest = new OrganizationTest(this);
+
+ populateClean();
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(getIdentityConfig()).buildIdentitySessionFactory();
+ }
+
+ @Destroy
+ public void tearDown() throws Exception
+ {
+ super.stop();
+ }
+
+ public IdentitySessionFactory getIdentitySessionFactory()
+ {
+ return identitySessionFactory;
+ }
+
+ @Test
+ public void testOrganization() throws Exception
+ {
+
+ orgTest.testRedHatOrganization(getSampleOrganizationRealmName());
+ }
+
+ @Test
+ public void testSamplePortal() throws Exception
+ {
+
+ orgTest.testSamplePortal(getSamplePortalRealmName());
+
+ }
+
+ public String getSamplePortalRealmName()
+ {
+ return samplePortalRealmName;
+ }
+
+ @Parameter
+ public void setSamplePortalRealmName(String samplePortalRealmName)
+ {
+ this.samplePortalRealmName = samplePortalRealmName;
+ }
+
+ public String getSampleOrganizationRealmName()
+ {
+ return sampleOrganizationRealmName;
+ }
+
+ @Parameter
+ public void setSampleOrganizationRealmName(String sampleOrganizationRealmName)
+ {
+ this.sampleOrganizationRealmName = sampleOrganizationRealmName;
+ }
+}
\ No newline at end of file
Copied: idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java (from rev 419, 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/OrganizationTestCase.java (rev 0)
+++ idm/branches/proto/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java 2009-04-02 22:33:10 UTC (rev 420)
@@ -0,0 +1,106 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.api;
+
+import org.jboss.identity.idm.impl.IdentityTestPOJO;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+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.jboss.unit.api.pojo.annotations.Parameter;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class OrganizationTestCase extends IdentityTestPOJO implements APITestContext
+{
+ private OrganizationTest orgTest;
+
+ private IdentitySessionFactory identitySessionFactory;
+
+ private String samplePortalRealmName = "realm://portal/SamplePortal/DB";
+
+ private String sampleOrganizationRealmName = "realm://RedHat/DB";
+
+
+ @Create
+ public void setUp() throws Exception
+ {
+ super.start();
+
+ orgTest = new OrganizationTest(this);
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(getIdentityConfig()).buildIdentitySessionFactory();
+ }
+
+ @Destroy
+ public void tearDown() throws Exception
+ {
+ super.stop();
+ }
+
+ public IdentitySessionFactory getIdentitySessionFactory()
+ {
+ return identitySessionFactory;
+ }
+
+ @Test
+ public void testOrganization() throws Exception
+ {
+
+ orgTest.testRedHatOrganization(getSampleOrganizationRealmName());
+ }
+
+ @Test
+ public void testSamplePortal() throws Exception
+ {
+
+ orgTest.testSamplePortal(getSamplePortalRealmName());
+
+ }
+
+ public String getSamplePortalRealmName()
+ {
+ return samplePortalRealmName;
+ }
+
+ @Parameter
+ public void setSamplePortalRealmName(String samplePortalRealmName)
+ {
+ this.samplePortalRealmName = samplePortalRealmName;
+ }
+
+ public String getSampleOrganizationRealmName()
+ {
+ return sampleOrganizationRealmName;
+ }
+
+ @Parameter
+ public void setSampleOrganizationRealmName(String sampleOrganizationRealmName)
+ {
+ this.sampleOrganizationRealmName = sampleOrganizationRealmName;
+ }
+}
\ No newline at end of file
Modified: idm/branches/proto/idm/src/test/resources/jboss-unit.xml
===================================================================
--- idm/branches/proto/idm/src/test/resources/jboss-unit.xml 2009-04-02 22:19:30 UTC (rev 419)
+++ idm/branches/proto/idm/src/test/resources/jboss-unit.xml 2009-04-02 22:33:10 UTC (rev 420)
@@ -12,14 +12,14 @@
<!--Without LDAP-->
<test >
- <class name="org.jboss.identity.idm.impl.api.OrganizationJBossUnitTest"/>
+ <class name="org.jboss.identity.idm.impl.api.OrganizationTestCase"/>
<parameter name="sampleOrganizationRealmName" value="realm://RedHat/DB"/>
<parameter name="samplePortalRealmName" value="realm://portal/SamplePortal/DB"/>
</test>
<!--With LDAP-->
<test >
- <class name="org.jboss.identity.idm.impl.api.OrganizationLDAPJBossUnitTest"/>
+ <class name="org.jboss.identity.idm.impl.api.OrganizationLDAPTestCase"/>
<parameter name="directoryName" value="EmbeddedOpenDS"/>
<parameter name="sampleOrganizationRealmName" value="realm://RedHat/DB_LDAP"/>
<parameter name="samplePortalRealmName" value="realm://portal/SamplePortal/DB_LDAP"/>
15 years, 9 months
JBoss Identity SVN: r419 - in idm/branches/proto/idm: src/test/java/org/jboss/identity/idm/impl and 4 other directories.
by jboss-identity-commits@lists.jboss.org
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>
15 years, 9 months
JBoss Identity SVN: r418 - idm/branches.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-04-02 17:11:13 -0400 (Thu, 02 Apr 2009)
New Revision: 418
Added:
idm/branches/proto/
Log:
trunk copy to test alternative testing approach...
Copied: idm/branches/proto (from rev 417, idm/trunk)
15 years, 9 months
JBoss Identity SVN: r417 - idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-04-02 14:31:50 -0400 (Thu, 02 Apr 2009)
New Revision: 417
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java
Log:
fix a fix
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java 2009-04-02 17:37:09 UTC (rev 416)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java 2009-04-02 18:31:50 UTC (rev 417)
@@ -116,28 +116,13 @@
URL ldifURL = Thread.currentThread().getContextClassLoader().getResource(ldif);
+ System.out.println("LDIF: " + ldifURL.toURI().getPath());
- File ldifFile;
-
- try
- {
- ldifFile = new File(ldifURL.toURI());
- }
- catch (URISyntaxException e)
- {
- ldifFile = new File(ldifURL.getPath());
- }
-
-
- //File ldif = new File(ldifRelativePath);
-
- System.out.println("LDIF: " + ldifFile.getAbsolutePath());
-
String[] cmd = new String[] {"-h", LDAP_HOST,
"-p", LDAP_PORT,
"-D", LDAP_PRINCIPAL,
"-w", LDAP_CREDENTIALS,
- "-a", "-f", ldifURL.getPath()};
+ "-a", "-f", ldifURL.toURI().getPath()};
System.out.println("Populate success: " + (LDAPModify.mainModify(cmd, false, System.out, System.err) == 0));
15 years, 9 months
JBoss Identity SVN: r416 - idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-04-02 13:37:09 -0400 (Thu, 02 Apr 2009)
New Revision: 416
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java
Log:
hopefully fix issues with spaces in hudson paths
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java 2009-04-02 17:01:38 UTC (rev 415)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java 2009-04-02 17:37:09 UTC (rev 416)
@@ -35,6 +35,7 @@
import java.util.Hashtable;
import java.io.File;
import java.net.URL;
+import java.net.URISyntaxException;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
@@ -116,9 +117,21 @@
URL ldifURL = Thread.currentThread().getContextClassLoader().getResource(ldif);
+ File ldifFile;
+
+ try
+ {
+ ldifFile = new File(ldifURL.toURI());
+ }
+ catch (URISyntaxException e)
+ {
+ ldifFile = new File(ldifURL.getPath());
+ }
+
+
//File ldif = new File(ldifRelativePath);
- System.out.println("LDIF: " + ldifURL.getPath());
+ System.out.println("LDIF: " + ldifFile.getAbsolutePath());
String[] cmd = new String[] {"-h", LDAP_HOST,
"-p", LDAP_PORT,
15 years, 9 months
JBoss Identity SVN: r415 - idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-04-02 13:01:38 -0400 (Thu, 02 Apr 2009)
New Revision: 415
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java
Log:
bobo
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java 2009-04-02 16:48:29 UTC (rev 414)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java 2009-04-02 17:01:38 UTC (rev 415)
@@ -237,7 +237,7 @@
catch (Exception e)
{
//expected
- session.getTransaction().rollback();
+ getHibernateSupport().commitTransaction();
}
@@ -270,7 +270,7 @@
catch (Exception e)
{
//expected
- session.getTransaction().rollback();
+ getHibernateSupport().commitTransaction();
}
15 years, 9 months
JBoss Identity SVN: r414 - in idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl: api and 2 other directories.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-04-02 12:48:29 -0400 (Thu, 02 Apr 2009)
New Revision: 414
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPJBossUnitTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPJBossUnitTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java
Log:
trata
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java 2009-04-02 16:24:17 UTC (rev 413)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java 2009-04-02 16:48:29 UTC (rev 414)
@@ -31,6 +31,7 @@
import javax.naming.Binding;
import javax.naming.directory.DirContext;
import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
import java.util.Hashtable;
import java.io.File;
import java.net.URL;
@@ -54,7 +55,7 @@
public static final String LDAP_CREDENTIALS = "password";
- static Hashtable<String,String> env = new Hashtable<String,String>();
+ public static Hashtable<String,String> env = new Hashtable<String,String>();
static
{
@@ -74,7 +75,7 @@
openDSService.start();
- populateClean();
+
}
@@ -162,5 +163,12 @@
mainCtx.unbind(name);
}
+
+ public LdapContext getLdapContext() throws Exception
+ {
+ return new InitialLdapContext(env, null);
+ }
+
+
}
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPJBossUnitTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPJBossUnitTest.java 2009-04-02 16:24:17 UTC (rev 413)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPJBossUnitTest.java 2009-04-02 16:48:29 UTC (rev 414)
@@ -66,7 +66,9 @@
relationshipManagerTest = new RelationshipManagerTest(this);
roleManagerTest = new RoleManagerTest(this);
+ populateClean();
+
identitySessionFactory = new IdentityConfigurationImpl().
configure(getIdentityConfig()).buildIdentitySessionFactory();
}
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPJBossUnitTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPJBossUnitTest.java 2009-04-02 16:24:17 UTC (rev 413)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPJBossUnitTest.java 2009-04-02 16:48:29 UTC (rev 414)
@@ -53,6 +53,8 @@
orgTest = new OrganizationTest(this);
+ populateClean();
+
identitySessionFactory = new IdentityConfigurationImpl().
configure(getIdentityConfig()).buildIdentitySessionFactory();
}
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java 2009-04-02 16:24:17 UTC (rev 413)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java 2009-04-02 16:48:29 UTC (rev 414)
@@ -77,7 +77,7 @@
commonTest = new CommonIdentityStoreTest(this);
IdentityConfigurationMetaData configurationMD = JAXB2IdentityConfiguration
- .createConfigurationMetaData(new File(getIdentityConfig()));
+ .createConfigurationMetaData(getIdentityConfig());
IdentityConfigurationContextRegistry identityConfiguration = (IdentityConfigurationContextRegistry)
new IdentityConfigurationImpl().configure(configurationMD);
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java 2009-04-02 16:24:17 UTC (rev 413)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java 2009-04-02 16:48:29 UTC (rev 414)
@@ -63,9 +63,11 @@
@Test
public void testPersistence() {
+
+ begin();
Session session = getSessionFactory().getCurrentSession();
- session.getTransaction().begin();
+
HibernateRealm realm = new HibernateRealm("default");
session.persist(realm);
@@ -119,7 +121,7 @@
session.delete(iort);
assertFalse(session.contains(iort));
- session.getTransaction().commit();
+ commit();
}
@@ -127,9 +129,11 @@
@Test
public void testRelationships()
{
+ begin();
+
+
Session session = getSessionFactory().getCurrentSession();
- session.getTransaction().begin();
HibernateRealm realm = new HibernateRealm("default");
session.persist(realm);
@@ -165,13 +169,15 @@
relationship = new HibernateIdentityObjectRelationship(memberType, group2, group1);
session.persist(relationship);
- session.getTransaction().commit();
+ commit();
//
+
+
+ begin();
+
session = getSessionFactory().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();
@@ -185,7 +191,7 @@
assertEquals(1, user3.getToRelationships().size());
assertEquals(0, user3.getFromRelationships().size());
assertEquals("group2", user3.getToRelationships().iterator().next().getFromIdentityObject().getName());
- session.getTransaction().commit();
+ commit();
}
@@ -193,10 +199,11 @@
public void testNameTypeConstraint() throws Exception
{
+ begin();
Session session = getSessionFactory().getCurrentSession();
- session.getTransaction().begin();
+
HibernateRealm realm = new HibernateRealm("default");
session.persist(realm);
@@ -210,12 +217,14 @@
HibernateIdentityObject user2 = new HibernateIdentityObject("user2", userType, realm);
session.persist(user2);
- session.getTransaction().commit();
+ commit();
+
+
+ begin();
+
session = getSessionFactory().getCurrentSession();
- session.getTransaction().begin();
-
try
{
@@ -231,11 +240,13 @@
session.getTransaction().rollback();
}
+
+
+ begin();
+
session = getSessionFactory().getCurrentSession();
- session.getTransaction().begin();
-
HibernateIdentityObject user4 = new HibernateIdentityObject("group1", userType, realm);
session.persist(user4);
@@ -262,16 +273,18 @@
session.getTransaction().rollback();
}
+
+
+ begin();
+
session = getSessionFactory().getCurrentSession();
- session.getTransaction().begin();
-
HibernateIdentityObject group4 = new HibernateIdentityObject("user1", groupType, realm);
session.persist(group4);
session.flush();
- session.getTransaction().commit();
+ commit();
@@ -282,11 +295,13 @@
@Test
public void testAttributes() throws Exception
{
+ begin();
+
Session session = getSessionFactory().getCurrentSession();
- session.getTransaction().begin();
+
HibernateRealm realm = new HibernateRealm("default");
session.persist(realm);
@@ -305,19 +320,21 @@
user1.getAttributes().add(new HibernateIdentityObjectTextAttribute(user1, "simple2", new String[]{"Val1", "Val2", "Val3"}));
- session.getTransaction().commit();
+ commit();
+
+
+ begin();
+
session = getSessionFactory().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();
+ commit();
}
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java 2009-04-02 16:24:17 UTC (rev 413)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java 2009-04-02 16:48:29 UTC (rev 414)
@@ -87,7 +87,7 @@
commonTest = new CommonIdentityStoreTest(this);
IdentityConfigurationMetaData configurationMD = JAXB2IdentityConfiguration
- .createConfigurationMetaData(new File(getIdentityConfig()));
+ .createConfigurationMetaData(getIdentityConfig());
IdentityConfigurationContextRegistry registry = (IdentityConfigurationContextRegistry) new IdentityConfigurationImpl().
configure(configurationMD);
@@ -189,16 +189,7 @@
super.stop();
}
-// public void begin() throws Exception
-// {
-// //nothing
-// }
-//
-// public void commit() throws Exception
-// {
-// //nothing
-// }
-//
+
public void flush() throws Exception
{
//nothing
@@ -215,87 +206,6 @@
}
- public LdapContext getLdapContext() throws Exception
- {
- 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);
-
- return new InitialLdapContext(env, null);
- }
-
-
-
- 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() throws Exception
- {
- DirContext ldapCtx = getLdapContext();
-
- try
- {
-
-
- String dn = "dc=portal,dc=example,dc=com";
-
- System.out.println("Removing: " + dn);
-
- removeContext(ldapCtx, dn);
- }
- catch (Exception e)
- {
- //
- }
- finally
- {
- ldapCtx.close();
- }
- }
-
- //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);
- }
-
// Tests
// Just test if OpenDS is running and was populated...
15 years, 9 months
JBoss Identity SVN: r413 - idm/trunk/idm/src/test/resources.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-04-02 12:24:17 -0400 (Thu, 02 Apr 2009)
New Revision: 413
Modified:
idm/trunk/idm/src/test/resources/jboss-unit.xml
Log:
toto
Modified: idm/trunk/idm/src/test/resources/jboss-unit.xml
===================================================================
--- idm/trunk/idm/src/test/resources/jboss-unit.xml 2009-04-02 16:08:18 UTC (rev 412)
+++ idm/trunk/idm/src/test/resources/jboss-unit.xml 2009-04-02 16:24:17 UTC (rev 413)
@@ -41,7 +41,7 @@
<!--Without LDAP-->
<test >
<class name="org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreJBossUnitTest"/>
- <parameter name="identityConfig" value="src/test/resources/store-test-config.xml"/>
+ <parameter name="identityConfig" value="store-test-config.xml"/>
</test>
<!--Without LDAP-->
@@ -53,7 +53,7 @@
<test >
<class name="org.jboss.identity.idm.impl.store.ldap.LDAPIdentityStoreJBossUnitTest"/>
<parameter name="directoryName" value="EmbeddedOpenDS"/>
- <parameter name="identityConfig" value="src/test/resources/store-test-config.xml"/>
+ <parameter name="identityConfig" value="store-test-config.xml"/>
</test>
</pojo>
15 years, 9 months
JBoss Identity SVN: r412 - in idm/trunk/idm: src/test/java/org/jboss/identity/idm/impl and 3 other directories.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-04-02 12:08:18 -0400 (Thu, 02 Apr 2009)
New Revision: 412
Modified:
idm/trunk/idm/pom.xml
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/opends/OpenDSService.java
Log:
- some testsuite fixes
Modified: idm/trunk/idm/pom.xml
===================================================================
--- idm/trunk/idm/pom.xml 2009-04-02 13:44:45 UTC (rev 411)
+++ idm/trunk/idm/pom.xml 2009-04-02 16:08:18 UTC (rev 412)
@@ -213,13 +213,13 @@
<build>
<plugins>
- <!--<plugin>-->
- <!--<artifactId>maven-surefire-plugin</artifactId>-->
- <!--<configuration>-->
- <!--<skip>true</skip>-->
- <!--</configuration>-->
- <!--</plugin>-->
<plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-tooling-maven2</artifactId>
<executions>
@@ -262,8 +262,8 @@
</testsuites>
<reports>
- <xml>target/tests/reports/xml</xml>
- <html>target/tests/reports/html</html>
+ <xml>idm/target/tests/reports/xml</xml>
+ <html>idm/target/tests/reports/html</html>
</reports>
</configuration>
</plugin>
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java 2009-04-02 13:44:45 UTC (rev 411)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java 2009-04-02 16:08:18 UTC (rev 412)
@@ -33,6 +33,7 @@
import javax.naming.ldap.InitialLdapContext;
import java.util.Hashtable;
import java.io.File;
+import java.net.URL;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
@@ -64,7 +65,7 @@
env.put(Context.SECURITY_CREDENTIALS, LDAP_CREDENTIALS);
}
- OpenDSService openDSService = new OpenDSService("target/test-classes/opends");
+ OpenDSService openDSService = new OpenDSService(null);
@Override
public void start() throws Exception
@@ -100,25 +101,29 @@
public void populate() throws Exception
{
- populateLDIF("target/test-classes/ldap/initial-opends.ldif");
+ populateLDIF("ldap/initial-opends.ldif");
}
public void populateClean() throws Exception
{
- populateLDIF("target/test-classes/ldap/initial-empty-opends.ldif");
+ populateLDIF("ldap/initial-empty-opends.ldif");
}
- public void populateLDIF(String ldifRelativePath) throws Exception
+ public void populateLDIF(String ldif) throws Exception
{
- File ldif = new File(ldifRelativePath);
- System.out.println("LDIF: " + ldif.getAbsolutePath());
+ URL ldifURL = Thread.currentThread().getContextClassLoader().getResource(ldif);
+
+ //File ldif = new File(ldifRelativePath);
+
+ System.out.println("LDIF: " + ldifURL.getPath());
+
String[] cmd = new String[] {"-h", LDAP_HOST,
"-p", LDAP_PORT,
"-D", LDAP_PRINCIPAL,
"-w", LDAP_CREDENTIALS,
- "-a", "-f", ldif.getPath()};
+ "-a", "-f", ldifURL.getPath()};
System.out.println("Populate success: " + (LDAPModify.mainModify(cmd, false, System.out, System.err) == 0));
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java 2009-04-02 13:44:45 UTC (rev 411)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java 2009-04-02 16:08:18 UTC (rev 412)
@@ -43,6 +43,7 @@
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;
@@ -159,6 +160,7 @@
// Tests
+ @Test
public void testStorePersistence() throws Exception
{
@@ -166,6 +168,7 @@
}
+ @Test
public void testFindMethods() throws Exception
{
@@ -173,6 +176,7 @@
}
+ @Test
public void testAttributes() throws Exception
{
@@ -271,17 +275,20 @@
}
+ @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();
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java 2009-04-02 13:44:45 UTC (rev 411)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java 2009-04-02 16:08:18 UTC (rev 412)
@@ -31,6 +31,7 @@
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.*;
@@ -59,6 +60,7 @@
super.stop();
}
+ @Test
public void testPersistence() {
Session session = getSessionFactory().getCurrentSession();
@@ -122,6 +124,7 @@
}
+ @Test
public void testRelationships()
{
Session session = getSessionFactory().getCurrentSession();
@@ -186,6 +189,7 @@
}
+ @Test
public void testNameTypeConstraint() throws Exception
{
@@ -275,7 +279,7 @@
}
-
+ @Test
public void testAttributes() throws Exception
{
Session session = getSessionFactory().getCurrentSession();
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java 2009-04-02 13:44:45 UTC (rev 411)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java 2009-04-02 16:08:18 UTC (rev 412)
@@ -44,6 +44,7 @@
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;
@@ -298,6 +299,7 @@
// Tests
// Just test if OpenDS is running and was populated...
+ @Test
public void testSimple() throws Exception
{
populate();
@@ -338,6 +340,7 @@
}
}
+ @Test
public void testIdentityObjectCount() throws Exception
{
populate();
@@ -347,6 +350,7 @@
assertEquals(2, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.GROUP));
}
+ @Test
public void testFindCreateRemove() throws Exception
{
populate();
@@ -382,6 +386,7 @@
}
+ @Test
public void testAttributes() throws Exception{
populate();
@@ -475,6 +480,7 @@
}
+ @Test
public void testRelationships() throws Exception
{
populateClean();
@@ -483,6 +489,7 @@
}
+ @Test
public void testStorePersistence() throws Exception
{
populateClean();
@@ -491,6 +498,7 @@
}
+ @Test
public void testFindMethods() throws Exception
{
populateClean();
@@ -499,6 +507,7 @@
}
+ @Test
public void testControls() throws Exception
{
populateClean();
@@ -507,6 +516,7 @@
}
+ @Test
public void testCredentials() throws Exception
{
populateClean();
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/opends/OpenDSService.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/opends/OpenDSService.java 2009-04-02 13:44:45 UTC (rev 411)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/opends/OpenDSService.java 2009-04-02 16:08:18 UTC (rev 412)
@@ -23,10 +23,15 @@
package org.jboss.identity.idm.opends;
import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URISyntaxException;
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.types.DirectoryEnvironmentConfig;
import org.opends.server.types.InitializationException;
+import org.jboss.identity.idm.impl.helper.SecurityActions;
+import org.jboss.identity.idm.exception.IdentityException;
/**
* Simple service class that enables to bootstrap OpenDS LDAP server and to manage its lifecycle
@@ -47,10 +52,46 @@
{
DirectoryEnvironmentConfig config = new DirectoryEnvironmentConfig();
+
try
{
- File root = new File(getServerRoot());
+ File root;
+ if (getServerRoot() != null)
+ {
+ root = new File(getServerRoot());
+ }
+ else
+ {
+
+ //Find opends root based on where the config.ldif file is:
+
+ URL rootURL = Thread.currentThread().getContextClassLoader().getResource("opends/config/config.ldif");
+
+ if (rootURL == null)
+ {
+ throw new IllegalStateException("opends root doesn't exist");
+ }
+
+
+
+ try
+ {
+ root = new File(rootURL.toURI());
+ }
+ catch (URISyntaxException e)
+ {
+ root = new File(rootURL.getPath());
+ }
+
+ if (root != null)
+ {
+ root = root.getParentFile().getParentFile();
+ }
+
+ }
+
+
if (root == null || !root.exists())
{
throw new IllegalStateException("opends root doesn't exist: " + getServerRoot());
@@ -61,7 +102,7 @@
}
// Server root points to the directory with opends configuration
- config.setServerRoot(new File(getServerRoot()));
+ config.setServerRoot(root);
config.setForceDaemonThreads(true);
}
15 years, 9 months
JBoss Identity SVN: r411 - in idm/trunk/idm: src/main/java/org/jboss/identity/idm/impl/api/session/managers and 14 other directories.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-04-02 09:44:45 -0400 (Thu, 02 Apr 2009)
New Revision: 411
Added:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/helper/SecurityActions.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/IdentityTestPOJO.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APIJBossUnitTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPJBossUnitTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationJBossUnitTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPJBossUnitTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/test/
idm/trunk/idm/src/test/java/org/jboss/identity/idm/test/HibernateAnnotationsSupport.java
idm/trunk/idm/src/test/resources/datasources/
idm/trunk/idm/src/test/resources/datasources/datasources.xml
idm/trunk/idm/src/test/resources/datasources/hibernates.xml
idm/trunk/idm/src/test/resources/jboss-unit.xml
idm/trunk/idm/src/test/resources/organization-test-jboss-unit-config.xml
Removed:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/SecurityActions.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java
Modified:
idm/trunk/idm/pom.xml
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheAttributeStoreWrapper.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectAttribute.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectBinaryAttribute.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectCredential.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectCredentialType.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipType.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectTextAttribute.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectType.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateRealm.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestContext.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java
idm/trunk/idm/src/test/resources/organization-test-config.xml
idm/trunk/idm/src/test/resources/store-test-config.xml
Log:
- JBoss Unit and multi DB testing support
Modified: idm/trunk/idm/pom.xml
===================================================================
--- idm/trunk/idm/pom.xml 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/pom.xml 2009-04-02 13:44:45 UTC (rev 411)
@@ -65,12 +65,20 @@
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
- <!-- Javassist as Hibernate's bytecode provider -->
+ <!--Javassist as Hibernate's bytecode provider-->
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.4.GA</version>
</dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-cglib-repack</artifactId>
+ <version>2.1_3</version>
+ </dependency>
+
+
<!-- Hibernate logging set up -->
<dependency>
<groupId>org.slf4j</groupId>
@@ -114,5 +122,186 @@
<scope>test</scope>
</dependency>
+ <!--JBoss Unit-->
+
+ <dependency>
+ <groupId>org.jboss.unit</groupId>
+ <artifactId>jboss-unit</artifactId>
+ <version>1.2.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.unit</groupId>
+ <artifactId>portal-test</artifactId>
+ <version>1.2.2</version>
+
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>hibernate</groupId>
+ <artifactId>hibernate3</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>sun-opends</groupId>
+ <artifactId>opends-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss.jbossas.core-libs</groupId>
+ <artifactId>jboss-local-jdbc</artifactId>
+ <version>4.0.4.GA</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jboss.jbossas.core-libs</groupId>
+ <artifactId>jboss-common-jdbc-wrapper</artifactId>
+ <version>4.0.4.GA</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>2.0.2.GA</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-logging-jdk</artifactId>
+ <version>2.0.2.GA</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <version>2.0.2.GA</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>8.3-604.jdbc3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.jtds</groupId>
+ <artifactId>jtds</artifactId>
+ <version>1.2.2</version>
+ <scope>test</scope>
+ </dependency>
+
+
+
+
</dependencies>
+
+
+
+ <build>
+ <plugins>
+ <!--<plugin>-->
+ <!--<artifactId>maven-surefire-plugin</artifactId>-->
+ <!--<configuration>-->
+ <!--<skip>true</skip>-->
+ <!--</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>
+
+ <!--<jpda>true</jpda>-->
+ <jpdaPort>5005</jpdaPort>
+ <jpdaSuspend>true</jpdaSuspend>
+
+ <failOnError>true</failOnError>
+
+
+ <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>
+
+
+ </testsuite>
+ </testsuites>
+
+ <reports>
+ <xml>target/tests/reports/xml</xml>
+ <html>target/tests/reports/html</html>
+ </reports>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>oracle-provided-jdbc-driver</id>
+ <dependencies>
+ <dependency>
+ <groupId>oracle</groupId>
+ <artifactId>jdbc-driver</artifactId>
+ <version>NA</version>
+ <scope>system</scope>
+ <systemPath>${oracle.jdbc.driver.path}</systemPath>
+ </dependency>
+ </dependencies>
+ </profile>
+ <!--<profile>-->
+ <!--<id>oracle-provided-jdbc-drivers</id>-->
+ <!--<dependencies>-->
+ <!--<dependency>-->
+ <!--<groupId>oracle</groupId>-->
+ <!--<artifactId>jdbc-driver1</artifactId>-->
+ <!--<version>NA</version>-->
+ <!--<scope>system</scope>-->
+ <!--<systemPath>${oracle.jdbc.driver1}</systemPath>-->
+ <!--</dependency>-->
+ <!--<dependency>-->
+ <!--<groupId>oracle</groupId>-->
+ <!--<artifactId>jdbc-driver2</artifactId>-->
+ <!--<version>NA</version>-->
+ <!--<scope>system</scope>-->
+ <!--<systemPath>${oracle.jdbc.driver1}</systemPath>-->
+ <!--</dependency>-->
+ <!--</dependencies>-->
+ <!--</profile>-->
+ </profiles>
</project>
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -340,6 +340,8 @@
throw new IdentityException("Unsupported Credential implementation: " + credential.getClass());
}
+ ioc = (IdentityObjectCredential)credential;
+
// All credentials must pass
if (!getRepository().validateCredential(getInvocationContext(), createIdentityObject(identity), ioc))
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheAttributeStoreWrapper.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheAttributeStoreWrapper.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheAttributeStoreWrapper.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -37,6 +37,7 @@
import java.util.logging.Logger;
import java.util.Set;
import java.util.Map;
+import java.io.InputStream;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
@@ -56,13 +57,13 @@
private boolean reloadAttributesToCacheOnUpdate = true;
- public JBossCacheAttributeStoreWrapper(AttributeStore attributeStore, String cacheConfigurationFile)
+ public JBossCacheAttributeStoreWrapper(AttributeStore attributeStore, InputStream cacheConfigInputStream)
{
this.attributeStore = attributeStore;
CacheFactory factory = new DefaultCacheFactory();
- this.cache = factory.createCache(cacheConfigurationFile);
+ this.cache = factory.createCache(cacheConfigInputStream);
this.cache.start();
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -39,6 +39,7 @@
import java.util.Collection;
import java.util.Set;
import java.util.logging.Logger;
+import java.io.InputStream;
/**
* IdentityStore implementation that wraps another IdentityStore and uses JBossCache to cache results.
@@ -56,9 +57,9 @@
private final IdentityStore identityStore;
- public JBossCacheIdentityStoreWrapper(IdentityStore identityStore, String cacheConfigurationFile) throws IdentityException
+ public JBossCacheIdentityStoreWrapper(IdentityStore identityStore, InputStream cacheConfigInputStream) throws IdentityException
{
- super(identityStore, cacheConfigurationFile);
+ super(identityStore, cacheConfigInputStream);
this.identityStore = identityStore;
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -50,6 +50,7 @@
import org.jboss.identity.idm.impl.configuration.jaxb2.generated.IdentityObjectTypeType;
import org.jboss.identity.idm.impl.configuration.jaxb2.generated.AttributeType;
import org.jboss.identity.idm.impl.configuration.jaxb2.generated.RelationshipType;
+import org.jboss.identity.idm.impl.helper.SecurityActions;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
Deleted: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/SecurityActions.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/SecurityActions.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/SecurityActions.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.configuration.jaxb2;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * Privileged Blocks
- * @author Anil.Saldhana(a)redhat.com
- * @since Feb 3, 2009
- */
-class SecurityActions
-{
- /**
- * Get the Thread Context CL
- * @return
- */
- static ClassLoader getContextClassLoader()
- {
- return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
- {
- public ClassLoader run()
- {
- return Thread.currentThread().getContextClassLoader();
- }
- });
- }
-
-}
\ No newline at end of file
Copied: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/helper/SecurityActions.java (from rev 390, idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/SecurityActions.java)
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/helper/SecurityActions.java (rev 0)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/helper/SecurityActions.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.helper;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Privileged Blocks
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Feb 3, 2009
+ */
+public class SecurityActions
+{
+ /**
+ * Get the Thread Context CL
+ * @return
+ */
+ public static ClassLoader getContextClassLoader()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+
+}
\ No newline at end of file
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -55,7 +55,7 @@
* @version : 0.1 $
*/
@Entity
-@Table(name = "identity_obj", uniqueConstraints = {@UniqueConstraint(columnNames = {"NAME", "IDENTITY_TYPE", "REALM"})})
+@Table(name = "jbid_io", uniqueConstraints = {@UniqueConstraint(columnNames = {"NAME", "IDENTITY_TYPE", "REALM"})})
public class HibernateIdentityObject implements IdentityObject
{
public static final String findIdentityObjectByNameAndType =
@@ -105,9 +105,9 @@
@Column(name = "PROPERTY")
private Map<String, String> properties = new HashMap<String, String>();
- @OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
+ @OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL}, mappedBy = "identityObject")
@Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
- private Map<String, HibernateIdentityObjectCredential> credentials = new HashMap<String, HibernateIdentityObjectCredential>();
+ private Set<HibernateIdentityObjectCredential> credentials = new HashSet<HibernateIdentityObjectCredential>();
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(nullable = false, unique = false, name="REALM")
@@ -254,12 +254,12 @@
this.realm = realm;
}
- public Map<String, HibernateIdentityObjectCredential> getCredentials()
+ public Set<HibernateIdentityObjectCredential> getCredentials()
{
return credentials;
}
- public void setCredentials(Map<String, HibernateIdentityObjectCredential> credentials)
+ public void setCredentials(Set<HibernateIdentityObjectCredential> credentials)
{
this.credentials = credentials;
}
@@ -267,7 +267,7 @@
public void addCredential(HibernateIdentityObjectCredential credential)
{
credential.setIdentityObject(this);
- credentials.put(credential.getType().getName(), credential);
+ credentials.add(credential);
}
public boolean hasCredentials()
@@ -281,13 +281,34 @@
public boolean hasCredential(IdentityObjectCredentialType type)
{
- if (credentials != null && credentials.keySet().contains(type.getName()))
+ if (credentials != null)
{
- return true;
+ for (HibernateIdentityObjectCredential credential : credentials)
+ {
+ if (credential.getType().getName().equals(type.getName()))
+ {
+ return true;
+ }
+ }
}
return false;
}
+ public HibernateIdentityObjectCredential getCredential(IdentityObjectCredentialType type)
+ {
+ if (credentials != null)
+ {
+ for (HibernateIdentityObjectCredential credential : credentials)
+ {
+ if (credential.getType().getName().equals(type.getName()))
+ {
+ return credential;
+ }
+ }
+ }
+ return null;
+ }
+
public Map<String, String> getProperties()
{
return properties;
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectAttribute.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectAttribute.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectAttribute.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -42,7 +42,7 @@
*/
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
-@Table(name = "identity_obj_attrs", uniqueConstraints = {@UniqueConstraint(columnNames = {"NAME", "IDENTITY_OBJECT_ID"})})
+@Table(name = "jbid_io_attr", uniqueConstraints = {@UniqueConstraint(columnNames = {"NAME", "IDENTITY_OBJECT_ID"})})
public abstract class HibernateIdentityObjectAttribute implements IdentityObjectAttribute
{
@Id
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectBinaryAttribute.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectBinaryAttribute.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectBinaryAttribute.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -38,7 +38,7 @@
*/
@Entity
-@Table(name = "identity_obj_attrs_binary")
+@Table(name = "jbid_io_attr_bin")
@PrimaryKeyJoinColumn(name = "ATTRIBUTE_ID")
public class HibernateIdentityObjectBinaryAttribute extends HibernateIdentityObjectAttribute
{
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectCredential.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectCredential.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectCredential.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -24,6 +24,7 @@
import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
import org.hibernate.annotations.CollectionOfElements;
+import org.hibernate.annotations.Type;
import javax.persistence.Entity;
import javax.persistence.Table;
@@ -35,6 +36,7 @@
import javax.persistence.ManyToOne;
import javax.persistence.JoinTable;
import javax.persistence.UniqueConstraint;
+import javax.persistence.Lob;
import java.util.Map;
import java.util.HashMap;
@@ -43,30 +45,35 @@
* @version : 0.1 $
*/
@Entity
-@Table(name = "identity_obj_credential", uniqueConstraints = {@UniqueConstraint(columnNames = {"IDENTITY_TYPE", "IDENTITY_ID"})})
+@Table(name = "jbid_io_creden", uniqueConstraints = {@UniqueConstraint(columnNames = {"IDENTITY_OBJECT_TYPE", "IDENTITY_OBJECT_ID"})})
public class HibernateIdentityObjectCredential implements IdentityObjectCredential
{
+ public static final String findIdentityObjectCredentialByIOAndTypeNAme =
+ "select c from HibernateIdentityObjectCredential c where c.type.name like :typeName and c.identityObject like :identityObject";
+
+
@Id
@GeneratedValue
private Long id;
@ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "IDENTITY_TYPE", nullable = false)
+ @JoinColumn(name = "IDENTITY_OBJECT_TYPE", nullable = false)
private HibernateIdentityObjectCredentialType type;
@ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "IDENTITY_ID", nullable = false)
+ @JoinColumn(name = "IDENTITY_OBJECT_ID", nullable = false)
private HibernateIdentityObject identityObject;
@Column(name= "TEXT", nullable = true)
private String textValue;
- @Column(name= "BINARY", nullable = true)
+ @Column(name= "BINARY_VALUE", nullable = true)
+ //@Type(type = "binary")
private byte[] binaryValue;
@CollectionOfElements
- @JoinTable(name = "identity_obj_credential_properties", joinColumns = @JoinColumn(name = "CREDENTIAL_ID"))
+ @JoinTable(name = "jbid_io_creden_props", joinColumns = @JoinColumn(name = "CREDENTIAL_ID"))
@Column(name = "PROPERTY")
private Map<String, String> properties = new HashMap<String, String>();
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectCredentialType.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectCredentialType.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectCredentialType.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -35,7 +35,7 @@
* @version : 0.1 $
*/
@Entity
-@Table(name = "identity_obj_credential_type")
+@Table(name = "jbid_io_creden_type")
public class HibernateIdentityObjectCredentialType implements IdentityObjectCredentialType
{
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -43,7 +43,7 @@
* @version : 0.1 $
*/
@Entity
-@Table(name="identity_relationship", uniqueConstraints = {@UniqueConstraint(columnNames = {"NAME", "TYPE", "FROM_IDENTITY", "TO_IDENTITY"})})
+@Table(name="jbid_io_rel", uniqueConstraints = {@UniqueConstraint(columnNames = {"NAME", "TYPE", "FROM_IDENTITY", "TO_IDENTITY"})})
public class HibernateIdentityObjectRelationship implements IdentityObjectRelationship
{
public static final String findIdentityObjectRelationshipsByType =
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -38,7 +38,7 @@
* @version : 0.1 $
*/
@Entity
-@Table(name="identity_relationship_name", uniqueConstraints = {@UniqueConstraint(columnNames = {"NAME", "REALM"})})
+@Table(name="jbid_io_rel_name", uniqueConstraints = {@UniqueConstraint(columnNames = {"NAME", "REALM"})})
public class HibernateIdentityObjectRelationshipName
{
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipType.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipType.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipType.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -43,7 +43,7 @@
// )
// })
@Entity
-@Table(name = "identity_relationship_type")
+@Table(name = "jbid_io_rel_type")
public class HibernateIdentityObjectRelationshipType implements IdentityObjectRelationshipType
{
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectTextAttribute.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectTextAttribute.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectTextAttribute.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -38,7 +38,7 @@
* @version : 0.1 $
*/
@Entity
-@Table(name = "identity_obj_attrs_text")
+@Table(name = "jbid_io_attr_text")
@PrimaryKeyJoinColumn(name = "ATTRIBUTE_ID")
public class HibernateIdentityObjectTextAttribute extends HibernateIdentityObjectAttribute
{
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectType.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectType.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectType.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -43,7 +43,7 @@
)
})
@Entity
-@Table(name = "identity_obj_type")
+@Table(name = "jbid_io_type")
public class HibernateIdentityObjectType implements IdentityObjectType
{
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateRealm.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateRealm.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateRealm.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -42,7 +42,7 @@
* @version : 0.1 $
*/
@Entity
-@Table(name = "identity_realm", uniqueConstraints = {@UniqueConstraint(columnNames = {"NAME"})})
+@Table(name = "jbid_realm", uniqueConstraints = {@UniqueConstraint(columnNames = {"NAME"})})
public class HibernateRealm
{
@@ -57,7 +57,7 @@
private String name;
@CollectionOfElements
- @JoinTable(name = "identity_realm_properties", joinColumns = @JoinColumn(name = "REALM_ID"))
+ @JoinTable(name = "jbid_io_realm_props", joinColumns = @JoinColumn(name = "REALM_ID"))
@Column(name = "PROPERTY")
private Map<String, String> properties = new HashMap<String, String>();
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -33,6 +33,7 @@
import org.jboss.identity.idm.spi.configuration.IdentityRepositoryConfigurationContext;
import org.jboss.identity.idm.exception.IdentityException;
import org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreWrapper;
+import org.jboss.identity.idm.impl.helper.SecurityActions;
import java.util.Set;
import java.util.Map;
@@ -40,6 +41,7 @@
import java.util.List;
import java.util.HashMap;
import java.io.File;
+import java.io.InputStream;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
@@ -93,15 +95,17 @@
throw new IdentityException(CACHE_CONFIG_FILE_OPTION + " is missing in the repository configuration");
}
- File cacheConfigFile = new File(cacheConfig);
-
- if(!cacheConfigFile.exists())
+ ClassLoader classLoader = SecurityActions.getContextClassLoader();
+ InputStream cacheConfigInputStream = classLoader.getResourceAsStream(cacheConfig);
+ if (cacheConfigInputStream == null)
{
throw new IdentityException("JBoss Cache config file specified in option \"" + CACHE_CONFIG_FILE_OPTION +
"\" doesn't exist: " + cacheConfig);
}
- defaultIdentityStore = new JBossCacheIdentityStoreWrapper(defaultIdentityStore, cacheConfig);
+ defaultIdentityStore = new JBossCacheIdentityStoreWrapper(defaultIdentityStore, cacheConfigInputStream);
+
+
}
}
@@ -123,15 +127,16 @@
throw new IdentityException(CACHE_CONFIG_FILE_OPTION + " is missing in the repository identity-store-mapping configuration");
}
- File cacheConfigFile = new File(cacheConfig);
-
- if(!cacheConfigFile.exists())
+ ClassLoader classLoader = SecurityActions.getContextClassLoader();
+ InputStream cacheConfigInputStream = classLoader.getResourceAsStream(cacheConfig);
+ if (cacheConfigInputStream == null)
{
throw new IdentityException("JBoss Cache config file specified in option \"" + CACHE_CONFIG_FILE_OPTION +
"\" doesn't exist: " + cacheConfig);
}
- store = new JBossCacheIdentityStoreWrapper(store, cacheConfig);
+
+ store = new JBossCacheIdentityStoreWrapper(store, cacheConfigInputStream);
}
if (store == null)
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -1635,8 +1635,15 @@
if (supportedFeatures.isCredentialSupported(hibernateObject.getIdentityType(),credential.getType()))
{
- HibernateIdentityObjectCredential hibernateCredential = hibernateObject.getCredentials().get(credential.getType().getName());
+ HibernateIdentityObjectCredential hibernateCredential = null;
+ hibernateCredential = (HibernateIdentityObjectCredential)getHibernateSession(ctx).
+ createQuery(HibernateIdentityObjectCredential.findIdentityObjectCredentialByIOAndTypeNAme).
+ setParameter("typeName", credential.getType().getName()).
+ setParameter("identityObject", hibernateObject).uniqueResult();
+
+
+
if (hibernateCredential == null)
{
return false;
@@ -1697,10 +1704,16 @@
throw new IllegalStateException("Credential type not present in this store: " + credential.getType().getName());
}
- HibernateIdentityObjectCredential hibernateCredential = new HibernateIdentityObjectCredential();
- hibernateCredential.setIdentityObject(hibernateObject);
- hibernateCredential.setType(hibernateCredentialType);
+ HibernateIdentityObjectCredential hibernateCredential = hibernateObject.getCredential(credential.getType());
+ if (hibernateCredential == null)
+ {
+ hibernateCredential = new HibernateIdentityObjectCredential();
+ hibernateCredential.setType(hibernateCredentialType);
+ hibernateObject.addCredential(hibernateCredential);
+ }
+
+
Object value = null;
// Handle generic impl
@@ -1768,7 +1781,7 @@
}
catch (Exception e)
{
- throw new IdentityException("Cannot obtain HibernateEntityManager", e);
+ throw new IdentityException("Cannot obtain Hibernate Session", e);
}
}
@@ -1880,13 +1893,13 @@
private HibernateIdentityObjectCredentialType getHibernateIdentityObjectCredentialType(IdentityStoreInvocationContext ctx, IdentityObjectCredentialType credentialType) throws IdentityException
{
- Session em = getHibernateSession(ctx);
+ Session session = getHibernateSession(ctx);
HibernateIdentityObjectCredentialType hibernateType = null;
try
{
- hibernateType = (HibernateIdentityObjectCredentialType)em.
+ hibernateType = (HibernateIdentityObjectCredentialType)session.
createCriteria(HibernateIdentityObjectCredentialType.class).add(Restrictions.eq("name", credentialType.getName())).uniqueResult();
}
catch (HibernateException e)
Added: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/IdentityTestPOJO.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/IdentityTestPOJO.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/IdentityTestPOJO.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,225 @@
+/*
+* 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;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Create;
+import static org.jboss.unit.api.Assert.assertTrue;
+import org.jboss.portal.test.framework.embedded.JNDISupport;
+import org.jboss.portal.test.framework.embedded.ConnectionManagerSupport;
+import org.jboss.portal.test.framework.embedded.TransactionManagerSupport;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.embedded.HibernateSupport;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateRealm;
+import org.jboss.identity.idm.test.HibernateAnnotationsSupport;
+import org.jboss.identity.idm.opends.OpenDSService;
+import org.opends.server.tools.LDAPModify;
+import org.hibernate.SessionFactory;
+
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.Binding;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.directory.DirContext;
+import java.util.List;
+import java.util.LinkedList;
+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 IdentityTestPOJO
+{
+
+ private String identityConfig;
+
+ private String realmName;
+
+ private String dataSourceName;
+
+ private String hibernateConfig;
+
+ private String datasources = "datasources/datasources.xml";
+
+ private JNDISupport jndiSupport;
+
+ protected TransactionManagerSupport transactonManagerSupport;
+
+ protected ConnectionManagerSupport connectionManagerSupport;
+
+ protected DataSourceSupport dataSourceSupport;
+
+ protected HibernateSupport hibernateSupport;
+
+
+
+ public void start() throws Exception
+ {
+ jndiSupport = new JNDISupport();
+ jndiSupport.start();
+ transactonManagerSupport = new TransactionManagerSupport();
+ transactonManagerSupport.start();
+ connectionManagerSupport = new ConnectionManagerSupport();
+ connectionManagerSupport.setTransactionManager(transactonManagerSupport.getTransactionManager());
+ connectionManagerSupport.start();
+
+
+
+ DataSourceSupport.Config dataSourceConfig = DataSourceSupport.Config.obtainConfig(datasources, dataSourceName);
+
+ HibernateSupport.Config hibernateSupportConfig = HibernateSupport.getConfig(dataSourceName, hibernateConfig);
+
+ dataSourceSupport = new DataSourceSupport();
+ dataSourceSupport.setTransactionManager(transactonManagerSupport.getTransactionManager());
+ dataSourceSupport.setConnectionManagerReference(connectionManagerSupport.getConnectionManagerReference());
+ dataSourceSupport.setConfig(dataSourceConfig);
+ dataSourceSupport.start();
+
+ hibernateSupport = new HibernateAnnotationsSupport();
+ hibernateSupport.setConfig(hibernateSupportConfig);
+ hibernateSupport.setJNDIName("java:/jbossidentity/HibernateStoreSessionFactory");
+
+ List<String> annotatedClasses = new LinkedList<String>();
+ annotatedClasses.add(HibernateIdentityObject.class.getName());
+ annotatedClasses.add(HibernateIdentityObjectAttribute.class.getName());
+ annotatedClasses.add(HibernateIdentityObjectBinaryAttribute.class.getName());
+ annotatedClasses.add(HibernateIdentityObjectTextAttribute.class.getName());
+ annotatedClasses.add(HibernateIdentityObjectCredential.class.getName());
+ annotatedClasses.add(HibernateIdentityObjectCredentialType.class.getName());
+ annotatedClasses.add(HibernateIdentityObjectRelationship.class.getName());
+ annotatedClasses.add(HibernateIdentityObjectRelationshipName.class.getName());
+ annotatedClasses.add(HibernateIdentityObjectRelationshipType.class.getName());
+ annotatedClasses.add(HibernateIdentityObjectType.class.getName());
+ annotatedClasses.add(HibernateRealm.class.getName());
+
+ hibernateSupport.setMappings(annotatedClasses);
+
+ hibernateSupport.start();
+
+
+ }
+
+ public void stop() throws Exception
+ {
+ hibernateSupport.stop();
+ dataSourceSupport.stop();
+ connectionManagerSupport.stop();
+ transactonManagerSupport.stop();
+ jndiSupport.stop();
+
+
+ }
+
+ public SessionFactory getSessionFactory()
+ {
+ return getHibernateSupport().getSessionFactory();
+ }
+
+
+
+
+ @Parameter(name="dataSourceName")
+ public void setDataSourceName(String dataSourceName)
+ {
+ this.dataSourceName = dataSourceName;
+ }
+
+ @Parameter(name="hibernateConfig")
+ public void setHibernateConfig(String hibernateConfig)
+ {
+ this.hibernateConfig = hibernateConfig;
+ }
+
+ @Parameter(name="datasources")
+ public void setDatasources(String datasources)
+ {
+ this.datasources = datasources;
+ }
+
+ @Parameter(name="identityConfig")
+ public void setIdentityConfig(String identityConfig)
+ {
+ this.identityConfig = identityConfig;
+ }
+
+ @Parameter(name="realmName")
+ public void setRealmName(String realmName)
+ {
+ this.realmName = realmName;
+ }
+
+ public String getDataSourceName()
+ {
+ return dataSourceName;
+ }
+
+ public String getHibernateConfig()
+ {
+ return hibernateConfig;
+ }
+
+ public String getDatasources()
+ {
+ return datasources;
+ }
+
+ public String getIdentityConfig()
+ {
+ return identityConfig;
+ }
+
+ public String getRealmName()
+ {
+ return realmName;
+ }
+
+ public HibernateSupport getHibernateSupport()
+ {
+ return hibernateSupport;
+ }
+
+ public void begin()
+ {
+ getHibernateSupport().openSession();
+ }
+
+ public void commit()
+ {
+ assertTrue(getHibernateSupport().commitTransaction());
+ }
+
+
+}
Added: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/LDAPTestPOJO.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,161 @@
+/*
+* 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;
+
+import org.jboss.identity.idm.opends.OpenDSService;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.opends.server.tools.LDAPModify;
+
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.Binding;
+import javax.naming.directory.DirContext;
+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 LDAPTestPOJO extends IdentityTestPOJO
+{
+
+ private String directoryName;
+
+ 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");
+
+ @Override
+ public void start() throws Exception
+ {
+ super.start();
+
+
+ openDSService.start();
+ populateClean();
+
+ }
+
+ @Override
+ public void stop() throws Exception
+ {
+ super.stop();
+
+ cleanUp(new InitialLdapContext(env, null));
+ openDSService.stop();
+
+ }
+
+ @Parameter
+ public void setDirectoryName(String directoryName)
+ {
+ this.directoryName = directoryName;
+ }
+
+ public String getDirectoryName()
+ {
+ return directoryName;
+ }
+
+ public void populate() throws Exception
+ {
+ populateLDIF("target/test-classes/ldap/initial-opends.ldif");
+ }
+
+ public void populateClean() throws Exception
+ {
+ populateLDIF("target/test-classes/ldap/initial-empty-opends.ldif");
+ }
+
+ public void populateLDIF(String ldifRelativePath) throws Exception
+ {
+ File ldif = new File(ldifRelativePath);
+
+ System.out.println("LDIF: " + ldif.getAbsolutePath());
+
+ String[] cmd = new String[] {"-h", LDAP_HOST,
+ "-p", LDAP_PORT,
+ "-D", LDAP_PRINCIPAL,
+ "-w", LDAP_CREDENTIALS,
+ "-a", "-f", ldif.getPath()};
+
+ System.out.println("Populate success: " + (LDAPModify.mainModify(cmd, false, System.out, System.err) == 0));
+
+ }
+
+ protected void cleanUp(DirContext ldapCtx) throws Exception
+ {
+ try
+ {
+ String dn = "dc=portal,dc=example,dc=com";
+
+ System.out.println("Removing: " + dn);
+
+ removeContext(ldapCtx, dn);
+ }
+ catch (Exception e)
+ {
+ //
+ }
+ }
+
+ //subsequent remove of javax.naming.Context
+ protected void removeContext(Context mainCtx, String name) throws Exception
+ {
+ Context deleteCtx = (Context)mainCtx.lookup(name);
+ NamingEnumeration subDirs = mainCtx.listBindings(name);
+
+ while (subDirs.hasMoreElements())
+ {
+ Binding binding = (Binding)subDirs.nextElement();
+ String subName = binding.getName();
+
+ removeContext(deleteCtx, subName);
+ }
+
+ mainCtx.unbind(name);
+ }
+
+
+}
Copied: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APIJBossUnitTest.java (from rev 390, idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java)
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APIJBossUnitTest.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APIJBossUnitTest.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,107 @@
+/*
+* 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
Added: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPJBossUnitTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPJBossUnitTest.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APILDAPJBossUnitTest.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,108 @@
+/*
+* 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);
+
+
+ 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
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -1,157 +1,165 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.idm.impl.api;
-
-import junit.framework.TestCase;
-import org.jboss.identity.idm.impl.HibernateTestSupport;
-import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
-import org.jboss.identity.idm.api.IdentitySessionFactory;
-import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
-import org.jboss.identity.idm.opends.OpenDSService;
-import org.opends.server.tools.LDAPModify;
-
-import javax.naming.directory.DirContext;
-import javax.naming.Context;
-import javax.naming.NamingEnumeration;
-import javax.naming.Binding;
-import javax.naming.ldap.InitialLdapContext;
-import java.util.Hashtable;
-import java.io.File;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class APITestBase extends TestCase implements APITestContext
-{
- HibernateTestSupport hibernateSupport =
- new HibernateTestSupport("unit-testing-jpa1", "hibernate-jboss-identity-classes.cfg.xml");
-
- IdentitySessionFactory identitySessionFactory;
-
- public static final String LDAP_HOST = "localhost";
-
- public static final String LDAP_PORT = "10389";
-
- public static final String LDAP_PROVIDER_URL = "ldap://" + LDAP_HOST + ":" + LDAP_PORT;
-
- public static final String LDAP_PRINCIPAL = "cn=Directory Manager";
-
- public static final String LDAP_CREDENTIALS = "password";
-
- static Hashtable<String,String> env = new Hashtable<String,String>();
-
- static
- {
- env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
- env.put(Context.PROVIDER_URL, LDAP_PROVIDER_URL);
- env.put(Context.SECURITY_AUTHENTICATION, "simple");
- env.put(Context.SECURITY_PRINCIPAL, LDAP_PRINCIPAL);
- env.put(Context.SECURITY_CREDENTIALS, LDAP_CREDENTIALS);
- }
-
- OpenDSService openDSService = new OpenDSService("target/test-classes/opends");
-
- protected void setUp() throws Exception
- {
- super.setUp();
- hibernateSupport.start();
- openDSService.start();
-
- }
-
- protected void tearDown() throws Exception
- {
- hibernateSupport.stop();
-
- cleanUp(new InitialLdapContext(env, null));
-
- openDSService.stop();
- }
-
- public IdentitySessionFactory getIdentitySessionFactory()
- {
- return identitySessionFactory;
- }
-
- public void populate() throws Exception
- {
- populateLDIF("target/test-classes/ldap/initial-opends.ldif");
- }
-
- public void populateClean() throws Exception
- {
- populateLDIF("target/test-classes/ldap/initial-empty-opends.ldif");
- }
-
- public void populateLDIF(String ldifRelativePath) throws Exception
- {
- File ldif = new File(ldifRelativePath);
-
- System.out.println("LDIF: " + ldif.getAbsolutePath());
-
- String[] cmd = new String[] {"-h", LDAP_HOST,
- "-p", LDAP_PORT,
- "-D", LDAP_PRINCIPAL,
- "-w", LDAP_CREDENTIALS,
- "-a", "-f", ldif.getPath()};
-
- System.out.println("Populate success: " + (LDAPModify.mainModify(cmd, false, System.out, System.err) == 0));
-
- }
-
- protected void cleanUp(DirContext ldapCtx) throws Exception
- {
- try
- {
- String dn = "dc=portal,dc=example,dc=com";
-
- System.out.println("Removing: " + dn);
-
- removeContext(ldapCtx, dn);
- }
- catch (Exception e)
- {
- //
- }
- }
-
- //subsequent remove of javax.naming.Context
- protected void removeContext(Context mainCtx, String name) throws Exception
- {
- Context deleteCtx = (Context)mainCtx.lookup(name);
- NamingEnumeration subDirs = mainCtx.listBindings(name);
-
- while (subDirs.hasMoreElements())
- {
- Binding binding = (Binding)subDirs.nextElement();
- String subName = binding.getName();
-
- removeContext(deleteCtx, subName);
- }
-
- mainCtx.unbind(name);
- }
-
-
-}
\ No newline at end of file
+///*
+//* 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
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -1,144 +1,144 @@
-/*
-* 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");
- }
-
-}
-
+///*
+//* 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");
+// }
+//
+//}
+//
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestContext.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestContext.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestContext.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -34,4 +34,8 @@
IdentitySessionFactory getIdentitySessionFactory();
+ void begin();
+
+ void commit();
+
}
Added: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationJBossUnitTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationJBossUnitTest.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationJBossUnitTest.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,106 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.api;
+
+import org.jboss.identity.idm.impl.IdentityTestPOJO;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+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.jboss.unit.api.pojo.annotations.Parameter;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class OrganizationJBossUnitTest extends IdentityTestPOJO implements APITestContext
+{
+ private OrganizationTest orgTest;
+
+ private IdentitySessionFactory identitySessionFactory;
+
+ private String samplePortalRealmName;
+
+ private String sampleOrganizationRealmName;
+
+
+ @Create
+ public void start() throws Exception
+ {
+ super.start();
+
+ orgTest = new OrganizationTest(this);
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(getIdentityConfig()).buildIdentitySessionFactory();
+ }
+
+ @Destroy
+ public void stop() throws Exception
+ {
+ super.stop();
+ }
+
+ public IdentitySessionFactory getIdentitySessionFactory()
+ {
+ return identitySessionFactory;
+ }
+
+ @Test
+ public void testOrganization() throws Exception
+ {
+
+ orgTest.testRedHatOrganization(getSampleOrganizationRealmName());
+ }
+
+ @Test
+ public void testSamplePortal() throws Exception
+ {
+
+ orgTest.testSamplePortal(getSamplePortalRealmName());
+
+ }
+
+ public String getSamplePortalRealmName()
+ {
+ return samplePortalRealmName;
+ }
+
+ @Parameter
+ public void setSamplePortalRealmName(String samplePortalRealmName)
+ {
+ this.samplePortalRealmName = samplePortalRealmName;
+ }
+
+ public String getSampleOrganizationRealmName()
+ {
+ return sampleOrganizationRealmName;
+ }
+
+ @Parameter
+ public void setSampleOrganizationRealmName(String sampleOrganizationRealmName)
+ {
+ this.sampleOrganizationRealmName = sampleOrganizationRealmName;
+ }
+}
\ No newline at end of file
Added: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPJBossUnitTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPJBossUnitTest.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationLDAPJBossUnitTest.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,107 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.api;
+
+import org.jboss.identity.idm.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.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Test;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class OrganizationLDAPJBossUnitTest extends LDAPTestPOJO implements APITestContext
+{
+ private OrganizationTest orgTest;
+
+ private IdentitySessionFactory identitySessionFactory;
+
+ private String samplePortalRealmName;
+
+ private String sampleOrganizationRealmName;
+
+
+ @Create
+ public void start() throws Exception
+ {
+ super.start();
+
+ orgTest = new OrganizationTest(this);
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(getIdentityConfig()).buildIdentitySessionFactory();
+ }
+
+ @Destroy
+ public void stop() throws Exception
+ {
+ super.stop();
+ }
+
+ public IdentitySessionFactory getIdentitySessionFactory()
+ {
+ return identitySessionFactory;
+ }
+
+ @Test
+ public void testOrganization() throws Exception
+ {
+
+ orgTest.testRedHatOrganization(getSampleOrganizationRealmName());
+ }
+
+ @Test
+ public void testSamplePortal() throws Exception
+ {
+
+ orgTest.testSamplePortal(getSamplePortalRealmName());
+
+ }
+
+ public String getSamplePortalRealmName()
+ {
+ return samplePortalRealmName;
+ }
+
+ @Parameter
+ public void setSamplePortalRealmName(String samplePortalRealmName)
+ {
+ this.samplePortalRealmName = samplePortalRealmName;
+ }
+
+ public String getSampleOrganizationRealmName()
+ {
+ return sampleOrganizationRealmName;
+ }
+
+ @Parameter
+ public void setSampleOrganizationRealmName(String sampleOrganizationRealmName)
+ {
+ this.sampleOrganizationRealmName = sampleOrganizationRealmName;
+ }
+}
\ No newline at end of file
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -29,6 +29,8 @@
import org.jboss.identity.idm.api.IdentitySessionFactory;
import org.jboss.identity.idm.api.Attribute;
import org.jboss.identity.idm.api.AttributeDescription;
+import org.jboss.identity.idm.api.CredentialType;
+import org.jboss.identity.idm.api.Credential;
import org.jboss.identity.idm.p3p.P3PConstants;
import java.util.Collection;
@@ -78,8 +80,10 @@
IdentitySession session = factory.createIdentitySession(realmName);
- session.getTransaction().start();
+ //ctx.begin();
+ ctx.begin();
+
// Organization structure
Group rhOrg = session.getPersistenceManager().createGroup("RedHat", ORGANIZATION);
@@ -296,8 +300,51 @@
assertEquals("Dawidowicz", (attributes.get(P3PConstants.INFO_USER_NAME_FAMILY)).getValue());
assertTrue(Arrays.equals((byte[])attributes.get("picture").getValue(), picture));
- session.getTransaction().commit();
+ // Credential
+ User anotherOne = bdawidowUser; //session.getPersistenceManager().createUser("blah1");
+
+ assertTrue(session.getAttributesManager().hasCredential(anotherOne, PasswordCredential.TYPE));
+
+ // #1
+ session.getAttributesManager().updatePassword(anotherOne, "secret");
+ assertTrue(session.getAttributesManager().validatePassword(anotherOne, "secret"));
+ assertFalse(session.getAttributesManager().validatePassword(anotherOne, "secret2"));
+ assertFalse(session.getAttributesManager().validatePassword(anotherOne, "secret3"));
+
+ // #1
+ session.getAttributesManager().updatePassword(anotherOne, "secret2");
+ assertTrue(session.getAttributesManager().validatePassword(anotherOne, "secret2"));
+ assertFalse(session.getAttributesManager().validatePassword(anotherOne, "secret"));
+ assertFalse(session.getAttributesManager().validatePassword(anotherOne, "secret3"));
+
+
+ // #1
+ session.getAttributesManager().updatePassword(anotherOne, "secret3");
+ assertTrue(session.getAttributesManager().validatePassword(anotherOne, "secret3"));
+ assertFalse(session.getAttributesManager().validatePassword(anotherOne, "secret"));
+ assertFalse(session.getAttributesManager().validatePassword(anotherOne, "secret2"));
+
+
+ // #2
+ Credential password = new PasswordCredential("secretPhrase");
+ session.getAttributesManager().updateCredential(anotherOne, password);
+ assertTrue(session.getAttributesManager().validateCredentials(anotherOne, new Credential[]{password}));
+
+ // #3
+
+ if (session.getAttributesManager().hasCredential(anotherOne, BinaryCredential.TYPE))
+ {
+ byte[] cert = new byte[5120];
+ random.nextBytes(cert);
+ Credential binaryCredential = new BinaryCredential(cert);
+ session.getAttributesManager().updateCredential(anotherOne, binaryCredential);
+ assertTrue(session.getAttributesManager().validateCredentials(anotherOne, new Credential[]{binaryCredential}));
+ }
+
+
+ ctx.commit();
+
}
public void testSamplePortal(String realmName) throws Exception
@@ -317,7 +364,7 @@
IdentitySession session = factory.createIdentitySession(realmName);
- session.getTransaction().start();
+ ctx.begin();
@@ -340,9 +387,9 @@
Group organizationRootGroup = session.getPersistenceManager().createGroup("ORGANIZATION_ROOT",SYSTEM);
Group usersROOTGroup = session.getPersistenceManager().createGroup("USERS_ROOT",SYSTEM);
- session.getTransaction().commit();
+ ctx.commit();
- session.getTransaction().start();
+ ctx.begin();
// Communities
@@ -414,9 +461,9 @@
User billUser = session.getPersistenceManager().createUser("bill");
User jackUser = session.getPersistenceManager().createUser("jack");
- session.getTransaction().commit();
+ ctx.commit();
- session.getTransaction().start();
+ ctx.begin();
// All users are under people root
@@ -432,9 +479,9 @@
session.getRelationshipManager().associateUser(usersROOTGroup, billUser);
session.getRelationshipManager().associateUser(usersROOTGroup, jackUser);
- session.getTransaction().commit();
+ ctx.commit();
- session.getTransaction().start();
+ ctx.begin();
//
@@ -460,9 +507,9 @@
session.save();
- session.getTransaction().commit();
+ ctx.commit();
- session.getTransaction().start();
+ ctx.begin();
session.getRoleManager().createRole(communityMemberRT, anneUser, baseJumpingCommunity);
session.getRoleManager().createRole(communityForumModeratorRT, anneUser, baseJumpingCommunity);
@@ -531,7 +578,7 @@
- session.getTransaction().commit();
+ ctx.commit();
}
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -1,102 +1,104 @@
-/*
-* 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
+///*
+//* 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
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -75,7 +75,7 @@
- session.getTransaction().start();
+ ctx.begin();
// Bad names
@@ -170,7 +170,7 @@
assertEquals(0, session.getPersistenceManager().findUser((IdentitySearchCriteria)null).size());
- session.getTransaction().commit();
+ ctx.commit();
}
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -76,7 +76,7 @@
IdentitySession session = factory.createIdentitySession(realmName);
- session.getTransaction().start();
+ ctx.begin();
// Create stuff
User user1 = session.getPersistenceManager().createUser("user1");
@@ -212,9 +212,9 @@
session.getRelationshipManager().disassociateUsers(Arrays.asList(group1), Arrays.asList(user1, user2));
- session.getTransaction().commit();
+ ctx.commit();
- session.getTransaction().start();
+ ctx.begin();
// Find methods - prepopulate
@@ -227,8 +227,8 @@
assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group2), Arrays.asList(group3, group4, group5)));
assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group3), Arrays.asList(user2, user3)));
- session.getTransaction().commit();
- session.getTransaction().start();
+ ctx.commit();
+ ctx.begin();
// Find users
//TODO: check if collections contain correct objects (not only size)
@@ -308,7 +308,7 @@
assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group2), Arrays.asList(group3, group4, group5)));
assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group3), Arrays.asList(user2, user3)));
- session.getTransaction().commit();
+ ctx.commit();
}
@@ -318,7 +318,7 @@
IdentitySession session = factory.createIdentitySession(realmName);
- session.getTransaction().start();
+ ctx.begin();
// Create stuff
User user1 = session.getPersistenceManager().createUser("user1");
@@ -364,7 +364,7 @@
assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2, (IdentitySearchCriteria)null).size());
assertEquals(2, session.getRelationshipManager().findRelatedGroups(user2, null, null).size());
- session.getTransaction().commit();
+ ctx.commit();
}
}
\ No newline at end of file
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -73,7 +73,7 @@
IdentitySession session = factory.createIdentitySession(realmName);
- session.getTransaction().start();
+ ctx.begin();
@@ -214,7 +214,7 @@
- session.getTransaction().commit();
+ ctx.commit();
}
Copied: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java (from rev 390, idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java)
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreJBossUnitTest.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,290 @@
+/*
+* 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 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(new File(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
+
+ 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);
+
+ 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();
+
+ }
+
+ public void testRelationships() throws Exception
+ {
+ commonTest.testRelationships();
+ }
+
+ public void testCredentials() throws Exception
+ {
+ commonTest.testPasswordCredential();
+ commonTest.testBinaryCredential();
+ }
+
+ public void testControls() throws Exception
+ {
+ commonTest.testControls();
+ }
+
+}
\ No newline at end of file
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -1,291 +1,291 @@
-/*
-* 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();
- }
-
-}
+///*
+//* 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/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java (from rev 390, idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java)
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelJBossUnitTest.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,320 @@
+/*
+* 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.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();
+ }
+
+ public void testPersistence() {
+
+ Session session = getSessionFactory().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 = getSessionFactory().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 = getSessionFactory().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 = getSessionFactory().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 = getSessionFactory().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 = getSessionFactory().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 = getSessionFactory().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 = getSessionFactory().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 = getSessionFactory().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();
+
+ }
+
+}
\ No newline at end of file
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -1,304 +1,304 @@
-/*
-* 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);
+///*
+//* 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.
+//*/
//
-// 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();
-
- }
-
-}
+//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();
+//
+// }
+//
+//}
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -1,64 +1,64 @@
-/*
-* 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();
- }
-}
+///*
+//* 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();
+// }
+//}
Copied: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java (from rev 390, idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java)
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreJBossUnitTest.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,517 @@
+/*
+* 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.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(new File(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 begin() throws Exception
+// {
+// //nothing
+// }
+//
+// public void commit() throws Exception
+// {
+// //nothing
+// }
+//
+ public void flush() throws Exception
+ {
+ //nothing
+ }
+
+ public IdentityStore getStore()
+ {
+ return store;
+ }
+
+ public IdentityStoreInvocationContext getCtx()
+ {
+ return ctx;
+ }
+
+
+ public LdapContext getLdapContext() throws Exception
+ {
+ 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);
+
+ return new InitialLdapContext(env, null);
+ }
+
+
+
+ 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() throws Exception
+ {
+ DirContext ldapCtx = getLdapContext();
+
+ try
+ {
+
+
+ String dn = "dc=portal,dc=example,dc=com";
+
+ System.out.println("Removing: " + dn);
+
+ removeContext(ldapCtx, dn);
+ }
+ catch (Exception e)
+ {
+ //
+ }
+ finally
+ {
+ ldapCtx.close();
+ }
+ }
+
+ //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);
+ }
+
+ // Tests
+
+// Just test if OpenDS is running and was populated...
+ 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();
+ }
+ }
+ }
+
+ 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));
+ }
+
+ 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());
+
+ }
+
+ 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());
+
+ }
+
+ public void testRelationships() throws Exception
+ {
+ populateClean();
+
+ commonTest.testRelationships();
+
+ }
+
+ public void testStorePersistence() throws Exception
+ {
+ populateClean();
+
+ commonTest.testStorePersistence();
+
+ }
+
+ public void testFindMethods() throws Exception
+ {
+ populateClean();
+
+ commonTest.testFindMethods();
+
+ }
+
+ public void testControls() throws Exception
+ {
+ populateClean();
+
+ commonTest.testControls();
+ }
+
+
+ public void testCredentials() throws Exception
+ {
+ populateClean();
+
+ commonTest.testPasswordCredential();
+ }
+
+}
Deleted: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -1,527 +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.exception.IdentityException;
-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;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class
- LDAPIdentityStoreTestCase extends TestCase implements IdentityStoreTestContext
-{
-
- 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";
-
- OpenDSService openDSService = new OpenDSService("target/test-classes/opends");
-
- IdentityStore store;
-
- CommonIdentityStoreTest commonTest;
-
- IdentityStoreInvocationContext ctx;
-
- public LDAPIdentityStoreTestCase(String s)
- {
- super(s);
- commonTest = new CommonIdentityStoreTest(this);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- openDSService.start();
-
- IdentityConfigurationMetaData configurationMD = JAXB2IdentityConfiguration
- .createConfigurationMetaData(new File("src/test/resources/store-test-config.xml"));
-
- 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);
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- cleanUp();
-
- openDSService.stop();
- }
-
- public void begin() throws Exception
- {
- //nothing
- }
-
- public void commit() throws Exception
- {
- //nothing
- }
-
- public void flush() throws Exception
- {
- //nothing
- }
-
- public IdentityStore getStore()
- {
- return store;
- }
-
- public IdentityStoreInvocationContext getCtx()
- {
- return ctx;
- }
-
-
- public LdapContext getLdapContext() throws Exception
- {
- 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);
-
- return new InitialLdapContext(env, null);
- }
-
-
-
- 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() throws Exception
- {
- DirContext ldapCtx = getLdapContext();
-
- try
- {
-
-
- String dn = "dc=portal,dc=example,dc=com";
-
- System.out.println("Removing: " + dn);
-
- removeContext(ldapCtx, dn);
- }
- catch (Exception e)
- {
- //
- }
- finally
- {
- ldapCtx.close();
- }
- }
-
- //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);
- }
-
- // Tests
-
-// Just test if OpenDS is running and was populated...
- 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();
- }
- }
- }
-
- 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));
- }
-
- 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());
-
- }
-
- 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());
-
- }
-
- public void testRelationships() throws Exception
- {
- populateClean();
-
- commonTest.testRelationships();
-
- }
-
- public void testStorePersistence() throws Exception
- {
- populateClean();
-
- commonTest.testStorePersistence();
-
- }
-
- public void testFindMethods() throws Exception
- {
- populateClean();
-
- commonTest.testFindMethods();
-
- }
-
- public void testControls() throws Exception
- {
- populateClean();
-
- commonTest.testControls();
- }
-
-
- public void testCredentials() throws Exception
- {
- populateClean();
-
- commonTest.testPasswordCredential();
- }
-
-}
Added: idm/trunk/idm/src/test/java/org/jboss/identity/idm/test/HibernateAnnotationsSupport.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/test/HibernateAnnotationsSupport.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/test/HibernateAnnotationsSupport.java 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,88 @@
+/*
+* 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.test;
+
+import org.jboss.portal.test.framework.embedded.HibernateSupport;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.AnnotationConfiguration;
+
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class HibernateAnnotationsSupport extends HibernateSupport
+{
+
+ @Override
+ protected void createConfiguration()
+ {
+ AnnotationConfiguration cfg = new AnnotationConfiguration();
+
+ //
+ for (Iterator i = mappings.iterator(); i.hasNext();)
+ {
+ String mapping = (String)i.next();
+ log.debug("Adding annotated enitity " + mapping);
+ try
+ {
+ Class mappedClass = Class.forName(mapping);
+ cfg.addAnnotatedClass(mappedClass);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IllegalArgumentException("Cannot find mapped class: " + mapping, e);
+ }
+
+ }
+
+ //
+ Properties props = new Properties();
+ for (Iterator i = config.getProperties().entrySet().iterator();i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String key = (String)entry.getKey();
+ String value = (String)entry.getValue();
+ log.debug("Adding property " + key + " = " + value);
+ cfg.setProperty(key, value);
+ }
+ cfg.addProperties(props);
+
+ // todo : make this configurable somehow
+ cfg.setProperty("hibernate.connection.datasource", "java:/DefaultDS");
+
+ //
+ if (jndiName != null)
+ {
+ log.debug("Setting jndi name to " + jndiName);
+ cfg.setProperty("hibernate.session_factory_name", jndiName);
+ }
+
+ //
+ this.settings = cfg.buildSettings();
+ this.cfg = cfg;
+ }
+}
Added: idm/trunk/idm/src/test/resources/datasources/datasources.xml
===================================================================
--- idm/trunk/idm/src/test/resources/datasources/datasources.xml (rev 0)
+++ idm/trunk/idm/src/test/resources/datasources/datasources.xml 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,97 @@
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<datasources>
+
+ <datasource>
+ <datasource-name>oracle10g-local</datasource-name>
+ <connection-url>jdbc:oracle:thin:@192.168.1.101:1521:XE</connection-url>
+ <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
+ <user-name>jbid</user-name>
+ <password>jbid</password>
+ </datasource>
+
+ <datasource>
+ <datasource-name>mysql5-local</datasource-name>
+ <connection-url>jdbc:mysql://localhost:3306/jbid?useServerPrepStmts=false&jdbcCompliantTruncation=false</connection-url>
+ <driver-class>com.mysql.jdbc.Driver</driver-class>
+ <user-name>root</user-name>
+ <password></password>
+ </datasource>
+
+ <datasource>
+ <datasource-name>hsqldb</datasource-name>
+ <connection-url>jdbc:hsqldb:file:test</connection-url>
+ <driver-class>org.hsqldb.jdbcDriver</driver-class>
+ <user-name>sa</user-name>
+ <password></password>
+ </datasource>
+
+ <datasource>
+ <datasource-name>postgresql8</datasource-name>
+ <connection-url>jdbc:postgresql://dev01.qa.atl.jboss.com:5432:portal</connection-url>
+ <driver-class>org.postgresql.Driver</driver-class>
+ <user-name>portal</user-name>
+ <password>password</password>
+ </datasource>
+
+ <datasource>
+ <datasource-name>sqlserver</datasource-name>
+ <connection-url>jdbc:jtds:sqlserver://dev30.qa.atl.jboss.com:3918/portal</connection-url>
+ <driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
+ <user-name>portal</user-name>
+ <password>password</password>
+ </datasource>
+
+ <datasource>
+ <datasource-name>oracle9i</datasource-name>
+ <connection-url>jdbc:oracle:thin:@dev20.qa.atl.jboss.com:1521:qa</connection-url>
+ <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
+ <user-name>portal</user-name>
+ <password>password</password>
+ </datasource>
+
+ <datasource>
+ <datasource-name>oracle10g</datasource-name>
+ <connection-url>jdbc:oracle:thin:@dev01.qa.atl.jboss.com:1521:qadb01</connection-url>
+ <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
+ <user-name>portal</user-name>
+ <password>password</password>
+ </datasource>
+
+ <datasource>
+ <datasource-name>mysql4</datasource-name>
+ <connection-url>jdbc:mysql://dev02.qa.atl.jboss.com/portal</connection-url>
+ <driver-class>com.mysql.jdbc.Driver</driver-class>
+ <user-name>portal</user-name>
+ <password>password</password>
+ </datasource>
+
+ <datasource>
+ <datasource-name>mysql5</datasource-name>
+ <connection-url>jdbc:mysql://dev02.qa.atl.jboss.com/portal?jdbcCompliantTruncation=false</connection-url>
+ <driver-class>com.mysql.jdbc.Driver</driver-class>
+ <user-name>portal</user-name>
+ <password>password</password>
+ </datasource>
+</datasources>
Added: idm/trunk/idm/src/test/resources/datasources/hibernates.xml
===================================================================
--- idm/trunk/idm/src/test/resources/datasources/hibernates.xml (rev 0)
+++ idm/trunk/idm/src/test/resources/datasources/hibernates.xml 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,157 @@
+<configurations>
+ <!-- The default configuration that will apply everywhere -->
+ <configuration>
+ <configuration-name>default</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.show_sql</name>
+ <value>true</value>
+ </property>
+ <property>
+ <name>hibernate.auto_close_session</name>
+ <value>true</value>
+ </property>
+ <property>
+ <name>hibernate.transaction.flush_before_completion</name>
+ <value>true</value>
+ </property>
+ <property>
+ <name>hibernate.transaction.factory_class</name>
+ <value>org.hibernate.transaction.JTATransactionFactory</value>
+ </property>
+ <property>
+ <name>hibernate.transaction.manager_lookup_class</name>
+ <value>org.hibernate.transaction.JBossTransactionManagerLookup</value>
+ </property>
+ <property>
+ <name>hibernate.cache.provider_class</name>
+ <value>org.hibernate.cache.HashtableCacheProvider</value>
+ </property>
+ <property>
+ <name>hibernate.cache.use_second_level_cache</name>
+ <value>false</value>
+ </property>
+ <property>
+ <name>hibernate.cache.use_query_cache</name>
+ <value>false</value>
+ </property>
+ </properties>
+ </configuration>
+ <!-- The hsqldb configuration -->
+ <configuration>
+ <configuration-name>hsqldb</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.HSQLDialect</value>
+ </property>
+ </properties>
+ </configuration>
+ <!-- The oracle 9i configuration -->
+ <configuration>
+ <configuration-name>oracle9i</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.Oracle9Dialect</value>
+ </property>
+ <!-- Needed in order to avoid the bug described in HBX-146 to happen in instance container test case -->
+ <property>
+ <name>hibernate.cache.use_second_level_cache</name>
+ <value>true</value>
+ </property>
+ </properties>
+ </configuration>
+ <configuration>
+ <configuration-name>oracle9i-local</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.Oracle9Dialect</value>
+ </property>
+ <!-- Needed in order to avoid the bug described in HBX-146 to happen in instance container test case -->
+ <property>
+ <name>hibernate.cache.use_second_level_cache</name>
+ <value>true</value>
+ </property>
+ </properties>
+ </configuration>
+ <!-- The oracle 10g configuration -->
+ <configuration>
+ <configuration-name>oracle10g</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.Oracle9Dialect</value>
+ </property>
+ <!-- Needed in order to avoid the bug described in HBX-146 to happen in instance container test case -->
+ <property>
+ <name>hibernate.cache.use_second_level_cache</name>
+ <value>true</value>
+ </property>
+ </properties>
+ </configuration>
+ <configuration>
+ <configuration-name>oracle10g-local</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.Oracle9Dialect</value>
+ </property>
+ <!-- Needed in order to avoid the bug described in HBX-146 to happen in instance container test case -->
+ <property>
+ <name>hibernate.cache.use_second_level_cache</name>
+ <value>true</value>
+ </property>
+ </properties>
+ </configuration>
+ <!-- The sqlserver configuration -->
+ <configuration>
+ <configuration-name>sqlserver</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.SQLServerDialect</value>
+ </property>
+ </properties>
+ </configuration>
+ <!-- The mysql 4 configuration -->
+ <configuration>
+ <configuration-name>mysql4</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.MySQLInnoDBDialect</value>
+ </property>
+ </properties>
+ </configuration>
+ <!-- The mysql 5 configuration -->
+ <configuration>
+ <configuration-name>mysql5</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.MySQLInnoDBDialect</value>
+ </property>
+ </properties>
+ </configuration>
+ <configuration>
+ <configuration-name>mysql5-local</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.MySQLInnoDBDialect</value>
+ </property>
+ </properties>
+ </configuration>
+ <!-- The postgresql 8 configuration -->
+ <configuration>
+ <configuration-name>postgresql8</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.PostgreSQLDialect</value>
+ </property>
+ </properties>
+ </configuration>
+</configurations>
Added: idm/trunk/idm/src/test/resources/jboss-unit.xml
===================================================================
--- idm/trunk/idm/src/test/resources/jboss-unit.xml (rev 0)
+++ idm/trunk/idm/src/test/resources/jboss-unit.xml 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-unit
+ xmlns="urn:jboss:jboss-unit:1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
+ <pojo>
+ <parameter name="datasources" value="datasources/datasources.xml"/>
+ <parameter name="dataSourceName" value="hsqldb"/>
+ <parameter name="hibernateConfig" value="datasources/hibernates.xml"/>
+ <parameter name="identityConfig" value="organization-test-jboss-unit-config.xml"/>
+ <parameter name="realmName" value=""/>
+
+ <!--Without LDAP-->
+ <test >
+ <class name="org.jboss.identity.idm.impl.api.OrganizationJBossUnitTest"/>
+ <parameter name="sampleOrganizationRealmName" value="realm://RedHat/DB"/>
+ <parameter name="samplePortalRealmName" value="realm://portal/SamplePortal/DB"/>
+ </test>
+
+ <!--With LDAP-->
+ <test >
+ <class name="org.jboss.identity.idm.impl.api.OrganizationLDAPJBossUnitTest"/>
+ <parameter name="directoryName" value="EmbeddedOpenDS"/>
+ <parameter name="sampleOrganizationRealmName" value="realm://RedHat/DB_LDAP"/>
+ <parameter name="samplePortalRealmName" value="realm://portal/SamplePortal/DB_LDAP"/>
+ </test>
+
+ <!--Without LDAP-->
+ <test >
+ <class name="org.jboss.identity.idm.impl.api.APIJBossUnitTest"/>
+ <parameter name="realmName" value="realm://RedHat/DB"/>
+ </test>
+
+ <!--With LDAP-->
+ <test >
+ <class name="org.jboss.identity.idm.impl.api.APILDAPJBossUnitTest"/>
+ <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"/>
+ <parameter name="identityConfig" value="src/test/resources/store-test-config.xml"/>
+ </test>
+
+ <!--Without LDAP-->
+ <test >
+ <class name="org.jboss.identity.idm.impl.store.hibernate.HibernateModelJBossUnitTest"/>
+ </test>
+
+ <!--With LDAP-->
+ <test >
+ <class name="org.jboss.identity.idm.impl.store.ldap.LDAPIdentityStoreJBossUnitTest"/>
+ <parameter name="directoryName" value="EmbeddedOpenDS"/>
+ <parameter name="identityConfig" value="src/test/resources/store-test-config.xml"/>
+ </test>
+
+ </pojo>
+</jboss-unit>
Modified: idm/trunk/idm/src/test/resources/organization-test-config.xml
===================================================================
--- idm/trunk/idm/src/test/resources/organization-test-config.xml 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/test/resources/organization-test-config.xml 2009-04-02 13:44:45 UTC (rev 411)
@@ -455,6 +455,10 @@
<name>hibernateConfiguration</name>
<value>hibernate-jboss-identity.cfg.xml</value>
</option>
+ <!--<option>-->
+ <!--<name>hibernateSessionFactoryJNDIName</name>-->
+ <!--<value>java:/jbossidentity/HibernateStoreSessionFactory</value>-->
+ <!--</option>-->
<option>
<name>populateRelationshipTypes</name>
<value>true</value>
@@ -524,7 +528,7 @@
</option>
<option>
<name>passwordAttributeName</name>
- <value>password</value>
+ <value>userPassword</value>
</option>
<option>
<name>ctxDNs</name>
Copied: idm/trunk/idm/src/test/resources/organization-test-jboss-unit-config.xml (from rev 390, idm/trunk/idm/src/test/resources/organization-test-config.xml)
===================================================================
--- idm/trunk/idm/src/test/resources/organization-test-jboss-unit-config.xml (rev 0)
+++ idm/trunk/idm/src/test/resources/organization-test-jboss-unit-config.xml 2009-04-02 13:44:45 UTC (rev 411)
@@ -0,0 +1,792 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-identity xmlns="urn:jboss:identity:idm:config:v1_0_alpha"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:identity:idm:config:v1_0_alpha identity-config.xsd">
+ <realms>
+ <realm>
+ <id>realm://RedHat/DB</id>
+ <repository-id-ref>RedHat Repository DB</repository-id-ref>
+ <identity-type-mappings>
+ <user-mapping>USER</user-mapping>
+ </identity-type-mappings>
+ </realm>
+ <realm>
+ <id>realm://portal/SamplePortal/DB</id>
+ <repository-id-ref>Sample Portal Repository DB</repository-id-ref>
+ <identity-type-mappings>
+ <user-mapping>USER</user-mapping>
+ </identity-type-mappings>
+ </realm>
+ <realm>
+ <id>realm://RedHat/DB_LDAP</id>
+ <repository-id-ref>RedHat Repository DB+LDAP</repository-id-ref>
+ <identity-type-mappings>
+ <user-mapping>USER</user-mapping>
+ </identity-type-mappings>
+ </realm>
+ <realm>
+ <id>realm://portal/SamplePortal/DB_LDAP</id>
+ <repository-id-ref>Sample Portal Repository DB+LDAP</repository-id-ref>
+ <identity-type-mappings>
+ <user-mapping>USER</user-mapping>
+ </identity-type-mappings>
+ </realm>
+ </realms>
+ <repositories>
+ <repository>
+ <id>RedHat Repository DB</id>
+ <class>org.jboss.identity.idm.impl.repository.WrapperIdentityStoreRepository</class>
+ <external-config/>
+ <default-identity-store-id>Hibernate Identity Store</default-identity-store-id>
+ <default-attribute-store-id>Hibernate Identity Store</default-attribute-store-id>
+ <options>
+ <option>
+ <name>allowNotDefinedAttributes</name>
+ <value>true</value>
+ </option>
+ </options>
+ </repository>
+ <repository>
+ <id>Sample Portal Repository DB</id>
+ <class>org.jboss.identity.idm.impl.repository.WrapperIdentityStoreRepository</class>
+ <external-config/>
+ <default-identity-store-id>Hibernate Identity Store</default-identity-store-id>
+ <default-attribute-store-id>Hibernate Identity Store</default-attribute-store-id>
+ <options>
+ <option>
+ <name>allowNotDefinedAttributes</name>
+ <value>true</value>
+ </option>
+ </options>
+ </repository>
+ <repository>
+ <id>RedHat Repository DB+LDAP</id>
+ <class>org.jboss.identity.idm.impl.repository.FallbackIdentityStoreRepository</class>
+ <external-config/>
+ <default-identity-store-id>Hibernate Identity Store</default-identity-store-id>
+ <default-attribute-store-id>Hibernate Identity Store</default-attribute-store-id>
+ <identity-store-mappings>
+ <identity-store-mapping>
+ <identity-store-id>Hibernate Identity Store</identity-store-id>
+ <identity-object-types>
+ <identity-object-type>DIVISION</identity-object-type>
+ <identity-object-type>PROJECT</identity-object-type>
+ <identity-object-type>PEOPLE</identity-object-type>
+ </identity-object-types>
+ <options/>
+ </identity-store-mapping>
+ <identity-store-mapping>
+ <identity-store-id>LDAP Identity Store</identity-store-id>
+ <identity-object-types>
+ <identity-object-type>USER</identity-object-type>
+ <identity-object-type>ORGANIZATION</identity-object-type>
+ <identity-object-type>ORGANIZATION_UNIT</identity-object-type>
+ <identity-object-type>DEPARTMENT</identity-object-type>
+ </identity-object-types>
+ <options>
+ <option>
+ <name>cache</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>cache.config-file</name>
+ <value>jboss-cache-config.xml</value>
+ </option>
+ </options>
+ </identity-store-mapping>
+ </identity-store-mappings>
+ <options>
+ <option>
+ <name>allowNotDefinedAttributes</name>
+ <value>true</value>
+ </option>
+ </options>
+ </repository>
+ <repository>
+ <id>Sample Portal Repository DB+LDAP</id>
+ <class>org.jboss.identity.idm.impl.repository.FallbackIdentityStoreRepository</class>
+ <external-config/>
+ <default-identity-store-id>Hibernate Identity Store</default-identity-store-id>
+ <default-attribute-store-id>Hibernate Identity Store</default-attribute-store-id>
+ <identity-store-mappings>
+ <identity-store-mapping>
+ <identity-store-id>Hibernate Identity Store</identity-store-id>
+ <identity-object-types>
+ <identity-object-type>SYSTEM</identity-object-type>
+ <identity-object-type>ADMINISTRATION</identity-object-type>
+ <identity-object-type>COMMUNITY</identity-object-type>
+ <identity-object-type>DIVISION</identity-object-type>
+ <identity-object-type>SECURITY</identity-object-type>
+ <identity-object-type>PEOPLE</identity-object-type>
+ </identity-object-types>
+ <options/>
+ </identity-store-mapping>
+ <identity-store-mapping>
+ <identity-store-id>LDAP Identity Store</identity-store-id>
+ <identity-object-types>
+ <identity-object-type>USER</identity-object-type>
+ <identity-object-type>DEPARTMENT</identity-object-type>
+ <identity-object-type>ORGANIZATION</identity-object-type>
+ <identity-object-type>ORGANIZATION_UNIT</identity-object-type>
+ <identity-object-type>OFFICE</identity-object-type>
+ </identity-object-types>
+ <options>
+ <option>
+ <name>cache</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>cache.config-file</name>
+ <value>jboss-cache-config.xml</value>
+ </option>
+ </options>
+ </identity-store-mapping>
+ </identity-store-mappings>
+ <options>
+ <option>
+ <name>allowNotDefinedAttributes</name>
+ <value>true</value>
+ </option>
+ </options>
+ </repository>
+ </repositories>
+ <stores>
+ <attribute-stores/>
+ <identity-stores>
+ <identity-store>
+ <id>Hibernate Identity Store</id>
+ <class>org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
+ <external-config/>
+ <supported-relationship-types>
+ <relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
+ <relationship-type>JBOSS_IDENTITY_ROLE</relationship-type>
+ </supported-relationship-types>
+ <supported-identity-object-types>
+ <identity-object-type>
+ <name>USER</name>
+ <relationships>
+ <!--<relationship>-->
+ <!--<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>-->
+ <!--<identity-object-type-ref>ORGANIZATION</identity-object-type-ref>-->
+ <!--</relationship>-->
+ <!--<relationship>-->
+ <!--<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>-->
+ <!--<identity-object-type-ref>COMMUNITY</identity-object-type-ref>-->
+ <!--</relationship>-->
+ <!--<relationship>-->
+ <!--<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>-->
+ <!--<identity-object-type-ref>OFFICE</identity-object-type-ref>-->
+ <!--</relationship>-->
+ <!--<relationship>-->
+ <!--<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>-->
+ <!--<identity-object-type-ref>SECURITY</identity-object-type-ref>-->
+ <!--</relationship>-->
+ <!--<relationship>-->
+ <!--<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>-->
+ <!--<identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>-->
+ <!--</relationship>-->
+ <!--<relationship>-->
+ <!--<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>-->
+ <!--<identity-object-type-ref>PROJECT</identity-object-type-ref>-->
+ <!--</relationship>-->
+ <!--<relationship>-->
+ <!--<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>-->
+ <!--<identity-object-type-ref>PEOPLE</identity-object-type-ref>-->
+ <!--</relationship>-->
+ </relationships>
+ <credentials>
+ <credential-type>PASSWORD</credential-type>
+ </credentials>
+ <attributes>
+ <attribute>
+ <name>picture</name>
+ <mapping>user.picture</mapping>
+ <type>binary</type>
+ <isRequired>false</isRequired>
+ <isMultivalued>false</isMultivalued>
+ <isReadOnly>false</isReadOnly>
+ </attribute>
+ </attributes>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>ORGANIZATION</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>DIVISION</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>ORGANIZATION_UNIT</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>DIVISION</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>DEPARTMENT</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>OFFICE</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>PEOPLE</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>PROJECT</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>DIVISION</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>DEPARTMENT</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>DEPARTMENT</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>DEPARTMENT</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>PROJECT</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>PEOPLE</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>ADMINISTRATION</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>COMMUNITY</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>OFFICE</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>SECURITY</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>SYSTEM</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>SECURITY</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>COMMUNITY</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ </supported-identity-object-types>
+ <options>
+ <!--<option>-->
+ <!--<name>hibernateConfiguration</name>-->
+ <!--<value>hibernate-jboss-identity.cfg.xml</value>-->
+ <!--</option>-->
+ <option>
+ <name>hibernateSessionFactoryJNDIName</name>
+ <value>java:/jbossidentity/HibernateStoreSessionFactory</value>
+ </option>
+ <option>
+ <name>populateRelationshipTypes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>populateIdentityObjectTypes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>allowNotDefinedAttributes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>isRealmAware</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>allowNotDefinedAttributes</name>
+ <value>true</value>
+ </option>
+ </options>
+ </identity-store>
+ <identity-store>
+ <id>LDAP Identity Store</id>
+ <class>org.jboss.identity.idm.impl.store.ldap.LDAPIdentityStoreImpl</class>
+ <external-config/>
+ <supported-relationship-types>
+ <relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
+ </supported-relationship-types>
+ <supported-identity-object-types>
+ <identity-object-type>
+ <name>USER</name>
+ <relationships/>
+ <credentials>
+ <credential-type>PASSWORD</credential-type>
+ </credentials>
+ <attributes>
+ <attribute>
+ <name>phone</name>
+ <mapping>telephoneNumber</mapping>
+ <type>text</type>
+ <isRequired>false</isRequired>
+ <isMultivalued>false</isMultivalued>
+ <isReadOnly>false</isReadOnly>
+ </attribute>
+ <attribute>
+ <name>description</name>
+ <mapping>description</mapping>
+ <type>text</type>
+ <isRequired>false</isRequired>
+ <isMultivalued>false</isMultivalued>
+ <isReadOnly>false</isReadOnly>
+ </attribute>
+ <attribute>
+ <name>carLicense</name>
+ <mapping>carLicense</mapping>
+ <type>text</type>
+ <isRequired>false</isRequired>
+ <isMultivalued>false</isMultivalued>
+ <isReadOnly>false</isReadOnly>
+ </attribute>
+ </attributes>
+ <options>
+ <option>
+ <name>idAttributeName</name>
+ <value>uid</value>
+ </option>
+ <option>
+ <name>passwordAttributeName</name>
+ <value>userPassword</value>
+ </option>
+ <option>
+ <name>ctxDNs</name>
+ <value>ou=People,o=test,dc=portal,dc=example,dc=com</value>
+ </option>
+ <option>
+ <name>allowCreateEntry</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>createEntryAttributeValues</name>
+ <value>objectClass=top</value>
+ <value>objectClass=inetOrgPerson</value>
+ <value>sn= </value>
+ <value>cn= </value>
+ </option>
+ </options>
+ </identity-object-type>
+ <identity-object-type>
+ <name>ORGANIZATION</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>DEPARTMENT</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>OFFICE</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options>
+ <option>
+ <name>idAttributeName</name>
+ <value>cn</value>
+ </option>
+ <option>
+ <name>ctxDNs</name>
+ <value>ou=Organizations,o=test,dc=portal,dc=example,dc=com</value>
+ </option>
+ <!--<option>-->
+ <!--<name>entrySearchFilter</name>-->
+ <!--<value></value>-->
+ <!--</option>-->
+ <option>
+ <name>allowCreateEntry</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>membershipAttributeName</name>
+ <value>member</value>
+ </option>
+ <option>
+ <name>isMembershipAttributeDN</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>allowEmptyMemberships</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>createEntryAttributeValues</name>
+ <value>objectClass=top</value>
+ <value>objectClass=groupOfNames</value>
+ </option>
+ </options>
+ </identity-object-type>
+ <identity-object-type>
+ <name>ORGANIZATION_UNIT</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>DEPARTMENT</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>OFFICE</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options>
+ <option>
+ <name>idAttributeName</name>
+ <value>cn</value>
+ </option>
+ <option>
+ <name>ctxDNs</name>
+ <value>ou=OrganizationUnits,o=test,dc=portal,dc=example,dc=com</value>
+ </option>
+ <!--<option>-->
+ <!--<name>entrySearchFilter</name>-->
+ <!--<value></value>-->
+ <!--</option>-->
+ <option>
+ <name>allowCreateEntry</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>membershipAttributeName</name>
+ <value>member</value>
+ </option>
+ <option>
+ <name>isMembershipAttributeDN</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>allowEmptyMemberships</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>createEntryAttributeValues</name>
+ <value>objectClass=top</value>
+ <value>objectClass=groupOfNames</value>
+ </option>
+ </options>
+ </identity-object-type>
+ <identity-object-type>
+ <name>DEPARTMENT</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>DEPARTMENT</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options>
+ <option>
+ <name>idAttributeName</name>
+ <value>cn</value>
+ </option>
+ <option>
+ <name>ctxDNs</name>
+ <value>ou=Departments,o=test,dc=portal,dc=example,dc=com</value>
+ </option>
+ <!--<option>-->
+ <!--<name>entrySearchFilter</name>-->
+ <!--<value></value>-->
+ <!--</option>-->
+ <option>
+ <name>allowCreateEntry</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>membershipAttributeName</name>
+ <value>member</value>
+ </option>
+ <option>
+ <name>isMembershipAttributeDN</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>allowEmptyMemberships</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>createEntryAttributeValues</name>
+ <value>objectClass=top</value>
+ <value>objectClass=groupOfNames</value>
+ </option>
+ </options>
+ </identity-object-type>
+ <identity-object-type>
+ <name>OFFICE</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options>
+ <option>
+ <name>idAttributeName</name>
+ <value>cn</value>
+ </option>
+ <option>
+ <name>ctxDNs</name>
+ <value>ou=Offices,o=test,dc=portal,dc=example,dc=com</value>
+ </option>
+ <!--<option>-->
+ <!--<name>entrySearchFilter</name>-->
+ <!--<value></value>-->
+ <!--</option>-->
+ <option>
+ <name>allowCreateEntry</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>membershipAttributeName</name>
+ <value>member</value>
+ </option>
+ <option>
+ <name>isMembershipAttributeDN</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>allowEmptyMemberships</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>createEntryAttributeValues</name>
+ <value>objectClass=top</value>
+ <value>objectClass=groupOfNames</value>
+ </option>
+ </options>
+ </identity-object-type>
+ </supported-identity-object-types>
+ <options>
+ <option>
+ <name>providerURL</name>
+ <value>ldap://localhost:10389</value>
+ </option>
+ <option>
+ <name>adminDN</name>
+ <value>cn=Directory Manager</value>
+ </option>
+ <option>
+ <name>adminPassword</name>
+ <value>password</value>
+ </option>
+ <option>
+ <name>searchTimeLimit</name>
+ <value>10000</value>
+ </option>
+ </options>
+ </identity-store>
+ </identity-stores>
+ </stores>
+</jboss-identity>
\ No newline at end of file
Modified: idm/trunk/idm/src/test/resources/store-test-config.xml
===================================================================
--- idm/trunk/idm/src/test/resources/store-test-config.xml 2009-03-30 17:33:49 UTC (rev 410)
+++ idm/trunk/idm/src/test/resources/store-test-config.xml 2009-04-02 13:44:45 UTC (rev 411)
@@ -94,9 +94,13 @@
</identity-object-type>
</supported-identity-object-types>
<options>
+ <!--<option>-->
+ <!--<name>hibernateConfiguration</name>-->
+ <!--<value>hibernate-jboss-identity.cfg.xml</value>-->
+ <!--</option>-->
<option>
- <name>hibernateConfiguration</name>
- <value>hibernate-jboss-identity.cfg.xml</value>
+ <name>hibernateSessionFactoryJNDIName</name>
+ <value>java:/jbossidentity/HibernateStoreSessionFactory</value>
</option>
<option>
<name>populateRelationshipTypes</name>
15 years, 9 months