diff --git a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/AntEditorTests.java b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/AntEditorTests.java index d35a323a9b7..0aaf216162f 100644 --- a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/AntEditorTests.java +++ b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/AntEditorTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -24,7 +24,6 @@ import org.eclipse.ant.internal.ui.editor.text.XMLTextHover; import org.eclipse.ant.tests.ui.editor.performance.EditorTestHelper; import org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest; -import org.eclipse.ant.tests.ui.testplugin.ProjectCreationDecorator; import org.eclipse.core.resources.IFile; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; @@ -359,11 +358,10 @@ public void testOpenImportViaClasspath() throws PartInitException { */ @Test public void testOpenImportWithByteOrderMark() throws PartInitException { - if (ProjectCreationDecorator.isJ2SE15Compatible()) { - IFile file = getIFile("importWithByteOrderMark.xml"); //$NON-NLS-1$ - AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, "org.eclipse.ant.ui.internal.editor.AntEditor", true); //$NON-NLS-1$ - assertNotNull("Should have imported target", editor.getAntModel().getTargetNode("build")); //$NON-NLS-1$ //$NON-NLS-2$ - } + IFile file = getIFile("importWithByteOrderMark.xml"); //$NON-NLS-1$ + AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, + "org.eclipse.ant.ui.internal.editor.AntEditor", true); //$NON-NLS-1$ + assertNotNull("Should have imported target", editor.getAntModel().getTargetNode("build")); //$NON-NLS-1$ //$NON-NLS-2$ } private int getOffsetWithinLine(AntEditor editor, int lineNumber, int offsetInLine) throws BadLocationException { diff --git a/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF index b6b36ead000..9b13228f9b5 100644 --- a/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF +++ b/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF @@ -4,7 +4,6 @@ Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.ant.tests.ui; singleton:=true Bundle-Version: 3.12.0.qualifier Bundle-ClassPath: anttestsui.jar -Bundle-Activator: org.eclipse.ant.tests.ui.testplugin.AntUITestPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.ant.tests.ui, diff --git a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AbstractAntUITest.java b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AbstractAntUITest.java index 4984b1102de..6c4960543b0 100644 --- a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AbstractAntUITest.java +++ b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AbstractAntUITest.java @@ -25,6 +25,7 @@ import java.io.UnsupportedEncodingException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.net.URL; import java.nio.file.Files; import javax.xml.parsers.SAXParser; @@ -42,6 +43,8 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -74,6 +77,8 @@ import org.eclipse.ui.progress.UIJob; import org.junit.Before; import org.junit.Rule; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; @@ -161,7 +166,7 @@ public static void assertProject() throws Exception { IProject project = ProjectHelper.createProject(ProjectHelper.PROJECT_NAME); IFolder folder = ProjectHelper.addFolder(project, "buildfiles"); //$NON-NLS-1$ ProjectHelper.addFolder(project, "launchConfigurations"); //$NON-NLS-1$ - File root = AntUITestPlugin.getDefault().getFileInPlugin(ProjectHelper.TEST_BUILDFILES_DIR); + File root = getFileInPlugin(ProjectHelper.TEST_BUILDFILES_DIR); ProjectHelper.importFilesFromDirectory(root, folder.getFullPath(), null); ProjectHelper.createLaunchConfigurationForBoth("echoing"); //$NON-NLS-1$ @@ -191,6 +196,17 @@ public static void assertProject() throws Exception { } } + public static File getFileInPlugin(IPath path) { + try { + Bundle bundle = FrameworkUtil.getBundle(AbstractAntUITest.class); + URL installURL = bundle.getEntry("/" + path.toString()); //$NON-NLS-1$ + URL localURL = FileLocator.toFileURL(installURL); + return new File(localURL.getFile()); + } catch (IOException e) { + return null; + } + } + /** * Returns the 'AntUITests' project. * diff --git a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AntUITestPlugin.java b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AntUITestPlugin.java deleted file mode 100644 index f09b46535c3..00000000000 --- a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AntUITestPlugin.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ant.tests.ui.testplugin; - -import java.io.File; -import java.io.IOException; -import java.net.URL; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceDescription; -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.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.Bundle; - -public class AntUITestPlugin extends AbstractUIPlugin { - - private static AntUITestPlugin deflt; - - public AntUITestPlugin() { - super(); - deflt = this; - } - - public static AntUITestPlugin getDefault() { - return deflt; - } - - public static IWorkspace getWorkspace() { - return ResourcesPlugin.getWorkspace(); - } - - public static void enableAutobuild(boolean enable) throws CoreException { - // disable auto build - IWorkspace workspace = AntUITestPlugin.getWorkspace(); - IWorkspaceDescription desc = workspace.getDescription(); - desc.setAutoBuilding(enable); - workspace.setDescription(desc); - } - - public File getFileInPlugin(IPath path) { - try { - Bundle bundle = getDefault().getBundle(); - URL installURL = new URL(bundle.getEntry("/"), path.toString()); //$NON-NLS-1$ - URL localURL = FileLocator.toFileURL(installURL); - return new File(localURL.getFile()); - } - catch (IOException e) { - return null; - } - } -} diff --git a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ProjectCreationDecorator.java b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ProjectCreationDecorator.java deleted file mode 100644 index a776880e9ed..00000000000 --- a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ProjectCreationDecorator.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ant.tests.ui.testplugin; - -/** - * Utility class - */ -public class ProjectCreationDecorator { - - private static boolean fgIsJ2SE15Compatible = false; - - static { - String version = System.getProperty("java.specification.version"); //$NON-NLS-1$ - if (version != null) { - String[] nums = version.split("\\."); //$NON-NLS-1$ - if (nums.length == 2) { - try { - int major = Integer.parseInt(nums[0]); - int minor = Integer.parseInt(nums[1]); - if (major >= 1) { - if (minor >= 5) { - fgIsJ2SE15Compatible = true; - } - } - } - catch (NumberFormatException e) { - // do nothing - } - } - } - } - - /** - * @return if the system property "java.specification.version" is 1.5 or greater - */ - public static boolean isJ2SE15Compatible() { - return fgIsJ2SE15Compatible; - } -} diff --git a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ProjectHelper.java b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ProjectHelper.java index 3ff473f699c..bdcc870fa42 100644 --- a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ProjectHelper.java +++ b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ProjectHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 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 @@ -17,7 +17,6 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.eclipse.ant.internal.ui.IAntUIConstants; @@ -91,13 +90,6 @@ private static void addNatureToProject(IProject proj, String natureId, IProgress proj.setDescription(description, monitor); } - /** - * Removes an IProject. - */ - public static void delete(IProject project) throws CoreException { - project.delete(true, true, null); - } - /** * Adds a folder to an IProject. */ @@ -135,9 +127,7 @@ private static void addFiles(File dir, List collection) throws IOException subDirs.add(file); } } - Iterator iter = subDirs.iterator(); - while (iter.hasNext()) { - File subDir = iter.next(); + for (File subDir : subDirs) { addFiles(subDir, collection); } }