Fixed bug 503050: [1.9] junit test cannot be run even though the
classpath has been configured to point to junit.jar
Change-Id: Ibaefaf124a991e34a38f4e959737ea5891535cfc
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationDelegate.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationDelegate.java
index 82c597c..911b3bd 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationDelegate.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -19,6 +19,7 @@
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList;
@@ -38,6 +39,7 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.URIUtil;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -388,20 +390,20 @@
for (int i= 0; i < entries.length; i++) {
try {
addEntry(junitEntries, entries[i]);
- } catch (IOException e) {
+ } catch (IOException | URISyntaxException e) {
Assert.isTrue(false, entries[i].getPluginId() + " is available (required JAR)"); //$NON-NLS-1$
}
}
return junitEntries;
}
- private void addEntry(List<String> junitEntries, final JUnitRuntimeClasspathEntry entry) throws IOException, MalformedURLException {
+ private void addEntry(List<String> junitEntries, final JUnitRuntimeClasspathEntry entry) throws IOException, MalformedURLException, URISyntaxException {
String entryString= entryString(entry);
if (entryString != null)
junitEntries.add(entryString);
}
- private String entryString(final JUnitRuntimeClasspathEntry entry) throws IOException, MalformedURLException {
+ private String entryString(final JUnitRuntimeClasspathEntry entry) throws IOException, MalformedURLException, URISyntaxException {
if (inDevelopmentMode()) {
try {
return localURL(entry.developmentModeEntry());
@@ -416,7 +418,7 @@
return fInDevelopmentMode;
}
- private String localURL(JUnitRuntimeClasspathEntry jar) throws IOException, MalformedURLException {
+ private String localURL(JUnitRuntimeClasspathEntry jar) throws IOException, MalformedURLException, URISyntaxException {
Bundle bundle= JUnitCorePlugin.getDefault().getBundle(jar.getPluginId());
URL url;
if (jar.getPluginRelativePath() == null)
@@ -425,7 +427,7 @@
url= bundle.getEntry(jar.getPluginRelativePath());
if (url == null)
throw new IOException();
- return FileLocator.toFileURL(url).getFile();
+ return URIUtil.toFile(URIUtil.toURI(FileLocator.toFileURL(url))).getAbsolutePath(); // See bug 503050
}
}