assertEquals( 1024, filter.getWriteBufferSize() );
}
public void testWriteUsingSocketTransport() throws Exception
{
ServiceRegistry reg = new SimpleServiceRegistry();
( ( SocketAcceptor ) reg.getAcceptor( TransportType.SOCKET ) ).setReuseAddress( true );
SocketAddress address = new InetSocketAddress( "localhost", AvailablePortFinder.getNextAvailable() );
Service service = new Service( "stream", TransportType.SOCKET, address );
SocketConnector connector = new SocketConnector();
connector.getFilterChain().addFirst( "threadPool", new ThreadPoolFilter() );
FixedRandomInputStream stream = new FixedRandomInputStream( 4 * 1024 * 1024 );
SenderHandler sender = new SenderHandler( stream );
ReceiverHandler receiver = new ReceiverHandler( stream.size );
reg.bind( service, sender );
synchronized( sender.lock )
{
synchronized( receiver.lock )
{
connector.connect( address, receiver );
sender.lock.wait();
receiver.lock.wait();
}
}
reg.unbindAll();
assertEquals( stream.bytesRead, receiver.bytesRead );
assertEquals( stream.size, receiver.bytesRead );
byte[] expectedMd5 = stream.digest.digest();
byte[] actualMd5 = receiver.digest.digest();