diff options
| author | Szymon Brandys | 2012-06-04 11:09:55 +0000 |
|---|---|---|
| committer | Szymon Brandys | 2012-08-02 10:47:29 +0000 |
| commit | b74a2ec151a535c6d9d57718b7d32a4f7533dcce (patch) | |
| tree | 50d084b58121f1df9e4d37b39466ad7dd71f21e9 | |
| parent | 778e639456788b4cdbf66081f470adc81f244115 (diff) | |
| download | eclipse.platform.resources-b74a2ec151a535c6d9d57718b7d32a4f7533dcce.tar.gz eclipse.platform.resources-b74a2ec151a535c6d9d57718b7d32a4f7533dcce.tar.xz eclipse.platform.resources-b74a2ec151a535c6d9d57718b7d32a4f7533dcce.zip | |
org.eclipse.core.internal.resources.PathVariableManager.validateValue(URI)
always returns null
Change-Id: I8f77d35163a24ad61abfe2e75fbc19c01647ce82
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 fec3029aa..671e4d8a4 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 000000000..923a2fb96 --- /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); + } + } +} |
