File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\test\src\main\java\org\jvnet\hudson\test\FakeLauncher.java.html

1 package org.jvnet.hudson.test;
2
3 import hudson.Launcher.ProcStarter;
4 import hudson.Proc;
5
6 import java.io.IOException;
7 import java.io.InputStream;
8 import java.io.OutputStream;
9
10 /**
11 * Fake a process launch.
12 *
13 * @author Kohsuke Kawaguchi
14 * @see PretendSlave
15 * @see MockFakeLauncher
16 */
17 public interface FakeLauncher {
18 /**
19 * Called whenever a {@link PretendSlave} is asked to fork a new process.
20 *
21 * <p>
22 * The callee can inspect the {@link ProcStarter} object to determine what process is being launched,
23 * and if necessary, fake a process launch by either returning a valid {@link Proc} object, or let
24 * the normal process launch happen by returning null.
25 */
26 Proc onLaunch(ProcStarter p) throws IOException;
27
28 /**
29 * Fake {@link Proc} implementation that represents a completed process.
30 */
31 class FinishedProc extends Proc {
32 public final int exitCode;
33
34 public FinishedProc(int exitCode) {
35 this.exitCode = exitCode;
36 }
37
38 @Override
39 public boolean isAlive() throws IOException, InterruptedException {
40 return false;
41 }
42
43 @Override
44 public void kill() throws IOException, InterruptedException {
45 throw new UnsupportedOperationException();
46 }
47
48 @Override
49 public int join() throws IOException, InterruptedException {
50 return exitCode;
51 }
52
53 @Override
54 public InputStream getStdout() {
55 // TODO
56 throw new UnsupportedOperationException();
57 }
58
59 @Override
60 public InputStream getStderr() {
61 // TODO
62 throw new UnsupportedOperationException();
63 }
64
65 @Override
66 public OutputStream getStdin() {
67 // TODO
68 throw new UnsupportedOperationException();
69 }
70 }
71 }
72