Author: trustin
Date: Sat Oct 30 20:40:08 2004
New Revision: 56115
Modified:
incubator/directory/seda/trunk/src/test/org/apache/seda/ProtocolTestCase.java
incubator/directory/seda/trunk/src/test/org/apache/seda/examples/DiscardProtocolProviderTest.java
Log:
Created a simple discart tcp procotol test.
Modified:
incubator/directory/seda/trunk/src/test/org/apache/seda/ProtocolTestCase.java
==============================================================================
---
incubator/directory/seda/trunk/src/test/org/apache/seda/ProtocolTestCase.java
(original)
+++
incubator/directory/seda/trunk/src/test/org/apache/seda/ProtocolTestCase.java
Sat Oct 30 20:40:08 2004
@@ -47,6 +47,9 @@
/** the listener configuration for the protocol */
protected ListenerConfig config = null;
+ /** the server port number for the test protocol */
+ protected int port;
+
public ProtocolTestCase(ProtocolProvider proto)
{
this.proto = proto;
@@ -75,10 +78,10 @@
super.setUp();
fe = (DefaultFrontend) new DefaultFrontendFactory().create();
+ this.port = AvailablePortFinder.getNextAvailable(6666);
+
InetServiceEntry srvEntry =
- new InetServiceEntry(
- proto.getName(),
- AvailablePortFinder.getNextAvailable(6666));
+ new InetServiceEntry(proto.getName(), port);
((DefaultInetServicesDatabase)
fe.getInetServicesDatabase()).addEntry(srvEntry);
config = new TCPListenerConfig(InetAddress.getLocalHost(), srvEntry);
fe.getListenerManager().bind(config);
Modified:
incubator/directory/seda/trunk/src/test/org/apache/seda/examples/DiscardProtocolProviderTest.java
==============================================================================
---
incubator/directory/seda/trunk/src/test/org/apache/seda/examples/DiscardProtocolProviderTest.java
(original)
+++
incubator/directory/seda/trunk/src/test/org/apache/seda/examples/DiscardProtocolProviderTest.java
Sat Oct 30 20:40:08 2004
@@ -37,8 +37,21 @@
super(new DiscardProtocolProvider());
}
- public void testDiscardProtocol()
+ public void testDiscardProtocol() throws Exception
{
DiscardTCPClient client = new DiscardTCPClient();
+ client.connect(InetAddress.getLocalHost(), port);
+
+ byte[] data = new byte[512];
+ byte value= (byte) 0;
+ for (int i = 0; i < 10; i++) {
+ for (int j = data.length-1; j >= 0; j--) {
+ data[j] = (byte) j;
+ }
+
+ client.getOutputStream().write(data);
+ }
+
+ client.disconnect();
}
}