users@grizzly.java.net

[Q] Testing ProtocolFilter

From: Simon Trudeau <strudeau_at_bluetreewireless.com>
Date: Fri, 7 Mar 2008 10:40:47 -0500

I would like to know, how can I test my protocol filter. I would like to
simulate, using unit tests, a truncated message.

 

I try invoking the connectorHandler's send() method twice (part1 and
part2 of my message) with a Thread.sleep in between but the protocol
parsers doesn't think tokens are missing, it sees the two different
operations as two different message. Does this has something with TCP/IP
where the stack is configured to "know" the packet received has been
truncated or do I need to investigate my ProtocolFilter further. How
should I test this?

 

            client.connect(new
InetSocketAddress(InetAddress.getLocalHost(), serverPort));

            ByteBuffer outputByteBuffer1 = ByteBuffer.wrap(new
String("\r\nPA").getBytes());

            ByteBuffer outputByteBuffer2 = ByteBuffer.wrap(new
String("SS\r\n\0").getBytes());

            client.send(outputByteBuffer1);

            Thread.sleep(25);

            client.send(outputByteBuffer2);

 

Thanks

            

 

Simon