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);
}