use of com.unboundid.ldap.sdk.unboundidds.extensions.CollectSupportDataOutputIntermediateResponse in project ldapsdk by pingidentity.
the class CollectSupportDataIRListenerTestCase method testOutputMessages.
/**
* Tests the behavior for output message responses.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testOutputMessages() throws Exception {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final ByteArrayOutputStream err = new ByteArrayOutputStream();
final CollectSupportData tool = new CollectSupportData(out, err);
final File outputFile = createTempFile();
assertTrue(outputFile.delete());
final CollectSupportDataIRListener listener = new CollectSupportDataIRListener(tool, outputFile);
listener.handleOutputIntermediateResponse(new CollectSupportDataOutputIntermediateResponse(CollectSupportDataOutputStream.STANDARD_OUTPUT, "standard output message"));
assertEquals(out.size(), "standard output message".length() + StaticUtils.EOL_BYTES.length);
assertEquals(err.size(), 0);
assertFalse(outputFile.exists());
assertNull(listener.getOutputStreamReference().get());
assertNull(listener.getFirstIOExceptionReference().get());
out.reset();
assertEquals(out.size(), 0);
listener.handleOutputIntermediateResponse(new CollectSupportDataOutputIntermediateResponse(CollectSupportDataOutputStream.STANDARD_ERROR, "standard error message"));
assertEquals(out.size(), 0);
assertEquals(err.size(), "standard error message".length() + StaticUtils.EOL_BYTES.length);
assertFalse(outputFile.exists());
assertNull(listener.getOutputStreamReference().get());
assertNull(listener.getFirstIOExceptionReference().get());
err.reset();
assertEquals(err.size(), 0);
listener.close();
assertEquals(out.size(), 0);
assertEquals(err.size(), 0);
assertFalse(outputFile.exists());
assertNull(listener.getOutputStreamReference().get());
assertNull(listener.getFirstIOExceptionReference().get());
}
Aggregations