Search in sources :

Example 31 with IntermediateResponse

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

the class StreamProxyValuesIntermediateResponseTestCase method testDecodeMalformedResult.

/**
 * Tests the behavior when trying to decode an intermediate response with a
 * malformed result element.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeMalformedResult() throws Exception {
    ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x81));
    ASN1OctetString value = new ASN1OctetString(valueSequence.encode());
    IntermediateResponse r = new IntermediateResponse("1.3.6.1.4.1.30221.2.6.9", value);
    new StreamProxyValuesIntermediateResponse(r);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) IntermediateResponse(com.unboundid.ldap.sdk.IntermediateResponse) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) Test(org.testng.annotations.Test)

Example 32 with IntermediateResponse

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

the class StreamProxyValuesIntermediateResponseTestCase method testFailureAttributeNotIndexed.

/**
 * Provides test coverage for an error response with an "attribute not
 * indexed" result.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testFailureAttributeNotIndexed() throws Exception {
    StreamProxyValuesIntermediateResponse r = new StreamProxyValuesIntermediateResponse("unindexed", StreamProxyValuesIntermediateResponse.RESULT_ATTRIBUTE_NOT_INDEXED, "Attribute unindexed is not indexed", null, new Control("1.2.3.4"), new Control("1.2.3.5"));
    r = new StreamProxyValuesIntermediateResponse(new IntermediateResponse(r.getOID(), r.getValue(), r.getControls()));
    assertNotNull(r);
    assertNotNull(r.getAttributeName());
    assertEquals(r.getAttributeName(), "unindexed");
    assertEquals(r.getResult(), StreamProxyValuesIntermediateResponse.RESULT_ATTRIBUTE_NOT_INDEXED);
    assertNotNull(r.getDiagnosticMessage());
    assertEquals(r.getDiagnosticMessage(), "Attribute unindexed is not indexed");
    assertNotNull(r.getValues());
    assertTrue(r.getValues().isEmpty());
    assertNotNull(r.getControls());
    assertEquals(r.getControls().length, 2);
    assertNotNull(r.getIntermediateResponseName());
    assertNotNull(r.valueToString());
    assertNotNull(r.toString());
}
Also used : Control(com.unboundid.ldap.sdk.Control) IntermediateResponse(com.unboundid.ldap.sdk.IntermediateResponse) Test(org.testng.annotations.Test)

Example 33 with IntermediateResponse

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

the class DebugTestCase method testDebugLDAPResult7EnabledWithoutLDAP.

/**
 * Tests the seventh {@code debugLDAPResult} method with the debugger enabled
 * and a debug type set that does not include the LDAP type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testDebugLDAPResult7EnabledWithoutLDAP() throws Exception {
    Debug.setEnabled(true, EnumSet.of(DebugType.OTHER));
    testLogHandler.resetMessageCount();
    assertFalse(Debug.debugEnabled(DebugType.LDAP));
    Debug.debugLDAPResult(new IntermediateResponse("1.2.3.4", null));
    assertTrue(testLogHandler.getMessageCount() >= 0);
}
Also used : IntermediateResponse(com.unboundid.ldap.sdk.IntermediateResponse) Test(org.testng.annotations.Test)

Example 34 with IntermediateResponse

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

the class DebugTestCase method testDebugLDAPResult7EnabledAll.

/**
 * Tests the seventh {@code debugLDAPResult} method with the debugger enabled
 * and a debug type set of all types.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testDebugLDAPResult7EnabledAll() throws Exception {
    Debug.setEnabled(true);
    testLogHandler.resetMessageCount();
    assertTrue(Debug.debugEnabled(DebugType.LDAP));
    Debug.debugLDAPResult(new IntermediateResponse("1.2.3.4", null));
    assertTrue(testLogHandler.getMessageCount() >= 1);
}
Also used : IntermediateResponse(com.unboundid.ldap.sdk.IntermediateResponse) Test(org.testng.annotations.Test)

Example 35 with IntermediateResponse

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

the class DebugTestCase method testDebugLDAPResult8EnabledAll.

/**
 * Tests the eighth {@code debugLDAPResult} method with the debugger enabled
 * and a debug type set of all types.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testDebugLDAPResult8EnabledAll() throws Exception {
    Debug.setEnabled(true);
    testLogHandler.resetMessageCount();
    assertTrue(Debug.debugEnabled(DebugType.LDAP));
    Debug.debugLDAPResult(Level.FINEST, new IntermediateResponse("1.2.3.4", null));
    assertTrue(testLogHandler.getMessageCount() >= 1);
}
Also used : IntermediateResponse(com.unboundid.ldap.sdk.IntermediateResponse) Test(org.testng.annotations.Test)

Aggregations

IntermediateResponse (com.unboundid.ldap.sdk.IntermediateResponse)56 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)39 Test (org.testng.annotations.Test)37 EnumSet (java.util.EnumSet)19 Set (java.util.Set)19 ExtendedResult (com.unboundid.ldap.sdk.ExtendedResult)18 LDAPException (com.unboundid.ldap.sdk.LDAPException)18 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)12 Control (com.unboundid.ldap.sdk.Control)11 LDAPResult (com.unboundid.ldap.sdk.LDAPResult)6 ASN1Enumerated (com.unboundid.asn1.ASN1Enumerated)5 ASN1Element (com.unboundid.asn1.ASN1Element)2 AddRequest (com.unboundid.ldap.sdk.AddRequest)2 BindResult (com.unboundid.ldap.sdk.BindResult)2 Entry (com.unboundid.ldap.sdk.Entry)2 SearchResultReference (com.unboundid.ldap.sdk.SearchResultReference)2 AddRequestProtocolOp (com.unboundid.ldap.protocol.AddRequestProtocolOp)1 IntermediateResponseProtocolOp (com.unboundid.ldap.protocol.IntermediateResponseProtocolOp)1 CompareRequest (com.unboundid.ldap.sdk.CompareRequest)1 DeleteRequest (com.unboundid.ldap.sdk.DeleteRequest)1