提交 06c30ce6 编写于 作者: K kohsuke

[HUDSON-3077]

Adding more probes to understand where the invalid data creeps in

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15446 71c3de6d-444a-0410-be80-ed276b4c234a
上级 607f8506
...@@ -24,26 +24,62 @@ ...@@ -24,26 +24,62 @@
package hudson; package hudson;
import junit.framework.TestCase; import junit.framework.TestCase;
import hudson.remoting.Channel;
import hudson.util.NullStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
/** /**
* @author Kohsuke Kawaguchi * @author Kohsuke Kawaguchi
*/ */
public class FilePathTest extends /*RmiTestBase*/ TestCase { public class FilePathTest extends TestCase {
public void testDummy() { /**
// TODO: figure out how to reuse test code from the remoting module. * Two channels that are connected to each other, but shares the same classloader.
// currently it fails because the remoting.jar is signed but */
// test code is not. private Channel french, british;
private ExecutorService executors = Executors.newCachedThreadPool();
@Override
protected void setUp() throws Exception {
super.setUp();
final PipedInputStream p1i = new PipedInputStream();
final PipedInputStream p2i = new PipedInputStream();
final PipedOutputStream p1o = new PipedOutputStream(p1i);
final PipedOutputStream p2o = new PipedOutputStream(p2i);
Future<Channel> f1 = executors.submit(new Callable<Channel>() {
public Channel call() throws Exception {
return new Channel("This side of the channel", executors, p1i, p2o);
}
});
Future<Channel> f2 = executors.submit(new Callable<Channel>() {
public Channel call() throws Exception {
return new Channel("The other side of the channel", executors, p2i, p1o);
}
});
french = f1.get();
british = f2.get();
}
@Override
protected void tearDown() throws Exception {
french.close();
british.close();
french.join();
british.join();
executors.shutdown();
}
public void testCopyTo() throws Exception {
File tmp = File.createTempFile("tmp","");
FilePath f = new FilePath(french,tmp.getPath());
f.copyTo(new NullStream());
} }
///**
// * Copy zero files.
// */
//public void testEmptyCopy() throws Exception {
// File src = Util.createTempDir();
// File dst = Util.createTempDir();
// src.deleteOnExit();
// dst.deleteOnExit();
//
// new FilePath(src).copyRecursiveTo("**/*",new FilePath(channel,dst.getPath()));
//}
} }
...@@ -71,6 +71,8 @@ final class ProxyOutputStream extends OutputStream { ...@@ -71,6 +71,8 @@ final class ProxyOutputStream extends OutputStream {
synchronized void connect(Channel channel, int oid) throws IOException { synchronized void connect(Channel channel, int oid) throws IOException {
if(this.channel!=null) if(this.channel!=null)
throw new IllegalStateException("Cannot connect twice"); throw new IllegalStateException("Cannot connect twice");
if(oid==0)
throw new IllegalArgumentException("oid=0");
this.channel = channel; this.channel = channel;
this.oid = oid; this.oid = oid;
......
...@@ -73,6 +73,8 @@ public final class RemoteOutputStream extends OutputStream implements Serializab ...@@ -73,6 +73,8 @@ public final class RemoteOutputStream extends OutputStream implements Serializab
private transient OutputStream core; private transient OutputStream core;
public RemoteOutputStream(OutputStream core) { public RemoteOutputStream(OutputStream core) {
if(core==null)
throw new IllegalArgumentException();
this.core = core; this.core = core;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册