directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oer...@apache.org
Subject svn commit: r549870 [5/9] - 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 Fri, 22 Jun 2007 16:39:54 GMT
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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 2007
@@ -0,0 +1,74 @@
+/*
+ *  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.XSDSchemaContextsSetup;
+
+public class SyntaxEntryCreatorTest 
+extends XSDSchemaContextsSetup
+{
+    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, 
+            xsdSyntaxesContext );
+        
+        String rdn = 
+            ComplexTypeRDNCreator.
+            create( 
+                TUSCANY_SYNTAX_OID_VALUE, 
+                dataTypeName, 
+                namespaceURI);
+        
+        syntaxEntryContext = 
+            ( DirContext ) 
+            xsdSyntaxesContext.
+            lookup(rdn);
+
+        assertNotNull(syntaxEntryContext);
+
+        SyntaxEntryDestroyer.
+        destroy( 
+            TUSCANY_SYNTAX_OID_VALUE, 
+            dataTypeName, 
+            namespaceURI, 
+            xsdSyntaxesContext );
+    }
+
+    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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 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=549870
==============================================================================
--- 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 Fri Jun 22 09:39:30 2007
@@ -0,0 +1,253 @@
+/*
+ *  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.schema.create.MetaTopSDOObjectClassCreator;
+import org.apache.tuscany.das.ldap.schema.destroy.MetaTopSDOObjectClassDestroyer;
+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 );
+
+        MetaTopSDOObjectClassDestroyer.
+            destroy(
+                ecoreAttributeTypesContext,
+                ecoreObjectClassesContext, 
+                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,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);
+
+        MetaTopSDOObjectClassCreator 
+        metaTopSDOObjectClassCreator = 
+            new MetaTopSDOObjectClassCreator();
+        
+        metaTopSDOObjectClassCreator.create(
+            ecoreAttributeTypesContext, 
+            ecoreObjectClassesContext, 
+            TUSCANY_SYNTAX_OID_VALUE );
+            
+        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 attributes = 
+    		eDataObjectContext.getAttributes("");
+    	
+    	assertEquals(
+    			attributes.get("example-com-users-accounts-User-userPassword").get(),
+    			"secret");
+    	
+    	assertEquals(
+    			attributes.get("example-com-users-accounts-User-userName").get(),
+    			"ole");
+    	
+    	authorizationContainerContext =
+    		(LdapContext) 
+    		eDataObjectContext.
+    		lookup(eContainingFeatureRDN);
+    }
+}
\ 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/EDataObjectCreatorTest.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/EDataObjectCreatorTest.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/EDataObjectCreatorTest.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/EDataObjectCreatorTest.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,148 @@
+/*
+ *  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.EDataObjectCreator;
+import org.apache.tuscany.das.ldap.schema.create.MetaTopSDOObjectClassCreator;
+import org.apache.tuscany.das.ldap.schema.destroy.MetaTopSDOObjectClassDestroyer;
+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.ecore.EClass;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class EDataObjectCreatorTest 
+extends EcoreSchemaAndDASContextsSetup
+implements Prototype
+{
+    protected static List<EClass> 
+    processedEClassifiers                                                  = null;
+    
+	protected static EDataObject userDataObject     = null;
+	
+	protected String eDataObjectRDN                         = null;
+	protected LdapContext namedContainerContext = null;
+	
+	public void tearDown() throws NamingException, Exception
+	{
+		containerContext.destroySubcontext(eDataObjectRDN);
+		
+        EObjectClassDestroyer.
+            destroy(
+                metaContext,
+                ecoreAttributeTypesContext,
+                ecoreObjectClassesContext, 
+                userEClass, 
+                TUSCANY_SYNTAX_OID_VALUE );
+
+        MetaTopSDOObjectClassDestroyer.
+            destroy(
+                ecoreAttributeTypesContext,
+                ecoreObjectClassesContext, 
+                TUSCANY_SYNTAX_OID_VALUE );        
+           
+        super.tearDown();
+	}
+	
+	public void setUp() throws Exception
+	{
+		super.setUp();
+		
+        userEClass.
+        getEStructuralFeatures().
+        add( userNameEAttribute );
+        userEClass.
+        getEStructuralFeatures().
+        add( userPasswordEAttribute );
+
+        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");
+
+        MetaTopSDOObjectClassCreator 
+        metaTopSDOObjectClassCreator = 
+            new MetaTopSDOObjectClassCreator();
+        
+        metaTopSDOObjectClassCreator.create(
+            ecoreAttributeTypesContext, 
+            ecoreObjectClassesContext, 
+            TUSCANY_SYNTAX_OID_VALUE );
+            
+        processedEClassifiers                   = 
+            new ArrayList<EClass>();
+        
+        EObjectClassCreator
+        eObjectClassCreator      =
+            new EObjectClassCreator();
+        
+        eObjectClassCreator.
+        create(
+            metaContext,
+            ecoreAttributeTypesContext,
+            ecoreObjectClassesContext,
+            userEClass, 
+            processedEClassifiers,
+            TUSCANY_SYNTAX_OID_VALUE );
+        
+    	eDataObjectRDN                             = 
+    		EDataObjectCreator.create(
+    				userDataObject,
+    				containerContext);
+    }
+	
+    public void testCreate() throws NamingException
+    {
+    	LdapContext 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 attributes = 
+    		eDataObjectContext.getAttributes("");
+    	
+    	assertEquals(
+    			attributes.get("example-com-users-accounts-User-userPassword").get(),
+    			"secret");
+    	
+    	assertEquals(
+    			attributes.get("example-com-users-accounts-User-userName").get(),
+    			"ole");
+    }
+}
\ 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/Prototype.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/Prototype.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/Prototype.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/Prototype.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,48 @@
+package org.apache.tuscany.das.ldap.emf.create.test;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+
+public interface Prototype {
+	EClass userEClass                               = 
+		PrototypeUtilities.createUserEClass();
+	EClass authorizationEClass                 = 
+		PrototypeUtilities.createAuthorizationEClass();
+	
+	EAttribute userNameEAttribute          = 
+		PrototypeUtilities.createUserNameEAttribute(); 
+	EAttribute userPasswordEAttribute    = 
+		PrototypeUtilities.createUserPasswordEAttribute();
+	EAttribute userIDEAttribute                =
+		PrototypeUtilities.createUserIDEAttribute();
+	
+	EAttribute fileEAttribute                     = 
+		PrototypeUtilities.createFileEAttribute();
+	EAttribute readEAttribute                   = 
+		PrototypeUtilities.createReadAuthorizationEAttribute();
+	EAttribute writeEAttribute                  = 
+		PrototypeUtilities.createWriteAuthorizationEAttribute();
+	EAttribute executeEAttribute             = 
+		PrototypeUtilities.createExecuteAuthorizationEAttribute();
+	EAttribute authorizationIDEAttribute = 
+		PrototypeUtilities.createAuthorizationIDEAttribute();
+	
+	EReference authorizationEReference = 
+		PrototypeUtilities.createAuthorizationEReference();
+	
+	EPackage  userEPackage                     = 
+		PrototypeUtilities.createUserEPackage();
+	
+	EFactory userEFactory                        =
+		userEPackage.getEFactoryInstance();
+	
+    EcoreFactory ecoreFactory                 = 
+    	EcoreFactory.eINSTANCE;
+    EcorePackage ecorePackage               = 
+    	EcorePackage.eINSTANCE;
+}

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/PrototypeUtilities.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/PrototypeUtilities.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/PrototypeUtilities.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/PrototypeUtilities.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,139 @@
+package org.apache.tuscany.das.ldap.emf.create.test;
+
+import org.apache.tuscany.das.ldap.testing.constants.DASTestingConstants;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;
+
+public class PrototypeUtilities 
+implements DASTestingConstants {
+	
+
+    public static EClass createUserEClass()
+    {
+        EClass userEClass                                     = 
+        	EcoreFactory.eINSTANCE.createEClass();
+        
+        userEClass.setName("User");
+        
+        return userEClass;
+    }
+    
+    public static EAttribute createUserIDEAttribute()
+    {
+        EAttribute id                         = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        id.setName( "id" );
+        id.setEType( EcorePackage.eINSTANCE.getEString() );
+        id.setID(true);
+        return id;
+    }
+
+    public static EAttribute createAuthorizationIDEAttribute()
+    {
+        EAttribute id                         = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        id.setName( "id" );
+        id.setEType( EcorePackage.eINSTANCE.getEString() );
+        id.setID(true);
+        return id;
+    }
+
+    public static EAttribute createUserNameEAttribute()
+    {
+        EAttribute userName                         = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        userName.setName( "userName" );
+        userName.setEType( EcorePackage.eINSTANCE.getEString() );
+        return userName;
+    }
+    
+    public static EAttribute createUserPasswordEAttribute()
+    {
+        EAttribute userPassword                    = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        userPassword.setName( "userPassword" );
+        userPassword.setEType( EcorePackage.eINSTANCE.getEString() );
+        return userPassword;
+    }
+
+    public static EPackage createUserEPackage()
+    {
+        EPackage userEPackage                     = 
+        	EcoreFactory.eINSTANCE.createEPackage();
+        userEPackage.setName( "userPackage" );
+        userEPackage.setNsPrefix( "user" );
+        userEPackage.setNsURI( xsdNamespace );
+        
+        userEPackage.setEFactoryInstance(
+            new DynamicEDataObjectImpl.FactoryImpl());
+        userEPackage.getEClassifiers().add(createUserEClass());
+        
+        return userEPackage;
+    }
+    
+    public static EClass createAuthorizationEClass()
+    {
+        EClass authorizationEClass         = 
+        	EcoreFactory.eINSTANCE.createEClass();
+        
+        authorizationEClass.setName("Authorization");
+
+        return authorizationEClass;
+    }
+    
+    public static EAttribute createFileEAttribute()
+    {
+        EAttribute fileNameEAttribute     = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        fileNameEAttribute.setName( "fileName" );
+        fileNameEAttribute.setEType( EcorePackage.eINSTANCE.getEString() );
+        return fileNameEAttribute;
+        
+    }
+    
+    public static EAttribute createWriteAuthorizationEAttribute()
+    {
+        EAttribute writeAuthorizationEAttribute  = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        writeAuthorizationEAttribute.setName( "writeAuthorization" );
+        writeAuthorizationEAttribute.setEType( EcorePackage.eINSTANCE.getEBoolean() );
+        return writeAuthorizationEAttribute;
+    }
+
+    public static EAttribute createReadAuthorizationEAttribute()
+    {
+        EAttribute readAuthorizationEAttribute  = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        readAuthorizationEAttribute.setName( "readAuthorization" );
+        readAuthorizationEAttribute.setEType( EcorePackage.eINSTANCE.getEBoolean() );
+        return readAuthorizationEAttribute;
+    }
+
+    public static EAttribute createExecuteAuthorizationEAttribute()
+    {
+        EAttribute readExecuteEAttribute  = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        readExecuteEAttribute.setName( "executeAuthorization" );
+        readExecuteEAttribute.setEType( EcorePackage.eINSTANCE.getEBoolean() );
+        return readExecuteEAttribute;
+    }
+
+    public static EReference createAuthorizationEReference()
+    {
+    	EReference authorizationEReference =
+    		EcoreFactory.eINSTANCE.createEReference();
+    	authorizationEReference.setLowerBound(0);
+    	authorizationEReference.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY);
+    	authorizationEReference.setContainment(true);
+    	authorizationEReference.setEType(createAuthorizationEClass());
+    	authorizationEReference.setName("authorizationList");
+    	
+    	return authorizationEReference;
+    }
+}

Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/learning/test/DASPartitionCleanerTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/learning/test/DASPartitionCleanerTest.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/learning/test/DASPartitionCleanerTest.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/learning/test/DASPartitionCleanerTest.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,139 @@
+/*
+ *  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.learning.test;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EcoreFactory;
+
+public class DASPartitionCleanerTest
+extends AbstractTestSetup
+{
+    private static EcoreFactory ecoreFactory = 
+        EcoreFactory.eINSTANCE;
+    
+    private EClass eClassL0                  =
+        null;
+
+    private EClass eClassL1                  =
+        null;
+
+    public void setUp() 
+    throws NamingException, Exception
+    {
+        super.setUp();
+        
+        eClassL0             = 
+            ecoreFactory.createEClass();
+        eClassL0.setName( "L0" );
+
+        eClassL1             = 
+            ecoreFactory.createEClass();
+        eClassL1.setName( "L1" );
+        
+        eClassL1.getESuperTypes().add(eClassL0);
+    }
+    
+    public void tearDown() 
+    throws NamingException, Exception
+    {
+        super.tearDown();
+    }
+    
+    public void testTemporaryCleanupMethod() throws NamingException
+    {
+        DirContext comContext      = null;
+        DirContext exampleContext  = null;
+        DirContext usersContext    = null;
+        DirContext accountsContext = null;
+        DirContext metaContext     = null;
+        DirContext parentContext   = null;
+        DirContext childContext    = null;
+
+        
+        comContext      = 
+            ( DirContext ) 
+            dasPartitionContext.lookup( "cn=com" );
+        assertNotNull(comContext);
+        
+        exampleContext  = 
+            ( DirContext )
+            comContext.lookup( "cn=example" );
+        assertNotNull(exampleContext);
+        
+        usersContext    = 
+            ( DirContext ) 
+            exampleContext.lookup( "cn=users" );
+        assertNotNull(usersContext);
+        
+        accountsContext = 
+            ( DirContext ) 
+            usersContext.lookup( "cn=accounts" );
+        assertNotNull(accountsContext);
+        
+        metaContext     = 
+            ( DirContext ) 
+            accountsContext.lookup( "cn=meta" );
+        assertNotNull(metaContext);
+        
+        
+       /*
+        parentContext              =
+            ( DirContext ) 
+            metaContext.
+            lookup( "cn=" + eClassL0.getName() );
+        assertNotNull(parentContext);
+        
+        
+        childContext               =  
+            ( DirContext ) 
+            parentContext.
+            lookup( "cn=" + eClassL1.getName() );
+        assertNotNull(childContext);
+        
+        
+
+        parentContext.
+        destroySubcontext( "cn=" + eClassL1.getName() );
+
+        metaContext.
+        destroySubcontext( "cn=" + eClassL0.getName() );
+*/
+        
+        
+        accountsContext.
+        destroySubcontext( "cn=meta" );
+               
+        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/learning/test/SearchingTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/learning/test/SearchingTest.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/learning/test/SearchingTest.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/tuscany/das/ldap/learning/test/SearchingTest.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,45 @@
+package org.apache.tuscany.das.ldap.learning.test;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup;
+
+import junit.framework.TestCase;
+
+public class SearchingTest extends AbstractTestSetup {
+	
+	public void testSearch() throws NamingException
+	{
+		dasPartitionContext.destroySubcontext("cn=L1, cn=L0");
+		dasPartitionContext.destroySubcontext("cn=L0");
+
+		LdapContext contextL0 = 
+			(LdapContext) 
+			dasPartitionContext.createSubcontext("cn=L0");
+		
+		contextL0.createSubcontext("cn=L1");
+		
+		Attributes searchAttributes = 
+			new BasicAttributes(true); 
+		
+		searchAttributes.put(new BasicAttribute("cn"));
+		
+		NamingEnumeration answer = contextL0.search("", searchAttributes);
+		while (answer.hasMore()) {
+			
+		    SearchResult result = (SearchResult)answer.next();
+		    Attributes attributes = result.getAttributes();
+		    
+		    System.out.println(attributes.get("cn").get().toString());
+		}
+		
+		
+	}
+
+}



Mime
View raw message