Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Brandys2011-01-12 06:51:57 -0500
committerSzymon Brandys2011-01-12 06:51:57 -0500
commit00004077ddef8cf94a0172cd1d0febf774a8cbd7 (patch)
tree10c8cad9041d96b85e5ccb5e64f15c5c45b32fdf
parent52749f9b26fbe97b69960df7978291715dab4e7e (diff)
downloadeclipse.platform.team-00004077ddef8cf94a0172cd1d0febf774a8cbd7.tar.gz
eclipse.platform.team-00004077ddef8cf94a0172cd1d0febf774a8cbd7.tar.xz
eclipse.platform.team-00004077ddef8cf94a0172cd1d0febf774a8cbd7.zip
bug 294925 - Wrong Default SSH DirectoryRoot_branch_20110112_bug330490
-rw-r--r--bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceInitializer.java3
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/META-INF/MANIFEST.MF4
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllCoreTests.java4
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/jsch/AllJschTests.java33
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/jsch/PreferenceInitializerTest.java100
5 files changed, 141 insertions, 3 deletions
diff --git a/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceInitializer.java b/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceInitializer.java
index e15c37003..d8337b443 100644
--- a/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceInitializer.java
+++ b/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceInitializer.java
@@ -36,7 +36,8 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer{
public void initializeDefaultPreferences(){
IEclipsePreferences defaultNode=DefaultScope.INSTANCE
.getNode(JSchCorePlugin.ID);
- defaultNode.put(IConstants.KEY_SSH2HOME, SSH_HOME_DEFAULT);
+ if(SSH_HOME_DEFAULT!=null)
+ defaultNode.put(IConstants.KEY_SSH2HOME, SSH_HOME_DEFAULT);
defaultNode.put(IConstants.KEY_PRIVATEKEY, IConstants.PRIVATE_KEYS_DEFAULT);
Utils.migrateSSH2Preferences();
changeDefaultWin32SshHome();
diff --git a/tests/org.eclipse.team.tests.cvs.core/META-INF/MANIFEST.MF b/tests/org.eclipse.team.tests.cvs.core/META-INF/MANIFEST.MF
index c61e64125..f62523d00 100644
--- a/tests/org.eclipse.team.tests.cvs.core/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.team.tests.cvs.core/META-INF/MANIFEST.MF
@@ -34,7 +34,9 @@ Require-Bundle: org.eclipse.ui.ide;resolution:=optional,
org.eclipse.team.tests.core,
org.eclipse.test.performance,
org.eclipse.core.tests.resources,
- org.eclipse.core.expressions
+ org.eclipse.core.expressions,
+ org.eclipse.core.filesystem;bundle-version="1.3.100",
+ org.eclipse.jsch.core;bundle-version="1.1.200"
Bundle-ActivationPolicy: lazy
Eclipse-AutoStart: true
Plugin-Class: org.eclipse.team.tests.ccvs.core.TeamCVSTestPlugin
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllCoreTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllCoreTests.java
index a5cbcb1b4..7f217c7b4 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllCoreTests.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/AllCoreTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -15,6 +15,7 @@ import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.team.tests.ccvs.core.cvsresources.AllTestsCVSResources;
+import org.eclipse.team.tests.ccvs.core.jsch.AllJschTests;
/**
* Tests that don't require the Team UI plugin to be loaded.
@@ -32,6 +33,7 @@ public class AllCoreTests extends EclipseTest {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(AllTestsCVSResources.suite());
+ suite.addTest(AllJschTests.suite());
return new TestSetup(suite);
}
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/jsch/AllJschTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/jsch/AllJschTests.java
new file mode 100644
index 000000000..06cd2f30c
--- /dev/null
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/jsch/AllJschTests.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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
+ *******************************************************************************/
+package org.eclipse.team.tests.ccvs.core.jsch;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.team.tests.ccvs.core.EclipseTest;
+
+public class AllJschTests extends EclipseTest {
+
+ public AllJschTests() {
+ super();
+ }
+
+ public AllJschTests(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTest(PreferenceInitializerTest.suite());
+ return suite;
+ }
+}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/jsch/PreferenceInitializerTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/jsch/PreferenceInitializerTest.java
new file mode 100644
index 000000000..cde651a5f
--- /dev/null
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/jsch/PreferenceInitializerTest.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 - ongoing maintenance
+ *******************************************************************************/
+package org.eclipse.team.tests.ccvs.core.jsch;
+
+import java.io.File;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jsch.internal.core.IConstants;
+import org.eclipse.jsch.internal.core.JSchCorePlugin;
+import org.eclipse.jsch.internal.core.PreferenceInitializer;
+import org.eclipse.team.tests.ccvs.core.EclipseTest;
+
+public class PreferenceInitializerTest extends EclipseTest {
+
+ private boolean PREF_HAS_CHANGED_DEFAULT_WIN32_SSH_HOME_value = false;
+ private String KEY_SSH2HOME_value = null;
+
+ protected void setUp() throws Exception {
+ if (!Platform.getOS().equals(Platform.OS_WIN32))
+ return;
+
+ super.setUp();
+ // remembering preferences changed in test
+ IEclipsePreferences preferences = InstanceScope.INSTANCE
+ .getNode(JSchCorePlugin.ID);
+ PREF_HAS_CHANGED_DEFAULT_WIN32_SSH_HOME_value = preferences.getBoolean(
+ IConstants.PREF_HAS_CHANGED_DEFAULT_WIN32_SSH_HOME, false);
+ KEY_SSH2HOME_value = preferences.get(IConstants.KEY_SSH2HOME, null);
+ }
+
+ protected void tearDown() throws Exception {
+ if (!Platform.getOS().equals(Platform.OS_WIN32))
+ return;
+
+ super.tearDown();
+ // restoring preferences changed in test
+ IEclipsePreferences preferences = InstanceScope.INSTANCE
+ .getNode(JSchCorePlugin.ID);
+ preferences.putBoolean(
+ IConstants.PREF_HAS_CHANGED_DEFAULT_WIN32_SSH_HOME,
+ PREF_HAS_CHANGED_DEFAULT_WIN32_SSH_HOME_value);
+ if (KEY_SSH2HOME_value != null)
+ preferences.put(IConstants.KEY_SSH2HOME, KEY_SSH2HOME_value);
+ else
+ preferences.remove(IConstants.KEY_SSH2HOME);
+ }
+
+ public void testChangeDefaultWin32SshHome() {
+ if (!Platform.getOS().equals(Platform.OS_WIN32))
+ return;
+
+ String userHome = System
+ .getProperty(IConstants.SYSTEM_PROPERTY_USER_HOME);
+
+ String oldDefaultWin32SshHome = null;
+ if (userHome != null) {
+ oldDefaultWin32SshHome = userHome + File.separator
+ + IConstants.SSH_OLD_DEFAULT_WIN32_HOME;
+ File file = new File(oldDefaultWin32SshHome);
+ if (!file.exists()) {
+ file.mkdir();
+ }
+ }
+
+ IEclipsePreferences preferences = InstanceScope.INSTANCE
+ .getNode(JSchCorePlugin.ID);
+ preferences.remove(IConstants.PREF_HAS_CHANGED_DEFAULT_WIN32_SSH_HOME);
+ preferences.remove(IConstants.KEY_SSH2HOME);
+
+ // verify that the preference is not set
+ assertFalse(preferences.getBoolean(
+ IConstants.PREF_HAS_CHANGED_DEFAULT_WIN32_SSH_HOME, false));
+
+ PreferenceInitializer preferenceInitializer = new PreferenceInitializer();
+ preferenceInitializer.initializeDefaultPreferences();
+
+ // verify that the preference is set now
+ assertTrue(preferences.getBoolean(
+ IConstants.PREF_HAS_CHANGED_DEFAULT_WIN32_SSH_HOME, false));
+ assertEquals(oldDefaultWin32SshHome,
+ preferences.get(IConstants.KEY_SSH2HOME, null));
+ }
+
+ public static Test suite() {
+ return new TestSuite(PreferenceInitializerTest.class);
+ }
+}

Back to the top