You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2010/05/19 21:03:54 UTC
svn commit: r946342 [3/3] - in /directory/shared/branches/xdbm-refactoring:
./ ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/
ldap-convert/src/main/java/org/apache/directory/shared/converter/schema/
ldap-schema-loader/src/main...
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimNormalizer.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimNormalizer.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimNormalizer.java Wed May 19 19:03:51 2010
@@ -20,7 +20,6 @@
package org.apache.directory.shared.ldap.schema.normalizers;
-import org.apache.directory.shared.ldap.schema.registries.Registries;
/**
@@ -43,13 +42,4 @@ public class CachingDeepTrimNormalizer e
{
super( new DeepTrimNormalizer() );
}
-
-
- /**
- * {@inheritDoc}
- */
- public void setRegistries( Registries registries )
- {
- super.setRegistries( registries );
- }
}
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimToLowerNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimToLowerNormalizer.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimToLowerNormalizer.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimToLowerNormalizer.java Wed May 19 19:03:51 2010
@@ -20,7 +20,6 @@
package org.apache.directory.shared.ldap.schema.normalizers;
-import org.apache.directory.shared.ldap.schema.registries.Registries;
/**
@@ -43,13 +42,4 @@ public class CachingDeepTrimToLowerNorma
{
super( new DeepTrimToLowerNormalizer() );
}
-
-
- /**
- * {@inheritDoc}
- */
- public void setRegistries( Registries registries )
- {
- super.setRegistries( registries );
- }
}
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDnNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDnNormalizer.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDnNormalizer.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDnNormalizer.java Wed May 19 19:03:51 2010
@@ -21,7 +21,6 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.schema.SchemaManager;
-import org.apache.directory.shared.ldap.schema.registries.Registries;
/**
@@ -49,15 +48,6 @@ public class CachingDnNormalizer extends
/**
* {@inheritDoc}
*/
- public void setRegistries( Registries registries )
- {
- super.setRegistries( registries );
- }
-
-
- /**
- * {@inheritDoc}
- */
public void setSchemaManager( SchemaManager schemaManager )
{
super.normalizer.setSchemaManager( schemaManager );
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java Wed May 19 19:03:51 2010
@@ -31,12 +31,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.ObjectClass;
import org.apache.directory.shared.ldap.schema.SchemaObject;
import org.apache.directory.shared.ldap.schema.syntaxCheckers.OpenLdapObjectIdentifierMacro;
-import org.apache.directory.shared.ldap.util.ExceptionUtils;
import antlr.RecognitionException;
import antlr.TokenStreamException;
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/ParserDescriptionUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/ParserDescriptionUtils.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/ParserDescriptionUtils.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/ParserDescriptionUtils.java Wed May 19 19:03:51 2010
@@ -234,12 +234,9 @@ public class ParserDescriptionUtils
}
// check that the obsolete flag is equal but not for syntaxes
- if ( ( so0 instanceof LdapSyntax ) || ( so1 instanceof LdapSyntax ) )
+ if ( ( ( so0 instanceof LdapSyntax ) || ( so1 instanceof LdapSyntax ) ) && so0.isObsolete() != so1.isObsolete() )
{
- if ( so0.isObsolete() != so1.isObsolete() )
- {
- return false;
- }
+ return false;
}
// check that the description matches
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java Wed May 19 19:03:51 2010
@@ -35,8 +35,6 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -47,9 +45,6 @@ import org.slf4j.LoggerFactory;
*/
public abstract class AbstractSchemaLoader implements SchemaLoader
{
- /** static class logger */
- private static final Logger LOG = LoggerFactory.getLogger( AbstractSchemaLoader.class );
-
protected SchemaLoaderListener listener;
/**
@@ -73,13 +68,10 @@ public abstract class AbstractSchemaLoad
listener.schemaLoaded( schema );
}
- if ( registries instanceof SchemaLoaderListener )
+ if ( registries instanceof SchemaLoaderListener && registries != listener )
{
- if ( registries != listener )
- {
- SchemaLoaderListener listener = ( SchemaLoaderListener ) registries;
- listener.schemaLoaded( schema );
- }
+ SchemaLoaderListener listener = ( SchemaLoaderListener ) registries;
+ listener.schemaLoaded( schema );
}
}
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultAttributeTypeRegistry.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultAttributeTypeRegistry.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultAttributeTypeRegistry.java Wed May 19 19:03:51 2010
@@ -50,9 +50,6 @@ public class DefaultAttributeTypeRegistr
/** static class logger */
private static final Logger LOG = LoggerFactory.getLogger( DefaultAttributeTypeRegistry.class );
- /** Speedup for DEBUG mode */
- private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
/** cached Oid/normalizer mapping */
private transient Map<String, OidNormalizer> oidNormalizerMap;
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultObjectClassRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultObjectClassRegistry.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultObjectClassRegistry.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultObjectClassRegistry.java Wed May 19 19:03:51 2010
@@ -33,8 +33,6 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.schema.ObjectClass;
import org.apache.directory.shared.ldap.schema.SchemaObject;
import org.apache.directory.shared.ldap.schema.SchemaObjectType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -46,12 +44,6 @@ import org.slf4j.LoggerFactory;
public class DefaultObjectClassRegistry extends DefaultSchemaObjectRegistry<ObjectClass>
implements ObjectClassRegistry
{
- /** static class logger */
- private static final Logger LOG = LoggerFactory.getLogger( DefaultObjectClassRegistry.class );
-
- /** Speedup for DEBUG mode */
- private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
/** maps OIDs to a Set of descendants for that OID */
private Map<String,Set<ObjectClass>> oidToDescendants;
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/OidRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/OidRegistry.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/OidRegistry.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/OidRegistry.java Wed May 19 19:03:51 2010
@@ -26,11 +26,11 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang.ArrayUtils;
import org.apache.directory.shared.asn1.primitives.OID;
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.schema.SchemaObject;
-import org.apache.directory.shared.ldap.util.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java Wed May 19 19:03:51 2010
@@ -134,6 +134,7 @@ public class Registries implements Schem
protected Map<SchemaObjectWrapper, Set<SchemaObjectWrapper>> using;
/** A reference on the schema Manager */
+ @SuppressWarnings("PMD.UnusedPrivateField") // False positive
private SchemaManager schemaManager;
@@ -666,6 +667,8 @@ public class Registries implements Schem
/**
* Build the DitContentRule references
*/
+ // Remove me when TODO is implemented
+ @SuppressWarnings("PMD.UnusedFormalParameter")
private void buildDitContentRuleReferences( List<Throwable> errors )
{
for ( DITContentRule ditContentRule : ditContentRuleRegistry )
@@ -678,6 +681,8 @@ public class Registries implements Schem
/**
* Build the DitStructureRule references
*/
+ // Remove me when TODO is implemented
+ @SuppressWarnings("PMD.UnusedFormalParameter")
private void buildDitStructureRuleReferences( List<Throwable> errors )
{
for ( DITStructureRule ditStructureRule : ditStructureRuleRegistry )
@@ -781,6 +786,8 @@ public class Registries implements Schem
/**
* Build the NameForm references
*/
+ // Remove me when TODO is implemented
+ @SuppressWarnings("PMD.UnusedFormalParameter")
private void buildNameFormReferences( List<Throwable> errors )
{
for ( NameForm nameFormRule : nameFormRegistry )
@@ -1730,6 +1737,8 @@ public class Registries implements Schem
* @param schemaObject The SchemaObject we want to deregister
* @throws LdapException If the removal failed
*/
+ // Remove me when TODO is implemented
+ @SuppressWarnings("PMD.UnusedFormalParameter")
private SchemaObject unregister( List<Throwable> errors, SchemaObject schemaObject ) throws LdapException
{
LOG.debug( "Unregistering {}:{}", schemaObject.getObjectType(), schemaObject.getOid() );
@@ -2601,8 +2610,6 @@ public class Registries implements Schem
}
catch ( LdapException ne )
{
- int i = 0;
- i++;
// Nothing to do
}
}
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java Wed May 19 19:03:51 2010
@@ -31,8 +31,8 @@ import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.InvalidAttributeIdentifierException;
+import org.apache.commons.lang.ArrayUtils;
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.entry.DefaultEntry;
import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
@@ -357,12 +357,9 @@ public class AttributeUtils
{
Object value = values.nextElement();
- if ( value instanceof byte[] )
+ if ( value instanceof byte[] && ArrayUtils.isEquals( comparedBytes, value ) )
{
- if ( ArrayUtils.isEquals( comparedBytes, value ) )
- {
- return true;
- }
+ return true;
}
}
}
@@ -405,12 +402,9 @@ public class AttributeUtils
{
Object attrVal = attrVals.nextElement();
- if ( attrVal instanceof String )
+ if ( attrVal instanceof String && strVal.equalsIgnoreCase( ( String ) attrVal ) )
{
- if ( strVal.equalsIgnoreCase( ( String ) attrVal ) )
- {
- return true;
- }
+ return true;
}
}
}
@@ -424,13 +418,9 @@ public class AttributeUtils
{
Object attrVal = attrVals.nextElement();
- if ( attrVal instanceof byte[] )
+ if ( attrVal instanceof byte[] && Arrays.equals( ( byte[] ) attrVal, valueBytes ) )
{
- if ( Arrays.equals( ( byte[] ) attrVal, valueBytes ) )
- {
- return true;
- }
-
+ return true;
}
}
}
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java Wed May 19 19:03:51 2010
@@ -363,6 +363,7 @@ public class LdapURL
* apply to the byte buffer TODO check that the topLabel is valid
* (it must start with an alpha)
*/
+ @SuppressWarnings("PMD.CollapsibleIfStatements") // Used because of comments
private int parseHost( char[] chars, int pos )
{
@@ -400,17 +401,13 @@ public class LdapURL
}
// Let's check the string we had before the dot.
- if ( isHostNumber )
+ if ( isHostNumber && nbDots < 4 )
{
- if ( nbDots < 4 )
+ // We had only digits. It may be an IP adress? Check it
+ if ( ipElem[nbDots] > 65535 )
{
-
- // We had only digits. It may be an IP adress? Check it
- if ( ipElem[nbDots] > 65535 )
- {
- invalidIp = true;
- }
+ invalidIp = true;
}
}
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/PreferencesDictionary.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/PreferencesDictionary.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/PreferencesDictionary.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/PreferencesDictionary.java Wed May 19 19:03:51 2010
@@ -25,6 +25,7 @@ import java.util.Enumeration;
import java.util.prefs.Preferences;
import java.util.prefs.BackingStoreException;
+import org.apache.commons.lang.exception.NestableRuntimeException;
import org.apache.directory.shared.i18n.I18n;
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java Wed May 19 19:03:51 2010
@@ -20,11 +20,10 @@
package org.apache.directory.shared.ldap.util;
-
import java.io.File;
-import java.io.InputStream;
-import java.io.IOException;
import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
@@ -116,6 +115,8 @@ public class PropertiesUtils
* a class to use for relative path references
* @return the static properties
*/
+ // This will suppress PMD.EmptyCatchBlock warnings in this method
+ @SuppressWarnings("PMD.EmptyCatchBlock")
public static Properties getStaticProperties( Class<?> ref )
{
final Properties properties = new Properties();
@@ -133,6 +134,20 @@ public class PropertiesUtils
{
return properties;
}
+ finally
+ {
+ if ( input != null )
+ {
+ try
+ {
+ input.close();
+ }
+ catch ( IOException e )
+ {
+ // Empty catch, we can't more than trying to close
+ }
+ }
+ }
}
return properties;
@@ -148,6 +163,8 @@ public class PropertiesUtils
* the relative path to the resoruce
* @return the static properties
*/
+ // This will suppress PMD.EmptyCatchBlock warnings in this method
+ @SuppressWarnings("PMD.EmptyCatchBlock")
public static Properties getStaticProperties( Class<?> ref, String path )
{
Properties properties = new Properties();
@@ -166,6 +183,20 @@ public class PropertiesUtils
{
return properties;
}
+ finally
+ {
+ if ( input != null )
+ {
+ try
+ {
+ input.close();
+ }
+ catch ( IOException e )
+ {
+ // Empty catch, we can't more than trying to close
+ }
+ }
+ }
return properties;
}
@@ -222,6 +253,8 @@ public class PropertiesUtils
* the path to the resource
* @return the loaded or new Properties
*/
+ // This will suppress PMD.EmptyCatchBlock warnings in this method
+ @SuppressWarnings("PMD.EmptyCatchBlock")
public static Properties getProperties( ClassLoader classloader, String path )
{
Properties properties = new Properties();
@@ -237,6 +270,20 @@ public class PropertiesUtils
{
return properties;
}
+ finally
+ {
+ if ( input != null )
+ {
+ try
+ {
+ input.close();
+ }
+ catch ( IOException e )
+ {
+ // Empty catch, we can't more than trying to close
+ }
+ }
+ }
}
return properties;
@@ -253,6 +300,8 @@ public class PropertiesUtils
* the relative path to the resource
* @return the loaded or new Properties
*/
+ // This will suppress PMD.EmptyCatchBlock warnings in this method
+ @SuppressWarnings("PMD.EmptyCatchBlock")
public static Properties getProperties( Class<?> clazz, String path )
{
Properties properties = new Properties();
@@ -268,6 +317,20 @@ public class PropertiesUtils
{
return properties;
}
+ finally
+ {
+ if ( input != null )
+ {
+ try
+ {
+ input.close();
+ }
+ catch ( IOException e )
+ {
+ // Empty catch, we can't more than trying to close
+ }
+ }
+ }
}
return properties;
@@ -309,7 +372,7 @@ public class PropertiesUtils
}
Enumeration<?> list = expanded.propertyNames();
-
+
while ( list.hasMoreElements() )
{
String key = ( String ) list.nextElement();
@@ -416,13 +479,13 @@ public class PropertiesUtils
/*
* H A N D L E S I N G L E V A L U E D K E Y S
*/
- for ( Object key:keys.keySet() )
+ for ( Object key : keys.keySet() )
{
- String value = discover( (String)key, sources, haltOnDiscovery );
+ String value = discover( ( String ) key, sources, haltOnDiscovery );
if ( value != null )
{
- keys.setProperty( (String)key, value );
+ keys.setProperty( ( String ) key, value );
}
}
}
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/SequencedHashMap.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/SequencedHashMap.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/SequencedHashMap.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/SequencedHashMap.java Wed May 19 19:03:51 2010
@@ -37,6 +37,7 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
+import org.apache.commons.collections.KeyValue;
import org.apache.directory.shared.i18n.I18n;
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java Wed May 19 19:03:51 2010
@@ -497,12 +497,9 @@ public class StringTools
ch = buf[i];
// filter out all uppercase characters
- if ( toLowerCase )
+ if ( toLowerCase && Character.isUpperCase( ch ) )
{
- if ( Character.isUpperCase( ch ) )
- {
- ch = Character.toLowerCase( ch );
- }
+ ch = Character.toLowerCase( ch );
}
// Check to see if we should add space
@@ -887,6 +884,7 @@ public class StringTools
* @return the filter accepted path component Strings in the order
* encountered
*/
+ @SuppressWarnings("PMD.CollapsibleIfStatements") // Used because of comments
public static final List<String> getPaths( String paths, FileFilter filter )
{
int start = 0;
@@ -3397,89 +3395,6 @@ public class StringTools
/**
- * Decodes sequences of escaped hex within an attribute's value into
- * a UTF-8 String. The hex is decoded inline and the complete decoded
- * String is returned.
- *
- * @param str the string containing hex escapes
- * @return the decoded string
- */
- public static final String decodeEscapedHex( String str ) throws InvalidNameException
- {
- if ( str == null )
- {
- throw new InvalidNameException( I18n.err( I18n.ERR_04433 ) );
- }
-
- int length = str.length();
-
- if ( length == 0 )
- {
- throw new InvalidNameException( I18n.err( I18n.ERR_04434 ) );
- }
-
- // create buffer and add everything before start of scan
- StringBuffer buf = new StringBuffer();
- ByteBuffer bb = new ByteBuffer();
- boolean escaped = false;
-
- // start scaning until we find an escaped series of bytes
- for ( int ii = 0; ii < length; ii++ )
- {
- char c = str.charAt( ii );
-
- if ( !escaped && c == '\\' )
- {
- // we have the start of a hex escape sequence
- if ( isHex( str, ii+1 ) && isHex ( str, ii+2 ) )
- {
- bb.clear();
- int advancedBy = collectEscapedHexBytes( bb, str, ii );
- ii+=advancedBy-1;
- buf.append( StringTools.utf8ToString( bb.buffer(), bb.position() ) );
- escaped = false;
- continue;
- }
- else
- {
- // It may be an escaped char ( ' ', '"', '#', '+', ',', ';', '<', '=', '>', '\' )
- escaped = true;
- continue;
- }
- }
-
- if ( escaped )
- {
- if ( DNUtils.isPairCharOnly( c ) )
- {
- // It is an escaped char ( ' ', '"', '#', '+', ',', ';', '<', '=', '>', '\' )
- // Stores it into the buffer without the '\'
- escaped = false;
- buf.append( c );
- continue;
- }
- else
- {
- throw new InvalidNameException( I18n.err( I18n.ERR_04435 ) );
- }
- }
- else
- {
- buf.append( str.charAt( ii ) );
- }
- }
-
- if ( escaped )
- {
- // We should not have a '\' at the end of the string
- throw new InvalidNameException( I18n.err( I18n.ERR_04436 ) );
- }
-
- return buf.toString();
- }
-
-
- /**
* Convert an escaoed list of bytes to a byte[]
*
* @param str the string containing hex escapes
@@ -3531,39 +3446,6 @@ public class StringTools
/**
- * Collects an hex sequence from a string, and returns the value
- * as an integer, after having modified the initial value (the escaped
- * hex value is transsformed to the byte it represents).
- *
- * @param bb the buffer which will contain the unescaped byte
- * @param str the initial string with ecaped chars
- * @param index the position in the string of the escaped data
- * @return the byte as an integer
- */
- public static int collectEscapedHexBytes( ByteBuffer bb, String str, int index )
- {
- int advanceBy = 0;
-
- for ( int ii = index; ii < str.length(); ii += 3, advanceBy += 3 )
- {
- // we have the start of a hex escape sequence
- if ( ( str.charAt( ii ) == '\\' ) && isHex( str, ii+1 ) && isHex ( str, ii+2 ) )
- {
- int bite = ( StringTools.HEX_VALUE[str.charAt( ii+1 )] << 4 ) +
- StringTools.HEX_VALUE[str.charAt( ii+2 )];
- bb.append( bite );
- }
- else
- {
- break;
- }
- }
-
- return advanceBy;
- }
-
-
- /**
* Thansform an array of ASCII bytes to a string. the byte array should contains
* only values in [0, 127].
*
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ArrayNamingEnumerationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ArrayNamingEnumerationTest.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ArrayNamingEnumerationTest.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ArrayNamingEnumerationTest.java Wed May 19 19:03:51 2010
@@ -22,8 +22,8 @@ package org.apache.directory.shared.ldap
import java.util.NoSuchElementException;
+import org.apache.commons.lang.ArrayUtils;
import org.apache.directory.shared.ldap.message.ArrayNamingEnumeration;
-import org.apache.directory.shared.ldap.util.ArrayUtils;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/CompareRequestImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/CompareRequestImplTest.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/CompareRequestImplTest.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/CompareRequestImplTest.java Wed May 19 19:03:51 2010
@@ -47,7 +47,7 @@ public class CompareRequestImplTest
private static final Map<String, Control> EMPTY_CONTROL_MAP = new HashMap<String, Control>();
/**
- * Tests the same object referrence for equality.
+ * Tests the same object reference for equality.
*/
@Test
public void testEqualsSameObj()
@@ -79,6 +79,37 @@ public class CompareRequestImplTest
/**
+ * Tests the same object reference for equal hashCode.
+ */
+ @Test
+ public void testHashCodeSameObj()
+ {
+ CompareRequestImpl req = new CompareRequestImpl( 5 );
+ assertTrue( req.hashCode() == req.hashCode() );
+ }
+
+
+ /**
+ * Tests for equal hashCode using exact copies.
+ */
+ @Test
+ public void testHashCodeExactCopy() throws LdapException
+ {
+ CompareRequestImpl req0 = new CompareRequestImpl( 5 );
+ req0.setName( new DN( "cn=admin,dc=example,dc=com" ) );
+ req0.setAttributeId( "objectClass" );
+ req0.setAssertionValue( "top" );
+
+ CompareRequestImpl req1 = new CompareRequestImpl( 5 );
+ req1.setName( new DN( "cn=admin,dc=example,dc=com" ) );
+ req1.setAttributeId( "objectClass" );
+ req1.setAssertionValue( "top" );
+
+ assertTrue( req0.hashCode() == req1.hashCode() );
+ }
+
+
+ /**
* Test for inequality when only the IDs are different.
*/
@Test
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/DeleteRequestImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/DeleteRequestImplTest.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/DeleteRequestImplTest.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/DeleteRequestImplTest.java Wed May 19 19:03:51 2010
@@ -46,7 +46,7 @@ public class DeleteRequestImplTest
private static final Map<String, Control> EMPTY_CONTROL_MAP = new HashMap<String, Control>();
/**
- * Tests the same object referrence for equality.
+ * Tests the same object reference for equality.
*/
@Test
public void testEqualsSameObj()
@@ -73,6 +73,33 @@ public class DeleteRequestImplTest
/**
+ * Tests the same object reference for equal hashCode.
+ */
+ @Test
+ public void testHashCodeSameObj()
+ {
+ DeleteRequestImpl req = new DeleteRequestImpl( 5 );
+ assertTrue( req.hashCode() == req.hashCode() );
+ }
+
+
+ /**
+ * Tests for equal hashCode using exact copies.
+ */
+ @Test
+ public void testHashCodeExactCopy() throws LdapException
+ {
+ DeleteRequestImpl req0 = new DeleteRequestImpl( 5 );
+ req0.setName( new DN( "cn=admin,dc=example,dc=com" ) );
+
+ DeleteRequestImpl req1 = new DeleteRequestImpl( 5 );
+ req1.setName( new DN( "cn=admin,dc=example,dc=com" ) );
+
+ assertTrue( req0.hashCode() == req1.hashCode() );
+ }
+
+
+ /**
* Test for inequality when only the IDs are different.
*/
@Test
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ExtendedRequestImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ExtendedRequestImplTest.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ExtendedRequestImplTest.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ExtendedRequestImplTest.java Wed May 19 19:03:51 2010
@@ -47,7 +47,7 @@ public class ExtendedRequestImplTest
private static final Map<String, Control> EMPTY_CONTROL_MAP = new HashMap<String, Control>();
/**
- * Tests the same object referrence for equality.
+ * Tests the same object reference for equality.
*/
@Test
public void testEqualsSameObj()
@@ -77,6 +77,35 @@ public class ExtendedRequestImplTest
/**
+ * Tests the same object reference for equal hashCode.
+ */
+ @Test
+ public void testHashCodeSameObj()
+ {
+ ExtendedRequestImpl req = new ExtendedRequestImpl( 5 );
+ assertTrue( req.hashCode() == req.hashCode() );
+ }
+
+
+ /**
+ * Tests for equal hashCode using exact copies.
+ */
+ @Test
+ public void testHashCodeExactCopy()
+ {
+ ExtendedRequestImpl req0 = new ExtendedRequestImpl( 5 );
+ req0.setOid( "1.1.1.1" );
+ req0.setPayload( "Hello World!".getBytes() );
+
+ ExtendedRequestImpl req1 = new ExtendedRequestImpl( 5 );
+ req1.setOid( "1.1.1.1" );
+ req1.setPayload( "Hello World!".getBytes() );
+
+ assertTrue( req0.hashCode() == req1.hashCode() );
+ }
+
+
+ /**
* Test for inequality when only the IDs are different.
*/
@Test
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ExtendedResponseImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ExtendedResponseImplTest.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ExtendedResponseImplTest.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ExtendedResponseImplTest.java Wed May 19 19:03:51 2010
@@ -228,6 +228,29 @@ public class ExtendedResponseImplTest
/**
+ * Tests for equal hashCode using the same object.
+ */
+ @Test
+ public void testHashCodeSameObj()
+ {
+ ExtendedResponseImpl resp = createStub();
+ assertTrue( resp.hashCode() == resp.hashCode() );
+ }
+
+
+ /**
+ * Tests for equal hashCode using an exact copy.
+ */
+ @Test
+ public void testHashCodeExactCopy()
+ {
+ ExtendedResponseImpl resp0 = createStub();
+ ExtendedResponseImpl resp1 = createStub();
+ assertTrue( resp0.hashCode() == resp1.hashCode() );
+ }
+
+
+ /**
* Tests inequality when messageIds are different.
*/
@Test
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/LdapResultImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/LdapResultImplTest.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/LdapResultImplTest.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/LdapResultImplTest.java Wed May 19 19:03:51 2010
@@ -176,6 +176,74 @@ public class LdapResultImplTest
/**
+ * Tests to make sure the two same objects have equal HashCode.
+ */
+ @Test
+ public void testHashCodeSameObj()
+ {
+ LdapResultImpl r0 = new LdapResultImpl();
+ assertTrue( r0.hashCode() == r0.hashCode() );
+ }
+
+
+ /**
+ * Tests to make sure a default LdapResultImpl has equal hashCode another one just
+ * created.
+ */
+ @Test
+ public void testHashCodeDefaultCopy()
+ {
+ LdapResultImpl r0 = new LdapResultImpl();
+ LdapResultImpl r1 = new LdapResultImpl();
+
+ assertTrue( r0.hashCode() == r1.hashCode() );
+ }
+
+
+ /**
+ * Tests for equal hashCode when the lockable parent is not the same.
+ */
+ @Test
+ public void testHashCodeDiffLockableParent()
+ {
+ LdapResultImpl r0 = new LdapResultImpl();
+ LdapResultImpl r1 = new LdapResultImpl();
+
+ assertTrue( r0.hashCode() == r1.hashCode() );
+ }
+
+
+ /**
+ * Tests two non default carbon copies for equal hashCode.
+ */
+ @Test
+ public void testHashCodeCarbonCopy() throws LdapException
+ {
+ LdapResultImpl r0 = new LdapResultImpl();
+ LdapResultImpl r1 = new LdapResultImpl();
+
+ r0.setErrorMessage( "blah blah blah" );
+ r1.setErrorMessage( "blah blah blah" );
+
+ r0.setMatchedDn( new DN( "dc=example,dc=com" ) );
+ r1.setMatchedDn( new DN( "dc=example,dc=com" ) );
+
+ r0.setResultCode( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
+ r1.setResultCode( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
+
+ InternalReferral refs0 = new ReferralImpl();
+ refs0.addLdapUrl( "ldap://someserver.com" );
+ refs0.addLdapUrl( "ldap://anotherserver.org" );
+
+ InternalReferral refs1 = new ReferralImpl();
+ refs1.addLdapUrl( "ldap://someserver.com" );
+ refs1.addLdapUrl( "ldap://anotherserver.org" );
+
+ assertTrue( r0.hashCode() == r1.hashCode() );
+ }
+
+
+ /**
* Tests for inequality when the error message is different.
*/
@Test
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ModifyDnRequestImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ModifyDnRequestImplTest.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ModifyDnRequestImplTest.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ModifyDnRequestImplTest.java Wed May 19 19:03:51 2010
@@ -73,7 +73,7 @@ public class ModifyDnRequestImplTest
/**
- * Tests the same object referrence for equality.
+ * Tests the same object reference for equality.
*/
@Test
public void testEqualsSameObj()
@@ -112,6 +112,45 @@ public class ModifyDnRequestImplTest
/**
+ * Tests the same object reference for equal hashCode
+ */
+ @Test
+ public void testHashCodeSameObj()
+ {
+ ModifyDnRequestImpl req = new ModifyDnRequestImpl( 5 );
+ assertTrue( req.hashCode() == req.hashCode() );
+ }
+
+
+ /**
+ * Tests for equal hashCode using exact copies.
+ */
+ @Test
+ public void testHashCodeExactCopy0()
+ {
+ ModifyDnRequestImpl req0 = getRequest();
+ ModifyDnRequestImpl req1 = getRequest();
+
+ assertTrue( req0.hashCode() == req1.hashCode() );
+ }
+
+
+ /**
+ * Tests for equal hashCode using exact copies.
+ */
+ @Test
+ public void testHashCodeExactCopy1()
+ {
+ ModifyDnRequestImpl req0 = getRequest();
+ req0.setNewSuperior( null );
+ ModifyDnRequestImpl req1 = getRequest();
+ req1.setNewSuperior( null );
+
+ assertTrue( req0.hashCode() == req1.hashCode() );
+ }
+
+
+ /**
* Test for inequality when only the IDs are different.
*/
@Test
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ModifyRequestImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ModifyRequestImplTest.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ModifyRequestImplTest.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ModifyRequestImplTest.java Wed May 19 19:03:51 2010
@@ -95,7 +95,7 @@ public class ModifyRequestImplTest
/**
- * Tests the same object referrence for equality.
+ * Tests the same object reference for equality.
*/
@Test
public void testEqualsSameObj()
@@ -118,6 +118,29 @@ public class ModifyRequestImplTest
/**
+ * Tests the same object reference for equal hashCode.
+ */
+ @Test
+ public void testHashCodeSameObj()
+ {
+ ModifyRequestImpl req = getRequest();
+ assertTrue( req.hashCode() == req.hashCode() );
+ }
+
+
+ /**
+ * Tests for equal hashCode using exact copies.
+ */
+ @Test
+ public void testHashCodeExactCopy()
+ {
+ ModifyRequestImpl req0 = getRequest();
+ ModifyRequestImpl req1 = getRequest();
+ assertTrue( req0.hashCode() == req1.hashCode() );
+ }
+
+
+ /**
* Test for inequality when only the IDs are different.
*/
@Test
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ReferralImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ReferralImplTest.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ReferralImplTest.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/ReferralImplTest.java Wed May 19 19:03:51 2010
@@ -92,6 +92,57 @@ public class ReferralImplTest
/**
+ * Tests to make sure to get equal hashCode for the same exact object.
+ */
+ @Test
+ public void testHashCodeSameObject()
+ {
+ ReferralImpl refs = new ReferralImpl();
+ assertTrue( refs.hashCode() == refs.hashCode() );
+ }
+
+
+ /**
+ * Tests to make sure to get equal hashCode for two objects that are the
+ * same exact copy of one another.
+ */
+ @Test
+ public void testHashCodeExactCopy()
+ {
+ ReferralImpl refs0 = new ReferralImpl();
+ refs0.addLdapUrl( "ldap://blah0" );
+ refs0.addLdapUrl( "ldap://blah1" );
+ refs0.addLdapUrl( "ldap://blah2" );
+ ReferralImpl refs1 = new ReferralImpl();
+ refs1.addLdapUrl( "ldap://blah0" );
+ refs1.addLdapUrl( "ldap://blah1" );
+ refs1.addLdapUrl( "ldap://blah2" );
+ assertTrue( refs0.hashCode() == refs1.hashCode() );
+ }
+
+
+ /**
+ * Tests to make sure to get equal hashCode for two objects that are the
+ * same exact copy of one another but there are redundant entries.
+ */
+ @Test
+ public void testHashCodeExactCopyWithRedundancy()
+ {
+ ReferralImpl refs0 = new ReferralImpl();
+ refs0.addLdapUrl( "ldap://blah0" );
+ refs0.addLdapUrl( "ldap://blah1" );
+ refs0.addLdapUrl( "ldap://blah2" );
+ refs0.addLdapUrl( "ldap://blah2" );
+ ReferralImpl refs1 = new ReferralImpl();
+ refs1.addLdapUrl( "ldap://blah0" );
+ refs1.addLdapUrl( "ldap://blah1" );
+ refs1.addLdapUrl( "ldap://blah2" );
+ refs1.addLdapUrl( "ldap://blah2" );
+ assertTrue( refs0.hashCode() == refs1.hashCode() );
+ }
+
+
+ /**
* Tests to make sure the equals method works for two objects that are the
* not exact copies of one another but have the same number of URLs.
*/
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseDoneImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseDoneImplTest.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseDoneImplTest.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseDoneImplTest.java Wed May 19 19:03:51 2010
@@ -188,6 +188,29 @@ public class SearchResponseDoneImplTest
/**
+ * Tests for equal hashCode using the same object.
+ */
+ @Test
+ public void testHashCodeSameObj()
+ {
+ SearchResponseDoneImpl resp = createStub();
+ assertTrue( resp.hashCode() == resp.hashCode() );
+ }
+
+
+ /**
+ * Tests for equal hashCode using an exact copy.
+ */
+ @Test
+ public void testHashCodeExactCopy()
+ {
+ SearchResponseDoneImpl resp0 = createStub();
+ SearchResponseDoneImpl resp1 = createStub();
+ assertTrue( resp0.hashCode() == resp1.hashCode() );
+ }
+
+
+ /**
* Tests inequality when messageIds are different.
*/
@Test
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseEntryImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseEntryImplTest.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseEntryImplTest.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseEntryImplTest.java Wed May 19 19:03:51 2010
@@ -73,7 +73,7 @@ public class SearchResponseEntryImplTest
/**
- * Tests for equality when the same object referrence is used.
+ * Tests for equality when the same object reference is used.
*/
@Test
public void testEqualsSameObject()
@@ -103,6 +103,35 @@ public class SearchResponseEntryImplTest
/**
+ * Tests for equal hashCode when the same object reference is used.
+ */
+ @Test
+ public void testHashCodeSameObject()
+ {
+ SearchResponseEntryImpl resp = new SearchResponseEntryImpl( 5 );
+ assertTrue( resp.hashCode() == resp.hashCode() );
+ }
+
+
+ /**
+ * Tests for equal hashCode when an exact copy is compared.
+ */
+ @Test
+ public void testHashCodeExactCopy() throws LdapException
+ {
+ SearchResponseEntryImpl resp0 = new SearchResponseEntryImpl( 5 );
+ resp0.setEntry( getEntry() );
+ resp0.setObjectName( new DN( "dc=example,dc=com" ) );
+
+ SearchResponseEntryImpl resp1 = new SearchResponseEntryImpl( 5 );
+ resp1.setEntry( getEntry() );
+ resp1.setObjectName( new DN( "dc=example,dc=com" ) );
+
+ assertTrue( resp0.hashCode() == resp1.hashCode() );
+ }
+
+
+ /**
* Tests for inequality when the objectName dn is not the same.
*/
@Test
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseReferenceImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseReferenceImplTest.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseReferenceImplTest.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseReferenceImplTest.java Wed May 19 19:03:51 2010
@@ -63,7 +63,7 @@ public class SearchResponseReferenceImpl
/**
- * Tests for equality when the same object referrence is used.
+ * Tests for equality when the same object reference is used.
*/
@Test
public void testEqualsSameObject()
@@ -169,6 +169,33 @@ public class SearchResponseReferenceImpl
/**
+ * Tests for equal hashCode when the same object reference is used.
+ */
+ @Test
+ public void testHashCodeSameObject()
+ {
+ SearchResponseReferenceImpl resp = new SearchResponseReferenceImpl( 5 );
+ getReferral( resp );
+ assertTrue( resp.hashCode() == resp.hashCode() );
+ }
+
+
+ /**
+ * Tests for equal hashCode when an exact copy is compared.
+ */
+ @Test
+ public void testHashCodeExactCopy()
+ {
+ SearchResponseReferenceImpl resp0 = new SearchResponseReferenceImpl( 5 );
+ getReferral( resp0 );
+ SearchResponseReferenceImpl resp1 = new SearchResponseReferenceImpl( 5 );
+ getReferral( resp1 );
+
+ assertTrue( resp0.hashCode() == resp1.hashCode() );
+ }
+
+
+ /**
* Tests for inequality when the urls are not the same.
*/
@Test
Modified: directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java?rev=946342&r1=946341&r2=946342&view=diff
==============================================================================
--- directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java (original)
+++ directory/shared/branches/xdbm-refactoring/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java Wed May 19 19:03:51 2010
@@ -47,29 +47,6 @@ import static org.junit.Assert.assertFal
public class StringToolsTest
{
@Test
- public void testDecodeEscapedHex() throws Exception
- {
- assertEquals( "Ferry", StringTools.decodeEscapedHex( "\\46\\65\\72\\72\\79" ) );
- assertEquals( "Ferry", StringTools.decodeEscapedHex( "Fe\\72\\72\\79" ) );
- assertEquals( "Ferry", StringTools.decodeEscapedHex( "Fe\\72\\72y" ) );
- assertEquals( "Ferry", StringTools.decodeEscapedHex( "Fe\\72ry" ) );
-
- assertEquals( "<DC", StringTools.decodeEscapedHex( "\\<DC" ) );
- assertEquals( ">DC", StringTools.decodeEscapedHex( "\\>DC" ) );
- assertEquals( "\"DC", StringTools.decodeEscapedHex( "\\\"DC" ) );
- assertEquals( "+DC", StringTools.decodeEscapedHex( "\\+DC" ) );
- assertEquals( ",DC", StringTools.decodeEscapedHex( "\\,DC" ) );
- assertEquals( ";DC", StringTools.decodeEscapedHex( "\\;DC" ) );
- assertEquals( "=DC", StringTools.decodeEscapedHex( "\\=DC" ) );
- assertEquals( " DC", StringTools.decodeEscapedHex( "\\ DC" ) );
- assertEquals( "#DC", StringTools.decodeEscapedHex( "\\#DC" ) );
-
- // test a corner case: ESC ESC HEX HEX
- assertEquals( "\\DC", StringTools.decodeEscapedHex( "\\5CDC" ) );
- assertEquals( "\\DC", StringTools.decodeEscapedHex( "\\\\DC" ) );
- }
-
- @Test
public void testDecodeHexString() throws Exception
{
// weird stuff - corner cases