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 2011/05/10 00:52:01 UTC
svn commit: r1101261 [3/3] - in /directory/apacheds/trunk:
core-api/src/main/java/org/apache/directory/server/core/
core-integ/src/test/java/org/apache/directory/server/core/admin/
core-integ/src/test/java/org/apache/directory/server/core/authn/ core-i...
Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java Mon May 9 22:52:00 2011
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertEqu
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.concurrent.TimeUnit;
@@ -41,12 +42,14 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.interceptor.context.BindOperationContext;
import org.apache.directory.shared.ldap.model.exception.LdapAuthenticationException;
import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapOperationException;
+import org.apache.directory.shared.ldap.model.exception.LdapUnwillingToPerformException;
import org.apache.directory.shared.ldap.model.message.BindRequest;
import org.apache.directory.shared.ldap.model.message.BindRequestImpl;
import org.apache.directory.shared.ldap.model.message.BindResponse;
-import org.apache.directory.shared.ldap.model.message.LdapResult;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.util.Strings;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -108,12 +111,8 @@ public class SimpleBindRequestTest exten
@Test
public void testSyncBindRequest() throws Exception
{
- BindResponse bindResponse = connection.bind( "uid=admin,ou=system", "secret" );
+ connection.bind( "uid=admin,ou=system", "secret" );
- assertNotNull( bindResponse );
- assertNotNull( bindResponse.getLdapResult() );
- assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
- assertEquals( 1, bindResponse.getMessageId() );
assertTrue( connection.isAuthenticated() );
}
@@ -186,13 +185,20 @@ public class SimpleBindRequestTest exten
{
getLdapServer().getDirectoryService().setAllowAnonymousAccess( false );
- BindResponse bindResponse = connection.bind();
- assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, bindResponse.getLdapResult().getResultCode() );
+ try
+ {
+ connection.bind();
+ fail();
+ }
+ catch ( LdapOperationException le )
+ {
+ assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, le.getResultCode() );
+ }
getLdapServer().getDirectoryService().setAllowAnonymousAccess( true );
- bindResponse = connection.bind();
- assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
+ connection.bind();
+ assertTrue( connection.isAuthenticated() );
}
@@ -207,12 +213,8 @@ public class SimpleBindRequestTest exten
//System.out.println( "------------------Bind" + i + "-------------" );
// Try with no parameters
- BindResponse bindResponse = connection.bind();
+ connection.bind();
- assertNotNull( bindResponse );
- assertNotNull( bindResponse.getLdapResult() );
- assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
- assertEquals( 1, bindResponse.getMessageId() );
assertTrue( connection.isAuthenticated() );
//System.out.println( "----------------Unbind" + i + "-------------" );
@@ -222,12 +224,8 @@ public class SimpleBindRequestTest exten
// Try with empty strings
connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
- bindResponse = connection.bind( "", "" );
+ connection.bind( "", "" );
- assertNotNull( bindResponse );
- assertNotNull( bindResponse.getLdapResult() );
- assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
- assertEquals( 1, bindResponse.getMessageId() );
assertTrue( connection.isAuthenticated() );
connection.unBind();
@@ -236,12 +234,8 @@ public class SimpleBindRequestTest exten
// Try with null parameters
connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
- bindResponse = connection.bind( ( String ) null, ( String ) null );
+ connection.bind( ( String ) null, ( String ) null );
- assertNotNull( bindResponse );
- assertNotNull( bindResponse.getLdapResult() );
- assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
- assertEquals( 1, bindResponse.getMessageId() );
assertTrue( connection.isAuthenticated() );
assertTrue( connection.isConnected() );
@@ -264,12 +258,18 @@ public class SimpleBindRequestTest exten
@Test
public void testSimpleBindNoNamePassword() throws Exception
{
- BindResponse response = connection.bind( ( String ) null, "abc" );
- LdapResult ldapResult = response.getLdapResult();
- assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, ldapResult.getResultCode() );
- assertEquals( 1, response.getMessageId() );
- assertFalse( connection.isAuthenticated() );
- assertTrue( connection.isConnected() );
+ try
+ {
+ connection.bind( ( String ) null, "abc" );
+ fail();
+ }
+ catch ( LdapAuthenticationException lae )
+ {
+ ResultCodeEnum resultCode = lae.getResultCode();
+ assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, resultCode );
+ assertFalse( connection.isAuthenticated() );
+ assertTrue( connection.isConnected() );
+ }
}
@@ -279,12 +279,18 @@ public class SimpleBindRequestTest exten
@Test
public void testSimpleBindUnauthenticated() throws Exception
{
- BindResponse response = connection.bind( "uid=admin,ou=system" );
- LdapResult ldapResult = response.getLdapResult();
- assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, ldapResult.getResultCode() );
- assertEquals( 1, response.getMessageId() );
- assertFalse( connection.isAuthenticated() );
- assertTrue( connection.isConnected() );
+ try
+ {
+ connection.bind( "uid=admin,ou=system" );
+ fail();
+ }
+ catch ( LdapUnwillingToPerformException lutpe )
+ {
+ ResultCodeEnum resultCode = lutpe.getResultCode();
+ assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, resultCode );
+ assertFalse( connection.isAuthenticated() );
+ assertTrue( connection.isConnected() );
+ }
}
@@ -304,10 +310,7 @@ public class SimpleBindRequestTest exten
@Test
public void testSimpleBindValid() throws Exception
{
- BindResponse response = connection.bind( "uid=admin,ou=system", "secret" );
- LdapResult ldapResult = response.getLdapResult();
- assertEquals( ResultCodeEnum.SUCCESS, ldapResult.getResultCode() );
- assertEquals( 1, response.getMessageId() );
+ connection.bind( "uid=admin,ou=system", "secret" );
assertTrue( connection.isAuthenticated() );
}
@@ -318,12 +321,18 @@ public class SimpleBindRequestTest exten
@Test
public void testSimpleBindValidUserWrongPassword() throws Exception
{
- BindResponse response = connection.bind( "uid=admin,ou=system", "badpassword" );
- LdapResult ldapResult = response.getLdapResult();
- assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, ldapResult.getResultCode() );
- assertEquals( 1, response.getMessageId() );
- assertFalse( connection.isAuthenticated() );
- assertTrue( connection.isConnected() );
+ try
+ {
+ connection.bind( "uid=admin,ou=system", "badpassword" );
+ fail();
+ }
+ catch ( LdapAuthenticationException lae )
+ {
+ ResultCodeEnum resultCode = lae.getResultCode();
+ assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, resultCode );
+ assertFalse( connection.isAuthenticated() );
+ assertTrue( connection.isConnected() );
+ }
}
@@ -333,12 +342,18 @@ public class SimpleBindRequestTest exten
@Test
public void testSimpleBindInvalidUser() throws Exception
{
- BindResponse response = connection.bind( "uid=wrong,ou=system", "secret" );
- LdapResult ldapResult = response.getLdapResult();
- assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, ldapResult.getResultCode() );
- assertEquals( 1, response.getMessageId() );
- assertFalse( connection.isAuthenticated() );
- assertTrue( connection.isConnected() );
+ try
+ {
+ connection.bind( "uid=wrong,ou=system", "secret" );
+ fail();
+ }
+ catch ( LdapAuthenticationException lae )
+ {
+ ResultCodeEnum resultCode = lae.getResultCode();
+ assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, resultCode );
+ assertFalse( connection.isAuthenticated() );
+ assertTrue( connection.isConnected() );
+ }
}
@@ -348,17 +363,23 @@ public class SimpleBindRequestTest exten
@Test
public void testDoubleSimpleBindValid() throws Exception
{
- BindResponse response1 = connection.bind( "uid=admin,ou=system", "secret" );
- LdapResult ldapResult1 = response1.getLdapResult();
- assertEquals( ResultCodeEnum.SUCCESS, ldapResult1.getResultCode() );
- assertEquals( 1, response1.getMessageId() );
+ BindRequest br1 = new BindRequestImpl();
+ br1.setName( new Dn( "uid=admin,ou=system" ) );
+ br1.setCredentials( Strings.getBytesUtf8( "secret" ) );
+
+ BindResponse response1 = connection.bind( br1 );
assertTrue( connection.isAuthenticated() );
+ int messageId1 = response1.getMessageId();
// The messageId must have been incremented
- BindResponse response2 = connection.bind( "uid=admin,ou=system", "secret" );
- LdapResult ldapResult2 = response2.getLdapResult();
- assertEquals( ResultCodeEnum.SUCCESS, ldapResult2.getResultCode() );
- assertEquals( 2, response2.getMessageId() );
+ BindRequest br2 = new BindRequestImpl();
+ br2.setName( new Dn( "uid=admin,ou=system" ) );
+ br2.setCredentials( Strings.getBytesUtf8( "secret" ) );
+
+ BindResponse response2 = connection.bind( br2 );
+ int messageId2 = response2.getMessageId();
+
+ assertTrue( messageId2 > messageId1 );
assertTrue( connection.isAuthenticated() );
// Now, unbind
@@ -367,10 +388,13 @@ public class SimpleBindRequestTest exten
assertFalse( connection.isConnected() );
// And Bind again. The messageId should be 1
- BindResponse response3 = connection.bind( "uid=admin,ou=system", "secret" );
- LdapResult ldapResult3 = response3.getLdapResult();
- assertEquals( ResultCodeEnum.SUCCESS, ldapResult3.getResultCode() );
- assertEquals( 1, response3.getMessageId() );
+ BindRequest br3 = new BindRequestImpl();
+ br3.setName( new Dn( "uid=admin,ou=system" ) );
+ br3.setCredentials( Strings.getBytesUtf8( "secret" ) );
+
+ BindResponse response3 = connection.bind( br3 );
+ int messageId = response3.getMessageId();
+ assertEquals( 1, messageId );
assertTrue( connection.isAuthenticated() );
}
@@ -417,10 +441,16 @@ public class SimpleBindRequestTest exten
Thread.sleep( 200 );
// It will take 1 seconds to bind, let's send another bind request : it should fail
- BindResponse response = connection.bind( "uid=admin,ou=system", "secret" );
-
- assertFalse( connection.isAuthenticated() );
- assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+ try
+ {
+ connection.bind( "uid=admin,ou=system", "secret" );
+ fail();
+ }
+ catch ( LdapUnwillingToPerformException lutpe )
+ {
+ assertFalse( connection.isAuthenticated() );
+ assertTrue( true );
+ }
// Now get back the BindResponse
BindResponse bindResponse = bindFuture.get( 2000, TimeUnit.MILLISECONDS );
@@ -443,30 +473,17 @@ public class SimpleBindRequestTest exten
public void testBindUserWhenAnonymous() throws Exception
{
// Bind anonymous
- BindResponse bindResponse = connection.bind();
-
- assertNotNull( bindResponse );
- assertNotNull( bindResponse.getLdapResult() );
- assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
- assertEquals( 1, bindResponse.getMessageId() );
+ connection.bind();
assertTrue( connection.isAuthenticated() );
// Now bind with some credentials
- bindResponse = connection.bind( "uid=admin, ou=system", "secret" );
+ connection.bind( "uid=admin, ou=system", "secret" );
- assertNotNull( bindResponse );
- assertNotNull( bindResponse.getLdapResult() );
- assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
- assertEquals( 2, bindResponse.getMessageId() );
assertTrue( connection.isAuthenticated() );
- //And back to anonymous
- bindResponse = connection.bind();
+ // And back to anonymous
+ connection.bind();
- assertNotNull( bindResponse );
- assertNotNull( bindResponse.getLdapResult() );
- assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
- assertEquals( 3, bindResponse.getMessageId() );
assertTrue( connection.isAuthenticated() );
}
@@ -478,21 +495,13 @@ public class SimpleBindRequestTest exten
public void testBindUserWhenAlreadyBound() throws Exception
{
// Bind with some credentials
- BindResponse bindResponse = connection.bind( "uid=admin, ou=system", "secret" );
+ connection.bind( "uid=admin, ou=system", "secret" );
- assertNotNull( bindResponse );
- assertNotNull( bindResponse.getLdapResult() );
- assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
- assertEquals( 1, bindResponse.getMessageId() );
assertTrue( connection.isAuthenticated() );
// Bind with another user
- bindResponse = connection.bind( "uid=superuser,ou=system", "test" );
+ connection.bind( "uid=superuser,ou=system", "test" );
- assertNotNull( bindResponse );
- assertNotNull( bindResponse.getLdapResult() );
- assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
- assertEquals( 2, bindResponse.getMessageId() );
assertTrue( connection.isAuthenticated() );
}
@@ -503,17 +512,17 @@ public class SimpleBindRequestTest exten
@Test
public void testSimpleBindInvalidFwdByValidOnSameCon() throws Exception
{
- BindResponse response = connection.bind( "uid=admin,ou=system", "wrongpwd" );
- LdapResult ldapResult = response.getLdapResult();
- assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, ldapResult.getResultCode() );
- assertEquals( 1, response.getMessageId() );
- assertFalse( connection.isAuthenticated() );
+ try
+ {
+ connection.bind( "uid=admin,ou=system", "wrongpwd" );
+ fail();
+ }
+ catch ( LdapAuthenticationException lae )
+ {
+ assertFalse( connection.isAuthenticated() );
+ }
- response = connection.bind( "uid=admin,ou=system", "secret" );
- ldapResult = response.getLdapResult();
- assertEquals( ResultCodeEnum.SUCCESS, ldapResult.getResultCode() );
- assertEquals( 2, response.getMessageId() );
+ connection.bind( "uid=admin,ou=system", "secret" );
assertTrue( connection.isAuthenticated() );
}
-
}
Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java Mon May 9 22:52:00 2011
@@ -23,6 +23,7 @@ package org.apache.directory.shared.clie
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.concurrent.TimeUnit;
@@ -101,12 +102,37 @@ public class ClientSearchRequestTest ext
@Test
+ public void testSimpleSearch() throws Exception
+ {
+ SearchCursor cursor = connection.search( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL );
+ int count = 0;
+
+ while ( cursor.next() )
+ {
+ Response response = cursor.get();
+ assertNotNull( response );
+ assertTrue( response instanceof SearchResultEntry );
+ System.out.println( ((SearchResultEntry)response).getEntry() );
+ count++;
+ }
+
+ SearchResultDone done = cursor.getSearchResultDone();
+
+ assertNotNull( done );
+ assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
+ assertEquals( 5, count );
+ cursor.close();
+ }
+
+
+ @Test
public void testSearch() throws Exception
{
SearchCursor cursor = connection.search( "ou=system", "(objectclass=*)",
SearchScope.ONELEVEL,
"*", "+" );
int count = 0;
+
while ( cursor.next() )
{
assertNotNull( cursor.get() );
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java Mon May 9 22:52:00 2011
@@ -51,11 +51,11 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.extras.controls.syncrepl_impl.SyncRequestValueDecorator;
import org.apache.directory.shared.ldap.extras.controls.syncrepl_impl.SyncStateValueDecorator;
import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
+import org.apache.directory.shared.ldap.model.entry.Attribute;
import org.apache.directory.shared.ldap.model.entry.DefaultAttribute;
+import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
import org.apache.directory.shared.ldap.model.entry.DefaultModification;
import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.entry.Attribute;
import org.apache.directory.shared.ldap.model.entry.Modification;
import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
import org.apache.directory.shared.ldap.model.exception.LdapException;
@@ -66,10 +66,8 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.filter.OrNode;
import org.apache.directory.shared.ldap.model.filter.PresenceNode;
import org.apache.directory.shared.ldap.model.message.AliasDerefMode;
-import org.apache.directory.shared.ldap.model.message.BindResponse;
import org.apache.directory.shared.ldap.model.message.Control;
import org.apache.directory.shared.ldap.model.message.IntermediateResponse;
-import org.apache.directory.shared.ldap.model.message.LdapResult;
import org.apache.directory.shared.ldap.model.message.Response;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.model.message.SearchRequest;
@@ -217,18 +215,14 @@ public class SyncReplConsumer implements
}
// Do a bind
- BindResponse bindResponse = connection.bind( config.getReplUserDn(), config.getReplUserPassword() );
-
- // Now get the result
- LdapResult ldapResult = bindResponse.getLdapResult();
-
- if ( ldapResult.getResultCode() != ResultCodeEnum.SUCCESS )
+ try
{
- LOG.warn( "Failed to bind to the server with the given bind Dn {} and credentials: {}", config.getReplUserDn(), ldapResult );
+ connection.bind( config.getReplUserDn(), config.getReplUserPassword() );
+ return true;
}
- else
+ catch ( LdapException le )
{
- return true;
+ LOG.warn( "Failed to bind to the server with the given bind Dn {} and credentials: {}", config.getReplUserDn(), le.getCause() );
}
}
catch ( Exception e )
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointAddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointAddIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointAddIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointAddIT.java Mon May 9 22:52:00 2011
@@ -20,9 +20,9 @@
package org.apache.directory.server.admin;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.server.annotations.CreateLdapServer;
@@ -34,8 +34,7 @@ import org.apache.directory.server.core.
import org.apache.directory.shared.ldap.model.entry.Attribute;
import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.message.AddResponse;
-import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.model.exception.LdapUnwillingToPerformException;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
import org.junit.After;
import org.junit.Before;
@@ -186,12 +185,15 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeInnerArea"
);
-
- AddResponse response = connection.add( entry );
-
- // It should fail
- assertNotNull( response );
- assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+ try
+ {
+ connection.add( entry );
+ fail();
+ }
+ catch ( LdapUnwillingToPerformException lutpe )
+ {
+ assertTrue( true );
+ }
// Add the entry under a SAP with the same role which has no parent AAP
entry = new DefaultEntry(
@@ -202,11 +204,10 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeInnerArea"
);
- response = connection.add( entry );
+ connection.add( entry );
// It should succeed
- assertNotNull( response );
- assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+ assertTrue( connection.exists( "ou=IAP-CANew,ou=SAP-CA2,ou=system" ) );
// Add the entry under a SAP with a different role which has no parent AAP
entry = new DefaultEntry(
@@ -217,11 +218,15 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeInnerArea"
);
- response = connection.add( entry );
-
- // It should fail
- assertNotNull( response );
- assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+ try
+ {
+ connection.add( entry );
+ fail();
+ }
+ catch ( LdapUnwillingToPerformException lutpe )
+ {
+ assertTrue( true );
+ }
// Add the entry under an AAP
entry = new DefaultEntry(
@@ -232,11 +237,10 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeInnerArea"
);
- response = connection.add( entry );
+ connection.add( entry );
// It should succeed
- assertNotNull( response );
- assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+ assertTrue( connection.exists( "ou=IAP-CANew,ou=AAP1,ou=system" ) );
// Add the entry under an IAP with the same role which has a parent AAP
entry = new DefaultEntry(
@@ -247,11 +251,10 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeInnerArea"
);
- response = connection.add( entry );
+ connection.add( entry );
// It should succeed
- assertNotNull( response );
- assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+ assertTrue( connection.exists( "ou=IAP-CANew,ou=IAP-CA1,ou=AAP1,ou=system" ) );
// Add the entry under an IAP with a different role which has a parent AAP
entry = new DefaultEntry(
@@ -262,11 +265,10 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeInnerArea"
);
- response = connection.add( entry );
+ connection.add( entry );
// It should succeed
- assertNotNull( response );
- assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+ assertTrue( connection.exists( "ou=IAP-CANew,ou=IAP-AC1,ou=AAP1,ou=system" ) );
// Add the entry under an SAP with the same role which has a parent AAP
entry = new DefaultEntry(
@@ -277,11 +279,10 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeInnerArea"
);
- response = connection.add( entry );
+ connection.add( entry );
// It should succeed
- assertNotNull( response );
- assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+ assertTrue( connection.exists( "ou=IAP-CANew,ou=SAP-CA1,ou=AAP1,ou=system" ) );
// Add the entry under an SAP with a different role which has a parent AAP
entry = new DefaultEntry(
@@ -292,11 +293,10 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeInnerArea"
);
- response = connection.add( entry );
+ connection.add( entry );
// It should succeed
- assertNotNull( response );
- assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+ assertTrue( connection.exists( "ou=IAP-CANew,ou=SAP-AC1,ou=AAP1,ou=system" ) );
}
@@ -318,11 +318,10 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeSpecificArea"
);
- AddResponse response = connection.add( entry );
+ connection.add( entry );
// It should succeed
- assertNotNull( response );
- assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+ assertTrue( connection.exists( "ou=SAP-CANew,ou=entry,ou=system" ) );
// Add the entry under a SAP with the same role which has no parent AAP
entry = new DefaultEntry(
@@ -333,11 +332,10 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeSpecificArea"
);
- response = connection.add( entry );
+ connection.add( entry );
// It should succeed
- assertNotNull( response );
- assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+ assertTrue( connection.exists( "ou=SAP-CANew,ou=SAP-CA2,ou=system" ) );
// Add the entry under a SAP with a different role which has no parent AAP
entry = new DefaultEntry(
@@ -348,11 +346,10 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeSpecificArea"
);
- response = connection.add( entry );
+ connection.add( entry );
// It should succeed
- assertNotNull( response );
- assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+ assertTrue( connection.exists( "ou=SAP-CANew,ou=SAP-AC2,ou=system" ) );
// Add the entry under an AAP
entry = new DefaultEntry(
@@ -363,11 +360,10 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeSpecificArea"
);
- response = connection.add( entry );
+ connection.add( entry );
// It should succeed
- assertNotNull( response );
- assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+ assertTrue( connection.exists( "ou=SAP-CANew,ou=AAP1,ou=system" ) );
// Add the entry under an IAP with the same role which has a parent AAP
entry = new DefaultEntry(
@@ -378,11 +374,10 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeSpecificArea"
);
- response = connection.add( entry );
+ connection.add( entry );
// It should succeed
- assertNotNull( response );
- assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+ assertTrue( connection.exists( "ou=SAP-CANew,ou=IAP-CA1,ou=AAP1,ou=system" ) );
// Add the entry under an IAP with a different role which has a parent AAP
entry = new DefaultEntry(
@@ -393,11 +388,10 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeSpecificArea"
);
- response = connection.add( entry );
+ connection.add( entry );
// It should succeed
- assertNotNull( response );
- assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+ assertTrue( connection.exists( "ou=SAP-CANew,ou=IAP-AC1,ou=AAP1,ou=system" ) );
// Add the entry under an SAP with the same role which has a parent AAP
entry = new DefaultEntry(
@@ -408,11 +402,10 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeSpecificArea"
);
- response = connection.add( entry );
+ connection.add( entry );
// It should succeed
- assertNotNull( response );
- assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+ assertTrue( connection.exists( "ou=SAP-CANew,ou=SAP-CA1,ou=AAP1,ou=system" ) );
// Add the entry under an SAP with a different role which has a parent AAP
entry = new DefaultEntry(
@@ -423,10 +416,9 @@ public class AdministrativePointAddIT ex
"administrativeRole: collectiveAttributeSpecificArea"
);
- response = connection.add( entry );
+ connection.add( entry );
// It should succeed
- assertNotNull( response );
- assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+ assertTrue( connection.exists( "ou=SAP-CANew,ou=SAP-AC1,ou=AAP1,ou=system" ) );
}
}
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointModifyDelIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointModifyDelIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointModifyDelIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointModifyDelIT.java Mon May 9 22:52:00 2011
@@ -20,9 +20,9 @@
package org.apache.directory.server.admin;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.server.annotations.CreateLdapServer;
@@ -31,14 +31,13 @@ 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.server.core.integ.IntegrationUtils;
+import org.apache.directory.shared.ldap.model.entry.Attribute;
import org.apache.directory.shared.ldap.model.entry.DefaultAttribute;
import org.apache.directory.shared.ldap.model.entry.DefaultModification;
import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.entry.Attribute;
import org.apache.directory.shared.ldap.model.entry.Modification;
import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
-import org.apache.directory.shared.ldap.model.message.ModifyResponse;
-import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.model.exception.LdapUnwillingToPerformException;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
import org.junit.After;
import org.junit.Before;
@@ -303,11 +302,16 @@ public class AdministrativePointModifyDe
// Remove the AAP
Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
new DefaultAttribute( "administrativeRole" ) );
- ModifyResponse response = connection.modify( "ou=AAP,ou=SAP-CA,ou=SAP-AC,ou=system", modification );
-
- // Should fail, as we have a TE IAP below
- assertNotNull( response );
- assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+
+ try
+ {
+ connection.modify( "ou=AAP,ou=SAP-CA,ou=SAP-AC,ou=system", modification );
+ fail();
+ }
+ catch ( LdapUnwillingToPerformException lutpe )
+ {
+ assertTrue( true );
+ }
}
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointModifyIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointModifyIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointModifyIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointModifyIT.java Mon May 9 22:52:00 2011
@@ -20,9 +20,9 @@
package org.apache.directory.server.admin;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.server.annotations.CreateLdapServer;
@@ -31,14 +31,13 @@ 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.server.core.integ.IntegrationUtils;
+import org.apache.directory.shared.ldap.model.entry.Attribute;
import org.apache.directory.shared.ldap.model.entry.DefaultAttribute;
import org.apache.directory.shared.ldap.model.entry.DefaultModification;
import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.entry.Attribute;
import org.apache.directory.shared.ldap.model.entry.Modification;
import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
-import org.apache.directory.shared.ldap.model.message.ModifyResponse;
-import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.model.exception.LdapUnwillingToPerformException;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
import org.junit.After;
import org.junit.Before;
@@ -304,9 +303,15 @@ public class AdministrativePointModifyIT
// Add the SAP
Modification modificationAddSap = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
new DefaultAttribute( "administrativeRole", "triggerExecutionSpecificArea" ) );
- ModifyResponse response = connection.modify( "ou=AAP,ou=SAP-CA,ou=SAP-AC,ou=system", modificationDelAap, modificationAddSap );
-
- assertNotNull( response );
- assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+
+ try
+ {
+ connection.modify( "ou=AAP,ou=SAP-CA,ou=SAP-AC,ou=system", modificationDelAap, modificationAddSap );
+ fail();
+ }
+ catch ( LdapUnwillingToPerformException lutpe )
+ {
+ assertTrue( true );
+ }
}
}
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java Mon May 9 22:52:00 2011
@@ -90,8 +90,8 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.entry.Entry;
import org.apache.directory.shared.ldap.model.entry.Modification;
import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.model.exception.LdapOperationException;
import org.apache.directory.shared.ldap.model.ldif.LdifUtils;
-import org.apache.directory.shared.ldap.model.message.AddResponse;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.model.name.Dn;
import org.apache.directory.shared.util.Strings;
@@ -1399,10 +1399,7 @@ public class AddIT extends AbstractLdapT
personEntry.add( "nonExistingAttribute", "value" );
personEntry.setDn( dn );
- AddResponse response = connection.add( personEntry );
-
- assertNotNull( response );
- assertTrue( !ResultCodeEnum.SUCCESS.equals( response.getLdapResult().getResultCode() ) );
+ connection.add( personEntry );
Entry entry = connection.lookup( dn );
assertNull( entry );
@@ -1416,7 +1413,7 @@ public class AddIT extends AbstractLdapT
*
* @throws Exception
*/
- @Test
+ @Test( expected = LdapOperationException.class )
public void testAddEntryNonExistingOC() throws Exception
{
LdapConnection connection = ServerIntegrationUtils.getClientApiConnection( getLdapServer() );
@@ -1429,14 +1426,6 @@ public class AddIT extends AbstractLdapT
personEntry.add( SchemaConstants.SN_AT, "Bush" );
personEntry.setDn( dn );
- AddResponse response = connection.add( personEntry );
-
- assertNotNull( response );
- assertTrue( !ResultCodeEnum.SUCCESS.equals( response.getLdapResult().getResultCode() ) );
-
- Entry entry = connection.lookup( dn );
- assertNull( entry );
-
- connection.close();
+ connection.add( personEntry );
}
}
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthIT.java Mon May 9 22:52:00 2011
@@ -37,8 +37,7 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.authn.StrongAuthenticator;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
-import org.apache.directory.shared.ldap.model.message.BindResponse;
-import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.model.exception.LdapAuthenticationException;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -95,42 +94,35 @@ public class DelegatedAuthIT extends Abs
assertTrue( getService().isStarted() );
assertEquals( "DelegatedAuthIT-method", getService().getInstanceId() );
LdapConnection ldapConnection = LdapConnectionFactory.getNetworkConnection( "localhost", getLdapServer().getPort() );
- BindResponse bindResponse = ldapConnection.bind( "uid=antoine,ou=users,ou=system", "secret" );
+ ldapConnection.bind( "uid=antoine,ou=users,ou=system", "secret" );
- if ( bindResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
- {
- fail( "this authentication should have been successful, got result code : "
- + bindResponse.getLdapResult().getResultCode() );
- }
+ assertTrue( ldapConnection.isAuthenticated() );
ldapConnection.unBind();
- bindResponse = ldapConnection.bind( "uid=antoine,ou=users,ou=system", "sesame" );
- if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+ try
+ {
+ ldapConnection.bind( "uid=antoine,ou=users,ou=system", "sesame" );
+ fail();
+ }
+ catch ( LdapAuthenticationException lae )
{
- fail( "this authentication should have failed due to wrong password, got result code : "
- + bindResponse.getLdapResult().getResultCode() );
+ assertTrue( true );
}
ldapConnection.unBind();
try
{
- bindResponse = ldapConnection.bind( "uid=ivanhoe,ou=users,ou=system", "secret" );
-
- if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
- {
- fail( "this authentication should fail, user does not exist, got result code : "
- + bindResponse.getLdapResult().getResultCode() );
- }
-
- ldapConnection.unBind();
+ ldapConnection.bind( "uid=ivanhoe,ou=users,ou=system", "secret" );
+ fail();
}
catch ( Exception exc )
{
assertTrue( true );
}
+ ldapConnection.unBind();
ldapConnection.close();
}
@@ -175,62 +167,56 @@ public class DelegatedAuthIT extends Abs
assertTrue( getService().isStarted() );
assertEquals( "DelegatedAuthIT-MultipleAuthenticators-method", getService().getInstanceId() );
LdapConnection ldapConnection = LdapConnectionFactory.getNetworkConnection( "localhost", getLdapServer().getPort() );
- BindResponse bindResponse = ldapConnection.bind( "uid=emmanuel,ou=users,ou=system", "sesame" );
+ ldapConnection.bind( "uid=emmanuel,ou=users,ou=system", "sesame" );
- if ( bindResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
- {
- fail( "this authentication should have been successful through local simple authenticator, got result code : "
- + bindResponse.getLdapResult().getResultCode() );
- }
+ assertTrue( ldapConnection.isAuthenticated() );
ldapConnection.unBind();
- bindResponse = ldapConnection.bind( "uid=emmanuel,ou=users,ou=system", "crypto" );
-
- if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+
+ try
{
- fail( "this authentication should fail due to wrong password, got result code : "
- + bindResponse.getLdapResult().getResultCode() );
+ ldapConnection.bind( "uid=emmanuel,ou=users,ou=system", "crypto" );
+ fail();
+ }
+ catch ( LdapAuthenticationException lae )
+ {
+ assertTrue( true );
}
ldapConnection.unBind();
- bindResponse = ldapConnection.bind();
+ ldapConnection.bind();
- if ( bindResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
- {
- fail( "this authentication should have been successful through local anonymous authenticator, got result code : "
- + bindResponse.getLdapResult().getResultCode() );
- }
+ assertTrue( ldapConnection.isAuthenticated() );
ldapConnection.unBind();
- bindResponse = ldapConnection.bind( "uid=antoine,ou=users,ou=system", "secret" );
+ ldapConnection.bind( "uid=antoine,ou=users,ou=system", "secret" );
- if ( bindResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
- {
- fail( "this authentication should have been successful, got result code : "
- + bindResponse.getLdapResult().getResultCode() );
- }
+ assertTrue( ldapConnection.isAuthenticated() );
ldapConnection.unBind();
- bindResponse = ldapConnection.bind( "uid=antoine,ou=users,ou=system", "sesame" );
- if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+ try
{
- fail( "this authentication should have failed due to wrong password, got result code : "
- + bindResponse.getLdapResult().getResultCode() );
+ ldapConnection.bind( "uid=antoine,ou=users,ou=system", "sesame" );
+ }
+ catch ( LdapAuthenticationException lae )
+ {
+ assertTrue( true );
}
ldapConnection.unBind();
try
{
- bindResponse = ldapConnection.bind( "uid=ivanhoe,ou=users,ou=system", "secret" );
-
- if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+ try
{
- fail( "this authentication should fail, user does not exist, got result code : "
- + bindResponse.getLdapResult().getResultCode() );
+ ldapConnection.bind( "uid=ivanhoe,ou=users,ou=system", "secret" );
}
-
+ catch ( LdapAuthenticationException lae )
+ {
+ assertTrue( true );
+ }
+
ldapConnection.unBind();
}
catch ( Exception exc )
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java Mon May 9 22:52:00 2011
@@ -54,9 +54,6 @@ 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.ldap.model.message.BindResponse;
-import org.apache.directory.shared.ldap.model.message.LdapResult;
-import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -454,10 +451,7 @@ public class SimpleBindIT extends Abstra
{
LdapConnection connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
- BindResponse response = connection.bind( "uid=\"admin\",ou=\"system\"", "secret" );
- LdapResult ldapResult = response.getLdapResult();
- assertEquals( ResultCodeEnum.SUCCESS, ldapResult.getResultCode() );
- assertEquals( 1, response.getMessageId() );
+ connection.bind( "uid=\"admin\",ou=\"system\"", "secret" );
assertTrue( connection.isAuthenticated() );
connection.close();
}
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java Mon May 9 22:52:00 2011
@@ -48,7 +48,6 @@ import org.apache.directory.server.annot
import org.apache.directory.server.core.annotations.ApplyLdifs;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
-import org.apache.directory.shared.ldap.model.message.CompareResponse;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -97,12 +96,12 @@ public class CompareIT extends AbstractL
LdapConnection conn = getClientApiConnection( getLdapServer() );
// comparison success
- CompareResponse resp = conn.compare( "uid=akarasulu,ou=users,ou=system", "sn", "karasulu" );
- assertEquals( ResultCodeEnum.COMPARE_TRUE, resp.getLdapResult().getResultCode() );
+ boolean response = conn.compare( "uid=akarasulu,ou=users,ou=system", "sn", "karasulu" );
+ assertTrue( response );
// comparison failure
- resp = conn.compare( "uid=akarasulu,ou=users,ou=system", "sn", "lecharny" );
- assertEquals( ResultCodeEnum.COMPARE_FALSE, resp.getLdapResult().getResultCode() );
+ response = conn.compare( "uid=akarasulu,ou=users,ou=system", "sn", "lecharny" );
+ assertFalse( response );
conn.unBind();
conn.close();
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/delete/DeleteIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/delete/DeleteIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/delete/DeleteIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/delete/DeleteIT.java Mon May 9 22:52:00 2011
@@ -24,6 +24,7 @@ import static org.apache.directory.serve
import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredConnection;
import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContextThrowOnRefferal;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import javax.naming.NameNotFoundException;
@@ -44,7 +45,8 @@ import org.apache.directory.server.annot
import org.apache.directory.server.core.annotations.ApplyLdifs;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
-import org.apache.directory.shared.ldap.model.message.DeleteResponse;
+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.junit.Test;
import org.junit.runner.RunWith;
@@ -95,8 +97,15 @@ public class DeleteIT extends AbstractLd
LdapConnection conn = getClientApiConnection( getLdapServer() );
// delete failure on non-leaf entry
- DeleteResponse resp = conn.delete( "uid=akarasulu,ou=users,ou=system" );
- assertEquals( ResultCodeEnum.NOT_ALLOWED_ON_NON_LEAF, resp.getLdapResult().getResultCode() );
+ try
+ {
+ conn.delete( "uid=akarasulu,ou=users,ou=system" );
+ fail();
+ }
+ catch ( LdapContextNotEmptyException lcnee )
+ {
+ assertTrue( true );
+ }
conn.unBind();
conn.close();
@@ -116,8 +125,15 @@ public class DeleteIT extends AbstractLd
conn.delete( "ou=computers,uid=akarasulu,ou=users,ou=system" );
// delete failure non-existant entry
- DeleteResponse resp = conn.delete( "uid=elecharny,ou=users,ou=system" );
- assertEquals( ResultCodeEnum.NO_SUCH_OBJECT, resp.getLdapResult().getResultCode() );
+ try
+ {
+ conn.delete( "uid=elecharny,ou=users,ou=system" );
+ fail();
+ }
+ catch ( LdapNoSuchObjectException lnsoe )
+ {
+ assertTrue( true );
+ }
conn.unBind();
conn.close();
@@ -134,8 +150,15 @@ public class DeleteIT extends AbstractLd
LdapConnection conn = getClientApiConnection( getLdapServer() );
// delete failure non-existent entry
- DeleteResponse resp = conn.delete( "uid=elecharny,ou=users,ou=system" );
- assertEquals( ResultCodeEnum.NO_SUCH_OBJECT, resp.getLdapResult().getResultCode() );
+ try
+ {
+ conn.delete( "uid=elecharny,ou=users,ou=system" );
+ fail();
+ }
+ catch ( LdapNoSuchObjectException lnsoe )
+ {
+ assertTrue( true );
+ }
conn.unBind();
conn.close();
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/MoveIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/MoveIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/MoveIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/MoveIT.java Mon May 9 22:52:00 2011
@@ -25,6 +25,7 @@ import static org.apache.directory.serve
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import javax.naming.NamingEnumeration;
import javax.naming.directory.SearchControls;
@@ -37,8 +38,7 @@ import org.apache.directory.server.annot
import org.apache.directory.server.core.annotations.ApplyLdifs;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
-import org.apache.directory.shared.ldap.model.message.ModifyDnResponse;
-import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.model.exception.LdapUnwillingToPerformException;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -122,8 +122,16 @@ public class MoveIT extends AbstractLdap
LdapConnection con = getClientApiConnection( getLdapServer() );
//now do something bad: make the parent a child of its own child
- ModifyDnResponse resp = con.move( "ou=parent,ou=system", "ou=child,ou=parent,ou=system" );
- assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, resp.getLdapResult().getResultCode() );
+ try
+ {
+ con.move( "ou=parent,ou=system", "ou=child,ou=parent,ou=system" );
+ fail();
+ }
+ catch ( LdapUnwillingToPerformException lutpe )
+ {
+ assertTrue( true );
+ }
+
con.close();
}
@@ -134,8 +142,15 @@ public class MoveIT extends AbstractLdap
LdapConnection con = getClientApiConnection( getLdapServer() );
//now do something bad: try to move the entry to the same Dn
- ModifyDnResponse resp = con.move( "ou=parent,ou=system", "ou=parent,ou=system" );
- assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, resp.getLdapResult().getResultCode() );
+ try
+ {
+ con.move( "ou=parent,ou=system", "ou=parent,ou=system" );
+ fail();
+ }
+ catch ( LdapUnwillingToPerformException lutpe )
+ {
+ assertTrue( true );
+ }
con.close();
}
}