From f89dd863fecd359899a75a96d927cbfc968737b0 Mon Sep 17 00:00:00 2001 From: Carsten Hammer Date: Sun, 20 Oct 2024 19:23:54 +0200 Subject: [PATCH] dogfooding migration to junit 5 test to run the upcoming junit 4 to junit 5 migration cleanup --- .../changes/TextDiffContentTest.java | 8 +-- .../changes/TrackPositionTest.java | 22 +++---- .../refactoring/nls/CellEditorTester.java | 4 +- .../refactoring/nls/NLSElementTester.java | 30 ++++----- .../refactoring/nls/NLSScannerTester.java | 66 +++++++++---------- .../refactoring/nls/NLSSubstitutionTest.java | 4 +- .../nls/PropertyFileDocumentModellTest.java | 4 +- .../refactoring/nls/SimpleLineReaderTest.java | 6 +- 8 files changed, 72 insertions(+), 72 deletions(-) diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TextDiffContentTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TextDiffContentTest.java index 5d7e982b37e..d7b9b7f7ab7 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TextDiffContentTest.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TextDiffContentTest.java @@ -15,10 +15,10 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.refactoring.changes; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; @@ -72,7 +72,7 @@ public class TextDiffContentTest { private TextEditChangeGroup fChange3; - @Before + @BeforeEach public void setUp() throws Exception { fDocument = new Document(MODIFIED_SOURCE_CONTENTS); fDocumentChange = new DocumentChange("Changes to document", fDocument); diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TrackPositionTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TrackPositionTest.java index 96bb6871f6c..eb2ec6c6e20 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TrackPositionTest.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/changes/TrackPositionTest.java @@ -13,12 +13,12 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.refactoring.changes; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertFalse; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.eclipse.core.runtime.NullProgressMonitor; @@ -39,7 +39,7 @@ public class TrackPositionTest { private IDocument fDocument; private DocumentChange fChange; - @Before + @BeforeEach public void setUp() throws Exception { fDocument= new Document("0123456789"); fChange= new DocumentChange(NN, fDocument); @@ -47,7 +47,7 @@ public void setUp() throws Exception { fChange.initializeValidationData(new NullProgressMonitor()); } - @After + @AfterEach public void tearDown() throws Exception { fChange= null; } @@ -65,8 +65,8 @@ public void test2() throws Exception { TextEdit edit= new ReplaceEdit(5, 3, "xy"); TextChangeCompatibility.addTextEdit(fChange, NN, edit); IDocument preview= fChange.getPreviewDocument(new NullProgressMonitor()); - Assert.assertEquals("0123456789", fDocument.get()); - Assert.assertEquals("01234xy89", preview.get()); + Assertions.assertEquals("0123456789", fDocument.get()); + Assertions.assertEquals("01234xy89", preview.get()); assertEquals(fChange.getPreviewEdit(edit).getRegion(), 5, 2); } @@ -80,7 +80,7 @@ private void executeChange() throws Exception { } private static void assertEquals(IRegion r, int offset, int length) { - Assert.assertEquals("Offset", offset, r.getOffset()); - Assert.assertEquals("Length", length, r.getLength()); + Assertions.assertEquals(offset, r.getOffset(), "Offset"); + Assertions.assertEquals(length, r.getLength(), "Length"); } } diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/CellEditorTester.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/CellEditorTester.java index a04b2557199..1a1ae8a362c 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/CellEditorTester.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/CellEditorTester.java @@ -13,9 +13,9 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.refactoring.nls; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.eclipse.jdt.internal.ui.refactoring.nls.MultiStateCellEditor; diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSElementTester.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSElementTester.java index 16abe0f51d9..6b101da5ada 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSElementTester.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSElementTester.java @@ -13,13 +13,13 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.refactoring.nls; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -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.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.eclipse.jdt.internal.corext.refactoring.nls.NLSElement; @@ -28,7 +28,7 @@ public class NLSElementTester{ private int fOff, fLen; private String fVal; - @Before + @BeforeEach public void setUp(){ fOff= 3; fLen= 5; @@ -38,40 +38,40 @@ public void setUp(){ @Test public void test0() { - assertEquals("Position offset", fOff, fEl.getPosition().getOffset()); //$NON-NLS-1$ + assertEquals(fOff, fEl.getPosition().getOffset(), "Position offset"); //$NON-NLS-1$ } @Test public void test1() { - assertEquals("Position length", fLen, fEl.getPosition().getLength()); //$NON-NLS-1$ + assertEquals(fLen, fEl.getPosition().getLength(), "Position length"); //$NON-NLS-1$ } @Test public void test2() { - assertEquals("value", fVal, fEl.getValue()); //$NON-NLS-1$ + assertEquals(fVal, fEl.getValue(), "value"); //$NON-NLS-1$ } @Test public void test3() { - assertNull("tagposition", fEl.getTagPosition()); //$NON-NLS-1$ + assertNull(fEl.getTagPosition(), "tagposition"); //$NON-NLS-1$ } @Test public void test3a() { fEl.setTagPosition(1, 2); - assertEquals("tagposition.length", 2, fEl.getTagPosition().getLength()); //$NON-NLS-1$ - assertEquals("tagposition.offset", 1, fEl.getTagPosition().getOffset()); //$NON-NLS-1$ + assertEquals(2, fEl.getTagPosition().getLength(), "tagposition.length"); //$NON-NLS-1$ + assertEquals(1, fEl.getTagPosition().getOffset(), "tagposition.offset"); //$NON-NLS-1$ } @Test public void test4() { - assertFalse("hastag", fEl.hasTag()); //$NON-NLS-1$ + assertFalse(fEl.hasTag(), "hastag"); //$NON-NLS-1$ } @Test public void test4a() { fEl.setTagPosition(1, 2); - assertTrue("hastag", fEl.hasTag()); //$NON-NLS-1$ + assertTrue(fEl.hasTag(), "hastag"); //$NON-NLS-1$ } } diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSScannerTester.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSScannerTester.java index 457f7399fb3..8587445a514 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSScannerTester.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSScannerTester.java @@ -14,11 +14,11 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.refactoring.nls; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.eclipse.jdt.internal.corext.refactoring.nls.NLSElement; import org.eclipse.jdt.internal.corext.refactoring.nls.NLSLine; @@ -29,42 +29,42 @@ public class NLSScannerTester { public void test0() throws Exception{ String text= "fred"; //$NON-NLS-1$ NLSLine[] l= NLSScanner.scan(text); - assertEquals("empty", 0, l.length); //$NON-NLS-1$ + assertEquals(0, l.length, "empty"); //$NON-NLS-1$ } @Test public void test1() throws Exception{ String text= "fred\"x\""; NLSLine[] l= NLSScanner.scan(text); - assertEquals("1 line", 1, l.length); + assertEquals(1, l.length, "1 line"); } @Test public void test1a() throws Exception{ String text= "fred\n\"x\""; //$NON-NLS-1$ NLSLine[] l= NLSScanner.scan(text); - assertEquals("1 line", 1, l.length); //$NON-NLS-1$ + assertEquals(1, l.length, "1 line"); //$NON-NLS-1$ } @Test public void test2() throws Exception{ String text= "fred\"x\"\n\"xx\""; NLSLine[] l= NLSScanner.scan(text); - assertEquals("2 line", 2, l.length); + assertEquals(2, l.length, "2 line"); } @Test public void test2a() throws Exception{ String text= "fred\n\"x\" \"xx\""; //$NON-NLS-1$ NLSLine[] l= NLSScanner.scan(text); - assertEquals("1 lines", 1, l.length); //$NON-NLS-1$ + assertEquals(1, l.length, "1 lines"); //$NON-NLS-1$ } @Test public void test3() throws Exception{ String text= "fred\"x\"\n \"xx\""; NLSLine[] l= NLSScanner.scan(text); - assertEquals("2 lines", 2, l.length); + assertEquals(2, l.length, "2 lines"); } @@ -72,7 +72,7 @@ public void test3() throws Exception{ public void test4() throws Exception{ String text= "fred\n \"xx\""; //$NON-NLS-1$ NLSLine[] l= NLSScanner.scan(text); - assertEquals("1 line", 1, l.length); //$NON-NLS-1$ + assertEquals(1, l.length, "1 line"); //$NON-NLS-1$ } @Test @@ -80,7 +80,7 @@ public void test5() throws Exception{ String text= "\n \"xx\""; //$NON-NLS-1$ NLSLine[] l= NLSScanner.scan(text); NLSLine line=l[0]; - assertEquals("1 string", 1, line.size()); //$NON-NLS-1$ + assertEquals(1, line.size(), "1 string"); //$NON-NLS-1$ } @Test @@ -88,7 +88,7 @@ public void test6() throws Exception{ String text= "\n \"xx\" \"dff\""; //$NON-NLS-1$ NLSLine[] l= NLSScanner.scan(text); NLSLine line=l[0]; - assertEquals("2 string", 2, line.size()); //$NON-NLS-1$ + assertEquals(2, line.size(), "2 string"); //$NON-NLS-1$ } @Test @@ -96,10 +96,10 @@ public void test7() throws Exception{ String text= "\n \"xx\" \n\"dff\""; //$NON-NLS-1$ NLSLine[] l= NLSScanner.scan(text); NLSLine line=l[0]; - assertEquals("1 string A", 1, line.size()); //$NON-NLS-1$ + assertEquals(1, line.size(), "1 string A"); //$NON-NLS-1$ line= l[1]; - assertEquals("1 string B", 1, line.size()); //$NON-NLS-1$ + assertEquals(1, line.size(), "1 string B"); //$NON-NLS-1$ } @@ -108,10 +108,10 @@ public void test8() throws Exception{ String text= "\n \"xx\" \n\"dff\" \"ccc\""; //$NON-NLS-1$ NLSLine[] l= NLSScanner.scan(text); NLSLine line=l[0]; - assertEquals("1 string A", 1, line.size()); //$NON-NLS-1$ + assertEquals(1, line.size(), "1 string A"); //$NON-NLS-1$ line= l[1]; - assertEquals("2 strings B", 2, line.size()); //$NON-NLS-1$ + assertEquals(2, line.size(), "2 strings B"); //$NON-NLS-1$ } @Test @@ -120,7 +120,7 @@ public void test9() throws Exception{ NLSLine[] l= NLSScanner.scan(text); NLSLine line=l[0]; NLSElement el= line.get(0); - assertTrue("has tag", el.hasTag()); //$NON-NLS-1$ + assertTrue(el.hasTag(), "has tag"); //$NON-NLS-1$ } @@ -130,7 +130,7 @@ public void test10() throws Exception{ NLSLine[] l= NLSScanner.scan(text); NLSLine line=l[0]; NLSElement el= line.get(0); - assertFalse("has tag", el.hasTag()); //$NON-NLS-1$ + assertFalse(el.hasTag(), "has tag"); //$NON-NLS-1$ } @Test @@ -142,13 +142,13 @@ public void test11() throws Exception{ + "\n"; //$NON-NLS-1$ NLSLine[] l= NLSScanner.scan(text); NLSLine line=l[0]; - assertEquals("2 strings", 2, line.size()); //$NON-NLS-1$ + assertEquals(2, line.size(), "2 strings"); //$NON-NLS-1$ NLSElement el= line.get(0); - assertTrue("0 has tag", el.hasTag()); //$NON-NLS-1$ + assertTrue(el.hasTag(), "0 has tag"); //$NON-NLS-1$ el= line.get(1); - assertTrue("1 has tag", el.hasTag()); //$NON-NLS-1$ + assertTrue(el.hasTag(), "1 has tag"); //$NON-NLS-1$ } @Test @@ -160,13 +160,13 @@ public void test12() throws Exception{ + "\n"; //$NON-NLS-1$ NLSLine[] l= NLSScanner.scan(text); NLSLine line=l[0]; - assertEquals("2 strings", 2, line.size()); //$NON-NLS-1$ + assertEquals(2, line.size(), "2 strings"); //$NON-NLS-1$ NLSElement el= line.get(0); - assertTrue("0 has tag", el.hasTag()); //$NON-NLS-1$ + assertTrue(el.hasTag(), "0 has tag"); //$NON-NLS-1$ el= line.get(1); - assertTrue("1 has tag", el.hasTag()); //$NON-NLS-1$ + assertTrue(el.hasTag(), "1 has tag"); //$NON-NLS-1$ } @Test @@ -177,13 +177,13 @@ public void test13() throws Exception{ + "\n"; //$NON-NLS-1$ NLSLine[] l= NLSScanner.scan(text); NLSLine line=l[0]; - assertEquals("2 strings", 2, line.size()); //$NON-NLS-1$ + assertEquals(2, line.size(), "2 strings"); //$NON-NLS-1$ NLSElement el= line.get(0); - assertTrue("0 has tag", el.hasTag()); //$NON-NLS-1$ + assertTrue(el.hasTag(), "0 has tag"); //$NON-NLS-1$ el= line.get(1); - assertFalse("1 has no tag", el.hasTag()); //$NON-NLS-1$ + assertFalse(el.hasTag(), "1 has no tag"); //$NON-NLS-1$ } @Test @@ -194,13 +194,13 @@ public void test14() throws Exception{ + "\n"; //$NON-NLS-1$ NLSLine[] l= NLSScanner.scan(text); NLSLine line=l[0]; - assertEquals("2 strings", 2, line.size()); //$NON-NLS-1$ + assertEquals(2, line.size(), "2 strings"); //$NON-NLS-1$ NLSElement el= line.get(0); - assertFalse("0 has no tag", el.hasTag()); //$NON-NLS-1$ + assertFalse(el.hasTag(), "0 has no tag"); //$NON-NLS-1$ el= line.get(1); - assertTrue("1 has tag", el.hasTag()); //$NON-NLS-1$ + assertTrue(el.hasTag(), "1 has tag"); //$NON-NLS-1$ } // test for bug 102132 @@ -433,9 +433,9 @@ public void test54() throws Exception{ + "\n"; //$NON-NLS-1$ NLSLine[] l= NLSScanner.scan(text); NLSLine line=l[0]; - assertEquals("1 strings", 1, line.size()); //$NON-NLS-1$ + assertEquals(1, line.size(), "1 strings"); //$NON-NLS-1$ NLSElement el= line.get(0); - assertFalse("0 has no tag", el.hasTag()); //$NON-NLS-1$ + assertFalse(el.hasTag(), "0 has no tag"); //$NON-NLS-1$ } } diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSSubstitutionTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSSubstitutionTest.java index af01bd3db3e..32f787238ab 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSSubstitutionTest.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSSubstitutionTest.java @@ -13,11 +13,11 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.refactoring.nls; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.eclipse.jdt.internal.corext.refactoring.nls.NLSSubstitution; diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/PropertyFileDocumentModellTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/PropertyFileDocumentModellTest.java index 32c0cc70464..884b44ffdf2 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/PropertyFileDocumentModellTest.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/PropertyFileDocumentModellTest.java @@ -13,9 +13,9 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.refactoring.nls; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/SimpleLineReaderTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/SimpleLineReaderTest.java index 391ff752af4..054abb9dd9e 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/SimpleLineReaderTest.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/SimpleLineReaderTest.java @@ -13,10 +13,10 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.refactoring.nls; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.Document;