You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2008/07/29 09:25:25 UTC
svn commit: r680638 - in /directory/apacheds/branches/bigbang:
server-integ/src/main/java/org/apache/directory/server/integ/
server-integ/src/main/java/org/apache/directory/server/integ/state/
server-integ/src/test/java/org/apache/directory/server/ ser...
Author: akarasulu
Date: Tue Jul 29 00:25:24 2008
New Revision: 680638
URL: http://svn.apache.org/viewvc?rev=680638&view=rev
Log:
making server-unit work and complete - tested
o added dummy test to show this is working
o added utility class for getting wired contexts to the server
Added:
directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java
directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/DummyIT.java
Modified:
directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java
directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
Added: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java?rev=680638&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java (added)
+++ directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java Tue Jul 29 00:25:24 2008
@@ -0,0 +1,62 @@
+/*
+ * 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.server.integ;
+
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.constants.ServerDNConstants;
+import org.apache.directory.server.core.integ.IntegrationUtils;
+import org.apache.directory.server.newldap.LdapServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class ServerIntegrationUtils extends IntegrationUtils
+{
+ /** The class logger */
+ private static final Logger LOG = LoggerFactory.getLogger( ServerIntegrationUtils.class );
+ private static final String CTX_FACTORY = "com.sun.jndi.ldap.LdapCtxFactory";
+
+
+ /**
+ * Creates a JNDI LdapContext with a connection over the wire using the
+ * SUN LDAP provider. The connection is made using the administrative
+ * user as the principalDN. The context is to the rootDSE.
+ *
+ * @param ldapServer the LDAP server to get the connection to
+ * @return an LdapContext as the administrative user to the RootDSE
+ * @throws Exception if there are problems creating the context
+ */
+ public static LdapContext getWiredContext( LdapServer ldapServer ) throws Exception
+ {
+ LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapServer.getIpPort() );
+ Hashtable<String, String> env = new Hashtable<String, String>();
+ env.put( Context.INITIAL_CONTEXT_FACTORY, CTX_FACTORY );
+ env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapServer.getIpPort() );
+ env.put( Context.SECURITY_PRINCIPAL, ServerDNConstants.ADMIN_SYSTEM_DN );
+ env.put( Context.SECURITY_CREDENTIALS, "secret" );
+ env.put( Context.SECURITY_AUTHENTICATION, "simple" );
+ return new InitialLdapContext( env, null );
+ }
+}
Modified: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java?rev=680638&r1=680637&r2=680638&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java Tue Jul 29 00:25:24 2008
@@ -22,6 +22,7 @@
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
+
import javax.naming.NamingException;
import org.apache.directory.server.integ.InheritableServerSettings;
@@ -207,10 +208,6 @@
Object test = testClass.getConstructor().newInstance();
Field field = testClass.getJavaClass().getDeclaredField( "ldapServer" );
field.set( testClass.getJavaClass(), get().getLdapServer() );
-
- // also check and add ctx member with access to server over the wire
- // TODO add here and make sure we cleanup
-
new MethodRoadie( test, testMethod, notifier, description ).run();
}
catch ( InvocationTargetException e )
Added: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/DummyIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/DummyIT.java?rev=680638&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/DummyIT.java (added)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/DummyIT.java Tue Jul 29 00:25:24 2008
@@ -0,0 +1,143 @@
+/*
+ * 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.server;
+
+
+import static org.junit.Assert.*;
+
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.annotations.CleanupLevel;
+import org.apache.directory.server.integ.ServerIntegrationUtils;
+import org.apache.directory.server.integ.SiRunner;
+import org.apache.directory.server.newldap.LdapServer;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A bogus test to make sure the framework is working.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith ( SiRunner.class )
+@CleanupLevel ( Level.CLASS )
+public class DummyIT
+{
+ private static final Logger LOG = LoggerFactory.getLogger( DummyIT.class );
+
+ // will be set by the framework
+ public static LdapServer ldapServer;
+
+
+ static
+ {
+ LOG.debug( "0 - {}", System.currentTimeMillis() );
+ }
+
+
+ @Test
+ public void testInitialization() throws Exception
+ {
+ LOG.debug( "testInitialization()" );
+ assertNotNull( ldapServer );
+
+ LdapContext ldapContext = null;
+
+ try
+ {
+ ldapContext = ServerIntegrationUtils.getWiredContext( ldapServer );
+ assertNotNull( ldapContext );
+
+ Attributes attrs = ldapContext.getAttributes( "uid=admin,ou=system" );
+ assertNotNull( attrs );
+ assertEquals( "administrator", attrs.get( "sn" ).get() );
+ assertEquals( "admin", attrs.get( "uid" ).get() );
+ assertEquals( "Directory Superuser", attrs.get( "displayName" ).get() );
+ }
+ finally
+ {
+ ldapContext.close();
+ }
+
+ LOG.debug( "1 - {}", System.currentTimeMillis() );
+ }
+
+
+ @Test
+ public void test2() throws Exception
+ {
+ LOG.debug( "2 - {}", System.currentTimeMillis() );
+ }
+
+
+ @Test
+ public void test3() throws Exception
+ {
+ LOG.debug( "3 - {}", System.currentTimeMillis() );
+ }
+
+
+ @Test
+ public void test4() throws Exception
+ {
+ LOG.debug( "4 - {}", System.currentTimeMillis() );
+ }
+
+
+ @Test
+ public void test5() throws Exception
+ {
+ LOG.debug( "5 - {}", System.currentTimeMillis() );
+ }
+
+
+ @Test
+ public void test6() throws Exception
+ {
+ LOG.debug( "6 - {}", System.currentTimeMillis() );
+ }
+
+
+ @Test
+ public void test7() throws Exception
+ {
+ LOG.debug( "7 - {}", System.currentTimeMillis() );
+ }
+
+
+ @Test
+ public void test8() throws Exception
+ {
+ LOG.debug( "8 - {}", System.currentTimeMillis() );
+ }
+
+
+ @Test
+ public void test9() throws Exception
+ {
+ LOG.debug( "9 - {}", System.currentTimeMillis() );
+ }
+}
Modified: directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java?rev=680638&r1=680637&r2=680638&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java (original)
+++ directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java Tue Jul 29 00:25:24 2008
@@ -280,7 +280,7 @@
{
Map<String, MechanismHandler> mechanismHandlerMap = new HashMap<String,MechanismHandler>();
- mechanismHandlerMap.put( SupportedSaslMechanisms.PLAIN, new SimpleMechanismHandler() );
+ mechanismHandlerMap.put( SupportedSaslMechanisms.PLAIN, new SimpleMechanismHandler() );
CramMd5MechanismHandler cramMd5MechanismHandler = new CramMd5MechanismHandler();
mechanismHandlerMap.put( SupportedSaslMechanisms.CRAM_MD5, cramMd5MechanismHandler );