diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceInitialSelectionTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceInitialSelectionTest.java index 62b6416e60f..61c43cee148 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceInitialSelectionTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceInitialSelectionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2024 Emmanuel Chebbi and others. + * Copyright (c) 2019, 2026 Emmanuel Chebbi and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,17 +14,17 @@ package org.eclipse.ui.tests.dialogs; import static java.util.Arrays.asList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; +import java.util.Set; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -41,9 +41,9 @@ import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog; import org.eclipse.ui.internal.decorators.DecoratorManager; import org.eclipse.ui.tests.harness.util.DisplayHelper; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests that FilteredResourcesSelectionDialog selects its initial selection @@ -64,7 +64,7 @@ public class ResourceInitialSelectionTest { private IProject project; - @Before + @BeforeEach public void doSetUp() throws Exception { FILES.clear(); createProject(); @@ -87,7 +87,7 @@ public void testSingleSelectionAndNoInitialSelectionWithInitialPattern() { List selected = getSelectedItems(dialog); - assertFalse("One file should be selected by default", selected.isEmpty()); + assertFalse(selected.isEmpty(), "One file should be selected by default"); } /** @@ -108,7 +108,7 @@ public void testSingleSelectionAndOneInitialSelectionWithInitialPattern() { List selected = getSelectedItems(dialog); - assertEquals("One file should be selected by default", asList(FILES.get("foo.txt")), selected); + assertEquals(asList(FILES.get("foo.txt")), selected, "One file should be selected by default"); } /** @@ -130,7 +130,7 @@ public void testSingleSelectionAndOneInitialNonExistingSelectionWithInitialPatte List selected = getSelectedItems(dialog); - assertTrue("No file should be selected by default", selected.isEmpty()); + assertTrue(selected.isEmpty(), "No file should be selected by default"); } /** @@ -150,7 +150,7 @@ public void testSingleSelectionAndOneInitialSelectionWithoutInitialPattern() { List selected = getSelectedItems(dialog); - assertTrue("No file should be selected by default", selected.isEmpty()); + assertTrue(selected.isEmpty(), "No file should be selected by default"); } /** @@ -172,7 +172,7 @@ public void testSingleSelectionAndOneFilteredSelection() { List selected = getSelectedItems(dialog); - assertTrue("No file should be selected by default", selected.isEmpty()); + assertTrue(selected.isEmpty(), "No file should be selected by default"); } /** @@ -194,7 +194,7 @@ public void testSingleSelectionAndTwoInitialSelectionsWithInitialPattern() { List selected = getSelectedItems(dialog); - assertEquals("The first file should be selected by default", asList(FILES.get("foo.txt")), selected); + assertEquals(asList(FILES.get("foo.txt")), selected, "The first file should be selected by default"); } /** @@ -215,7 +215,7 @@ public void testMultiSelectionAndNoInitialSelectionWithInitialPattern() { List selected = getSelectedItems(dialog); - assertFalse("One file should be selected by default", selected.isEmpty()); + assertFalse(selected.isEmpty(), "One file should be selected by default"); } /** @@ -237,7 +237,7 @@ public void testMultiSelectionAndOneInitialSelectionWithInitialPattern() { List selected = getSelectedItems(dialog); - assertEquals("One file should be selected by default", asList(FILES.get("foo.txt")), selected); + assertEquals(asList(FILES.get("foo.txt")), selected, "One file should be selected by default"); } /** @@ -257,7 +257,7 @@ public void testMultiSelectionAndOneInitialSelectionWithoutInitialPattern() { List selected = getSelectedItems(dialog); - assertTrue("No file should be selected by default", selected.isEmpty()); + assertTrue(selected.isEmpty(), "No file should be selected by default"); } /** @@ -279,7 +279,7 @@ public void testMultiSelectionAndTwoInitialNonExistingSelectionWithInitialPatter List selected = getSelectedItems(dialog); - assertTrue("No file should be selected by default", selected.isEmpty()); + assertTrue(selected.isEmpty(), "No file should be selected by default"); } /** @@ -303,7 +303,7 @@ public void testMultiSelectionAndSomeInitialNonExistingSelectionWithInitialPatte Set expectedSelection = new HashSet<>(asList(FILES.get("bar.txt"), FILES.get("foofoo"))); boolean allInitialElementsAreSelected = expectedSelection.equals(new HashSet<>(selected)); - assertTrue("Two files should be selected by default", allInitialElementsAreSelected); + assertTrue(allInitialElementsAreSelected, "Two files should be selected by default"); } /** @@ -328,7 +328,7 @@ public void testMultiSelectionAndTwoInitialSelectionsWithInitialPattern() { boolean initialElementsAreSelected = selected.containsAll(initialSelection) && initialSelection.containsAll(selected); - assertTrue("Two files should be selected by default", initialElementsAreSelected); + assertTrue(initialElementsAreSelected, "Two files should be selected by default"); } /** @@ -354,7 +354,7 @@ public void testMultiSelectionAndTwoInitialFilteredSelections() { boolean initialElementsAreSelected = selected.containsAll(expectedSelection) && expectedSelection.containsAll(selected); - assertTrue("Two files should be selected by default", initialElementsAreSelected); + assertTrue(initialElementsAreSelected, "Two files should be selected by default"); } private FilteredResourcesSelectionDialog createDialog(boolean multiSelection) { @@ -394,11 +394,11 @@ private void createProject() throws CoreException { for (String fileName : FILE_NAMES) { DisplayHelper.waitForCondition(display, 1000, () -> project.getFile(fileName).exists()); - assertTrue("File was not created", project.getFile(fileName).exists()); + assertTrue(project.getFile(fileName).exists(), "File was not created"); } } - @After + @AfterEach public void doTearDown() throws Exception { if (dialog != null) { dialog.close(); @@ -406,22 +406,22 @@ public void doTearDown() throws Exception { if (project != null) { // Process any pending UI events before cleanup processUIEvents(); - + try { // Wait for decorator jobs to finish Job.getJobManager().wakeUp(DecoratorManager.FAMILY_DECORATE); Job.getJobManager().join(DecoratorManager.FAMILY_DECORATE, null); - + // Wait for any resource jobs that might be running Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_REFRESH, null); Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null); - + // Process UI events again after joining jobs processUIEvents(); - + // Try to delete with proper progress monitor and retry mechanism deleteProjectWithRetry(project); - + } catch (Exception e) { // try to get a stacktrace which jobs still has project open so that it can not // be deleted: @@ -495,7 +495,7 @@ private void waitForDialogRefresh() { private void deleteProjectWithRetry(IProject projectToDelete) throws CoreException { final int MAX_RETRY = 5; CoreException lastException = null; - + for (int i = 0; i < MAX_RETRY; i++) { try { projectToDelete.delete(true, true, new NullProgressMonitor()); @@ -514,7 +514,7 @@ private void deleteProjectWithRetry(IProject projectToDelete) throws CoreExcepti } } } - + // If we get here, all retries failed if (lastException != null) { throw lastException; diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceItemLabelTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceItemLabelTest.java index 4f89a111b07..4740f1ea74b 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceItemLabelTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceItemLabelTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2018 Red Hat Inc. and others. + * Copyright (c) 2017, 2026 Red Hat Inc. and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,9 +13,10 @@ *******************************************************************************/ package org.eclipse.ui.tests.dialogs; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.ByteArrayInputStream; import java.io.InputStream; @@ -35,9 +36,9 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog; import org.eclipse.ui.tests.harness.util.DisplayHelper; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests that resources are highlighted to match user search input. See Bug @@ -49,7 +50,7 @@ public class ResourceItemLabelTest { private IProject project; - @Before + @BeforeEach public void doSetUp() throws Exception { project = ResourcesPlugin.getWorkspace().getRoot() .getProject(getClass().getName() + "_" + System.currentTimeMillis()); @@ -269,16 +270,16 @@ public void testBug566858_leadingWhitespace() throws Exception { } private void compareStyleRanges(Position[] expected, StyleRange[] actual, String fileName, String fileParentPath) { - assertEquals("Length of StyleRanges is incorrect: " + printStyleRanges(actual), expected.length + 1, - actual.length); + assertEquals(expected.length + 1, actual.length, + "Length of StyleRanges is incorrect: " + printStyleRanges(actual)); int i; for (i = 0; i < actual.length - 1; i++) { - assertEquals("Start of StyleRange at index " + i + " is incorrect.", expected[i].offset, actual[i].start); - assertEquals("Length of StyleRange at index " + i + " is incorrect.", expected[i].length, actual[i].length); + assertEquals(expected[i].offset, actual[i].start, "Start of StyleRange at index " + i + " is incorrect."); + assertEquals(expected[i].length, actual[i].length, "Length of StyleRange at index " + i + " is incorrect."); } - assertEquals("Start of file path StyleRange is incorrect.", fileName.length(), actual[i].start); - assertEquals("Length of file path StyleRange at index is incorrect.", - 3 + project.getName().length() + fileParentPath.length(), actual[i].length); + assertEquals(fileName.length(), actual[i].start, "Start of file path StyleRange is incorrect."); + assertEquals(3 + project.getName().length() + fileParentPath.length(), actual[i].length, + "Length of file path StyleRange at index is incorrect."); } private FilteredResourcesSelectionDialog dialog; @@ -304,7 +305,7 @@ protected boolean condition() { } }.waitForCondition(shell.getDisplay(), 1000); - assertTrue("File was not created", project.getFile(fileName).exists()); + assertTrue(project.getFile(fileName).exists(), "File was not created"); dialog.reloadCache(true, new NullProgressMonitor()); ((Text) dialog.getPatternControl()).setText(searchString); @@ -350,7 +351,7 @@ private String printStyleRanges(StyleRange[] styleRanges) { return builder.toString(); } - @After + @AfterEach public void doTearDown() throws Exception { if (dialog != null) { dialog.close(); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceSelectionFilteringDialogTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceSelectionFilteringDialogTest.java index d855c08ef4b..2c613a6fed5 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceSelectionFilteringDialogTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceSelectionFilteringDialogTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019 Red Hat Inc. and others. + * Copyright (c) 2019, 2026 Red Hat Inc. and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.ui.tests.dialogs; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.ByteArrayInputStream; import java.io.File; @@ -24,10 +26,9 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog; import org.eclipse.ui.tests.harness.util.DisplayHelper; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class ResourceSelectionFilteringDialogTest { @@ -41,7 +42,7 @@ private static SeeThroughFilteredResourcesSelectionDialog createDialog() { private IProject project; - @Before + @BeforeEach public void doSetUp() throws Exception { project = ResourcesPlugin.getWorkspace().getRoot() .getProject(getClass().getSimpleName() + System.currentTimeMillis()); @@ -61,7 +62,7 @@ public void testMatch() throws CoreException { dialog.setInitialPattern("c/f"); dialog.open(); dialog.refresh(); - Assert.assertTrue(DisplayHelper.waitForCondition(dialog.getShell().getDisplay(), 3000, + assertTrue(DisplayHelper.waitForCondition(dialog.getShell().getDisplay(), 3000, () -> file.equals(dialog.getSelectedItems().getFirstElement()) )); } finally { @@ -69,7 +70,7 @@ public void testMatch() throws CoreException { } } - @After + @AfterEach public void doTearDown() throws Exception { project.delete(true, null); }