From 40af908d310714f7bdcf82393747d2bdad93e1a0 Mon Sep 17 00:00:00 2001 From: Carsten Hammer Date: Sun, 27 Oct 2024 17:47:08 +0100 Subject: [PATCH] test more migrated classes --- .../JavaIgnoreWhitespaceContributorTest.java | 2 +- .../ui/compare/JavaTokenComparatorTest.java | 4 +- ...dJUnitLaunchConfigurationDelegateTest.java | 6 +- .../PackagesViewContentProviderTests.java | 82 ++++++++-------- .../PackagesViewContentProviderTests2.java | 84 ++++++++-------- .../browsing/PackagesViewDeltaTests.java | 92 +++++++++--------- ...BuildpathModifierActionEnablementTest.java | 22 ++--- .../BuildpathModifierActionTest.java | 96 +++++++++---------- .../BuildpathProblemQuickFixTest.java | 8 +- .../ui/tests/buildpath/CPUserLibraryTest.java | 6 +- .../buildpath/ClassPathElementsOrderTest.java | 36 +++---- 11 files changed, 219 insertions(+), 219 deletions(-) diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/internal/ui/compare/JavaIgnoreWhitespaceContributorTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/internal/ui/compare/JavaIgnoreWhitespaceContributorTest.java index 75cdcbb7152..8bf008999a0 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/internal/ui/compare/JavaIgnoreWhitespaceContributorTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/internal/ui/compare/JavaIgnoreWhitespaceContributorTest.java @@ -22,7 +22,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/internal/ui/compare/JavaTokenComparatorTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/internal/ui/compare/JavaTokenComparatorTest.java index a549a048e65..714bc92f53c 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/internal/ui/compare/JavaTokenComparatorTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/internal/ui/compare/JavaTokenComparatorTest.java @@ -13,11 +13,11 @@ *******************************************************************************/ package org.eclipse.jdt.internal.ui.compare; -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 org.junit.Test; +import org.junit.jupiter.api.Test; public class JavaTokenComparatorTest { diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/launcher/AdvancedJUnitLaunchConfigurationDelegateTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/launcher/AdvancedJUnitLaunchConfigurationDelegateTest.java index 7f340d50589..7d50ae7d127 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/launcher/AdvancedJUnitLaunchConfigurationDelegateTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/launcher/AdvancedJUnitLaunchConfigurationDelegateTest.java @@ -20,8 +20,8 @@ import java.nio.file.Paths; import java.util.List; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.eclipse.jdt.junit.JUnitCore; import org.eclipse.jdt.testplugin.JavaProjectHelper; @@ -47,7 +47,7 @@ public class AdvancedJUnitLaunchConfigurationDelegateTest { private IJavaProject fJavaProject; - @After + @AfterEach public void deleteProject() throws CoreException { if (fJavaProject != null) { JavaProjectHelper.delete(fJavaProject); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests.java index dbb545d795e..d0fcc8a3ee1 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests.java @@ -13,17 +13,17 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.browsing; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.File; -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; import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jdt.testplugin.JavaTestPlugin; @@ -110,7 +110,7 @@ public void testGetChildrenProjectWithSourceFolders() throws Exception { Object[] expectedChildren= new Object[]{fPack21, fPack12, cp, defaultCp}; Object[] children= fProvider.getChildren(fJProject2); - assertTrue("Wrong children found for project", compareArrays(children, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "Wrong children found for project");//$NON-NLS-1$ } @@ -121,14 +121,14 @@ public void testGetChildrentMidLevelFragmentNotLogicalPackage() throws Exception Object[] expectedChildren= new Object[]{fPack17}; Object[] actualChildren= fProvider.getChildren(fPack12); - assertTrue("Wrong children found for PackageFragment", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(actualChildren, expectedChildren), "Wrong children found for PackageFragment");//$NON-NLS-1$ } @Test public void testGetChildrenBottomLevelFragment() throws Exception { Object[] expectedChildren= new Object[]{}; Object[] actualChildren= fProvider.getChildren(fPack21); - assertTrue("Wrong children found for PackageFragment", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(actualChildren, expectedChildren), "Wrong children found for PackageFragment");//$NON-NLS-1$ } @Test @@ -153,7 +153,7 @@ public void testGetChildrenLogicalPackage() throws Exception { Object[] expectedChildren= new Object[]{fPack81, childCp1, childCp2}; Object[] actualChildren= fProvider.getChildren(cp); - assertTrue("Wrong children found for project", compareArrays(actualChildren, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(actualChildren, expectedChildren), "Wrong children found for project"); //$NON-NLS-1$ } @Test @@ -173,7 +173,7 @@ public void testGetChildrenLogicalPackage2() throws Exception { Object[] expectedChildren= new Object[]{fPack91, fInternalPack10}; Object[] actualChildren= fProvider.getChildren(cp); - assertTrue("Wrong children found for project", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(actualChildren, expectedChildren), "Wrong children found for project");//$NON-NLS-1$ } @Test @@ -184,28 +184,28 @@ public void testGetChildrenMidLevelFragmentInArchive() throws Exception { Object[] expectedChildren= new Object[]{fPackJunitSamplesMoney}; Object[] actualChildren= fProvider.getChildren(fPackJunitSamples); - assertTrue("wrong children found for a NON bottom PackageFragment in PackageFragmentRoot Archive", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(actualChildren, expectedChildren), "wrong children found for a NON bottom PackageFragment in PackageFragmentRoot Archive");//$NON-NLS-1$ } @Test public void testGetChildrenBottomLevelFragmentInArchive() throws Exception { Object[] expectedChildren= new Object[]{}; Object[] actualChildren= fProvider.getChildren(fPackJunitSamplesMoney); - assertTrue("wrong children found for a bottom PackageFragment in PackageFragmentRoot Archive", compareArrays(actualChildren, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(actualChildren, expectedChildren), "wrong children found for a bottom PackageFragment in PackageFragmentRoot Archive"); //$NON-NLS-1$ } @Test public void testGetChildrenSourceFolder() throws Exception { Object[] expectedChildren = new Object[] {fPack21, fPack31, fPackDefault1}; Object[] actualChildren = fProvider.getChildren(fRoot1); - assertTrue("Wrong children found for PackageFragmentRoot", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(actualChildren, expectedChildren), "Wrong children found for PackageFragmentRoot");//$NON-NLS-1$ } @Test public void testGetChildrenArchive() { Object[] expectedChildren= new Object[] {fPackJunit, fArchiveFragmentRoot.getPackageFragment("")};//$NON-NLS-1$ Object[] actualChildren= fProvider.getChildren(fArchiveFragmentRoot); - assertTrue("Wrong child found for PackageFragmentRoot Archive", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(actualChildren, expectedChildren), "Wrong child found for PackageFragmentRoot Archive");//$NON-NLS-1$ } //---------------Get Parent Tests----------------------------- @@ -213,7 +213,7 @@ public void testGetChildrenArchive() { @Test public void testGetParentArchive() throws Exception { Object actualParent= fProvider.getParent(fArchiveFragmentRoot); - assertNull("Wrong parent found for PackageFragmentRoot Archive", actualParent);//$NON-NLS-1$ + assertNull(actualParent, "Wrong parent found for PackageFragmentRoot Archive");//$NON-NLS-1$ } @Test @@ -225,14 +225,14 @@ public void testGetParentMidLevelFragmentInArchive() throws Exception { Object expectedParent= fPackJunitSamples; Object actualParent= fProvider.getParent(fPackJunitSamplesMoney); - assertEquals("Wrong parent found for a NON top level PackageFragment in an Archive", expectedParent, actualParent);//$NON-NLS-1$ + assertEquals(expectedParent, actualParent, "Wrong parent found for a NON top level PackageFragment in an Archive");//$NON-NLS-1$ } @Test public void testGetParentTopLevelFragmentInArchive() throws Exception { Object expectedParent= fPackJunit; Object actualParent= fProvider.getParent(fPackJunitSamples); - assertEquals("Wrong parent found for a top level PackageFragment in an Archive", expectedParent, actualParent); //$NON-NLS-1$ + assertEquals(expectedParent, actualParent, "Wrong parent found for a top level PackageFragment in an Archive"); //$NON-NLS-1$ } @Test @@ -242,7 +242,7 @@ public void testGetParentTopLevelLogicalPackage() throws Exception { cp.add(fInternalPack3); Object actualParent= fProvider.getParent(cp); - assertEquals("Wrong parent found for a top level LogicalPackage", fJProject2, actualParent);//$NON-NLS-1$ + assertEquals(fJProject2, actualParent, "Wrong parent found for a top level LogicalPackage");//$NON-NLS-1$ } @Test @@ -255,7 +255,7 @@ public void testGetParentPackageFragmentWithLogicalPackageParent() throws Except fProvider.getChildren(fJProject2); Object parent= fProvider.getParent(fPack81); - assertEquals("Wrong parent found for a top level LogicalPackage", cp, parent);//$NON-NLS-1$ + assertEquals(cp, parent, "Wrong parent found for a top level LogicalPackage");//$NON-NLS-1$ } @Test @@ -272,7 +272,7 @@ public void testGetParentOfLogicalPackagetWithLogicalPackageParent() throws Exce fProvider.getChildren(fJProject2); Object parent= fProvider.getParent(cp); - assertEquals("Wrong parent found for a top level LogicalPackage", parentCp, parent);//$NON-NLS-1$ + assertEquals(parentCp, parent, "Wrong parent found for a top level LogicalPackage");//$NON-NLS-1$ } // public void testGetParentWithPFRootFocus(){ @@ -299,7 +299,7 @@ public void testGetParentPFwithProjectFocus(){ cp.add(fInternalPack3); Object parent= fProvider.getParent(fPack41); - assertEquals("Wrong parent found for a mid level Fragment with Root Focus", cp, parent); //$NON-NLS-1$ + assertEquals(cp, parent, "Wrong parent found for a mid level Fragment with Root Focus"); //$NON-NLS-1$ } @Test @@ -321,7 +321,7 @@ public void testGetParentWithRootFocusAfterProjectFocus(){ Object[] expectedChildren= new Object[]{fPack21, fPack12, cp, defaultCp}; - assertTrue("expected children of project with focus", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(actualChildren, expectedChildren), "expected children of project with focus");//$NON-NLS-1$ //set up map with root focus for (Object object : fProvider.getChildren(fRoot1)) { @@ -335,7 +335,7 @@ public void testGetParentWithRootFocusAfterProjectFocus(){ public void testGetParentTopLevelFragment() throws Exception { Object actualParent= fProvider.getParent(fPack21); Object expectedParent= fRoot1; - assertEquals("Wrong parent found for a top level PackageFragment", expectedParent, actualParent); //$NON-NLS-1$ + assertEquals(expectedParent, actualParent, "Wrong parent found for a top level PackageFragment"); //$NON-NLS-1$ } @@ -343,7 +343,7 @@ public void testGetParentTopLevelFragment() throws Exception { public void testGetParentMidLevelFragment() throws Exception { Object expectedParent= fPack12; Object actualParent= fProvider.getParent(fPack17); - assertEquals("Wrong parent found for a NON top level PackageFragment", expectedParent, actualParent); //$NON-NLS-1$ + assertEquals(expectedParent, actualParent, "Wrong parent found for a NON top level PackageFragment"); //$NON-NLS-1$ } @@ -356,7 +356,7 @@ public void testBug123424_1() throws Exception { fJProject2.setRawClasspath(new IClasspathEntry[] {rawClasspath[0], element.getClasspathEntry(), rawClasspath[2]}, null); Object[] expectedChildren= new Object[]{fPack12.getResource(), fPack32.getResource()}; Object[] actualChildren= fProvider.getChildren(fRoot2); - assertTrue("Wrong children found for project", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(actualChildren, expectedChildren), "Wrong children found for project");//$NON-NLS-1$ } @Test @@ -368,13 +368,13 @@ public void testBug123424_2() throws Exception { fJProject2.setRawClasspath(new IClasspathEntry[] {rawClasspath[0], element.getClasspathEntry(), rawClasspath[2]}, null); Object[] expectedChildren= new Object[]{fPack42.getResource(), fPack52}; Object[] actualChildren= fProvider.getChildren(fPack32.getResource()); - assertTrue("Wrong children found for project", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(actualChildren, expectedChildren), "Wrong children found for project");//$NON-NLS-1$ } /* * @see TestCase#setUp() */ - @Before + @BeforeEach public void setUp() throws Exception { fWorkspace= ResourcesPlugin.getWorkspace(); assertNotNull(fWorkspace); @@ -387,22 +387,22 @@ public void setUp() throws Exception { fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");//$NON-NLS-1$//$NON-NLS-2$ fJProject2= JavaProjectHelper.createJavaProject("TestProject2", "bin");//$NON-NLS-1$//$NON-NLS-2$ - assertNotNull("project1 null", fJProject1);//$NON-NLS-1$ - assertNotNull("project2 null", fJProject2);//$NON-NLS-1$ + assertNotNull(fJProject1, "project1 null");//$NON-NLS-1$ + assertNotNull(fJProject2, "project2 null");//$NON-NLS-1$ //------------set up project #1 : External Jar and zip file------- IPackageFragmentRoot jdk= JavaProjectHelper.addVariableRTJar(fJProject1, "JRE_LIB_TEST", null, null);//$NON-NLS-1$ - assertNotNull("jdk not found", jdk);//$NON-NLS-1$ + assertNotNull(jdk, "jdk not found");//$NON-NLS-1$ //---Create zip file------------------- java.io.File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381); - assertNotNull("junit src not found", junitSrcArchive);//$NON-NLS-1$ - assertTrue("junit src not found", junitSrcArchive.exists());//$NON-NLS-1$ + assertNotNull(junitSrcArchive, "junit src not found");//$NON-NLS-1$ + assertTrue(junitSrcArchive.exists(), "junit src not found");//$NON-NLS-1$ fArchiveFragmentRoot= JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);//$NON-NLS-1$ @@ -410,9 +410,9 @@ public void setUp() throws Exception { fPackJunitSamples= fArchiveFragmentRoot.getPackageFragment("junit.samples");//$NON-NLS-1$ fPackJunitSamplesMoney= fArchiveFragmentRoot.getPackageFragment("junit.samples.money");//$NON-NLS-1$ - assertNotNull("creating fPackJunit", fPackJunit);//$NON-NLS-1$ - assertNotNull("creating fPackJunitSamples", fPackJunitSamples);//$NON-NLS-1$ - assertNotNull("creating fPackJunitSamplesMoney",fPackJunitSamplesMoney);//$NON-NLS-1$ + assertNotNull(fPackJunit, "creating fPackJunit");//$NON-NLS-1$ + assertNotNull(fPackJunitSamples, "creating fPackJunitSamples");//$NON-NLS-1$ + assertNotNull(fPackJunitSamplesMoney,"creating fPackJunitSamplesMoney");//$NON-NLS-1$ fPackJunitSamplesMoney.getCompilationUnit("IMoney.java");//$NON-NLS-1$ fPackJunitSamplesMoney.getCompilationUnit("Money.java");//$NON-NLS-1$ @@ -425,8 +425,8 @@ public void setUp() throws Exception { //----------------Set up internal jar---------------------------- File myInternalJar= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/compoundtest.jar"));//$NON-NLS-1$ - assertNotNull("lib not found", myInternalJar);//$NON-NLS-1$ - assertTrue("lib not found", myInternalJar.exists());//$NON-NLS-1$ + assertNotNull(myInternalJar, "lib not found");//$NON-NLS-1$ + assertTrue(myInternalJar.exists(), "lib not found");//$NON-NLS-1$ fInternalJarRoot= JavaProjectHelper.addLibraryWithImport(fJProject2, Path.fromOSString(myInternalJar.getPath()), null, null); @@ -500,7 +500,7 @@ public void setUpMockView() throws Exception { /* * @see TestCase#tearDown() */ - @After + @AfterEach public void tearDown() throws Exception { JavaProjectHelper.delete(fJProject1); JavaProjectHelper.delete(fJProject2); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests2.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests2.java index e8ec8a86e04..ccbecfeb51a 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests2.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests2.java @@ -13,17 +13,17 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.browsing; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -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.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.File; -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; import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jdt.testplugin.JavaTestPlugin; @@ -105,7 +105,7 @@ public class PackagesViewContentProviderTests2 { public void testGetElementsPackageFragmentRoot() throws Exception { Object[] children= fProvider.getElements(fRoot1); Object[] expectedChildren= new Object[] { fPack21, fPack31, fPack41, fPack51, fPack61, fPack81, fPack91, fPackDefault1 }; - assertTrue("Wrong children found for PackageFragment", compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "Wrong children found for PackageFragment"); //$NON-NLS-1$ } @Test @@ -136,7 +136,7 @@ public void testGetElementsProject() throws Exception { Object[] children= fProvider.getElements(fJProject2); Object[] expectedChildren= new Object[] { defaultCp, cp3, cp4, cp5, cp6, cp10, fPack21, fPack12, fPack91, fPack81, fPack17 }; - assertTrue("Wrong children founf for PackageFragment", compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "Wrong children founf for PackageFragment"); //$NON-NLS-1$ } //---------------Delta Tests----------------------------- @@ -154,8 +154,8 @@ public void testRemovePackageNotLogicalPackage() throws Exception { //force events from display fMyPart.pushDisplay(); - assertTrue("Remove happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$ - assertTrue("Correct package removed", fMyPart.getRemovedObject().contains(fPack12)); //$NON-NLS-1$ + assertTrue(fMyPart.hasRemoveHappened(), "Remove happened"); //$NON-NLS-1$ + assertTrue(fMyPart.getRemovedObject().contains(fPack12), "Correct package removed"); //$NON-NLS-1$ } @Test @@ -178,12 +178,12 @@ public void testRemovePackageInTwoPackageLogicalPackage() throws Exception { fMyPart.pushDisplay(); //assert remove happened (delta worked) - assertTrue("Refresh happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$ - assertTrue("Refresh happened", fMyPart.hasAddHappened()); //$NON-NLS-1$ + assertTrue(fMyPart.hasRemoveHappened(), "Refresh happened"); //$NON-NLS-1$ + assertTrue(fMyPart.hasAddHappened(), "Refresh happened"); //$NON-NLS-1$ Object addedObject= fMyPart.getAddedObject().get(0); Object removedObject= fMyPart.getRemovedObject().get(0); - assertTrue("Correct guy removed", canFindEqualCompoundElement(cp10, new Object[] { removedObject })); //$NON-NLS-1$ - assertEquals("Correct guy added", fInternalPack10, addedObject); //$NON-NLS-1$ + assertTrue(canFindEqualCompoundElement(cp10, new Object[] { removedObject }), "Correct guy removed"); //$NON-NLS-1$ + assertEquals(fInternalPack10, addedObject, "Correct guy added"); //$NON-NLS-1$ } @Test @@ -203,7 +203,7 @@ public void testRemovePackageFromLogicalPackage() throws Exception { fMyPart.pushDisplay(); //assert remove happened (delta worked) - assertFalse("Refresh did not happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ + assertFalse(fMyPart.hasRefreshHappened(), "Refresh did not happened"); //$NON-NLS-1$ } @Test @@ -228,9 +228,9 @@ public void testRemoveCUFromPackageNotLogicalPackage() throws Exception { } private void assertPack81RefreshedOnce() { - assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ - assertTrue("fPack81 not refreshed:\n" + fMyPart.getRefreshedObject(), fMyPart.getRefreshedObject().contains(fPack81)); - assertEquals("Too many refreshes (" + fMyPart.getRefreshedObject().size() + "):\n" + fMyPart.getRefreshedObject(), 1, fMyPart.getRefreshedObject().size()); + assertTrue(fMyPart.hasRefreshHappened(), "Refresh happened"); //$NON-NLS-1$ + assertTrue(fMyPart.getRefreshedObject().contains(fPack81), "fPack81 not refreshed:\n" + fMyPart.getRefreshedObject()); + assertEquals(1, fMyPart.getRefreshedObject().size(), "Too many refreshes (" + fMyPart.getRefreshedObject().size() + "):\n" + fMyPart.getRefreshedObject()); } @Test @@ -251,9 +251,9 @@ public void testAddCUFromPackageNotLogicalPackage() throws Exception { fMyPart.pushDisplay(); assertPack81RefreshedOnce(); - assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ - assertTrue("fPack81 not refreshed:\n" + fMyPart.getRefreshedObject(), fMyPart.getRefreshedObject().contains(fPack81)); - assertEquals("Too many refreshes (" + fMyPart.getRefreshedObject().size() + "):\n" + fMyPart.getRefreshedObject(), 1, fMyPart.getRefreshedObject().size()); + assertTrue(fMyPart.hasRefreshHappened(), "Refresh happened"); //$NON-NLS-1$ + assertTrue(fMyPart.getRefreshedObject().contains(fPack81), "fPack81 not refreshed:\n" + fMyPart.getRefreshedObject()); + assertEquals(1, fMyPart.getRefreshedObject().size(), "Too many refreshes (" + fMyPart.getRefreshedObject().size() + "):\n" + fMyPart.getRefreshedObject()); } @Test @@ -276,7 +276,7 @@ public void testAddFragmentToLogicalPackage() throws Exception { fMyPart.pushDisplay(); //make sure no refresh happened - assertFalse("Refresh did not happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ + assertFalse(fMyPart.hasRefreshHappened(), "Refresh did not happened"); //$NON-NLS-1$ } @Test @@ -295,8 +295,8 @@ public void testAddPackageNotLogicalPackage() throws Exception { //force events from display fMyPart.pushDisplay(); - assertTrue("Add happened", fMyPart.hasAddHappened()); //$NON-NLS-1$ - assertTrue("Correct package added", fMyPart.getAddedObject().contains(test)); //$NON-NLS-1$ + assertTrue(fMyPart.hasAddHappened(), "Add happened"); //$NON-NLS-1$ + assertTrue(fMyPart.getAddedObject().contains(test), "Correct package added"); //$NON-NLS-1$ } @Test @@ -322,12 +322,12 @@ public void testAddPackageToCreateLogicalPackage() throws Exception { fMyPart.pushDisplay(); //assert remove and add happened (delta worked) - assertTrue("Remove and add happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$ - assertTrue("Remove and add happened", fMyPart.hasAddHappened()); //$NON-NLS-1$ + assertTrue(fMyPart.hasRemoveHappened(), "Remove and add happened"); //$NON-NLS-1$ + assertTrue(fMyPart.hasAddHappened(), "Remove and add happened"); //$NON-NLS-1$ Object addedObject= fMyPart.getAddedObject().get(0); Object removedObject= fMyPart.getRemovedObject().get(0); - assertEquals("Correct guy removed", fPack12, removedObject); //$NON-NLS-1$ - assertEquals("Correct guy added", lp1, addedObject); //$NON-NLS-1$ + assertEquals(fPack12, removedObject, "Correct guy removed"); //$NON-NLS-1$ + assertEquals(lp1, addedObject, "Correct guy added"); //$NON-NLS-1$ } @@ -335,7 +335,7 @@ public void testAddPackageToCreateLogicalPackage() throws Exception { /* * @see TestCase#setUp() */ - @Before + @BeforeEach public void setUp() throws Exception { fWorkspace= ResourcesPlugin.getWorkspace(); assertNotNull(fWorkspace); @@ -348,22 +348,22 @@ public void setUp() throws Exception { fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");//$NON-NLS-1$//$NON-NLS-2$ fJProject2= JavaProjectHelper.createJavaProject("TestProject2", "bin");//$NON-NLS-1$//$NON-NLS-2$ - assertNotNull("project1 null", fJProject1);//$NON-NLS-1$ - assertNotNull("project2 null", fJProject2);//$NON-NLS-1$ + assertNotNull(fJProject1, "project1 null");//$NON-NLS-1$ + assertNotNull(fJProject2, "project2 null");//$NON-NLS-1$ //------------set up project #1 : External Jar and zip file------- IPackageFragmentRoot jdk= JavaProjectHelper.addVariableRTJar(fJProject1, "JRE_LIB_TEST", null, null);//$NON-NLS-1$ - assertNotNull("jdk not found", jdk);//$NON-NLS-1$ + assertNotNull(jdk, "jdk not found");//$NON-NLS-1$ //---Create zip file------------------- java.io.File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381); - assertNotNull("junit src not found", junitSrcArchive);//$NON-NLS-1$ - assertTrue("junit src not found", junitSrcArchive.exists());//$NON-NLS-1$ + assertNotNull(junitSrcArchive, "junit src not found");//$NON-NLS-1$ + assertTrue(junitSrcArchive.exists(), "junit src not found");//$NON-NLS-1$ fArchiveFragmentRoot= JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);//$NON-NLS-1$ @@ -371,9 +371,9 @@ public void setUp() throws Exception { fPackJunitSamples= fArchiveFragmentRoot.getPackageFragment("junit.samples");//$NON-NLS-1$ fPackJunitSamplesMoney= fArchiveFragmentRoot.getPackageFragment("junit.samples.money");//$NON-NLS-1$ - assertNotNull("creating fPackJunit", fPackJunit);//$NON-NLS-1$ - assertNotNull("creating fPackJunitSamples", fPackJunitSamples);//$NON-NLS-1$ - assertNotNull("creating fPackJunitSamplesMoney",fPackJunitSamplesMoney);//$NON-NLS-1$ + assertNotNull(fPackJunit, "creating fPackJunit");//$NON-NLS-1$ + assertNotNull(fPackJunitSamples, "creating fPackJunitSamples");//$NON-NLS-1$ + assertNotNull(fPackJunitSamplesMoney,"creating fPackJunitSamplesMoney");//$NON-NLS-1$ fPackJunitSamplesMoney.getCompilationUnit("IMoney.java");//$NON-NLS-1$ fPackJunitSamplesMoney.getCompilationUnit("Money.java");//$NON-NLS-1$ @@ -386,8 +386,8 @@ public void setUp() throws Exception { //----------------Set up internal jar---------------------------- File myInternalJar= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/compoundtest.jar"));//$NON-NLS-1$ - assertNotNull("lib not found", myInternalJar);//$NON-NLS-1$ - assertTrue("lib not found", myInternalJar.exists());//$NON-NLS-1$ + assertNotNull(myInternalJar, "lib not found");//$NON-NLS-1$ + assertTrue(myInternalJar.exists(), "lib not found");//$NON-NLS-1$ fInternalJarRoot= JavaProjectHelper.addLibraryWithImport(fJProject2, Path.fromOSString(myInternalJar.getPath()), null, null); @@ -464,7 +464,7 @@ public void setUpMockView() throws Exception{ /* * @see TestCase#tearDown() */ - @After + @AfterEach public void tearDown() throws Exception { JavaProjectHelper.delete(fJProject1); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewDeltaTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewDeltaTests.java index 0215213bc61..fd1df3d549f 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewDeltaTests.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewDeltaTests.java @@ -13,17 +13,17 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.browsing; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -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.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.File; -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; import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jdt.testplugin.JavaTestPlugin; @@ -110,8 +110,8 @@ public void testRemoveTopLevelFragmentNotLogicalPackage() throws Exception { // Force events from display fMyPart.pushDisplay(); - assertTrue("Remove happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$ - assertTrue("Correct package removed", fMyPart.getRemovedObject().contains(fPack12)); //$NON-NLS-1$ + assertTrue(fMyPart.hasRemoveHappened(), "Remove happened"); //$NON-NLS-1$ + assertTrue(fMyPart.getRemovedObject().contains(fPack12), "Correct package removed"); //$NON-NLS-1$ } @Test @@ -128,7 +128,7 @@ public void testRemoveBottomLevelFragmentNotLogicalPackage() throws Exception { // Force events from display fMyPart.pushDisplay(); - assertFalse("No remove happened, in Logical Package", fMyPart.hasRemoveHappened()); //$NON-NLS-1$ + assertFalse(fMyPart.hasRemoveHappened(), "No remove happened, in Logical Package"); //$NON-NLS-1$ } //This is a bogus test because this situation could never occur @@ -162,15 +162,15 @@ public void testRemoveFragmentInMultiFragmentLogicalPackage() throws Exception { fMyPart.pushDisplay(); // Assert remove happened - assertFalse("Remove happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$ - assertFalse("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ + assertFalse(fMyPart.hasRemoveHappened(), "Remove happened"); //$NON-NLS-1$ + assertFalse(fMyPart.hasRefreshHappened(), "Refresh happened"); //$NON-NLS-1$ // Test life cycle of Logical Package Object parent= fProvider.getParent(ChildCp1); - assertTrue("wrong parent found for logical package after remove", parent instanceof LogicalPackage); + assertTrue(parent instanceof LogicalPackage, "wrong parent found for logical package after remove"); LogicalPackage lp= (LogicalPackage) parent; - assertEquals("PackageFragment removed from logical package", expectedParent, lp); //$NON-NLS-1$ + assertEquals(expectedParent, lp, "PackageFragment removed from logical package"); //$NON-NLS-1$ } @Test @@ -208,16 +208,16 @@ public void testRemoveBottomLevelFragmentInMultiFragmentLogicalPackage() throws fMyPart.pushDisplay(); // Assert delta correct (no remove or refresh, only change to logicalpackage) - assertFalse("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ - assertFalse("Refresh happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$ + assertFalse(fMyPart.hasRefreshHappened(), "Refresh happened"); //$NON-NLS-1$ + assertFalse(fMyPart.hasRemoveHappened(), "Refresh happened"); //$NON-NLS-1$ // Test life cycle of LogicalPackage Object[] child= fProvider.getChildren(ParentCp5); - assertTrue("wrong parent found for logical package after remove", (child.length == 1) && (child[0] instanceof LogicalPackage)); //$NON-NLS-1$ + assertTrue((child.length == 1) && (child[0] instanceof LogicalPackage), "wrong parent found for logical package after remove"); //$NON-NLS-1$ LogicalPackage lp= (LogicalPackage) child[0]; - assertEquals("PackageFragment removed from logical package", expectedChild, lp); //$NON-NLS-1$ + assertEquals(expectedChild, lp, "PackageFragment removed from logical package"); //$NON-NLS-1$ } @Test @@ -253,16 +253,16 @@ public void testRemoveFragmentInTwoFragmentLogicalPackage() throws Exception { fMyPart.pushDisplay(); // Assert remove happened (delta worked) - assertTrue("Refresh happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$ - assertTrue("Refresh happened", fMyPart.hasAddHappened()); //$NON-NLS-1$ + assertTrue(fMyPart.hasRemoveHappened(), "Refresh happened"); //$NON-NLS-1$ + assertTrue(fMyPart.hasAddHappened(), "Refresh happened"); //$NON-NLS-1$ Object addedObject= fMyPart.getAddedObject().get(0); Object removedObject= fMyPart.getRemovedObject().get(0); - assertEquals("Correct guy removed", cp10, removedObject); //$NON-NLS-1$ - assertEquals("Correct guy added", fInternalPack10, addedObject); //$NON-NLS-1$ + assertEquals(cp10, removedObject, "Correct guy removed"); //$NON-NLS-1$ + assertEquals(fInternalPack10, addedObject, "Correct guy added"); //$NON-NLS-1$ // Assert correct children gotten Object[] children= fProvider.getChildren(ParentCp4); - assertTrue("PackageFragment removed from logial package", compareArrays(children, new Object[] { fPack91, fInternalPack10 })); //$NON-NLS-1$ + assertTrue(compareArrays(children, new Object[] { fPack91, fInternalPack10 }), "PackageFragment removed from logial package"); //$NON-NLS-1$ } //-----------------------Add delta test cases---------------------------------- @@ -281,8 +281,8 @@ public void testAddTopLevelFragmentNotLogicalPackage() throws Exception { // Force events from display fMyPart.pushDisplay(); - assertTrue("Add happened", fMyPart.hasAddHappened()); //$NON-NLS-1$ - assertTrue("Correct package added", fMyPart.getAddedObject().contains(test)); //$NON-NLS-1$ + assertTrue(fMyPart.hasAddHappened(), "Add happened"); //$NON-NLS-1$ + assertTrue(fMyPart.getAddedObject().contains(test), "Correct package added"); //$NON-NLS-1$ } @Test @@ -305,7 +305,7 @@ public void testAddFragmentToLogicalPackage() throws Exception { fMyPart.pushDisplay(); // Make sure no refresh happened - assertFalse("Refresh did not happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ + assertFalse(fMyPart.hasRefreshHappened(), "Refresh did not happened"); //$NON-NLS-1$ } @Test @@ -332,9 +332,9 @@ public void testAddCUFromFragmentNotLogicalPackageVisible() throws Exception { // Force events from display fMyPart.pushDisplay(); - assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ - assertTrue("Correct package refreshed", fMyPart.getRefreshedObject().contains(fPack81)); //$NON-NLS-1$ - assertEquals("Correct number of refreshes", 1, fMyPart.getRefreshedObject().size());//$NON-NLS-1$ + assertTrue(fMyPart.hasRefreshHappened(), "Refresh happened"); //$NON-NLS-1$ + assertTrue(fMyPart.getRefreshedObject().contains(fPack81), "Correct package refreshed"); //$NON-NLS-1$ + assertEquals(1, fMyPart.getRefreshedObject().size(), "Correct number of refreshes");//$NON-NLS-1$ } @Test @@ -359,9 +359,9 @@ public void testAddCUFromFragmentNotLogicalPackageNotVisible() throws Exception // Force events from display fMyPart.pushDisplay(); - assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ - assertTrue("Correct package refreshed", fMyPart.getRefreshedObject().contains(cp3)); //$NON-NLS-1$ - assertEquals("Correct number of refreshes", 1, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$ + assertTrue(fMyPart.hasRefreshHappened(), "Refresh happened"); //$NON-NLS-1$ + assertTrue(fMyPart.getRefreshedObject().contains(cp3), "Correct package refreshed"); //$NON-NLS-1$ + assertEquals(1, fMyPart.getRefreshedObject().size(), "Correct number of refreshes"); //$NON-NLS-1$ } @Test @@ -390,9 +390,9 @@ public void testRemoveCUFromFragmentNotLogicalPackage() throws Exception { // Force events from display fMyPart.pushDisplay(); - assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ - assertTrue("Correct package refreshed", fMyPart.getRefreshedObject().contains(fPack81)); //$NON-NLS-1$ - assertEquals("Correct number of refreshes", 1, fMyPart.getRefreshedObject().size());//$NON-NLS-1$ + assertTrue(fMyPart.hasRefreshHappened(), "Refresh happened"); //$NON-NLS-1$ + assertTrue(fMyPart.getRefreshedObject().contains(fPack81), "Correct package refreshed"); //$NON-NLS-1$ + assertEquals(1, fMyPart.getRefreshedObject().size(), "Correct number of refreshes");//$NON-NLS-1$ } @Test @@ -417,9 +417,9 @@ public void testRemoveCUFromFragmentNotLogicalPackageWithParentNotVisible() thro // Force events from display fMyPart.pushDisplay(); - assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ - assertTrue("Correct package refreshed", fMyPart.getRefreshedObject().contains(cp3)); //$NON-NLS-1$ - assertEquals("Correct number of refreshes", 1, fMyPart.getRefreshedObject().size());//$NON-NLS-1$ + assertTrue(fMyPart.hasRefreshHappened(), "Refresh happened"); //$NON-NLS-1$ + assertTrue(fMyPart.getRefreshedObject().contains(cp3), "Correct package refreshed"); //$NON-NLS-1$ + assertEquals(1, fMyPart.getRefreshedObject().size(), "Correct number of refreshes");//$NON-NLS-1$ } @Test @@ -443,14 +443,14 @@ public void testAddBottomLevelFragmentNotLogicalPackage() throws Exception { // Force events from display fMyPart.pushDisplay(); - assertTrue("Add happened", fMyPart.hasAddHappened()); //$NON-NLS-1$ - assertTrue("Corrent package added", fMyPart.getAddedObject().contains(test)); //$NON-NLS-1$ + assertTrue(fMyPart.hasAddHappened(), "Add happened"); //$NON-NLS-1$ + assertTrue(fMyPart.getAddedObject().contains(test), "Corrent package added"); //$NON-NLS-1$ } /* * @see TestCase#setUp() */ - @Before + @BeforeEach public void setUp() throws Exception { fWorkspace= ResourcesPlugin.getWorkspace(); assertNotNull(fWorkspace); @@ -462,12 +462,12 @@ public void setUp() throws Exception { //------------set up project ------------------------------ fJProject= JavaProjectHelper.createJavaProject("TestProject2", "bin"); //$NON-NLS-1$//$NON-NLS-2$ - assertNotNull("project null", fJProject); //$NON-NLS-1$ + assertNotNull(fJProject, "project null"); //$NON-NLS-1$ //----------------Set up internal jar---------------------------- File myInternalJar= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/compoundtest.jar")); //$NON-NLS-1$ - assertNotNull("lib not found", myInternalJar); //$NON-NLS-1$ - assertTrue("lib not found", myInternalJar.exists()); //$NON-NLS-1$ + assertNotNull(myInternalJar, "lib not found"); //$NON-NLS-1$ + assertTrue(myInternalJar.exists(), "lib not found"); //$NON-NLS-1$ fInternalJarRoot= JavaProjectHelper.addLibraryWithImport(fJProject, Path.fromOSString(myInternalJar.getPath()), null, null); fInternalJarRoot.getPackageFragment(""); //$NON-NLS-1$ fInternalPack3= fInternalJarRoot.getPackageFragment("pack3"); //$NON-NLS-1$ @@ -542,7 +542,7 @@ public void setUpMockView() throws Exception { /* * @see TestCase#tearDown() */ - @After + @AfterEach public void tearDown() throws Exception { JavaProjectHelper.delete(fJProject); fProvider.inputChanged(null, null, null); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathModifierActionEnablementTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathModifierActionEnablementTest.java index fe10a251d96..b6cb5a70385 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathModifierActionEnablementTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathModifierActionEnablementTest.java @@ -13,18 +13,18 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.buildpath; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -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; import org.eclipse.jdt.testplugin.JavaProjectHelper; @@ -107,7 +107,7 @@ public class BuildpathModifierActionEnablementTest { * |- NormalFolder */ - @Before + @BeforeEach public void setUp() throws Exception { fActions= createActions(); fProject= createProject(); @@ -138,7 +138,7 @@ private BuildpathModifierAction[] createActions() { }; } - @After + @AfterEach public void tearDown() throws Exception { fProject.getProject().delete(true, true, null); } @@ -146,9 +146,9 @@ public void tearDown() throws Exception { private void assertOnlyEnabled(IAction[] enabledActions) { for (BuildpathModifierAction action : fActions) { if (action.isEnabled()) { - assertTrue(action.getText() + " is enabled but should not be.", contains(enabledActions, action)); + assertTrue(contains(enabledActions, action), action.getText() + " is enabled but should not be."); } else { - assertFalse(action.getText() + " is disabled but should not be.", contains(enabledActions, action)); + assertFalse(contains(enabledActions, action), action.getText() + " is disabled but should not be."); } } } @@ -164,7 +164,7 @@ private boolean contains(IAction[] actions, IAction action) { private void assertAllDisabled() { for (BuildpathModifierAction action : fActions) { - assertFalse(action.getText() + " is enabled but should not be.", action.isEnabled()); + assertFalse(action.isEnabled(), action.getText() + " is enabled but should not be."); } } diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathModifierActionTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathModifierActionTest.java index 2b7be9d3a51..275e238147b 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathModifierActionTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathModifierActionTest.java @@ -13,17 +13,17 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.buildpath; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; -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.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.util.List; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.eclipse.jdt.testplugin.JavaProjectHelper; @@ -54,7 +54,7 @@ public class BuildpathModifierActionTest { private IJavaProject fJavaProject; - @After + @AfterEach public void tearDown() throws Exception { if (fJavaProject != null) { JavaProjectHelper.delete(fJavaProject); @@ -88,18 +88,18 @@ private static void assertDeltaResources(BuildpathDelta delta, IPath[] createdFo for (int i= 0; i < createdPaths.length; i++) { IPath path= createdPaths[i]; if (createdResources[i] instanceof IFile) { - assertTrue("File " + createdResources[i] + " is unexpected created", contains(createdFiles, path)); + assertTrue(contains(createdFiles, path), "File " + createdResources[i] + " is unexpected created"); } else if (createdResources[i] instanceof IFolder) { - assertTrue("Folder " + createdResources[i] + " is unexpected created", contains(createdFolders, path)); + assertTrue(contains(createdFolders, path), "Folder " + createdResources[i] + " is unexpected created"); } else { fail("Resource " + createdResources[i] + " is nor file nor folder."); } } for (IPath createdFolder : createdFolders) { - assertTrue("Folder at " + createdFolder + " was not created", contains(createdPaths, createdFolder)); + assertTrue(contains(createdPaths, createdFolder), "Folder at " + createdFolder + " was not created"); } for (IPath createdFile : createdFiles) { - assertTrue("File at " + createdFile + " was not created", contains(createdPaths, createdFile)); + assertTrue(contains(createdPaths, createdFile), "File at " + createdFile + " was not created"); } IResource[] deletedResources= delta.getDeletedResources(); @@ -111,24 +111,24 @@ private static void assertDeltaResources(BuildpathDelta delta, IPath[] createdFo for (int i= 0; i < deletedPaths.length; i++) { IPath path= deletedPaths[i]; if (deletedResources[i] instanceof IFile) { - assertTrue("File " + deletedResources[i] + " is unexpected removed", contains(removedFiles, path)); + assertTrue(contains(removedFiles, path), "File " + deletedResources[i] + " is unexpected removed"); } else if (deletedResources[i] instanceof IFolder) { - assertTrue("Folder " + deletedResources[i] + " is unexpected removed", contains(removedFolders, path)); + assertTrue(contains(removedFolders, path), "Folder " + deletedResources[i] + " is unexpected removed"); } else { fail("Resource " + deletedResources[i] + " is nor file nor folder."); } } for (IPath removedFolder : removedFolders) { - assertTrue("Folder at " + removedFolder + " was not removed", contains(deletedPaths, removedFolder)); + assertTrue(contains(deletedPaths, removedFolder), "Folder at " + removedFolder + " was not removed"); } for (IPath removedFile : removedFiles) { - assertTrue("File at " + removedFile + " was not removed", contains(deletedPaths, removedFile)); + assertTrue(contains(deletedPaths, removedFile), "File at " + removedFile + " was not removed"); } } private static void assertDeltaRemovedEntries(BuildpathDelta delta, IPath[] paths) { List removedEntries= delta.getRemovedEntries(); - assertEquals("Expected " + paths.length + " is " + removedEntries.size(), removedEntries.size(), paths.length); + assertEquals(removedEntries.size(), paths.length, "Expected " + paths.length + " is " + removedEntries.size()); IPath[] removed= new IPath[removedEntries.size()]; int i= 0; for (CPListElement element : removedEntries) { @@ -136,16 +136,16 @@ private static void assertDeltaRemovedEntries(BuildpathDelta delta, IPath[] path i++; } for (IPath path : paths) { - assertTrue("Entry " + path + " was not removed", contains(removed, path)); + assertTrue(contains(removed, path), "Entry " + path + " was not removed"); } for (IPath removed1 : removed) { - assertTrue("Entry " + removed1 + " was removed", contains(paths, removed1)); + assertTrue(contains(paths, removed1), "Entry " + removed1 + " was removed"); } } private static void assertDeltaAddedEntries(BuildpathDelta delta, IPath[] paths) { List addedEntries= delta.getAddedEntries(); - assertEquals("Expected " + paths.length + " is " + addedEntries.size(), addedEntries.size(), paths.length); + assertEquals(addedEntries.size(), paths.length, "Expected " + paths.length + " is " + addedEntries.size()); IPath[] added= new IPath[addedEntries.size()]; int i= 0; for (CPListElement element : addedEntries) { @@ -153,10 +153,10 @@ private static void assertDeltaAddedEntries(BuildpathDelta delta, IPath[] paths) i++; } for (IPath path : paths) { - assertTrue("Entry " + path + " was not added", contains(added, path)); + assertTrue(contains(added, path), "Entry " + path + " was not added"); } for (IPath add : added) { - assertTrue("Entry " + add + " was added", contains(paths, add)); + assertTrue(contains(paths, add), "Entry " + add + " was added"); } } @@ -171,11 +171,11 @@ private static boolean contains(IPath[] paths, IPath path) { private static void assertDeltaDefaultOutputFolder(BuildpathDelta delta, IPath expectedLocation) { IPath location= delta.getDefaultOutputLocation(); - assertTrue("Default output location is " + location + " expected was " + expectedLocation, location.equals(expectedLocation)); + assertTrue(location.equals(expectedLocation), "Default output location is " + location + " expected was " + expectedLocation); } private static void assertNumberOfEntries(IClasspathEntry[] entries, int expected) { - assertEquals("Expected count was " + expected + " is " + entries.length, expected, entries.length); + assertEquals(expected, entries.length, "Expected count was " + expected + " is " + entries.length); } @Test @@ -245,7 +245,7 @@ public void testAddExternalJar02AddMuiltiLibsTwice() throws Exception { cpProject= CPJavaProject.createFromExisting(fJavaProject); IStatus status= ClasspathModifier.checkAddExternalJarsPrecondition(jarPaths, cpProject); - assertEquals(status.getMessage(), IStatus.INFO, status.getSeverity()); + assertEquals(IStatus.INFO, status.getSeverity(), status.getMessage()); BuildpathDelta delta= ClasspathModifier.addExternalJars(jarPaths, cpProject); assertDeltaResources(delta, new IPath[0], new IPath[0], new IPath[0], new IPath[0]); @@ -299,7 +299,7 @@ public void testEditOutputFolder01SetOutputFolderForSourceFolder() throws Except CPJavaProject cpProject= CPJavaProject.createFromExisting(fJavaProject); CPListElement element= cpProject.getCPElement(CPListElement.createFromExisting(src.getRawClasspathEntry(), fJavaProject)); IStatus status= ClasspathModifier.checkSetOutputLocationPrecondition(element, outputPath, false, cpProject); - assertNotEquals(status.getMessage(), IStatus.ERROR, status.getSeverity()); + assertNotEquals(IStatus.ERROR, status.getSeverity(), status.getMessage()); BuildpathDelta delta= ClasspathModifier.setOutputLocation(element, outputPath, false, cpProject); assertDeltaResources(delta, new IPath[] {outputPath}, new IPath[0], new IPath[0], new IPath[0]); @@ -314,7 +314,7 @@ public void testEditOutputFolder01SetOutputFolderForSourceFolder() throws Except IClasspathEntry entry= classpathEntries[1]; assertSame(src.getRawClasspathEntry(), entry); IPath location= entry.getOutputLocation(); - assertTrue("Output path is " + location + " expected was " + outputPath, outputPath.equals(location)); + assertTrue(outputPath.equals(location), "Output path is " + location + " expected was " + outputPath); } @Test @@ -333,7 +333,7 @@ public void testEditOutputFolder02RemoveProjectAsSourceFolder() throws Exception CPJavaProject cpProject= CPJavaProject.createFromExisting(fJavaProject); CPListElement element= cpProject.getCPElement(CPListElement.createFromExisting(src.getRawClasspathEntry(), fJavaProject)); IStatus status= ClasspathModifier.checkSetOutputLocationPrecondition(element, outputPath, false, cpProject); - assertEquals(status.getMessage(), IStatus.INFO, status.getSeverity()); + assertEquals(IStatus.INFO, status.getSeverity(), status.getMessage()); BuildpathDelta delta= ClasspathModifier.setOutputLocation(element, outputPath, false, cpProject); assertDeltaResources(delta, new IPath[] {outputPath}, new IPath[0], new IPath[0], new IPath[0]); @@ -343,14 +343,14 @@ public void testEditOutputFolder02RemoveProjectAsSourceFolder() throws Exception ClasspathModifier.commitClassPath(cpProject, null); - assertTrue("Default output folder was not set to bin", fJavaProject.getOutputLocation().equals(fJavaProject.getPath().append(DEFAULT_OUTPUT_FOLDER_NAME))); + assertTrue(fJavaProject.getOutputLocation().equals(fJavaProject.getPath().append(DEFAULT_OUTPUT_FOLDER_NAME)), "Default output folder was not set to bin"); IClasspathEntry[] classpathEntries= fJavaProject.getRawClasspath(); assertNumberOfEntries(classpathEntries, 2); IClasspathEntry entry= classpathEntries[1]; assertSame(src.getRawClasspathEntry(), entry); IPath location= entry.getOutputLocation(); - assertTrue("Output path is " + location + " expected was " + outputPath, outputPath.equals(location)); + assertTrue(outputPath.equals(location), "Output path is " + location + " expected was " + outputPath); } @Test @@ -364,7 +364,7 @@ public void testEditOutputFolder03ExcludeOutputFolderSelf() throws Exception { CPJavaProject cpProject= CPJavaProject.createFromExisting(fJavaProject); CPListElement element= cpProject.getCPElement(CPListElement.createFromExisting(src1.getRawClasspathEntry(), fJavaProject)); IStatus status= ClasspathModifier.checkSetOutputLocationPrecondition(element, outputPath, false, cpProject); - assertNotEquals(status.getMessage(), IStatus.ERROR, status.getSeverity()); + assertNotEquals(IStatus.ERROR, status.getSeverity(), status.getMessage()); BuildpathDelta delta= ClasspathModifier.setOutputLocation(element, outputPath, false, cpProject); assertDeltaResources(delta, new IPath[] {outputPath}, new IPath[0], new IPath[0], new IPath[0]); @@ -379,7 +379,7 @@ public void testEditOutputFolder03ExcludeOutputFolderSelf() throws Exception { IClasspathEntry entry= classpathEntries[1]; assertSame(src1.getRawClasspathEntry(), entry); IPath location= entry.getOutputLocation(); - assertTrue("Output path is " + location + " expected was " + outputPath, outputPath.equals(location)); + assertTrue(outputPath.equals(location), "Output path is " + location + " expected was " + outputPath); IPath[] exclusionPatterns= entry.getExclusionPatterns(); assertEquals(1, exclusionPatterns.length); assertEquals("bin/", exclusionPatterns[0].toString()); @@ -397,7 +397,7 @@ public void testEditOutputFolder03ExcludeOutputFolderOther() throws Exception { CPJavaProject cpProject= CPJavaProject.createFromExisting(fJavaProject); CPListElement element= cpProject.getCPElement(CPListElement.createFromExisting(src1.getRawClasspathEntry(), fJavaProject)); IStatus status= ClasspathModifier.checkSetOutputLocationPrecondition(element, outputPath, false, cpProject); - assertNotEquals(status.getMessage(), IStatus.ERROR, status.getSeverity()); + assertNotEquals(IStatus.ERROR, status.getSeverity(), status.getMessage()); BuildpathDelta delta= ClasspathModifier.setOutputLocation(element, outputPath, false, cpProject); assertDeltaResources(delta, new IPath[] {outputPath}, new IPath[0], new IPath[0], new IPath[0]); @@ -412,7 +412,7 @@ public void testEditOutputFolder03ExcludeOutputFolderOther() throws Exception { IClasspathEntry entry= classpathEntries[1]; assertSame(src1.getRawClasspathEntry(), entry); IPath location= entry.getOutputLocation(); - assertTrue("Output path is " + location + " expected was " + outputPath, outputPath.equals(location)); + assertTrue(outputPath.equals(location), "Output path is " + location + " expected was " + outputPath); entry= classpathEntries[2]; assertSame(src2.getRawClasspathEntry(), entry); @@ -438,7 +438,7 @@ public void testEditOutputFolder04RemoveProjectAndExcludeOutput() throws Excepti CPJavaProject cpProject= CPJavaProject.createFromExisting(fJavaProject); CPListElement element= cpProject.getCPElement(CPListElement.createFromExisting(src1.getRawClasspathEntry(), fJavaProject)); IStatus status= ClasspathModifier.checkSetOutputLocationPrecondition(element, outputPath, false, cpProject); - assertEquals(status.getMessage(), IStatus.INFO, status.getSeverity()); + assertEquals(IStatus.INFO, status.getSeverity(), status.getMessage()); BuildpathDelta delta= ClasspathModifier.setOutputLocation(element, outputPath, false, cpProject); assertDeltaResources(delta, new IPath[] {outputPath}, new IPath[0], new IPath[0], new IPath[0]); @@ -448,14 +448,14 @@ public void testEditOutputFolder04RemoveProjectAndExcludeOutput() throws Excepti ClasspathModifier.commitClassPath(cpProject, null); - assertTrue("Default output folder was not set to bin", fJavaProject.getOutputLocation().equals(fJavaProject.getPath().append(DEFAULT_OUTPUT_FOLDER_NAME))); + assertTrue(fJavaProject.getOutputLocation().equals(fJavaProject.getPath().append(DEFAULT_OUTPUT_FOLDER_NAME)), "Default output folder was not set to bin"); IClasspathEntry[] classpathEntries= fJavaProject.getRawClasspath(); assertNumberOfEntries(classpathEntries, 3); IClasspathEntry entry= classpathEntries[1]; assertSame(src1.getRawClasspathEntry(), entry); IPath location= entry.getOutputLocation(); - assertTrue("Output path is " + location + " expected was " + outputPath, outputPath.equals(location)); + assertTrue(outputPath.equals(location), "Output path is " + location + " expected was " + outputPath); entry= classpathEntries[2]; assertSame(src2.getRawClasspathEntry(), entry); @@ -476,7 +476,7 @@ public void testEditOutputFolder05CannotOutputToSource() throws Exception { CPJavaProject cpProject= CPJavaProject.createFromExisting(fJavaProject); CPListElement element= cpProject.getCPElement(CPListElement.createFromExisting(src1.getRawClasspathEntry(), fJavaProject)); IStatus status= ClasspathModifier.checkSetOutputLocationPrecondition(element, outputPath, false, cpProject); - assertEquals(status.getMessage(), IStatus.ERROR, status.getSeverity()); + assertEquals(IStatus.ERROR, status.getSeverity(), status.getMessage()); } @Test @@ -490,7 +490,7 @@ public void testEditOutputFolderBug153068() throws Exception { CPJavaProject cpProject= CPJavaProject.createFromExisting(fJavaProject); CPListElement element= cpProject.getCPElement(CPListElement.createFromExisting(src.getRawClasspathEntry(), fJavaProject)); IStatus status= ClasspathModifier.checkSetOutputLocationPrecondition(element, outputPath, false, cpProject); - assertEquals(status.getMessage(), IStatus.ERROR, status.getSeverity()); + assertEquals(IStatus.ERROR, status.getSeverity(), status.getMessage()); } @Test @@ -511,7 +511,7 @@ public void testEditOutputFolderBug154044() throws Exception { cpProject= CPJavaProject.createFromExisting(fJavaProject); element= cpProject.getCPElement(CPListElement.createFromExisting(src1.getRawClasspathEntry(), fJavaProject)); IStatus status= ClasspathModifier.checkSetOutputLocationPrecondition(element, outputPath, false, cpProject); - assertTrue(status.getMessage(), status.isOK()); + assertTrue(status.isOK(), status.getMessage()); BuildpathDelta delta= ClasspathModifier.setOutputLocation(element, outputPath, false, cpProject); assertDeltaResources(delta, new IPath[] {outputPath}, new IPath[] {oldOutputPath}, new IPath[0], new IPath[0]); @@ -526,10 +526,10 @@ public void testEditOutputFolderBug154044() throws Exception { IClasspathEntry entry= classpathEntries[1]; assertSame(src1.getRawClasspathEntry(), entry); IPath location= entry.getOutputLocation(); - assertTrue("Output path is " + location + " expected was " + outputPath, outputPath.equals(location)); + assertTrue(outputPath.equals(location), "Output path is " + location + " expected was " + outputPath); IPath[] exclusionPatterns= entry.getExclusionPatterns(); assertEquals(1, exclusionPatterns.length); - assertEquals(exclusionPatterns[0].toString(), "sub/newBin/", exclusionPatterns[0].toString()); + assertEquals("sub/newBin/", exclusionPatterns[0].toString(), exclusionPatterns[0].toString()); } @Test @@ -549,7 +549,7 @@ public void testEditOutputFolderBug154044OldIsProject() throws Exception { cpProject= CPJavaProject.createFromExisting(fJavaProject); element= cpProject.getCPElement(CPListElement.createFromExisting(p01.getRawClasspathEntry(), fJavaProject)); IStatus status= ClasspathModifier.checkSetOutputLocationPrecondition(element, outputPath, false, cpProject); - assertTrue(status.getMessage(), status.isOK()); + assertTrue(status.isOK(), status.getMessage()); BuildpathDelta delta= ClasspathModifier.setOutputLocation(element, outputPath, false, cpProject); assertDeltaResources(delta, new IPath[] {outputPath}, new IPath[0], new IPath[0], new IPath[0]); @@ -564,10 +564,10 @@ public void testEditOutputFolderBug154044OldIsProject() throws Exception { IClasspathEntry entry= classpathEntries[1]; assertSame(p01.getRawClasspathEntry(), entry); IPath location= entry.getOutputLocation(); - assertTrue("Output path is " + location + " expected was " + outputPath, outputPath.equals(location)); + assertTrue(outputPath.equals(location), "Output path is " + location + " expected was " + outputPath); IPath[] exclusionPatterns= entry.getExclusionPatterns(); assertEquals(1, exclusionPatterns.length); - assertEquals(exclusionPatterns[0].toString(), "bin/", exclusionPatterns[0].toString()); + assertEquals("bin/", exclusionPatterns[0].toString(), exclusionPatterns[0].toString()); } @Test @@ -588,7 +588,7 @@ public void testEditOutputFolderBug154044DonotDeleteDefaultOutputFolder() throws cpProject= CPJavaProject.createFromExisting(fJavaProject); element= cpProject.getCPElement(CPListElement.createFromExisting(src1.getRawClasspathEntry(), fJavaProject)); IStatus status= ClasspathModifier.checkSetOutputLocationPrecondition(element, outputPath, false, cpProject); - assertTrue(status.getMessage(), status.isOK()); + assertTrue(status.isOK(), status.getMessage()); BuildpathDelta delta= ClasspathModifier.setOutputLocation(element, outputPath, false, cpProject); assertDeltaResources(delta, new IPath[] {outputPath}, new IPath[0], new IPath[0], new IPath[0]); @@ -603,7 +603,7 @@ public void testEditOutputFolderBug154044DonotDeleteDefaultOutputFolder() throws IClasspathEntry entry= classpathEntries[1]; assertSame(src1.getRawClasspathEntry(), entry); IPath location= entry.getOutputLocation(); - assertTrue("Output path is " + location + " expected was " + outputPath, outputPath.equals(location)); + assertTrue(outputPath.equals(location), "Output path is " + location + " expected was " + outputPath); IPath[] exclusionPatterns= entry.getExclusionPatterns(); assertEquals(0, exclusionPatterns.length); } @@ -624,7 +624,7 @@ public void testEditOutputFolderBug154196() throws Exception { cpProject= CPJavaProject.createFromExisting(fJavaProject); element= cpProject.getCPElement(CPListElement.createFromExisting(src1.getRawClasspathEntry(), fJavaProject)); IStatus status= ClasspathModifier.checkSetOutputLocationPrecondition(element, null, false, cpProject); - assertTrue(status.getMessage(), status.isOK()); + assertTrue(status.isOK(), status.getMessage()); BuildpathDelta delta= ClasspathModifier.setOutputLocation(element, null, false, cpProject); assertDeltaResources(delta, new IPath[0], new IPath[] {oldOutputPath}, new IPath[0], new IPath[0]); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathProblemQuickFixTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathProblemQuickFixTest.java index a06af9dd560..1ac654ff291 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathProblemQuickFixTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathProblemQuickFixTest.java @@ -13,15 +13,15 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.buildpath; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Arrays; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.eclipse.jdt.testplugin.JavaProjectHelper; @@ -52,7 +52,7 @@ public class BuildpathProblemQuickFixTest { private IJavaProject fJavaProject2; - @After + @AfterEach public void tearDown() throws Exception { if (fJavaProject1 != null) { JavaProjectHelper.delete(fJavaProject1); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/CPUserLibraryTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/CPUserLibraryTest.java index 75675c4eb8e..6389e7d67a8 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/CPUserLibraryTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/CPUserLibraryTest.java @@ -13,13 +13,13 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.buildpath; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; @@ -79,7 +79,7 @@ public void testUserLibrarySorting() { String result = Arrays.stream(sortedChildren) .map(e -> ((CPUserLibraryElement)e).getName()) .collect(Collectors.joining(":")); - assertEquals("Unexpected element", "ALIB:BLIB:CLIB", result); + assertEquals("ALIB:BLIB:CLIB", result, "Unexpected element"); } finally { parent.dispose(); } diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/ClassPathElementsOrderTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/ClassPathElementsOrderTest.java index db53a47582d..ccd303fb46c 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/ClassPathElementsOrderTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/ClassPathElementsOrderTest.java @@ -13,14 +13,14 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.buildpath; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.osgi.service.prefs.BackingStoreException; import org.eclipse.core.runtime.CoreException; @@ -52,7 +52,7 @@ public class ClassPathElementsOrderTest { private static final String NEW_JAR_PATH= "/data/test.jar"; - @Before + @BeforeEach public void setUp() throws CoreException, BackingStoreException { IWorkspaceRoot wsRoot= ResourcesPlugin.getWorkspace().getRoot(); IProject genProj= wsRoot.getProject("java proj"); @@ -94,14 +94,14 @@ public void testClassPathOrder() { LibrariesWorkbookPage page= new LibrariesWorkbookPage(classPathList, null); page.init(javaProject); CPListElement cpElement= new CPListElement(javaProject, IClasspathEntry.CPE_LIBRARY, new Path(NEW_JAR_PATH), null); - assertEquals("There should be 2 classpath elements before adding class path element", 2, classPathList.getElements().size()); - assertEquals("java container should be at the top", cont1, classPathList.getElements().get(0)); - assertEquals("src should be at position 1", src1, classPathList.getElements().get(1)); + assertEquals(2, classPathList.getElements().size(), "There should be 2 classpath elements before adding class path element"); + assertEquals(cont1, classPathList.getElements().get(0), "java container should be at the top"); + assertEquals(src1, classPathList.getElements().get(1), "src should be at position 1"); page.addElement(cpElement); - assertEquals("There should be 3 classpath elements after adding class path element", 3, classPathList.getElements().size()); - assertEquals("java container should be at the top", cont1, classPathList.getElements().get(0)); - assertEquals("src should be at position 1", src1, classPathList.getElements().get(1)); - assertEquals("newly added class path entry must be at the end of the list", NEW_JAR_PATH, classPathList.getElements().get(2).getPath().toString()); + assertEquals(3, classPathList.getElements().size(), "There should be 3 classpath elements after adding class path element"); + assertEquals(cont1, classPathList.getElements().get(0), "java container should be at the top"); + assertEquals(src1, classPathList.getElements().get(1), "src should be at position 1"); + assertEquals(NEW_JAR_PATH, classPathList.getElements().get(2).getPath().toString(), "newly added class path entry must be at the end of the list"); } /** @@ -131,14 +131,14 @@ public void testIntegrationClassPathOrderAddingLibrary() { classPathList.setElements(elements); TestableLibrariesWorkBookPage page= new TestableLibrariesWorkBookPage(classPathList, null); page.init(javaProject); - assertEquals("There should be 6 classpath elements before adding external jar", 6, classPathList.getElements().size()); - assertEquals("java container should be at the top", cont1, classPathList.getElements().get(0)); - assertEquals("src should be at position 2", src1, classPathList.getElements().get(2)); + assertEquals(6, classPathList.getElements().size(), "There should be 6 classpath elements before adding external jar"); + assertEquals(cont1, classPathList.getElements().get(0), "java container should be at the top"); + assertEquals(src1, classPathList.getElements().get(2), "src should be at position 2"); page.addExternalJar(); - assertEquals("There should be 7 classpath elements after adding external jar", 7, classPathList.getElements().size()); - assertEquals("java container should be at the top", cont1, classPathList.getElements().get(0)); - assertEquals("src should be at position 2", src1, classPathList.getElements().get(2)); - assertEquals("newly added jar must be at the end of the list", NEW_JAR_PATH, classPathList.getElements().get(6).getPath().toString()); + assertEquals(7, classPathList.getElements().size(), "There should be 7 classpath elements after adding external jar"); + assertEquals(cont1, classPathList.getElements().get(0), "java container should be at the top"); + assertEquals(src1, classPathList.getElements().get(2), "src should be at position 2"); + assertEquals(NEW_JAR_PATH, classPathList.getElements().get(6).getPath().toString(), "newly added jar must be at the end of the list"); } public class TestableLibrariesWorkBookPage extends LibrariesWorkbookPage {