提交 9ce28281 编写于 作者: K kohsuke

added a test in an attempt to reproduce / pin-point HUDSON-7809 but this was not it.



git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@37070 71c3de6d-444a-0410-be80-ed276b4c234a
上级 92a2c48f
......@@ -25,12 +25,15 @@ package hudson.remoting;
import hudson.remoting.ChannelRunner.InProcessCompatibilityMode;
import junit.framework.Test;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.NullOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Arrays;
/**
......@@ -38,7 +41,7 @@ import java.util.Arrays;
*
* @author Kohsuke Kawaguchi
*/
public class PipeTest extends RmiTestBase {
public class PipeTest extends RmiTestBase implements Serializable {
/**
* Test the "remote-write local-read" pipe.
*/
......@@ -205,6 +208,28 @@ public class PipeTest extends RmiTestBase {
f.close();
}
/**
* Writer end closes even before the remote computation kicks in.
*/
public void testQuickBurstWrite() throws Exception {
final Pipe p = Pipe.createLocalToRemote();
Future<Integer> f = channel.callAsync(new Callable<Integer, IOException>() {
public Integer call() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
IOUtils.copy(p.getIn(), baos);
return baos.size();
}
});
OutputStream os = p.getOut();
os.write(1);
os.close();
// at this point the async executable kicks in.
// TODO: introduce a lock to ensure the ordering.
assertEquals(1,(int)f.get());
}
private static class DevNullSink implements Callable<OutputStream, IOException> {
public OutputStream call() throws IOException {
return new RemoteOutputStream(new NullOutputStream());
......@@ -215,4 +240,8 @@ public class PipeTest extends RmiTestBase {
public static Test suite() throws Exception {
return buildSuite(PipeTest.class);
}
private Object writeReplace() {
return null;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册