runCheck(port,localhost,0);
}
private void runCheck(int port, boolean localhost, long batchOutgoingMessagesDelayMillis) throws Throwable
{
final StatsCollector statsCollector = new StatsCollectorFactoryCoda().createStatsCollector(new ClusterId("test", "test-cluster"), new Destination(){});
SenderFactory factory = null;
TcpReceiver adaptor = null;
try
{
//===========================================
// setup the sender and receiver
adaptor = new TcpReceiver(null,getFailFast());
adaptor.setStatsCollector(statsCollector);
// we want to keep track of the number of bytes written
factory = makeSenderFactory(new OutputStreamFactory() {
@Override
public OutputStream makeOutputStream(final OutputStream socketOutputStream, final Socket socket) throws IOException
{
return new OutputStream()
{
@Override
public void write(int b) { }
public void write(byte b[], int off, int len) throws IOException { throw new IOException("Fake IOException"); }
};
}
}, statsCollector,batchOutgoingMessagesDelayMillis);
if (port > 0) adaptor.setPort(port);
if (localhost) adaptor.setUseLocalhost(localhost);
//===========================================
adaptor.start(); // start the adaptor
Destination destination = adaptor.getDestination(); // get the destination
// send a message
TcpSender sender = (TcpSender)factory.getSender(destination);
BlockingQueue<byte[]> internalQueue = sender.sendingQueue;