[jboss-svn-commits] JBoss Portal SVN: r5314 - in trunk: identity/src/main/org/jboss/portal/identity2/db identity/src/main/org/jboss/portal/test/identity test/src/etc test/src/main/org/jboss/portal/test/framework/embedded
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Oct 3 15:58:34 EDT 2006
Author: bdaw
Date: 2006-10-03 15:58:26 -0400 (Tue, 03 Oct 2006)
New Revision: 5314
Added:
trunk/test/src/etc/directories.xml
trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java
trunk/identity/src/main/org/jboss/portal/test/identity/LDAPUserTestCase.java
Log:
add parametrization for LDAPUserTestCase
Modified: trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java 2006-10-03 19:10:59 UTC (rev 5313)
+++ trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java 2006-10-03 19:58:26 UTC (rev 5314)
@@ -1,6 +1,6 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.
*
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/LDAPUserTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/LDAPUserTestCase.java 2006-10-03 19:10:59 UTC (rev 5313)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/LDAPUserTestCase.java 2006-10-03 19:58:26 UTC (rev 5314)
@@ -29,6 +29,10 @@
import java.util.Hashtable;
import org.jboss.portal.test.framework.TestRuntimeContext;
+import org.jboss.portal.test.framework.embedded.DSConfig;
+import org.jboss.portal.common.junit.metadata.TestCaseMetaData;
+import org.jboss.portal.common.junit.metadata.TestCaseParameterMetaData;
+import org.jboss.portal.common.junit.TestCaseFactory;
import org.apache.log4j.Appender;
import org.apache.log4j.ConsoleAppender;
@@ -54,21 +58,20 @@
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPUserTestCase.class);
- /*public static TestSuite suite() throws Exception
+ public static TestSuite suite() throws Exception
{
- //URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
- //TestCaseMetaData testCaseMD = new TestCaseMetaData();
- //testCaseMD.bindParameter(new TestCaseParameterMetaData("DataSourceConfig"), DataSourceSupport.Config.fromXML2(configsURL));
- //TestSuite suite = TestCaseFactory.create(testCaseMD, LDAPUserTestCase.class);
- //return suite;
- }*/
+ URL configsURL = Thread.currentThread().getContextClassLoader().getResource("directories.xml");
+ TestCaseMetaData testCaseMD = new TestCaseMetaData();
+ testCaseMD.bindParameter(new TestCaseParameterMetaData("DirectoryServerConfig"), DSConfig.fromXML2(configsURL));
+ TestSuite suite = TestCaseFactory.create(testCaseMD, LDAPUserTestCase.class);
+ return suite;
+ }
static
{
Appender appender = new ConsoleAppender(new SimpleLayout());
Logger.getRoot().addAppender(appender);
Logger.getRoot().setLevel(Level.INFO);
- //Logger.getLogger("org.hibernate").setLevel(Level.ERROR);
}
public LDAPUserTestCase()
@@ -78,27 +81,20 @@
public LDAPUserTestCase(Map parametrization)
{
- //dsCfg = (DataSourceSupport.Config)parametrization.get("DataSourceConfig");
+ dsConfig = (DSConfig)parametrization.get("DirectoryServerConfig");
}
- //temporary
- private String contextFactory = System.getProperty("jboss.security.ldap.ctxfactory",
- "com.sun.jndi.ldap.LdapCtxFactory");
- private String serverHost = "localhost";
- private String port = "10389";
- //private String adminDN = "cn=Directory Manager";
- private String adminDN = "uid=admin,ou=system";
- //private String adminPW = "password";
- private String adminPW = "secret";
- private String dn = "dc=jboss,dc=org";
+ public LDAPUserTestCase(DSConfig dsConfig)
+ {
+ this.dsConfig = dsConfig;
+ }
- /**
- * .
- */
private TestRuntimeContext runtimeContext;
+ private DSConfig dsConfig;
+
/** . */
- //private UserTest utc;
+ private UserTest utc;
/** . */
//private DBUserModuleImpl userModule;
@@ -107,9 +103,11 @@
* .
*/
//private DBRoleModuleImpl roleModule;
+
+
public String getName()
{
- return super.getName(); // + "," + dsCfg.getDisplayName();
+ return super.getName() + "," + dsConfig.getName() + "," + dsConfig.getDescription();
}
protected void setUp() throws Exception
@@ -118,8 +116,9 @@
runtimeContext.addBean("LDAPTestBean", this);
runtimeContext.start();
- /*//
+ //
utc = new UserTest();
+ /*
userModule = new DBUserModuleImpl();
userModule.setSessionFactoryJNDIName("java:/SessionFactory");
userModule.start();
@@ -389,13 +388,12 @@
private DirContext getDirContext() throws Exception
{
- String url = "ldap://" + serverHost + ":" + port;
Hashtable env = new Hashtable();
- env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
- env.put(Context.PROVIDER_URL, url);
+ env.put(Context.INITIAL_CONTEXT_FACTORY, dsConfig.getContextFactory());
+ env.put(Context.PROVIDER_URL, dsConfig.getProviderUrl());
env.put(Context.SECURITY_AUTHENTICATION, "simple");
- env.put(Context.SECURITY_PRINCIPAL, this.adminDN);
- env.put(Context.SECURITY_CREDENTIALS, this.adminPW);
+ env.put(Context.SECURITY_PRINCIPAL, dsConfig.getAdminDN());
+ env.put(Context.SECURITY_CREDENTIALS, dsConfig.getAdminPassword());
return new InitialDirContext(env);
}
Added: trunk/test/src/etc/directories.xml
===================================================================
--- trunk/test/src/etc/directories.xml 2006-10-03 19:10:59 UTC (rev 5313)
+++ trunk/test/src/etc/directories.xml 2006-10-03 19:58:26 UTC (rev 5314)
@@ -0,0 +1,10 @@
+<directories>
+ <directory>
+ <name>ApacheDS</name>
+ <description>Embedded ApacheDS service</description>
+ <provider-url>ldap://localhost:10389</provider-url>
+ <context-factory>com.sun.jndi.ldap.LdapCtxFactory</context-factory>
+ <admin-dn>uid=admin,ou=system</admin-dn>
+ <admin-password>secret</admin-password>
+ </directory>
+</directories>
Added: trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java
===================================================================
--- trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java 2006-10-03 19:10:59 UTC (rev 5313)
+++ trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java 2006-10-03 19:58:26 UTC (rev 5314)
@@ -0,0 +1,173 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.test.framework.embedded;
+
+import org.jboss.portal.common.junit.metadata.TestCaseParameterIterableValue;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.util.XML;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class DSConfig
+{
+
+
+ private String name;
+
+ private String description;
+
+ private String providerUrl;
+
+ private String contextFactory;
+
+ private String adminDN;
+
+ private String adminPassword;
+
+ public DSConfig(String name, String description, String url, String contextFactory, String adminDN, String adminPass)
+ {
+ this.name = name;
+ this.description = description;
+ this.providerUrl = url;
+ this.contextFactory = contextFactory;
+ this.adminDN = adminDN;
+ this.adminPassword = adminPass;
+ }
+
+ public static TestCaseParameterIterableValue fromXML2(URL url) throws Exception
+ {
+ DSConfig[] configs = fromXML(url);
+ List list = Arrays.asList(configs);
+ return new TestCaseParameterIterableValue(list);
+ }
+
+ public static DSConfig[] fromXML(URL url) throws Exception
+ {
+ ArrayList configs = new ArrayList();
+ InputStream in = null;
+ try
+ {
+ in = Tools.safeBufferedWrapper(url.openStream());
+ Document doc = XML.getDocumentBuilderFactory().newDocumentBuilder().parse(in);
+ for (Iterator i = XML.getChildrenIterator(doc.getDocumentElement(), "directory"); i.hasNext();)
+ {
+ Element childElt = (Element)i.next();
+ Element nm = XML.getUniqueChild(childElt, "name", true);
+ Element desc = XML.getUniqueChild(childElt, "description", true);
+ Element purl = XML.getUniqueChild(childElt, "provider-url", true);
+ Element context = XML.getUniqueChild(childElt, "context-factory", true);
+ Element admin = XML.getUniqueChild(childElt, "admin-dn", true);
+ Element password = XML.getUniqueChild(childElt, "admin-password", true);
+ String name = XML.asString(nm);
+ String description = XML.asString(desc);
+ String providerURL = XML.asString(purl);
+ String contextFactory = XML.asString(context);
+ String adminDN = XML.asString(admin);
+ String adminPassword = XML.asString(password);
+ DSConfig dsCfg = new DSConfig(
+ name,
+ description,
+ providerURL,
+ contextFactory,
+ adminDN,
+ adminPassword);
+ configs.add(dsCfg);
+ }
+ return (DSConfig[])configs.toArray(new DSConfig[configs.size()]);
+ }
+ finally
+ {
+ Tools.safeClose(in);
+ }
+ }
+
+ public String getProviderUrl()
+ {
+ return providerUrl;
+ }
+
+ public void setProviderUrl(String providerUrl)
+ {
+ this.providerUrl = providerUrl;
+ }
+
+ public String getContextFactory()
+ {
+ return contextFactory;
+ }
+
+ public void setContextFactory(String contextFactory)
+ {
+ this.contextFactory = contextFactory;
+ }
+
+ public String getAdminDN()
+ {
+ return adminDN;
+ }
+
+ public void setAdminDN(String adminDN)
+ {
+ this.adminDN = adminDN;
+ }
+
+ public String getAdminPassword()
+ {
+ return adminPassword;
+ }
+
+ public void setAdminPassword(String adminPassword)
+ {
+ this.adminPassword = adminPassword;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+}
More information about the jboss-svn-commits
mailing list