Attempting to get timeouts working
This commit is contained in:
parent
c8821605fe
commit
d3b599d67c
|
@ -44,6 +44,8 @@ public class WebSocketServletRFCTest
|
|||
public void registerWebSockets(WebSocketServerFactory factory)
|
||||
{
|
||||
factory.register(RFCSocket.class);
|
||||
|
||||
factory.getPolicy().setMaxIdleTime(800);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,22 +231,25 @@ public class WebSocketServletRFCTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Idle Timeouts not working (yet)")
|
||||
@Ignore("Still not working")
|
||||
public void testIdle() throws Exception
|
||||
{
|
||||
BlockheadClient client = new BlockheadClient(server.getServerUri());
|
||||
client.setProtocols("onConnect");
|
||||
client.setTimeout(TimeUnit.MILLISECONDS,800);
|
||||
try
|
||||
{
|
||||
client.connect();
|
||||
client.sendStandardRequest();
|
||||
client.expectUpgradeResponse();
|
||||
|
||||
client.sleep(TimeUnit.SECONDS,1);
|
||||
|
||||
client.write(WebSocketFrame.text("Hello"));
|
||||
|
||||
// now wait for the server to time out
|
||||
// should be 2 frames, the TextFrame echo, and then the Close on disconnect
|
||||
Queue<WebSocketFrame> frames = client.readFrames(2,TimeUnit.SECONDS,5);
|
||||
Queue<WebSocketFrame> frames = client.readFrames(2,TimeUnit.SECONDS,2);
|
||||
Assert.assertThat("frames[0].opcode",frames.remove().getOpCode(),is(OpCode.TEXT));
|
||||
Assert.assertThat("frames[1].opcode",frames.remove().getOpCode(),is(OpCode.CLOSE));
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ public class BlockheadClient implements Parser.Listener
|
|||
int startCount = incomingFrameQueue.size();
|
||||
|
||||
ByteBuffer buf = bufferPool.acquire(policy.getBufferSize(),false);
|
||||
BufferUtil.clearToFill(buf);
|
||||
BufferUtil.clear(buf);
|
||||
try
|
||||
{
|
||||
long now = System.currentTimeMillis();
|
||||
|
@ -351,6 +351,13 @@ public class BlockheadClient implements Parser.Listener
|
|||
}
|
||||
}
|
||||
|
||||
public void sleep(TimeUnit unit, int duration) throws InterruptedException
|
||||
{
|
||||
LOG.info("Sleeping for {} {}",duration,unit);
|
||||
unit.sleep(duration);
|
||||
LOG.info("Waking up from sleep");
|
||||
}
|
||||
|
||||
public void write(WebSocketFrame frame) throws IOException
|
||||
{
|
||||
LOG.debug("write(Frame->{})",frame);
|
||||
|
|
Loading…
Reference in New Issue