1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 01:05:38 +02:00

Test suit for remote support.

Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
Greg Watson 2013-08-21 21:21:40 -04:00
parent c3bf5ecaa5
commit 3cb6c62acb
11 changed files with 657 additions and 6 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.remote.core.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,73 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=warning
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.5

View file

@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.remote.core.tests;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: %pluginProvider
Require-Bundle: org.eclipse.core.runtime,
org.junit,
com.jcraft.jsch;bundle-version="0.1.41",
org.eclipse.core.filesystem;bundle-version="1.2.0",
org.eclipse.remote.core;bundle-version="1.0.0",
org.eclipse.remote.ui;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -0,0 +1,13 @@
###############################################################################
# Copyright (c) 2009 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
pluginName=Remote Core Tests
pluginProvider=Eclipse PTP

View file

@ -0,0 +1,202 @@
package org.eclipse.remote.core.tests;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import junit.framework.TestCase;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.filesystem.IFileSystem;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnectionManager;
import org.eclipse.remote.core.IRemoteFileManager;
import org.eclipse.remote.core.IRemoteProcess;
import org.eclipse.remote.core.IRemoteProcessBuilder;
import org.eclipse.remote.core.IRemoteServices;
import org.eclipse.remote.core.RemoteServices;
import org.eclipse.remote.core.exception.RemoteConnectionException;
public class ConnectionTests extends TestCase {
private static final String USERNAME = "user"; //$NON-NLS-1$
private static final String PASSWORD = "password"; //$NON-NLS-1$
private static final String HOST = "localhost"; //$NON-NLS-1$
private IRemoteServices fRemoteServices;
private IRemoteConnection fRemoteConnection;
public void testEnv() {
String var = fRemoteConnection.getEnv("SHELL"); //$NON-NLS-1$
assertNotNull(var);
var = fRemoteConnection.getEnv("FOO_VAR_SHOULD_NOT_BE_DEFINED"); //$NON-NLS-1$
assertNull(var);
assertNotNull(fRemoteConnection.getProperty("os.name")); //$NON-NLS-1$
assertNotNull(fRemoteConnection.getProperty("os.arch")); //$NON-NLS-1$
assertNotNull(fRemoteConnection.getProperty("os.version")); //$NON-NLS-1$
assertNotNull(fRemoteConnection.getProperty("file.separator")); //$NON-NLS-1$
assertNotNull(fRemoteConnection.getProperty("path.separator")); //$NON-NLS-1$
assertNotNull(fRemoteConnection.getProperty("line.separator")); //$NON-NLS-1$
IRemoteProcessBuilder builder = fRemoteServices.getProcessBuilder(fRemoteConnection, "env"); //$NON-NLS-1$
builder.environment().put("FOO", "BAR"); //$NON-NLS-1$ //$NON-NLS-2$
builder.environment().put("USER", "FOO"); //$NON-NLS-1$ //$NON-NLS-2$
try {
IRemoteProcess proc = builder.start();
BufferedReader stdout = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line;
while ((line = stdout.readLine()) != null) {
String[] kv = line.trim().split("="); //$NON-NLS-1$
if (kv.length == 2) {
if (kv[0].equals("FOO")) {
assertTrue(kv[1].equals("BAR")); //$NON-NLS-1$ //$NON-NLS-2$
}
if (kv[0].equals("USER")) {
assertTrue(kv[1].equals("FOO")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
} catch (IOException e) {
fail(e.getMessage());
}
}
public void testCopy() {
final IRemoteFileManager fileManager = fRemoteServices.getFileManager(fRemoteConnection);
final IFileSystem fileSystem = EFS.getLocalFileSystem();
final IFileStore srcFileStore = fileSystem.getStore(new Path("/tmp/log_src.txt"));
final IFileStore dstFileStore = fileManager.getResource("/tmp").getChild("log_dst.txt");
try {
srcFileStore.delete(EFS.NONE, new NullProgressMonitor());
dstFileStore.delete(EFS.NONE, new NullProgressMonitor());
OutputStream stream = srcFileStore.openOutputStream(EFS.NONE, new NullProgressMonitor());
stream.write(new byte[] { 'f', 'o', 'o', '\n' });
stream.close();
srcFileStore.copy(dstFileStore, EFS.NONE, new NullProgressMonitor());
} catch (CoreException e) {
fail(e.getMessage());
} catch (IOException e) {
fail(e.getMessage());
}
IFileInfo srcInfo = srcFileStore.fetchInfo();
IFileInfo dstInfo = dstFileStore.fetchInfo();
assertTrue(dstInfo.exists());
assertTrue(srcInfo.getLength() == dstInfo.getLength());
try {
InputStream stream = dstFileStore.openInputStream(EFS.NONE, new NullProgressMonitor());
byte[] b = new byte[4];
stream.read(b);
stream.close();
assertTrue(b[0] == 'f');
assertTrue(b[1] == 'o');
assertTrue(b[2] == 'o');
assertTrue(b[3] == '\n');
} catch (CoreException e) {
fail(e.getMessage());
} catch (IOException e) {
fail(e.getMessage());
}
try {
srcFileStore.delete(EFS.NONE, new NullProgressMonitor());
dstFileStore.delete(EFS.NONE, new NullProgressMonitor());
} catch (CoreException e) {
fail(e.getMessage());
}
}
public void testWd() {
/*
* Test connection wd
*/
String oldWd = fRemoteConnection.getWorkingDirectory();
assertTrue(oldWd.startsWith("/"));
String newWd = "/tmp";
fRemoteConnection.setWorkingDirectory(newWd);
assertTrue(fRemoteConnection.getWorkingDirectory().equals(newWd));
/*
* Test process builder inherits wd from connection
*/
IRemoteProcessBuilder builder = fRemoteServices.getProcessBuilder(fRemoteConnection, "pwd"); //$NON-NLS-1$
try {
IRemoteProcess proc = builder.start();
BufferedReader stdout = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line = stdout.readLine();
proc.destroy();
assertTrue(line != null && line.equals(newWd));
} catch (IOException e) {
fail(e.getMessage());
}
/*
* Test process builder wd
*/
final IRemoteFileManager fileManager = fRemoteServices.getFileManager(fRemoteConnection);
builder = fRemoteServices.getProcessBuilder(fRemoteConnection, "pwd"); //$NON-NLS-1$
builder.directory(fileManager.getResource("/bin"));
try {
IRemoteProcess proc = builder.start();
BufferedReader stdout = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line = stdout.readLine();
proc.destroy();
assertTrue(line != null && line.equals("/bin"));
} catch (IOException e) {
fail(e.getMessage());
}
}
/*
* (non-Javadoc)
*
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
fRemoteServices = RemoteServices.getRemoteServices("org.eclipse.remote.JSch"); //$NON-NLS-1$
assertNotNull(fRemoteServices);
IRemoteConnectionManager connMgr = fRemoteServices.getConnectionManager();
assertNotNull(connMgr);
try {
fRemoteConnection = connMgr.newConnection("test_connection"); //$NON-NLS-1$
} catch (RemoteConnectionException e) {
fail(e.getMessage());
}
assertNotNull(fRemoteConnection);
fRemoteConnection.setAddress(HOST);
fRemoteConnection.setUsername(USERNAME);
fRemoteConnection.setPassword(PASSWORD);
try {
fRemoteConnection.open(new NullProgressMonitor());
} catch (RemoteConnectionException e) {
fail(e.getMessage());
}
assertTrue(fRemoteConnection.isOpen());
}
/*
* (non-Javadoc)
*
* @see junit.framework.TestCase#tearDown()
*/
@Override
protected void tearDown() throws Exception {
fRemoteConnection.close();
IRemoteConnectionManager connMgr = fRemoteServices.getConnectionManager();
assertNotNull(connMgr);
connMgr.removeConnection(fRemoteConnection);
}
}

View file

@ -0,0 +1,141 @@
package org.eclipse.remote.core.tests;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.URI;
import junit.framework.TestCase;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnectionManager;
import org.eclipse.remote.core.IRemoteFileManager;
import org.eclipse.remote.core.IRemoteServices;
import org.eclipse.remote.core.RemoteServices;
import org.eclipse.remote.core.exception.RemoteConnectionException;
public class FileStoreTests extends TestCase {
private static final String CONNECTION_NAME = "test_connection";
private static final String USERNAME = "user";
private static final String PASSWORD = "password";
private static final String HOST = "localhost";
private static final String PATH1 = "/home/user/sftp_test";
private static final String PATH2 = PATH1 + "/.file1";
private static final String TEST_STRING = "a string containing fairly *()(*&^$%## random text";
private IRemoteServices fRemoteServices;
private IRemoteConnection fRemoteConnection;
private IRemoteFileManager fRemoteFileManager;
public void testFileStore() {
URI path1Uri = fRemoteFileManager.toURI(PATH1);
URI path2Uri = fRemoteFileManager.toURI(PATH2);
assertNotNull(path1Uri);
assertNotNull(path2Uri);
IFileStore store1 = null;
IFileStore store2 = null;
try {
store1 = EFS.getStore(path1Uri);
store2 = EFS.getStore(path2Uri);
} catch (Exception e) {
fail(e.getLocalizedMessage());
}
for (int i = 0; i < 5; i++) {
assertFalse(store1.fetchInfo().exists());
try {
store1.mkdir(EFS.NONE, null);
} catch (CoreException e) {
e.getLocalizedMessage();
}
assertTrue(store1.fetchInfo().exists());
assertFalse(store2.fetchInfo().exists());
try {
OutputStream stream = store2.openOutputStream(EFS.NONE, null);
assertNotNull(stream);
BufferedWriter buf = new BufferedWriter(new OutputStreamWriter(stream));
buf.write(TEST_STRING);
buf.close();
} catch (Exception e) {
e.getLocalizedMessage();
}
assertTrue(store2.fetchInfo().exists());
try {
InputStream stream = store2.openInputStream(EFS.NONE, null);
assertNotNull(stream);
BufferedReader buf = new BufferedReader(new InputStreamReader(stream));
String line = buf.readLine().trim();
assertTrue(line.equals(TEST_STRING));
buf.close();
} catch (Exception e) {
e.getLocalizedMessage();
}
try {
store2.delete(EFS.NONE, null);
} catch (CoreException e) {
e.getLocalizedMessage();
}
assertFalse(store2.fetchInfo().exists());
try {
store1.delete(EFS.NONE, null);
} catch (CoreException e) {
e.getLocalizedMessage();
}
assertFalse(store1.fetchInfo().exists());
}
}
/*
* (non-Javadoc)
*
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
fRemoteServices = RemoteServices.getRemoteServices("org.eclipse.remote.JSch");
assertNotNull(fRemoteServices);
IRemoteConnectionManager connMgr = fRemoteServices.getConnectionManager();
assertNotNull(connMgr);
try {
fRemoteConnection = connMgr.newConnection(CONNECTION_NAME);
} catch (RemoteConnectionException e) {
fail(e.getLocalizedMessage());
}
assertNotNull(fRemoteConnection);
fRemoteConnection.setAddress(HOST);
fRemoteConnection.setUsername(USERNAME);
fRemoteConnection.setPassword(PASSWORD);
fRemoteFileManager = fRemoteServices.getFileManager(fRemoteConnection);
assertNotNull(fRemoteFileManager);
}
/*
* (non-Javadoc)
*
* @see junit.framework.TestCase#tearDown()
*/
@Override
protected void tearDown() throws Exception {
fRemoteConnection.close();
IRemoteConnectionManager connMgr = fRemoteServices.getConnectionManager();
assertNotNull(connMgr);
connMgr.removeConnection(fRemoteConnection);
}
}

View file

@ -0,0 +1,139 @@
package org.eclipse.remote.core.tests;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import junit.framework.TestCase;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnectionManager;
import org.eclipse.remote.core.IRemoteProcess;
import org.eclipse.remote.core.IRemoteProcessBuilder;
import org.eclipse.remote.core.IRemoteServices;
import org.eclipse.remote.core.RemoteServices;
import org.eclipse.remote.core.exception.RemoteConnectionException;
public class ProcessTests extends TestCase {
private static final String USERNAME = "user"; //$NON-NLS-1$
private static final String PASSWORD = "password"; //$NON-NLS-1$
private static final String HOST = "localhost"; //$NON-NLS-1$
private static int NUM_THREADS = 5;
private IRemoteServices fRemoteServices;
private IRemoteConnection fRemoteConnection;
public void testConcurrentProcess() {
Thread[] threads = new Thread[NUM_THREADS];
final Set<String> results = Collections.synchronizedSet(new HashSet<String>());
for (int t = 0; t < NUM_THREADS; t++) {
Thread thread = new Thread("test thread " + t) {
@Override
public void run() {
IRemoteProcessBuilder builder = fRemoteServices.getProcessBuilder(fRemoteConnection, "perl", "-V:version"); //$NON-NLS-1$
builder.redirectErrorStream(true);
for (int i = 0; i < 10; i++) {
try {
IRemoteProcess proc = builder.start();
BufferedReader stdout = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line;
while ((line = stdout.readLine()) != null) {
results.add(line);
}
try {
proc.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
fail(e.getLocalizedMessage());
}
}
}
};
thread.start();
threads[t] = thread;
}
for (Thread t : threads) {
try {
t.join();
} catch (InterruptedException e) {
}
}
assertTrue(results.size() == 1);
}
public void testEnv() {
IRemoteProcessBuilder builder = fRemoteServices.getProcessBuilder(fRemoteConnection, "printenv"); //$NON-NLS-1$
builder.redirectErrorStream(true);
String path = builder.environment().get("PATH");
builder.environment().clear();
builder.environment().put("PATH", path);
try {
IRemoteProcess proc = builder.start();
BufferedReader stdout = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line;
String result = null;
while ((line = stdout.readLine()) != null) {
assertTrue(result == null);
result = line;
}
assertEquals(result, "PATH=" + path);
} catch (IOException e) {
e.printStackTrace();
fail(e.getLocalizedMessage());
}
}
/*
* (non-Javadoc)
*
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
fRemoteServices = RemoteServices.getRemoteServices("org.eclipse.remote.JSch"); //$NON-NLS-1$
assertNotNull(fRemoteServices);
IRemoteConnectionManager connMgr = fRemoteServices.getConnectionManager();
assertNotNull(connMgr);
try {
fRemoteConnection = connMgr.newConnection("test_connection"); //$NON-NLS-1$
} catch (RemoteConnectionException e) {
fail(e.getLocalizedMessage());
}
assertNotNull(fRemoteConnection);
fRemoteConnection.setAddress(HOST);
fRemoteConnection.setUsername(USERNAME);
fRemoteConnection.setPassword(PASSWORD);
try {
fRemoteConnection.open(new NullProgressMonitor());
} catch (RemoteConnectionException e) {
fail(e.getLocalizedMessage());
}
assertTrue(fRemoteConnection.isOpen());
}
/*
* (non-Javadoc)
*
* @see junit.framework.TestCase#tearDown()
*/
@Override
protected void tearDown() throws Exception {
fRemoteConnection.close();
IRemoteConnectionManager connMgr = fRemoteServices.getConnectionManager();
assertNotNull(connMgr);
connMgr.removeConnection(fRemoteConnection);
}
}

View file

@ -0,0 +1,20 @@
package org.eclipse.remote.core.tests.suite;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.remote.core.tests.ConnectionTests;
import org.eclipse.remote.core.tests.FileStoreTests;
import org.eclipse.remote.core.tests.ProcessTests;
public class RemoteCoreTestSuite {
public static Test suite() {
TestSuite suite = new TestSuite(RemoteCoreTestSuite.class.getName());
suite.addTestSuite(ConnectionTests.class);
suite.addTestSuite(FileStoreTests.class);
suite.addTestSuite(ProcessTests.class);
return suite;
}
}

View file

@ -169,12 +169,14 @@ public class JSchProcessBuilder extends AbstractRemoteProcessBuilder {
} }
try { try {
ChannelExec command = fConnection.getExecChannel(); ChannelExec exec = fConnection.getExecChannel();
command.setCommand(buildCommand(remoteCmd, env, clearEnv)); String command = buildCommand(remoteCmd, env, clearEnv);
command.setPty((flags & ALLOCATE_PTY) == ALLOCATE_PTY); exec.setCommand(command);
command.setXForwarding((flags & FORWARD_X11) == FORWARD_X11); System.out.println("running command: " + command);
command.connect(); exec.setPty((flags & ALLOCATE_PTY) == ALLOCATE_PTY);
return new JSchProcess(command, redirectErrorStream()); exec.setXForwarding((flags & FORWARD_X11) == FORWARD_X11);
exec.connect();
return new JSchProcess(exec, redirectErrorStream());
} catch (RemoteConnectionException e) { } catch (RemoteConnectionException e) {
throw new IOException(e.getMessage()); throw new IOException(e.getMessage());
} catch (JSchException e) { } catch (JSchException e) {
@ -184,6 +186,9 @@ public class JSchProcessBuilder extends AbstractRemoteProcessBuilder {
private String buildCommand(String cmd, List<String> environment, boolean clearEnv) { private String buildCommand(String cmd, List<String> environment, boolean clearEnv) {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if (directory() != null) {
sb.append("cd " + charEscapify(directory().toURI().getPath(), charSet) + "; "); //$NON-NLS-1$ //$NON-NLS-2$
}
if (clearEnv) { if (clearEnv) {
sb.append("env -i"); //$NON-NLS-1$ sb.append("env -i"); //$NON-NLS-1$
for (String env : environment) { for (String env : environment) {