use of org.webpieces.nio.api.channels.TCPChannel in project webpieces by deanhiller.
the class ZPerformanceSuper method profilerTestConnectCloseBatches.
/**
* Test used to test with netbeans profiler. Was seeing bizarre results where profiler
* claimed server selector thread was stuck on a monitor for 10 seconds but this is
* never shown in the snapshot, and is very bizarre. The most time spent in one
* of my methods if looked at the hotspot is from the main test thread, not the server
* selector thread which is bizarre as that thread showed no indication of being on a
* monitor.
*/
public void profilerTestConnectCloseBatches() throws Exception {
try {
log.info("test beginning");
int size = 10;
String[] methodNames = new String[size];
for (int i = 0; i < size; i++) {
methodNames[i] = "connected";
}
for (int j = 0; j < 10000; j++) {
TCPChannel[] clients = new TCPChannel[size];
for (int i = 0; i < size; i++) {
clients[i] = chanMgr.createTCPChannel("Client[" + i + "]", getClientFactoryHolder());
}
for (int i = 0; i < size; i++) {
clients[i].oldConnect(svrAddr, (ConnectionCallback) mockConnect);
}
mockConnect.expect(methodNames);
for (TCPChannel channel : clients) {
channel.oldClose();
}
}
} catch (Exception e) {
log.error("the exception", e);
} finally {
log.erroring("test ending*********************");
}
// long timePerConnect = result/size;
// log.info("time for initiating connects ="+result2);
// log.info("time for initiating/finishing connects="+result);
// log.info("connected per connection time ="+timePerConnect);
// log.info("--time to beat ="+getBasicConnectTimeLimit());
// assertTrue(timePerConnect < getBasicConnectTimeLimit());
}
use of org.webpieces.nio.api.channels.TCPChannel in project webpieces by deanhiller.
the class ZNioFailureSuperclass method testClientThrowsIntoConnectCallback.
public void testClientThrowsIntoConnectCallback() throws Exception {
setNumberOfExpectedWarnings(1);
log.info("hello");
//make sure we are testing the right one....
Class c = Class.forName(getChannelImplName());
assertEquals("should be instance of correct channel type", c, client1.getClass());
log.info("class name" + client1.getClass().getName());
String msg = "some exception message";
IOException e = new IOException(msg);
mockConnect.addThrowException("connected", e);
client1.bind(loopBackAnyPort);
client1.oldConnect(svrAddr, (ConnectionCallback) mockConnect);
client1.registerForReads((DataListener) mockHandler);
mockConnect.expect("connected");
TCPChannel svrChan = expectServerChannel(mockServer, c);
verifyDataPassing(svrChan);
verifyTearDown();
}
use of org.webpieces.nio.api.channels.TCPChannel in project webpieces by deanhiller.
the class ZNioFailureSuperclass method testClientThrowsIntoDataHandlerIncomingData.
public void testClientThrowsIntoDataHandlerIncomingData() throws Exception {
setNumberOfExpectedWarnings(1);
//make sure we are testing the right one....
Class c = Class.forName(getChannelImplName());
assertEquals("should be instance of correct channel type", c, client1.getClass());
mockHandler.addBehavior("incomingData", new ThrowAndClone());
log.info("class name" + client1.getClass());
client1.bind(loopBackAnyPort);
client1.oldConnect(svrAddr, (ConnectionCallback) mockConnect);
client1.registerForReads((DataListener) mockHandler);
mockConnect.expect("connected");
TCPChannel svrChan = expectServerChannel(mockServer, c);
verifyDataPassing(svrChan);
verifyTearDown();
}
use of org.webpieces.nio.api.channels.TCPChannel in project webpieces by deanhiller.
the class ZNioSuperclassTest method testCloseSvrSocketBeforeChannelMgrShutdown.
/**
* Test closing socket before ChannelManager shutdown works.
* @throws Exception
*/
public void testCloseSvrSocketBeforeChannelMgrShutdown() throws Exception {
Class c = Class.forName(getChannelImplName());
client1.bind(loopBackAnyPort);
client1.oldConnect(svrAddr);
boolean isConnected = client1.isConnected();
assertTrue("Client should be connected", isConnected);
TCPChannel svrChan = ZNioFailureSuperclass.expectServerChannel(mockServer, c);
client1.registerForReads((DataListener) mockHandler);
verifyDataPassing(svrChan);
svrChan.oldClose();
//shutdown channel manager first
mockServer.stop();
mockHandler.expect(MockNIOServer.FAR_END_CLOSED);
}
Aggregations