/*package*/ Channel(ChannelBuilder settings, InputStream is, OutputStream os) throws IOException { this(settings, settings.negotiate(is,os)); }
/** * Performs a handshake over the communication channel and builds a {@link Channel}. * * @param is * Stream connected to the remote peer. It's the caller's responsibility to do * buffering on this stream, if that's necessary. * @param os * Stream connected to the remote peer. It's the caller's responsibility to do * buffering on this stream, if that's necessary. */ public Channel build(InputStream is, OutputStream os) throws IOException { return new Channel(this,negotiate(is,os)); }
@Test public void exercise() throws Exception { ClassicCommandTransport ct = (ClassicCommandTransport) new ChannelBuilder("dummy",null) .withMode(Mode.BINARY) .withBaseLoader(getClass().getClassLoader()) .negotiate(new ByteArrayInputStream(payload), new NullOutputStream()); verify(ct); }
/** * This tests the behaviour of the diagnosis blocking on a non-completed stream, as the writer end is kept open. */ @Test(timeout=3000) public void blockingStreamShouldNotPreventDiagnosis() throws Exception { FastPipedInputStream in = new FastPipedInputStream(); FastPipedOutputStream out = new FastPipedOutputStream(in); out.write(payload); ClassicCommandTransport ct = (ClassicCommandTransport) new ChannelBuilder("dummy",null) .withMode(Mode.BINARY) .withBaseLoader(getClass().getClassLoader()) .negotiate(in, new NullOutputStream()); verify(ct); } }