From 2f220c180b7009cf70af4fba278afd09e690dcf1 Mon Sep 17 00:00:00 2001 From: emmanuel lecharny Date: Tue, 13 Aug 2024 14:44:54 +0200 Subject: [PATCH] Fix for DIRSERVER-2408, 2409 --- .../apache/directory/server/i18n/I18n.java | 4 +- .../directory/server/i18n/errors.properties | 4 +- .../client/api/AdsSchemaLoaderTest.java | 6 +-- .../shared/client/api/LdapConnectionTest.java | 7 ++-- .../client/api/ServerSchemaLoaderTest.java | 6 +-- .../operations/ClientAbandonRequestTest.java | 7 ++-- .../api/operations/ClientAddRequestTest.java | 13 +++--- .../operations/ClientCompareRequestTest.java | 7 ++-- .../operations/ClientDeleteRequestTest.java | 11 ++--- .../operations/ClientExtendedRequestTest.java | 42 ++++++------------- .../operations/ClientModifyDnRequestTest.java | 7 ++-- .../operations/ClientModifyRequestTest.java | 7 ++-- .../client/api/operations/GetRootDseTest.java | 6 +-- .../api/operations/lookup/LookupTest.java | 5 ++- .../search/ClientSearchRequestTest.java | 11 ++--- .../search/OperationWithIndexTest.java | 9 ++-- .../SearchRequestReturningAttributesTest.java | 8 ++-- .../search/SearchWithReferralsTest.java | 6 +-- 18 files changed, 79 insertions(+), 87 deletions(-) diff --git a/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java b/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java index 49ccb0749d..b859ed71dd 100644 --- a/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java +++ b/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java @@ -677,8 +677,8 @@ public enum I18n ERR_640("ERR_640"), ERR_641("ERR_641"), ERR_642("ERR_642"), - // ERR_643( "ERR_643" ), - // ERR_644( "ERR_644" ), + ERR_643( "ERR_643" ), + ERR_644( "ERR_644" ), // ERR_645( "ERR_645" ), ERR_646("ERR_646"), ERR_647("ERR_647"), diff --git a/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties b/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties index 2a56945dd1..78af2bc394 100644 --- a/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties +++ b/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties @@ -664,8 +664,8 @@ ERR_639=Class {0} is not a descendant of DhcpOption ERR_640=Can''t initialize option field classes ERR_641=Max data length: 128 bytes. ERR_642=ASCII encoding unavailable -# ERR_643= -# ERR_644= +ERR_643=Not enough data in the buffer +ERR_644=Negative index in the buffer # ERR_645= ERR_646=Record type to objectClass mapping has not been set. ERR_647=ResourceRecord requires STRUCTURAL objectClass diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/AdsSchemaLoaderTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/AdsSchemaLoaderTest.java index 709c987077..2973bd4b44 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/AdsSchemaLoaderTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/AdsSchemaLoaderTest.java @@ -28,7 +28,7 @@ import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager; import org.apache.directory.api.util.exception.Exceptions; import org.apache.directory.ldap.client.api.DefaultSchemaLoader; -import org.apache.directory.ldap.client.api.LdapConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; import org.apache.directory.server.core.integ.AbstractLdapTestUnit; @@ -49,13 +49,13 @@ { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") }) public class AdsSchemaLoaderTest extends AbstractLdapTestUnit { - private LdapConnection connection; + private PooledLdapConnection connection; @BeforeEach public void setup() throws Exception { - connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); } diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java index 5819795b06..31dc6f4e43 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java @@ -47,6 +47,7 @@ import org.apache.directory.ldap.client.api.LdapConnection; import org.apache.directory.ldap.client.api.LdapConnectionConfig; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.ldap.client.api.exception.InvalidConnectionException; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; @@ -70,13 +71,13 @@ public class LdapConnectionTest extends AbstractLdapTestUnit { private static final String ADMIN_DN = "uid=admin,ou=system"; - private LdapConnection connection; + private PooledLdapConnection connection; @BeforeEach public void setup() throws Exception { - connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); } @@ -234,7 +235,7 @@ public void testRetrieveBinaryAttibute() throws Exception assertFalse( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() ); // Now, test using the scerver's schema - ( ( LdapNetworkConnection ) connection ).loadSchema(); + ( ( LdapNetworkConnection ) connection.wrapped() ).loadSchema(); connection.bind( "uid=admin,ou=system", "secret" ); // Use the default list of binary Attributes diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/ServerSchemaLoaderTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/ServerSchemaLoaderTest.java index 90672b541b..445f7d467d 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/ServerSchemaLoaderTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/ServerSchemaLoaderTest.java @@ -32,7 +32,7 @@ import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager; import org.apache.directory.api.util.exception.Exceptions; import org.apache.directory.ldap.client.api.DefaultSchemaLoader; -import org.apache.directory.ldap.client.api.LdapConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; import org.apache.directory.server.core.integ.AbstractLdapTestUnit; @@ -53,13 +53,13 @@ { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") }) public class ServerSchemaLoaderTest extends AbstractLdapTestUnit { - private LdapConnection connection; + private PooledLdapConnection connection; @BeforeEach public void setup() throws Exception { - connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); } diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java index b087b747a5..8114c3d8f6 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java @@ -39,6 +39,7 @@ import org.apache.directory.api.ldap.model.message.SearchScope; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.ldap.client.api.future.SearchFuture; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; @@ -64,7 +65,7 @@ public class ClientAbandonRequestTest extends AbstractLdapTestUnit { private static final int numEntries = 100; private DelayInducingInterceptor delayInterceptor; - private LdapNetworkConnection connection; + private PooledLdapConnection connection; @BeforeEach @@ -72,7 +73,7 @@ public void setup() throws Exception { delayInterceptor = new DelayInducingInterceptor(); getLdapServer().getDirectoryService().addFirst( delayInterceptor ); - connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); // injecting some values to keep the // followed search operation to run for a while @@ -113,7 +114,7 @@ public void testCancelSearch() throws Exception sr.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES ); // Launch the search now - SearchFuture searchFuture = connection.searchAsync( sr ); + SearchFuture searchFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).searchAsync( sr ); Response searchResponse = null; int count = 0; diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java index c3c79ca879..ba5d9f73e2 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java @@ -53,6 +53,7 @@ import org.apache.directory.api.util.Strings; import org.apache.directory.api.util.TimeProvider; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.ldap.client.api.future.AddFuture; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; @@ -77,14 +78,14 @@ { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") }) public class ClientAddRequestTest extends AbstractLdapTestUnit { - private LdapNetworkConnection connection; + private PooledLdapConnection connection; private CoreSession session; @BeforeEach public void setup() throws Exception { - connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ) ); session = getLdapServer().getDirectoryService().getAdminSession(); } @@ -182,7 +183,7 @@ public void testAddAsync() throws Exception AddRequest addRequest = new AddRequestImpl(); addRequest.setEntry( entry ); - AddFuture addFuture = connection.addAsync( addRequest ); + AddFuture addFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).addAsync( addRequest ); AddResponse addResponse = addFuture.get( 1000, TimeUnit.MILLISECONDS ); @@ -207,7 +208,7 @@ public void testAddAsyncLdif() throws Exception AddRequest addRequest = new AddRequestImpl(); addRequest.setEntry( entry ); - AddFuture addFuture = connection.addAsync( addRequest ); + AddFuture addFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).addAsync( addRequest ); AddResponse addResponse = addFuture.get( 1000, TimeUnit.MILLISECONDS ); @@ -428,7 +429,7 @@ public void testAddNullValueSchemaAware() throws LdapException, IOException assertTrue( Strings.isEmpty( userPassword ) ); assertTrue( Strings.isEmpty( mail ) ); - connection.close(); + //connection.close(); } @@ -461,6 +462,6 @@ public void testAddUidWithDash() throws LdapException, IOException assertNotNull( found.get( "userPassword" ) ); assertTrue( found.contains( "uid", "Hi" ) ); - connection.close(); + //connection.close(); } } diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java index 149a819b7e..d795215945 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java @@ -34,6 +34,7 @@ import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.util.Strings; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.ldap.client.api.future.CompareFuture; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; @@ -57,14 +58,14 @@ { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") }) public class ClientCompareRequestTest extends AbstractLdapTestUnit { - private LdapNetworkConnection connection; + private PooledLdapConnection connection; private CoreSession session; @BeforeEach public void setup() throws Exception { - connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); session = getLdapServer().getDirectoryService().getAdminSession(); } @@ -105,7 +106,7 @@ public void testCompareAsync() throws Exception assertTrue( session.exists( dn ) ); - CompareFuture compareFuture = connection.compareAsync( compareRequest ); + CompareFuture compareFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).compareAsync( compareRequest ); CompareResponse compareResponse = compareFuture.get( 1000, TimeUnit.MILLISECONDS ); diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java index f378c78088..a092c9d196 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java @@ -41,6 +41,7 @@ import org.apache.directory.api.ldap.model.message.controls.OpaqueControl; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.ldap.client.api.future.DeleteFuture; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; @@ -86,14 +87,14 @@ "sn: grand_child12_sn" }) public class ClientDeleteRequestTest extends AbstractLdapTestUnit { - private LdapNetworkConnection connection; + private PooledLdapConnection connection; private CoreSession session; @BeforeEach public void setup() throws Exception { - connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); session = getLdapServer().getDirectoryService().getAdminSession(); } @@ -142,7 +143,7 @@ public void testDeleteWithCascadeControl() throws Exception if ( connection.isControlSupported( "1.2.840.113556.1.4.805" ) ) { - connection.deleteTree( "cn=parent,ou=system" ); + ( ( LdapNetworkConnection ) connection.wrapped() ).deleteTree( "cn=parent,ou=system" ); assertFalse( session.exists( "cn=parent,ou=system" ) ); } @@ -193,7 +194,7 @@ public void testDeleteAsyncWithoutCascadeControl() throws Exception try { - connection.deleteTree( "cn=parent,ou=system" ); + ( ( LdapNetworkConnection ) connection.wrapped() ).deleteTree( "cn=parent,ou=system" ); fail(); } catch ( LdapException le ) @@ -211,7 +212,7 @@ public void testDeleteAsync() throws Exception DeleteRequest deleteRequest = new DeleteRequestImpl(); deleteRequest.setName( new Dn( "cn=grand_child12,cn=child1,cn=parent,ou=system" ) ); - DeleteFuture deleteFuture = connection.deleteAsync( deleteRequest ); + DeleteFuture deleteFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).deleteAsync( deleteRequest ); DeleteResponse deleteResponse = deleteFuture.get( 1000, TimeUnit.MILLISECONDS ); diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java index b0c457cb77..eebfc105a1 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java @@ -33,6 +33,7 @@ import org.apache.directory.api.ldap.model.message.ExtendedResponse; import org.apache.directory.api.ldap.model.message.ResultCodeEnum; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.ldap.client.api.future.ExtendedFuture; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; @@ -61,13 +62,13 @@ { StartTlsHandler.class }) public class ClientExtendedRequestTest extends AbstractLdapTestUnit { - private LdapNetworkConnection connection; + private PooledLdapConnection connection; @BeforeEach public void setup() throws Exception { - connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); } @@ -81,41 +82,24 @@ public void shutdown() throws Exception @Test public void testExtended() throws Exception { - try - { - ExtendedResponse response = connection.extended( StartTlsRequest.OID ); - assertNotNull( response ); - assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() ); - } - finally - { - // close connection to stop TLS - connection.close(); - } + ExtendedResponse response = connection.extended( StartTlsRequest.OID ); + assertNotNull( response ); + assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() ); } @Test public void testExtendedAsync() throws Exception { - try - { - ExtendedRequest extendedRequest = new StartTlsRequestImpl(); - extendedRequest.setRequestName( StartTlsRequest.OID ); + ExtendedRequest extendedRequest = new StartTlsRequestImpl(); + extendedRequest.setRequestName( StartTlsRequest.OID ); - ExtendedFuture extendedFuture = connection.extendedAsync( extendedRequest ); + ExtendedFuture extendedFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).extendedAsync( extendedRequest ); - ExtendedResponse extendedResponse = ( ExtendedResponse ) extendedFuture.get( 1000, TimeUnit.MILLISECONDS ); - - assertNotNull( extendedResponse ); - assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() ); - assertTrue( connection.isAuthenticated() ); - } - finally - { - // close connection to stop TLS - connection.close(); - } + ExtendedResponse extendedResponse = ( ExtendedResponse ) extendedFuture.get( 1000, TimeUnit.MILLISECONDS ); + assertNotNull( extendedResponse ); + assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() ); + assertTrue( connection.isAuthenticated() ); } } \ No newline at end of file diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java index c2f6ab635a..f9b797af23 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java @@ -37,6 +37,7 @@ import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.ldap.model.name.Rdn; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.ldap.client.api.future.ModifyDnFuture; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; @@ -83,14 +84,14 @@ public class ClientModifyDnRequestTest extends AbstractLdapTestUnit private static final String DN = "cn=modDn,ou=system"; private static final String DN_EMPLOYEE = "employeeNumber=test,ou=system"; private static final String DN_CONTAINER = "ou=container,ou=system"; - private LdapNetworkConnection connection; + private PooledLdapConnection connection; private CoreSession session; @BeforeEach public void setup() throws Exception { - connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); session = getLdapServer().getDirectoryService().getAdminSession(); } @@ -189,7 +190,7 @@ public void testModifyDnAsync() throws Exception modDnReq.setNewRdn( new Rdn( "cn=modifyDnWithString" ) ); modDnReq.setDeleteOldRdn( true ); - ModifyDnFuture modifyDnFuture = connection.modifyDnAsync( modDnReq ); + ModifyDnFuture modifyDnFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).modifyDnAsync( modDnReq ); ModifyDnResponse response = modifyDnFuture.get( 1000, TimeUnit.MILLISECONDS ); diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java index 66f3d58cdd..25bfa7d593 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java @@ -43,6 +43,7 @@ import org.apache.directory.api.util.Network; import org.apache.directory.api.util.TimeProvider; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.ldap.client.api.future.ModifyFuture; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; @@ -78,14 +79,14 @@ }) public class ClientModifyRequestTest extends AbstractLdapTestUnit { - private LdapNetworkConnection connection; + private PooledLdapConnection connection; private CoreSession session; @BeforeEach public void setup() throws Exception { - connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); session = getLdapServer().getDirectoryService().getAdminSession(); } @@ -183,7 +184,7 @@ public void modifyAsync() throws Exception assertTrue( session.exists( dn ) ); - ModifyFuture modifyFuture = connection.modifyAsync( modifyRequest ); + ModifyFuture modifyFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).modifyAsync( modifyRequest ); ModifyResponse response = modifyFuture.get( 1000, TimeUnit.MILLISECONDS ); diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/GetRootDseTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/GetRootDseTest.java index 8655fe7ff6..f0472bb2e9 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/GetRootDseTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/GetRootDseTest.java @@ -26,7 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.directory.api.ldap.model.entry.Entry; -import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; import org.apache.directory.server.core.integ.AbstractLdapTestUnit; @@ -48,13 +48,13 @@ { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") }) public class GetRootDseTest extends AbstractLdapTestUnit { - private LdapNetworkConnection connection; + private PooledLdapConnection connection; @BeforeEach public void setup() throws Exception { - connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = (PooledLdapConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); } diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/lookup/LookupTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/lookup/LookupTest.java index f1bdeec3ca..a40f2255c6 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/lookup/LookupTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/lookup/LookupTest.java @@ -26,6 +26,7 @@ import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.ldap.model.message.SearchScope; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; import org.apache.directory.server.core.annotations.ApplyLdifs; @@ -142,13 +143,13 @@ */ public class LookupTest extends AbstractLdapTestUnit { - private LdapNetworkConnection connection; + private PooledLdapConnection connection; @BeforeEach public void setup() throws Exception { - connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); // Restart the service so that the index is created getService().shutdown(); diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java index 0a1fbde1c0..5921d0d323 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java @@ -42,6 +42,7 @@ import org.apache.directory.api.ldap.model.message.controls.ManageDsaITImpl; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.ldap.client.api.future.SearchFuture; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; @@ -106,13 +107,13 @@ }) public class ClientSearchRequestTest extends AbstractLdapTestUnit { - private LdapNetworkConnection connection; + private PooledLdapConnection connection; @BeforeEach public void setup() throws Exception { - connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); } @@ -222,7 +223,7 @@ public void testSearchEquality() throws Exception @Test public void testAsyncSearch() throws Exception { - SearchFuture searchFuture = connection.searchAsync( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL, "*", + SearchFuture searchFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).searchAsync( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL, "*", "+" ); int count = 0; Response searchResponse = null; @@ -249,7 +250,7 @@ public void testAsyncSearch() throws Exception @Test public void testSearchSubstring() throws Exception { - SearchFuture searchFuture = connection.searchAsync( "ou=system", "(cn=*e*)", SearchScope.SUBTREE, + SearchFuture searchFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).searchAsync( "ou=system", "(cn=*e*)", SearchScope.SUBTREE, "*", "+" ); int count = 0; Response searchResponse = null; @@ -277,7 +278,7 @@ public void testSearchSubstring() throws Exception @Test public void testSearchSubstring2() throws Exception { - SearchFuture searchFuture = connection.searchAsync( "ou=system", "(cn=Test *)", SearchScope.SUBTREE, + SearchFuture searchFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).searchAsync( "ou=system", "(cn=Test *)", SearchScope.SUBTREE, "*", "+" ); int count = 0; Response searchResponse = null; diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java index faec088c85..2361d435a6 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java @@ -42,6 +42,7 @@ import org.apache.directory.api.ldap.model.message.SearchScope; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; import org.apache.directory.server.core.annotations.ContextEntry; @@ -111,13 +112,13 @@ */ public class OperationWithIndexTest extends AbstractLdapTestUnit { - private LdapNetworkConnection connection; + private PooledLdapConnection connection; @BeforeEach public void setup() throws Exception { - connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); // Restart the service so that the index is created getService().shutdown(); @@ -280,7 +281,7 @@ public void testAddPerf() throws Exception System.out.println( "--------------> Starting up completed in " + ( ns9 - ns8 ) ); // and do a search again - connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); long ns10 = System.currentTimeMillis(); results = connection.search( "dc=example,dc=com", "(displayName=345*)", SearchScope.SUBTREE, "*" ); @@ -312,7 +313,7 @@ public void testAddPerf() throws Exception System.out.println( "--------------> Starting up completed in " + ( ns15 - ns14 ) ); // and do a search again - connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); long ns16 = System.currentTimeMillis(); results = connection.search( "dc=example,dc=com", "(displayName=345*)", SearchScope.SUBTREE, "*" ); diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java index c37bf882bb..a0a7374bbc 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java @@ -33,8 +33,6 @@ import org.apache.directory.api.ldap.model.cursor.Cursor; import org.apache.directory.api.ldap.model.cursor.EntryCursor; import org.apache.directory.api.ldap.model.entry.Entry; -import org.apache.directory.api.ldap.model.filter.ExprNode; -import org.apache.directory.api.ldap.model.filter.FilterParser; import org.apache.directory.api.ldap.model.message.Response; import org.apache.directory.api.ldap.model.message.SearchRequest; import org.apache.directory.api.ldap.model.message.SearchRequestImpl; @@ -43,7 +41,7 @@ import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.ldap.model.schema.SchemaManager; import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager; -import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; import org.apache.directory.server.core.annotations.ApplyLdifs; @@ -76,13 +74,13 @@ "cn: user1-alias" }) public class SearchRequestReturningAttributesTest extends AbstractLdapTestUnit { - private LdapNetworkConnection connection; + private PooledLdapConnection connection; @BeforeEach public void setup() throws Exception { - connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = (PooledLdapConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); } diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchWithReferralsTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchWithReferralsTest.java index 740a2da854..5741aa5965 100644 --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchWithReferralsTest.java +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchWithReferralsTest.java @@ -41,7 +41,7 @@ import org.apache.directory.api.ldap.model.message.SearchRequestImpl; import org.apache.directory.api.ldap.model.message.SearchScope; import org.apache.directory.api.ldap.model.name.Dn; -import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.ldap.client.api.PooledLdapConnection; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; import org.apache.directory.server.core.annotations.ApplyLdifs; @@ -129,7 +129,7 @@ "ou: Countries" }) public class SearchWithReferralsTest extends AbstractLdapTestUnit { - private LdapNetworkConnection connection; + private PooledLdapConnection connection; @BeforeEach @@ -161,7 +161,7 @@ public void setupReferrals() throws Exception reader.close(); - connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); }