Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java')
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java
index 0c5667235..bac6a22d0 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java
@@ -18,9 +18,9 @@ import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
+import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationType;
@@ -66,6 +66,9 @@ public class MockProcess extends Process {
/** The simulated exit code. */
private int exitCode = 0;
+ /** The child/sub mock-processes of this mock-process. */
+ private Optional<MockProcessHandle> handle = Optional.of(new MockProcessHandle(this));
+
/**
* Create new silent mockup process which runs for a given amount of time.
* Does not read input or produce any output.
@@ -166,6 +169,15 @@ public class MockProcess extends Process {
}
@Override
+ public ProcessHandle toHandle() {
+ if (handle.isPresent()) {
+ return handle.get();
+ }
+ // let super implementation throw the UnsupportedOperationException
+ return super.toHandle();
+ }
+
+ @Override
public int waitFor() throws InterruptedException {
synchronized (waitForTerminationLock) {
while (!isTerminated()) {
@@ -245,6 +257,16 @@ public class MockProcess extends Process {
}
/**
+ * Set the {@link ProcessHandle} of the process. A null value indices that
+ * this process does not support {@link Process#toHandle()}.
+ *
+ * @param handle new process handle
+ */
+ public void setHandle(MockProcessHandle handle) {
+ this.handle = Optional.ofNullable(handle);
+ }
+
+ /**
* Create a {@link RuntimeProcess} which wraps this {@link MockProcess}.
* <p>
* Note: the process will only be connected to a minimal dummy launch

Back to the top