From 1d50889bc0372aaa741fd0e08b6e049a4831adae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Thu, 19 Dec 2024 10:06:16 +0200 Subject: [PATCH] Stop using deprecated URL constructors Changes tests only. --- .../classpathresolver/ClasspathResolverTest.java | 11 ++++++----- .../pde/ui/tests/launcher/PluginBasedLaunchTest.java | 9 ++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/classpathresolver/ClasspathResolverTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/classpathresolver/ClasspathResolverTest.java index 5d39f776e3..f433e69a96 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/classpathresolver/ClasspathResolverTest.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/classpathresolver/ClasspathResolverTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2021 Sonatype, Inc. and others. + * Copyright (c) 2011, 2024 Sonatype, Inc. and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -27,7 +27,8 @@ import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Field; -import java.net.URL; +import java.net.URI; +import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; @@ -401,15 +402,15 @@ private void mockTPWithRunningPlatformAndBundles( } private Properties createDevEntryProperties(List launchedBundles) - throws IOException, CoreException { + throws IOException, CoreException, URISyntaxException { File devPropertiesFile = tempFolder.newFile("dev.properties").getCanonicalFile(); Map> bundlesMap = Map.of(HOST_BUNDLE_ID, launchedBundles); String devPropertiesURL = ClasspathHelper.getDevEntriesProperties(devPropertiesFile.getPath(), bundlesMap); return loadProperties(devPropertiesURL); } - private static Properties loadProperties(String devPropertiesURL) throws IOException { - File propertiesFile = new File(new URL(devPropertiesURL).getPath()); + private static Properties loadProperties(String devPropertiesURL) throws IOException, URISyntaxException { + File propertiesFile = new File(new URI(devPropertiesURL).getPath()); Properties devProperties = new Properties(); try (InputStream stream = new FileInputStream(propertiesFile)) { devProperties.load(stream); diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java index 9385f331d1..1aec1f12ff 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021, 2022 Hannes Wellmann and others. + * Copyright (c) 2021, 2024 Hannes Wellmann and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -27,9 +27,8 @@ import java.io.File; import java.io.InputStream; -import java.net.MalformedURLException; import java.net.URI; -import java.net.URL; +import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; import java.util.Arrays; @@ -1052,7 +1051,7 @@ private static ILaunchConfigurationWorkingCopy createPluginLaunchConfig(String n private static final Pattern WHITESPACE = Pattern.compile("\\s+"); private Path getConfigurationFolder(ILaunchConfigurationWorkingCopy launchConfig) - throws CoreException, MalformedURLException { + throws CoreException, URISyntaxException { ILaunch launch = new Launch(launchConfig, ILaunchManager.RUN_MODE, null); var config = new EclipseApplicationLaunchConfiguration(); String commandLine = config.showCommandLine(launchConfig, ILaunchManager.RUN_MODE, launch, null); @@ -1062,7 +1061,7 @@ private Path getConfigurationFolder(ILaunchConfigurationWorkingCopy launchConfig try { return Path.of(URI.create(configURL)); } catch (IllegalArgumentException e) { - return Path.of(new URL(configURL).getPath()); + return Path.of(new URI(configURL).getPath()); } }