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());
}
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())));
}
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));
}
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());
}
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);
}
Aggregations