directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oer...@apache.org
Subject svn commit: r550803 [5/10] - in /directory/sandbox/oersoy/das.ldap.parent: ./ das.ldap.constants/ das.ldap.constants/.settings/ das.ldap.constants/src/ das.ldap.constants/src/main/ das.ldap.constants/src/main/java/ das.ldap.constants/src/main/java/org/...
Date Tue, 26 Jun 2007 13:29:26 GMT
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/provide/SyntaxOIDProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/provide/SyntaxOIDProvider.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/provide/SyntaxOIDProvider.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/provide/SyntaxOIDProvider.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,62 @@
+package org.apache.tuscany.das.ldap.schema.emf.provide;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.das.ldap.constants.SyntaxOIDValues;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EcorePackage;
+
+public class SyntaxOIDProvider 
+implements SyntaxOIDValues {
+
+	private static Map<EClassifier, String> dataTypeToADSSyntaxOIDMap = null;
+
+	private EcorePackage ecorePackage   = EcorePackage.eINSTANCE;
+	
+	//TODO Make this a singleton
+	public SyntaxOIDProvider()
+	{
+		dataTypeToADSSyntaxOIDMap            = 
+			new HashMap<EClassifier, String>();
+		
+		this.create();
+		ecorePackage                                       = 
+			EcorePackage.eINSTANCE;
+	}
+	
+	public String getSyntaxOID(EClassifier eClassifier)
+	{
+		String syntaxOID = dataTypeToADSSyntaxOIDMap.get(eClassifier);
+		if (syntaxOID == null)
+		{
+			return SYNTAX_STRING_OID_VALUE;
+		}
+		return syntaxOID;
+	}
+	
+	private Map<EClassifier, String> create()
+	{
+		dataTypeToADSSyntaxOIDMap.put(
+				EcorePackage.eINSTANCE.getEString(), 
+				SYNTAX_STRING_OID_VALUE);
+		
+		dataTypeToADSSyntaxOIDMap.put(
+				EcorePackage.eINSTANCE.getEInt(), 
+				SYNTAX_INTEGER_OID_VALUE);
+
+		dataTypeToADSSyntaxOIDMap.put(
+				EcorePackage.eINSTANCE.getEIntegerObject(), 
+				SYNTAX_INTEGER_OID_VALUE);
+
+		dataTypeToADSSyntaxOIDMap.put(
+				EcorePackage.eINSTANCE.getEBoolean(), 
+				SYNTAX_BOOLEAN_OID_VALUE);
+
+		dataTypeToADSSyntaxOIDMap.put(
+				EcorePackage.eINSTANCE.getEBooleanObject(), 
+				SYNTAX_BOOLEAN_OID_VALUE);
+
+		return dataTypeToADSSyntaxOIDMap;
+	}
+}
\ No newline at end of file

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,39 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.  
+ */
+package org.apache.tuscany.das.ldap.util;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class DataTypeNamespaceQualifier.
+ */
+public class ComplexTypeNamespaceQualifier
+{
+    /**
+     * Qualify.
+     * 
+     * @param namespaceURI the namespace URI
+     * @param complexTypeName the name
+     * 
+     * @return the string
+     */
+    public static String qualify(String namespaceURI, String complexTypeName )
+    {
+        return namespaceURI + "/" + complexTypeName;
+    }
+}

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,10 @@
+package org.apache.tuscany.das.ldap.util;
+
+public class IDGenerator {
+
+	static long currentID= System.currentTimeMillis();
+	
+	static public synchronized long generate(){
+	    return currentID++;
+	}
+}

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,168 @@
+
+package org.apache.tuscany.das.ldap.util;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+/**
+ * The Class JNDIUtil.
+ */
+public class JNDIUtil
+{
+    /**
+     * Calculate DN components.
+     * 
+     * @param context the context
+     * 
+     * @return the string[] containing the components of the DN
+     * 
+     * @throws NamingException the naming exception
+     */
+    public static String[] calculateDNComponents(
+        DirContext context) 
+    throws NamingException
+    {
+        String contextDN                  = 
+            context.getNameInNamespace();
+        
+        String[] initialContextComponents = 
+            contextDN.split( "[,]" );
+
+        return initialContextComponents;
+    }
+
+    
+    /**
+     * Calculate DN components.
+     * 
+     * @param contextDN the context DN
+     * 
+     * @return the string[] containing the components of the DN
+     * 
+     * @throws NamingException the naming exception
+     */
+    public static String[] calculateDNComponents(
+        String contextDN) 
+    throws NamingException
+    {
+        String[] initialContextComponents = 
+            contextDN.split( "[,]" );
+
+        return initialContextComponents;
+    }
+    
+    /**
+     * Gets the parent context.
+     * 
+     * @param partitionContext the partition context
+     * @param childContext the child context
+     * 
+     * @return the parent context (Null if the child context is the root)
+     * 
+     * @throws NamingException the naming exception
+     */
+    public static DirContext getParentContext(
+        DirContext childContext, 
+        DirContext partitionContext) 
+    throws NamingException
+    {
+        String[] childContextDNComponents = 
+            calculateDNComponents( childContext );
+        
+        String[] partitionDNComponents    = 
+            calculateDNComponents( partitionContext );
+        
+        DirContext parentContext          = null; 
+        
+        if (childContextDNComponents.length == partitionDNComponents.length)
+        {
+            return null;
+        }
+        else if ( (childContextDNComponents.length - 1) == partitionDNComponents.length)
+        {
+            return partitionContext;
+        }
+        else
+        {
+            String parentLookupDN = 
+                calculateParentRelativeDN( 
+                    childContext, partitionContext.getNameInNamespace() );
+            
+            
+            
+            parentContext = 
+                ( DirContext ) partitionContext.lookup( parentLookupDN );
+        }
+        return parentContext;
+    }
+
+    
+    /**
+     * Calculate parent relative DN.
+     * The parent relative DN is the
+     * DN of the parent context, relative
+     * to the partition context.
+     * 
+     * So if the partition context is
+     * <i>ou=system</i> and
+     * the child context has DN
+     * <i>cn=accounts, cn=users, cn=example, ou=system</i>
+     * 
+     * then the parent relative DN is
+     * <i>cn=users, cn=example</i>
+     * 
+     * @param childContext the child context
+     * @param partitionDN the partition DN
+     * 
+     * @return the string
+     * 
+     * @throws NamingException the naming exception
+     */
+    public static String calculateParentRelativeDN(
+        DirContext childContext, 
+        String partitionDN) 
+    throws NamingException
+    {
+        String parentRelativeDN           = null;
+        
+        String[] childContextDNComponents = 
+            calculateDNComponents( childContext );
+        
+        String[] partitionDNComponents    = 
+            calculateDNComponents( partitionDN );
+        
+        if (childContextDNComponents.length == 
+            partitionDNComponents.length)
+        {
+            return null;
+        }
+        else if (childContextDNComponents.length ==
+             partitionDNComponents.length + 1)
+        {
+            String childRDN            = childContextDNComponents[0];
+            String childContextDN      = childContext.getNameInNamespace();
+            
+            int beginIndex = childRDN.length() + 1;
+            int endIndex   = childContextDN.length();
+
+            parentRelativeDN = childContextDN.substring( 
+                beginIndex, endIndex );
+            
+            return parentRelativeDN;
+        }
+        else
+        {
+            String childRDN            = childContextDNComponents[0];
+            String childContextDN      = childContext.getNameInNamespace();
+            
+            int beginIndex = childRDN.length() + 1;
+            int endIndex   = 
+                childContextDN.length() - 
+                ( partitionDN.length() +1);
+            
+            parentRelativeDN = childContextDN.substring( 
+                beginIndex, endIndex );
+        }
+        return parentRelativeDN;
+    }
+}

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,38 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.  
+ *  
+ */
+package org.apache.tuscany.das.ldap.util;
+
+public class LDAPNormalizer
+{
+    
+    /**
+     * Normalize a qualified string for LDAP
+     * by replacing periods with dashes.
+     * 
+     * @param qualifiedName the qualified name
+     */
+    public static void normalize(String qualifiedName)
+    {
+        qualifiedName = qualifiedName.replace( ".", "-" );
+    }
+    
+    
+
+}

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.  
+ *  
+ */
+package org.apache.tuscany.das.ldap.util;
+
+public class QualifiedNameNormalizer
+{
+    /**
+     * Normalize a qualified string for LDAP
+     * by replacing periods with dashes.
+     * 
+     * @param qualifiedName the qualified name
+     */
+	public static String normalize(String qualifiedName)
+	{
+		qualifiedName = qualifiedName.replace("http://", "");
+		qualifiedName = qualifiedName.replace("/", "-");
+		return qualifiedName.replace(".", "-");
+	}
+}

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,39 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.  
+ */
+package org.apache.tuscany.das.ldap.util;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class DataTypeNamespaceQualifier.
+ */
+public class SimpleTypeNamespaceQualifier
+{
+    /**
+     * Qualify.
+     * 
+     * @param namespaceURI the namespace URI
+     * @param complexTypeName the name
+     * 
+     * @return the string
+     */
+    public static String qualify(String namespaceURI, String complexTypeName, String simpleTypeName )
+    {
+        return namespaceURI + "/" + complexTypeName  + "/" + simpleTypeName;
+    }
+}

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,49 @@
+
+package org.apache.tuscany.das.ldap.util;
+
+import org.eclipse.emf.common.util.URI;
+
+/**
+ * The Class XSDNamespaceToInitialContextTransformer.
+ * 
+ * Takes the XSD Namespace used by the DataObjects
+ * and transforms it into the DN of the initial context
+ * used for the root DataObject entry.
+ */
+public class XSDNamespaceToInitialContextTransformer
+{
+    /**
+     * Transform.
+     * 
+     * @param namespaceURIString the namespace URI string
+     * 
+     * @return the DN of the initial context
+     * 
+     * @throws Exception the exception
+     */
+    public static String transform(String namespaceURIString) throws Exception
+    {
+        URI namespaceURI = URI.createURI(namespaceURIString);
+        String authority = namespaceURI.authority();
+
+        String path      = namespaceURI.path();
+
+        String[] authorityTokens = authority.split( "[.]" );
+        String[] pathTokens      = path.split("[/]");
+        
+        String DN = new String("");
+        
+        for (int i = (pathTokens.length-1); i > 0; i--)
+        {
+            DN = DN + "cn=" + pathTokens[i] + ", ";
+        }
+
+        for (int i = 0; i <= (authorityTokens.length-2); i++)
+        {
+            DN = DN + "cn=" + authorityTokens[i] + ", ";
+        }
+        
+        DN = DN + "ou=" + authorityTokens[authorityTokens.length-1];
+        return DN;
+    }
+}

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,26 @@
+
+package org.apache.tuscany.das.ldap.util;
+
+import org.eclipse.emf.common.util.URI;
+
+public class XSDNamespaceURITokenizer
+{
+    
+    public static String[] createAuthorityTokens( URI xsdNamespaceURI )
+    {
+        String authority = xsdNamespaceURI.authority();
+        String[] authorityTokens = authority.split( "[.]" );
+        return authorityTokens;
+    }
+    
+    public static String[] createPathTokens(URI xsdNamespace)
+    {
+        String path              = xsdNamespace.path(); 
+        if (path != null)
+        {
+            return path.split("[/]"); 
+        }
+        else
+            return null;
+    }
+}

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,129 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
+import org.apache.directory.server.core.configuration.ShutdownConfiguration;
+import org.apache.log4j.PropertyConfigurator;
+
+/**
+ * The Class JNDIEmbeddedConnectionTemplate.
+ */
+public abstract class ADSEmbeddedConnectionTemplate
+extends JNDIConnectionTemplate
+{
+    public void tearDown() throws NamingException, Exception
+    {
+        Hashtable<String,Object> env = 
+        	new Hashtable<String,Object>();
+        
+        env = createEnvironment(env);
+        
+        env.put( 
+        		Context.PROVIDER_URL, 
+        		SYSTEM_PROVIDER_PATH);
+        env.put( 
+        		Context.INITIAL_CONTEXT_FACTORY, 
+        		"org.apache.directory.server.core.jndi.CoreContextFactory" );
+        env.putAll( 
+        		new ShutdownConfiguration().toJndiEnvironment() );
+        
+        new InitialContext( env );
+        Runtime.getRuntime().gc();
+        super.tearDown();
+    }
+    
+    
+    
+    public void setUp() throws Exception
+    {
+    	PropertyConfigurator.
+    	configure(NLOG4J_CONFIGURATION_FILEPATH);
+        super.setUp();
+    }
+    
+	/**
+	 * Connect to an embedded ApacheDS server.
+	 * 
+	 * @param providerPath the provider path ("ou=schema", ou="system", etc.)
+	 * 
+	 * @return the ldap context
+	 * 
+	 * @throws NamingException the naming exception
+	 */
+	public LdapContext connect( String providerPath ) throws NamingException
+	{
+		 MutableStartupConfiguration mutableStartupConfiguration = 
+	    		new MutableStartupConfiguration();
+		 
+	    Hashtable<String,Object> adminEnv  =
+	    	new Hashtable<String,Object>( );
+	    
+	    adminEnv.putAll( 
+	    			mutableStartupConfiguration.
+	    			toJndiEnvironment());
+	    
+	    adminEnv.put( 
+	    		Context.PROVIDER_URL, 
+	    		SYSTEM_PROVIDER_PATH);
+	    adminEnv.put( 
+	    		Context.SECURITY_PRINCIPAL, 
+	    		DEFAULT_SECURITY_PRINCIPAL_VALUE);
+	    adminEnv.put( 
+	    		Context.SECURITY_CREDENTIALS, 
+	    		DEFAULT_SECURITY_CREDENTIALS_VALUE);
+	    adminEnv.put( 
+	    		Context.SECURITY_AUTHENTICATION, 
+	    		SIMPLE_SECURITY_AUTHENTICATION_VALUE );
+   		new InitialLdapContext( adminEnv, null );
+
+   		
+   		
+	    Hashtable<String,Object> env            = 
+	    	new Hashtable<String,Object>();
+	    
+	    env.put( 
+	    		Context.INITIAL_CONTEXT_FACTORY, 
+	    		"org.apache.directory.server.core.jndi.CoreContextFactory" );
+	    env.put( 	    		
+	    		Context.SECURITY_PRINCIPAL, 
+	    		DEFAULT_SECURITY_PRINCIPAL_VALUE);
+	    env.put( 
+	    		Context.SECURITY_CREDENTIALS, 
+	    		DEFAULT_SECURITY_CREDENTIALS_VALUE);
+	    env.put( 
+	    		Context.SECURITY_AUTHENTICATION, 
+	    		SIMPLE_SECURITY_AUTHENTICATION_VALUE );
+	    env.put( Context.PROVIDER_URL, providerPath );
+	    
+	    env.put( Context.PROVIDER_URL, providerPath );
+		
+	    return new InitialLdapContext( env, null );
+		
+	}
+}
\ No newline at end of file

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplateTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplateTest.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplateTest.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplateTest.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,59 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+public class ADSEmbeddedConnectionTemplateTest 
+extends ADSEmbeddedConnectionTemplate  
+{
+    public void tearDown() throws NamingException, Exception
+    {
+        super.tearDown();
+    }
+    
+    public void setUp() throws Exception
+    {
+        super.setUp();
+    }
+    
+    public void testSchemaConnect() throws NamingException
+    {
+    	LdapContext ldapContext =null;
+    	
+	    ldapContext =connect("ou=schema");
+	    
+	    assertEquals(
+	    		"ou=schema", 
+	    		ldapContext.getNameInNamespace()); 
+    }
+    
+    public void testRootDSEConnect() throws NamingException
+    {
+    	LdapContext ldapContext =null;
+    	
+	    ldapContext =connect("");
+	    
+	    assertEquals(
+	    		"", 
+	    		ldapContext.getNameInNamespace()); 
+    }
+}
\ No newline at end of file

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplate.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplate.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplate.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplate.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,157 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.core.configuration.Configuration;
+import org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
+import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
+import org.apache.directory.server.core.configuration.ShutdownConfiguration;
+import org.apache.log4j.PropertyConfigurator;
+
+/**
+ * The Class JNDIEmbeddedConnectionTemplate.
+ */
+public abstract class ADSEmbeddedHotPartitionTemplate
+extends JNDIConnectionTemplate
+{
+    public void tearDown() throws NamingException, Exception
+    {
+        Hashtable<String,Object> env = 
+        	new Hashtable<String,Object>();
+        
+        env = createEnvironment(env);
+        
+        env.put( 
+        		Context.PROVIDER_URL, 
+        		SYSTEM_PROVIDER_PATH);
+        env.put( 
+        		Context.INITIAL_CONTEXT_FACTORY, 
+        		"org.apache.directory.server.core.jndi.CoreContextFactory" );
+        env.putAll( 
+        		new ShutdownConfiguration().toJndiEnvironment() );
+        
+        new InitialContext( env );
+        Runtime.getRuntime().gc();
+        super.tearDown();
+    }
+    
+    
+    
+    public void setUp() throws Exception
+    {
+    	PropertyConfigurator.
+    	configure(NLOG4J_CONFIGURATION_FILEPATH);
+        super.setUp();
+    }
+    
+	/**
+	 * Connect to an embedded ApacheDS server.
+	 * 
+	 * @param partitionName the provider path ("ou=schema", ou="system", etc.)
+	 * 
+	 * @return the ldap context
+	 * 
+	 * @throws NamingException the naming exception
+	 */
+	public LdapContext connect( String partitionName ) throws NamingException
+	{
+		 MutableStartupConfiguration mutableStartupConfiguration = 
+	    		new MutableStartupConfiguration();
+		 
+	    Hashtable<String,Object> adminEnv                                       =
+	    	new Hashtable<String,Object>( );
+	    
+	    adminEnv.putAll( 
+	    			mutableStartupConfiguration.
+	    			toJndiEnvironment());
+	    
+	    adminEnv.put( 
+	    		Context.PROVIDER_URL, 
+	    		SYSTEM_PROVIDER_PATH);
+	    adminEnv.put( 
+	    		Context.SECURITY_PRINCIPAL, 
+	    		DEFAULT_SECURITY_PRINCIPAL_VALUE);
+	    adminEnv.put( 
+	    		Context.SECURITY_CREDENTIALS, 
+	    		DEFAULT_SECURITY_CREDENTIALS_VALUE);
+	    adminEnv.put( 
+	    		Context.SECURITY_AUTHENTICATION, 
+	    		SIMPLE_SECURITY_AUTHENTICATION_VALUE );
+   		new InitialLdapContext( adminEnv, null );
+
+
+        MutablePartitionConfiguration dasPartition                      = 
+            new MutablePartitionConfiguration();
+        
+        Attributes suffixAttributes = new BasicAttributes();
+        suffixAttributes.put( "objectClass", "top");
+        suffixAttributes.get( "objectClass" ).add( "organizationalUnit" );
+        suffixAttributes.put( "ou", partitionName );
+
+        dasPartition.setName( partitionName);
+        dasPartition.setSuffix( "ou=" +partitionName );
+        dasPartition.setContextEntry( suffixAttributes );
+        
+        Set<MutablePartitionConfiguration> partitions =
+        	new HashSet<MutablePartitionConfiguration> ();
+        
+        partitions.add( dasPartition );
+        
+        mutableStartupConfiguration.
+        setPartitionConfigurations( partitions );
+   		
+	    Hashtable<String,Object> env            = 
+	    	new Hashtable<String,Object>();
+	    
+	    env.put( 
+	    		Context.INITIAL_CONTEXT_FACTORY, 
+	    		"org.apache.directory.server.core.jndi.CoreContextFactory" );
+	    env.put( 	    		
+	    		Context.SECURITY_PRINCIPAL, 
+	    		DEFAULT_SECURITY_PRINCIPAL_VALUE);
+	    env.put( 
+	    		Context.SECURITY_CREDENTIALS, 
+	    		DEFAULT_SECURITY_CREDENTIALS_VALUE);
+	    env.put( 
+	    		Context.SECURITY_AUTHENTICATION, 
+	    		SIMPLE_SECURITY_AUTHENTICATION_VALUE );
+	    env.put( 
+	    		Context.PROVIDER_URL, 
+	    		"ou=" + partitionName );
+	    
+        env.put( 
+        		Configuration.JNDI_KEY, 
+        		mutableStartupConfiguration );
+		
+	    return new InitialLdapContext( env, null );
+	}
+}
\ No newline at end of file

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplateTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplateTest.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplateTest.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplateTest.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,50 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+public class ADSEmbeddedHotPartitionTemplateTest 
+extends ADSEmbeddedHotPartitionTemplate  
+{
+    public void tearDown() throws NamingException, Exception
+    {
+        super.tearDown();
+    }
+    
+    public void setUp() throws Exception
+    {
+        super.setUp();
+    }
+    
+    public void testCreateHotPartition() throws NamingException
+    {
+    	LdapContext ldapContext =
+    		null;
+    	
+	    ldapContext                       =
+	    	connect("test");
+	    
+	    assertEquals(
+	    		"ou=test", 
+	    		ldapContext.getNameInNamespace()); 
+    }
+}
\ No newline at end of file

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplate.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplate.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplate.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplate.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,102 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.connection.constants.ApacheDSConnectionConstants;
+import junit.framework.TestCase;
+
+/*
+ * Just a class template class
+ */
+public abstract class JNDIConnectionTemplate
+extends TestCase
+implements ApacheDSConnectionConstants
+{
+    protected String providerHost                    =
+        "ldap://localhost:10389/";
+
+    protected String providerPath                    =
+    	SYSTEM_PROVIDER_PATH;
+
+    private String  providerURL                          =
+        providerHost + providerPath;
+
+    protected String initialContextFactory     = 
+        SUN_CONTEXT_FACTORY;
+    
+    protected String  securityAuthentication = 
+        SIMPLE_SECURITY_AUTHENTICATION_VALUE;
+    
+    protected String  securityPrincipal            = 
+        DEFAULT_SECURITY_PRINCIPAL_VALUE;
+    
+    protected String credentials                      =
+        DEFAULT_SECURITY_CREDENTIALS_VALUE;
+
+    public Hashtable<String,Object> createEnvironment(
+    		Hashtable<String, Object> env)
+    {
+      providerURL                                                  =
+            providerHost + providerPath;
+
+        env.put( 
+            Context.PROVIDER_URL,
+            providerURL);
+
+        env.put( 
+            Context.INITIAL_CONTEXT_FACTORY, 
+            initialContextFactory );
+
+        env.put( 
+            Context.SECURITY_AUTHENTICATION, 
+            securityAuthentication);
+        
+        env.put( 
+            Context.SECURITY_PRINCIPAL, 
+            securityPrincipal );
+        
+        env.put( 
+            Context.SECURITY_CREDENTIALS, 
+            credentials );
+        
+        return env;
+    }
+
+    public LdapContext connect() throws NamingException
+    {
+    	Hashtable<String, Object> env = 
+    		new Hashtable<String, Object>();
+    	
+        return new InitialLdapContext(
+        		createEnvironment(env), null);
+    }
+    
+    public void setUp() throws Exception
+    {
+    	super.setUp();
+    }
+}
\ No newline at end of file

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplateTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplateTest.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplateTest.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplateTest.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,66 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+/*
+ * These tests require a running server.
+ */
+public class JNDIConnectionTemplateTest extends JNDIConnectionTemplate  
+{
+	private static LdapContext systemContext  = null;
+	private static LdapContext schemaContext = null;
+	
+    public void tearDown() throws NamingException, Exception
+    {
+        super.tearDown();
+    }
+    
+    public void setUp() throws NamingException, Exception
+    {
+        super.setUp();
+    }
+    
+    public void testSystemContextConnection() 
+    throws NamingException
+    {
+    	systemContext = connect();
+    	assertNotNull( systemContext );
+        assertNotNull( connect() );
+        assertEquals(
+        		systemContext.
+        		getNameInNamespace(),
+        		"ou=system");
+    }
+    
+    public void testSchemaContextConnection() 
+    throws NamingException
+    {
+    	providerPath     = SCHEMA_PROVIDER_PATH;
+    	schemaContext = connect();
+    	assertNotNull (schemaContext);
+        assertNotNull(connect());
+        assertEquals(
+        		schemaContext.getNameInNamespace(), 
+        		"ou=schema");
+    }
+}
\ No newline at end of file

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplate.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplate.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplate.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplate.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,117 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.connection.constants.ApacheDSConnectionConstants;
+import org.apache.directory.server.core.configuration.Configuration;
+import org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
+import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
+import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup;
+
+import junit.framework.TestCase;
+
+/*
+ * Just a class template class
+ */
+public abstract class JNDIHotPartitionConnectionTemplate
+extends AbstractTestSetup
+implements ApacheDSConnectionConstants
+{
+
+    public Hashtable<String,Object> createEnvironment(
+    		Hashtable<String, Object> env,
+    		String partitionName) throws NamingException
+    {
+    	MutableStartupConfiguration mutableStartupConfiguration =
+    		new MutableStartupConfiguration();
+    	
+    	  MutablePartitionConfiguration dasPartition                          =
+    		  new MutablePartitionConfiguration();
+    	  
+    	  Attributes suffixAttributes = new BasicAttributes();
+    	  suffixAttributes.put( "objectClass", "top");
+    	  suffixAttributes.get( "objectClass" ).add( "organizationalUnit" );
+    	  suffixAttributes.put( "ou", partitionName );
+    	  
+    	  dasPartition.setName( partitionName);
+    	  dasPartition.setSuffix( "ou=" +partitionName );
+    	  dasPartition.setContextEntry( suffixAttributes );
+    	  
+    	  Set<MutablePartitionConfiguration> partitions =
+    		  new HashSet<MutablePartitionConfiguration> ();
+    	  
+    	  partitions.add( dasPartition );
+    	  
+    	  mutableStartupConfiguration.
+    	  setPartitionConfigurations( partitions );
+    	  
+    	  env.put(
+    			  Context.INITIAL_CONTEXT_FACTORY,
+    			  "org.apache.directory.server.core.jndi.CoreContextFactory" );
+    	  
+    	  env.put(
+    			  Context.SECURITY_PRINCIPAL,
+    			  DEFAULT_SECURITY_PRINCIPAL_VALUE);
+    	  
+    	  env.put(
+    			  Context.SECURITY_CREDENTIALS,
+    			  DEFAULT_SECURITY_CREDENTIALS_VALUE);
+    	  
+    	  env.put(
+    			  Context.SECURITY_AUTHENTICATION,
+    			  SIMPLE_SECURITY_AUTHENTICATION_VALUE );
+    	  
+    	  env.put(
+    			  Context.PROVIDER_URL,
+    			  "ou=" + partitionName );
+    	  
+    	  env.put(
+    			  Configuration.JNDI_KEY,
+    			  mutableStartupConfiguration );
+        
+        return env;
+    }
+
+    public LdapContext connect( String partitionName ) 
+    throws NamingException
+    {
+    	Hashtable<String, Object> env = 
+    		new Hashtable<String, Object>();
+    	
+        return new InitialLdapContext(
+        		createEnvironment(env, partitionName), null);
+    }
+    
+    public void setUp() throws Exception
+    {
+    	super.setUp();
+    }
+}
\ No newline at end of file

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplateTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplateTest.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplateTest.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplateTest.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,73 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+/*
+ * These tests require a running server.
+ */
+public class JNDIHotPartitionConnectionTemplateTest 
+extends JNDIHotPartitionConnectionTemplate  
+{
+	private static LdapContext testContext        = null;
+	private static LdapContext systemContext  = null;
+	private static LdapContext schemaContext = null;
+	
+    public void tearDown() throws NamingException, Exception
+    {
+        super.tearDown();
+    }
+    
+    public void setUp() throws NamingException, Exception
+    {
+        super.setUp();
+    }
+    
+    public void testTestContextConnection() 
+    throws NamingException
+    {
+    	testContext = connect("test");
+    	assertNotNull(testContext );
+        assertEquals(
+        		testContext.getNameInNamespace(), "ou=test");
+    }
+
+    
+    public void testSystemContextConnection() 
+    throws NamingException
+    {
+    	systemContext = connect("system");
+        assertNotNull( systemContext );
+        assertEquals(
+        		systemContext.getNameInNamespace(), "ou=system");
+    }
+    
+    public void testSchemaContextConnection() 
+    throws NamingException
+    {
+    	schemaContext = connect("schema");
+        assertNotNull(  schemaContext );
+        assertEquals(
+        		schemaContext.getNameInNamespace(), 
+        		"ou=schema");
+    }
+}
\ No newline at end of file

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/connection/constants/ApacheDSConnectionConstants.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/connection/constants/ApacheDSConnectionConstants.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/connection/constants/ApacheDSConnectionConstants.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/connection/constants/ApacheDSConnectionConstants.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,48 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.connection.constants;
+
+public interface ApacheDSConnectionConstants
+{
+    String APACHE_CONTEXT_FACTORY                          =
+        "org.apache.directory.server.core.jndi.CoreContextFactory";
+
+    String SUN_CONTEXT_FACTORY                                =
+        "com.sun.jndi.ldap.LdapCtxFactory";
+    
+    String SIMPLE_SECURITY_AUTHENTICATION_VALUE = 
+        "simple";
+    
+    String DEFAULT_SECURITY_PRINCIPAL_VALUE          = 
+        "uid=admin,ou=system";
+    
+    String DEFAULT_SECURITY_CREDENTIALS_VALUE    = 
+        "secret";
+    
+    String SCHEMA_PROVIDER_PATH                              =
+    	"ou=schema";
+    
+    String SYSTEM_PROVIDER_PATH                               =
+    	"ou=system";
+    
+    String NLOG4J_CONFIGURATION_FILEPATH              =
+    	"src/test/resources/log4j.properties";
+    	
+}

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/InitialContextCreatorHelperTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/InitialContextCreatorHelperTest.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/InitialContextCreatorHelperTest.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/InitialContextCreatorHelperTest.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,189 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.create.test;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.create.InitialContextCreatorHelper;
+
+import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup;
+import org.apache.tuscany.das.ldap.util.XSDNamespaceURITokenizer;
+import org.eclipse.emf.common.util.URI;
+
+/*
+ * Note these tests require a running instance of ApacheDS
+ */
+
+public class InitialContextCreatorHelperTest 
+extends AbstractTestSetup
+{
+    protected String xsdNamespace = "http://example.com/users/accounts";
+    protected URI xsdNamespaceURI = URI.createURI( xsdNamespace );
+    
+    LdapContext comContext     = null;
+    LdapContext exampleContext = null;
+    LdapContext usersContext   = null;
+
+    public void setUp() throws Exception
+    {
+    	super.setUp();
+    }
+
+    public void tearDown() throws Exception
+    {
+    	super.tearDown();
+    }
+
+    public void testCreateSystemSubContext() throws NamingException
+    {
+        String testContextRDN      = "cn=newContext";
+
+        Object testContext         = null;
+        
+        try {
+            testContext = dasPartitionContext.lookup( testContextRDN );            
+        }
+        catch (Exception e)
+        {
+            //good 
+        }
+        
+        assertNull(testContext);
+        
+        InitialContextCreatorHelper.createSubContext(
+            dasPartitionContext,
+            testContextRDN,
+            null);
+        
+        testContext = dasPartitionContext.lookup( testContextRDN );
+        
+        assertNotNull(testContext);
+        dasPartitionContext.destroySubcontext( testContextRDN );
+    }
+
+    public void testCreateExistingSystemSubContext() throws NamingException
+    {
+        String testContextRDN      = "cn=newContext";
+        Object testContext         = null;
+        
+        try {
+            testContext = dasPartitionContext.lookup( testContextRDN );            
+        }
+        catch (Exception e)
+        {
+            //good 
+        }
+        
+        assertNull(testContext);
+        
+        InitialContextCreatorHelper.createSubContext(
+            dasPartitionContext,
+            testContextRDN,
+            null);
+        
+        //Run the same code again.
+        InitialContextCreatorHelper.createSubContext(
+            dasPartitionContext,
+            testContextRDN,
+            null);
+        
+        testContext = dasPartitionContext.lookup( testContextRDN );
+        
+        assertNotNull(testContext);
+        dasPartitionContext.destroySubcontext( testContextRDN );
+    }
+    
+    
+    public void testCreateAuthorityContext() 
+    throws NamingException
+    {        
+        try
+        {
+            comContext = 
+                ( LdapContext ) 
+                dasPartitionContext.lookup("cn=com");
+        }
+        catch ( NamingException e )
+        {
+            //Good - the subcontext does not exist
+        }
+        assertTrue(comContext==null);
+
+        String[] authorityTokens    = 
+            XSDNamespaceURITokenizer.createAuthorityTokens(xsdNamespaceURI);
+        
+        InitialContextCreatorHelper.createAuthorityContext(
+            dasPartitionContext, 
+            authorityTokens );
+        
+        comContext             =
+            ( LdapContext ) dasPartitionContext.lookup("cn=com");
+
+        assertNotNull(comContext);
+        
+        exampleContext             =
+            ( LdapContext ) comContext.lookup("cn=example");
+
+        assertNotNull(exampleContext);
+        
+        comContext.destroySubcontext( "cn=example" );
+        dasPartitionContext.destroySubcontext( "cn=com" );
+    }
+    
+    public void testCreatePathContext() throws NamingException
+    {
+        String[] authorityTokens   =  
+            XSDNamespaceURITokenizer.
+            createAuthorityTokens(xsdNamespaceURI);
+        
+        exampleContext             =
+            InitialContextCreatorHelper.
+            createAuthorityContext(
+                dasPartitionContext, 
+                authorityTokens );
+
+        String[] pathTokens        =  
+            XSDNamespaceURITokenizer.
+            createPathTokens(xsdNamespaceURI);
+
+        InitialContextCreatorHelper.
+        createPathContext(
+            exampleContext, 
+            pathTokens );
+        
+        comContext                 =
+            ( LdapContext ) 
+            dasPartitionContext.
+            lookup("cn=com");
+        
+        exampleContext             =
+            ( LdapContext ) 
+            comContext.
+            lookup("cn=example");
+        
+        usersContext               =            ( LdapContext ) exampleContext.lookup("cn=users");
+
+        usersContext.destroySubcontext( "cn=accounts" );
+        exampleContext.destroySubcontext( "cn=users" );
+        comContext.destroySubcontext( "cn=example" );
+        dasPartitionContext.destroySubcontext( "cn=com" );
+    }
+}
\ No newline at end of file

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/InitialContextCreatorTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/InitialContextCreatorTest.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/InitialContextCreatorTest.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/InitialContextCreatorTest.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,67 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.create.test;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.create.InitialContextCreator;
+import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup;
+
+public class InitialContextCreatorTest 
+extends AbstractTestSetup
+{
+    public void testCreate() throws NamingException
+    {
+    	LdapContext comContext      = null;
+        LdapContext exampleContext  = null;
+        LdapContext usersContext    = null;
+        LdapContext accountsContext = null;
+                
+        InitialContextCreator. create( 
+            xsdNamespace, 
+            dasPartitionContext );
+        
+        comContext      = 
+            ( LdapContext ) 
+            dasPartitionContext.lookup( "cn=com" );
+        exampleContext  = ( LdapContext )comContext.lookup( "cn=example" );
+        usersContext    = ( LdapContext ) exampleContext.lookup( "cn=users" );
+        accountsContext = ( LdapContext ) usersContext.lookup( "cn=accounts" );
+        accountsContext = ( LdapContext ) usersContext.lookup( "cn=accounts" );
+        
+        assertNotNull(comContext);
+        assertNotNull(exampleContext);
+        assertNotNull(usersContext);
+        assertNotNull(accountsContext);
+
+        usersContext.
+        destroySubcontext( "cn=accounts" );
+        
+        exampleContext.
+        destroySubcontext( "cn=users" );
+
+        comContext.
+        destroySubcontext( "cn=example" );
+
+        dasPartitionContext.
+        destroySubcontext( "cn=com" );
+    }
+}

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/MetaContextCreatorTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/MetaContextCreatorTest.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/MetaContextCreatorTest.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/MetaContextCreatorTest.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,70 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.create.test;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.apache.tuscany.das.ldap.create.InitialContextCreator;
+import org.apache.tuscany.das.ldap.create.MetaContextCreator;
+import org.apache.tuscany.das.ldap.destroy.InitialContextDestroyer;
+import org.apache.tuscany.das.ldap.destroy.MetaContextDestroyer;
+import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup;
+
+public class MetaContextCreatorTest 
+extends AbstractTestSetup
+{
+    private DirContext modelContext    = null;
+    private DirContext metaContext     = null;
+    
+    public void tearDown() 
+    throws NamingException
+    {
+        
+        MetaContextDestroyer.destroy( modelContext );
+        
+        InitialContextDestroyer.destroy( 
+            modelContext, 
+            dasPartitionContext );
+    }
+
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        modelContext = 
+            InitialContextCreator.
+            create(
+                xsdNamespace,
+                dasPartitionContext);
+        
+        metaContext = 
+            MetaContextCreator.
+            create(modelContext );
+    }
+    
+    public void testCreate() throws NamingException
+    {
+        assertTrue(true);
+        
+        assertEquals(
+            "cn=meta,cn=accounts,cn=users,cn=example,cn=com,ou=das",
+            metaContext.getNameInNamespace() );
+    }
+}

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/SyntaxEntryCreatorTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/SyntaxEntryCreatorTest.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/SyntaxEntryCreatorTest.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/SyntaxEntryCreatorTest.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,76 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.create.test;
+
+import javax.naming.directory.DirContext;
+
+import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator;
+import org.apache.tuscany.das.ldap.schema.create.SyntaxEntryCreator;
+import org.apache.tuscany.das.ldap.schema.destroy.SyntaxEntryDestroyer;
+import org.apache.tuscany.das.ldap.schema.embedded.setup.test.EcoreSchemaContextsSetup;
+
+public class SyntaxEntryCreatorTest 
+extends EcoreSchemaContextsSetup
+{
+    DirContext syntaxEntryContext = 
+        null;
+    String dataTypeName           = 
+        "string";
+    String namespaceURI           = 
+        "http://org.apache.tuscany/sdo/datatypes";
+    
+    public void testCreate() 
+    throws Exception
+    {
+        SyntaxEntryCreator.create(
+            TUSCANY_SYNTAX_OID_VALUE, 
+            dataTypeName, 
+            namespaceURI, 
+            ecoreSyntaxesContext,
+            ecoreSyntaxCheckersContext);
+        
+        String rdn = 
+            ComplexTypeRDNCreator.
+            create( 
+                TUSCANY_SYNTAX_OID_VALUE, 
+                dataTypeName, 
+                namespaceURI);
+        
+        syntaxEntryContext = 
+            ( DirContext ) 
+            ecoreSyntaxesContext.
+            lookup(rdn);
+
+        assertNotNull(syntaxEntryContext);
+
+        SyntaxEntryDestroyer.
+        destroy( 
+            TUSCANY_SYNTAX_OID_VALUE, 
+            dataTypeName, 
+            namespaceURI, 
+            ecoreSyntaxesContext,
+            ecoreSyntaxCheckersContext);
+    }
+
+    public void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+}

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/UniqueOIDCreatorHelperTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/UniqueOIDCreatorHelperTest.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/UniqueOIDCreatorHelperTest.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/UniqueOIDCreatorHelperTest.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,53 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.create.test;
+
+import org.apache.tuscany.das.ldap.oid.create.OIDCreatorHelper;
+
+import junit.framework.TestCase;
+
+public class UniqueOIDCreatorHelperTest 
+extends TestCase
+{
+    public void testCalculateSegmentedOID() throws Exception
+    {
+        String input1 = "56102578";
+        String input2 = "5610257834";
+
+        String result = 
+            "will not pass if exception not caught";
+        try {
+            result = 
+                OIDCreatorHelper.
+                calculateSegmentedOID( input1 );            
+        }
+        catch (Exception e)
+        {
+            result = "passed";
+        }
+        assertEquals(result, "passed");
+        
+        result = 
+            OIDCreatorHelper.
+            calculateSegmentedOID( input2 );
+        
+        assertEquals(result, "56102578.4");
+    }
+}
\ No newline at end of file

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/destroy/test/InitialContextDestroyerTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/destroy/test/InitialContextDestroyerTest.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/destroy/test/InitialContextDestroyerTest.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/destroy/test/InitialContextDestroyerTest.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.destroy.test;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.apache.tuscany.das.ldap.destroy.InitialContextDestroyer;
+import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup;
+
+public class InitialContextDestroyerTest extends AbstractTestSetup
+{
+    DirContext test1Context = null;
+    DirContext test2Context = null;
+    DirContext test3Context = null;
+    
+    /*
+     * Tests that the initial context destroyer 
+     * destroys child projects before parent projects.
+     */
+    public void testDestroy() throws NamingException
+    {
+        test1Context = 
+            ( DirContext ) 
+            dasPartitionContext.
+            createSubcontext( "cn=test1" );
+        
+        test2Context = 
+            ( DirContext ) 
+            test1Context.
+            createSubcontext( "cn=test2" );
+        
+        test3Context = 
+            ( DirContext ) 
+            test2Context.
+            createSubcontext( "cn=test3" );
+        
+        Object test = null; 
+        test = 
+            dasPartitionContext.
+            lookup( "cn=test1" );
+        
+        assertNotNull(test);
+        
+        InitialContextDestroyer.
+        destroy(
+            test3Context, 
+            dasPartitionContext);
+        
+        try 
+        {
+            test = dasPartitionContext.lookup( "cn=test1" );
+        }
+        catch (Exception e)
+        {
+            test = "caught";
+        }
+        
+        assertSame("caught", test);
+    }
+}
\ No newline at end of file

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/EDataGraphCreatorTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/EDataGraphCreatorTest.java?view=auto&rev=550803
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/EDataGraphCreatorTest.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/EDataGraphCreatorTest.java Tue Jun 26 06:29:06 2007
@@ -0,0 +1,265 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.emf.create.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.emf.create.EDataGraphCreator;
+import org.apache.tuscany.das.ldap.prototype.setup.Prototype;
+import org.apache.tuscany.das.ldap.schema.embedded.setup.test.EcoreSchemaAndDASContextsSetup;
+import org.apache.tuscany.das.ldap.schema.emf.create.EObjectClassCreator;
+import org.apache.tuscany.das.ldap.schema.emf.destroy.EObjectClassDestroyer;
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.sdo.EDataGraph;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+import org.eclipse.emf.ecore.sdo.SDOFactory;
+
+public class EDataGraphCreatorTest 
+extends EcoreSchemaAndDASContextsSetup
+implements Prototype
+{
+	private EDataObject authorizationDataObject0 = null;
+	private EDataObject authorizationDataObject1 = null;
+	private EDataGraph eDataGraph                          = null;
+	
+	private static List<EClass> 
+    processedEClassifiers                                              = null;
+    
+	private EDataObject userDataObject                  = null;
+	
+
+	String eDataObjectRDN                                     = 
+		"example-com-users-accounts-User-id=1";
+	String eContainingFeatureRDN                         = 
+		"cn=authorizationList";
+	String authorizationDataObject1RDN              = 
+		"example-com-users-accounts-Authorization-id=2";
+	String authorizationDataObject2RDN              = 
+		"example-com-users-accounts-Authorization-id=3";
+	
+	LdapContext authorizationContainerContext  = null;
+	LdapContext eDataObjectContext                   = null;
+	
+	public void tearDown() throws NamingException, Exception
+	{
+		authorizationContainerContext.destroySubcontext(authorizationDataObject1RDN);
+		authorizationContainerContext.destroySubcontext(authorizationDataObject2RDN);
+		eDataObjectContext.destroySubcontext(eContainingFeatureRDN);
+		containerContext.destroySubcontext(eDataObjectRDN);
+
+        EObjectClassDestroyer.
+        destroy(
+            metaContext,
+            ecoreAttributeTypesContext,
+            ecoreObjectClassesContext, 
+            authorizationEClass, 
+            TUSCANY_SYNTAX_OID_VALUE );
+
+        EObjectClassDestroyer.
+            destroy(
+                metaContext,
+                ecoreAttributeTypesContext,
+                ecoreObjectClassesContext, 
+                userEClass, 
+                TUSCANY_SYNTAX_OID_VALUE );
+           
+        super.tearDown();
+	}
+	
+	public void setUp() throws Exception
+	{
+		super.setUp();
+
+        userEClass.
+        getEStructuralFeatures().
+        add( userNameEAttribute );
+        userEClass.
+        getEStructuralFeatures().
+        add( userPasswordEAttribute );
+        userEClass.
+        getEStructuralFeatures().
+        add( authorizationEReference );
+        userEClass.
+        getEStructuralFeatures().
+        add( userIDEAttribute );
+
+		userEPackage.getEClassifiers().add(userEClass);
+		
+    	userDataObject =
+    		(EDataObject) 
+    		userEFactory.create(userEClass);
+    	
+    	userDataObject.eSet(userNameEAttribute,"ole");
+    	userDataObject.eSet(userPasswordEAttribute,"secret");
+    	userDataObject.eSet(userIDEAttribute, "1");
+    	
+        
+		userEPackage.getEClassifiers().
+		add(authorizationEClass);
+		
+		authorizationEClass.
+		getEStructuralFeatures().
+		add(fileEAttribute);
+
+		authorizationEClass.
+		getEStructuralFeatures().
+		add(writeEAttribute);
+
+		authorizationEClass.
+		getEStructuralFeatures().
+		add(readEAttribute);
+		
+		authorizationEClass.
+		getEStructuralFeatures().
+		add(executeEAttribute);
+
+		authorizationEClass.
+		getEStructuralFeatures().
+		add(authorizationIDEAttribute);
+		
+    	authorizationDataObject0  =
+    		(EDataObject) 
+    		userEFactory.create(authorizationEClass);
+    	
+    	authorizationDataObject1  =
+    		(EDataObject) 
+    		userEFactory.create(authorizationEClass);
+    	
+    	authorizationDataObject0.eSet(fileEAttribute,"somefile.text");
+    	authorizationDataObject0.eSet(writeEAttribute, true);
+    	authorizationDataObject0.eSet(readEAttribute,true);
+    	authorizationDataObject0.eSet(executeEAttribute,true);
+    	authorizationDataObject0.eSet(authorizationIDEAttribute, "2");
+
+    	authorizationDataObject1.eSet(fileEAttribute,"someOtherfile.text");
+    	authorizationDataObject1.eSet(writeEAttribute,Boolean.TRUE);
+    	authorizationDataObject1.eSet(readEAttribute,true);
+    	authorizationDataObject1.eSet(executeEAttribute,true);
+    	authorizationDataObject1.eSet(authorizationIDEAttribute, "3");
+    	
+    	EList userDataObjectAuthorizationList =
+    		new BasicEList();
+    	
+    	userDataObjectAuthorizationList.add(authorizationDataObject0);
+    	userDataObjectAuthorizationList.add(authorizationDataObject1);
+    	
+		userDataObject.eSet(
+				authorizationEReference, 
+				userDataObjectAuthorizationList);
+            
+        processedEClassifiers                   = 
+            new ArrayList<EClass>();
+        
+        EObjectClassCreator
+        eObjectClassCreator      =
+            new EObjectClassCreator();
+        
+        eObjectClassCreator.
+        create(
+            metaContext,
+            ecoreAttributeTypesContext,
+            ecoreObjectClassesContext,
+            userEClass, 
+            processedEClassifiers,
+            TUSCANY_SYNTAX_OID_VALUE );
+
+        eObjectClassCreator.
+        create(
+            metaContext,
+            ecoreAttributeTypesContext,
+            ecoreObjectClassesContext,
+            authorizationEClass, 
+            processedEClassifiers,
+            TUSCANY_SYNTAX_OID_VALUE );
+
+    	eDataGraph             =
+    		SDOFactory.eINSTANCE.createEDataGraph();
+    	   		
+    	eDataGraph.setERootObject(userDataObject);
+
+    	EDataGraphCreator.create(
+				eDataGraph,
+				containerContext);
+	}
+	    
+    public void testCreate() throws NamingException
+    {
+    	eDataObjectContext = 
+    		(LdapContext) 
+    		containerContext.
+    		lookup(eDataObjectRDN);
+    	
+    	assertEquals(
+    			"example-com-users-accounts-User-id=1,cn=accounts,cn=users,cn=example,cn=com,ou=das",
+    			eDataObjectContext.getNameInNamespace());
+    	
+    	Attributes userEntryAttributes = 
+    		eDataObjectContext.getAttributes("");
+    	
+    	assertEquals(
+    			userEntryAttributes.get(
+    					"example-com-users-accounts-User-userPassword").get(),
+    					"secret");
+
+    	assertEquals(
+    			userEntryAttributes.get(
+    					"example-com-users-accounts-User-authorizationList").get(0), "2");
+
+    	assertEquals(
+    			userEntryAttributes.get(
+    					"example-com-users-accounts-User-authorizationList").get(1), "3");
+    	
+    	assertEquals(
+    			userEntryAttributes.get("example-com-users-accounts-User-userName").get(),
+    			"ole");
+    	
+    	authorizationContainerContext =
+    		(LdapContext) 
+    		eDataObjectContext.
+    		lookup(eContainingFeatureRDN);
+    	
+    	Attributes authorizationEntry1Attributes            =
+    		authorizationContainerContext.
+    		getAttributes(authorizationDataObject1RDN);
+    	
+    	assertEquals(
+    			authorizationEntry1Attributes.get("example-com-users-accounts-Authorization-fileName").get(),
+    			"somefile.text");
+    	
+    	assertEquals(
+    			authorizationEntry1Attributes.get("example-com-users-accounts-Authorization-writeAuthorization").get(),
+    			"TRUE");
+    	
+    	Attributes authorizationEntry2Attributes            =
+    		authorizationContainerContext.
+    		getAttributes(authorizationDataObject2RDN);
+    	
+    	assertEquals(
+    			authorizationEntry2Attributes.get("example-com-users-accounts-Authorization-fileName").get(),
+    			"someOtherfile.text");
+    }
+}
\ No newline at end of file



Mime
View raw message