directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1026697 - in /directory/apacheds/branches/apacheds-config/server-config/src/test: java/org/apache/directory/server/config/DnsServerConfigReaderTest.java resources/dnsserver.ldif
Date Sat, 23 Oct 2010 22:06:13 GMT
Author: elecharny
Date: Sat Oct 23 22:06:13 2010
New Revision: 1026697

URL: http://svn.apache.org/viewvc?rev=1026697&view=rev
Log:
Added the DnsServer test

Added:
    directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/DnsServerConfigReaderTest.java
    directory/apacheds/branches/apacheds-config/server-config/src/test/resources/dnsserver.ldif

Added: directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/DnsServerConfigReaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/DnsServerConfigReaderTest.java?rev=1026697&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/DnsServerConfigReaderTest.java
(added)
+++ directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/DnsServerConfigReaderTest.java
Sat Oct 23 22:06:13 2010
@@ -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.server.config;
+
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.server.config.beans.ConfigBean;
+import org.apache.directory.server.config.beans.DnsServerBean;
+import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
+import org.apache.directory.shared.ldap.name.DN;
+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.ldif.extractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.schema.registries.SchemaLoader;
+import org.apache.directory.shared.ldap.util.LdapExceptionUtils;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Test class for ConfigPartitionReader
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class DnsServerConfigReaderTest
+{
+    private static SchemaManager schemaManager;
+
+    private static File workDir = new File( System.getProperty( "java.io.tmpdir" ) + "/server-work"
);
+
+
+    @BeforeClass
+    public static void readConfig() throws Exception
+    {
+        FileUtils.deleteDirectory( workDir );
+        workDir.mkdir();
+
+        String workingDirectory = workDir.getPath();
+        // Extract the schema on disk (a brand new one) and load the registries
+        File schemaRepository = new File( workingDirectory, "schema" );
+        
+        if ( schemaRepository.exists() )
+        {
+            FileUtils.deleteDirectory( schemaRepository );
+        }
+
+        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory
) );
+        extractor.extractOrCopy();
+
+        SchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+        schemaManager = new DefaultSchemaManager( loader );
+
+        // We have to load the schema now, otherwise we won't be able
+        // to initialize the Partitions, as we won't be able to parse 
+        // and normalize their suffix DN
+        schemaManager.loadAllEnabled();
+
+        List<Throwable> errors = schemaManager.getErrors();
+
+        if ( errors.size() != 0 )
+        {
+            throw new Exception( "Schema load failed : " + LdapExceptionUtils.printErrors(
errors ) );
+        }
+    }
+
+
+    @Test
+    public void testNtpService() throws Exception
+    {
+        File configDir = new File( workDir, "dnsserver" ); // could be any directory, cause
the config is now in a single file
+        String configFile = LdifConfigExtractor.extractSingleFileConfig( configDir, "dnsserver.ldif",
true );
+
+        SingleFileLdifPartition configPartition = new SingleFileLdifPartition( configFile
);
+        configPartition.setId( "config" );
+        configPartition.setSuffix( new DN( "ou=config" ) );
+        configPartition.setSchemaManager( schemaManager );
+        
+        configPartition.initialize();
+        ConfigPartitionReader cpReader = new ConfigPartitionReader( configPartition, workDir
);
+        
+        ConfigBean configBean = cpReader.readConfig( new DN( "ou=servers,ads-directoryServiceId=default,ou=config"
), ConfigSchemaConstants.ADS_DNS_SERVER_OC.getValue() );
+
+        assertNotNull( configBean );
+        DnsServerBean dnsServerBean = (DnsServerBean)configBean.getDirectoryServiceBeans().get(
0 );
+        assertNotNull( dnsServerBean );
+    }
+}

Added: directory/apacheds/branches/apacheds-config/server-config/src/test/resources/dnsserver.ldif
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-config/server-config/src/test/resources/dnsserver.ldif?rev=1026697&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-config/server-config/src/test/resources/dnsserver.ldif
(added)
+++ directory/apacheds/branches/apacheds-config/server-config/src/test/resources/dnsserver.ldif
Sat Oct 23 22:06:13 2010
@@ -0,0 +1,82 @@
+version: 1
+dn: ou=config
+ou: config
+objectclass: top
+objectclass: organizationalUnit
+
+dn: ads-directoryServiceId=default,ou=config
+objectclass: top
+objectclass: ads-base
+objectclass: ads-directoryService
+ads-directoryserviceid: default
+ads-dsreplicaid: 1
+ads-dssyncperiodmillis: 15000
+ads-dsmaxpdusize: 2000000
+ads-dsallowanonymousaccess: true
+ads-dsaccesscontrolenabled: false
+ads-dsdenormalizeopattrsenabled: false
+ads-servers: changepasswordserver
+ads-servers: dns
+ads-servers: httpserver
+ads-servers: kerberos
+ads-servers: ldapserver
+ads-servers: ntp
+ads-partitions: example
+ads-partitions: system
+ads-interceptors: aciAuthorizationInterceptor
+ads-interceptors: authenticationInterceptor
+ads-interceptors: collectiveAttributeInterceptor
+ads-interceptors: defaultAuthorizationInterceptor
+ads-interceptors: eventInterceptor
+ads-interceptors: exceptionInterceptor
+ads-interceptors: keyderivationinterceptor
+ads-interceptors: normalizationInterceptor
+ads-interceptors: operationalAttributeInterceptor
+ads-interceptors: passwordpolicyinterceptor
+ads-interceptors: referralInterceptor
+ads-interceptors: schemaInterceptor
+ads-interceptors: subentryInterceptor
+ads-interceptors: triggerInterceptor
+ads-enabled: true
+
+dn: ou=servers,ads-directoryServiceId=default,ou=config
+ou: servers
+objectclass: organizationalUnit
+objectclass: top
+
+dn: ads-serverId=dnsServer,ou=servers,ads-directoryServiceId=default,ou=config
+objectclass: top
+objectclass: ads-base
+objectclass: ads-server
+objectclass: ads-dnsServer
+ads-serverId: dnsServer
+description: DNS server
+
+dn: ou=transports,ads-serverId=dnsServer,ou=servers,ads-directoryServiceId=default,ou=config
+ou: transports
+objectclass: organizationalUnit
+objectclass: top
+
+dn: ads-transportid=ntp-tcp,ou=transports,ads-serverId=dnsServer,ou=servers,ads-directoryServiceId=default,ou=config
+objectclass: top
+objectclass: ads-base
+objectclass: ads-transport
+objectclass: ads-tcpTransport
+ads-transportid: ntp-tcp
+ads-systemport: 123
+ads-transportenablessl: false
+ads-transportbacklog: 50
+ads-transportnbthreads: 8
+ads-transportaddress: 0.0.0.0
+ads-enabled: true
+
+dn: ads-transportid=ntp-udp,ou=transports,ads-serverId=dnsServer,ou=servers,ads-directoryServiceId=default,ou=config
+objectclass: top
+objectclass: ads-base
+objectclass: ads-transport
+objectclass: ads-udpTransport
+ads-transportid: ntp-udp
+ads-transportaddress: localhost
+ads-systemport: 456
+ads-transportenablessl: true
+ads-enabled: true



Mime
View raw message