Search in sources :

Example 51 with IntermediateResponse

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

the class MissingChangelogEntriesIntermediateResponseTestCase method testDecodeGenericResponseWithoutValue.

/**
 * Provides test coverage for an attempt to decode a generic intermediate
 * response without a value.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testDecodeGenericResponseWithoutValue() throws Exception {
    final IntermediateResponse genericIR = new IntermediateResponse(MissingChangelogEntriesIntermediateResponse.MISSING_CHANGELOG_ENTRIES_INTERMEDIATE_RESPONSE_OID, null);
    final MissingChangelogEntriesIntermediateResponse mceIR = new MissingChangelogEntriesIntermediateResponse(genericIR);
    assertNotNull(mceIR);
    assertNull(mceIR.getMessage());
    assertNotNull(mceIR.getIntermediateResponseName());
    assertNull(mceIR.valueToString());
    assertNotNull(mceIR.toString());
}
Also used : IntermediateResponse(com.unboundid.ldap.sdk.IntermediateResponse) Test(org.testng.annotations.Test)

Example 52 with IntermediateResponse

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

the class MissingChangelogEntriesIntermediateResponseTestCase method testDecodeValueSequenceInvalidElementType.

/**
 * Provides test coverage for an attempt to decode a generic intermediate
 * response with a value sequence with an invalid element type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueSequenceInvalidElementType() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x00, "foo"));
    new MissingChangelogEntriesIntermediateResponse(new IntermediateResponse(MissingChangelogEntriesIntermediateResponse.MISSING_CHANGELOG_ENTRIES_INTERMEDIATE_RESPONSE_OID, new ASN1OctetString(valueSequence.encode())));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) IntermediateResponse(com.unboundid.ldap.sdk.IntermediateResponse) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) Test(org.testng.annotations.Test)

Example 53 with IntermediateResponse

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

the class CollectSupportDataOutputIntermediateResponseTestCase method testDecodeResponseWithUnrecognizedOutputStream.

/**
 * Tests the behavior when trying to decode an intermediate response that
 * has an unrecognized output stream value.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeResponseWithUnrecognizedOutputStream() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Enumerated((byte) 0x80, 12345), new ASN1OctetString((byte) 0x81, "message"));
    final ASN1OctetString value = new ASN1OctetString(valueSequence.encode());
    new CollectSupportDataOutputIntermediateResponse(new IntermediateResponse("1.3.6.1.4.1.30221.2.6.65", value));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) IntermediateResponse(com.unboundid.ldap.sdk.IntermediateResponse) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) Test(org.testng.annotations.Test)

Example 54 with IntermediateResponse

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

the class DefaultChangelogEntryListenerTestCase method testHandleOtherIntermediateResponse.

/**
 * Provides test coverage for the {@code handleOtherIntermediateResponse}
 * method.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testHandleOtherIntermediateResponse() throws Exception {
    final GetChangelogBatchExtendedRequest r = new GetChangelogBatchExtendedRequest(new EndOfChangelogStartingPoint(), 100, 300000L);
    final DefaultChangelogEntryListener l = new DefaultChangelogEntryListener(r);
    l.handleOtherIntermediateResponse(new IntermediateResponse("1.2.3.4", null));
    assertNotNull(l.getEntryList());
    assertTrue(l.getEntryList().isEmpty());
}
Also used : IntermediateResponse(com.unboundid.ldap.sdk.IntermediateResponse) Test(org.testng.annotations.Test)

Example 55 with IntermediateResponse

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

the class CollectSupportDataExtendedRequestTestCase method testIntermediateResponseReturned.

/**
 * Tests the behavior of the intermediate response returned method.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testIntermediateResponseReturned() throws Exception {
    final TestCollectSupportDataIntermediateResponseListener listener = new TestCollectSupportDataIntermediateResponseListener();
    final CollectSupportDataExtendedRequest r = new CollectSupportDataExtendedRequest(new CollectSupportDataExtendedRequestProperties(), listener);
    // Test with a valid output message sent to standard output.
    r.intermediateResponseReturned(new CollectSupportDataOutputIntermediateResponse(CollectSupportDataOutputStream.STANDARD_OUTPUT, "standard output message"));
    assertNotNull(listener.getStandardOutputMessages());
    assertEquals(listener.getStandardOutputMessages().size(), 1);
    assertNotNull(listener.getStandardErrorMessages());
    assertEquals(listener.getStandardErrorMessages().size(), 0);
    assertNotNull(listener.getArchiveData());
    assertEquals(listener.getArchiveData().length, 0);
    assertNotNull(listener.getOtherResponses());
    assertEquals(listener.getOtherResponses().size(), 0);
    // Test with a valid output message sent to standard error.
    listener.clear();
    r.intermediateResponseReturned(new CollectSupportDataOutputIntermediateResponse(CollectSupportDataOutputStream.STANDARD_ERROR, "standard error message"));
    assertNotNull(listener.getStandardOutputMessages());
    assertEquals(listener.getStandardOutputMessages().size(), 0);
    assertNotNull(listener.getStandardErrorMessages());
    assertEquals(listener.getStandardErrorMessages().size(), 1);
    assertNotNull(listener.getArchiveData());
    assertEquals(listener.getArchiveData().length, 0);
    assertNotNull(listener.getOtherResponses());
    assertEquals(listener.getOtherResponses().size(), 0);
    // Test with a malformed output message sent to standard error.
    listener.clear();
    r.intermediateResponseReturned(new IntermediateResponse("1.3.6.1.4.1.30221.2.6.65", new ASN1OctetString("malformed")));
    assertNotNull(listener.getStandardOutputMessages());
    assertEquals(listener.getStandardOutputMessages().size(), 0);
    assertNotNull(listener.getStandardErrorMessages());
    assertEquals(listener.getStandardErrorMessages().size(), 0);
    assertNotNull(listener.getArchiveData());
    assertEquals(listener.getArchiveData().length, 0);
    assertNotNull(listener.getOtherResponses());
    assertEquals(listener.getOtherResponses().size(), 1);
    // Test with a valid archive fragment.
    listener.clear();
    r.intermediateResponseReturned(new CollectSupportDataArchiveFragmentIntermediateResponse("csd.zip", 123_456L, true, StaticUtils.byteArray(1, 2, 3, 4, 5)));
    assertNotNull(listener.getStandardOutputMessages());
    assertEquals(listener.getStandardOutputMessages().size(), 0);
    assertNotNull(listener.getStandardErrorMessages());
    assertEquals(listener.getStandardErrorMessages().size(), 0);
    assertNotNull(listener.getArchiveData());
    assertEquals(listener.getArchiveData().length, 5);
    assertNotNull(listener.getOtherResponses());
    assertEquals(listener.getOtherResponses().size(), 0);
    // Test with a malformed archive fragment.
    listener.clear();
    r.intermediateResponseReturned(new IntermediateResponse("1.3.6.1.4.1.30221.2.6.66", new ASN1OctetString("malformed")));
    assertNotNull(listener.getStandardOutputMessages());
    assertEquals(listener.getStandardOutputMessages().size(), 0);
    assertNotNull(listener.getStandardErrorMessages());
    assertEquals(listener.getStandardErrorMessages().size(), 0);
    assertNotNull(listener.getArchiveData());
    assertEquals(listener.getArchiveData().length, 0);
    assertNotNull(listener.getOtherResponses());
    assertEquals(listener.getOtherResponses().size(), 1);
    // Test with some other type of intermediate response.
    listener.clear();
    r.intermediateResponseReturned(new IntermediateResponse("1.2.3.4", new ASN1OctetString("foo")));
    assertNotNull(listener.getStandardOutputMessages());
    assertEquals(listener.getStandardOutputMessages().size(), 0);
    assertNotNull(listener.getStandardErrorMessages());
    assertEquals(listener.getStandardErrorMessages().size(), 0);
    assertNotNull(listener.getArchiveData());
    assertEquals(listener.getArchiveData().length, 0);
    assertNotNull(listener.getOtherResponses());
    assertEquals(listener.getOtherResponses().size(), 1);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) 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