From fbedc16e678d2885825a2024b03b27d419329745 Mon Sep 17 00:00:00 2001 From: Carsten Hammer Date: Mon, 28 Oct 2024 11:43:41 +0100 Subject: [PATCH] and even more tests --- .../packageview/ContentProviderTests1.java | 90 +++++++-------- .../packageview/ContentProviderTests2.java | 58 +++++----- .../packageview/ContentProviderTests3.java | 104 +++++++++--------- .../packageview/ContentProviderTests4.java | 60 +++++----- .../packageview/ContentProviderTests5.java | 20 ++-- .../packageview/ContentProviderTests6.java | 44 ++++---- .../packageview/ContentProviderTests7.java | 22 ++-- .../HierarchicalContentProviderTests.java | 20 ++-- .../tests/packageview/PackageCacheTest.java | 32 +++--- .../PackageExplorerShowInTests.java | 12 +- .../WorkingSetDropAdapterTest.java | 14 +-- .../refactoring/IsCompletelySelectedTest.java | 16 +-- .../tests/refactoring/ParentCheckerTest.java | 20 ++-- 13 files changed, 257 insertions(+), 255 deletions(-) diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests1.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests1.java index 71436e6fcab..333893ec06c 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests1.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests1.java @@ -13,15 +13,15 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.packageview; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; -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,48 +105,48 @@ public class ContentProviderTests1 { public void testGetChildrenProjectWithSourceFolders() throws Exception { Object[] expectedChildren= new Object[]{fRoot1, fDotClasspathFile, dotSettings, fDotProjectFile}; Object[] actualChildren= fProvider.getChildren(fJProject2); - 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 public void testGetChildrentMidLevelFragment() throws Exception { Object[] expectedChildren= new Object[]{fPack4, fPack5}; Object[] actualChildren= fProvider.getChildren(fPack3); - 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[]{fCU1}; Object[] actualChildren= fProvider.getChildren(fPack2); - 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 testGetChildrenMidLevelFragmentInArchive() throws Exception { Object[] expectedChildren= new Object[]{fPackJunitSamplesMoney, fCUAllTests, fCUSimpleTest, fCUVectorTest }; Object[] actualChildren= fProvider.getChildren(fPackJunitSamples); - assertTrue("wrong chidren found for mid level PackageFragment in Archive", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(actualChildren, expectedChildren), "wrong chidren found for mid level PackageFragment in Archive");//$NON-NLS-1$ } @Test public void testGetChildrenBottomLevelFragmentInArchive() throws Exception { Object[] expectedChildren= new Object[]{fCUIMoney, fCUMoney, fCUMoneyBag, fCUMoneyTest}; 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[] { fPack1, fPack2, fPack3, fRoot1.getPackageFragment("")};//$NON-NLS-1$ 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----------------------------- @@ -154,35 +154,35 @@ public void testGetChildrenSourceFolder() throws Exception { @Test public void testGetParentArchive() throws Exception { Object parent= fProvider.getParent(fArchiveFragmentRoot); - assertSame("Wrong parent found for PackageFragmentRoot Archive", parent, fJProject1);//$NON-NLS-1$ + assertSame(parent, fJProject1, "Wrong parent found for PackageFragmentRoot Archive");//$NON-NLS-1$ } @Test 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 public void testGetParentTopLevelFragment() throws Exception { Object expectedParent= fRoot1; Object actualParent= fProvider.getParent(fPack3); - 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$ } @Test public void testGetParentMidLevelFragment() throws Exception { Object expectedParent= fPack3; Object actualParent= fProvider.getParent(fPack4); - 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$ } @Test @@ -195,9 +195,9 @@ public void testDeleteBottomLevelFragment() throws Exception { // Force events from dispaly while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {} - assertTrue("Remove happened", fMyPart.hasRemoveHappened());//$NON-NLS-1$ - assertTrue("Correct Remove", fMyPart.getRemovedObjects().contains(fPack2));//$NON-NLS-1$ - assertEquals("No refreshes", 0, fMyPart.getRefreshedObject().size());//$NON-NLS-1$ + assertTrue(fMyPart.hasRemoveHappened(), "Remove happened");//$NON-NLS-1$ + assertTrue(fMyPart.getRemovedObjects().contains(fPack2), "Correct Remove");//$NON-NLS-1$ + assertEquals(0, fMyPart.getRefreshedObject().size(), "No refreshes");//$NON-NLS-1$ } @Test @@ -212,9 +212,9 @@ public void testAddBottomLevelFragment() throws Exception { // Force events from dispaly while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {} - assertTrue("Add happened", fMyPart.hasAddHappened()); //$NON-NLS-1$ - assertEquals("Correct Add", test, fMyPart.getAddedObject()); //$NON-NLS-1$ - assertEquals("No refreshes", 0, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$ + assertTrue(fMyPart.hasAddHappened(), "Add happened"); //$NON-NLS-1$ + assertEquals(test, fMyPart.getAddedObject(), "Correct Add"); //$NON-NLS-1$ + assertEquals(0, fMyPart.getRefreshedObject().size(), "No refreshes"); //$NON-NLS-1$ } @Test @@ -227,7 +227,7 @@ public void testChangedTopLevelPackageFragment() throws Exception { // Force events from display while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {} - assertEquals("No refresh happened", 0, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$ + assertEquals(0, fMyPart.getRefreshedObject().size(), "No refresh happened"); //$NON-NLS-1$ } @Test @@ -241,7 +241,7 @@ public void testChangeBottomLevelPackageFragment() throws Exception { // Force events from display while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {} - assertEquals("No refresh happened", 0, fMyPart.getRefreshedObject().size());//$NON-NLS-1$ + assertEquals(0, fMyPart.getRefreshedObject().size(), "No refresh happened");//$NON-NLS-1$ } @Test @@ -255,7 +255,7 @@ public void testRemoveCUsFromPackageFragment() throws Exception { while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {} // removing more than one CU now results in a refresh. - assertEquals("One refresh", 1, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$ + assertEquals(1, fMyPart.getRefreshedObject().size(), "One refresh"); //$NON-NLS-1$ } @Test @@ -268,9 +268,9 @@ public void testRemoveCUFromPackageFragment() throws Exception { // Force events from display while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {} - assertTrue("Remove happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$ - assertTrue("Correct refresh", fMyPart.getRemovedObjects().contains(fCU2)); //$NON-NLS-1$ - assertEquals("No refreshes", 0, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$ + assertTrue(fMyPart.hasRemoveHappened(), "Remove happened"); //$NON-NLS-1$ + assertTrue(fMyPart.getRemovedObjects().contains(fCU2), "Correct refresh"); //$NON-NLS-1$ + assertEquals(0, fMyPart.getRefreshedObject().size(), "No refreshes"); //$NON-NLS-1$ } @Test @@ -282,11 +282,11 @@ public void testBug65240() throws Exception { fJProject2.setRawClasspath(new IClasspathEntry[] {element.getClasspathEntry()}, null); Object[] expectedChildren= new Object[]{fPack4.getResource(), fPack5}; Object[] children= fProvider.getChildren(fPack3.getResource()); - assertTrue("Wrong children found for folder", compareArrays(children, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "Wrong children found for folder");//$NON-NLS-1$ expectedChildren= new Object[]{fPack1.getResource(), fPack2.getResource(), fPack3.getResource()}; children= fProvider.getChildren(fRoot1); - assertTrue("Wrong children found for source folder", compareArrays(children, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "Wrong children found for source folder");//$NON-NLS-1$ } // public void testAddWorkingCopyCU() throws Exception { @@ -323,7 +323,7 @@ public void testBug65240() throws Exception { // } - @Before + @BeforeEach public void setUp() throws Exception { fWorkspace= ResourcesPlugin.getWorkspace(); assertNotNull(fWorkspace); @@ -337,8 +337,8 @@ 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$ fJProject1.setRawClasspath(new IClasspathEntry[0], null); @@ -362,22 +362,22 @@ else if (".project".equals(file.getName()))//$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$ 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$ - assertTrue("Unable to create zipfile archive",fArchiveFragmentRoot.exists());//$NON-NLS-1$ + assertTrue(fArchiveFragmentRoot.exists(),"Unable to create zipfile archive");//$NON-NLS-1$ fPackJunit= fArchiveFragmentRoot.getPackageFragment("junit");//$NON-NLS-1$ 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$ fCUIMoney= fPackJunitSamplesMoney.getCompilationUnit("IMoney.java");//$NON-NLS-1$ fCUMoney= fPackJunitSamplesMoney.getCompilationUnit("Money.java");//$NON-NLS-1$ @@ -431,7 +431,7 @@ public void setUpMockView() throws Exception { assertNotNull(fProvider); } - @After + @AfterEach public void tearDown() throws Exception { fArchiveFragmentRoot.close(); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests2.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests2.java index 99914fff34c..ac2ef654858 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests2.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests2.java @@ -13,17 +13,17 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.packageview; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +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; @@ -97,62 +97,62 @@ public class ContentProviderTests2{ public void testGetChildrenProject() throws Exception{ Object[] expectedChildren= new Object[]{fPack1, fPack2, fPack3, fRoot1.getPackageFragment(""), fFile1, fFile2, dotSettings, fInternalRoot1,jdk}; //$NON-NLS-1$ Object[] children= fProvider.getChildren(fJProject3); - assertTrue("Wrong children found for project", compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "Wrong children found for project"); //$NON-NLS-1$ } @Test public void testGetChildrentMidLevelFragment() throws Exception{ Object[] expectedChildren= new Object[]{fPack4, fPack5}; Object[] children= fProvider.getChildren(fPack3); - 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 public void testGetChildrenBottomLevelFragment() throws Exception{ Object[] expectedChildren= new Object[]{}; Object[] children= fProvider.getChildren(fPack1); - 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 public void testGetChildrenBottomLevelFragmentWithCU() throws Exception{ Object[] expectedChildren= new Object[]{fCU1}; Object[] children= fProvider.getChildren(fPack2); - assertTrue("Wrong children found for PackageFragment with CU",compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren),"Wrong children found for PackageFragment with CU"); //$NON-NLS-1$ } @Test public void testGetChildrenBottomLevelFragmentFile() throws Exception{ Object[] expectedChildren= new Object[]{}; Object[] children= fProvider.getChildren(fPack1); - assertTrue("Wrong children found for PackageFragment with File",compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren),"Wrong children found for PackageFragment with File"); //$NON-NLS-1$ } @Test public void testGetChildrenBottomLevelFragment2() throws Exception{ Object[] expectedChildren= new Object[]{fCU2}; Object[] children= fProvider.getChildren(fPack6); - 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 public void testGetChildrenMidLevelFragmentInInternalArchive() throws Exception{ Object[] expectedChildren= new Object[]{fC}; Object[] children= fProvider.getChildren(fB); - assertTrue("wrong children found for a NON bottom PackageFragment in PackageFragmentRoot Internal Archive", compareArrays(children, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "wrong children found for a NON bottom PackageFragment in PackageFragmentRoot Internal Archive");//$NON-NLS-1$ } @Test public void testGetChildrenBottomLevelFragmentInInternalArchive() throws Exception{ Object[] expectedChildren= new Object[]{fYClassFile}; Object[] children= fProvider.getChildren(fY); - assertTrue("wrong children found for a bottom PackageFragment in PackageFragmentRoot Internal Archive", compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "wrong children found for a bottom PackageFragment in PackageFragmentRoot Internal Archive"); //$NON-NLS-1$ } public void getChildrenInternalArchive() throws Exception{ Object[] expectedChildren= new Object[]{fX,fA, fInternalRoot1.getPackageFragment("")}; //$NON-NLS-1$ Object[] children= fProvider.getChildren(fInternalRoot1); - assertTrue("Wrong child found for PackageFragmentRoot Internal Archive", compareArrays(children,expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "Wrong child found for PackageFragmentRoot Internal Archive");//$NON-NLS-1$ } //---------------Get Parent Tests----------------------------- @@ -160,40 +160,40 @@ public void getChildrenInternalArchive() throws Exception{ @Test public void testGetParentArchive() throws Exception{ Object parent= fProvider.getParent(fInternalRoot1); - assertSame("Wrong parent found for PackageFragmentRoot Archive", parent, fJProject3); //$NON-NLS-1$ + assertSame(parent, fJProject3, "Wrong parent found for PackageFragmentRoot Archive"); //$NON-NLS-1$ } @Test public void testGetParentMidLevelFragmentInArchive() throws Exception{ Object expectedParent= fB; Object parent= fProvider.getParent(fC); - assertEquals("Wrong parent found for a NON top level PackageFragment in an Archive", expectedParent, parent); //$NON-NLS-1$ + assertEquals(expectedParent, parent, "Wrong parent found for a NON top level PackageFragment in an Archive"); //$NON-NLS-1$ } @Test public void testGetParentTopLevelFragmentInArchive() throws Exception{ Object expectedParent= fInternalRoot1; Object parent= fProvider.getParent(fA); - assertEquals("Wrong parent found for a top level PackageFragment in an Archive", expectedParent, parent); //$NON-NLS-1$ + assertEquals(expectedParent, parent, "Wrong parent found for a top level PackageFragment in an Archive"); //$NON-NLS-1$ } @Test public void testGetParentTopLevelFragment() throws Exception{ Object expectedParent= fJProject3; Object parent= fProvider.getParent(fPack3); - assertEquals("Wrong parent found for a top level PackageFragment", expectedParent, parent); //$NON-NLS-1$ + assertEquals(expectedParent, parent, "Wrong parent found for a top level PackageFragment"); //$NON-NLS-1$ } @Test public void testGetParentMidLevelFragment() throws Exception{ Object expectedParent= fPack3; Object parent= fProvider.getParent(fPack5); - assertEquals("Wrong parent found for a NON top level PackageFragment", expectedParent, parent); //$NON-NLS-1$ + assertEquals(expectedParent, parent, "Wrong parent found for a NON top level PackageFragment"); //$NON-NLS-1$ } //-------------------Set up methods-------------------------------- - @Before + @BeforeEach public void setUp() throws Exception { @@ -206,7 +206,7 @@ public void setUp() throws Exception { //create project fJProject3= JavaProjectHelper.createJavaProject("TestProject3", "bin"); //$NON-NLS-1$ //$NON-NLS-2$ - assertNotNull("project3 null", fJProject3); //$NON-NLS-1$ + assertNotNull(fJProject3, "project3 null"); //$NON-NLS-1$ for (Object object : fJProject3.getNonJavaResources()) { if(object instanceof IFile){ @@ -228,17 +228,17 @@ else if (".project".equals(file.getName())) //$NON-NLS-1$ //add rt.jar jdk= JavaProjectHelper.addVariableRTJar(fJProject3, "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 the PackageFragmentRoot that represents the project as source folder fRoot1= JavaProjectHelper.addSourceContainer(fJProject3, ""); //$NON-NLS-1$ - assertNotNull("getting default package", fRoot1); //$NON-NLS-1$ + assertNotNull(fRoot1, "getting default package"); //$NON-NLS-1$ //set up project #3: file system structure with project as source folder //add an internal jar File myInternalLibJar= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/myinternallib.jar")); //$NON-NLS-1$ - assertNotNull("lib not found", myInternalLibJar); //$NON-NLS-1$ - assertTrue("lib not found", myInternalLibJar.exists()); //$NON-NLS-1$ + assertNotNull(myInternalLibJar, "lib not found"); //$NON-NLS-1$ + assertTrue(myInternalLibJar.exists(), "lib not found"); //$NON-NLS-1$ fInternalRoot1= JavaProjectHelper.addLibraryWithImport(fJProject3, Path.fromOSString(myInternalLibJar.getPath()), null, null); //create internal PackageFragments @@ -294,7 +294,7 @@ public void setUpMockView() throws Exception { assertNotNull(fProvider); } - @After + @AfterEach public void tearDown() throws Exception { fInternalRoot1.close(); JavaProjectHelper.delete(fJProject3); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests3.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests3.java index abfbc3e8ff2..c6dcf4b94c1 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests3.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests3.java @@ -13,18 +13,18 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.packageview; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -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.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +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; @@ -111,7 +111,7 @@ public class ContentProviderTests3{ public void testGetChildrenProjectWithSourceFolders() throws Exception{ Object[] expectedChildren= new Object[]{fRoot1, fFile1, fFile2, dotSettings, jdk}; Object[] children= fProvider.getChildren(fJProject2); - assertTrue("Wrong children found for project with folding", compareArrays(children, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "Wrong children found for project with folding");//$NON-NLS-1$ } @@ -119,14 +119,14 @@ public void testGetChildrenProjectWithSourceFolders() throws Exception{ public void testGetChildrentMidLevelFragment() throws Exception{ Object[] expectedChildren= new Object[]{fPack4, fPack6}; Object[] children= fProvider.getChildren(fPack3); - assertTrue("Wrong children found for PackageFragment with folding",compareArrays(children, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren),"Wrong children found for PackageFragment with folding");//$NON-NLS-1$ } @Test public void testGetChildrenBottomLevelFragment() throws Exception{ Object[] expectedChildren= new Object[]{}; Object[] children= fProvider.getChildren(fPack1); - assertTrue("Wrong children found for PackageFragment with folding",compareArrays(children, expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren),"Wrong children found for PackageFragment with folding");//$NON-NLS-1$ } @@ -134,28 +134,28 @@ public void testGetChildrenBottomLevelFragment() throws Exception{ public void testGetChildrenBottomLevelFragmentWithCU() throws Exception{ Object[] expectedChildren= new Object[]{fCU1}; Object[] children= fProvider.getChildren(fPack2); - assertTrue("Wrong children found for PackageFragment with folding",compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren),"Wrong children found for PackageFragment with folding"); //$NON-NLS-1$ } @Test public void testGetChildrenBottomLevelFragmentInArchive() throws Exception{ Object[] expectedChildren= new Object[]{fCUIMoney, fCUMoney, fCUMoneyBag, fCUMoneyTest}; Object[] children= fProvider.getChildren(fPackJunitSamplesMoney); - assertTrue("wrong children found for a bottom PackageFragment in PackageFragmentRoot Archive with folding", compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "wrong children found for a bottom PackageFragment in PackageFragmentRoot Archive with folding"); //$NON-NLS-1$ } @Test public void testGetChildrenSource() throws Exception{ Object[] expectedChildren= new Object[]{fPack1,fPack2,fPack3, fRoot1.getPackageFragment("")};//$NON-NLS-1$ Object[] children= fProvider.getChildren(fRoot1); - assertTrue("Wrong children found for PackageFragmentRoot with folding", compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "Wrong children found for PackageFragmentRoot with folding"); //$NON-NLS-1$ } @Test public void testGetChildrenArchive(){ Object[] expectedChildren= new Object[]{fPackJunit, fArchiveFragmentRoot.getPackageFragment("")};//$NON-NLS-1$ Object[] children= fProvider.getChildren(fArchiveFragmentRoot); - assertTrue("Wrong child found for PackageFragmentRoot Archive with folding", compareArrays(children,expectedChildren));//$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "Wrong child found for PackageFragmentRoot Archive with folding");//$NON-NLS-1$ } @@ -164,28 +164,28 @@ public void testGetChildrenArchive(){ @Test public void testGetParentArchive() throws Exception{ Object parent= fProvider.getParent(fArchiveFragmentRoot); - assertSame("Wrong parent found for PackageFragmentRoot Archive with folding", parent, fJProject1);//$NON-NLS-1$ + assertSame(parent, fJProject1, "Wrong parent found for PackageFragmentRoot Archive with folding");//$NON-NLS-1$ } @Test public void testGetParentTopLevelFragmentInArchive() throws Exception{ Object expectedParent= fPackJunit; Object parent= fProvider.getParent(fPackJunitSamples); - assertEquals("Wrong parent found for a top level PackageFragment in an Archive with folding", expectedParent, parent); //$NON-NLS-1$ + assertEquals(expectedParent, parent, "Wrong parent found for a top level PackageFragment in an Archive with folding"); //$NON-NLS-1$ } @Test public void testGetParentTopLevelFragment() throws Exception{ Object expectedParent= fRoot1; Object parent= fProvider.getParent(fPack3); - assertEquals("Wrong parent found for a top level PackageFragment with folding", expectedParent, parent); //$NON-NLS-1$ + assertEquals(expectedParent, parent, "Wrong parent found for a top level PackageFragment with folding"); //$NON-NLS-1$ } @Test public void testGetParentFoldedBottomFragment() throws Exception{ Object expectedParent= fRoot1; Object parent= fProvider.getParent(fPack3); - assertEquals("Wrong parent found for a top level PackageFragment with folding", expectedParent, parent);//$NON-NLS-1$ + assertEquals(expectedParent, parent, "Wrong parent found for a top level PackageFragment with folding");//$NON-NLS-1$ } @@ -193,7 +193,7 @@ public void testGetParentFoldedBottomFragment() throws Exception{ public void testGetParentMidLevelFragment() throws Exception{ Object expectedParent= fPack3; Object parent= fProvider.getParent(fPack4); - assertEquals("Wrong parent found for a NON top level PackageFragment with folding", expectedParent, parent);//$NON-NLS-1$ + assertEquals(expectedParent, parent, "Wrong parent found for a NON top level PackageFragment with folding");//$NON-NLS-1$ } @Test @@ -207,9 +207,9 @@ public void testDeleteBottomLevelFragmentFolding() throws Exception { //force events from dispaly while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) - assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ - assertTrue("Correct Refresh", fMyPart.wasObjectRefreshed(fRoot1)); //$NON-NLS-1$ - assertEquals("Single refresh", 1, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$ + assertTrue(fMyPart.hasRefreshHappened(), "Refresh happened"); //$NON-NLS-1$ + assertTrue(fMyPart.wasObjectRefreshed(fRoot1), "Correct Refresh"); //$NON-NLS-1$ + assertEquals(1, fMyPart.getRefreshedObject().size(), "Single refresh"); //$NON-NLS-1$ } @Test @@ -225,10 +225,10 @@ public void testAddBottomLevelFragmentFolding() throws Exception { while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) { } - assertFalse("No add happened", fMyPart.hasAddHappened()); //$NON-NLS-1$ - assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ - assertTrue("Correct Refresh", fMyPart.wasObjectRefreshed(fRoot1)); //$NON-NLS-1$ - assertEquals("Single refresh", 1, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$ + assertFalse(fMyPart.hasAddHappened(), "No add happened"); //$NON-NLS-1$ + assertTrue(fMyPart.hasRefreshHappened(), "Refresh happened"); //$NON-NLS-1$ + assertTrue(fMyPart.wasObjectRefreshed(fRoot1), "Correct Refresh"); //$NON-NLS-1$ + assertEquals(1, fMyPart.getRefreshedObject().size(), "Single refresh"); //$NON-NLS-1$ } @Test @@ -242,7 +242,7 @@ public void testChangedTopLevelPackageFragmentFolding() throws Exception { while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) { } - assertEquals("No refreshs", 0, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$ + assertEquals(0, fMyPart.getRefreshedObject().size(), "No refreshs"); //$NON-NLS-1$ } @Test @@ -256,7 +256,7 @@ public void testChangeBottomLevelPackageFragmentFolding() throws Exception { while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) { } - assertEquals("No refreshs",0, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$ + assertEquals(0,fMyPart.getRefreshedObject().size(), "No refreshs"); //$NON-NLS-1$ } @Test @@ -272,7 +272,7 @@ public void testRemoveCUsFromPackageFragment() throws Exception{ } // removing more than one CU now results in a refresh. - assertEquals("One refresh", 1, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$ + assertEquals(1, fMyPart.getRefreshedObject().size(), "One refresh"); //$NON-NLS-1$ } @Test @@ -287,16 +287,16 @@ public void testRemoveCUFromPackageFragment() throws Exception { while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) { } - assertTrue("Remove happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$ - assertTrue("Correct refresh", fMyPart.getRemovedObjects().contains(fCU2)); //$NON-NLS-1$ - assertEquals("No refreshes", 0, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$ + assertTrue(fMyPart.hasRemoveHappened(), "Remove happened"); //$NON-NLS-1$ + assertTrue(fMyPart.getRemovedObjects().contains(fCU2), "Correct refresh"); //$NON-NLS-1$ + assertEquals(0, fMyPart.getRefreshedObject().size(), "No refreshes"); //$NON-NLS-1$ } /* * @see TestCase#setUp() */ - @Before + @BeforeEach public void setUp() throws Exception { fWorkspace= ResourcesPlugin.getWorkspace(); @@ -309,8 +309,8 @@ 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$ for (Object object : fJProject2.getNonJavaResources()) { if(object instanceof IFile){ @@ -332,12 +332,12 @@ else if (".project".equals(file.getName()))//$NON-NLS-1$ //set up project #1 : External Jar and zip file 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$ 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$ @@ -351,15 +351,15 @@ else if (".project".equals(file.getName()))//$NON-NLS-1$ fPackJunitTextUi= fArchiveFragmentRoot.getPackageFragment("junit.textui");//$NON-NLS-1$ fPackJunitUi= fArchiveFragmentRoot.getPackageFragment("junit.ui");//$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("", fPackJunitExtentions);//$NON-NLS-1$ - assertNotNull("",fPackJunitFramework);//$NON-NLS-1$ - assertNotNull("",fPackJunitRunner);//$NON-NLS-1$ - assertNotNull("",fPackJunitTests);//$NON-NLS-1$ - assertNotNull("",fPackJunitTextUi);//$NON-NLS-1$ - assertNotNull("",fPackJunitUi);//$NON-NLS-1$ + assertNotNull(fPackJunit, "creating fPackJunit");//$NON-NLS-1$ + assertNotNull(fPackJunitSamples, "creating fPackJunitSamples");//$NON-NLS-1$ + assertNotNull(fPackJunitSamplesMoney,"creating fPackJunitSamplesMoney");//$NON-NLS-1$ + assertNotNull(fPackJunitExtentions, "");//$NON-NLS-1$ + assertNotNull(fPackJunitFramework,"");//$NON-NLS-1$ + assertNotNull(fPackJunitRunner,"");//$NON-NLS-1$ + assertNotNull(fPackJunitTests,"");//$NON-NLS-1$ + assertNotNull(fPackJunitTextUi,"");//$NON-NLS-1$ + assertNotNull(fPackJunitUi,"");//$NON-NLS-1$ fCUIMoney= fPackJunitSamplesMoney.getCompilationUnit("IMoney.java");//$NON-NLS-1$ fCUMoney= fPackJunitSamplesMoney.getCompilationUnit("Money.java");//$NON-NLS-1$ @@ -367,8 +367,8 @@ else if (".project".equals(file.getName()))//$NON-NLS-1$ fCUMoneyTest= fPackJunitSamplesMoney.getCompilationUnit("MoneyTest.java");//$NON-NLS-1$ File mylibJar= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.MYLIB); - assertNotNull("lib not found", mylibJar);//$NON-NLS-1$ - assertTrue("lib not found", mylibJar.exists());//$NON-NLS-1$ + assertNotNull(mylibJar, "lib not found");//$NON-NLS-1$ + assertTrue(mylibJar.exists(), "lib not found");//$NON-NLS-1$ JavaProjectHelper.addLibraryWithImport(fJProject1, Path.fromOSString(mylibJar.getPath()), null, null); //set up project #2: file system structure with in a source folder @@ -422,7 +422,7 @@ public void setUpMockView() throws Exception{ assertNotNull(fProvider); } - @After + @AfterEach public void tearDown() throws Exception { fArchiveFragmentRoot.close(); JavaProjectHelper.delete(fJProject1); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests4.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests4.java index 740619d49ef..8eec99f796e 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests4.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests4.java @@ -13,17 +13,17 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.packageview; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +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; @@ -101,62 +101,62 @@ public class ContentProviderTests4{ public void testGetChildrenProject() throws Exception{ Object[] expectedChildren= new Object[]{fPack1, fPack2, fPack3, fDefaultPackage, fFile1, fFile2, dotSettings, fInternalRoot1,jdk}; Object[] children= fProvider.getChildren(fJProject3); - assertTrue("Wrong children found for project with folding", compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "Wrong children found for project with folding"); //$NON-NLS-1$ } @Test public void testGetChildrenDefaultProject(){ Object[] expectedChildren= new Object[]{fCUinDefault}; Object[] children= fProvider.getChildren(fDefaultPackage); - assertTrue("Wrong children found for default package with folding", compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "Wrong children found for default package with folding"); //$NON-NLS-1$ } @Test public void testGetChildrentMidLevelFragment() throws Exception{ Object[] expectedChildren= new Object[]{fPack4, fPack6}; Object[] children= fProvider.getChildren(fPack3); - assertTrue("Wrong children found for PackageFragment with folding",compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren),"Wrong children found for PackageFragment with folding"); //$NON-NLS-1$ } @Test public void testGetChildrenBottomLevelFragment() throws Exception{ Object[] expectedChildren= new Object[]{}; Object[] children= fProvider.getChildren(fPack1); - assertTrue("Wrong children found for PackageFragment with folding",compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren),"Wrong children found for PackageFragment with folding"); //$NON-NLS-1$ } @Test public void testGetChildrenBottomLevelFragmentWithCU() throws Exception{ Object[] expectedChildren= new Object[]{fCU1}; Object[] children= fProvider.getChildren(fPack2); - assertTrue("Wrong children found for PackageFragment with folding",compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren),"Wrong children found for PackageFragment with folding"); //$NON-NLS-1$ } @Test public void testGetChildrenBottomLevelFragmenWithCU2() throws Exception{ Object[] expectedChildren= new Object[]{fCU2}; Object[] children= fProvider.getChildren(fPack6); - assertTrue("Wrong children found for PackageFragment with folding",compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren),"Wrong children found for PackageFragment with folding"); //$NON-NLS-1$ } @Test public void testGetChildrenMidLevelFragmentInInternalArchive() throws Exception{ Object[] expectedChildren= new Object[]{fC, fD, fAClassFile}; Object[] children= fProvider.getChildren(fA); - assertTrue("wrong children found for a NON bottom PackageFragment in PackageFragmentRoot Internal Archive with folding", compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "wrong children found for a NON bottom PackageFragment in PackageFragmentRoot Internal Archive with folding"); //$NON-NLS-1$ } @Test public void testGetChildrenBottomLevelFragmentInInternalArchive() throws Exception{ Object[] expectedChildren= new Object[]{fYClassFile}; Object[] children= fProvider.getChildren(fY); - assertTrue("wrong children found for a bottom PackageFragment in PackageFragmentRoot Internal Archive with folding", compareArrays(children, expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "wrong children found for a bottom PackageFragment in PackageFragmentRoot Internal Archive with folding"); //$NON-NLS-1$ } public void getChildrenInternalArchive() throws Exception{ Object[] expectedChildren= new Object[]{fX,fA, fInternalRoot1.getPackageFragment("")}; //$NON-NLS-1$ Object[] children= fProvider.getChildren(fInternalRoot1); - assertTrue("Wrong child found for PackageFragmentRoot Internal Archive with folding", compareArrays(children,expectedChildren)); //$NON-NLS-1$ + assertTrue(compareArrays(children, expectedChildren), "Wrong child found for PackageFragmentRoot Internal Archive with folding"); //$NON-NLS-1$ } //---------------Get Parent Tests----------------------------- @@ -164,47 +164,47 @@ public void getChildrenInternalArchive() throws Exception{ @Test public void testGetParentArchive() throws Exception{ Object parent= fProvider.getParent(fInternalRoot1); - assertSame("Wrong parent found for PackageFragmentRoot Archive with folding", parent, fJProject3);//$NON-NLS-1$ + assertSame(parent, fJProject3, "Wrong parent found for PackageFragmentRoot Archive with folding");//$NON-NLS-1$ } @Test public void testGetParentMidLevelFragmentInArchive() throws Exception{ Object expectedParent= fA; Object parent= fProvider.getParent(fC); - assertEquals("Wrong parent found for a NON top level PackageFragment in an Archive with folding", expectedParent, parent);//$NON-NLS-1$ + assertEquals(expectedParent, parent, "Wrong parent found for a NON top level PackageFragment in an Archive with folding");//$NON-NLS-1$ } @Test public void testGetParentTopLevelFragmentInArchive() throws Exception{ Object expectedParent= fInternalRoot1; Object parent= fProvider.getParent(fA); - assertEquals("Wrong parent found for a top level PackageFragment in an Archive with folding", expectedParent, parent); //$NON-NLS-1$ + assertEquals(expectedParent, parent, "Wrong parent found for a top level PackageFragment in an Archive with folding"); //$NON-NLS-1$ } @Test public void testGetParentTopLevelFragment() throws Exception{ Object expectedParent= fJProject3; Object parent= fProvider.getParent(fPack3); - assertEquals("Wrong parent found for a top level PackageFragment with folding", expectedParent, parent);//$NON-NLS-1$ + assertEquals(expectedParent, parent, "Wrong parent found for a top level PackageFragment with folding");//$NON-NLS-1$ } @Test public void testGetParentMidLevelFragment() throws Exception{ Object expectedParent= fPack3; Object parent= fProvider.getParent(fPack6); - assertEquals("Wrong parent found for a NON top level PackageFragment with folding", expectedParent, parent);//$NON-NLS-1$ + assertEquals(expectedParent, parent, "Wrong parent found for a NON top level PackageFragment with folding");//$NON-NLS-1$ } @Test public void testGetParentMidLevelFragment2() throws Exception{ Object expectedParent= fPack3; Object parent= fProvider.getParent(fPack5); - assertEquals("Wrong parent found for a NON top level PackageFragment with folding", expectedParent, parent);//$NON-NLS-1$ + assertEquals(expectedParent, parent, "Wrong parent found for a NON top level PackageFragment with folding");//$NON-NLS-1$ } //-------------------Set up methods-------------------------------- - @Before + @BeforeEach public void setUp() throws Exception { fWorkspace= ResourcesPlugin.getWorkspace(); assertNotNull(fWorkspace); @@ -215,7 +215,7 @@ public void setUp() throws Exception { //create project fJProject3 = JavaProjectHelper.createJavaProject("TestProject3", "bin");//$NON-NLS-1$//$NON-NLS-2$ - assertNotNull("project3 null", fJProject3);//$NON-NLS-1$ + assertNotNull(fJProject3, "project3 null");//$NON-NLS-1$ for (Object object : fJProject3.getNonJavaResources()) { if (object instanceof IFile) { @@ -237,11 +237,11 @@ else if (".project".equals(file.getName()))//$NON-NLS-1$ //add rt.jar jdk= JavaProjectHelper.addVariableRTJar(fJProject3, "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 the PackageFragmentRoot that represents the project as source folder fRoot1= JavaProjectHelper.addSourceContainer(fJProject3, "");//$NON-NLS-1$ - assertNotNull("getting default package", fRoot1);//$NON-NLS-1$ + assertNotNull(fRoot1, "getting default package");//$NON-NLS-1$ fDefaultPackage= fRoot1.createPackageFragment("",true,null);//$NON-NLS-1$ fCUinDefault= fDefaultPackage.createCompilationUnit("Object.java","",true, null);//$NON-NLS-1$//$NON-NLS-2$ @@ -249,8 +249,8 @@ else if (".project".equals(file.getName()))//$NON-NLS-1$ //set up project #3: file system structure with project as source folder //add an internal jar myInternalLibJar = JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/myinternallib.jar"));//$NON-NLS-1$ - assertNotNull("lib not found", myInternalLibJar); //$NON-NLS-1$ - assertTrue("lib not found", myInternalLibJar.exists()); //$NON-NLS-1$ + assertNotNull(myInternalLibJar, "lib not found"); //$NON-NLS-1$ + assertTrue(myInternalLibJar.exists(), "lib not found"); //$NON-NLS-1$ fInternalRoot1= JavaProjectHelper.addLibraryWithImport(fJProject3, Path.fromOSString(myInternalLibJar.getPath()), null, null); //create internal PackageFragments @@ -307,7 +307,7 @@ public void setUpMockView() throws Exception { assertNotNull(fProvider); } - @After + @AfterEach public void tearDown() throws Exception { fInternalRoot1.close(); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests5.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests5.java index 68adfeac7f2..6423acf5025 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests5.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests5.java @@ -13,17 +13,17 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.packageview; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -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.fail; import java.io.ByteArrayInputStream; import java.io.UnsupportedEncodingException; import java.util.Arrays; -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; @@ -78,7 +78,7 @@ public class ContentProviderTests5{ private IFile fDotProject; private IPackageFragmentRoot jdk; - @Before + @BeforeEach public void setUp() throws Exception { IWorkspace workspace= ResourcesPlugin.getWorkspace(); @@ -112,7 +112,7 @@ else if (".project".equals(file.getName())) //add rt.jar jdk= JavaProjectHelper.addVariableRTJar(fJProject, "JRE_LIB_TEST", null, null); - assertNotNull("jdk not found", jdk); + assertNotNull(jdk, "jdk not found"); setUpView(); } @@ -140,7 +140,7 @@ private void setFolding(boolean fold) { JavaPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.APPEARANCE_FOLD_PACKAGES_IN_PACKAGE_EXPLORER, fold); } - @After + @AfterEach public void tearDown() throws Exception { JavaProjectHelper.delete(fJProject); @@ -266,7 +266,7 @@ public void testInclExcl1() throws Exception { //bug 35851, 66694 } private void assertEqualElements(Object[] expected, Object[] actual) { - assertEquals("array length", expected.length, actual.length); + assertEquals(expected.length, actual.length, "array length"); exp: for (int i= 0; i < expected.length; i++) { Object e= expected[i]; for (Object a : actual) { diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests6.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests6.java index c5912eeac6f..16f6c2d93db 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests6.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests6.java @@ -13,17 +13,17 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.packageview; -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.ByteArrayInputStream; -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; @@ -90,7 +90,7 @@ public void testAddFileToClassFolder() throws Exception { while (fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) { } - assertFalse("No add happened", fMyPart.hasAddHappened()); //$NON-NLS-1$ + assertFalse(fMyPart.hasAddHappened(), "No add happened"); //$NON-NLS-1$ assertions(); } @@ -111,7 +111,7 @@ public void testAddFolderToClassFolder() throws Exception { while (fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) { } - assertFalse("No add happened", fMyPart.hasAddHappened()); //$NON-NLS-1$ + assertFalse(fMyPart.hasAddHappened(), "No add happened"); //$NON-NLS-1$ assertions(); } @@ -133,7 +133,7 @@ public void testRemoveFileFromClassFolder() throws Exception { while (fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) { } - assertFalse("No remove happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$ + assertFalse(fMyPart.hasRemoveHappened(), "No remove happened"); //$NON-NLS-1$ assertions(); } @@ -155,7 +155,7 @@ public void testRemoveFolderFromClassFolder() throws Exception { while (fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) { } - assertFalse("No remove happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$ + assertFalse(fMyPart.hasRemoveHappened(), "No remove happened"); //$NON-NLS-1$ assertions(); } @@ -175,21 +175,21 @@ public void testChangeClassInProject() throws Exception { while (fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) { } - assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ - assertFalse("Project not refreshed", fMyPart.wasObjectRefreshed(fJProject)); //$NON-NLS-1$ + assertTrue(fMyPart.hasRefreshHappened(), "Refresh happened"); //$NON-NLS-1$ + assertFalse(fMyPart.wasObjectRefreshed(fJProject), "Project not refreshed"); //$NON-NLS-1$ } private void assertions() { - assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$ - assertTrue("LibraryContainer Refreshed", fMyPart.wasObjectRefreshed(new LibraryContainer(fJProject))); //$NON-NLS-1$ - assertTrue("Resource Refreshed", fMyPart.wasObjectRefreshed(classFolder.getResource())); //$NON-NLS-1$ - assertEquals("Number of refreshed objects", 2, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$ + assertTrue(fMyPart.hasRefreshHappened(), "Refresh happened"); //$NON-NLS-1$ + assertTrue(fMyPart.wasObjectRefreshed(new LibraryContainer(fJProject)), "LibraryContainer Refreshed"); //$NON-NLS-1$ + assertTrue(fMyPart.wasObjectRefreshed(classFolder.getResource()), "Resource Refreshed"); //$NON-NLS-1$ + assertEquals(2, fMyPart.getRefreshedObject().size(), "Number of refreshed objects"); //$NON-NLS-1$ } /* * @see TestCase#setUp() */ - @Before + @BeforeEach public void setUp() throws Exception { IWorkspaceDescription workspaceDesc= ResourcesPlugin.getWorkspace().getDescription(); fEnableAutoBuildAfterTesting= workspaceDesc.isAutoBuilding(); @@ -197,11 +197,11 @@ public void setUp() throws Exception { CoreUtility.setAutoBuilding(false); fJProject= JavaProjectHelper.createJavaProject("TestProject", "bin");//$NON-NLS-1$//$NON-NLS-2$ - assertNotNull("project null", fJProject);//$NON-NLS-1$ + assertNotNull(fJProject, "project null");//$NON-NLS-1$ //set up project : Add classFolder classFolder= JavaProjectHelper.addClassFolder(fJProject, "classFolder", null, null); //$NON-NLS-1$ - assertNotNull("class folder null", classFolder); //$NON-NLS-1$ + assertNotNull(classFolder, "class folder null"); //$NON-NLS-1$ //set up the mock view setUpMockView(); @@ -223,7 +223,7 @@ public void setUpMockView() throws Exception{ assertNotNull(fProvider); } - @After + @AfterEach public void tearDown() throws Exception { JavaProjectHelper.delete(fJProject); if (fEnableAutoBuildAfterTesting) diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests7.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests7.java index 75471950237..988a3333948 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests7.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests7.java @@ -13,12 +13,12 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.packageview; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -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; @@ -94,8 +94,8 @@ private Object[] getChildren(IJavaElement src, boolean isFlatLayout) { } private void assertResults(Object[][] actual, Object[] expectedSrcFolderChildren, Object[] expectedDefaultPkgChildren) { - assertTrue("Wrong children found for source folder", compareArrays(actual[0], expectedSrcFolderChildren)); - assertTrue("Wrong children found for default package", compareArrays(actual[1], expectedDefaultPkgChildren));//$NON-NLS-1$ + assertTrue(compareArrays(actual[0], expectedSrcFolderChildren), "Wrong children found for source folder"); + assertTrue(compareArrays(actual[1], expectedDefaultPkgChildren), "Wrong children found for default package");//$NON-NLS-1$ } @Test @@ -190,10 +190,10 @@ public void testModule2Flat() throws Exception { /* * @see TestCase#setUp() */ - @Before + @BeforeEach public void setUp() throws Exception { fJProject= JavaProjectHelper.createJavaProject("TestProject", "bin");//$NON-NLS-1$//$NON-NLS-2$ - assertNotNull("project null", fJProject);//$NON-NLS-1$ + assertNotNull(fJProject, "project null");//$NON-NLS-1$ IPath[] rtJarPath= JavaProjectHelper.findRtJar(JavaProjectHelper.RT_STUBS_9); JavaProjectHelper.set9CompilerOptions(fJProject); IClasspathAttribute[] attributes= { new ClasspathAttribute(IClasspathAttribute.MODULE, "true") }; @@ -203,7 +203,7 @@ public void setUp() throws Exception { //set up project : Add classFolder fSrcFolder= JavaProjectHelper.addSourceContainer(fJProject, "src", null, null); //$NON-NLS-1$ - assertNotNull("source folder null", fSrcFolder); //$NON-NLS-1$ + assertNotNull(fSrcFolder, "source folder null"); //$NON-NLS-1$ } private boolean compareArrays(Object[] children, Object[] expectedChildren) { @@ -244,7 +244,7 @@ private boolean contains(IJavaElement fragment, Object[] expectedChildren) { return false; } - @After + @AfterEach public void tearDown() throws Exception { JavaProjectHelper.delete(fJProject); } diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/HierarchicalContentProviderTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/HierarchicalContentProviderTests.java index e36a975a7d5..cb1ea7525a3 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/HierarchicalContentProviderTests.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/HierarchicalContentProviderTests.java @@ -20,10 +20,12 @@ import java.util.Collections; import java.util.List; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExternalResource; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.RegisterExtension; import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jdt.testplugin.JavaTestPlugin; @@ -46,7 +48,7 @@ public class HierarchicalContentProviderTests { - private static class MyTestSetup extends ExternalResource { + private static class MyTestSetup implements BeforeEachCallback, AfterEachCallback { public static IJavaProject fJProject; public static IPackageFragmentRoot fJAR; @@ -55,7 +57,7 @@ private static class MyTestSetup extends ExternalResource { public static List fExpectedInJAR, fExpectedInCF; @Override - protected void before() throws Exception { + public void beforeEach(ExtensionContext context) throws Exception { fJProject= JavaProjectHelper.createJavaProject("Testing", "bin"); JavaProjectHelper.addRTJar(fJProject); @@ -80,7 +82,7 @@ private static List getExpected(IPackageFragmentRoot root) throws JavaMo } @Override - protected void after() { + public void afterEach(ExtensionContext context) { try { JavaProjectHelper.delete(fJProject); } catch (CoreException e) { @@ -93,7 +95,7 @@ protected void after() { } - @Rule + @RegisterExtension public MyTestSetup mytestsetup=new MyTestSetup(); private static void testAndAdd(Object curr, List res) { @@ -131,7 +133,7 @@ public void testClassFolderFoldedHierarchical() { private void assertEquals(List expected, List current) { - Assert.assertEquals(getString(expected), getString(current)); + Assertions.assertEquals(getString(expected), getString(current)); } diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/PackageCacheTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/PackageCacheTest.java index 5bb05824c0a..24ac3903c74 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/PackageCacheTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/PackageCacheTest.java @@ -13,7 +13,7 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.packageview; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.Arrays; @@ -22,9 +22,9 @@ import java.util.List; import java.util.Map; -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; @@ -59,7 +59,7 @@ public class PackageCacheTest { private PackageCache packageCache; - @Before + @BeforeEach public void setUp() throws Exception { IProgressMonitor monitor= new NullProgressMonitor(); @@ -81,7 +81,7 @@ public void setUp() throws Exception { packageCache= new PackageCache(src); } - @After + @AfterEach public void tearDown() throws Exception { testProject.getProject().delete(true, false, new NullProgressMonitor()); } @@ -107,8 +107,8 @@ public void testGetDirectChildren() throws Exception { expectedChildren.put(package_f, Arrays.asList(package_f_g)); expectedChildren.put(package_f_g, Collections.emptyList()); - assertEquals("method returned wrong results", - expectedChildren, actualChildren); + assertEquals(expectedChildren, + actualChildren, "method returned wrong results"); } @Test @@ -116,8 +116,8 @@ public void testGetSingleChild() throws Exception { Map actualSingleChildren= actualSingleChildren(); Map expectedSingleChildren= expectedSingleChildren(); - assertEquals("method returned wrong results", - expectedSingleChildren, actualSingleChildren); + assertEquals(expectedSingleChildren, + actualSingleChildren, "method returned wrong results"); } @Test @@ -133,8 +133,8 @@ public void testSingleChildAgainstOldImplementation() throws Exception { } } - assertEquals("method returned wrong results", - expectedSingleChildren, actualSingleChildren); + assertEquals(expectedSingleChildren, + actualSingleChildren, "method returned wrong results"); } @Test @@ -142,8 +142,8 @@ public void testHasSingleChild() throws Exception { List actualPackagesWithSingleChild= actualPackagesWithSingleChild(); List expectedPackagesWithSingleChild= expectedPackagesWithSingleChild(); - assertEquals("method returned wrong results", - expectedPackagesWithSingleChild, actualPackagesWithSingleChild); + assertEquals(expectedPackagesWithSingleChild, + actualPackagesWithSingleChild, "method returned wrong results"); } @Test @@ -159,8 +159,8 @@ public void testHasSingleChildAgainstOldImplementation() throws Exception { } } - assertEquals("method returned wrong results", - expectedPackagesWithSingleChild, actualPackagesWithSingleChild); + assertEquals(expectedPackagesWithSingleChild, + actualPackagesWithSingleChild, "method returned wrong results"); } private Map actualSingleChildren() throws Exception { diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/PackageExplorerShowInTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/PackageExplorerShowInTests.java index c35c6dc8255..7013b3e44ad 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/PackageExplorerShowInTests.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/PackageExplorerShowInTests.java @@ -14,14 +14,14 @@ package org.eclipse.jdt.ui.tests.packageview; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.ByteArrayInputStream; -import org.junit.After; -import org.junit.Before; import org.junit.Rule; -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; @@ -59,7 +59,7 @@ public class PackageExplorerShowInTests { private PackageExplorerPart fPackageExplorer; private IWorkbenchPage fPage; - @Before + @BeforeEach public void setUp() throws Exception { fJProject= pts.getProject(); fPage= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); @@ -67,7 +67,7 @@ public void setUp() throws Exception { fPackageExplorer.selectAndReveal(new StructuredSelection()); } - @After + @AfterEach public void tearDown() throws Exception { JavaProjectHelper.clear(fJProject, pts.getDefaultClasspath()); fPage.hideView(fPackageExplorer); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/WorkingSetDropAdapterTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/WorkingSetDropAdapterTest.java index 5148a80be68..a7717ff82a4 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/WorkingSetDropAdapterTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/WorkingSetDropAdapterTest.java @@ -13,15 +13,15 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.packageview; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; 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; @@ -62,7 +62,7 @@ public class WorkingSetDropAdapterTest { private WorkingSetDropAdapter fAdapter; - @Before + @BeforeEach public void setUp() throws Exception { fProject= JavaProjectHelper.createJavaProject("Test", "bin"); IWorkbenchPage activePage= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); @@ -71,7 +71,7 @@ public void setUp() throws Exception { fAdapter= new WorkingSetDropAdapter(fPackageExplorer); } - @After + @AfterEach public void tearDown() throws Exception { JavaProjectHelper.delete(fProject); IWorkbenchPage activePage= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/refactoring/IsCompletelySelectedTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/refactoring/IsCompletelySelectedTest.java index 72407e5e55a..f0ff1fd499d 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/refactoring/IsCompletelySelectedTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/refactoring/IsCompletelySelectedTest.java @@ -13,17 +13,17 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.refactoring; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import org.junit.After; -import org.junit.Before; import org.junit.Rule; -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; @@ -72,7 +72,7 @@ public class IsCompletelySelectedTest { @Rule public ProjectTestSetup projectSetup = new ProjectTestSetup(); - @Before + @BeforeEach public void setUp() throws Exception { IProgressMonitor monitor= new NullProgressMonitor(); @@ -90,7 +90,7 @@ public void setUp() throws Exception { package_a_b_e= src.createPackageFragment("a.b.e", force, monitor); } - @After + @AfterEach public void tearDown() throws Exception { testProject.getProject().delete(true, false, new NullProgressMonitor()); } @@ -159,8 +159,8 @@ private void assertMatchesOnly(IsCompletelySelected predicate, IPackageFragment. } } - assertEquals("wrong set of completely selected packages", - new LinkedHashSet<>(Arrays.asList(expectedCompletelySelectedPackages)), actualCompletelySelectedPackages); + assertEquals(new LinkedHashSet<>(Arrays.asList(expectedCompletelySelectedPackages)), + actualCompletelySelectedPackages, "wrong set of completely selected packages"); } private IPackageFragment[] allPackages() { diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/refactoring/ParentCheckerTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/refactoring/ParentCheckerTest.java index f5e35a9f250..d7b7733dbdc 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/refactoring/ParentCheckerTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/refactoring/ParentCheckerTest.java @@ -13,14 +13,14 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.refactoring; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.LinkedHashSet; -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; @@ -53,7 +53,7 @@ public class ParentCheckerTest { private IResource classD2; - @Before + @BeforeEach public void setUp() throws Exception { /* @@ -92,7 +92,7 @@ public void setUp() throws Exception { classD2= createClass(package_a_b_d, "D2"); } - @After + @AfterEach public void tearDown() throws Exception { testProject.getProject().delete(true, true, null); } @@ -207,10 +207,10 @@ private static void assertCorrectRemovalOfElements(IJavaElement[] folders, IReso IJavaElement[] actualRemainingPackages= checker.getJavaElements(); IResource[] actualRemainingResources= checker.getResources(); - assertEquals("wrong folders remained after removing packages with ancestors", - asLinkedHashSet(expectedRemainingFolders), asLinkedHashSet(actualRemainingPackages)); - assertEquals("wrong resources remain after removing resources with ancestors", - asLinkedHashSet(expectedRemainingResources), asLinkedHashSet(actualRemainingResources)); + assertEquals(asLinkedHashSet(expectedRemainingFolders), + asLinkedHashSet(actualRemainingPackages), "wrong folders remained after removing packages with ancestors"); + assertEquals(asLinkedHashSet(expectedRemainingResources), + asLinkedHashSet(actualRemainingResources), "wrong resources remain after removing resources with ancestors"); } private static LinkedHashSet asLinkedHashSet(T[] elements) {