directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r888077 - in /directory/shared/branches/shared-schema: ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/ ldap-schema-loader/src/test/java/org/apache/directory/server/schema/
Date Mon, 07 Dec 2009 18:53:35 GMT
Author: elecharny
Date: Mon Dec  7 18:53:31 2009
New Revision: 888077

URL: http://svn.apache.org/viewvc?rev=888077&view=rev
Log:
Added some test for the enable/disabled/loadAllEnabled methods.

Added:
    directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerEnableDisableLoadTest.java
Modified:
    directory/shared/branches/shared-schema/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/MetaSchemaConstants.java

Modified: directory/shared/branches/shared-schema/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/MetaSchemaConstants.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/MetaSchemaConstants.java?rev=888077&r1=888076&r2=888077&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/MetaSchemaConstants.java
(original)
+++ directory/shared/branches/shared-schema/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/MetaSchemaConstants.java
Mon Dec  7 18:53:31 2009
@@ -29,6 +29,7 @@
 public interface MetaSchemaConstants
 {
     String SCHEMA_NAME = "apachemeta";
+    String SCHEMA_OTHER = "other";
 
     // -- objectClass names --
     
@@ -171,6 +172,4 @@
     String X_IS_HUMAN_READABLE              = "X-IS-HUMAN-READABLE";
     String X_READ_ONLY                      = "X-READ-ONLY";
     String X_ENABLED                        = "X-ENABLED";
-    
-    String SCHEMA_OTHER = "other";
 }

Added: directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerEnableDisableLoadTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerEnableDisableLoadTest.java?rev=888077&view=auto
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerEnableDisableLoadTest.java
(added)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerEnableDisableLoadTest.java
Mon Dec  7 18:53:31 2009
@@ -0,0 +1,181 @@
+/*
+ *  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.schema;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.registries.Schema;
+import org.apache.directory.shared.schema.DefaultSchemaManager;
+import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * A test class for SchemaManager enable/disable and loadAllEnbled() methods. 
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaManagerEnableDisableLoadTest
+{
+    // A directory in which the ldif files will be stored
+    private static String workingDirectory;
+
+    // The schema repository
+    private static File schemaRepository;
+
+    // The schemaManager
+    private SchemaManager schemaManager;
+
+    // List of all the available schemas, enabled or disabled
+    private List<String> allSchemas = Arrays.asList( "system", "core", "cosine", "inetorgperson",
"apache",
+        "apachemeta", "collective", "java", "krb5kdc", "other", "nis", "autofs", "apachedns",
"dhcp", "samba", "corba" );
+
+    // List of all the enabled schemas
+    private List<String> enabledSchemas = Arrays.asList( "system", "core", "cosine",
"inetorgperson", "apache",
+        "apachemeta", "collective", "java", "krb5kdc", "other" );
+
+    // List of all the disabled schemas
+    private List<String> disabledSchemas = Arrays.asList( "nis", "autofs", "apachedns",
"dhcp", "samba", "corba" );
+
+
+    @BeforeClass
+    public static void setup() throws Exception
+    {
+        workingDirectory = System.getProperty( "workingDirectory" );
+
+        if ( workingDirectory == null )
+        {
+            String path = SchemaManagerEnableDisableLoadTest.class.getResource( "" ).getPath();
+            int targetPos = path.indexOf( "target" );
+            workingDirectory = path.substring( 0, targetPos + 6 );
+        }
+
+        schemaRepository = new File( workingDirectory, "schema" );
+
+        // Cleanup the target directory
+        FileUtils.deleteDirectory( schemaRepository );
+
+        SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory
) );
+        extractor.extractOrCopy();
+    }
+
+
+    @Before
+    public void init() throws Exception
+    {
+        LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+        schemaManager = new DefaultSchemaManager( loader );
+    }
+
+
+    @AfterClass
+    public static void cleanup() throws IOException
+    {
+        // Cleanup the target directory
+        FileUtils.deleteDirectory( schemaRepository );
+    }
+
+
+    //-------------------------------------------------------------------------
+    // Test the loadAllEnabled() method
+    //-------------------------------------------------------------------------
+    /**
+     * Tst the loadEnabled() method
+     */
+    @Test
+    public void testLoadAllEnabled() throws Exception
+    {
+        assertTrue( schemaManager.getEnabled().isEmpty() );
+        assertTrue( schemaManager.loadAllEnabled() );
+
+        for ( String schemaName : allSchemas )
+        {
+            assertTrue( schemaManager.isSchemaLoaded( schemaName ) );
+        }
+
+        // The enabled schemas
+        List<Schema> enabled = schemaManager.getEnabled();
+
+        assertEquals( enabled.size(), enabledSchemas.size() );
+
+        for ( Schema schema : enabled )
+        {
+            assertTrue( enabledSchemas.contains( schema.getSchemaName().toLowerCase() ) );
+        }
+
+        // The disabled schemas
+        List<Schema> disabled = schemaManager.getDisabled();
+
+        assertEquals( 0, disabled.size() );
+    }
+
+
+    //-------------------------------------------------------------------------
+    // Test the enable( String... schemaName) method
+    //-------------------------------------------------------------------------
+    /**
+     * Enable a schema which is alread enabled
+     */
+    @Test
+    public void testEnableAlreadyEnabled() throws Exception
+    {
+        schemaManager.loadAllEnabled();
+
+        assertTrue( schemaManager.enable( "core" ) );
+    }
+
+
+    @Test
+    public void testEnableDisabled()
+    {
+
+    }
+
+
+    @Test
+    public void testEnableNonExisting()
+    {
+
+    }
+
+
+    /**
+     * Enable multiple schemas, some are enabled, sme are disabled, some are not existing
+     */
+    @Test
+    public void testEnableMultipleSchemas()
+    {
+
+    }
+}



Mime
View raw message