You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/02/05 19:05:42 UTC

svn commit: r1240772 - in /directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api: LdapConnectionTest.java SsseSchemaLoaderTest.java

Author: elecharny
Date: Sun Feb  5 18:05:42 2012
New Revision: 1240772

URL: http://svn.apache.org/viewvc?rev=1240772&view=rev
Log:
Added a dedicated test for the SsseSchemaLoader, and moved the test out of the NetworkSchemaLoaderTest class

Added:
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/SsseSchemaLoaderTest.java
Modified:
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java?rev=1240772&r1=1240771&r2=1240772&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java Sun Feb  5 18:05:42 2012
@@ -32,7 +32,6 @@ import java.util.List;
 
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
-import org.apache.directory.ldap.client.api.SsseSchemaLoader;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.annotations.ApplyLdifs;
@@ -45,12 +44,8 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.filter.EqualityNode;
 import org.apache.directory.shared.ldap.model.message.SearchScope;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
-import org.apache.directory.shared.ldap.model.schema.registries.DefaultSchema;
-import org.apache.directory.shared.ldap.model.schema.registries.Schema;
-import org.apache.directory.shared.ldap.model.schema.registries.SchemaLoader;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -221,49 +216,4 @@ public void testLookup() throws Exceptio
         assertTrue( connection.isAuthenticated() );
         connection.close();
     }
-    
-    
-    @Test
-    @Ignore
-    public void testLoadPrivateSchema() throws Exception
-    {
-        LdapNetworkConnection connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
-        
-        // Load the default schema
-        connection.loadDefaultSchema();
-        
-        // Now, try to load the NIS schema
-        SchemaManager schemaManager = connection.getSchemaManager();
-        
-        Schema mySchema = new DefaultSchema( "mySchema" );
-        
-        assertTrue( schemaManager.load( "nis" ) );
-
-        connection.bind();
-        assertTrue( connection.isAuthenticated() );
-        connection.close();
-        
-    }
-    
-    
-    @Test
-    public void testLoadSSSE() throws Exception
-    {
-        SchemaLoader loader = new SsseSchemaLoader( connection );
-        
-        // Load the default schema
-        connection.loadSchema( loader );
-        SchemaManager schemaManager = connection.getSchemaManager();
-        assertNotNull( schemaManager );
-        assertTrue( schemaManager.isSchemaLoaded( "system" ) );
-        assertTrue( schemaManager.isEnabled( "system" ) );
-        assertFalse( schemaManager.isSchemaLoaded( "nis" ) );
-        assertEquals( schemaManager.getLoader().getAllSchemas().size(), schemaManager.getEnabled().size() );
-
-        
-        connection.bind();
-        assertTrue( connection.isAuthenticated() );
-        connection.close();
-        
-    }
 }

Added: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/SsseSchemaLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/SsseSchemaLoaderTest.java?rev=1240772&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/SsseSchemaLoaderTest.java (added)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/SsseSchemaLoaderTest.java Sun Feb  5 18:05:42 2012
@@ -0,0 +1,97 @@
+/*
+ *   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.shared.client.api;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.SsseSchemaLoader;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.ldap.model.schema.registries.SchemaLoader;
+import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.exception.Exceptions;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * A test class for NetworkSchemaLoader.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer(transports =
+    { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
+public class SsseSchemaLoaderTest extends AbstractLdapTestUnit
+{
+    private LdapNetworkConnection connection;
+
+
+    @Before
+    public void setup() throws Exception
+    {
+        connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
+    }
+
+
+    @After
+    public void shutdown() throws Exception
+    {
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, getLdapServer() );
+    }
+    
+    
+    @Test
+    public void testLoadSSSE() throws Exception
+    {
+        SchemaLoader loader = new SsseSchemaLoader( connection );
+        
+        // Load the schemas
+        SchemaManager schemaManager = new DefaultSchemaManager( loader );
+
+        assertNotNull( schemaManager );
+
+        boolean loaded = schemaManager.loadAllEnabled();
+
+        if ( !loaded )
+        {
+            fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
+        }
+
+        assertTrue( schemaManager.isSchemaLoaded( "system" ) );
+        assertTrue( schemaManager.isEnabled( "system" ) );
+        assertFalse( schemaManager.isSchemaLoaded( "nis" ) );
+        assertEquals( schemaManager.getLoader().getAllSchemas().size(), schemaManager.getEnabled().size() );
+
+        assertTrue( schemaManager.getRegistries().getAttributeTypeRegistry().contains( "cn" ) );
+    }
+}