Author: mturk
Date: Thu Aug 11 15:37:21 2011
New Revision: 1156655
URL: http://svn.apache.org/viewvc?rev=1156655&view=rev
Log:
Move sendfile test to the inet socket
Modified:
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestLocalEndpoint.java
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestServerEndpoint.java
Modified:
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestLocalEndpoint.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestLocalEndpoint.java?rev=1156655&r1=1156654&r2=1156655&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestLocalEndpoint.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestLocalEndpoint.java
Thu Aug 11 15:37:21 2011
@@ -17,8 +17,6 @@
package org.apache.commons.runtime.net;
import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import org.apache.commons.runtime.io.Stream;
@@ -149,23 +147,13 @@ public class TestLocalEndpoint extends A
LocalEndpoint cs = new LocalEndpoint();
cs.connect(sa);
assertTrue(cs.isBlocking());
- File sendf = new File("acrsendfile.tmp");
- sendf.deleteOnExit();
- FileOutputStream fs = new FileOutputStream(sendf);
- byte[] b = new byte[1000];
- for (int i = 0; i < 500; i++)
- fs.write(b);
- fs.close();
+ Stream s = cs.getStream();
+ s.write(' ');
try {
- Sendfile sf = new Sendfile(sendf);
- cs.configureBlocking(false);
- int send = sf.send(cs);
- assertTrue(send > 0);
- assertEquals(sf.length() - send, sf.remaining());
- cs.configureBlocking(true);
- System.out.println("Send " + send + " bytes.");
- } catch (Exception se) {
- System.out.println("Error sending file " + se);
+ // Sleep for a while till the connection is handled
+ Thread.sleep(200);
+ } catch (InterruptedException x) {
+ // Ignore
}
cs.close();
ps.interrupt();
Modified:
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestServerEndpoint.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestServerEndpoint.java?rev=1156655&r1=1156654&r2=1156655&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestServerEndpoint.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestServerEndpoint.java
Thu Aug 11 15:37:21 2011
@@ -17,12 +17,14 @@
package org.apache.commons.runtime.net;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import org.testng.annotations.*;
import org.testng.Assert;
import org.apache.commons.runtime.io.Descriptor;
+import org.apache.commons.runtime.io.Stream;
public class TestServerEndpoint extends Assert
{
@@ -73,6 +75,10 @@ public class TestServerEndpoint extends
// Another select with zero timeout
set = ps.select(0);
assertEquals(set.size(), 0);
+ e.configureBlocking(true);
+ Stream s = e.getStream();
+ s.read();
+
} catch (Exception x) {
fail("Accept failed " + x.toString());
break;
@@ -130,6 +136,24 @@ public class TestServerEndpoint extends
SocketEndpoint cs = new SocketEndpoint();
cs.connect(ss.getLocalAddress());
assertTrue(cs.isBlocking());
+ File sendf = new File("acrsendfile.tmp");
+ sendf.deleteOnExit();
+ FileOutputStream fs = new FileOutputStream(sendf);
+ byte[] b = new byte[1000];
+ for (int i = 0; i < 500; i++)
+ fs.write(b);
+ fs.close();
+ try {
+ Sendfile sf = new Sendfile(sendf);
+ cs.configureBlocking(false);
+ int send = sf.send(cs);
+ assertTrue(send > 0);
+ assertEquals(sf.length() - send, sf.remaining());
+ cs.configureBlocking(true);
+ System.out.println("Send " + send + " bytes.");
+ } catch (Exception se) {
+ System.out.println("Error sending file " + se);
+ }
cs.close();
ps.interrupt();
try {