Skip to content

Commit

Permalink
Fix warnings due Java 21 deprecations in o.e.debug.tests
Browse files Browse the repository at this point in the history
Do not create new URL but fetch it directly from bundle.
Minor cleanup to specify type of collections which allows the forech
cleanup to kick up too.
  • Loading branch information
akurtakov committed Jan 11, 2025
1 parent fd5c8ce commit 8262741
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2013 Wind River Systems and others.
* Copyright (c) 2009, 2025 Wind River Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -24,7 +24,6 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;

Expand All @@ -38,15 +37,17 @@ public class TestsPlugin {
public static final String PLUGIN_ID = "org.eclipse.debug.tests"; //$NON-NLS-1$

/**
* Returns the file corresponding to the specified path from within this bundle
* @return the file corresponding to the specified path from within this bundle, or
* <code>null</code> if not found
* Returns the file corresponding to the specified path from within this
* bundle
*
* @return the file corresponding to the specified path from within this
* bundle, or <code>null</code> if not found
*/
public static File getFileInPlugin(IPath path) {
public static File getFileInPlugin(String path) {
try {
Bundle bundle = FrameworkUtil.getBundle(TestsPlugin.class);
URL installURL = new URL(bundle.getEntry("/"), path.toString()); //$NON-NLS-1$
URL localURL= FileLocator.toFileURL(installURL);//Platform.asLocalURL(installURL);
URL installURL = bundle.getEntry("/" + path); //$NON-NLS-1$
URL localURL = FileLocator.toFileURL(installURL);
return new File(localURL.getFile());
} catch (IOException e) {
return null;
Expand All @@ -55,6 +56,7 @@ public static File getFileInPlugin(IPath path) {

/**
* Creates a new project with the specified name
*
* @return a new project with the specified name
*/
public static IProject createProject(String projectName) throws CoreException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2021 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -38,7 +38,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -1213,7 +1212,7 @@ public void testImport() throws Exception {
ILaunchConfiguration handle = wc.doSave();
assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$

File dir = TestsPlugin.getFileInPlugin(IPath.fromOSString("test-import")); //$NON-NLS-1$
File dir = TestsPlugin.getFileInPlugin("test-import"); //$NON-NLS-1$
assertTrue("Import directory does not exist", dir.exists()); //$NON-NLS-1$
LaunchManager manager = (LaunchManager) getLaunchManager();

Expand All @@ -1231,12 +1230,10 @@ public void testImport() throws Exception {
assertTrue("Import4 should be removed", removed.contains(handle)); //$NON-NLS-1$

// should be 5 added
List<?> added = listener.getAdded();
List<ILaunchConfiguration> added = listener.getAdded();
assertEquals("Should be 5 added configs", 5, added.size()); //$NON-NLS-1$
Set<String> names = new HashSet<>();
Iterator<?> iterator = added.iterator();
while (iterator.hasNext()) {
ILaunchConfiguration lc = (ILaunchConfiguration) iterator.next();
for (ILaunchConfiguration lc : added) {
names.add(lc.getName());
}
assertTrue("Missing Name", names.contains("Import1")); //$NON-NLS-1$ //$NON-NLS-2$
Expand Down

0 comments on commit 8262741

Please sign in to comment.