Used the Strings.EMPTY_STRING instead of a new byte[0] in the code

git-svn-id: https://svn.apache.org/repos/asf/directory/apacheds/branches/apacheds-mvbt@1388934 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializer.java b/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializer.java
index b53c5a0..f5d55df 100644
--- a/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializer.java
+++ b/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializer.java
@@ -24,6 +24,8 @@
 
 import jdbm.helper.Serializer;
 
+import org.apache.directory.shared.util.Strings;
+
 
 /**
  * A custom String serializer to [de]serialize Strings.
@@ -67,8 +69,6 @@
         return new String( strchars );
     }
 
-    private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
-
 
     /* (non-Javadoc)
      * @see jdbm.helper.Serializer#serialize(java.lang.Object)
@@ -77,7 +77,7 @@
     {
         if ( ( ( String ) str ).length() == 0 )
         {
-            return EMPTY_BYTE_ARRAY;
+            return Strings.EMPTY_BYTES;
         }
 
         char[] strchars = ( ( String ) str ).toCharArray();
diff --git a/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java b/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java
index c69406c..fd8be0f 100644
--- a/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java
+++ b/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java
@@ -36,6 +36,7 @@
 import jdbm.helper.TupleBrowser;
 import jdbm.recman.BaseRecordManager;
 
+import org.apache.directory.shared.util.Strings;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -51,7 +52,6 @@
 public class KeyBTreeCursorTest
 {
     private static final Logger LOG = LoggerFactory.getLogger( KeyBTreeCursorTest.class.getSimpleName() );
-    private static final byte[] EMPTY_BYTES = new byte[0];
     private static final String TEST_OUTPUT_PATH = "test.output.path";
 
     File dbFile;
@@ -78,16 +78,16 @@
         bt = new BTree<String, byte[]>( recman, comparator );
 
         // add some data to it
-        bt.insert( "0", EMPTY_BYTES, true );
-        bt.insert( "1", EMPTY_BYTES, true );
-        bt.insert( "2", EMPTY_BYTES, true );
-        bt.insert( "3", EMPTY_BYTES, true );
-        bt.insert( "4", EMPTY_BYTES, true );
-        bt.insert( "5", EMPTY_BYTES, true );
-        bt.insert( "6", EMPTY_BYTES, true );
-        bt.insert( "7", EMPTY_BYTES, true );
-        bt.insert( "8", EMPTY_BYTES, true );
-        bt.insert( "9", EMPTY_BYTES, true );
+        bt.insert( "0", Strings.EMPTY_BYTES, true );
+        bt.insert( "1", Strings.EMPTY_BYTES, true );
+        bt.insert( "2", Strings.EMPTY_BYTES, true );
+        bt.insert( "3", Strings.EMPTY_BYTES, true );
+        bt.insert( "4", Strings.EMPTY_BYTES, true );
+        bt.insert( "5", Strings.EMPTY_BYTES, true );
+        bt.insert( "6", Strings.EMPTY_BYTES, true );
+        bt.insert( "7", Strings.EMPTY_BYTES, true );
+        bt.insert( "8", Strings.EMPTY_BYTES, true );
+        bt.insert( "9", Strings.EMPTY_BYTES, true );
 
         cursor = new KeyBTreeCursor<String>( bt, comparator );
         LOG.debug( "Created new KeyBTreeCursor and populated it's btree" );
@@ -106,7 +106,7 @@
         new File( fileToDelete + ".lg" ).delete();
 
         dbFile = null;
-        
+
         cursor.close();
     }
 
diff --git a/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java b/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java
index 57ff937..620d875 100644
--- a/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java
+++ b/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java
@@ -36,6 +36,7 @@
 import jdbm.helper.TupleBrowser;
 import jdbm.recman.BaseRecordManager;
 
+import org.apache.directory.shared.util.Strings;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -51,7 +52,6 @@
 public class KeyCursorTest
 {
     private static final Logger LOG = LoggerFactory.getLogger( KeyCursorTest.class.getSimpleName() );
-    private static final byte[] EMPTY_BYTES = new byte[0];
     private static final String TEST_OUTPUT_PATH = "test.output.path";
 
     File dbFile;
@@ -78,16 +78,16 @@
         bt = new BTree<String, byte[]>( recman, comparator );
 
         // add some data to it
-        bt.insert( "0", EMPTY_BYTES, true );
-        bt.insert( "1", EMPTY_BYTES, true );
-        bt.insert( "2", EMPTY_BYTES, true );
-        bt.insert( "3", EMPTY_BYTES, true );
-        bt.insert( "4", EMPTY_BYTES, true );
-        bt.insert( "5", EMPTY_BYTES, true );
-        bt.insert( "6", EMPTY_BYTES, true );
-        bt.insert( "7", EMPTY_BYTES, true );
-        bt.insert( "8", EMPTY_BYTES, true );
-        bt.insert( "9", EMPTY_BYTES, true );
+        bt.insert( "0", Strings.EMPTY_BYTES, true );
+        bt.insert( "1", Strings.EMPTY_BYTES, true );
+        bt.insert( "2", Strings.EMPTY_BYTES, true );
+        bt.insert( "3", Strings.EMPTY_BYTES, true );
+        bt.insert( "4", Strings.EMPTY_BYTES, true );
+        bt.insert( "5", Strings.EMPTY_BYTES, true );
+        bt.insert( "6", Strings.EMPTY_BYTES, true );
+        bt.insert( "7", Strings.EMPTY_BYTES, true );
+        bt.insert( "8", Strings.EMPTY_BYTES, true );
+        bt.insert( "9", Strings.EMPTY_BYTES, true );
 
         cursor = new KeyBTreeCursor<String>( bt, comparator );
         LOG.debug( "Created new KeyBTreeCursor and populated it's btree" );
@@ -106,7 +106,7 @@
         new File( fileToDelete + ".lg" ).delete();
 
         dbFile = null;
-        
+
         cursor.close();
     }
 
diff --git a/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/Des3CbcSha1KdEncryption.java b/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/Des3CbcSha1KdEncryption.java
index b77c2de..2ae8942 100644
--- a/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/Des3CbcSha1KdEncryption.java
+++ b/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/Des3CbcSha1KdEncryption.java
@@ -31,12 +31,13 @@
 import javax.crypto.spec.SecretKeySpec;
 
 import org.apache.directory.server.kerberos.shared.crypto.checksum.ChecksumEngine;
-import org.apache.directory.shared.kerberos.exceptions.KerberosException;
 import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
 import org.apache.directory.shared.kerberos.components.EncryptedData;
 import org.apache.directory.shared.kerberos.components.EncryptionKey;
 import org.apache.directory.shared.kerberos.crypto.checksum.ChecksumType;
 import org.apache.directory.shared.kerberos.exceptions.ErrorType;
+import org.apache.directory.shared.kerberos.exceptions.KerberosException;
+import org.apache.directory.shared.util.Strings;
 
 
 /**
@@ -172,7 +173,7 @@
         int kBytes = 24;
         byte[] result = new byte[kBytes];
 
-        byte[] fillingKey = new byte[0];
+        byte[] fillingKey = Strings.EMPTY_BYTES;
 
         int pos = 0;
 
diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TransitedEncoding.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TransitedEncoding.java
index 6a0b1d3..e0d9662 100644
--- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TransitedEncoding.java
+++ b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TransitedEncoding.java
@@ -27,9 +27,9 @@
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.shared.asn1.AbstractAsn1Object;
 import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.asn1.ber.tlv.BerValue;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.shared.asn1.ber.tlv.BerValue;
 import org.apache.directory.shared.kerberos.KerberosConstants;
 import org.apache.directory.shared.kerberos.codec.types.TransitedEncodingType;
 import org.apache.directory.shared.util.Strings;
@@ -80,7 +80,7 @@
     public TransitedEncoding()
     {
         trType = TransitedEncodingType.NULL;
-        contents = new byte[0];
+        contents = Strings.EMPTY_BYTES;
     }
 
 
diff --git a/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java b/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java
index f9fed3b..92ca29d 100644
--- a/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java
+++ b/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java
@@ -42,6 +42,7 @@
 
 import org.apache.directory.ldap.client.api.Krb5LoginConfiguration;
 import org.apache.directory.server.i18n.I18n;
+import org.apache.directory.shared.util.Strings;
 import org.ietf.jgss.GSSContext;
 import org.ietf.jgss.GSSCredential;
 import org.ietf.jgss.GSSException;
@@ -392,9 +393,9 @@
                 context.requestConf( true );
                 context.requestInteg( true );
 
-                context.initSecContext( new byte[0], 0, 0 );
+                context.initSecContext( Strings.EMPTY_BYTES, 0, 0 );
 
-                // byte[] outToken = context.initSecContext( new byte[0], 0, 0 );
+                // byte[] outToken = context.initSecContext( Strings.EMPTY_BYTES, 0, 0 );
                 // System.out.println(new BASE64Encoder().encode(outToken));
                 context.dispose();
 
diff --git a/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java b/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java
index f860de6..4891f53 100644
--- a/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java
+++ b/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java
@@ -24,6 +24,7 @@
 import java.nio.ByteBuffer;
 import java.util.Date;
 import java.util.List;
+
 import javax.security.auth.kerberos.KerberosKey;
 import javax.security.auth.kerberos.KerberosPrincipal;
 
@@ -68,6 +69,7 @@
 import org.apache.directory.shared.kerberos.messages.AsRep;
 import org.apache.directory.shared.kerberos.messages.EncAsRepPart;
 import org.apache.directory.shared.kerberos.messages.Ticket;
+import org.apache.directory.shared.util.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -301,7 +303,8 @@
                 if ( timestamp == null )
                 {
                     throw new KerberosException( ErrorType.KDC_ERR_PREAUTH_REQUIRED,
-                        preparePreAuthenticationError( authContext.getRequest().getKdcReqBody().getEType(), config.getEncryptionTypes() ) );
+                        preparePreAuthenticationError( authContext.getRequest().getKdcReqBody().getEType(),
+                            config.getEncryptionTypes() ) );
                 }
 
                 if ( !timestamp.getPaTimestamp().isInClockSkew( config.getAllowableClockSkew() ) )
@@ -788,13 +791,14 @@
      * @param encryptionTypes
      * @return The error message as bytes.
      */
