File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\test\java\hudson\util\ProcessTreeTest.java.html

1 package hudson.util;
2
3 import hudson.ChannelTestCase;
4 import hudson.remoting.Callable;
5 import hudson.remoting.VirtualChannel;
6 import hudson.util.ProcessTree.OSProcess;
7 import hudson.util.ProcessTree.ProcessCallable;
8
9 import java.io.IOException;
10 import java.io.Serializable;
11
12 /**
13 * @author Kohsuke Kawaguchi
14 */
15 public class ProcessTreeTest extends ChannelTestCase {
16 static class Tag implements Serializable {
17 ProcessTree tree;
18 OSProcess p;
19 int id;
20 private static final long serialVersionUID = 1L;
21 }
22
23 public void testRemoting() throws Exception {
24 Tag t = french.call(new MyCallable());
25
26 // make sure the serialization preserved the reference graph
27 assertSame(t.p.getTree(), t.tree);
28
29 // verify that some remote call works
30 t.p.getEnvironmentVariables();
31
32 // it should point to the same object
33 assertEquals(t.id,t.p.getPid());
34
35 t.p.act(new ProcessCallableImpl());
36 }
37
38 private static class MyCallable implements Callable<Tag, IOException>, Serializable {
39 public Tag call() throws IOException {
40 Tag t = new Tag();
41 t.tree = ProcessTree.get();
42 t.p = t.tree.iterator().next();
43 t.id = t.p.getPid();
44 return t;
45 }
46
47 private static final long serialVersionUID = 1L;
48 }
49
50 private static class ProcessCallableImpl implements ProcessCallable<Void> {
51 public Void invoke(OSProcess process, VirtualChannel channel) throws IOException {
52 assertNotNull(process);
53 assertNotNull(channel);
54 return null;
55 }
56 }
57 }
58