You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/09/24 04:17:20 UTC
svn commit: r1389184 [4/13] - in /directory/apacheds/trunk:
core-annotations/src/main/java/org/apache/directory/server/core/factory/
core-api/src/main/java/org/apache/directory/server/core/api/
core-api/src/main/java/org/apache/directory/server/core/ap...
Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java Mon Sep 24 02:17:13 2012
@@ -24,6 +24,7 @@ import java.net.InetAddress;
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.kerbe
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 @@ public class AuthenticationService
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 @@ public class AuthenticationService
* @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;
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java Mon Sep 24 02:17:13 2012
@@ -178,7 +178,10 @@ public class SearchHandler extends LdapR
*/
public final void handle( LdapSession session, SearchRequest req ) throws Exception
{
- LOG.debug( "Handling single reply request: {}", req );
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Handling single reply request: {}", req );
+ }
// check first for the syncrepl search request decorator
if ( req.getControls().containsKey( SyncRequestValue.OID ) )
@@ -244,25 +247,26 @@ public class SearchHandler extends LdapR
{
Map<String, Control> controlMap = req.getControls();
Control[] controls = null;
-
+
if ( controlMap != null )
{
Collection<Control> controlValues = controlMap.values();
-
+
controls = new Control[controlValues.size()];
int pos = 0;
-
+
for ( Control control : controlMap.values() )
{
controls[pos++] = control;
}
}
-
+
Entry entry = session.getCoreSession().lookup(
req.getBase(),
controls,
- req.getAttributes().toArray( new String[]{} ) );
-
+ req.getAttributes().toArray( new String[]
+ {} ) );
+
session.getIoSession().write( generateResponse( session, req, entry ) );
// write the SearchResultDone message
@@ -376,20 +380,34 @@ public class SearchHandler extends LdapR
if ( session.getIoSession().isClosing() )
{
// The client has closed the connection
- LOG.debug( "Request terminated for message {}, the client has closed the session", req.getMessageId() );
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Request terminated for message {}, the client has closed the session",
+ req.getMessageId() );
+ }
+
break;
}
if ( req.isAbandoned() )
{
// The cursor has been closed by an abandon request.
- LOG.debug( "Request terminated by an AbandonRequest for message {}", req.getMessageId() );
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Request terminated by an AbandonRequest for message {}", req.getMessageId() );
+ }
+
break;
}
Entry entry = cursor.get();
session.getIoSession().write( generateResponse( session, req, entry ) );
- LOG.debug( "Sending {}", entry.getDn() );
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Sending {}", entry.getDn() );
+ }
+
count++;
}
@@ -414,7 +432,12 @@ public class SearchHandler extends LdapR
{
req.addAbandonListener( new SearchAbandonListener( ldapServer, cursor ) );
setTimeLimitsOnCursor( req, session, cursor );
- LOG.debug( "using <{},{}> for size limit", sizeLimit, pagedLimit );
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "using <{},{}> for size limit", sizeLimit, pagedLimit );
+ }
+
int cookieValue = 0;
int count = pagedContext.getCurrentPosition();
@@ -796,7 +819,12 @@ public class SearchHandler extends LdapR
req.addAbandonListener( new SearchAbandonListener( ldapServer, cursor ) );
setTimeLimitsOnCursor( req, session, cursor );
- LOG.debug( "using <{},{}> for size limit", requestLimit, serverLimit );
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "using <{},{}> for size limit", requestLimit, serverLimit );
+ }
+
long sizeLimit = min( requestLimit, serverLimit );
readResults( session, req, ldapResult, cursor, sizeLimit );
@@ -976,8 +1004,8 @@ public class SearchHandler extends LdapR
// using varags to add two expressions to an OR node
req.setFilter( new OrNode( req.getFilter(), newIsReferralEqualityNode( session ) ) );
}
-
-
+
+
/**
* Handles the RootDSE and lookups searches
*/
@@ -1003,20 +1031,20 @@ public class SearchHandler extends LdapR
}
}
-/*
- if ( isBaseScope && isObjectClassFilter )
- {
- // This is a lookup
- handleLookup( session, req );
+ /*
+ if ( isBaseScope && isObjectClassFilter )
+ {
+ // This is a lookup
+ handleLookup( session, req );
- return true;
- }
- else
- {
- // a standard search
- return false;
- }
-*/
+ return true;
+ }
+ else
+ {
+ // a standard search
+ return false;
+ }
+ */
boolean isBaseIsRoot = req.getBase().isEmpty();
if ( isBaseScope && isObjectClassFilter )
@@ -1080,7 +1108,6 @@ public class SearchHandler extends LdapR
{
return;
}
-
// modify the filter to affect continuation support
modifyFilter( session, req );
@@ -1185,8 +1212,13 @@ public class SearchHandler extends LdapR
{
// This is not a referral and it does not have a parent which
// is a referral : standard case, just deal with the request
- LOG.debug( "Entry {} is NOT a referral.", reqTargetDn );
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Entry {} is NOT a referral.", reqTargetDn );
+ }
+
handleIgnoringReferrals( session, req );
+
return;
}
else
@@ -1202,7 +1234,11 @@ public class SearchHandler extends LdapR
try
{
entry = session.getCoreSession().lookup( reqTargetDn );
- LOG.debug( "Entry for {} was found: ", reqTargetDn, entry );
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Entry for {} was found: ", reqTargetDn, entry );
+ }
}
catch ( LdapException e )
{
@@ -1213,6 +1249,7 @@ public class SearchHandler extends LdapR
{
/* serious and needs handling */
handleException( session, req, e );
+
return;
}
@@ -1224,7 +1261,10 @@ public class SearchHandler extends LdapR
{
try
{
- LOG.debug( "Entry is a referral: {}", entry );
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Entry is a referral: {}", entry );
+ }
handleReferralEntryForSearch( session, req, entry );
@@ -1256,6 +1296,7 @@ public class SearchHandler extends LdapR
catch ( Exception e )
{
handleException( session, req, e );
+
return;
}
@@ -1264,6 +1305,7 @@ public class SearchHandler extends LdapR
result.setDiagnosticMessage( "Entry not found." );
result.setResultCode( ResultCodeEnum.NO_SUCH_OBJECT );
session.getIoSession().write( req.getResultResponse() );
+
return;
}
@@ -1389,7 +1431,10 @@ public class SearchHandler extends LdapR
public Referral getReferralOnAncestorForSearch( LdapSession session, SearchRequest req,
Entry referralAncestor ) throws Exception
{
- LOG.debug( "Inside getReferralOnAncestor()" );
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Inside getReferralOnAncestor()" );
+ }
Attribute refAttr = ( ( ClonedServerEntry ) referralAncestor ).getOriginalEntry().get( SchemaConstants.REF_AT );
Referral referral = new ReferralImpl();
@@ -1398,7 +1443,10 @@ public class SearchHandler extends LdapR
{
String ref = value.getString();
- LOG.debug( "Calculating LdapURL for referrence value {}", ref );
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Calculating LdapURL for referrence value {}", ref );
+ }
// need to add non-ldap URLs as-is
if ( !ref.startsWith( "ldap" ) )
@@ -1462,7 +1510,10 @@ public class SearchHandler extends LdapR
public Referral getReferralOnAncestor( LdapSession session, Dn reqTargetDn, SearchRequest req,
Entry referralAncestor ) throws Exception
{
- LOG.debug( "Inside getReferralOnAncestor()" );
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Inside getReferralOnAncestor()" );
+ }
Attribute refAttr = ( ( ClonedServerEntry ) referralAncestor ).getOriginalEntry().get( SchemaConstants.REF_AT );
Referral referral = new ReferralImpl();
@@ -1471,7 +1522,10 @@ public class SearchHandler extends LdapR
{
String ref = value.getString();
- LOG.debug( "Calculating LdapURL for referrence value {}", ref );
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Calculating LdapURL for referrence value {}", ref );
+ }
// need to add non-ldap URLs as-is
if ( !ref.startsWith( "ldap" ) )
@@ -1568,7 +1622,11 @@ public class SearchHandler extends LdapR
* embed the result code name into the message.
*/
String msg = code.toString() + ": failed for " + req + ": " + e.getLocalizedMessage();
- LOG.debug( msg, e );
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( msg, e );
+ }
if ( IS_DEBUG )
{
@@ -1618,7 +1676,10 @@ public class SearchHandler extends LdapR
while ( !dn.isEmpty() )
{
- LOG.debug( "Walking ancestors of {} to find referrals.", dn );
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Walking ancestors of {} to find referrals.", dn );
+ }
try
{
@@ -1636,7 +1697,10 @@ public class SearchHandler extends LdapR
}
catch ( LdapException e )
{
- LOG.debug( "Entry for {} not found.", dn );
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Entry for {} not found.", dn );
+ }
// update the Dn as we strip last component
dn = dn.getParent();
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/AbstractSaslServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/AbstractSaslServer.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/AbstractSaslServer.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/AbstractSaslServer.java Mon Sep 24 02:17:13 2012
@@ -27,6 +27,7 @@ import org.apache.directory.server.core.
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 abstract class AbstractSaslServer
*/
public byte[] wrap( byte[] outgoing, int offset, int len ) throws SaslException
{
- return new byte[0];
+ return Strings.EMPTY_BYTES;
}
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/controls/PagedSearchContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/controls/PagedSearchContext.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/controls/PagedSearchContext.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/controls/PagedSearchContext.java Mon Sep 24 02:17:13 2012
@@ -237,10 +237,7 @@ public class PagedSearchContext
{
request.getBase().apply( schemaManager );
- if ( !previousSearchRequest.getBase().isSchemaAware() )
- {
- previousSearchRequest.getBase().apply( schemaManager );
- }
+ previousSearchRequest.getBase().apply( schemaManager );
if ( !request.getBase().equals( previousSearchRequest.getBase() ) )
{
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java Mon Sep 24 02:17:13 2012
@@ -49,6 +49,7 @@ import org.apache.directory.shared.ldap.
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 @@ public class StartTlsHandler implements
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 );
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/ReplicaEventLog.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/ReplicaEventLog.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/ReplicaEventLog.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/ReplicaEventLog.java Mon Sep 24 02:17:13 2012
@@ -122,7 +122,7 @@ public class ReplicaEventLog implements
comparator.setSchemaManager( schemaManager );
journal = new JdbmTable<String, ReplicaEventMessage>( schemaManager, "replication", recman, comparator,
- new StringSerializer(), new ReplicaEventMessageSerializer( schemaManager ) );
+ StringSerializer.INSTANCE, new ReplicaEventMessageSerializer( schemaManager ) );
}
Modified: directory/apacheds/trunk/protocol-ldap/src/test/java/org/apache/directory/server/ldap/JournalTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/test/java/org/apache/directory/server/ldap/JournalTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/test/java/org/apache/directory/server/ldap/JournalTest.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/test/java/org/apache/directory/server/ldap/JournalTest.java Mon Sep 24 02:17:13 2012
@@ -136,7 +136,7 @@ public class JournalTest
comparator.setSchemaManager( schemaManager );
journal = new JdbmTable<String, ReplicaEventMessage>( schemaManager, "test", recman, comparator,
- new StringSerializer(), new ReplicaEventMessageSerializer( schemaManager ) );
+ StringSerializer.INSTANCE, new ReplicaEventMessageSerializer( schemaManager ) );
}
@@ -226,7 +226,7 @@ public class JournalTest
pos++;
}
-
+
cursor.close();
}
@@ -272,7 +272,7 @@ public class JournalTest
journal.sync();
deleted++;
}
-
+
deleteCursor.close();
// Now check that the first mod is the 501th
@@ -286,7 +286,7 @@ public class JournalTest
ReplicaEventMessage replicaEventMessage = tuple.getValue();
assertEquals( ChangeType.ADD, replicaEventMessage.getChangeType() );
assertEquals( "test500", replicaEventMessage.getEntry().get( "ou" ).getString() );
-
+
cursor.close();
}
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/IndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/IndexTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/IndexTest.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/IndexTest.java Mon Sep 24 02:17:13 2012
@@ -29,9 +29,10 @@ import java.io.File;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
import org.apache.directory.server.xdbm.Index;
-import org.apache.directory.server.xdbm.IndexCursor;
+import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.impl.avl.AvlIndex;
import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.model.cursor.Cursor;
import org.apache.directory.shared.ldap.model.entry.Entry;
import org.apache.directory.shared.ldap.model.schema.AttributeType;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
@@ -39,6 +40,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.Strings;
import org.apache.directory.shared.util.exception.Exceptions;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -93,7 +95,7 @@ public class IndexTest
AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OU_AT );
- jdbmIndex = new JdbmIndex<String, Entry>();
+ jdbmIndex = new JdbmIndex<String, Entry>( attributeType.getName(), false );
jdbmIndex.setWkDirPath( dbFileDir.toURI() );
jdbmIndex.init( schemaManager, attributeType );
@@ -110,47 +112,47 @@ public class IndexTest
@Test
- @Ignore( "Does not work with JDBM2" )
+ @Ignore("Does not work with JDBM2")
public void testJdbmIndex() throws Exception
{
doTest( jdbmIndex );
}
- private void doTest( Index<String, Entry, Long> idx ) throws Exception
+ private void doTest( Index<String, Entry, String> idx ) throws Exception
{
String alphabet = "abcdefghijklmnopqrstuvwxyz";
- for ( long i = 0L; i < 26L; i++ )
+ for ( int i = 0; i < 26; i++ )
{
- String val = alphabet.substring( ( int ) i, ( int ) ( i + 1 ) );
- idx.add( val, i + 1 );
+ String val = alphabet.substring( i, i + 1 );
+ idx.add( val, Strings.getUUID( i + 1 ) );
}
assertEquals( 26, idx.count() );
- IndexCursor<String, Entry, Long> cursor1 = idx.forwardCursor();
+ Cursor<IndexEntry<String, String>> cursor1 = idx.forwardCursor();
cursor1.beforeFirst();
- assertHasNext( cursor1, 1L );
- assertHasNext( cursor1, 2L );
+ assertHasNext( cursor1, Strings.getUUID( 1L ) );
+ assertHasNext( cursor1, Strings.getUUID( 2L ) );
- idx.drop( "c", 3L );
+ idx.drop( "c", Strings.getUUID( 3L ) );
for ( long i = 4L; i < 27L; i++ )
{
- assertHasNext( cursor1, i );
+ assertHasNext( cursor1, Strings.getUUID( i ) );
}
assertFalse( cursor1.next() );
-
+
cursor1.close();
}
- private void assertHasNext( IndexCursor<String, Entry, Long> cursor1, long expectedId ) throws Exception
+ private void assertHasNext( Cursor<IndexEntry<String, String>> cursor1, String expectedId ) throws Exception
{
assertTrue( cursor1.next() );
- assertEquals( expectedId, cursor1.get().getId().longValue() );
+ assertEquals( expectedId, cursor1.get().getId() );
}
}
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java Mon Sep 24 02:17:13 2012
@@ -23,7 +23,6 @@ package org.apache.directory.server.oper
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.
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 @@ public class BindIT extends AbstractLdap
{
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
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java Mon Sep 24 02:17:13 2012
@@ -707,8 +707,8 @@ public class AddIT extends AbstractLdapT
{
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
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/BindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/BindIT.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/BindIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/BindIT.java Mon Sep 24 02:17:13 2012
@@ -39,6 +39,7 @@ import org.apache.directory.server.core.
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 @@ public class BindIT extends AbstractLdap
{
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
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/CompareIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/CompareIT.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/CompareIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/CompareIT.java Mon Sep 24 02:17:13 2012
@@ -50,6 +50,7 @@ import org.apache.directory.server.core.
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 @@ public class CompareIT extends AbstractL
{
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
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/DeleteIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/DeleteIT.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/DeleteIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/DeleteIT.java Mon Sep 24 02:17:13 2012
@@ -49,6 +49,7 @@ import org.apache.directory.server.core.
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 @@ public class DeleteIT extends AbstractLd
{
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
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyDnReferralIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyDnReferralIT.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyDnReferralIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyDnReferralIT.java Mon Sep 24 02:17:13 2012
@@ -45,6 +45,7 @@ import org.apache.directory.server.core.
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 @@ import org.slf4j.LoggerFactory;
})
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
- {
- 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();
- }
-
-
- /**
- * 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, 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();
- }
-
-
- /**
- * 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
- {
- 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();
- }
-
-
- /**
- * 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
- {
- 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();
- }
-
-
- /**
- * 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
- {
- 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();
+@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
+ {
+ 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();
+}
+
+
+/**
+ * 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
+ {
+ 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();
+}
+
+
+/**
+ * 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
+ {
+ 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();
+}
+
+
+/**
+ * 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
+ {
+ 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();
+}
}
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyReferralIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyReferralIT.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyReferralIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyReferralIT.java Mon Sep 24 02:17:13 2012
@@ -48,6 +48,7 @@ import org.apache.directory.server.core.
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 @@ import org.slf4j.LoggerFactory;
})
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
- {
- 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();
- }
-
-
- /**
- * 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
+@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
{
- 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();
+ ctx.modifyAttributes( "uid=akarasuluref,ou=users,ou=system", new ModificationItem[]
+ { mod } );
}
-
-
- /**
- * 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
- 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();
+ // 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();
+}
}