-    private static byte[] preparePreAuthenticationError( List<EncryptionType> clientEncryptionTypes, List<EncryptionType> serverEncryptionTypes )
+    private static byte[] preparePreAuthenticationError( List<EncryptionType> clientEncryptionTypes,
+        List<EncryptionType> serverEncryptionTypes )
     {
         PaData[] paDataSequence = new PaData[2];
 
         PaData paData = new PaData();
         paData.setPaDataType( PaDataType.PA_ENC_TIMESTAMP );
-        paData.setPaDataValue( new byte[0] );
+        paData.setPaDataValue( Strings.EMPTY_BYTES );
 
         paDataSequence[0] = paData;
 
diff --git a/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/AbstractSaslServer.java b/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/AbstractSaslServer.java
index 3ddd1fa..7f8d0bd 100644
--- a/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/AbstractSaslServer.java
+++ b/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/AbstractSaslServer.java
@@ -27,6 +27,7 @@
 import org.apache.directory.server.ldap.LdapSession;
 import org.apache.directory.shared.ldap.model.message.BindRequest;
 import org.apache.directory.shared.util.StringConstants;
+import org.apache.directory.shared.util.Strings;
 
 
 /**
@@ -73,7 +74,7 @@
      */
     public byte[] wrap( byte[] outgoing, int offset, int len ) throws SaslException
     {
-        return new byte[0];
+        return Strings.EMPTY_BYTES;
     }
 
 
diff --git a/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java b/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
index defbbf6..2bb81dd 100644
--- a/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
+++ b/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
@@ -49,6 +49,7 @@
 import org.apache.directory.shared.ldap.model.message.ExtendedResponseImpl;
 import org.apache.directory.shared.ldap.model.message.LdapResult;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
 import org.apache.mina.core.filterchain.IoFilterChain;
 import org.apache.mina.filter.ssl.SslFilter;
 import org.slf4j.Logger;
@@ -99,7 +100,7 @@
         LdapResult result = res.getLdapResult();
         result.setResultCode( ResultCodeEnum.SUCCESS );
         res.setResponseName( EXTENSION_OID );
-        res.setResponseValue( new byte[0] );
+        res.setResponseValue( Strings.EMPTY_BYTES );
 
         // Send a response.
         session.getIoSession().setAttribute( SslFilter.DISABLE_ENCRYPTION_ONCE );
diff --git a/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java b/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
index 5850034..a815818 100644
--- a/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
+++ b/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
@@ -23,7 +23,6 @@
 import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredConnection;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
-
 import netscape.ldap.LDAPConnection;
 import netscape.ldap.LDAPConstraints;
 import netscape.ldap.LDAPControl;
@@ -38,6 +37,7 @@
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.model.exception.LdapAuthenticationException;
 import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.shared.util.Strings;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -160,8 +160,8 @@
     {
         LDAPConnection conn = new LDAPConnection();
         LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
+        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
         conn.setConstraints( constraints );
 
         try
diff --git a/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java b/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java
index ebdcaaf..714b0c7 100644
--- a/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java
+++ b/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java
@@ -707,8 +707,8 @@
     {
         LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
         LDAPConstraints constraints = new LDAPSearchConstraints();
-        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
+        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
         conn.setConstraints( constraints );
 
         // add success
diff --git a/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/BindIT.java b/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/BindIT.java
index 4bfc5d3..fcfb334 100644
--- a/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/BindIT.java
+++ b/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/BindIT.java
@@ -39,6 +39,7 @@
 import org.apache.directory.server.core.annotations.CreateDS;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.util.Strings;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -179,8 +180,8 @@
     {
         LDAPConnection conn = new LDAPConnection();
         LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
+        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
         conn.setConstraints( constraints );
 
         try
diff --git a/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/CompareIT.java b/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/CompareIT.java
index b79a970..0146e52 100644
--- a/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/CompareIT.java
+++ b/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/CompareIT.java
@@ -50,6 +50,7 @@
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -159,8 +160,8 @@
     {
         LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
         LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
+        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
         conn.setConstraints( constraints );
 
         // comparison success
diff --git a/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/DeleteIT.java b/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/DeleteIT.java
index 1191c86..a9ac321 100644
--- a/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/DeleteIT.java
+++ b/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/DeleteIT.java
@@ -49,6 +49,7 @@
 import org.apache.directory.shared.ldap.model.exception.LdapContextNotEmptyException;
 import org.apache.directory.shared.ldap.model.exception.LdapNoSuchObjectException;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -185,8 +186,8 @@
     {
         LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
         LDAPConstraints constraints = new LDAPSearchConstraints();
-        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
+        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
         conn.setConstraints( constraints );
 
         // delete success
diff --git a/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyDnReferralIT.java b/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyDnReferralIT.java
index 7039d99..d7c6ec4 100644
--- a/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyDnReferralIT.java
+++ b/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyDnReferralIT.java
@@ -45,6 +45,7 @@
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -103,196 +104,196 @@
 })
 public class ModifyDnReferralIT extends AbstractLdapTestUnit
 {
-    @Rule
-    public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
-    private static final Logger LOG = LoggerFactory.getLogger( ModifyDnReferralIT.class );
-    
-    
-    /**
-     * Tests ModifyDN operation on referral entry with the ManageDsaIT control.
-     */
-    @Test
-    public void testOnReferralWithManageDsaITControl() throws Exception
+@Rule
+public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
+private static final Logger LOG = LoggerFactory.getLogger( ModifyDnReferralIT.class );
+
+
+/**
+ * Tests ModifyDN operation on referral entry with the ManageDsaIT control.
+ */
+@Test
+public void testOnReferralWithManageDsaITControl() throws Exception
+{
+    LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+    LDAPConstraints constraints = new LDAPSearchConstraints();
+    constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+    constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+    conn.setConstraints( constraints );
+
+    // ModifyDN success
+    conn.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref", true, constraints );
+    LDAPEntry entry = conn.read( "uid=ref,ou=users,ou=system", ( LDAPSearchConstraints ) constraints );
+    assertNotNull( entry );
+    assertEquals( "uid=ref,ou=users,ou=system", entry.getDN() );
+
+    conn.disconnect();
+}
+
+
+/**
+ * Tests ModifyDN operation with newSuperior on referral entry with the
+ * ManageDsaIT control.
+ */
+@Test
+public void testNewSuperiorOnReferralWithManageDsaITControl() throws Exception
+{
+    LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+    LDAPConstraints constraints = new LDAPSearchConstraints();
+    constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+    constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+    conn.setConstraints( constraints );
+
+    // ModifyDN success
+    try
     {
-        LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPSearchConstraints();
-        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        conn.setConstraints( constraints );
-    
-        // ModifyDN success
-        conn.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref", true, constraints );
-        LDAPEntry entry = conn.read( "uid=ref,ou=users,ou=system", ( LDAPSearchConstraints ) constraints );
-        assertNotNull( entry );
-        assertEquals( "uid=ref,ou=users,ou=system", entry.getDN() );
-    
-        conn.disconnect();
+        conn.rename( "uid=elecharny,ou=users,ou=system", "uid=newuser",
+            "uid=akarasuluref,ou=users,ou=system", true, constraints );
     }
-    
-    
-    /**
-     * Tests ModifyDN operation with newSuperior on referral entry with the
-     * ManageDsaIT control.
-     */
-    @Test
-    public void testNewSuperiorOnReferralWithManageDsaITControl() throws Exception
+    catch ( LDAPException le )
     {
-        LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPSearchConstraints();
-        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        conn.setConstraints( constraints );
-    
-        // ModifyDN success
-        try
-        {
-            conn.rename( "uid=elecharny,ou=users,ou=system", "uid=newuser",
-                "uid=akarasuluref,ou=users,ou=system", true, constraints );
-        }
-        catch ( LDAPException le )
-        {
-            assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, le.getLDAPResultCode() );
-        }
-    
-        conn.disconnect();
+        assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, le.getLDAPResultCode() );
     }
-    
-    
-    /**
-     * Tests ModifyDN operation on normal and referral entries without the
-     * ManageDsaIT control. Referrals are sent back to the client with a
-     * non-success result code.
-     */
-    @Test
-    public void testOnReferral() throws Exception
+
+    conn.disconnect();
+}
+
+
+/**
+ * Tests ModifyDN operation on normal and referral entries without the
+ * ManageDsaIT control. Referrals are sent back to the client with a
+ * non-success result code.
+ */
+@Test
+public void testOnReferral() throws Exception
+{
+    LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+    LDAPConstraints constraints = new LDAPConstraints();
+    constraints.setReferrals( false );
+    conn.setConstraints( constraints );
+
+    // referrals failure
+    LDAPResponseListener listener = null;
+    LDAPResponse response = null;
+
+    listener = conn.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref", true, null, constraints );
+    response = listener.getResponse();
+    assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
+
+    assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
+    assertEquals( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
+    assertEquals( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+
+    conn.disconnect();
+}
+
+
+/**
+ * Tests ModifyDN operation on normal and referral entries without the
+ * ManageDsaIT control. Referrals are sent back to the client with a
+ * non-success result code.
+ */
+@Test
+public void testNewSupierorOnReferral() throws Exception
+{
+    LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+    LDAPConstraints constraints = new LDAPConstraints();
+    constraints.setReferrals( false );
+    conn.setConstraints( constraints );
+
+    // referrals failure
+    try
     {
-        LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setReferrals( false );
-        conn.setConstraints( constraints );
-    
-        // referrals failure
-        LDAPResponseListener listener = null;
-        LDAPResponse response = null;
-    
-        listener = conn.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref", true, null, constraints );
-        response = listener.getResponse();
-        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-    
-        assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
-        assertEquals( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
-        assertEquals( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
-    
-        conn.disconnect();
+        conn.rename( "uid=elecharny,ou=users,ou=system", "uid=ref",
+            "uid=akarasuluref,ou=users,ou=system", true, constraints );
     }
-    
-    
-    /**
-     * Tests ModifyDN operation on normal and referral entries without the
-     * ManageDsaIT control. Referrals are sent back to the client with a
-     * non-success result code.
-     */
-    @Test
-    public void testNewSupierorOnReferral() throws Exception
+    catch ( LDAPException e )
     {
-        LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setReferrals( false );
-        conn.setConstraints( constraints );
-    
-        // referrals failure
-        try
-        {
-            conn.rename( "uid=elecharny,ou=users,ou=system", "uid=ref",
-                "uid=akarasuluref,ou=users,ou=system", true, constraints );
-        }
-        catch ( LDAPException e )
-        {
-            assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, e.getLDAPResultCode() );
-        }
-    
-        conn.disconnect();
+        assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, e.getLDAPResultCode() );
     }
-    
-    
-    /**
-     * Tests ModifyDN operation on normal and referral entries without the
-     * ManageDsaIT control using JNDI instead of the Netscape API. Referrals
-     * are sent back to the client with a non-success result code.
-     */
-    @Test
-    public void testThrowOnReferralWithJndi() throws Exception
+
+    conn.disconnect();
+}
+
+
+/**
+ * Tests ModifyDN operation on normal and referral entries without the
+ * ManageDsaIT control using JNDI instead of the Netscape API. Referrals
+ * are sent back to the client with a non-success result code.
+ */
+@Test
+public void testThrowOnReferralWithJndi() throws Exception
+{
+    LdapContext ctx = getWiredContextThrowOnRefferal( getLdapServer() );
+
+    // ModifyDN referrals failure
+    try
     {
-        LdapContext ctx = getWiredContextThrowOnRefferal( getLdapServer() );
-    
-        // ModifyDN referrals failure
-        try
-        {
-            ctx.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref,ou=users,ou=system" );
-            fail( "Should never get here due to ModifyDN failure on ReferralException" );
-        }
-        catch ( ReferralException e )
-        {
-            // seems JNDI only returns the first referral URL and not all so we test for it
-            assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", e.getReferralInfo() );
-        }
-    
-        ctx.close();
+        ctx.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref,ou=users,ou=system" );
+        fail( "Should never get here due to ModifyDN failure on ReferralException" );
     }
-    
-    
-    /**
-     * Tests referral handling when an ancestor is a referral.
-     */
-    @Test
-    public void testAncestorReferral() throws Exception
+    catch ( ReferralException e )
     {
-        LOG.debug( "" );
-    
-        LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        conn.setConstraints( constraints );
-    
-        // referrals failure
-        LDAPResponseListener listener = null;
-        LDAPResponse response = null;
-    
-        listener = conn.rename( "ou=Computers,uid=akarasuluref,ou=users,ou=system", "ou=Machines", true, null, constraints );
-        response = listener.getResponse();
-        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-    
-        assertEquals( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
-        assertEquals( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
-        assertEquals( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
-    
-        conn.disconnect();
+        // seems JNDI only returns the first referral URL and not all so we test for it
+        assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", e.getReferralInfo() );
     }
-    
-    
-    /**
-     * Tests referral handling when an ancestor is a referral.
-     */
-    @Test
-    public void testNewSuperiorAncestorReferral() throws Exception
+
+    ctx.close();
+}
+
+
+/**
+ * Tests referral handling when an ancestor is a referral.
+ */
+@Test
+public void testAncestorReferral() throws Exception
+{
+    LOG.debug( "" );
+
+    LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+    LDAPConstraints constraints = new LDAPConstraints();
+    conn.setConstraints( constraints );
+
+    // referrals failure
+    LDAPResponseListener listener = null;
+    LDAPResponse response = null;
+
+    listener = conn.rename( "ou=Computers,uid=akarasuluref,ou=users,ou=system", "ou=Machines", true, null, constraints );
+    response = listener.getResponse();
+    assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
+
+    assertEquals( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
+    assertEquals( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
+    assertEquals( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+
+    conn.disconnect();
+}
+
+
+/**
+ * Tests referral handling when an ancestor is a referral.
+ */
+@Test
+public void testNewSuperiorAncestorReferral() throws Exception
+{
+    LOG.debug( "" );
+
+    LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+    LDAPConstraints constraints = new LDAPConstraints();
+    conn.setConstraints( constraints );
+
+    // referrals failure
+    try
     {
-        LOG.debug( "" );
-    
-        LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        conn.setConstraints( constraints );
-    
-        // referrals failure
-        try
-        {
-            conn.rename( "uid=elecharny,ou=users,ou=system", "ou=Machines",
-                "ou=Computers,uid=akarasuluref,ou=users,ou=system", true, constraints );
-            fail( "Should never get here to affectsMultipleDSA error result code" );
-        }
-        catch ( LDAPException e )
-        {
-            assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, e.getLDAPResultCode() );
-        }
-    
-        conn.disconnect();
+        conn.rename( "uid=elecharny,ou=users,ou=system", "ou=Machines",
+            "ou=Computers,uid=akarasuluref,ou=users,ou=system", true, constraints );
+        fail( "Should never get here to affectsMultipleDSA error result code" );
     }
+    catch ( LDAPException e )
+    {
+        assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, e.getLDAPResultCode() );
+    }
+
+    conn.disconnect();
+}
 }
diff --git a/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyReferralIT.java b/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyReferralIT.java
index 629d071..044386a 100644
--- a/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyReferralIT.java
+++ b/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyReferralIT.java
@@ -48,6 +48,7 @@
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.server.operations.compare.CompareIT;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -111,119 +112,119 @@
 })
 public class ModifyReferralIT extends AbstractLdapTestUnit
 {
-    @Rule
-    public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
-    private static final Logger LOG = LoggerFactory.getLogger( CompareIT.class );
-    
-    
-    /**
-     * Tests modify operation on referral entry with the ManageDsaIT control.
-     */
-    @Test
-    public void testOnReferralWithManageDsaITControl() throws Exception
+@Rule
+public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
+private static final Logger LOG = LoggerFactory.getLogger( CompareIT.class );
+
+
+/**
+ * Tests modify operation on referral entry with the ManageDsaIT control.
+ */
+@Test
+public void testOnReferralWithManageDsaITControl() throws Exception
+{
+    LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+    LDAPConstraints constraints = new LDAPConstraints();
+    constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+    constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+    conn.setConstraints( constraints );
+
+    // modify success
+    LDAPAttribute attribute = new LDAPAttribute( "description", "referral to akarasulu" );
+    LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
+    conn.modify( "uid=akarasuluref,ou=users,ou=system", mod, constraints );
+
+    assertTrue( conn.compare( "uid=akarasuluref,ou=users,ou=system", attribute, constraints ) );
+
+    conn.disconnect();
+}
+
+
+/**
+ * Tests modify operation on referral entries without the
+ * ManageDsaIT control. Referrals are sent back to the client with a
+ * non-success result code.
+ */
+@Test
+public void testOnReferral() throws Exception
+{
+    LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+    LDAPConstraints constraints = new LDAPConstraints();
+    constraints.setReferrals( false );
+    conn.setConstraints( constraints );
+
+    // referrals failure
+    // modify success
+    LDAPAttribute attribute = new LDAPAttribute( "description", "referral to akarasulu" );
+    LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
+    LDAPResponseListener listener = conn.modify( "uid=akarasuluref,ou=users,ou=system", mod, null, constraints );
+    LDAPResponse response = listener.getResponse();
+
+    assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
+
+    assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
+    assertEquals( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
+    assertEquals( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+
+    conn.disconnect();
+}
+
+
+/**
+ * Tests modify operation on normal and referral entries without the
+ * ManageDsaIT control using JNDI instead of the Netscape API. Referrals
+ * are sent back to the client with a non-success result code.
+ */
+@Test
+public void testThrowOnReferralWithJndi() throws Exception
+{
+    LdapContext ctx = getWiredContextThrowOnRefferal( getLdapServer() );
+
+    // modify failure
+    Attribute attr = new BasicAttribute( "description", "referral to akarasulu" );
+    ModificationItem mod = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
+
+    try
     {
-        LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        conn.setConstraints( constraints );
-    
-        // modify success
-        LDAPAttribute attribute = new LDAPAttribute( "description", "referral to akarasulu" );
-        LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
-        conn.modify( "uid=akarasuluref,ou=users,ou=system", mod, constraints );
-    
-        assertTrue( conn.compare( "uid=akarasuluref,ou=users,ou=system", attribute, constraints ) );
-    
-        conn.disconnect();
+        ctx.modifyAttributes( "uid=akarasuluref,ou=users,ou=system", new ModificationItem[]
+            { mod } );
     }
-    
-    
-    /**
-     * Tests modify operation on referral entries without the
-     * ManageDsaIT control. Referrals are sent back to the client with a
-     * non-success result code.
-     */
-    @Test
-    public void testOnReferral() throws Exception
+    catch ( ReferralException e )
     {
-        LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setReferrals( false );
-        conn.setConstraints( constraints );
-    
-        // referrals failure
-        // modify success
-        LDAPAttribute attribute = new LDAPAttribute( "description", "referral to akarasulu" );
-        LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
-        LDAPResponseListener listener = conn.modify( "uid=akarasuluref,ou=users,ou=system", mod, null, constraints );
-        LDAPResponse response = listener.getResponse();
-    
-        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-    
-        assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
-        assertEquals( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
-        assertEquals( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
-    
-        conn.disconnect();
+        // seems JNDI only returns the first referral URL and not all so we test for it
+        assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", e.getReferralInfo() );
     }
-    
-    
-    /**
-     * Tests modify operation on normal and referral entries without the
-     * ManageDsaIT control using JNDI instead of the Netscape API. Referrals
-     * are sent back to the client with a non-success result code.
-     */
-    @Test
-    public void testThrowOnReferralWithJndi() throws Exception
-    {
-        LdapContext ctx = getWiredContextThrowOnRefferal( getLdapServer() );
-    
-        // modify failure
-        Attribute attr = new BasicAttribute( "description", "referral to akarasulu" );
-        ModificationItem mod = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
-    
-        try
-        {
-            ctx.modifyAttributes( "uid=akarasuluref,ou=users,ou=system", new ModificationItem[]
-                { mod } );
-        }
-        catch ( ReferralException e )
-        {
-            // seems JNDI only returns the first referral URL and not all so we test for it
-            assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", e.getReferralInfo() );
-        }
-    
-        ctx.close();
-    }
-    
-    
-    /**
-     * Tests referral handling when an ancestor is a referral.
-     */
-    @Test
-    public void testAncestorReferral() throws Exception
-    {
-        LOG.debug( "" );
-    
-        LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        conn.setConstraints( constraints );
-    
-        // referrals failure
-        LDAPAttribute attribute = new LDAPAttribute( "ou", "Machines" );
-        LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
-        LDAPResponseListener listener = null;
-        LDAPResponse response = null;
-    
-        listener = conn.modify( "ou=Computers,uid=akarasuluref,ou=users,ou=system", mod, null, constraints );
-        response = listener.getResponse();
-        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-    
-        assertEquals( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
-        assertEquals( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
-        assertEquals( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
-    
-        conn.disconnect();
-    }
+
+    ctx.close();
+}
+
+
+/**
+ * Tests referral handling when an ancestor is a referral.
+ */
+@Test
+public void testAncestorReferral() throws Exception
+{
+    LOG.debug( "" );
+
+    LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+    LDAPConstraints constraints = new LDAPConstraints();
+    conn.setConstraints( constraints );
+
+    // referrals failure
+    LDAPAttribute attribute = new LDAPAttribute( "ou", "Machines" );
+    LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
+    LDAPResponseListener listener = null;
+    LDAPResponse response = null;
+
+    listener = conn.modify( "ou=Computers,uid=akarasuluref,ou=users,ou=system", mod, null, constraints );
+    response = listener.getResponse();
+    assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
+
+    assertEquals( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
+    assertEquals( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
+    assertEquals( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+
+    conn.disconnect();
+}
 }