Search in sources :

Example 6 with TestIntermediateResponseListener

use of com.unboundid.ldap.sdk.TestIntermediateResponseListener in project ldapsdk by pingidentity.

the class InMemoryOperationInterceptorTestCase method testSearchWithTransformations.

/**
 * Tests to ensure that processing works correctly for search operations.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testSearchWithTransformations() throws Exception {
    final LDAPConnection conn = ds.getConnection();
    SearchRequest searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    SearchResult searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.SUCCESS);
    assertEntriesReturnedEquals(searchResult, 1);
    assertReferencesReturnedEquals(searchResult, 0);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ALTER_DN));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.NO_SUCH_OBJECT);
    assertEntriesReturnedEquals(searchResult, 0);
    assertReferencesReturnedEquals(searchResult, 0);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REJECT_REQUEST));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.UNWILLING_TO_PERFORM);
    assertEntriesReturnedEquals(searchResult, 0);
    assertReferencesReturnedEquals(searchResult, 0);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REQUEST_RUNTIME_EXCEPTION));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.OTHER);
    assertEntriesReturnedEquals(searchResult, 0);
    assertReferencesReturnedEquals(searchResult, 0);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ERROR_RESULT));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.UNWILLING_TO_PERFORM);
    assertEntriesReturnedEquals(searchResult, 1);
    assertReferencesReturnedEquals(searchResult, 0);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.RESULT_RUNTIME_EXCEPTION));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.OTHER);
    assertEntriesReturnedEquals(searchResult, 1);
    assertReferencesReturnedEquals(searchResult, 0);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_ENTRY));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.SUCCESS);
    assertEntriesReturnedEquals(searchResult, 3);
    assertReferencesReturnedEquals(searchResult, 0);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ENTRY_RUNTIME_EXCEPTION));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.SUCCESS);
    assertEntriesReturnedEquals(searchResult, 0);
    assertReferencesReturnedEquals(searchResult, 0);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ALTER_ENTRY));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.SUCCESS);
    assertEntriesReturnedEquals(searchResult, 1);
    assertReferencesReturnedEquals(searchResult, 0);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.SUPPRESS_ENTRY));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.SUCCESS);
    assertEntriesReturnedEquals(searchResult, 0);
    assertReferencesReturnedEquals(searchResult, 0);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_ENTRY, ControlBasedOperationInterceptor.TransformType.SUPPRESS_ENTRY));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.SUCCESS);
    assertEntriesReturnedEquals(searchResult, 0);
    assertReferencesReturnedEquals(searchResult, 0);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_ENTRY, ControlBasedOperationInterceptor.TransformType.ALTER_ENTRY));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.SUCCESS);
    assertEntriesReturnedEquals(searchResult, 3);
    assertReferencesReturnedEquals(searchResult, 0);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_REFERENCE));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.SUCCESS);
    assertEntriesReturnedEquals(searchResult, 1);
    assertReferencesReturnedEquals(searchResult, 2);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_REFERENCE, ControlBasedOperationInterceptor.TransformType.SUPPRESS_REFERENCE));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.SUCCESS);
    assertEntriesReturnedEquals(searchResult, 1);
    assertReferencesReturnedEquals(searchResult, 0);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_REFERENCE, ControlBasedOperationInterceptor.TransformType.ALTER_REFERENCE));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.SUCCESS);
    assertEntriesReturnedEquals(searchResult, 1);
    assertReferencesReturnedEquals(searchResult, 2);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_REFERENCE, ControlBasedOperationInterceptor.TransformType.REFERENCE_RUNTIME_EXCEPTION));
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.SUCCESS);
    assertEntriesReturnedEquals(searchResult, 1);
    assertReferencesReturnedEquals(searchResult, 0);
    searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, "(objectClass=*)");
    searchRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_INTERMEDIATE_RESPONSE));
    final TestIntermediateResponseListener testIRListener = new TestIntermediateResponseListener();
    searchRequest.setIntermediateResponseListener(testIRListener);
    searchResult = (SearchResult) assertResultCodeEquals(conn, searchRequest, ResultCode.SUCCESS);
    assertEntriesReturnedEquals(searchResult, 1);
    assertReferencesReturnedEquals(searchResult, 0);
    assertEquals(testIRListener.getCount(), 2);
    conn.close();
}
Also used : SearchRequest(com.unboundid.ldap.sdk.SearchRequest) TestIntermediateResponseListener(com.unboundid.ldap.sdk.TestIntermediateResponseListener) SearchResult(com.unboundid.ldap.sdk.SearchResult) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) Test(org.testng.annotations.Test)

Example 7 with TestIntermediateResponseListener

use of com.unboundid.ldap.sdk.TestIntermediateResponseListener in project ldapsdk by pingidentity.

the class InMemoryOperationInterceptorTestCase method testModifyDNWithTransformations.

/**
 * Tests to ensure that processing works correctly for modify DN operations.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testModifyDNWithTransformations() throws Exception {
    final LDAPConnection conn = ds.getConnection();
    conn.add("dn: ou=test1,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: test1");
    conn.add("dn: ou=test2,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: test2");
    conn.add("dn: ou=test3,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: test3");
    conn.add("dn: ou=test4,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: test4");
    conn.add("dn: ou=altered,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: altered");
    ModifyDNRequest modifyDNRequest = new ModifyDNRequest("ou=test1,dc=example,dc=com", "ou=renamed1", true);
    assertResultCodeEquals(conn, modifyDNRequest, ResultCode.SUCCESS);
    assertEntryMissing(conn, "ou=test1,dc=example,dc=com");
    assertEntryExists(conn, "ou=renamed1,dc=example,dc=com");
    modifyDNRequest = new ModifyDNRequest("ou=test2,dc=example,dc=com", "ou=renamed2", true);
    modifyDNRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ALTER_DN));
    assertResultCodeEquals(conn, modifyDNRequest, ResultCode.SUCCESS);
    assertEntryExists(conn, "ou=test2,dc=example,dc=com");
    assertEntryMissing(conn, "ou=altered,dc=example,dc=com");
    assertEntryExists(conn, "ou=renamed2,dc=example,dc=com");
    modifyDNRequest = new ModifyDNRequest("ou=test2,dc=example,dc=com", "ou=renamed3", true);
    modifyDNRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REJECT_REQUEST));
    assertResultCodeEquals(conn, modifyDNRequest, ResultCode.UNWILLING_TO_PERFORM);
    assertEntryExists(conn, "ou=test2,dc=example,dc=com");
    assertEntryMissing(conn, "ou=renamed3,dc=example,dc=com");
    modifyDNRequest = new ModifyDNRequest("ou=test2,dc=example,dc=com", "ou=renamed3", true);
    modifyDNRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REQUEST_RUNTIME_EXCEPTION));
    assertResultCodeEquals(conn, modifyDNRequest, ResultCode.OTHER);
    assertEntryExists(conn, "ou=test2,dc=example,dc=com");
    assertEntryMissing(conn, "ou=renamed3,dc=example,dc=com");
    modifyDNRequest = new ModifyDNRequest("ou=test2,dc=example,dc=com", "ou=renamed3", true);
    modifyDNRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ERROR_RESULT));
    assertResultCodeEquals(conn, modifyDNRequest, ResultCode.UNWILLING_TO_PERFORM);
    assertEntryMissing(conn, "ou=test2,dc=example,dc=com");
    assertEntryExists(conn, "ou=renamed3,dc=example,dc=com");
    modifyDNRequest = new ModifyDNRequest("ou=test3,dc=example,dc=com", "ou=renamed4", true);
    modifyDNRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.RESULT_RUNTIME_EXCEPTION));
    assertResultCodeEquals(conn, modifyDNRequest, ResultCode.OTHER);
    assertEntryMissing(conn, "ou=test3,dc=example,dc=com");
    assertEntryExists(conn, "ou=renamed4,dc=example,dc=com");
    modifyDNRequest = new ModifyDNRequest("ou=test4,dc=example,dc=com", "ou=renamed5", true);
    modifyDNRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_INTERMEDIATE_RESPONSE));
    final TestIntermediateResponseListener testIRListener = new TestIntermediateResponseListener();
    modifyDNRequest.setIntermediateResponseListener(testIRListener);
    assertResultCodeEquals(conn, modifyDNRequest, ResultCode.SUCCESS);
    assertEntryMissing(conn, "ou=test4,dc=example,dc=com");
    assertEntryExists(conn, "ou=renamed5,dc=example,dc=com");
    assertEquals(testIRListener.getCount(), 2);
    conn.delete("ou=renamed1,dc=example,dc=com");
    conn.delete("ou=renamed2,dc=example,dc=com");
    conn.delete("ou=renamed3,dc=example,dc=com");
    conn.delete("ou=renamed4,dc=example,dc=com");
    conn.delete("ou=renamed5,dc=example,dc=com");
    conn.close();
}
Also used : ModifyDNRequest(com.unboundid.ldap.sdk.ModifyDNRequest) TestIntermediateResponseListener(com.unboundid.ldap.sdk.TestIntermediateResponseListener) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) Test(org.testng.annotations.Test)

Example 8 with TestIntermediateResponseListener

use of com.unboundid.ldap.sdk.TestIntermediateResponseListener in project ldapsdk by pingidentity.

the class InMemoryOperationInterceptorTestCase method testSimpleBindWithTransformations.

/**
 * Tests to ensure that processing works correctly for simple bind operations.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testSimpleBindWithTransformations() throws Exception {
    final LDAPConnection conn = ds.getConnection();
    SimpleBindRequest bindRequest = new SimpleBindRequest("cn=Directory Manager", "password");
    assertResultCodeEquals(conn, bindRequest, ResultCode.SUCCESS);
    bindRequest = new SimpleBindRequest("cn=Directory Manager", "password", ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ALTER_DN));
    assertResultCodeEquals(conn, bindRequest, ResultCode.INVALID_CREDENTIALS);
    bindRequest = new SimpleBindRequest("cn=Directory Manager", "password", ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REJECT_REQUEST));
    assertResultCodeEquals(conn, bindRequest, ResultCode.UNWILLING_TO_PERFORM);
    bindRequest = new SimpleBindRequest("cn=Directory Manager", "password", ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REQUEST_RUNTIME_EXCEPTION));
    assertResultCodeEquals(conn, bindRequest, ResultCode.OTHER);
    bindRequest = new SimpleBindRequest("cn=Directory Manager", "password", ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ERROR_RESULT));
    assertResultCodeEquals(conn, bindRequest, ResultCode.UNWILLING_TO_PERFORM);
    bindRequest = new SimpleBindRequest("cn=Directory Manager", "password", ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.RESULT_RUNTIME_EXCEPTION));
    assertResultCodeEquals(conn, bindRequest, ResultCode.OTHER);
    bindRequest = new SimpleBindRequest("cn=Directory Manager", "password", ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_INTERMEDIATE_RESPONSE));
    final TestIntermediateResponseListener testIRListener = new TestIntermediateResponseListener();
    bindRequest.setIntermediateResponseListener(testIRListener);
    assertResultCodeEquals(conn, bindRequest, ResultCode.SUCCESS);
    assertEquals(testIRListener.getCount(), 2);
    conn.close();
}
Also used : SimpleBindRequest(com.unboundid.ldap.sdk.SimpleBindRequest) TestIntermediateResponseListener(com.unboundid.ldap.sdk.TestIntermediateResponseListener) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) Test(org.testng.annotations.Test)

Example 9 with TestIntermediateResponseListener

use of com.unboundid.ldap.sdk.TestIntermediateResponseListener in project ldapsdk by pingidentity.

the class InMemoryOperationInterceptorTestCase method testAddWithTransformations.

/**
 * Tests to ensure that processing works correctly for add operations.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testAddWithTransformations() throws Exception {
    final LDAPConnection conn = ds.getConnection();
    AddRequest addRequest = new AddRequest("dn: ou=no transforms,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: no transforms");
    assertResultCodeEquals(conn, addRequest, ResultCode.SUCCESS);
    assertEntryExists(conn, "ou=no transforms,dc=example,dc=com");
    addRequest = new AddRequest("dn: ou=with alter DN transform,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: no transforms");
    addRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ALTER_DN));
    assertResultCodeEquals(conn, addRequest, ResultCode.SUCCESS);
    assertEntryMissing(conn, "ou=with alter DN transform,dc=example,dc=com");
    assertEntryExists(conn, "ou=altered,dc=example,dc=com");
    addRequest = new AddRequest("dn: ou=with inject IR transform,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: with inject IR transform");
    addRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_INTERMEDIATE_RESPONSE));
    final TestIntermediateResponseListener testIRListener = new TestIntermediateResponseListener();
    addRequest.setIntermediateResponseListener(testIRListener);
    assertResultCodeEquals(conn, addRequest, ResultCode.SUCCESS);
    assertEntryExists(conn, "ou=with inject IR transform,dc=example,dc=com");
    assertEquals(testIRListener.getCount(), 2);
    addRequest = new AddRequest("dn: ou=with reject request transform,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: with reject request transform");
    addRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REJECT_REQUEST));
    assertResultCodeEquals(conn, addRequest, ResultCode.UNWILLING_TO_PERFORM);
    assertEntryMissing(conn, "ou=with reject request transform,dc=example,dc=com");
    addRequest = new AddRequest("dn: ou=with request RTE transform,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: with request RTE transform");
    addRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REQUEST_RUNTIME_EXCEPTION));
    assertResultCodeEquals(conn, addRequest, ResultCode.OTHER);
    assertEntryMissing(conn, "ou=with request RTE transform,dc=example,dc=com");
    addRequest = new AddRequest("dn: ou=with error result transform,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: with error result transform");
    addRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ERROR_RESULT));
    assertResultCodeEquals(conn, addRequest, ResultCode.UNWILLING_TO_PERFORM);
    assertEntryExists(conn, "ou=with error result transform,dc=example,dc=com");
    addRequest = new AddRequest("dn: ou=with result RTE transform,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: with result RTE transform");
    addRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.RESULT_RUNTIME_EXCEPTION));
    assertResultCodeEquals(conn, addRequest, ResultCode.OTHER);
    assertEntryExists(conn, "ou=with result RTE transform,dc=example,dc=com");
    conn.delete("ou=no transforms,dc=example,dc=com");
    conn.delete("ou=altered,dc=example,dc=com");
    conn.delete("ou=with inject IR transform,dc=example,dc=com");
    conn.delete("ou=with error result transform,dc=example,dc=com");
    conn.delete("ou=with result RTE transform,dc=example,dc=com");
    conn.close();
}
Also used : AddRequest(com.unboundid.ldap.sdk.AddRequest) TestIntermediateResponseListener(com.unboundid.ldap.sdk.TestIntermediateResponseListener) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) Test(org.testng.annotations.Test)

Example 10 with TestIntermediateResponseListener

use of com.unboundid.ldap.sdk.TestIntermediateResponseListener in project ldapsdk by pingidentity.

the class InMemoryOperationInterceptorTestCase method testDeleteWithTransformations.

/**
 * Tests to ensure that processing works correctly for delete operations.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testDeleteWithTransformations() throws Exception {
    final LDAPConnection conn = ds.getConnection();
    conn.add("dn: ou=test1,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: test1");
    conn.add("dn: ou=test2,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: test2");
    conn.add("dn: ou=test3,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: test3");
    conn.add("dn: ou=test4,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: test4");
    conn.add("dn: ou=altered,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: altered");
    DeleteRequest deleteRequest = new DeleteRequest("ou=test1,dc=example,dc=com");
    assertResultCodeEquals(conn, deleteRequest, ResultCode.SUCCESS);
    assertEntryMissing(conn, "ou=test1,dc=example,dc=com");
    deleteRequest = new DeleteRequest("ou=test2,dc=example,dc=com");
    deleteRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ALTER_DN));
    assertResultCodeEquals(conn, deleteRequest, ResultCode.SUCCESS);
    assertEntryExists(conn, "ou=test2,dc=example,dc=com");
    assertEntryMissing(conn, "ou=altered,dc=example,dc=com");
    deleteRequest = new DeleteRequest("ou=test2,dc=example,dc=com");
    deleteRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REJECT_REQUEST));
    assertResultCodeEquals(conn, deleteRequest, ResultCode.UNWILLING_TO_PERFORM);
    assertEntryExists(conn, "ou=test2,dc=example,dc=com");
    deleteRequest = new DeleteRequest("ou=test2,dc=example,dc=com");
    deleteRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REQUEST_RUNTIME_EXCEPTION));
    assertResultCodeEquals(conn, deleteRequest, ResultCode.OTHER);
    assertEntryExists(conn, "ou=test2,dc=example,dc=com");
    deleteRequest = new DeleteRequest("ou=test2,dc=example,dc=com");
    deleteRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ERROR_RESULT));
    assertResultCodeEquals(conn, deleteRequest, ResultCode.UNWILLING_TO_PERFORM);
    assertEntryMissing(conn, "ou=test2,dc=example,dc=com");
    deleteRequest = new DeleteRequest("ou=test3,dc=example,dc=com");
    deleteRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.RESULT_RUNTIME_EXCEPTION));
    assertResultCodeEquals(conn, deleteRequest, ResultCode.OTHER);
    assertEntryMissing(conn, "ou=test3,dc=example,dc=com");
    deleteRequest = new DeleteRequest("ou=test4,dc=example,dc=com");
    deleteRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_INTERMEDIATE_RESPONSE));
    final TestIntermediateResponseListener testIRListener = new TestIntermediateResponseListener();
    deleteRequest.setIntermediateResponseListener(testIRListener);
    assertResultCodeEquals(conn, deleteRequest, ResultCode.SUCCESS);
    assertEntryMissing(conn, "ou=test4,dc=example,dc=com");
    assertEquals(testIRListener.getCount(), 2);
    conn.close();
}
Also used : TestIntermediateResponseListener(com.unboundid.ldap.sdk.TestIntermediateResponseListener) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) DeleteRequest(com.unboundid.ldap.sdk.DeleteRequest) Test(org.testng.annotations.Test)

Aggregations

LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)11 TestIntermediateResponseListener (com.unboundid.ldap.sdk.TestIntermediateResponseListener)11 Test (org.testng.annotations.Test)11 WhoAmIExtendedRequest (com.unboundid.ldap.sdk.extensions.WhoAmIExtendedRequest)2 AddRequest (com.unboundid.ldap.sdk.AddRequest)1 CompareRequest (com.unboundid.ldap.sdk.CompareRequest)1 DeleteRequest (com.unboundid.ldap.sdk.DeleteRequest)1 LDAPException (com.unboundid.ldap.sdk.LDAPException)1 ModifyDNRequest (com.unboundid.ldap.sdk.ModifyDNRequest)1 ModifyRequest (com.unboundid.ldap.sdk.ModifyRequest)1 PLAINBindRequest (com.unboundid.ldap.sdk.PLAINBindRequest)1 SearchRequest (com.unboundid.ldap.sdk.SearchRequest)1 SearchResult (com.unboundid.ldap.sdk.SearchResult)1 SimpleBindRequest (com.unboundid.ldap.sdk.SimpleBindRequest)1