summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Brandys2012-06-04 07:09:55 (EDT)
committer Szymon Brandys2012-08-02 06:47:29 (EDT)
commitb74a2ec151a535c6d9d57718b7d32a4f7533dcce (patch)
tree50d084b58121f1df9e4d37b39466ad7dd71f21e9
parent778e639456788b4cdbf66081f470adc81f244115 (diff)
downloadeclipse.platform.resources-b74a2ec151a535c6d9d57718b7d32a4f7533dcce.zip
eclipse.platform.resources-b74a2ec151a535c6d9d57718b7d32a4f7533dcce.tar.gz
eclipse.platform.resources-b74a2ec151a535c6d9d57718b7d32a4f7533dcce.tar.bz2
org.eclipse.core.internal.resources.PathVariableManager.validateValue(URI) always returns null Change-Id: I8f77d35163a24ad61abfe2e75fbc19c01647ce82
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PathVariableManager.java23
-rw-r--r--tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_380386.java67
2 files changed, 79 insertions, 11 deletions
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PathVariableManager.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PathVariableManager.java
index fec3029..671e4d8 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PathVariableManager.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PathVariableManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -299,13 +299,15 @@ public class PathVariableManager implements IPathVariableManager, IManager {
}
/**
- * @throws CoreException
* @see IPathVariableManager#convertToRelative(URI, boolean, String)
*/
public URI convertToRelative(URI path, boolean force, String variableHint) throws CoreException {
return PathVariableUtil.convertToRelative(this, path, null, false, variableHint);
}
+ /**
+ * see IPathVariableManager#getURIValue(String)
+ */
public URI getURIValue(String name) {
IPath path = getValue(name);
if (path != null)
@@ -313,19 +315,18 @@ public class PathVariableManager implements IPathVariableManager, IManager {
return null;
}
+ /**
+ * see IPathVariableManager#setURIValue(String, URI)
+ */
public void setURIValue(String name, URI value) throws CoreException {
- if (value != null)
- setValue(name, URIUtil.toPath(value));
- else
- setValue(name, null);
+ setValue(name, (value != null ? URIUtil.toPath(value) : null));
}
+ /**
+ * @see IPathVariableManager#validateValue(URI)
+ */
public IStatus validateValue(URI path) {
- if (path != null)
- validateValue(URIUtil.toPath(path));
- else
- validateValue((IPath) null);
- return null;
+ return validateValue(path != null ? URIUtil.toPath(path) : (IPath) null);
}
public URI resolveURI(URI uri, IResource resource) {
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_380386.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_380386.java
new file mode 100644
index 0000000..923a2fb
--- /dev/null
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_380386.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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 - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.tests.resources.regression;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.eclipse.core.resources.IPathVariableManager;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.tests.resources.ResourceTest;
+
+/**
+ * Test for Bug 380386
+ */
+public class Bug_380386 extends ResourceTest {
+
+ public static Test suite() {
+ return new TestSuite(Bug_380386.class);
+ }
+
+ public void testBug() throws Exception {
+
+ String path = "C:\\temp";
+ java.net.URI value = new java.io.File(path).toURI();
+ IPathVariableManager pathManager = ResourcesPlugin.getWorkspace().getPathVariableManager();
+ String name = "somename";
+ IStatus statusName = pathManager.validateName(name);
+ IStatus statusValue = pathManager.validateValue(value);
+
+ if (statusName == null || statusValue == null) {
+ System.err.println("statusName is " + (statusName == null ? "null" : ("not null: '" + statusName + "'.")));
+ System.err.println("statusValue is " + (statusValue == null ? "null" : ("not null: '" + statusValue + "'.")));
+
+ } else if (statusName.isOK() && statusValue.isOK()) {
+ pathManager.setURIValue(name, value);
+ System.out.println("Everything is fine");
+ } else {
+ if (!statusName.isOK()) {
+ System.err.println("statusName is not OK.");
+ }
+ if (!statusValue.isOK()) {
+ System.err.println("statusValue is not OK.");
+ }
+ }
+
+ assertNotNull("1.0", statusName);
+ assertNotNull("2.0", statusValue);
+
+ assertTrue("3.0", statusName.isOK());
+ assertNotNull("4.0", statusValue.isOK());
+
+ try {
+ pathManager.setURIValue(name, value);
+ } catch (CoreException e) {
+ fail("5.0", e);
+ }
+ }
+}