directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: rev 56127 - in incubator/directory/seda/trunk/src/test/org/apache/seda: . decoder event examples
Date Sun, 31 Oct 2004 07:42:15 GMT
Author: trustin
Date: Sun Oct 31 00:42:14 2004
New Revision: 56127

Modified:
   incubator/directory/seda/trunk/src/test/org/apache/seda/ProtocolTestCase.java
   incubator/directory/seda/trunk/src/test/org/apache/seda/decoder/DefaultDecoderManagerTest.java
   incubator/directory/seda/trunk/src/test/org/apache/seda/event/DefaultStageTest.java
   incubator/directory/seda/trunk/src/test/org/apache/seda/examples/EchoProtocolProviderTest.java
Log:
More accurate test case for echo protocol

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	Sun Oct
31 00:42:14 2004
@@ -18,14 +18,10 @@
 package org.apache.seda;
 
 import java.net.InetAddress;
-import java.nio.ByteBuffer;
 
 import junit.framework.TestCase;
 
-import org.apache.seda.input.InputManagerMonitorAdapter;
-import org.apache.seda.input.TCPInputManager;
 import org.apache.seda.listener.AvailablePortFinder;
-import org.apache.seda.listener.ClientKey;
 import org.apache.seda.listener.ListenerConfig;
 import org.apache.seda.listener.TCPListenerConfig;
 import org.apache.seda.protocol.DefaultInetServicesDatabase;
@@ -90,13 +86,7 @@
         config = new TCPListenerConfig(InetAddress.getLocalHost(), srvEntry);
         fe.getListenerManager().bind(config);
         fe.register(proto);
-        
-        ((TCPInputManager) fe.getInputManager()).setMonitor(new InputManagerMonitorAdapter()
{
-            public void inputRecieved(ByteBuffer buffer, ClientKey key)
-            {
-            	System.out.println("READ");
-            }
-        });
+
     }
     
     public static void assertEquals(byte[] expected, byte[] actual) {

Modified: incubator/directory/seda/trunk/src/test/org/apache/seda/decoder/DefaultDecoderManagerTest.java
==============================================================================
--- incubator/directory/seda/trunk/src/test/org/apache/seda/decoder/DefaultDecoderManagerTest.java
(original)
+++ incubator/directory/seda/trunk/src/test/org/apache/seda/decoder/DefaultDecoderManagerTest.java
Sun Oct 31 00:42:14 2004
@@ -85,7 +85,7 @@
                     /* (non-Javadoc)
                      * @see org.apache.seda.thread.ThreadPool#execute(java.lang.Runnable)
                      */
-                    public void execute(Runnable runnable)
+                    public void execute(Runnable runnable, Object hint)
                     {
                         // fake it out
                         runnable.run();
@@ -94,8 +94,7 @@
 
         config = new DefaultStageConfig("default", tpool);
         decodeMan =
-            new DefaultDecoderManager(
-                                      router, config,
+            new DefaultDecoderManager(router, config,
                                       new InetServicesDatabase()
                 {
                     public Iterator getByName(String name)
@@ -113,14 +112,12 @@
                         return null;
                     }
 
-                    public InetServiceEntry getByName(
-                                                      String name, String proto)
+                    public InetServiceEntry getByName(String name, String proto)
                     {
                         return null;
                     }
 
-                    public InetServiceEntry getByPort(
-                                                      String port, String proto)
+                    public InetServiceEntry getByPort(String port, String proto)
                     {
                         return null;
                     }

Modified: incubator/directory/seda/trunk/src/test/org/apache/seda/event/DefaultStageTest.java
==============================================================================
--- incubator/directory/seda/trunk/src/test/org/apache/seda/event/DefaultStageTest.java	(original)
+++ incubator/directory/seda/trunk/src/test/org/apache/seda/event/DefaultStageTest.java	Sun
Oct 31 00:42:14 2004
@@ -69,7 +69,7 @@
                     /* (non-Javadoc)
                      * @see org.apache.seda.thread.ThreadPool#execute(java.lang.Runnable)
                      */
-                    public void execute(Runnable runnable)
+                    public void execute(Runnable runnable, Object hint)
                     {
                         runnable.run();
                     }
@@ -89,7 +89,7 @@
         config = new DefaultStageConfig("test", pool);
         config.setHandler(handler);
         stage = new DefaultStage(config);
-        stage.setMonitor(new LoggingStageMonitor(stage.getClass()));
+        stage.setStageMonitor(new LoggingStageMonitor(stage.getClass()));
         stage.start();
     }
 

Modified: incubator/directory/seda/trunk/src/test/org/apache/seda/examples/EchoProtocolProviderTest.java
==============================================================================
--- incubator/directory/seda/trunk/src/test/org/apache/seda/examples/EchoProtocolProviderTest.java
(original)
+++ incubator/directory/seda/trunk/src/test/org/apache/seda/examples/EchoProtocolProviderTest.java
Sun Oct 31 00:42:14 2004
@@ -43,18 +43,22 @@
         EchoTCPClient client = new EchoTCPClient();
         client.connect(InetAddress.getLocalHost(), port);
         
-        byte[] writeBuf = new byte[512];
-        byte[] readBuf = new byte[writeBuf.length];
-        byte value= (byte) 0;
+        byte[] writeBuf = new byte[16];
         for (int i = 0; i < 10; i++) {
         	for (int j = writeBuf.length-1; j >= 0; j--) {
-        		writeBuf[j] = (byte) j;
+        		writeBuf[j] = (byte) (j + i);
         	}
         	
-            client.setSoTimeout(3000);
     		client.getOutputStream().write(writeBuf);
-    		
-    		int readBytes = 0;
+        }
+        
+    	byte[] readBuf = new byte[writeBuf.length];
+        for (int i = 0; i < 10; i++) {
+        	for (int j = writeBuf.length-1; j >= 0; j--) {
+        		writeBuf[j] = (byte) (j + i);
+        	}
+
+        	int readBytes = 0;
     		while (readBytes < readBuf.length) {
         		int nBytes = client.getInputStream().read(readBuf, readBytes, readBuf.length -
readBytes);
         		if (nBytes < 0)
@@ -64,14 +68,15 @@
     		
     		assertEquals(writeBuf, readBuf);
     		
-			client.setSoTimeout(100);
-    		try {
-    			client.getInputStream().read();
-    			fail("Unexpected incoming data.");
-    		} catch (SocketTimeoutException e) {
-    		}
         }
         
-        client.disconnect();
+		client.setSoTimeout(100);
+		try {
+			client.getInputStream().read();
+			fail("Unexpected incoming data.");
+		} catch (SocketTimeoutException e) {
+		}
+
+		client.disconnect();
     }
 }

Mime
View raw message