Search in sources :

Example 6 with TestOutputStream

use of com.unboundid.util.TestOutputStream in project ldapsdk by pingidentity.

the class LDAPListenerClientConnectionTestCase method testThrowOnGetOutputStream.

/**
 * Tests the behavior when a client connection has been created without a
 * listener and with a socket that throws an exception when trying to get the
 * output stream.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testThrowOnGetOutputStream() throws Exception {
    final TestSocket s = new TestSocket(new TestInputStream(new ByteArrayInputStream(new byte[1024]), new IOException("foo"), 100, true), new TestOutputStream(new ByteArrayOutputStream(), new IOException("bar"), 1024, true));
    s.setThrowOnGetOutputStream(true);
    s.setThrowOnClose(true);
    new LDAPListenerClientConnection(null, s, new CannedResponseRequestHandler(), null);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) TestOutputStream(com.unboundid.util.TestOutputStream) TestSocket(com.unboundid.util.TestSocket) IOException(java.io.IOException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TestInputStream(com.unboundid.util.TestInputStream) Test(org.testng.annotations.Test)

Aggregations

TestOutputStream (com.unboundid.util.TestOutputStream)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 IOException (java.io.IOException)6 Test (org.testng.annotations.Test)6 TestInputStream (com.unboundid.util.TestInputStream)4 TestSocket (com.unboundid.util.TestSocket)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 CollectSupportDataArchiveFragmentIntermediateResponse (com.unboundid.ldap.sdk.unboundidds.extensions.CollectSupportDataArchiveFragmentIntermediateResponse)2 CollectSupportDataOutputStream (com.unboundid.ldap.sdk.unboundidds.extensions.CollectSupportDataOutputStream)2 File (java.io.File)2 OutputStream (java.io.OutputStream)2 LDAPException (com.unboundid.ldap.sdk.LDAPException)1