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 2010/10/23 23:14:54 UTC
svn commit: r1026680 - in
/directory/apacheds/branches/apacheds-config/server-config/src:
main/java/org/apache/directory/server/config/beans/
test/java/org/apache/directory/server/config/ test/resources/
Author: elecharny
Date: Sat Oct 23 21:14:54 2010
New Revision: 1026680
URL: http://svn.apache.org/viewvc?rev=1026680&view=rev
Log:
o Added the code for DhcpServer config (test, and config file)
o Minor other fixes
Added:
directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/DhcpServerConfigReaderTest.java
directory/apacheds/branches/apacheds-config/server-config/src/test/resources/dhcpserver.ldif
Modified:
directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/DSBasedServerBean.java
directory/apacheds/branches/apacheds-config/server-config/src/test/resources/ntpserver.ldif
Modified: directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/DSBasedServerBean.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/DSBasedServerBean.java?rev=1026680&r1=1026679&r2=1026680&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/DSBasedServerBean.java (original)
+++ directory/apacheds/branches/apacheds-config/server-config/src/main/java/org/apache/directory/server/config/beans/DSBasedServerBean.java Sat Oct 23 21:14:54 2010
@@ -19,7 +19,6 @@
*/
package org.apache.directory.server.config.beans;
-import org.apache.directory.server.constants.ServerDNConstants;
/**
* A class used to store the KdcServer configuration.
@@ -34,7 +33,7 @@ public class DSBasedServerBean extends S
* configuration for catalog entries. Otherwise it will use this
* search base as a single point of searching the DIT.
*/
- private String searchbasedn = ServerDNConstants.USER_EXAMPLE_COM_DN;
+ private String searchbasedn;
/**
* Create a new JournalBean instance
@@ -70,7 +69,12 @@ public class DSBasedServerBean extends S
*/
public String toString( String tabs )
{
- return super.toString( tabs ) + tabs + "searchBaseDN : " + searchbasedn + "\n";
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( super.toString( tabs ) );
+ sb.append( toString( tabs, "searchBaseDN", searchbasedn ) );
+
+ return sb.toString();
}
Added: directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/DhcpServerConfigReaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/DhcpServerConfigReaderTest.java?rev=1026680&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/DhcpServerConfigReaderTest.java (added)
+++ directory/apacheds/branches/apacheds-config/server-config/src/test/java/org/apache/directory/server/config/DhcpServerConfigReaderTest.java Sat Oct 23 21:14:54 2010
@@ -0,0 +1,141 @@
+/*
+ * 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.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+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.core.DirectoryService;
+import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
+import org.apache.directory.server.ldap.LdapServer;
+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.AfterClass;
+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 DhcpServerConfigReaderTest
+{
+
+ private static DirectoryService dirService;
+
+ private static LdapServer server;
+
+ private static SchemaManager schemaManager;
+
+
+ @BeforeClass
+ public static void readConfig() throws Exception
+ {
+ File workDir = new File( System.getProperty( "java.io.tmpdir" ) + "/server-work" );
+ 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 ) );
+ }
+
+ File configDir = new File( workDir, "dhcpserver" ); // could be any directory, cause the config is now in a single file
+
+ String configFile = LdifConfigExtractor.extractSingleFileConfig( configDir, "dhcpserver.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_DHCP_SERVER_OC.getValue() );
+ }
+
+
+ @AfterClass
+ public static void cleanup() throws Exception
+ {
+ server.stop();
+ dirService.shutdown();
+ }
+
+
+ @Test
+ public void testDirService()
+ {
+ assertTrue( dirService.isStarted() );
+ assertEquals( "default", dirService.getInstanceId() );
+ }
+
+
+ @Test
+ public void testLdapServer()
+ {
+ assertTrue( server.isStarted() );
+ assertEquals( dirService, server.getDirectoryService() );
+ }
+}
Added: directory/apacheds/branches/apacheds-config/server-config/src/test/resources/dhcpserver.ldif
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-config/server-config/src/test/resources/dhcpserver.ldif?rev=1026680&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-config/server-config/src/test/resources/dhcpserver.ldif (added)
+++ directory/apacheds/branches/apacheds-config/server-config/src/test/resources/dhcpserver.ldif Sat Oct 23 21:14:54 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=dhcpServer,ou=servers,ads-directoryServiceId=default,ou=config
+objectclass: top
+objectclass: ads-base
+objectclass: ads-server
+objectclass: ads-dhcpServer
+ads-serverId: dhcpServer
+description: DHCP server
+
+dn: ou=transports,ads-serverId=dhcpServer,ou=servers,ads-directoryServiceId=default,ou=config
+ou: transports
+objectclass: organizationalUnit
+objectclass: top
+
+dn: ads-transportid=ntp-tcp,ou=transports,ads-serverId=dhcpServer,ou=servers,ads-directoryServiceId=default,ou=config
+objectclass: top
+objectclass: ads-base
+objectclass: ads-transport
+objectclass: ads-tcpTransport
+ads-transportid: ntp-tcp
+ads-transportaddress: 0.0.0.0
+ads-systemport: 123
+ads-transportenablessl: false
+ads-transportbacklog: 50
+ads-transportnbthreads: 8
+ads-enabled: true
+
+dn: ads-transportid=ntp-udp,ou=transports,ads-serverId=dhcpServer,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
Modified: directory/apacheds/branches/apacheds-config/server-config/src/test/resources/ntpserver.ldif
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-config/server-config/src/test/resources/ntpserver.ldif?rev=1026680&r1=1026679&r2=1026680&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-config/server-config/src/test/resources/ntpserver.ldif (original)
+++ directory/apacheds/branches/apacheds-config/server-config/src/test/resources/ntpserver.ldif Sat Oct 23 21:14:54 2010
@@ -44,33 +44,33 @@ ou: servers
objectclass: organizationalUnit
objectclass: top
-dn: ads-serverId=ldapServer,ou=servers,ads-directoryServiceId=default,ou=config
+dn: ads-serverId=ntpServer,ou=servers,ads-directoryServiceId=default,ou=config
objectclass: top
objectclass: ads-base
objectclass: ads-server
objectclass: ads-ntpServer
ads-serverId: ntpServer
-description: NTP Server
+description: NTP server
-dn: ou=transports,ads-serverId=ldapServer,ou=servers,ads-directoryServiceId=default,ou=config
+dn: ou=transports,ads-serverId=ntpServer,ou=servers,ads-directoryServiceId=default,ou=config
ou: transports
objectclass: organizationalUnit
objectclass: top
-dn: ads-transportid=ntp-tcp,ou=transports,ads-serverId=ldapServer,ou=servers,ads-directoryServiceId=default,ou=config
+dn: ads-transportid=ntp-tcp,ou=transports,ads-serverId=ntpServer,ou=servers,ads-directoryServiceId=default,ou=config
objectclass: top
objectclass: ads-base
objectclass: ads-transport
objectclass: ads-tcpTransport
ads-transportid: ntp-tcp
-ads-transportaddress: 0.0.0.0
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=ldapServer,ou=servers,ads-directoryServiceId=default,ou=config
+dn: ads-transportid=ntp-udp,ou=transports,ads-serverId=ntpServer,ou=servers,ads-directoryServiceId=default,ou=config
objectclass: top
objectclass: ads-base
objectclass: ads-transport