63d94f4d75164678091a476eae7dbad63a8c34a3
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.remote.core.tests / stubs / org / eclipse / tracecompass / internal / tmf / remote / core / stubs / shells / TestCommandShell.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2015 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
12 **********************************************************************/
13 package org.eclipse.tracecompass.internal.tmf.remote.core.stubs.shells;
14
15 import org.eclipse.core.commands.ExecutionException;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.tracecompass.internal.tmf.remote.core.shell.CommandInput;
19 import org.eclipse.tracecompass.internal.tmf.remote.core.shell.CommandResult;
20 import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandInput;
21 import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandOutputListener;
22 import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandResult;
23 import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandShell;
24
25 /**
26 * Command shell stub
27 */
28 public class TestCommandShell implements ICommandShell {
29
30 /** If the shell is connected */
31 protected boolean fIsConnected = false;
32
33 @Override
34 public void dispose() {
35 fIsConnected = false;
36 }
37
38 @Override
39 public ICommandResult executeCommand(ICommandInput command, IProgressMonitor monitor) throws ExecutionException {
40 return executeCommand(command, monitor, null);
41 }
42
43 @Override
44 public ICommandResult executeCommand(ICommandInput command, IProgressMonitor monitor, ICommandOutputListener listener) throws ExecutionException {
45 if (fIsConnected) {
46 return createCommandResult(0, new String[0], new String[0]);
47 }
48 return createCommandResult(1, new String[0], new String[0]);
49 }
50
51 @Override
52 public ICommandInput createCommand() {
53 return new CommandInput();
54 }
55
56 /**
57 * Creates a command result
58 *
59 * @param result
60 * The result of the command
61 * @param output
62 * The output, as an array of strings
63 * @param errorOutput
64 * THe error output as an array of strings
65 * @return {@link ICommandResult} instance
66 */
67 @NonNullByDefault
68 protected ICommandResult createCommandResult(int result, String[] output, String[] errorOutput) {
69 return new CommandResult(result, output, errorOutput);
70 }
71 }
This page took 0.04436 seconds and 4 git commands to generate.