From commits-return-15738-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Sat Oct 06 06:50:22 2007 Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 24842 invoked from network); 6 Oct 2007 06:50:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Oct 2007 06:50:10 -0000 Received: (qmail 36740 invoked by uid 500); 6 Oct 2007 06:49:58 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 36658 invoked by uid 500); 6 Oct 2007 06:49:58 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 36468 invoked by uid 99); 6 Oct 2007 06:49:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Oct 2007 23:49:58 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Oct 2007 06:49:57 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 964C91A9859; Fri, 5 Oct 2007 23:49:07 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r582462 [9/10] - in /directory: apacheds/branches/bigbang/ apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/ apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/ apacheds... Date: Sat, 06 Oct 2007 06:48:45 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071006064907.964C91A9859@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/diagnosticcmd/DiagnosticCommandExecutor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/diagnosticcmd/DiagnosticCommandExecutor.java?rev=582462&r1=582461&r2=582462&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/diagnosticcmd/DiagnosticCommandExecutor.java (original) +++ directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/diagnosticcmd/DiagnosticCommandExecutor.java Fri Oct 5 23:48:35 2007 @@ -20,16 +20,7 @@ package org.apache.directory.server.tools.commands.diagnosticcmd; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Map; - -import javax.naming.ldap.InitialLdapContext; -import javax.naming.ldap.LdapContext; - -import org.apache.directory.server.configuration.ServerStartupConfiguration; +import org.apache.directory.server.configuration.ApacheDS; import org.apache.directory.server.tools.ToolCommandListener; import org.apache.directory.server.tools.execution.BaseToolCommandExecutor; import org.apache.directory.server.tools.util.ListenerParameter; @@ -39,6 +30,14 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; +import javax.naming.ldap.InitialLdapContext; +import javax.naming.ldap.LdapContext; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; + /** * This is the Executor Class of the Diagnostic Command. @@ -135,21 +134,21 @@ Boolean quietParam = ( Boolean ) parameters.get( QUIET_PARAMETER ); if ( quietParam != null ) { - setQuietEnabled( quietParam.booleanValue() ); + setQuietEnabled( quietParam ); } // Debug param Boolean debugParam = ( Boolean ) parameters.get( DEBUG_PARAMETER ); if ( debugParam != null ) { - setDebugEnabled( debugParam.booleanValue() ); + setDebugEnabled( debugParam ); } // Verbose param Boolean verboseParam = ( Boolean ) parameters.get( VERBOSE_PARAMETER ); if ( verboseParam != null ) { - setVerboseEnabled( verboseParam.booleanValue() ); + setVerboseEnabled( verboseParam ); } // Install-path param @@ -163,12 +162,9 @@ { notifyOutputListener( "loading settings from: " + getLayout().getConfigurationFile() ); } - ApplicationContext factory = null; - URL configUrl; - - configUrl = getLayout().getConfigurationFile().toURI().toURL(); - factory = new FileSystemXmlApplicationContext( configUrl.toString() ); - setConfiguration( ( ServerStartupConfiguration ) factory.getBean( "configuration" ) ); + URL configUrl = getLayout().getConfigurationFile().toURI().toURL(); + ApplicationContext factory = new FileSystemXmlApplicationContext( configUrl.toString() ); + setApacheDS( ( ApacheDS ) factory.getBean( "apacheDS" ) ); } catch ( MalformedURLException e ) { @@ -197,11 +193,11 @@ Integer portParam = ( Integer ) parameters.get( PORT_PARAMETER ); if ( portParam != null ) { - port = portParam.intValue(); + port = portParam; } - else if ( getConfiguration() != null ) + else if ( getApacheDS() != null ) { - port = getConfiguration().getLdapConfiguration().getIpPort(); + port = getApacheDS().getLdapConfiguration().getIpPort(); if ( isDebugEnabled() ) { Modified: directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/disconnectnotificationcmd/DisconnectNotificationCommandExecutor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/disconnectnotificationcmd/DisconnectNotificationCommandExecutor.java?rev=582462&r1=582461&r2=582462&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/disconnectnotificationcmd/DisconnectNotificationCommandExecutor.java (original) +++ directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/disconnectnotificationcmd/DisconnectNotificationCommandExecutor.java Fri Oct 5 23:48:35 2007 @@ -20,22 +20,7 @@ package org.apache.directory.server.tools.commands.disconnectnotificationcmd; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Map; - -import javax.naming.directory.SearchControls; -import javax.naming.event.EventContext; -import javax.naming.event.NamingExceptionEvent; -import javax.naming.ldap.InitialLdapContext; -import javax.naming.ldap.LdapContext; -import javax.naming.ldap.UnsolicitedNotification; -import javax.naming.ldap.UnsolicitedNotificationEvent; -import javax.naming.ldap.UnsolicitedNotificationListener; - -import org.apache.directory.server.configuration.ServerStartupConfiguration; +import org.apache.directory.server.configuration.ApacheDS; import org.apache.directory.server.tools.ToolCommandListener; import org.apache.directory.server.tools.execution.BaseToolCommandExecutor; import org.apache.directory.server.tools.util.ListenerParameter; @@ -47,6 +32,16 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; +import javax.naming.directory.SearchControls; +import javax.naming.event.EventContext; +import javax.naming.event.NamingExceptionEvent; +import javax.naming.ldap.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; + /** * This is the Executor Class of the Disconnect Notification Command. @@ -60,9 +55,9 @@ public static final String BINDDN_PARAMETER = "bindDN"; private String bindDN; - public final static String DEFAULT_BINDDN = "uid=admin,ou=system"; + public static final String DEFAULT_BINDDN = "uid=admin,ou=system"; UnsolicitedNotification notification; - boolean canceled = false; + boolean canceled; public DisconnectNotificationCommandExecutor() @@ -131,6 +126,7 @@ notifyOutputListener( "Listening for notifications." ); notifyOutputListener( "Press any key to terminate." ); + //noinspection ResultOfMethodCallIgnored System.in.read(); ctx.close(); notifyOutputListener( "Process terminated!!!" ); @@ -140,10 +136,9 @@ private void processParameters( Parameter[] params ) { Map parameters = new HashMap(); - - for ( int i = 0; i < params.length; i++ ) + + for ( Parameter parameter : params ) { - Parameter parameter = params[i]; parameters.put( parameter.getName(), parameter.getValue() ); } @@ -151,21 +146,21 @@ Boolean quietParam = ( Boolean ) parameters.get( QUIET_PARAMETER ); if ( quietParam != null ) { - setQuietEnabled( quietParam.booleanValue() ); + setQuietEnabled( quietParam ); } // Debug param Boolean debugParam = ( Boolean ) parameters.get( DEBUG_PARAMETER ); if ( debugParam != null ) { - setDebugEnabled( debugParam.booleanValue() ); + setDebugEnabled( debugParam ); } // Verbose param Boolean verboseParam = ( Boolean ) parameters.get( VERBOSE_PARAMETER ); if ( verboseParam != null ) { - setVerboseEnabled( verboseParam.booleanValue() ); + setVerboseEnabled( verboseParam ); } // Install-path param @@ -179,12 +174,10 @@ { notifyOutputListener( "loading settings from: " + getLayout().getConfigurationFile() ); } - ApplicationContext factory = null; - URL configUrl; - - configUrl = getLayout().getConfigurationFile().toURI().toURL(); - factory = new FileSystemXmlApplicationContext( configUrl.toString() ); - setConfiguration( ( ServerStartupConfiguration ) factory.getBean( "configuration" ) ); + + URL configUrl = getLayout().getConfigurationFile().toURI().toURL(); + ApplicationContext factory = new FileSystemXmlApplicationContext( configUrl.toString() ); + setApacheDS( ( ApacheDS ) factory.getBean( "apacheDS" ) ); } catch ( MalformedURLException e ) { @@ -213,11 +206,11 @@ Integer portParam = ( Integer ) parameters.get( PORT_PARAMETER ); if ( portParam != null ) { - port = portParam.intValue(); + port = portParam; } - else if ( getConfiguration() != null ) + else if ( getApacheDS() != null ) { - port = getConfiguration().getLdapConfiguration().getIpPort(); + port = getApacheDS().getLdapConfiguration().getIpPort(); if ( isDebugEnabled() ) { @@ -327,7 +320,8 @@ // TODO Auto-generated catch block de.printStackTrace(); } - + + assert gd != null; notifyOutputListener( "LDAP server will shutdown in " + gd.getDelay() + " seconds." ); notifyOutputListener( "LDAP server will be back online in " + gd.getTimeOffline() + " minutes." ); @@ -377,6 +371,7 @@ } catch ( InterruptedException e ) { + e.printStackTrace(); } notifyOutputListener( "." ); } @@ -389,7 +384,6 @@ { notifyOutputListener( "]" ); notifyOutputListener( "Client shutting down gracefully." ); - return; } } } Modified: directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/dumpcmd/DumpCommandExecutor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/dumpcmd/DumpCommandExecutor.java?rev=582462&r1=582461&r2=582462&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/dumpcmd/DumpCommandExecutor.java (original) +++ directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/dumpcmd/DumpCommandExecutor.java Fri Oct 5 23:48:35 2007 @@ -23,21 +23,15 @@ import jdbm.helper.MRU; import jdbm.recman.BaseRecordManager; import jdbm.recman.CacheRecordManager; -import org.apache.directory.server.configuration.MutableServerStartupConfiguration; -import org.apache.directory.server.configuration.ServerStartupConfiguration; +import org.apache.directory.server.configuration.ApacheDS; +import org.apache.directory.server.core.DefaultDirectoryService; import org.apache.directory.server.core.DirectoryService; -import org.apache.directory.server.core.DirectoryServiceConfiguration; -import org.apache.directory.server.core.DirectoryServiceListener; -import org.apache.directory.server.core.configuration.StartupConfiguration; -import org.apache.directory.server.core.interceptor.InterceptorChain; -import org.apache.directory.server.core.partition.PartitionNexus; import org.apache.directory.server.core.partition.impl.btree.Index; import org.apache.directory.server.core.partition.impl.btree.Tuple; import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex; import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmMasterTable; import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition; import org.apache.directory.server.core.schema.PartitionSchemaLoader; -import org.apache.directory.server.core.schema.SchemaManager; import org.apache.directory.server.schema.SerializableComparator; import org.apache.directory.server.schema.bootstrap.*; import org.apache.directory.server.schema.bootstrap.partition.DbFileListing; @@ -88,7 +82,7 @@ private Registries bootstrapRegistries = new DefaultRegistries( "bootstrap", new BootstrapSchemaLoader(), new DefaultOidRegistry() ); private Set exclusions = new HashSet(); - private boolean includeOperational = false; + private boolean includeOperational; private String outputFile; private String[] partitions; private String[] excludedAttributes; @@ -193,7 +187,7 @@ schemaPartition.setId( "schema" ); schemaPartition.setCacheSize( 1000 ); - DbFileListing listing = null; + DbFileListing listing; try { listing = new DbFileListing(); @@ -218,60 +212,8 @@ entry.put( SchemaConstants.OU_AT, "schema" ); schemaPartition.setContextEntry( entry ); - DirectoryServiceConfiguration dsc = new DirectoryServiceConfiguration() - { - public Hashtable getEnvironment() - { - return null; - } - - public String getInstanceId() - { - return "1"; - } - - public InterceptorChain getInterceptorChain() - { - return null; - } - - public PartitionNexus getPartitionNexus() - { - return null; - } - - public Registries getRegistries() - { - return registries; - } - - public SchemaManager getSchemaManager() - { - return null; - } - - public DirectoryService getService() - { - return null; - } - - public DirectoryServiceListener getServiceListener() - { - return null; - } - - public StartupConfiguration getStartupConfiguration() - { - return getConfiguration(); - } - - public boolean isFirstStart() - { - return false; - } - }; - - schemaPartition.init( dsc ); + DirectoryService directoryService = new DefaultDirectoryService(); + schemaPartition.init( directoryService ); // -------------------------------------------------------------------- // Initialize schema subsystem and reset registries @@ -291,13 +233,13 @@ bootstrapRegistries = loadRegistries(); - PrintWriter out = null; + PrintWriter out; if ( excludedAttributes != null ) { AttributeTypeRegistry registry = bootstrapRegistries.getAttributeTypeRegistry(); - for ( int ii = 0; ii < excludedAttributes.length; ii++ ) + for ( String excludedAttribute : excludedAttributes ) { - AttributeType type = registry.lookup( excludedAttributes[ii] ); + AttributeType type = registry.lookup( excludedAttribute ); exclusions.add( type.getName() ); } } @@ -310,10 +252,10 @@ { out = new PrintWriter( new FileWriter( outputFile ) ); } - - for ( int ii = 0; ii < partitions.length; ii++ ) + + for ( String partition : partitions ) { - File partitionDirectory = new File( getLayout().getPartitionsDirectory(), partitions[ii] ); + File partitionDirectory = new File( getLayout().getPartitionsDirectory(), partition ); out.println( "\n\n" ); dump( partitionDirectory, out ); } @@ -323,9 +265,8 @@ private void processParameters( Parameter[] params ) { Map parameters = new HashMap(); - for ( int i = 0; i < params.length; i++ ) + for ( Parameter parameter : params ) { - Parameter parameter = params[i]; parameters.put( parameter.getName(), parameter.getValue() ); } @@ -333,21 +274,21 @@ Boolean quietParam = ( Boolean ) parameters.get( QUIET_PARAMETER ); if ( quietParam != null ) { - setQuietEnabled( quietParam.booleanValue() ); + setQuietEnabled( quietParam ); } // Debug param Boolean debugParam = ( Boolean ) parameters.get( DEBUG_PARAMETER ); if ( debugParam != null ) { - setDebugEnabled( debugParam.booleanValue() ); + setDebugEnabled( debugParam ); } // Verbose param Boolean verboseParam = ( Boolean ) parameters.get( VERBOSE_PARAMETER ); if ( verboseParam != null ) { - setVerboseEnabled( verboseParam.booleanValue() ); + setVerboseEnabled( verboseParam ); } // Install-path param @@ -361,14 +302,12 @@ { notifyOutputListener( "loading settings from: " + getLayout().getConfigurationFile() ); } - ApplicationContext factory = null; - URL configUrl; - configUrl = getLayout().getConfigurationFile().toURI().toURL(); - factory = new FileSystemXmlApplicationContext( configUrl.toString() ); - setConfiguration( ( ServerStartupConfiguration ) factory.getBean( "configuration" ) ); - MutableServerStartupConfiguration msc = ( MutableServerStartupConfiguration ) getConfiguration(); - msc.setWorkingDirectory( getLayout().getPartitionsDirectory() ); + URL configUrl = getLayout().getConfigurationFile().toURI().toURL(); + ApplicationContext factory = new FileSystemXmlApplicationContext( configUrl.toString() ); + ApacheDS apacheDS = ( ApacheDS ) factory.getBean( "apacheDS" ); + setApacheDS( apacheDS ); + apacheDS.getDirectoryService().setWorkingDirectory( getLayout().getPartitionsDirectory() ); } catch ( MalformedURLException e ) { @@ -402,7 +341,7 @@ Boolean includeOperationalParam = ( Boolean ) parameters.get( INCLUDEOPERATIONAL_PARAMETER ); if ( includeOperationalParam != null ) { - includeOperational = includeOperationalParam.booleanValue(); + includeOperational = includeOperationalParam; } } @@ -410,9 +349,8 @@ private void processListeners( ListenerParameter[] listeners ) { Map parameters = new HashMap(); - for ( int i = 0; i < listeners.length; i++ ) + for ( ListenerParameter parameter : listeners ) { - ListenerParameter parameter = listeners[i]; parameters.put( parameter.getName(), parameter.getListener() ); } @@ -525,9 +463,8 @@ toRemove.add( attr.getID() ); } } - for ( int ii = 0; ii < toRemove.size(); ii++ ) + for ( String id : toRemove ) { - String id = toRemove.get( ii ); entry.remove( id ); if ( isDebugEnabled() ) { Modified: directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/exportcmd/ExportCommandExecutor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/exportcmd/ExportCommandExecutor.java?rev=582462&r1=582461&r2=582462&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/exportcmd/ExportCommandExecutor.java (original) +++ directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/exportcmd/ExportCommandExecutor.java Fri Oct 5 23:48:35 2007 @@ -20,30 +20,8 @@ package org.apache.directory.server.tools.commands.exportcmd; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.Serializable; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Collection; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Map; -import java.util.Set; - -import javax.naming.Context; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attribute; -import javax.naming.directory.Attributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.InitialDirContext; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - import org.apache.commons.collections.map.MultiValueMap; -import org.apache.directory.server.configuration.ServerStartupConfiguration; +import org.apache.directory.server.configuration.ApacheDS; import org.apache.directory.server.tools.ToolCommandListener; import org.apache.directory.server.tools.execution.BaseToolCommandExecutor; import org.apache.directory.server.tools.util.ListenerParameter; @@ -55,6 +33,18 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; +import javax.naming.Context; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.*; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.Serializable; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.*; + /** * This is the Executor Class of the Export Command. @@ -262,7 +252,7 @@ while ( attributesEnumeration.hasMoreElements() ) { Attribute attr = ( Attribute ) attributesEnumeration.nextElement(); - NamingEnumeration e2 = null; + NamingEnumeration e2; e2 = attr.getAll(); @@ -282,7 +272,7 @@ if ( entriesCounter % 10 == 0 ) { - notifyOutputListener( new Character( '.' ) ); + notifyOutputListener( '.' ); } if ( entriesCounter % 500 == 0 ) @@ -304,8 +294,9 @@ /** * Gets and returns the entries from the server. - * @throws ToolCommandException - * @throws NamingException + * + * @throws ToolCommandException if there is a problem connecting + * @return the entries */ public NamingEnumeration connectToServerAndGetEntries() throws ToolCommandException { @@ -365,21 +356,21 @@ Boolean quietParam = ( Boolean ) parameters.get( QUIET_PARAMETER ); if ( quietParam != null ) { - setQuietEnabled( quietParam.booleanValue() ); + setQuietEnabled( quietParam ); } // Debug param Boolean debugParam = ( Boolean ) parameters.get( DEBUG_PARAMETER ); if ( debugParam != null ) { - setDebugEnabled( debugParam.booleanValue() ); + setDebugEnabled( debugParam ); } // Verbose param Boolean verboseParam = ( Boolean ) parameters.get( VERBOSE_PARAMETER ); if ( verboseParam != null ) { - setVerboseEnabled( verboseParam.booleanValue() ); + setVerboseEnabled( verboseParam ); } // Install-path param @@ -393,12 +384,10 @@ { notifyOutputListener( "loading settings from: " + getLayout().getConfigurationFile() ); } - ApplicationContext factory = null; - URL configUrl; - configUrl = getLayout().getConfigurationFile().toURI().toURL(); - factory = new FileSystemXmlApplicationContext( configUrl.toString() ); - setConfiguration( ( ServerStartupConfiguration ) factory.getBean( "configuration" ) ); + URL configUrl = getLayout().getConfigurationFile().toURI().toURL(); + ApplicationContext factory = new FileSystemXmlApplicationContext( configUrl.toString() ); + setApacheDS( ( ApacheDS ) factory.getBean( "apacheDS" ) ); } catch ( MalformedURLException e ) { @@ -427,11 +416,11 @@ Integer portParam = ( Integer ) parameters.get( PORT_PARAMETER ); if ( portParam != null ) { - port = portParam.intValue(); + port = portParam; } - else if ( getConfiguration() != null ) + else if ( getApacheDS() != null ) { - port = getConfiguration().getLdapConfiguration().getIpPort(); + port = getApacheDS().getLdapConfiguration().getIpPort(); if ( isDebugEnabled() ) { Modified: directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/gracefulshutdowncmd/GracefulShutdownCommandExecutor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/gracefulshutdowncmd/GracefulShutdownCommandExecutor.java?rev=582462&r1=582461&r2=582462&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/gracefulshutdowncmd/GracefulShutdownCommandExecutor.java (original) +++ directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/gracefulshutdowncmd/GracefulShutdownCommandExecutor.java Fri Oct 5 23:48:35 2007 @@ -20,17 +20,7 @@ package org.apache.directory.server.tools.commands.gracefulshutdowncmd; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Map; - -import javax.naming.CommunicationException; -import javax.naming.ldap.InitialLdapContext; -import javax.naming.ldap.LdapContext; - -import org.apache.directory.server.configuration.ServerStartupConfiguration; +import org.apache.directory.server.configuration.ApacheDS; import org.apache.directory.server.tools.ToolCommandListener; import org.apache.directory.server.tools.execution.BaseToolCommandExecutor; import org.apache.directory.server.tools.util.ListenerParameter; @@ -41,6 +31,15 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; +import javax.naming.CommunicationException; +import javax.naming.ldap.InitialLdapContext; +import javax.naming.ldap.LdapContext; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; + /** * This is the Executor Class of the GracefulShutdown Command. @@ -58,8 +57,8 @@ private int timeOffline; private boolean isWaiting; - private boolean isSuccess = false; - private Thread executeThread = null; + private boolean isSuccess; + private Thread executeThread; public GracefulShutdownCommandExecutor() @@ -186,7 +185,7 @@ if ( quietParam != null ) { - setQuietEnabled( quietParam.booleanValue() ); + setQuietEnabled( quietParam ); } // Debug param @@ -194,7 +193,7 @@ if ( debugParam != null ) { - setDebugEnabled( debugParam.booleanValue() ); + setDebugEnabled( debugParam ); } // Verbose param @@ -202,7 +201,7 @@ if ( verboseParam != null ) { - setVerboseEnabled( verboseParam.booleanValue() ); + setVerboseEnabled( verboseParam ); } // Install-path param @@ -217,12 +216,10 @@ { notifyOutputListener( "loading settings from: " + getLayout().getConfigurationFile() ); } - ApplicationContext factory = null; - URL configUrl; - configUrl = getLayout().getConfigurationFile().toURI().toURL(); - factory = new FileSystemXmlApplicationContext( configUrl.toString() ); - setConfiguration( ( ServerStartupConfiguration ) factory.getBean( "configuration" ) ); + URL configUrl = getLayout().getConfigurationFile().toURI().toURL(); + ApplicationContext factory = new FileSystemXmlApplicationContext( configUrl.toString() ); + setApacheDS( ( ApacheDS ) factory.getBean( "apacheDS" ) ); } catch ( MalformedURLException e ) { @@ -253,11 +250,11 @@ if ( portParam != null ) { - port = portParam.intValue(); + port = portParam; } - else if ( getConfiguration() != null ) + else if ( getApacheDS() != null ) { - port = getConfiguration().getLdapConfiguration().getIpPort(); + port = getApacheDS().getLdapConfiguration().getIpPort(); if ( isDebugEnabled() ) { @@ -296,7 +293,7 @@ if ( delayParam != null ) { - delay = delayParam.intValue(); + delay = delayParam; } else { @@ -313,7 +310,7 @@ if ( timeOfflineParam != null ) { - timeOffline = timeOfflineParam.intValue(); + timeOffline = timeOfflineParam; } else { @@ -392,7 +389,6 @@ { e.printStackTrace(); } - return; } else { @@ -406,8 +402,8 @@ { e.printStackTrace(); } + //noinspection ThrowableInstanceNeverThrown notifyExceptionListener( new ToolCommandException( "Shutdown failed" ) ); - return; } } } Modified: directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/importcmd/ImportCommandExecutor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/importcmd/ImportCommandExecutor.java?rev=582462&r1=582461&r2=582462&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/importcmd/ImportCommandExecutor.java (original) +++ directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/importcmd/ImportCommandExecutor.java Fri Oct 5 23:48:35 2007 @@ -20,28 +20,7 @@ package org.apache.directory.server.tools.commands.importcmd; -import java.io.File; -import java.io.IOException; -import java.io.Serializable; -import java.net.InetSocketAddress; -import java.net.MalformedURLException; -import java.net.SocketAddress; -import java.net.URL; -import java.net.UnknownHostException; -import java.nio.ByteBuffer; -import java.nio.channels.SocketChannel; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import javax.naming.InvalidNameException; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attribute; -import javax.naming.directory.Attributes; -import javax.naming.directory.DirContext; - -import org.apache.directory.server.configuration.ServerStartupConfiguration; +import org.apache.directory.server.configuration.ApacheDS; import org.apache.directory.server.tools.ToolCommandListener; import org.apache.directory.server.tools.execution.BaseToolCommandExecutor; import org.apache.directory.server.tools.util.ListenerParameter; @@ -52,11 +31,7 @@ import org.apache.directory.shared.asn1.ber.tlv.TLVStateEnum; import org.apache.directory.shared.asn1.codec.DecoderException; import org.apache.directory.shared.asn1.codec.EncoderException; -import org.apache.directory.shared.ldap.codec.LdapConstants; -import org.apache.directory.shared.ldap.codec.LdapDecoder; -import org.apache.directory.shared.ldap.codec.LdapMessage; -import org.apache.directory.shared.ldap.codec.LdapMessageContainer; -import org.apache.directory.shared.ldap.codec.LdapResult; +import org.apache.directory.shared.ldap.codec.*; import org.apache.directory.shared.ldap.codec.add.AddRequest; import org.apache.directory.shared.ldap.codec.bind.BindRequest; import org.apache.directory.shared.ldap.codec.bind.BindResponse; @@ -78,6 +53,22 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; +import javax.naming.InvalidNameException; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.DirContext; +import java.io.File; +import java.io.IOException; +import java.io.Serializable; +import java.net.*; +import java.nio.ByteBuffer; +import java.nio.channels.SocketChannel; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + /** * This is the Executor Class of the Import Command. @@ -96,9 +87,7 @@ private File ldifFile; - private String logs; - - private boolean ignoreErrors = false; + private boolean ignoreErrors; private static final int IMPORT_ERROR = -1; @@ -109,8 +98,6 @@ */ private SocketChannel channel; - private SocketAddress serverAddress; - private IAsn1Container ldapMessageContainer = new LdapMessageContainer(); private Asn1Decoder ldapDecoder = new LdapDecoder(); @@ -131,14 +118,12 @@ * Output Streams. All the required information for the connection should be * in the options from the command line, or the default values. * - * @throws UnknownHostException - * The hostname or the Address of server could not be found - * @throws IOException - * There was a error opening or establishing the socket + * @throws UnknownHostException the hostname or the Address of server could not be found + * @throws IOException there was a error opening or establishing the socket */ - private void connect() throws UnknownHostException, IOException + private void connect() throws IOException { - serverAddress = new InetSocketAddress( host, port ); + SocketAddress serverAddress = new InetSocketAddress( host, port ); channel = SocketChannel.open( serverAddress ); channel.configureBlocking( true ); } @@ -213,12 +198,15 @@ * Send the entry to the encoder, then wait for a * reponse from the LDAP server on the results of the operation. * - * @param entry - * The entry to add - * @param msgId - * message id number + * @param entry the entry to add + * @param messageId message id number + * @return ?? + * @throws IOException ?? + * @throws DecoderException ?? + * @throws NamingException ?? + * @throws EncoderException ?? */ - private int addEntry( Entry entry, int messageId ) throws IOException, DecoderException, InvalidNameException, + private int addEntry( Entry entry, int messageId ) throws IOException, DecoderException, NamingException, EncoderException { AddRequest addRequest = new AddRequest(); @@ -291,12 +279,15 @@ * Send the entry to the encoder, then wait for a * reponse from the LDAP server on the results of the operation. * - * @param entry - * The entry to delete - * @param msgId - * message id number + * @param entry the entry to delete + * @param messageId message id number + * @return ??? + * @throws IOException ??? + * @throws DecoderException ?? + * @throws NamingException ?? + * @throws EncoderException ?? */ - private int deleteEntry( Entry entry, int messageId ) throws IOException, DecoderException, InvalidNameException, + private int deleteEntry( Entry entry, int messageId ) throws IOException, DecoderException, NamingException, EncoderException { DelRequest delRequest = new DelRequest(); @@ -350,13 +341,16 @@ * Send the entry to the encoder, then wait for a * reponse from the LDAP server on the results of the operation. * - * @param entry - * The entry to modify - * @param msgId - * message id number + * @param entry the entry to modify + * @param messageId message id number + * @return ?? + * @throws IOException ?? + * @throws InvalidNameException ?? + * @throws DecoderException ?? + * @throws EncoderException ?? */ private int changeModRDNEntry( Entry entry, int messageId ) throws IOException, DecoderException, - InvalidNameException, NamingException, EncoderException + NamingException, EncoderException { ModifyDNRequest modifyDNRequest = new ModifyDNRequest(); @@ -371,7 +365,7 @@ modifyDNRequest.setDeleteOldRDN( entry.isDeleteOldRdn() ); modifyDNRequest.setNewRDN( new Rdn( entry.getNewRdn() ) ); - if ( StringTools.isEmpty( entry.getNewSuperior() ) == false ) + if ( ! StringTools.isEmpty( entry.getNewSuperior() ) ) { modifyDNRequest.setNewSuperior( new LdapDN( entry.getNewSuperior() ) ); } @@ -416,13 +410,16 @@ * Send the entry to the encoder, then wait for a * reponse from the LDAP server on the results of the operation. * - * @param entry - * The entry to modify - * @param msgId - * message id number + * @param entry the entry to modify + * @param messageId message id number + * @return ?? + * @throws IOException ?? + * @throws NamingException ?? + * @throws DecoderException ?? + * @throws EncoderException ?? */ private int changeModifyEntry( Entry entry, int messageId ) throws IOException, DecoderException, - InvalidNameException, NamingException, EncoderException + NamingException, EncoderException { ModifyRequest modifyRequest = new ModifyRequest(); @@ -436,13 +433,9 @@ modifyRequest.setObject( new LdapDN( dn ) ); modifyRequest.initModifications(); - Iterator modifications = entry.getModificationItems().iterator(); - - while ( modifications.hasNext() ) + for ( ModificationItemImpl modificationItem : entry.getModificationItems() ) { - ModificationItemImpl modification = ( ModificationItemImpl ) modifications.next(); - - switch ( modification.getModificationOp() ) + switch ( modificationItem.getModificationOp() ) { case DirContext.ADD_ATTRIBUTE: modifyRequest.setCurrentOperation( LdapConstants.OPERATION_ADD ); @@ -460,9 +453,9 @@ notifyErrorListener( "Unknown modify operation for DN " + dn ); } - modifyRequest.addAttributeTypeAndValues( modification.getAttribute().getID() ); + modifyRequest.addAttributeTypeAndValues( modificationItem.getAttribute().getID() ); - for ( NamingEnumeration values = modification.getAttribute().getAll(); values.hasMoreElements(); ) + for ( NamingEnumeration values = modificationItem.getAttribute().getAll(); values.hasMoreElements(); ) { Object value = values.nextElement(); modifyRequest.addAttributeValue( value ); @@ -509,13 +502,16 @@ * Send the change operation to the encoder, then wait for a * reponse from the LDAP server on the results of the operation. * - * @param entry - * The entry to add - * @param msgId - * message id number + * @param entry the entry to add + * @param messageId message id number + * @return ?? + * @throws IOException ?? + * @throws NamingException ?? + * @throws DecoderException ?? + * @throws EncoderException ?? */ - private int changeEntry( Entry entry, int messageId ) throws IOException, DecoderException, InvalidNameException, - NamingException, EncoderException + private int changeEntry( Entry entry, int messageId ) throws IOException, DecoderException, + NamingException, EncoderException { switch ( entry.getChangeType().getChangeType() ) { @@ -543,7 +539,11 @@ * Bind to the ldap server * * @param messageId The message Id - * @throws NamingException + * @throws NamingException ?? + * @throws IOException ?? + * @throws ToolCommandException ?? + * @throws DecoderException ?? + * @throws EncoderException ?? */ private void bind( int messageId ) throws EncoderException, DecoderException, IOException, ToolCommandException, NamingException @@ -600,12 +600,9 @@ /** * Unbind from the server * - * @param messageId - * The message Id - * @throws InvalidNameException - * @throws EncoderException - * @throws DecoderException - * @throws IOException + * @param messageId the message Id + * @throws EncoderException ?? + * @throws IOException ?? */ private void unbind( int messageId ) throws EncoderException, IOException { @@ -640,7 +637,7 @@ if ( quietParam != null ) { - setQuietEnabled( quietParam.booleanValue() ); + setQuietEnabled( quietParam ); } // Debug param @@ -648,7 +645,7 @@ if ( debugParam != null ) { - setDebugEnabled( debugParam.booleanValue() ); + setDebugEnabled( debugParam ); } // Verbose param @@ -656,7 +653,7 @@ if ( verboseParam != null ) { - setVerboseEnabled( verboseParam.booleanValue() ); + setVerboseEnabled( verboseParam ); } // Install-path param @@ -671,12 +668,10 @@ { notifyOutputListener( "loading settings from: " + getLayout().getConfigurationFile() ); } - ApplicationContext factory = null; - URL configUrl; - configUrl = getLayout().getConfigurationFile().toURI().toURL(); - factory = new FileSystemXmlApplicationContext( configUrl.toString() ); - setConfiguration( ( ServerStartupConfiguration ) factory.getBean( "configuration" ) ); + URL configUrl = getLayout().getConfigurationFile().toURI().toURL(); + ApplicationContext factory = new FileSystemXmlApplicationContext( configUrl.toString() ); + setApacheDS( ( ApacheDS ) factory.getBean( "apacheDS" ) ); } catch ( MalformedURLException e ) { @@ -707,11 +702,11 @@ if ( portParam != null ) { - port = portParam.intValue(); + port = portParam; } - else if ( getConfiguration() != null ) + else if ( getApacheDS() != null ) { - port = getConfiguration().getLdapConfiguration().getIpPort(); + port = getApacheDS().getLdapConfiguration().getIpPort(); if ( isDebugEnabled() ) { @@ -792,7 +787,7 @@ if ( ignoreErrorsParam != null ) { - ignoreErrors = ignoreErrorsParam.booleanValue(); + ignoreErrors = ignoreErrorsParam; } else if ( isDebugEnabled() ) { @@ -812,7 +807,6 @@ notifyOutputListener( "user = " + user ); notifyOutputListener( "auth type = " + auth ); notifyOutputListener( "file = " + ldifFile ); - notifyOutputListener( "logs = " + logs ); } int messageId = 0; @@ -825,7 +819,7 @@ notifyOutputListener( "Connection to the server established.\n" + "Importing data ... " ); } - LdifReader ldifReader = null; + LdifReader ldifReader; try { @@ -855,7 +849,7 @@ notifyErrorListener( "Found an error while persing an entry : " + ldifReader.getError().getMessage() ); - if ( ignoreErrors == false ) + if ( !ignoreErrors ) { unbind( messageId ); @@ -868,7 +862,7 @@ if ( addEntry( entry, messageId++ ) == IMPORT_ERROR ) { - if ( ignoreErrors == false ) + if ( !ignoreErrors ) { unbind( messageId ); @@ -887,7 +881,7 @@ if ( nbAdd % 10 == 0 ) { - notifyOutputListener( new Character( '.' ) ); + notifyOutputListener( '.' ); } if ( nbAdd % 500 == 0 ) @@ -920,7 +914,7 @@ notifyErrorListener( "Found an error while persing an entry : " + ldifReader.getError().getMessage() ); - if ( ignoreErrors == false ) + if ( !ignoreErrors ) { unbind( messageId ); @@ -934,7 +928,7 @@ if ( changeEntry( entry, messageId++ ) == IMPORT_ERROR ) { - if ( ignoreErrors == false ) + if ( !ignoreErrors ) { unbind( messageId ); @@ -954,7 +948,7 @@ if ( nbMod % 10 == 0 ) { - notifyOutputListener( new Character( '.' ) ); + notifyOutputListener( '.' ); } if ( nbMod % 500 == 0 ) @@ -972,6 +966,7 @@ } // Logout to the server + //noinspection UnusedAssignment unbind( messageId++ ); } Modified: directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/storedprocedurecmd/StoredProcedureCommandExecutor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/storedprocedurecmd/StoredProcedureCommandExecutor.java?rev=582462&r1=582461&r2=582462&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/storedprocedurecmd/StoredProcedureCommandExecutor.java (original) +++ directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/storedprocedurecmd/StoredProcedureCommandExecutor.java Fri Oct 5 23:48:35 2007 @@ -19,16 +19,7 @@ */ package org.apache.directory.server.tools.commands.storedprocedurecmd; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Map; - -import javax.naming.ldap.InitialLdapContext; -import javax.naming.ldap.LdapContext; - -import org.apache.directory.server.configuration.ServerStartupConfiguration; +import org.apache.directory.server.configuration.ApacheDS; import org.apache.directory.server.tools.ToolCommandListener; import org.apache.directory.server.tools.execution.BaseToolCommandExecutor; import org.apache.directory.server.tools.util.ListenerParameter; @@ -38,6 +29,14 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; +import javax.naming.ldap.InitialLdapContext; +import javax.naming.ldap.LdapContext; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; + /** * This is the Executor Class of the Stored Procedure Command. * @@ -138,7 +137,7 @@ if ( quietParam != null ) { - setQuietEnabled( quietParam.booleanValue() ); + setQuietEnabled( quietParam ); } // Debug param @@ -146,7 +145,7 @@ if ( debugParam != null ) { - setDebugEnabled( debugParam.booleanValue() ); + setDebugEnabled( debugParam ); } // Verbose param @@ -154,7 +153,7 @@ if ( verboseParam != null ) { - setVerboseEnabled( verboseParam.booleanValue() ); + setVerboseEnabled( verboseParam ); } // Install-path param @@ -171,12 +170,9 @@ notifyOutputListener( "loading settings from: " + getLayout().getConfigurationFile() ); } - ApplicationContext factory = null; - URL configUrl; - - configUrl = getLayout().getConfigurationFile().toURI().toURL(); - factory = new FileSystemXmlApplicationContext( configUrl.toString() ); - setConfiguration( ( ServerStartupConfiguration ) factory.getBean( "configuration" ) ); + URL configUrl = getLayout().getConfigurationFile().toURI().toURL(); + ApplicationContext factory = new FileSystemXmlApplicationContext( configUrl.toString() ); + setApacheDS( ( ApacheDS ) factory.getBean( "apacheDS" ) ); } catch ( MalformedURLException e ) { @@ -206,11 +202,11 @@ if ( portParam != null ) { - port = portParam.intValue(); + port = portParam; } - else if ( getConfiguration() != null ) + else if ( getApacheDS() != null ) { - port = getConfiguration().getLdapConfiguration().getIpPort(); + port = getApacheDS().getLdapConfiguration().getIpPort(); if ( isDebugEnabled() ) { Modified: directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/execution/BaseToolCommandExecutor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/execution/BaseToolCommandExecutor.java?rev=582462&r1=582461&r2=582462&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/execution/BaseToolCommandExecutor.java (original) +++ directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/execution/BaseToolCommandExecutor.java Fri Oct 5 23:48:35 2007 @@ -20,14 +20,14 @@ package org.apache.directory.server.tools.execution; -import java.io.File; - import org.apache.directory.daemon.InstallationLayout; -import org.apache.directory.server.configuration.ServerStartupConfiguration; +import org.apache.directory.server.configuration.ApacheDS; import org.apache.directory.server.tools.BaseToolCommand; import org.apache.directory.server.tools.util.ListenerParameter; import org.apache.directory.server.tools.util.Parameter; +import java.io.File; + /** * Abstract class that must be extended by every Executor @@ -53,7 +53,7 @@ public static final String EXCEPTIONLISTENER_PARAMETER = "exceptionListener"; private InstallationLayout layout; - private ServerStartupConfiguration configuration; + private ApacheDS apacheDS; public BaseToolCommandExecutor( String name ) @@ -86,15 +86,15 @@ } - public void setConfiguration( ServerStartupConfiguration configuration ) + public void setApacheDS( ApacheDS apacheDS ) { - this.configuration = configuration; + this.apacheDS = apacheDS; } - public ServerStartupConfiguration getConfiguration() + public ApacheDS getApacheDS() { - return configuration; + return apacheDS; } Modified: directory/apacheds/branches/bigbang/server-unit/pom.xml URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/pom.xml?rev=582462&r1=582461&r2=582462&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/server-unit/pom.xml (original) +++ directory/apacheds/branches/bigbang/server-unit/pom.xml Fri Oct 5 23:48:35 2007 @@ -58,6 +58,12 @@ org.apache.directory.server + apacheds-interceptor-kerberos + ${pom.version} + + + + org.apache.directory.server apacheds-core-unit ${pom.version} Modified: directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerFastTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerFastTest.java?rev=582462&r1=582461&r2=582462&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerFastTest.java (original) +++ directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerFastTest.java Fri Oct 5 23:48:35 2007 @@ -20,30 +20,9 @@ package org.apache.directory.server.unit; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NameAlreadyBoundException; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attribute; -import javax.naming.directory.Attributes; -import javax.naming.ldap.InitialLdapContext; -import javax.naming.ldap.LdapContext; - import junit.framework.AssertionFailedError; - import org.apache.commons.io.FileUtils; -import org.apache.directory.server.configuration.MutableServerStartupConfiguration; -import org.apache.directory.server.core.configuration.ShutdownConfiguration; +import org.apache.directory.server.configuration.ApacheDS; import org.apache.directory.server.jndi.ServerContextFactory; import org.apache.directory.shared.ldap.exception.LdapConfigurationException; import org.apache.directory.shared.ldap.ldif.Entry; @@ -51,11 +30,21 @@ import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.mina.util.AvailablePortFinder; import org.junit.AfterClass; -import org.junit.BeforeClass; import static org.junit.Assert.assertNotNull; +import org.junit.BeforeClass; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.naming.*; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.ldap.InitialLdapContext; +import javax.naming.ldap.LdapContext; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.*; + /** * A simple testcase for testing JNDI provider functionality. @@ -65,7 +54,7 @@ */ public abstract class AbstractServerFastTest { - private static final Logger log = LoggerFactory.getLogger( AbstractServerFastTest.class ); + private static final Logger LOG = LoggerFactory.getLogger( AbstractServerFastTest.class ); private static final List EMPTY_LIST = Collections.unmodifiableList( new ArrayList( 0 ) ); private static final String CTX_FACTORY = "com.sun.jndi.ldap.LdapCtxFactory"; @@ -87,33 +76,29 @@ /** flag whether to delete database files for each test or not */ protected static boolean doDelete = true; - protected static MutableServerStartupConfiguration configuration = new MutableServerStartupConfiguration(); - protected static int port = -1; - - private static long start; - - protected static final String ldif = null; - + protected static final String LDIF = null; protected static final String HOST = "localhost"; protected static final String USER = "uid=admin,ou=system"; protected static final String PASSWORD = "secret"; protected static final String BASE = "dc=example,dc=com"; + protected static ApacheDS apacheDS = new ApacheDS(); + /** * If there is an LDIF file with the same name as the test class - * but with the .ldif extension then it is read and the entries + * but with the .LDIF extension then it is read and the entries * it contains are added to the server. It appears as though the * administor adds these entries to the server. * * @param verifyEntries whether or not all entry additions are checked * to see if they were in fact correctly added to the server * @return a list of entries added to the server in the order they were added - * @throws NamingException + * @throws NamingException of the load of test LDIF fails */ protected List loadTestLdif( boolean verifyEntries ) throws NamingException { - InputStream in = getClass().getResourceAsStream( getClass().getSimpleName() + ".ldif" ); + InputStream in = getClass().getResourceAsStream( getClass().getSimpleName() + ".LDIF" ); if ( in == null ) { @@ -131,11 +116,11 @@ if ( verifyEntries ) { verify( entry ); - log.info( "Successfully verified addition of entry {}", entry.getDn() ); + LOG.info( "Successfully verified addition of entry {}", entry.getDn() ); } else { - log.info( "Added entry {} without verification", entry.getDn() ); + LOG.info( "Added entry {} without verification", entry.getDn() ); } entries.add( entry ); @@ -166,7 +151,7 @@ { if ( ! readAttribute.contains( origAttribute.get( ii ) ) ) { - log.error( "Failed to verify entry addition of {}. {} attribute in original " + + LOG.error( "Failed to verify entry addition of {}. {} attribute in original " + "entry missing from read entry.", entry.getDn(), id ); throw new AssertionFailedError( "Failed to verify entry addition of " + entry.getDn() ); } @@ -215,14 +200,14 @@ @BeforeClass public static void setUpBeforeClass() throws Exception { - start = System.currentTimeMillis(); - - doDelete( configuration.getWorkingDirectory() ); + doDelete( apacheDS.getDirectoryService().getWorkingDirectory() ); port = AvailablePortFinder.getNextAvailable( 1024 ); - configuration.getLdapConfiguration().setIpPort( port ); - configuration.setShutdownHookEnabled( false ); + apacheDS.getLdapConfiguration().setIpPort( port ); + apacheDS.getDirectoryService().setShutdownHookEnabled( false ); + apacheDS.startup(); - Hashtable env = new Hashtable( configuration.toJndiEnvironment() ); + Hashtable env = new Hashtable(); + env.put( ApacheDS.JNDI_KEY, apacheDS ); env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" ); env.put( Context.SECURITY_CREDENTIALS, "secret" ); env.put( Context.SECURITY_AUTHENTICATION, "simple" ); @@ -234,6 +219,8 @@ /** * Deletes the Eve working directory. + * @param wkdir the working directory to delete + * @throws IOException if the directory cannot be deleted */ protected static void doDelete( File wkdir ) throws IOException { @@ -314,30 +301,23 @@ * Sets the system context root to null. * * @see junit.framework.TestCase#tearDown() + * @throws Exception if there are problems shutting down the server */ @AfterClass public static void tearDownAfterClass() throws Exception { - Hashtable env = new Hashtable(); - env.put( Context.PROVIDER_URL, "ou=system" ); - env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.directory.server.jndi.ServerContextFactory" ); - env.putAll( new ShutdownConfiguration().toJndiEnvironment() ); - env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" ); - env.put( Context.SECURITY_CREDENTIALS, "secret" ); - try { - new InitialContext( env ); + apacheDS.shutdown(); } catch ( Exception e ) { + LOG.error( "Encountered exception while trying to shutdown.", e ); } root = null; - doDelete( configuration.getWorkingDirectory() ); - configuration = new MutableServerStartupConfiguration(); - - System.out.println( "Delta : " + (System.currentTimeMillis() - start ) ); + doDelete( apacheDS.getDirectoryService().getWorkingDirectory() ); + apacheDS = new ApacheDS(); } @@ -347,8 +327,9 @@ * that only ou=system entries will be added - entries for other partitions * cannot be imported and will blow chunks. * - * @throws NamingException if there are problems reading the ldif file and + * @throws NamingException if there are problems reading the LDIF file and * adding those entries to the system partition + * @param in the input stream to read the LDIF file from */ protected void importLdif( InputStream in ) throws NamingException { @@ -365,7 +346,7 @@ } catch ( Exception e ) { - String msg = "failed while trying to parse system ldif file"; + String msg = "failed while trying to parse system LDIF file"; NamingException ne = new LdapConfigurationException( msg ); ne.setRootCause( e ); throw ne; @@ -394,7 +375,7 @@ } catch ( Exception e ) { - String msg = "failed while trying to parse system ldif file"; + String msg = "failed while trying to parse system LDIF file"; NamingException ne = new LdapConfigurationException( msg ); ne.setRootCause( e ); throw ne; @@ -403,19 +384,18 @@ /** - * Inject an ldif String into the server. DN must be relative to the + * Inject an LDIF String into the server. DN must be relative to the * root. + * @param ldif the LDIF to add + * @throws NamingException if there are problems adding the entries in the LDIF */ protected void injectEntries( String ldif ) throws NamingException { LdifReader reader = new LdifReader(); List entries = reader.parseLdif( ldif ); - - Iterator entryIter = entries.iterator(); - - while ( entryIter.hasNext() ) + + for ( Entry entry : entries ) { - Entry entry = entryIter.next(); rootDSE.createSubcontext( new LdapDN( entry.getDn() ), entry.getAttributes() ); } } 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=582462&r1=582461&r2=582462&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 Fri Oct 5 23:48:35 2007 @@ -23,9 +23,7 @@ import junit.framework.AssertionFailedError; import junit.framework.TestCase; import org.apache.commons.io.FileUtils; -import org.apache.directory.server.configuration.MutableServerStartupConfiguration; -import org.apache.directory.server.core.configuration.ShutdownConfiguration; -import org.apache.directory.server.core.configuration.SyncConfiguration; +import org.apache.directory.server.configuration.ApacheDS; import org.apache.directory.server.jndi.ServerContextFactory; import org.apache.directory.shared.ldap.exception.LdapConfigurationException; import org.apache.directory.shared.ldap.ldif.Entry; @@ -54,7 +52,7 @@ */ public abstract class AbstractServerTest extends TestCase { - private static final Logger log = LoggerFactory.getLogger( AbstractServerTest.class ); + private static final Logger LOG = LoggerFactory.getLogger( AbstractServerTest.class ); private static final List EMPTY_LIST = Collections.unmodifiableList( new ArrayList( 0 ) ); private static final String CTX_FACTORY = "com.sun.jndi.ldap.LdapCtxFactory"; @@ -67,30 +65,18 @@ /** the context root for the schema */ protected LdapContext schemaRoot; - /** flag that indicates whether or not the server has started */ - private boolean serverOnline = false; - /** flag whether to delete database files for each test or not */ protected boolean doDelete = true; - protected MutableServerStartupConfiguration configuration = new MutableServerStartupConfiguration(); + protected ApacheDS apacheDS = new ApacheDS(); protected int port = -1; - private static int start = 0; - private static long t0 = 0L; + private static int start; + private static long t0; protected static int nbTests = 10000; - /** - * Tells subclasses whether or not the server is online. - * - * @return true if the server has started false otherwise. - */ - public boolean isServerOnline() - { - return serverOnline; - } - + /** * If there is an LDIF file with the same name as the test class @@ -101,7 +87,7 @@ * @param verifyEntries whether or not all entry additions are checked * to see if they were in fact correctly added to the server * @return a list of entries added to the server in the order they were added - * @throws NamingException + * @throws NamingException of the load fails */ protected List loadTestLdif( boolean verifyEntries ) throws NamingException { @@ -111,7 +97,7 @@ return EMPTY_LIST; } - if ( ! serverOnline ) + if ( ! apacheDS.isStarted() ) { throw new ConfigurationException( "The server has not been started - cannot add entries." ); } @@ -126,11 +112,11 @@ if ( verifyEntries ) { verify( entry ); - log.info( "Successfully verified addition of entry {}", entry.getDn() ); + LOG.info( "Successfully verified addition of entry {}", entry.getDn() ); } else { - log.info( "Added entry {} without verification", entry.getDn() ); + LOG.info( "Added entry {} without verification", entry.getDn() ); } entries.add( entry ); @@ -161,7 +147,7 @@ { if ( ! readAttribute.contains( origAttribute.get( ii ) ) ) { - log.error( "Failed to verify entry addition of {}. {} attribute in original " + + LOG.error( "Failed to verify entry addition of {}. {} attribute in original " + "entry missing from read entry.", entry.getDn(), id ); throw new AssertionFailedError( "Failed to verify entry addition of " + entry.getDn() ); } @@ -198,7 +184,7 @@ */ protected LdapContext getWiredContext( String bindPrincipalDn, String password ) throws NamingException { - if ( ! serverOnline ) + if ( ! apacheDS.isStarted() ) { throw new ConfigurationException( "The server is not online! Cannot connect to it." ); } @@ -230,19 +216,18 @@ start++; - doDelete( configuration.getWorkingDirectory() ); + doDelete( apacheDS.getDirectoryService().getWorkingDirectory() ); port = AvailablePortFinder.getNextAvailable( 1024 ); - configuration.getLdapConfiguration().setIpPort( port ); - configuration.setShutdownHookEnabled( false ); + apacheDS.getLdapConfiguration().setIpPort( port ); + apacheDS.getDirectoryService().setShutdownHookEnabled( false ); + apacheDS.startup(); try { setContexts( "uid=admin,ou=system", "secret" ); - serverOnline = true; } catch( Exception e ) { - serverOnline = false; throw e; } } @@ -250,6 +235,8 @@ /** * Deletes the Eve working directory. + * @param wkdir the directory to delete + * @throws IOException if the directory cannot be deleted */ protected void doDelete( File wkdir ) throws IOException { @@ -279,7 +266,8 @@ */ protected void setContexts( String user, String passwd ) throws NamingException { - Hashtable env = new Hashtable( configuration.toJndiEnvironment() ); + Hashtable env = new Hashtable(); + env.put( ApacheDS.JNDI_KEY, apacheDS ); env.put( Context.SECURITY_PRINCIPAL, user ); env.put( Context.SECURITY_CREDENTIALS, passwd ); env.put( Context.SECURITY_AUTHENTICATION, "simple" ); @@ -317,19 +305,10 @@ protected void tearDown() throws Exception { super.tearDown(); - Hashtable env = new Hashtable(); - env.put( Context.PROVIDER_URL, "ou=system" ); - env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.directory.server.jndi.ServerContextFactory" ); - env.putAll( new ShutdownConfiguration().toJndiEnvironment() ); - env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" ); - env.put( Context.SECURITY_CREDENTIALS, "secret" ); - env.put( Context.SECURITY_AUTHENTICATION, "simple" ); - try { - new InitialContext( env ); - serverOnline = false; + apacheDS.shutdown(); } catch ( Exception e ) { @@ -337,7 +316,7 @@ } sysRoot = null; - configuration = new MutableServerStartupConfiguration(); + apacheDS = new ApacheDS(); if ( start >= nbTests ) { @@ -354,6 +333,7 @@ * * @throws NamingException if there are problems reading the ldif file and * adding those entries to the system partition + * @param in the input stream with the ldif */ protected void importLdif( InputStream in ) throws NamingException { @@ -380,17 +360,16 @@ /** * Inject an ldif String into the server. DN must be relative to the * root. + * @param ldif the entries to inject + * @throws NamingException if the entries cannot be added */ protected void injectEntries( String ldif ) throws NamingException { LdifReader reader = new LdifReader(); List entries = reader.parseLdif( ldif ); - - Iterator entryIter = entries.iterator(); - - while ( entryIter.hasNext() ) + + for ( Entry entry : entries ) { - Entry entry = entryIter.next(); rootDSE.createSubcontext( new LdapDN( entry.getDn() ), entry.getAttributes() ); } } Modified: directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/AddITest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/AddITest.java?rev=582462&r1=582461&r2=582462&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/AddITest.java (original) +++ directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/AddITest.java Fri Oct 5 23:48:35 2007 @@ -55,7 +55,7 @@ { private static final String RDN = "cn=The Person"; - private DirContext ctx = null; + private DirContext ctx; /** @@ -104,7 +104,7 @@ * Just a little test to check wether the person is created correctly after * setup. * - * @throws NamingException + * @throws NamingException if we cannot connect to the server */ public void testSetUpTearDown() throws NamingException { @@ -116,11 +116,9 @@ Attributes attributes = person.getAttributes( "" ); Attribute ocls = attributes.get( "objectClass" ); - String[] expectedOcls = - { "top", "person" }; - for ( int i = 0; i < expectedOcls.length; i++ ) + String[] expectedOcls = { "top", "person" }; + for ( String name : expectedOcls ) { - String name = expectedOcls[i]; assertTrue( "object class " + name + " is NOT present when it should be!", ocls.contains( name ) ); } } @@ -129,7 +127,7 @@ /** * This is the original defect as in JIRA DIREVE-216. * - * @throws NamingException + * @throws NamingException if we cannot connect and perform add operations */ public void testAddObjectClasses() throws NamingException { @@ -149,11 +147,9 @@ attributes = person.getAttributes( "" ); Attribute newOcls = attributes.get( "objectClass" ); - String[] expectedOcls = - { "top", "person", "organizationalPerson", "inetOrgPerson" }; - for ( int i = 0; i < expectedOcls.length; i++ ) + String[] expectedOcls = { "top", "person", "organizationalPerson", "inetOrgPerson" }; + for ( String name : expectedOcls ) { - String name = expectedOcls[i]; assertTrue( "object class " + name + " is present", newOcls.contains( name ) ); } } @@ -162,7 +158,7 @@ /** * This changes a single attribute value. Just as a reference. * - * @throws NamingException + * @throws NamingException if we cannot connect and modify the description */ public void testModifyDescription() throws NamingException { @@ -188,7 +184,7 @@ /** * Try to add entry with required attribute missing. * - * @throws NamingException + * @throws NamingException if we fail to connect */ public void testAddWithMissingRequiredAttributes() throws NamingException { @@ -224,7 +220,7 @@ * two description attributes does not combine values."). Uses Sun ONE Directory * SDK for Java 4.1 , or comparable (Netscape, Mozilla). * - * @throws LDAPException + * @throws LDAPException if we fail to connect and add entries */ public void testAddEntryWithTwoDescriptions() throws LDAPException { @@ -266,7 +262,7 @@ * two description attributes does not combine values."). Uses Sun ONE Directory * SDK for Java 4.1 , or comparable (Netscape, Mozilla). * - * @throws LDAPException + * @throws LDAPException if we fail to connect and add entries */ public void testAddEntryWithTwoDescriptionsVariant() throws LDAPException { @@ -309,7 +305,7 @@ * two description attributes does not combine values."). Uses Sun ONE Directory * SDK for Java 4.1 , or comparable (Netscape, Mozilla). * - * @throws LDAPException + * @throws LDAPException if we fail to connect and add entries */ public void testAddEntryWithTwoDescriptionsSecondVariant() throws LDAPException { @@ -349,7 +345,7 @@ /** * Try to add entry with invalid number of values for a single-valued atribute * - * @throws NamingException + * @throws NamingException if we fail to connect and add entries * @see DIRSERVER-614 */ public void testAddWithInvalidNumberOfAttributeValues() throws NamingException @@ -382,7 +378,7 @@ /** * Try to add entry and an alias to it. Afterwards, remove it. * - * @throws NamingException + * @throws NamingException if we fail to connect and add entries */ public void testAddAlias() throws NamingException { @@ -420,7 +416,7 @@ * Try to add entry and an alias to it. Afterwards, remove it. This version * cretes a container entry before the operations. * - * @throws NamingException + * @throws NamingException if we fail to connect and add entries */ public void testAddAliasInContainer() throws NamingException { Modified: directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java?rev=582462&r1=582461&r2=582462&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java (original) +++ directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java Fri Oct 5 23:48:35 2007 @@ -53,7 +53,7 @@ */ public class DIRSERVER951ITest extends AbstractServerTest { - private LdapContext ctx = null; + private LdapContext ctx; /** @@ -96,7 +96,7 @@ systemEntry.put( "uid", "testUid" ); systemCfg.setContextEntry( systemEntry ); - configuration.setSystemPartition( systemCfg ); + apacheDS.getDirectoryService().setSystemPartition( systemCfg ); super.setUp(); super.loadTestLdif( true ); @@ -120,6 +120,8 @@ * Tests to make sure a negated search for OU of "test1" returns * those entries that do not have the OU attribute or do not have * a "test1" value for OU if the attribute exists. + * + * @throws Exception on failure to search */ public void testSearchNotOU() throws Exception { Modified: directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/FastSearchTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/FastSearchTest.java?rev=582462&r1=582461&r2=582462&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/FastSearchTest.java (original) +++ directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/FastSearchTest.java Fri Oct 5 23:48:35 2007 @@ -55,7 +55,7 @@ /** * Test case for Search operation. It's using JUnit 4 capabilities, * so the server is only launched once for the whole test case, but - * the ldif file is loaded for each test. + * the LDIF file is loaded for each test. * * @author Apache Directory Project * @version $Rev: 569048 $ @@ -213,7 +213,7 @@ } catch ( NamingException ne ) { - // Do nothing + ne.printStackTrace(); } } @@ -259,14 +259,14 @@ try { - NamingEnumeration ii = context.search( "", filter, controls ); + NamingEnumeration ii = context.search( "", filter, controls ); // collect all results HashSet results = new HashSet(); while ( ii.hasMore() ) { - SearchResult result = ( SearchResult ) ii.next(); + SearchResult result = ii.next(); results.add( result.getName() ); } @@ -327,11 +327,11 @@ try { // Check entry - NamingEnumeration enm = sysRoot.search( base, filter, sctls ); + NamingEnumeration enm = sysRoot.search( base, filter, sctls ); assertTrue( enm.hasMore() ); while ( enm.hasMore() ) { - SearchResult sr = ( SearchResult ) enm.next(); + SearchResult sr = enm.next(); Attributes attrs = sr.getAttributes(); Attribute sn = attrs.get( "sn" ); assertNotNull( sn ); @@ -360,7 +360,7 @@ ctls.setSearchScope( SearchControls.OBJECT_SCOPE ); // Search for all entries - NamingEnumeration results = sysRoot.search( RDN, "(cn=*)", ctls ); + NamingEnumeration results = sysRoot.search( RDN, "(cn=*)", ctls ); assertTrue( results.hasMore() ); results = sysRoot.search( RDN2, "(cn=*)", ctls ); @@ -446,19 +446,23 @@ // sn="Kylie Minogue" (with quotes) String base = "cn=\"Tori Amos\""; - try { + try + { // Check entry - NamingEnumeration enm = sysRoot.search( base, filter, sctls ); + NamingEnumeration enm = sysRoot.search( base, filter, sctls ); assertTrue( enm.hasMore() ); - while ( enm.hasMore() ) { - SearchResult sr = (SearchResult) enm.next(); + while ( enm.hasMore() ) + { + SearchResult sr = enm.next(); Attributes attrs = sr.getAttributes(); Attribute sn = attrs.get("sn"); - assertNotNull(sn); + assertNotNull( sn ); assertTrue( sn.contains( "Amos" ) ); } - } catch (Exception e) { + } + catch ( Exception e ) + { fail( e.getMessage() ); } } @@ -491,17 +495,17 @@ controls.setSearchScope( SearchControls.OBJECT_SCOPE ); controls.setReturningAttributes( new String[] { "objectClasses" } ); - NamingEnumeration results = schemaRoot.search( "", "objectClass=subschema", controls ); + NamingEnumeration results = schemaRoot.search( "", "objectClass=subschema", controls ); assertTrue( results.hasMore() ); - SearchResult result = ( SearchResult ) results.next(); + SearchResult result = results.next(); assertNotNull( result ); assertFalse( results.hasMore() ); - NamingEnumeration attrs = result.getAttributes().getAll(); + NamingEnumeration attrs = result.getAttributes().getAll(); while ( attrs.hasMoreElements() ) { - Attribute attr = (Attribute)attrs.next(); + Attribute attr = attrs.next(); String ID = attr.getID(); assertEquals( "objectClasses", ID ); }