diff --git a/tests/org.eclipse.text.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.text.tests/META-INF/MANIFEST.MF index 09e2c8732d2..5491c055d2c 100644 --- a/tests/org.eclipse.text.tests/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.text.tests/META-INF/MANIFEST.MF @@ -12,9 +12,9 @@ Export-Package: Require-Bundle: org.eclipse.core.commands;bundle-version="[3.5.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", - org.eclipse.text;bundle-version="[3.6.3,4.0.0)", - org.junit;bundle-version="4.12.0" + org.eclipse.text;bundle-version="[3.6.3,4.0.0)" Import-Package: org.junit.jupiter.api;version="[5.14.0,6.0.0)", + org.junit.jupiter.api.function;version="[5.14.0,6.0.0)", org.junit.platform.suite.api;version="[1.14.0,2.0.0)" Bundle-RequiredExecutionEnvironment: JavaSE-17 Eclipse-BundleShape: dir diff --git a/tests/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java b/tests/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java index a6a78afdb77..6d453eb6970 100644 --- a/tests/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java +++ b/tests/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java @@ -14,20 +14,20 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -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.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; -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.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultLineTracker; @@ -117,7 +117,7 @@ private String getOriginalMasterContents() { "99999999999999999999"; } - @Before + @BeforeEach public void setUp() { fMasterDocument= new Document(); fMasterDocument.set(getOriginalMasterContents()); @@ -125,7 +125,7 @@ public void setUp() { fSlaveDocument= (ProjectionDocument) fSlaveDocumentManager.createSlaveDocument(fMasterDocument); } - @After + @AfterEach public void tearDown () { fSlaveDocumentManager.freeSlaveDocument(fSlaveDocument); fSlaveDocument= null; @@ -251,12 +251,12 @@ private void assertFragmentation(Position[] expected, boolean checkWellFormednes } Position[] segmentation= fSlaveDocument.getSegments2(); - assertTrue("invalid number of segments", expected.length == segmentation.length); + assertTrue(expected.length == segmentation.length, "invalid number of segments"); for (int i= 0; i < expected.length; i++) { Segment segment= (Segment) segmentation[i]; Fragment actual= segment.fragment; - Assert.assertEquals(print(actual) + " != " + print(expected[i]), expected[i], actual); + Assertions.assertEquals(expected[i], actual, print(actual) + " != " + print(expected[i])); } } @@ -267,15 +267,15 @@ private void assertLineInformationConsistency(IDocument document) { int textLines= textTracker.getNumberOfLines(); int trackerLines= document.getNumberOfLines(); - Assert.assertEquals(trackerLines, textLines); + Assertions.assertEquals(trackerLines, textLines); for (int i= 0; i < trackerLines; i++) { try { IRegion trackerLine= document.getLineInformation(i); IRegion textLine= textTracker.getLineInformation(i); - Assert.assertEquals(trackerLine.getOffset(), textLine.getOffset()); - Assert.assertEquals(trackerLine.getLength(), textLine.getLength()); + Assertions.assertEquals(trackerLine.getOffset(), textLine.getOffset()); + Assertions.assertEquals(trackerLine.getLength(), textLine.getLength()); } catch (BadLocationException e) { assertTrue(false); @@ -286,7 +286,7 @@ private void assertLineInformationConsistency(IDocument document) { private void assertContents(String expected, IDocument document) { assertWellFormedSegmentation(); assertWellFormedFragmentation(); - Assert.assertEquals(expected, document.get()); + Assertions.assertEquals(expected, document.get()); assertLineInformationConsistency(document); } @@ -682,9 +682,9 @@ public void test9_7() { try { int startOffset= fMasterDocument.getLineOffset(4); - Assert.assertEquals(80, startOffset); + Assertions.assertEquals(80, startOffset); int endOffset= fMasterDocument.getLineOffset(7); - Assert.assertEquals(140, endOffset); + Assertions.assertEquals(140, endOffset); fSlaveDocument.addMasterDocumentRange(startOffset, endOffset - startOffset); assertSlaveContents(getOriginalMasterContents().substring(80, 140)); @@ -1629,12 +1629,12 @@ public void test21_a() { private void assertEquals(DocumentEvent expected, DocumentEvent received) { assertSame(expected.getDocument(), received.getDocument()); - Assert.assertEquals(expected.getOffset(), received.getOffset()); - Assert.assertEquals(expected.getLength(), received.getLength()); + Assertions.assertEquals(expected.getOffset(), received.getOffset()); + Assertions.assertEquals(expected.getLength(), received.getLength()); if (expected.getText() == null || expected.getText().isEmpty()) assertTrue(received.getText() == null || received.getText().isEmpty()); else - Assert.assertEquals(expected.getText(), received.getText()); + Assertions.assertEquals(expected.getText(), received.getText()); } private void assertSlaveEvents(DocumentEvent[] expected, DocumentEvent[] received) { @@ -2120,9 +2120,9 @@ private void assertRegions(IRegion[] expected, IRegion[] actual) { assertNull(expected); } - assertTrue("invalid number of regions", expected.length == actual.length); + assertTrue(expected.length == actual.length, "invalid number of regions"); for (int i= 0; i < expected.length; i++) - Assert.assertEquals(print(actual[i]) + " != " + print(expected[i]), expected[i], actual[i]); + Assertions.assertEquals(expected[i], actual[i], print(actual[i]) + " != " + print(expected[i])); } private void assertUnprojectedMasterRegions(IRegion[] expected, int offsetInMaster, int lengthInMaster) { diff --git a/tests/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionMappingTest.java b/tests/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionMappingTest.java index e342babfeea..2cf994d2e7d 100644 --- a/tests/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionMappingTest.java +++ b/tests/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionMappingTest.java @@ -13,12 +13,14 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadPositionCategoryException; @@ -107,7 +109,7 @@ private void createLineWrappingProjection() { addProjection(70, 30, 10); } - @Before + @BeforeEach public void setUp() { fMasterDocument= new Document(); fSlaveDocument= new Document(); @@ -119,7 +121,7 @@ public void setUp() { } - @After + @AfterEach public void tearDown() { fMasterDocument= null; fSlaveDocument= null; @@ -627,7 +629,7 @@ public void test10c() { } private void assertRegions(IRegion[] expected, IRegion[] actual) { - assertTrue("invalid number of regions", expected.length == actual.length); + assertTrue(expected.length == actual.length, "invalid number of regions"); for (int i= 0; i < expected.length; i++) assertEquals(expected[i], actual[i]); } diff --git a/tests/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionTestSuite.java b/tests/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionTestSuite.java index 3cb66588888..9e2b94308e7 100644 --- a/tests/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionTestSuite.java +++ b/tests/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionTestSuite.java @@ -14,8 +14,8 @@ package org.eclipse.text.tests; -import org.junit.platform.suite.api.Suite; import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AbstractGapTextTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AbstractGapTextTest.java index f7b3cbb034b..c2df6791215 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AbstractGapTextTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AbstractGapTextTest.java @@ -13,8 +13,9 @@ *******************************************************************************/ package org.eclipse.text.tests; -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 org.eclipse.jface.text.GapTextStore; @@ -72,7 +73,7 @@ private String printGap(int start, int end) { } protected void assertGap(int start, int end) { - assertTrue("Invalid gap. Expected: " + printGap(start, end) + " actual:" + printGap() , fText.getGapStart() == start && fText.getGapEnd() == end); + assertTrue(fText.getGapStart() == start && fText.getGapEnd() == end, "Invalid gap. Expected: " + printGap(start, end) + " actual:" + printGap()); } protected void assertContents(String expected) { diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AbstractLineTrackerTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AbstractLineTrackerTest.java index a5593de633d..a11dc72b591 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AbstractLineTrackerTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AbstractLineTrackerTest.java @@ -13,7 +13,8 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.ILineTracker; @@ -29,14 +30,14 @@ public abstract class AbstractLineTrackerTest { protected ILineTracker fTracker; protected final void checkLines(int[] lines) throws BadLocationException { - assertEquals("number of lines", lines.length, fTracker.getNumberOfLines()); + assertEquals(lines.length, fTracker.getNumberOfLines(), "number of lines"); for (int i= 0; i < lines.length; i++) { IRegion line= fTracker.getLineInformation(i); - assertEquals("line lenght of line " + i, lines[i], line.getLength()); + assertEquals(lines[i], line.getLength(), "line lenght of line " + i); - assertEquals("line offset of line " + i, getLineOffset(i, lines), line.getOffset()); + assertEquals(getLineOffset(i, lines), line.getOffset(), "line offset of line " + i); } } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AdaptiveGapTextTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AdaptiveGapTextTest.java index db02fdf7e6b..78652e8ccea 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AdaptiveGapTextTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AdaptiveGapTextTest.java @@ -13,19 +13,19 @@ *******************************************************************************/ package org.eclipse.text.tests; -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; public class AdaptiveGapTextTest extends AbstractGapTextTest { - @Before + @BeforeEach public void setUp() { fText= new GapText(2, 10, 0.5f); fText.set("xxxxx"); } - @After + @AfterEach public void tearDown () { fText= null; } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java index 58e56a6553b..1aa8f9ebd01 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java @@ -13,7 +13,8 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.fail; + +import static org.junit.jupiter.api.Assertions.fail; import java.util.ArrayList; import java.util.Arrays; @@ -21,9 +22,9 @@ import java.util.HashSet; import java.util.Iterator; -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.jface.text.Document; import org.eclipse.jface.text.IDocument; @@ -102,7 +103,7 @@ public void removeAllAnnotations() { private Annotation fAfterIn; private Annotation fAfterOut; - @Before + @BeforeEach public void setUp() { fDocument= new Document("How much wood\nwould a woodchuck chuck\nif a woodchuck\ncould chuck wood?\n42"); @@ -129,7 +130,7 @@ public void setUp() { fAnnotationModel.connect(fDocument); } - @After + @AfterEach public void tearDown() { fAnnotationModel.disconnect(fDocument); } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java index d2aeb87408e..37ae5dc52eb 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java @@ -13,17 +13,18 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.Iterator; import java.util.Random; -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.jface.text.Document; import org.eclipse.jface.text.Position; @@ -1216,7 +1217,7 @@ public AnnotationData(int offset, int length, int annotationNumber) { private AnnotationModel fInnerModel1; private AnnotationModel fInnerModel2; - @Before + @BeforeEach public void setUp() throws Exception { fDocument= new Document(RANDOM_CONTENT); @@ -1231,7 +1232,7 @@ public void setUp() throws Exception { fAnnotationModel.connect(fDocument); } - @After + @AfterEach public void tearDown() throws Exception { fAnnotationModel.disconnect(fDocument); diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/Bug401391Test.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/Bug401391Test.java index 9ea4acf7ea7..e4dd594e3ab 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/Bug401391Test.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/Bug401391Test.java @@ -13,11 +13,12 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; + +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.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Field; import java.util.AbstractMap; @@ -26,9 +27,9 @@ import java.util.Map; import java.util.Set; -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.jface.text.Document; import org.eclipse.jface.text.Position; @@ -42,7 +43,7 @@ public class Bug401391Test { private AnnotationModel fFirstInnerModel; private AnnotationModel fSecondInnerModel; - @Before + @BeforeEach public void setUp() throws Exception { fDocument = new Document("123456789"); @@ -112,7 +113,7 @@ public Object put(Object key, Object value) { fld.set(target, new TrapMap()); } - @After + @AfterEach public void tearDown() { fAnnotationModel.disconnect(fDocument); } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/ChildDocumentTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/ChildDocumentTest.java index a1a975d1fd6..568c81c176b 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/ChildDocumentTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/ChildDocumentTest.java @@ -13,12 +13,14 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadPositionCategoryException; @@ -40,20 +42,20 @@ public class ChildDocumentTest { protected void checkPositions(Position[] positions) throws BadPositionCategoryException { Position[] v = fDocument.getPositions(IDocument.DEFAULT_CATEGORY); - assertTrue("invalid number of positions", v.length == positions.length); + assertTrue(v.length == positions.length, "invalid number of positions"); for (int i = 0; i < positions.length; i++) { - assertEquals(print(v[i]) + " != " + print(positions[i]), positions[i], v[i]); + assertEquals(positions[i], v[i], print(v[i]) + " != " + print(positions[i])); } } protected void checkPositions(Position[] expected, Position[] actual) { - assertTrue("invalid number of positions", expected.length == actual.length); + assertTrue(expected.length == actual.length, "invalid number of positions"); for (int i= 0; i < expected.length; i++) { - assertEquals(print(actual[i]) + " != " + print(expected[i]), expected[i], actual[i]); + assertEquals(expected[i], actual[i], print(actual[i]) + " != " + print(expected[i])); } } @@ -69,19 +71,19 @@ protected void checkLineInformationConsistency() throws BadLocationException { int textLines= textTracker.getNumberOfLines(); int trackerLines= fDocument.getNumberOfLines(); - assertEquals("Child document store and child line tracker are inconsistent", trackerLines, textLines); + assertEquals(trackerLines, textLines, "Child document store and child line tracker are inconsistent"); for (int i = 0; i < trackerLines; i++) { IRegion trackerLine = fDocument.getLineInformation(i); IRegion textLine = textTracker.getLineInformation(i); - assertEquals("Child document store and child line tracker are inconsistent", trackerLine.getOffset(), - textLine.getOffset()); - assertEquals("Child document store and child line tracker are inconsistent", trackerLine.getLength(), - textLine.getLength()); + assertEquals(trackerLine.getOffset(), textLine.getOffset(), + "Child document store and child line tracker are inconsistent"); + assertEquals(trackerLine.getLength(), textLine.getLength(), + "Child document store and child line tracker are inconsistent"); } } - @Before + @BeforeEach public void setUp() throws BadLocationException { fParent= new Document(); @@ -117,7 +119,7 @@ public void setUp() throws BadLocationException { } - @After + @AfterEach public void tearDown () { fDocument= null; } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/ConfigurableLineTrackerTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/ConfigurableLineTrackerTest.java index fe6f597485f..2b035879a87 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/ConfigurableLineTrackerTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/ConfigurableLineTrackerTest.java @@ -10,9 +10,10 @@ *******************************************************************************/ package org.eclipse.text.tests; -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.jface.text.ConfigurableLineTracker; import org.eclipse.jface.text.DefaultLineTracker; @@ -20,12 +21,12 @@ public class ConfigurableLineTrackerTest extends AbstractLineTrackerTest { - @Before + @BeforeEach public void setUp() { fText= new GapTextStore(); } - @After + @AfterEach public void tearDown() { fTracker= null; fText= null; diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/CopyOnWriteTextStoreTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/CopyOnWriteTextStoreTest.java index cc8fc3d5d65..3942f12c13c 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/CopyOnWriteTextStoreTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/CopyOnWriteTextStoreTest.java @@ -14,11 +14,14 @@ package org.eclipse.text.tests; -import static org.junit.Assert.*; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.CopyOnWriteTextStore; import org.eclipse.jface.text.GapTextStore; @@ -47,14 +50,14 @@ String get() { private COWTextStore fText; - @Before + @BeforeEach public void setUp() { fText= new COWTextStore(); fText.set(INITIAL_CONTENT); } - @After + @AfterEach public void tearDown () { fText= null; } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DefaultLineTrackerTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DefaultLineTrackerTest.java index 92a2cc21c88..bdcdb760d94 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DefaultLineTrackerTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DefaultLineTrackerTest.java @@ -13,9 +13,11 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.assertEquals; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java index 2f91f707a5b..9e73c4a9293 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java @@ -14,12 +14,13 @@ package org.eclipse.text.tests; -import static org.junit.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; -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/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentTest.java index 540083bd6df..9073fef87d6 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentTest.java @@ -13,12 +13,14 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadPositionCategoryException; @@ -39,15 +41,15 @@ protected void checkPositions(Position[] expected) throws BadPositionCategoryExc protected void checkPositions(Position[] expected, Position[] actual) { - assertTrue("invalid number of positions", expected.length == actual.length); + assertTrue(expected.length == actual.length, "invalid number of positions"); for (int i= 0; i < expected.length; i++) { - assertEquals("Position " + i + " wrong:", expected[i], actual[i]); + assertEquals(expected[i], actual[i], "Position " + i + " wrong:"); } } - @Before + @BeforeEach public void setUp() throws BadLocationException { fDocument= new Document(); @@ -78,7 +80,7 @@ public void setUp() throws BadLocationException { } - @After + @AfterEach public void tearDown () { fDocument= null; } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentUndoManagerTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentUndoManagerTest.java index 1a32a77353e..0681060b71a 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentUndoManagerTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentUndoManagerTest.java @@ -13,14 +13,16 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.eclipse.core.commands.ExecutionException; @@ -71,12 +73,12 @@ public class DocumentUndoManagerTest { /** The undo manager. */ private IDocumentUndoManager fUndoManager; - @Before + @BeforeEach public void setUp() { fUndoManager = null; } - @After + @AfterEach public void tearDown() { fUndoManager.disconnect(this); fUndoManager = null; diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/EclipseTextTestSuite.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/EclipseTextTestSuite.java index b70f8e44739..d2cb66ed1e2 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/EclipseTextTestSuite.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/EclipseTextTestSuite.java @@ -14,8 +14,9 @@ *******************************************************************************/ package org.eclipse.text.tests; -import org.junit.platform.suite.api.Suite; + import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; import org.eclipse.text.tests.link.LinkTestSuite; import org.eclipse.text.tests.templates.TemplatesTestSuite; diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/ExclusivePositionUpdaterTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/ExclusivePositionUpdaterTest.java index ad629798942..0c39ec61fee 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/ExclusivePositionUpdaterTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/ExclusivePositionUpdaterTest.java @@ -13,10 +13,11 @@ *******************************************************************************/ package org.eclipse.text.tests; -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.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultPositionUpdater; @@ -36,7 +37,7 @@ public class ExclusivePositionUpdaterTest { private Position fPos; private IDocument fDoc; - @Before + @BeforeEach public void setUp() throws Exception { fUpdater= new DefaultPositionUpdater(CATEGORY); fDoc= new Document("ccccccccccccccccccccccccccccccccccccccccccccc"); @@ -47,7 +48,7 @@ public void setUp() throws Exception { fDoc.addPosition(CATEGORY, fPos); } - @After + @AfterEach public void tearDown() throws Exception { fDoc.removePositionUpdater(fUpdater); fDoc.removePositionCategory(CATEGORY); @@ -58,111 +59,111 @@ public void tearDown() throws Exception { @Test public void testDeleteBefore() throws BadLocationException { fDoc.replace(2, 2, ""); - Assert.assertEquals(3, fPos.offset); - Assert.assertEquals(5, fPos.length); - Assert.assertFalse(fPos.isDeleted); + Assertions.assertEquals(3, fPos.offset); + Assertions.assertEquals(5, fPos.length); + Assertions.assertFalse(fPos.isDeleted); } @Test public void testDeleteRightBefore() throws BadLocationException { fDoc.replace(3, 2, ""); - Assert.assertEquals(3, fPos.offset); - Assert.assertEquals(5, fPos.length); - Assert.assertFalse(fPos.isDeleted); + Assertions.assertEquals(3, fPos.offset); + Assertions.assertEquals(5, fPos.length); + Assertions.assertFalse(fPos.isDeleted); } @Test public void testDeleteOverLeftBorder() throws BadLocationException { fDoc.replace(3, 6, ""); - Assert.assertEquals(3, fPos.offset); - Assert.assertEquals(1, fPos.length); - Assert.assertFalse(fPos.isDeleted); + Assertions.assertEquals(3, fPos.offset); + Assertions.assertEquals(1, fPos.length); + Assertions.assertFalse(fPos.isDeleted); } @Test public void testDeleteOverLeftBorderTillRight() throws BadLocationException { fDoc.replace(4, 6, ""); - Assert.assertEquals(4, fPos.offset); - Assert.assertEquals(0, fPos.length); - Assert.assertFalse(fPos.isDeleted); + Assertions.assertEquals(4, fPos.offset); + Assertions.assertEquals(0, fPos.length); + Assertions.assertFalse(fPos.isDeleted); } @Test public void testDeleted() throws BadLocationException { fDoc.replace(4, 7, ""); - Assert.assertTrue(fPos.isDeleted); + Assertions.assertTrue(fPos.isDeleted); } @Test public void testDeleteAtOffset() throws BadLocationException { fDoc.replace(5, 1, ""); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(4, fPos.length); - Assert.assertFalse(fPos.isDeleted); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(4, fPos.length); + Assertions.assertFalse(fPos.isDeleted); } @Test public void testDeleteAtOffset2() throws BadLocationException { fDoc.replace(5, 2, ""); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(3, fPos.length); - Assert.assertFalse(fPos.isDeleted); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(3, fPos.length); + Assertions.assertFalse(fPos.isDeleted); } @Test public void testDeleteAtOffsetTillRight() throws BadLocationException { fDoc.replace(5, 5, ""); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(0, fPos.length); - Assert.assertFalse(fPos.isDeleted); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(0, fPos.length); + Assertions.assertFalse(fPos.isDeleted); } @Test public void testDeleteAtOffsetOverRightBorder() throws BadLocationException { fDoc.replace(5, 6, ""); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(0, fPos.length); - Assert.assertFalse(fPos.isDeleted); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(0, fPos.length); + Assertions.assertFalse(fPos.isDeleted); } @Test public void testDeleteWithin() throws BadLocationException { fDoc.replace(6, 2, ""); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(3, fPos.length); - Assert.assertFalse(fPos.isDeleted); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(3, fPos.length); + Assertions.assertFalse(fPos.isDeleted); } @Test public void testDeleteAtRight() throws BadLocationException { fDoc.replace(8, 2, ""); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(3, fPos.length); - Assert.assertFalse(fPos.isDeleted); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(3, fPos.length); + Assertions.assertFalse(fPos.isDeleted); } @Test public void testDeleteOverRightBorder() throws BadLocationException { fDoc.replace(9, 2, ""); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(4, fPos.length); - Assert.assertFalse(fPos.isDeleted); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(4, fPos.length); + Assertions.assertFalse(fPos.isDeleted); } @Test public void testDeleteRightAfter() throws BadLocationException { fDoc.replace(10, 2, ""); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(5, fPos.length); - Assert.assertFalse(fPos.isDeleted); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(5, fPos.length); + Assertions.assertFalse(fPos.isDeleted); } @Test public void testDeleteAfter() throws BadLocationException { fDoc.replace(20, 2, ""); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(5, fPos.length); - Assert.assertFalse(fPos.isDeleted); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(5, fPos.length); + Assertions.assertFalse(fPos.isDeleted); } // Add, ascending by offset: @@ -170,43 +171,43 @@ public void testDeleteAfter() throws BadLocationException { @Test public void testAddBefore() throws BadLocationException { fDoc.replace(2, 0, "yy"); - Assert.assertEquals(7, fPos.offset); - Assert.assertEquals(5, fPos.length); + Assertions.assertEquals(7, fPos.offset); + Assertions.assertEquals(5, fPos.length); } @Test public void testAddRightBefore() throws BadLocationException { fDoc.replace(5, 0, "yy"); - Assert.assertEquals(7, fPos.offset); - Assert.assertEquals(5, fPos.length); + Assertions.assertEquals(7, fPos.offset); + Assertions.assertEquals(5, fPos.length); } @Test public void testAddWithin() throws BadLocationException { fDoc.replace(6, 0, "yy"); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(7, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(7, fPos.length); } @Test public void testAddWithin2() throws BadLocationException { fDoc.replace(9, 0, "yy"); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(7, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(7, fPos.length); } @Test public void testAddRightAfter() throws BadLocationException { fDoc.replace(10, 0, "yy"); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(5, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(5, fPos.length); } @Test public void testAddAfter() throws BadLocationException { fDoc.replace(20, 0, "yy"); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(5, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(5, fPos.length); } // Replace, ascending by offset, length: @@ -214,88 +215,88 @@ public void testAddAfter() throws BadLocationException { @Test public void testReplaceBefore() throws BadLocationException { fDoc.replace(2, 2, "y"); - Assert.assertEquals(4, fPos.offset); - Assert.assertEquals(5, fPos.length); + Assertions.assertEquals(4, fPos.offset); + Assertions.assertEquals(5, fPos.length); } @Test public void testReplaceRightBefore() throws BadLocationException { fDoc.replace(2, 3, "y"); - Assert.assertEquals(3, fPos.offset); - Assert.assertEquals(5, fPos.length); + Assertions.assertEquals(3, fPos.offset); + Assertions.assertEquals(5, fPos.length); } @Test public void testReplaceLeftBorder() throws BadLocationException { fDoc.replace(4, 2, "yy"); - Assert.assertEquals(6, fPos.offset); - Assert.assertEquals(4, fPos.length); + Assertions.assertEquals(6, fPos.offset); + Assertions.assertEquals(4, fPos.length); } @Test public void testReplaceLeftBorderTillRight() throws BadLocationException { fDoc.replace(4, 6, "yy"); - Assert.assertEquals(6, fPos.offset); - Assert.assertEquals(0, fPos.length); + Assertions.assertEquals(6, fPos.offset); + Assertions.assertEquals(0, fPos.length); } @Test public void testReplaced() throws BadLocationException { fDoc.replace(4, 7, "yyyyyyy"); - Assert.assertTrue(fPos.isDeleted); + Assertions.assertTrue(fPos.isDeleted); } @Test public void testReplaceAtOffset1() throws BadLocationException { fDoc.replace(5, 1, "yy"); // 01234[fPo]0123456789 - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(6, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(6, fPos.length); } @Test public void testReplaceAtOffset2() throws BadLocationException { fDoc.replace(5, 4, "yy"); // 01234[fPo]0123456789 - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(3, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(3, fPos.length); } @Test public void testReplaceAtOffsetTillRight() throws BadLocationException { fDoc.replace(5, 5, "yy"); // 01234[fPo]0123456789 - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(2, fPos.length); - Assert.assertFalse(fPos.isDeleted); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(2, fPos.length); + Assertions.assertFalse(fPos.isDeleted); } @Test public void testReplaceAtRight() throws BadLocationException { fDoc.replace(6, 4, "yy"); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(3, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(3, fPos.length); } @Test public void testReplaceRightBorder() throws BadLocationException { fDoc.replace(9, 2, "yy"); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(4, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(4, fPos.length); } @Test public void testReplaceRightAfter() throws BadLocationException { fDoc.replace(10, 2, "y"); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(5, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(5, fPos.length); } @Test public void testReplaceAfter() throws BadLocationException { fDoc.replace(20, 2, "y"); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(5, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(5, fPos.length); } } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/FindReplaceDocumentAdapterTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/FindReplaceDocumentAdapterTest.java index 98de7eb46d7..7966fb0684f 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/FindReplaceDocumentAdapterTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/FindReplaceDocumentAdapterTest.java @@ -15,22 +15,23 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThrows; -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.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Arrays; import java.util.Locale; import java.util.regex.PatternSyntaxException; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -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.Disabled; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; @@ -49,7 +50,7 @@ public class FindReplaceDocumentAdapterTest { private Document fDocument; - @Before + @BeforeEach public void setUp() { fDocument= new Document(); @@ -72,12 +73,12 @@ public void setUp() { fDocument.set(text); } - @After + @AfterEach public void tearDown () { fDocument= null; } - @org.junit.Test + @Test public void testFind() { FindReplaceDocumentAdapter findReplaceDocumentAdapter= new FindReplaceDocumentAdapter(fDocument); try { @@ -96,7 +97,7 @@ public void testFind() { assertEquals(r, result); } catch (BadLocationException e) { - Assert.assertTrue(false); + Assertions.assertTrue(false); } } @@ -114,7 +115,7 @@ public void testFindCaretInMiddleOfWord() { assertNull(r); } catch (BadLocationException e) { - Assert.assertTrue(false); + Assertions.assertTrue(false); } } @@ -128,7 +129,7 @@ public void testFindCaretAtWordStart() { assertEquals(new Region(8, 11), r); } catch (BadLocationException e) { - Assert.assertTrue(false); + Assertions.assertTrue(false); } } @@ -142,7 +143,7 @@ public void testFindCaretAtEndStart() { assertEquals(new Region(8, 11), r); } catch (BadLocationException e) { - Assert.assertTrue(false); + Assertions.assertTrue(false); } } @@ -157,7 +158,7 @@ public void testBug74993() { assertEquals(new Region(6, 1), r); } catch (BadLocationException e) { - Assert.assertTrue(false); + Assertions.assertTrue(false); } } @@ -171,7 +172,7 @@ public void testBug386751() { IRegion result= adapter.find(0, ".", true, false, true, false); assertNull(result); } catch (BadLocationException e) { - Assert.assertTrue(false); + Assertions.assertTrue(false); } } @@ -194,7 +195,7 @@ public void testUTF8Pattern() { assertEquals(result, r); } catch (BadLocationException e) { - Assert.assertTrue(false); + Assertions.assertTrue(false); } } @@ -239,12 +240,12 @@ public void testReplace() { assertEquals(text, fDocument.get()); } catch (BadLocationException e) { - Assert.assertTrue(false); + Assertions.assertTrue(false); } } @Test - @Ignore + @Disabled public void _testRegexReplace() throws Exception { fDocument.set( "UnixWindowsMacInferred\n" + @@ -412,7 +413,7 @@ public void testRegexFindLinebreak2_fail() throws Exception { } @Test - @Ignore + @Disabled public void _testRegexFindLinebreak2() throws Exception { FindReplaceDocumentAdapter adapter= new FindReplaceDocumentAdapter(fDocument); String contents= "+[\\R]\\R\r\n"; @@ -482,18 +483,18 @@ public void testIllegalState() { try { findReplaceDocumentAdapter.replace("TestPackage", false); //$NON-NLS-1$ } catch (IllegalStateException e) { - Assert.assertTrue(true); + Assertions.assertTrue(true); } catch (BadLocationException e) { - Assert.assertTrue(false); + Assertions.assertTrue(false); } findReplaceDocumentAdapter= new FindReplaceDocumentAdapter(fDocument); try { findReplaceDocumentAdapter.replace("TestPackage", true); //$NON-NLS-1$ } catch (IllegalStateException e) { - Assert.assertTrue(true); + Assertions.assertTrue(true); } catch (BadLocationException e) { - Assert.assertTrue(false); + Assertions.assertTrue(false); } } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/GapTextTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/GapTextTest.java index 24ef93a32f8..eb78fecb91e 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/GapTextTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/GapTextTest.java @@ -13,22 +13,22 @@ *******************************************************************************/ package org.eclipse.text.tests; -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; public class GapTextTest extends AbstractGapTextTest { /** * @deprecated tests the legacy constructor of GapTextStore */ @Deprecated - @Before + @BeforeEach public void setUp() { fText= new GapText(5, 10); fText.set("xxxxx"); } - @After + @AfterEach public void tearDown () { fText= null; } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest3.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest3.java index b574f5d8ceb..6285009795a 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest3.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest3.java @@ -14,11 +14,15 @@ package org.eclipse.text.tests; -import static org.junit.Assert.*; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.ConfigurableLineTracker; @@ -27,14 +31,14 @@ public class LineTrackerTest3 extends AbstractLineTrackerTest { - @Before + @BeforeEach public void setUp() { fText= new GapTextStore(); fTracker= new ConfigurableLineTracker(new String[] { "\n" }); set("x\nx\nx\nx\nx\n"); } - @After + @AfterEach public void tearDown() { fTracker= null; fText= null; @@ -80,7 +84,7 @@ public void testEmptyLines() throws Exception { for (int i= 0; i < 6; i++) { int no= fTracker.getLineNumberOfOffset(i); - assertTrue("invalid line number " + no + " reported instead of " + i, no == i); + assertTrue(no == i, "invalid line number " + no + " reported instead of " + i); } } @@ -123,7 +127,7 @@ public void testLinesNumbers() throws Exception { for (int i= 0; i < 5; i++) { for (int j= 0; j < i; j++) { int no= fTracker.getLineNumberOfOffset(offset + j); - assertTrue("invalid line number " + no + " reported instead of " + i, no == i); + assertTrue(no == i, "invalid line number " + no + " reported instead of " + i); } offset+= (i + 1); } @@ -137,19 +141,19 @@ public void testOffsets() throws Exception { IRegion line= fTracker.getLineInformation(i); int pos= line.getOffset() + line.getLength(); int offset= (2 * i) + 1; - assertTrue("invalid line end offset " + pos + " for line " + i + " should be " + offset, offset == pos); + assertTrue(offset == pos, "invalid line end offset " + pos + " for line " + i + " should be " + offset); } for (int i= 0; i < 5; i++) { int pos= fTracker.getLineOffset(i); int offset= 2 * i; - assertTrue("invalid line start offset " + pos + " for line " + i + " should be " + offset, pos == offset); + assertTrue(pos == offset, "invalid line start offset " + pos + " for line " + i + " should be " + offset); } for (int i= 0; i < 10; i++) { int line= fTracker.getLineNumberOfOffset(i); double l= Math.floor(i / 2); - assertTrue("invalid line number " + line + " for position " + i + " should be " + l, l == line); + assertTrue(l == line, "invalid line number " + line + " for position " + i + " should be " + l); } } @@ -229,7 +233,7 @@ public void testShiftLeft() throws Exception { } String txt= fText.get(0, fText.getLength()); - assertEquals("invalid text", "x\nx\nx\nx\nx\n", txt); + assertEquals("x\nx\nx\nx\nx\n", txt, "invalid text"); } @Test @@ -244,7 +248,7 @@ public void testShiftRight() throws Exception { checkLines(new int[] { 2, 2, 2, 2, 2, 0 }); String txt= fText.get(0, fText.getLength()); - assertEquals("invalid text", "\tx\n\tx\n\tx\n\tx\n\tx\n", txt); + assertEquals("\tx\n\tx\n\tx\n\tx\n\tx\n", txt, "invalid text"); } @Test @@ -324,12 +328,12 @@ public void testFunnyLastLineCompatibility() throws Exception { int[] offsets= { 0, 2 }; int[] lengths= { 1, 0 }; - assertEquals("invalid number of lines, ", lengths.length, fTracker.getNumberOfLines()); - assertEquals("invalid number of lines, ", lengths.length, fTracker.getNumberOfLines(0, fText.getLength())); + assertEquals(lengths.length, fTracker.getNumberOfLines(), "invalid number of lines, "); + assertEquals(lengths.length, fTracker.getNumberOfLines(0, fText.getLength()), "invalid number of lines, "); for (int i= 0; i < lengths.length; i++) { IRegion line= fTracker.getLineInformation(i); - assertEquals("line: " + i, lengths[i], line.getLength()); - assertEquals("line: " + i, offsets[i], line.getOffset()); + assertEquals(lengths[i], line.getLength(), "line: " + i); + assertEquals(offsets[i], line.getOffset(), "line: " + i); } try { fTracker.getLineInformation(lengths.length); @@ -348,22 +352,22 @@ public void testFunnyLastLineCompatibility() throws Exception { set("x\nx"); offsets= new int[] { 0, 2, 3 }; lengths= new int[] {1, 1, 0}; - assertEquals("invalid number of lines, ", lengths.length - 1 /* !!!! */, fTracker.getNumberOfLines()); - assertEquals("invalid number of lines, ", lengths.length - 1 /* !!!! */, fTracker.getNumberOfLines(0, fText.getLength())); + assertEquals(lengths.length - 1 /* !!!! */, fTracker.getNumberOfLines(), "invalid number of lines, "); + assertEquals(lengths.length - 1 /* !!!! */, fTracker.getNumberOfLines(0, fText.getLength()), "invalid number of lines, "); for (int i= 0; i < lengths.length; i++) { IRegion line= fTracker.getLineInformation(i); int len= lengths[i]; int offset= offsets[i]; - assertEquals("length of line: " + i, len, line.getLength()); - assertEquals("offset of line: " + i, offset, line.getOffset()); + assertEquals(len, line.getLength(), "length of line: " + i); + assertEquals(offset, line.getOffset(), "offset of line: " + i); line= fTracker.getLineInformationOfOffset(offset); if ( i == lengths.length - 1) { // phantom line cannot be queried by offset len= lengths[i - 1]; offset= offsets[i - 1]; } - assertEquals("length of line: " + i, len, line.getLength()); - assertEquals("offset of line: " + i, offset, line.getOffset()); + assertEquals(len, line.getLength(), "length of line: " + i); + assertEquals(offset, line.getOffset(), "offset of line: " + i); } try { @@ -398,12 +402,12 @@ public void testFunnyLastLineCompatibility2() throws Exception { int[] offsets= { 0, 2 }; int[] lengths= { 1, 0 }; - assertEquals("invalid number of lines, ", lengths.length, fTracker.getNumberOfLines()); - assertEquals("invalid number of lines, ", lengths.length, fTracker.getNumberOfLines(0, fText.getLength())); + assertEquals(lengths.length, fTracker.getNumberOfLines(), "invalid number of lines, "); + assertEquals(lengths.length, fTracker.getNumberOfLines(0, fText.getLength()), "invalid number of lines, "); for (int i= 0; i < lengths.length; i++) { IRegion line= fTracker.getLineInformation(i); - assertEquals("line: " + i, lengths[i], line.getLength()); - assertEquals("line: " + i, offsets[i], line.getOffset()); + assertEquals(lengths[i], line.getLength(), "line: " + i); + assertEquals(offsets[i], line.getOffset(), "line: " + i); } try { fTracker.getLineInformation(lengths.length); @@ -422,22 +426,22 @@ public void testFunnyLastLineCompatibility2() throws Exception { set("x\nx"); offsets= new int[] { 0, 2, 3 }; lengths= new int[] {1, 1, 0}; - assertEquals("invalid number of lines, ", lengths.length - 1 /* !!!! */, fTracker.getNumberOfLines()); - assertEquals("invalid number of lines, ", lengths.length - 1 /* !!!! */, fTracker.getNumberOfLines(0, fText.getLength())); + assertEquals(lengths.length - 1 /* !!!! */, fTracker.getNumberOfLines(), "invalid number of lines, "); + assertEquals(lengths.length - 1 /* !!!! */, fTracker.getNumberOfLines(0, fText.getLength()), "invalid number of lines, "); for (int i= 0; i < lengths.length; i++) { IRegion line= fTracker.getLineInformation(i); int len= lengths[i]; int offset= offsets[i]; - assertEquals("length of line: " + i, len, line.getLength()); - assertEquals("offset of line: " + i, offset, line.getOffset()); + assertEquals(len, line.getLength(), "length of line: " + i); + assertEquals(offset, line.getOffset(), "offset of line: " + i); line= fTracker.getLineInformationOfOffset(offset); if ( i == lengths.length - 1) { // phantom line cannot be queried by offset len= lengths[i - 1]; offset= offsets[i - 1]; } - assertEquals("length of line: " + i, len, line.getLength()); - assertEquals("offset of line: " + i, offset, line.getOffset()); + assertEquals(len, line.getLength(), "length of line: " + i); + assertEquals(offset, line.getOffset(), "offset of line: " + i); } try { @@ -555,8 +559,8 @@ public void testNegativeOffset2() throws Exception { public void testBug545565_setNull() throws BadLocationException { int initialContentLength= fText.getLength(); set(null); - assertEquals("Tracker not empty.", 1, fTracker.getNumberOfLines()); - assertEquals("Tracker not empty.", 0, fTracker.getLineLength(0)); + assertEquals(1, fTracker.getNumberOfLines(), "Tracker not empty."); + assertEquals(0, fTracker.getLineLength(0), "Tracker not empty."); try { fTracker.getLineInformationOfOffset(5); fail("No exception for bad location."); @@ -601,6 +605,6 @@ public void testBug545565_compareTrackerResult() throws BadLocationException { int lineFromListTracker= fTracker.getLineNumberOfOffset(0); replace(0, 0, null); int lineFromTreeTracker= fTracker.getLineNumberOfOffset(0); - assertEquals("Trackers returned different lines for same offset.", lineFromTreeTracker, lineFromListTracker); + assertEquals(lineFromTreeTracker, lineFromListTracker, "Trackers returned different lines for same offset."); } } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest4.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest4.java index 18339653c9d..11685b76f57 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest4.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest4.java @@ -13,11 +13,14 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.*; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.ConfigurableLineTracker; import org.eclipse.jface.text.GapTextStore; @@ -26,14 +29,14 @@ public class LineTrackerTest4 extends AbstractLineTrackerTest { - @Before + @BeforeEach public void setUp() { fText= new GapTextStore(); fTracker= new ConfigurableLineTracker(new String[] { "\r\n" }); set("x\r\nx\r\nx\r\nx\r\nx\r\n"); } - @After + @AfterEach public void tearDown() { fTracker= null; fText= null; @@ -80,7 +83,7 @@ public void testEmptyLines() throws Exception { for (int i= 0; i < 10; i++) { int no= fTracker.getLineNumberOfOffset(i); double l= Math.floor(i / 2); - assertTrue("invalid line number " + no + " for position " + i + " should be " + l, l == no); + assertTrue(l == no, "invalid line number " + no + " for position " + i + " should be " + l); } } @@ -123,7 +126,7 @@ public void testLinesNumbers() throws Exception { for (int i= 0; i < 5; i++) { for (int j= 0; j <= i; j++) { int no= fTracker.getLineNumberOfOffset(offset + j); - assertTrue("invalid line number " + no + " reported instead of " + i, no == i); + assertTrue(no == i, "invalid line number " + no + " reported instead of " + i); } offset+= (i + 2); } @@ -137,29 +140,29 @@ public void testOffsets() throws Exception { IRegion line= fTracker.getLineInformation(i); int pos= line.getOffset() + line.getLength() + 1; int offset= (3 * i) + 2; - assertTrue("invalid line end offset " + pos + " for line " + i + " should be " + offset, offset == pos); + assertTrue(offset == pos, "invalid line end offset " + pos + " for line " + i + " should be " + offset); } for (int i= 0; i < 5; i++) { int pos= fTracker.getLineOffset(i); int offset= 3 * i; - assertTrue("invalid line start offset " + pos + " for line " + i + " should be " + offset, pos == offset); + assertTrue(pos == offset, "invalid line start offset " + pos + " for line " + i + " should be " + offset); } for (int i= 0; i < 15; i++) { int line= fTracker.getLineNumberOfOffset(i); double l= Math.floor(i / 3); - assertTrue("invalid line number " + line + " for position " + i + " should be " + l, l == line); + assertTrue(l == line, "invalid line number " + line + " for position " + i + " should be " + l); } int lastLine= fTracker.getLineNumberOfOffset(fText.getLength()); - assertTrue("invalid last line number " + lastLine, 5 == lastLine); + assertTrue(5 == lastLine, "invalid last line number " + lastLine); int offset= fTracker.getLineOffset(lastLine); - assertTrue("invalid last line start offset " + offset, fText.getLength() == offset); + assertTrue(fText.getLength() == offset, "invalid last line start offset " + offset); int length= fTracker.getLineLength(lastLine); - assertTrue("invalid last line end offset " + (offset + length - 1), 0 == length); + assertTrue(0 == length, "invalid last line end offset " + (offset + length - 1)); } @Test @@ -200,7 +203,7 @@ public void testShiftLeft() throws Exception { } String txt= fText.get(0, fText.getLength()); - assertEquals("invalid text", "x\r\nx\r\nx\r\nx\r\nx\r\n", txt); + assertEquals("x\r\nx\r\nx\r\nx\r\nx\r\n", txt, "invalid text"); } @Test @@ -215,6 +218,6 @@ public void testShiftRight() throws Exception { checkLines(new int[] { 2, 2, 2, 2, 2, 0 }); String txt= fText.get(0, fText.getLength()); - assertEquals("invalid text", "\tx\r\n\tx\r\n\tx\r\n\tx\r\n\tx\r\n", txt); + assertEquals("\tx\r\n\tx\r\n\tx\r\n\tx\r\n\tx\r\n", txt, "invalid text"); } } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/MultiStringMatcherTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/MultiStringMatcherTest.java index 22217f8f982..2a4e0332197 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/MultiStringMatcherTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/MultiStringMatcherTest.java @@ -10,15 +10,16 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThrows; + +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.assertThrows; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.MultiStringMatcher; import org.eclipse.jface.text.MultiStringMatcher.Match; @@ -35,14 +36,14 @@ private static Match run(String text, int offset, String... needles) { private static Match run(TestCharSequence text, int offset, String... needles) { Match result = MultiStringMatcher.indexOf(text, offset, needles); - assertEquals("Algorithm backtracked", 0, text.getBackTrack()); + assertEquals(0, text.getBackTrack(), "Algorithm backtracked"); return result; } private static void test(Match m, String expected, int index) { - assertNotNull("No match", m); - assertEquals("Unexpected match", expected, m.getText()); - assertEquals("Unexpected index", index, m.getOffset()); + assertNotNull(m, "No match"); + assertEquals(expected, m.getText(), "Unexpected match"); + assertEquals(index, m.getOffset(), "Unexpected index"); } private static void testList(List matches, String expected) { @@ -53,7 +54,7 @@ private static void testList(List matches, String expected) { } return Integer.compare(a.getText().length(), b.getText().length()); }); - assertEquals("Unexpected results", expected, matches.toString()); + assertEquals(expected, matches.toString(), "Unexpected results"); } @Test @@ -137,13 +138,13 @@ public void test013() throws Exception { @Test public void test014() throws Exception { Match m = run("", "a", "b", "ab"); - assertNull("Expected no match", m); + assertNull(m, "Expected no match"); } @Test public void test015() throws Exception { Match m = run("dddca", "ac", "cac", "ab"); - assertNull("Expected no match", m); + assertNull(m, "Expected no match"); } @Test @@ -221,7 +222,7 @@ public void test027() throws Exception { @Test public void test028() throws Exception { Match m = run("dddhisheddd", 7, "he", "she", "his", "hers"); - assertNull("Expected no match", m); + assertNull(m, "Expected no match"); } @Test @@ -377,7 +378,7 @@ public void multi011() throws Exception { public void multi012() throws Exception { MultiStringMatcher m = MultiStringMatcher.create("she", "his", "hers"); List matches = m.find("dddhiheddd", 0); - assertEquals("Expected no match", 0, matches.size()); + assertEquals(0, matches.size(), "Expected no match"); } @Test @@ -397,25 +398,25 @@ public void multi014() throws Exception { @Test public void noStrings001() throws Exception { MultiStringMatcher m = MultiStringMatcher.builder().build(); - assertNull("Expected no match", m.indexOf("dhihedd", 0)); + assertNull(m.indexOf("dhihedd", 0), "Expected no match\""); List matches = m.find("dddhiheddd", 0); - assertEquals("Expected no match", 0, matches.size()); + assertEquals(0, matches.size(), "Expected no match"); } @Test public void noStrings002() throws Exception { MultiStringMatcher m = MultiStringMatcher.builder().add("").build(); - assertNull("Expected no match", m.indexOf("dhihedd", 0)); + assertNull(m.indexOf("dhihedd", 0), "Expected no match"); List matches = m.find("dddhiheddd", 0); - assertEquals("Expected no match", 0, matches.size()); + assertEquals(0, matches.size(), "Expected no match"); } @Test public void noStrings003() throws Exception { MultiStringMatcher m = MultiStringMatcher.builder().add((String[]) null).build(); - assertNull("Expected no match", m.indexOf("dhihedd", 0)); + assertNull(m.indexOf("dhihedd", 0), "Expected no match"); List matches = m.find("dddhiheddd", 0); - assertEquals("Expected no match", 0, matches.size()); + assertEquals(0, matches.size(), "Expected no match"); } @Test @@ -455,7 +456,7 @@ public void scan001() throws Exception { TestCharSequence text = new TestCharSequence("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); Match m = run(text, 0, "x", "xx", "xxx", "xxxx"); test(m, "xxxx", 0); - assertEquals("Scanned too far", 3, text.getLastIndex()); + assertEquals(3, text.getLastIndex(), "Scanned too far"); } @Test @@ -463,7 +464,7 @@ public void scan002() throws Exception { TestCharSequence text = new TestCharSequence("ddcababababababcabxdd"); Match m = run(text, 0, "ca", "cabx", "ababc"); test(m, "ca", 2); - assertEquals("Scanned too far", 5, text.getLastIndex()); + assertEquals(5, text.getLastIndex(), "Scanned too far"); } @Test @@ -471,7 +472,7 @@ public void scan003() throws Exception { TestCharSequence text = new TestCharSequence("ddcabarbarazz"); Match m = run(text, 0, "a", "cabby", "barbara"); test(m, "a", 3); - assertEquals("Scanned too far", 5, text.getLastIndex()); + assertEquals(5, text.getLastIndex(), "Scanned too far"); } private static class TestCharSequence implements CharSequence { diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/PositionUpdatingCornerCasesTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/PositionUpdatingCornerCasesTest.java index 6c347a1c93c..01f15362c62 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/PositionUpdatingCornerCasesTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/PositionUpdatingCornerCasesTest.java @@ -13,11 +13,13 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import org.junit.After; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.BadPositionCategoryException; import org.eclipse.jface.text.Document; @@ -31,10 +33,10 @@ public class PositionUpdatingCornerCasesTest { protected void checkPositions(Position[] expected) throws BadPositionCategoryException { Position[] actual= fDocument.getPositions(IDocument.DEFAULT_CATEGORY); - assertTrue("invalid number of positions", actual.length == expected.length); + assertTrue(actual.length == expected.length, "invalid number of positions"); for (int i= 0; i < expected.length; i++) { - assertEquals(print(actual[i]) + " != " + print(expected[i]), expected[i], actual[i]); + assertEquals(expected[i], actual[i], print(actual[i]) + " != " + print(expected[i])); } } @@ -42,7 +44,7 @@ protected String print(Position p) { return "[" + p.getOffset() + "," + p.getLength() + "]"; } - @After + @AfterEach public void tearDown() { fDocument= null; } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java index 107883459d3..136a3f41bee 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java @@ -13,17 +13,19 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.*; + +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 java.util.ArrayList; import java.util.Comparator; import java.util.List; -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.text.edits.CopySourceEdit; import org.eclipse.text.edits.CopyTargetEdit; @@ -49,13 +51,13 @@ public class TextEditTests { private IDocument fDocument; private MultiTextEdit fRoot; - @Before + @BeforeEach public void setUp() { fDocument= new Document("0123456789"); fRoot= new MultiTextEdit(); } - @After + @AfterEach public void tearDown() { fRoot= null; fRoot= null; @@ -65,14 +67,14 @@ public void tearDown() { public void testCovers1() throws Exception { InsertEdit insert= new InsertEdit(1, ""); DeleteEdit delete= new DeleteEdit(2, 2); - Assert.assertFalse(insert.covers(delete)); + Assertions.assertFalse(insert.covers(delete)); } @Test public void testCovers2() throws Exception { MultiTextEdit multi= new MultiTextEdit(0,0); MultiTextEdit child= new MultiTextEdit(0,0); - Assert.assertTrue(multi.covers(child)); + Assertions.assertTrue(multi.covers(child)); } @Test @@ -221,11 +223,11 @@ public void testUndefinedMultiEdit2() throws Exception { @Test public void testUndefinedMultiEdit3() throws Exception { MultiTextEdit m2= new MultiTextEdit(); - Assert.assertEquals(0, m2.getOffset()); - Assert.assertEquals(0, m2.getLength()); + Assertions.assertEquals(0, m2.getOffset()); + Assertions.assertEquals(0, m2.getLength()); m2.addChild(new DeleteEdit(1,3)); - Assert.assertEquals(1, m2.getOffset()); - Assert.assertEquals(3, m2.getLength()); + Assertions.assertEquals(1, m2.getOffset()); + Assertions.assertEquals(3, m2.getLength()); } @Test @@ -233,8 +235,8 @@ public void testUndefinedMultiEdit4() throws Exception { MultiTextEdit m2= new MultiTextEdit(); m2.addChild(new DeleteEdit(1,3)); m2.addChild(new DeleteEdit(4, 2)); - Assert.assertEquals(1, m2.getOffset()); - Assert.assertEquals(5, m2.getLength()); + Assertions.assertEquals(1, m2.getOffset()); + Assertions.assertEquals(5, m2.getLength()); } @Test @@ -242,8 +244,8 @@ public void testUndefinedMultiEdit5() throws Exception { MultiTextEdit m2= new MultiTextEdit(); m2.addChild(new DeleteEdit(4, 2)); m2.addChild(new DeleteEdit(1,3)); - Assert.assertEquals(1, m2.getOffset()); - Assert.assertEquals(5, m2.getLength()); + Assertions.assertEquals(1, m2.getOffset()); + Assertions.assertEquals(5, m2.getLength()); } @Test @@ -324,25 +326,25 @@ private static void flatten(List result, TextEdit edit) { } private static void compare(List org, List copy) { - assertTrue("Same length", org.size() == copy.size()); + assertTrue(org.size() == copy.size(), "Same length"); for (TextEdit edit : copy) { - assertTrue("Original is part of copy list", !org.contains(edit)); + assertTrue(!org.contains(edit), "Original is part of copy list"); if (edit instanceof MoveSourceEdit) { MoveSourceEdit source= (MoveSourceEdit)edit; - assertTrue("Target edit isn't a copy", copy.contains(source.getTargetEdit())); - assertTrue("Traget edit is a original", !org.contains(source.getTargetEdit())); + assertTrue(copy.contains(source.getTargetEdit()), "Target edit isn't a copy"); + assertTrue(!org.contains(source.getTargetEdit()), "Traget edit is a original"); } else if (edit instanceof MoveTargetEdit) { MoveTargetEdit target= (MoveTargetEdit)edit; - assertTrue("Source edit isn't a copy", copy.contains(target.getSourceEdit())); - assertTrue("Source edit is a original", !org.contains(target.getSourceEdit())); + assertTrue(copy.contains(target.getSourceEdit()), "Source edit isn't a copy"); + assertTrue(!org.contains(target.getSourceEdit()), "Source edit is a original"); } else if (edit instanceof CopySourceEdit) { CopySourceEdit source= (CopySourceEdit)edit; - assertTrue("Target edit isn't a copy", copy.contains(source.getTargetEdit())); - assertTrue("Traget edit is a original", !org.contains(source.getTargetEdit())); + assertTrue(copy.contains(source.getTargetEdit()), "Target edit isn't a copy"); + assertTrue(!org.contains(source.getTargetEdit()), "Traget edit is a original"); } else if (edit instanceof CopyTargetEdit) { CopyTargetEdit target= (CopyTargetEdit)edit; - assertTrue("Source edit isn't a copy", copy.contains(target.getSourceEdit())); - assertTrue("Source edit is a original", !org.contains(target.getSourceEdit())); + assertTrue(copy.contains(target.getSourceEdit()), "Source edit isn't a copy"); + assertTrue(!org.contains(target.getSourceEdit()), "Source edit is a original"); } } } @@ -358,7 +360,7 @@ public void testInsert1() throws Exception { assertEquals(fRoot, 2, 6); assertEquals(e1, 2, 2); assertEquals(e2, 4, 4); - Assert.assertEquals("Buffer content", "01yy345656789", fDocument.get()); + Assertions.assertEquals("01yy345656789", fDocument.get()); doUndoRedo(undo, "01yy345656789"); } @@ -373,7 +375,7 @@ public void testInsert2() throws Exception { assertEquals(fRoot, 2, 4); assertEquals(e1, 2, 2); assertEquals(e2, 4, 2); - Assert.assertEquals("Buffer content", "01yyxx23456789", fDocument.get()); + Assertions.assertEquals("01yyxx23456789", fDocument.get()); doUndoRedo(undo, "01yyxx23456789"); } @@ -391,7 +393,7 @@ public void testInsert3() throws Exception { assertEquals(e1, 0, 3); assertEquals(e2, 3, 2); assertEquals(e3, 5, 1); - Assert.assertEquals("Buffer content", "011xx2456789", fDocument.get()); + Assertions.assertEquals("011xx2456789", fDocument.get()); doUndoRedo(undo, "011xx2456789"); } @@ -400,10 +402,10 @@ public void testInsert4() throws Exception { TextEdit e1= new InsertEdit(0, "xx"); fRoot.addChild(e1); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer length", 12, fDocument.getLength()); + Assertions.assertEquals(12, fDocument.getLength(), "Buffer length"); assertEquals(fRoot, 0, 2); assertEquals(e1, 0, 2); - Assert.assertEquals("Buffer content", "xx0123456789", fDocument.get()); + Assertions.assertEquals("xx0123456789", fDocument.get()); doUndoRedo(undo, "xx0123456789"); } @@ -412,10 +414,10 @@ public void testInsert5() throws Exception { TextEdit e1= new InsertEdit(10, "xx"); fRoot.addChild(e1); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer length", 12, fDocument.getLength()); + Assertions.assertEquals(12, fDocument.getLength(), "Buffer length"); assertEquals(fRoot, 10, 2); assertEquals(e1, 10, 2); - Assert.assertEquals("Buffer content", "0123456789xx", fDocument.get()); + Assertions.assertEquals("0123456789xx", fDocument.get()); doUndoRedo(undo, "0123456789xx"); } @@ -429,7 +431,7 @@ public void testInsertReplace1() throws Exception { assertEquals(fRoot, 2, 3); assertEquals(e1, 4, 1); assertEquals(e2, 2, 2); - Assert.assertEquals("Buffer content", "01xxy3456789", fDocument.get()); + Assertions.assertEquals("01xxy3456789", fDocument.get()); doUndoRedo(undo, "01xxy3456789"); } @@ -440,7 +442,7 @@ public void testDelete1() throws Exception { UndoEdit undo= fRoot.apply(fDocument); assertEquals(fRoot, 3, 0); assertEquals(e1, 3, 0); - Assert.assertEquals("Buffer content", "012456789", fDocument.get()); + Assertions.assertEquals("012456789", fDocument.get()); doUndoRedo(undo, "012456789"); } @@ -457,7 +459,7 @@ public void testDelete2() throws Exception { assertEquals(e1, 3, 0); assertEquals(e2, 3, 0); assertEquals(e3, 3, 0); - Assert.assertEquals("Buffer content", "0126789", fDocument.get()); + Assertions.assertEquals("0126789", fDocument.get()); doUndoRedo(undo, "0126789"); } @@ -471,7 +473,7 @@ public void testDelete3() throws Exception { assertEquals(fRoot, 3, 1); assertEquals(e1, 3, 1); assertEquals(e2, 4, 0); - Assert.assertEquals("Buffer content", "012x456789", fDocument.get()); + Assertions.assertEquals("012x456789", fDocument.get()); doUndoRedo(undo, "012x456789"); } @@ -486,7 +488,7 @@ public void testDeleteWithChildren() throws Exception { e2.addChild(e4); fRoot.addChild(e1); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "0189", fDocument.get()); + Assertions.assertEquals("0189", fDocument.get()); assertEquals(fRoot, 2, 0); assertEquals(e1, 2, 0); assertTrue(e2.isDeleted()); @@ -512,7 +514,7 @@ public void testTreeUpdate1() throws Exception { assertEquals(m1, 2, 2); assertEquals(m2, 6, 2); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "01aa23bb45cc67dd89", fDocument.get()); + Assertions.assertEquals("01aa23bb45cc67dd89", fDocument.get()); assertEquals(e1, 2, 2); assertEquals(e2, 6, 2); assertEquals(e3, 10, 2); @@ -530,7 +532,7 @@ public void testMove1() throws Exception { fRoot.addChild(s1); fRoot.addChild(t1); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "0142356789", fDocument.get()); + Assertions.assertEquals("0142356789", fDocument.get()); assertEquals(s1, 2, 0); assertEquals(t1, 3, 2); doUndoRedo(undo, "0142356789"); @@ -543,7 +545,7 @@ public void testMove2() throws Exception { fRoot.addChild(s1); fRoot.addChild(t1); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "0156234789", fDocument.get()); + Assertions.assertEquals("0156234789", fDocument.get()); assertEquals(s1, 7, 0); assertEquals(t1, 2, 2); doUndoRedo(undo, "0156234789"); @@ -558,7 +560,7 @@ public void testMove3() throws Exception { fRoot.addChild(t1); fRoot.addChild(e2); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "01x5623789", fDocument.get()); + Assertions.assertEquals("01x5623789", fDocument.get()); assertEquals(s1, 2, 0); assertEquals(t1, 5, 2); assertEquals(e2, 2, 1); @@ -574,7 +576,7 @@ public void testMove4() throws Exception { fRoot.addChild(t1); fRoot.addChild(e2); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "0178234x69", fDocument.get()); + Assertions.assertEquals("0178234x69", fDocument.get()); assertEquals(s1, 9, 0); assertEquals(t1, 2, 2); assertEquals(e2, 7, 1); @@ -594,7 +596,7 @@ public void testMove5() throws Exception { assertEquals(s1, 2, 0); assertEquals(t1, 2, 1); assertEquals(e2, 2, 1); - Assert.assertEquals("Buffer content", "01x3456789", fDocument.get()); + Assertions.assertEquals("01x3456789", fDocument.get()); doUndoRedo(undo, "01x3456789"); } @@ -611,7 +613,7 @@ public void testMove6() throws Exception { assertEquals(s1, 3, 0); assertEquals(t1, 2, 1); assertEquals(e2, 2, 1); - Assert.assertEquals("Buffer content", "01x3456789", fDocument.get()); + Assertions.assertEquals("01x3456789", fDocument.get()); doUndoRedo(undo,"01x3456789"); } @@ -624,7 +626,7 @@ public void testMove7() throws Exception { fRoot.addChild(s1); fRoot.addChild(t1); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "01562x4789", fDocument.get()); + Assertions.assertEquals("01562x4789", fDocument.get()); assertEquals(s1, 2, 0); assertEquals(t1, 4, 3); assertEquals(e2, 5, 1); @@ -640,7 +642,7 @@ public void testMove8() throws Exception { fRoot.addChild(s1); fRoot.addChild(t1); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "05x7123489", fDocument.get()); + Assertions.assertEquals("05x7123489", fDocument.get()); assertEquals(s1, 8, 0); assertEquals(t1, 1, 3); assertEquals(e2, 2, 1); @@ -665,7 +667,7 @@ public void testMove9() throws Exception { assertEquals(s2, 2, 0); assertEquals(t2, 3, 1); - Assert.assertEquals("Buffer content", "0421356789", fDocument.get()); + Assertions.assertEquals("0421356789", fDocument.get()); doUndoRedo(undo, "0421356789"); } @@ -686,7 +688,7 @@ public void testMove10() throws Exception { assertEquals(t1, 6, 2); assertEquals(s2, 5, 0); assertEquals(t2, 1, 2); - Assert.assertEquals("Buffer content", "0561472389", fDocument.get()); + Assertions.assertEquals("0561472389", fDocument.get()); doUndoRedo(undo, "0561472389"); } @@ -702,7 +704,7 @@ public void testMoveWithRangeMarker() throws Exception { fRoot.addChild(t1); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "0142356789", fDocument.get()); + Assertions.assertEquals("0142356789", fDocument.get()); assertEquals(s1, 2, 0); assertEquals(t1, 3, 2); assertEquals(marker, 3, 2); @@ -718,7 +720,7 @@ public void testMoveWithTargetDelete() throws Exception { fRoot.addChild(s1); fRoot.addChild(e2); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "01589", fDocument.get()); + Assertions.assertEquals("01589", fDocument.get()); assertEquals(s1, 2, 0); assertTrue(t1.isDeleted()); assertEquals(e2, 3, 0); @@ -740,7 +742,7 @@ public void testMoveUpWithSourceDelete() throws Exception { fRoot.addChild(t1); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "0156234789", fDocument.get()); + Assertions.assertEquals("0156234789", fDocument.get()); assertEquals(t1, 2, 2); assertEquals(marker, 2, 2); assertTrue(s1.isDeleted()); @@ -764,7 +766,7 @@ public void testMoveDown() throws Exception { fRoot.addChild(d1); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "014x562378", fDocument.get()); + Assertions.assertEquals("014x562378", fDocument.get()); assertEquals(s1, 2, 0); assertEquals(i1, 3, 1); assertEquals(t1, 6, 2); @@ -789,7 +791,7 @@ public void testMoveUp() throws Exception { fRoot.addChild(d1); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "0178234x56", fDocument.get()); + Assertions.assertEquals("0178234x56", fDocument.get()); assertEquals(s1, 10, 0); assertEquals(i1, 7, 1); assertEquals(t1, 2, 2); @@ -813,7 +815,7 @@ public void testMoveDownWithSourceDelete() throws Exception { fRoot.addChild(d1); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "0145623789", fDocument.get()); + Assertions.assertEquals("0145623789", fDocument.get()); assertEquals(d1, 2, 0); assertTrue(s1.isDeleted()); assertEquals(t1, 5, 2); @@ -830,7 +832,7 @@ public void testMoveUpWithInnerMark() throws Exception { fRoot.addChild(m); fRoot.addChild(s1); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "017823yy569", fDocument.get()); + Assertions.assertEquals("017823yy569", fDocument.get()); assertEquals(s1, 10, 0); assertEquals(t1, 2, 2); assertEquals(m, 6, 2); @@ -846,7 +848,7 @@ public void testMoveDownWithInnerMark() throws Exception { fRoot.addChild(m); fRoot.addChild(s1); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "01yy5623789", fDocument.get()); + Assertions.assertEquals("01yy5623789", fDocument.get()); assertEquals(s1, 2, 0); assertEquals(t1, 6, 2); assertEquals(m, 2, 2); @@ -862,7 +864,7 @@ public void testMoveUpWithParentMark() throws Exception { m.addChild(t1); fRoot.addChild(m); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "0124536789", fDocument.get()); + Assertions.assertEquals("0124536789", fDocument.get()); assertEquals(m, 2, 6); assertEquals(t1, 3, 2); assertEquals(s1, 6, 0); @@ -878,7 +880,7 @@ public void testMoveDownWithParentMark() throws Exception { m.addChild(t1); fRoot.addChild(m); UndoEdit undo= fRoot.apply(fDocument); - Assert.assertEquals("Buffer content", "0142356789", fDocument.get()); + Assertions.assertEquals("0142356789", fDocument.get()); assertEquals(m, 2, 6); assertEquals(t1, 3, 2); assertEquals(s1, 2, 0); @@ -907,7 +909,7 @@ public void testNestedMoveSource() throws Exception { assertEquals(t2, 4, 2); assertEquals(t3, 2, 1); String result= "0637248159"; - Assert.assertEquals("Buffer content", result, fDocument.get()); + Assertions.assertEquals(result, fDocument.get()); doUndoRedo(undo, result); } @@ -936,7 +938,7 @@ public void testNestedMoveSourceWithInsert() throws Exception { assertEquals(t2, 5, 2); assertEquals(t3, 2, 2); String result= "063x7248159"; - Assert.assertEquals("Buffer content", result, fDocument.get()); + Assertions.assertEquals(result, fDocument.get()); doUndoRedo(undo, result); } @@ -956,7 +958,7 @@ public void testNestedMoveTarget() throws Exception { assertEquals(t1, 5, 2); assertEquals(t2, 4, 5); String result= "0348512679"; - Assert.assertEquals("Buffer content", result, fDocument.get()); + Assertions.assertEquals(result, fDocument.get()); doUndoRedo(undo, result); } @@ -971,7 +973,7 @@ public void testCopyDown() throws Exception { assertEquals(s1, 2, 3); assertEquals(t1, 8, 3); String result= "0123456723489"; - Assert.assertEquals("Buffer content", result, fDocument.get()); + Assertions.assertEquals(result, fDocument.get()); doUndoRedo(undo, result); } @@ -986,7 +988,7 @@ public void testCopyUp() throws Exception { assertEquals(s1, 9, 2); assertEquals(t1, 3, 2); String result= "012783456789"; - Assert.assertEquals("Buffer content", result, fDocument.get()); + Assertions.assertEquals(result, fDocument.get()); doUndoRedo(undo, result); } @@ -1007,7 +1009,7 @@ public void testDoubleCopy() throws Exception { assertEquals(s2, 7, 2); assertEquals(t2, 2, 2); String result= "01562345675689"; - Assert.assertEquals("Buffer content", result, fDocument.get()); + Assertions.assertEquals(result, fDocument.get()); doUndoRedo(undo, result); } @@ -1033,7 +1035,7 @@ public void testNestedCopySource() throws Exception { assertEquals(t2, 9, 3); assertEquals(t3, 7, 1); String result= "0123456372348123459"; - Assert.assertEquals("Buffer content", result, fDocument.get()); + Assertions.assertEquals(result, fDocument.get()); doUndoRedo(undo, result); } @@ -1062,7 +1064,7 @@ public void testNestedCopySourceWithInsert() throws Exception { assertEquals(t2, 11, 4); assertEquals(t3, 8, 2); String result= "0123x4563x723x48123x459"; - Assert.assertEquals("Buffer content", result, fDocument.get()); + Assertions.assertEquals(result, fDocument.get()); doUndoRedo(undo, result); } @@ -1082,7 +1084,7 @@ public void testNestedCopyTarget() throws Exception { assertEquals(t1, 6, 2); assertEquals(t2, 11, 5); String result= "01234512678512679"; - Assert.assertEquals("Buffer content", result, fDocument.get()); + Assertions.assertEquals(result, fDocument.get()); doUndoRedo(undo, result); } @@ -1110,7 +1112,7 @@ public void testSwap1() throws Exception { root.apply(document); String result= "3, foo(1, 2)"; - Assert.assertEquals("Buffer content", result, document.get()); + Assertions.assertEquals(result, document.get()); } @Test @@ -1136,7 +1138,7 @@ public void testSwap2() throws Exception { root.apply(document); String result= "foo(2, 1), 3"; - Assert.assertEquals("Buffer content", result, document.get()); + Assertions.assertEquals(result, document.get()); } @Test @@ -1178,7 +1180,7 @@ public void testSwap2InSwap1() throws Exception { root.apply(document); String result= "3, foo(2, 1)"; - Assert.assertEquals("Buffer content", result, document.get()); + Assertions.assertEquals(result, document.get()); } @Test @@ -1189,12 +1191,12 @@ public void testMoveTree1() { TextEdit e2= new ReplaceEdit(2, 2, ""); root.addChild(e2); root.moveTree(3); - Assert.assertEquals(3, root.getOffset()); - Assert.assertEquals(4, root.getLength()); - Assert.assertEquals(3, e1.getOffset()); - Assert.assertEquals(1, e1.getLength()); - Assert.assertEquals(5, e2.getOffset()); - Assert.assertEquals(2, e2.getLength()); + Assertions.assertEquals(3, root.getOffset()); + Assertions.assertEquals(4, root.getLength()); + Assertions.assertEquals(3, e1.getOffset()); + Assertions.assertEquals(1, e1.getLength()); + Assertions.assertEquals(5, e2.getOffset()); + Assertions.assertEquals(2, e2.getLength()); } @Test @@ -1205,12 +1207,12 @@ public void testMoveTree2() { TextEdit e2= new ReplaceEdit(5, 2, ""); root.addChild(e2); root.moveTree(-3); - Assert.assertEquals(0, root.getOffset()); - Assert.assertEquals(4, root.getLength()); - Assert.assertEquals(0, e1.getOffset()); - Assert.assertEquals(1, e1.getLength()); - Assert.assertEquals(2, e2.getOffset()); - Assert.assertEquals(2, e2.getLength()); + Assertions.assertEquals(0, root.getOffset()); + Assertions.assertEquals(4, root.getLength()); + Assertions.assertEquals(0, e1.getOffset()); + Assertions.assertEquals(1, e1.getLength()); + Assertions.assertEquals(2, e2.getOffset()); + Assertions.assertEquals(2, e2.getLength()); } @Test @@ -1251,9 +1253,9 @@ public void testComparator() throws Exception { TextEdit edit3= new InsertEdit(57, "test3"); assertTrue(edit1.equals(edit1)); - Assert.assertEquals(0, comparator.compare(edit1, edit1)); - Assert.assertEquals(0, comparator.compare(edit1, edit2)); - Assert.assertEquals(0, comparator.compare(edit2, edit1)); + Assertions.assertEquals(0, comparator.compare(edit1, edit1)); + Assertions.assertEquals(0, comparator.compare(edit1, edit2)); + Assertions.assertEquals(0, comparator.compare(edit2, edit1)); assertTrue(comparator.compare(edit1, edit3) == -comparator.compare(edit3, edit1)); } @@ -1278,7 +1280,7 @@ public ReplaceEdit[] getModifications(String source) { }); fRoot.apply(fDocument); String result= "016782aa459"; - Assert.assertEquals("Buffer content", result, fDocument.get()); + Assertions.assertEquals(result, fDocument.get()); assertEquals(r1, 6, 3); } @@ -1307,7 +1309,7 @@ public ReplaceEdit[] getModifications(String source) { }); fRoot.apply(fDocument); String result= "01678aa459"; - Assert.assertEquals("Buffer content", result, fDocument.get()); + Assertions.assertEquals(result, fDocument.get()); assertTrue(r1.isDeleted()); assertTrue(r2.isDeleted()); assertEquals(r3, 7, 2); @@ -1333,7 +1335,7 @@ public ReplaceEdit[] getModifications(String source) { }); fRoot.apply(fDocument); String result= "01678aa459"; - Assert.assertEquals("Buffer content", result, fDocument.get()); + Assertions.assertEquals(result, fDocument.get()); assertEquals(r1, 7, 1); } @@ -1357,7 +1359,7 @@ public ReplaceEdit[] getModifications(String source) { }); fRoot.apply(fDocument); String result= "0167823aa9"; - Assert.assertEquals("Buffer content", result, fDocument.get()); + Assertions.assertEquals(result, fDocument.get()); assertEquals(r1, 6, 3); } @@ -1389,23 +1391,23 @@ private void doUndoRedo(UndoEdit undo, String redoResult) throws Exception { UndoEdit redo= undo.apply(fDocument); assertBufferContent(); undo= redo.apply(fDocument); - Assert.assertEquals("Buffer content redo", redoResult, fDocument.get()); + Assertions.assertEquals(redoResult, fDocument.get(), "Buffer content redo"); undo.apply(fDocument); assertBufferContent(); } private void assertEquals(TextEdit edit, int offset, int length) { - Assert.assertEquals("Offset", offset, edit.getOffset()); - Assert.assertEquals("Length", length, edit.getLength()); + Assertions.assertEquals(offset, edit.getOffset(), "Offset"); + Assertions.assertEquals(length, edit.getLength(), "Length"); } private void assertEquals(IRegion region, int offset, int length) { - Assert.assertEquals("Offset", offset, region.getOffset()); - Assert.assertEquals("Length", length, region.getLength()); + Assertions.assertEquals(offset, region.getOffset(), "Offset"); + Assertions.assertEquals(length, region.getLength(), "Length"); } private void assertBufferContent() { - Assert.assertEquals("Buffer content restored", "0123456789", fDocument.get()); + Assertions.assertEquals("0123456789", fDocument.get(), "Buffer content restored"); } } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/TextStoreTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/TextStoreTest.java index 408862aa5ed..60fc6630eee 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/TextStoreTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/TextStoreTest.java @@ -13,13 +13,15 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.ConfigurableLineTracker; @@ -37,7 +39,7 @@ public abstract class TextStoreTest { private ITextStore fTextStore; private ILineTracker fTracker; - @Before + @BeforeEach public void setUp() { fTextStore= createTextStore(); @@ -61,7 +63,7 @@ protected final void set(String text) { abstract protected ITextStore createTextStore(); - @After + @AfterEach public void tearDown() { fTextStore= null; fTracker= null; @@ -172,7 +174,7 @@ public void testLinesNumbers() throws Exception { for (int i= 0; i < 5; i++) { for (int j= 0; j < i; j++) { int no= fTracker.getLineNumberOfOffset(offset + j); - assertTrue("invalid line number " + no + " reported instead of " + i, no == i); + assertTrue(no == i, "invalid line number " + no + " reported instead of " + i); } offset+= (i + 1); } @@ -184,19 +186,19 @@ public void testOffsets() throws Exception { IRegion line= fTracker.getLineInformation(i); int pos= line.getOffset() + line.getLength(); int offset= (2 * i) + 1; - assertTrue("invalid line end offset " + pos + " for line " + i + " should be " + offset, offset == pos); + assertTrue(offset == pos, "invalid line end offset " + pos + " for line " + i + " should be " + offset); } for (int i= 0; i < 5; i++) { int pos= fTracker.getLineOffset(i); int offset= 2 * i; - assertTrue("invalid line start offset " + pos + " for line " + i + " should be " + offset, pos == offset); + assertTrue(pos == offset, "invalid line start offset " + pos + " for line " + i + " should be " + offset); } for (int i= 0; i < 10; i++) { int line= fTracker.getLineNumberOfOffset(i); double l= Math.floor(i / 2); - assertTrue("invalid line number " + line + " for position " + i + " should be " + l, l == line); + assertTrue(l == line, "invalid line number " + line + " for position " + i + " should be " + l); } } @@ -390,12 +392,12 @@ public void testFunnyLastLineCompatibility() throws Exception { int[] offsets= {0, 2}; int[] lengths= {1, 0}; - assertEquals("invalid number of lines, ", lengths.length, fTracker.getNumberOfLines()); - assertEquals("invalid number of lines, ", lengths.length, fTracker.getNumberOfLines(0, fTextStore.getLength())); + assertEquals(lengths.length, fTracker.getNumberOfLines(), "invalid number of lines, "); + assertEquals(lengths.length, fTracker.getNumberOfLines(0, fTextStore.getLength()), "invalid number of lines, "); for (int i= 0; i < lengths.length; i++) { IRegion line= fTracker.getLineInformation(i); - assertEquals("line: " + i, lengths[i], line.getLength()); - assertEquals("line: " + i, offsets[i], line.getOffset()); + assertEquals(lengths[i], line.getLength(), "line: " + i); + assertEquals(offsets[i], line.getOffset(), "line: " + i); } try { fTracker.getLineInformation(lengths.length); @@ -414,22 +416,22 @@ public void testFunnyLastLineCompatibility() throws Exception { assertTextStoreContents("x\nx"); offsets= new int[]{0, 2, 3}; lengths= new int[]{1, 1, 0}; - assertEquals("invalid number of lines, ", lengths.length - 1 /* !!!! */, fTracker.getNumberOfLines()); - assertEquals("invalid number of lines, ", lengths.length - 1 /* !!!! */, fTracker.getNumberOfLines(0, fTextStore.getLength())); + assertEquals(lengths.length - 1 /* !!!! */, fTracker.getNumberOfLines(), "invalid number of lines, "); + assertEquals(lengths.length - 1 /* !!!! */, fTracker.getNumberOfLines(0, fTextStore.getLength()), "invalid number of lines, "); for (int i= 0; i < lengths.length; i++) { IRegion line= fTracker.getLineInformation(i); int len= lengths[i]; int offset= offsets[i]; - assertEquals("length of line: " + i, len, line.getLength()); - assertEquals("offset of line: " + i, offset, line.getOffset()); + assertEquals(len, line.getLength(), "length of line: " + i); + assertEquals(offset, line.getOffset(), "offset of line: " + i); line= fTracker.getLineInformationOfOffset(offset); if (i == lengths.length - 1) { // phantom line cannot be queried by offset len= lengths[i - 1]; offset= offsets[i - 1]; } - assertEquals("length of line: " + i, len, line.getLength()); - assertEquals("offset of line: " + i, offset, line.getOffset()); + assertEquals(len, line.getLength(), "length of line: " + i); + assertEquals(offset, line.getOffset(), "offset of line: " + i); } try { diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/TextUtilitiesTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/TextUtilitiesTest.java index d09fc5f6c54..36fac30e797 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/TextUtilitiesTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/TextUtilitiesTest.java @@ -13,15 +13,16 @@ *******************************************************************************/ package org.eclipse.text.tests; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -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.fail; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.AbstractLineTracker.DelimiterInfo; import org.eclipse.jface.text.BadLocationException; @@ -132,7 +133,7 @@ public String get() { try { flush(); } catch (BadLocationException e) { - Assert.fail("bad implementation"); + fail("bad implementation"); } return super.get(); } @@ -169,7 +170,7 @@ public void testMergeEvents1() { check(reference, testee); } catch (BadLocationException e) { - Assert.fail("bad location exception"); + fail("bad location exception"); } } @@ -220,7 +221,7 @@ public void testMergeEvents() { // System.out.println("[" + testee.get() + "]"); } catch (BadLocationException e) { - Assert.fail("bad location exception"); + fail("bad location exception"); } } @@ -263,12 +264,12 @@ public void testMergeEvents2() { check(reference, testee); } catch (BadLocationException e) { - Assert.fail("bad location exception"); + fail("bad location exception"); } } private static void check(IDocument reference, IDocument testee) { - Assert.assertEquals(reference.get(), testee.get()); + Assertions.assertEquals(reference.get(), testee.get()); } @Test diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/InclusivePositionUpdaterTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/InclusivePositionUpdaterTest.java index 742a7407c2a..80ad15e00b6 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/InclusivePositionUpdaterTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/InclusivePositionUpdaterTest.java @@ -13,10 +13,11 @@ *******************************************************************************/ package org.eclipse.text.tests.link; -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.jface.text.BadLocationException; import org.eclipse.jface.text.Document; @@ -32,7 +33,7 @@ public class InclusivePositionUpdaterTest { private Position fPos; private IDocument fDoc; - @Before + @BeforeEach public void setUp() throws Exception { fUpdater= new InclusivePositionUpdater(CATEGORY); fDoc= new Document("ccccccccccccccccccccccccccccccccccccccccccccc"); @@ -42,7 +43,7 @@ public void setUp() throws Exception { fDoc.addPosition(CATEGORY, fPos); } - @After + @AfterEach public void tearDown() throws Exception{ fDoc.removePositionUpdater(fUpdater); fDoc.removePositionCategory(CATEGORY); @@ -51,111 +52,111 @@ public void tearDown() throws Exception{ @Test public void testDeleteAfter() throws BadLocationException { fDoc.replace(20, 2, ""); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(5, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(5, fPos.length); } @Test public void testAddAfter() throws BadLocationException { fDoc.replace(20, 0, "yy"); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(5, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(5, fPos.length); } @Test public void testDeleteBefore() throws BadLocationException { fDoc.replace(2, 2, ""); - Assert.assertEquals(3, fPos.offset); - Assert.assertEquals(5, fPos.length); + Assertions.assertEquals(3, fPos.offset); + Assertions.assertEquals(5, fPos.length); } @Test public void testAddBefore() throws BadLocationException { fDoc.replace(2, 0, "yy"); - Assert.assertEquals(7, fPos.offset); - Assert.assertEquals(5, fPos.length); + Assertions.assertEquals(7, fPos.offset); + Assertions.assertEquals(5, fPos.length); } @Test public void testAddRightBefore() throws BadLocationException { fDoc.replace(5, 0, "yy"); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(7, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(7, fPos.length); } @Test public void testDeleteAtOffset() throws BadLocationException { fDoc.replace(5, 2, ""); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(3, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(3, fPos.length); } @Test public void testDeleteRightBefore() throws BadLocationException { fDoc.replace(3, 2, ""); - Assert.assertEquals(3, fPos.offset); - Assert.assertEquals(5, fPos.length); + Assertions.assertEquals(3, fPos.offset); + Assertions.assertEquals(5, fPos.length); } @Test public void testAddRightAfter() throws BadLocationException { fDoc.replace(10, 0, "yy"); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(7, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(7, fPos.length); } @Test public void testDeleteRightAfter() throws BadLocationException { fDoc.replace(10, 2, ""); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(5, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(5, fPos.length); } @Test public void testAddWithin() throws BadLocationException { fDoc.replace(6, 0, "yy"); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(7, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(7, fPos.length); } @Test public void testDeleteWithin() throws BadLocationException { fDoc.replace(6, 2, ""); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(3, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(3, fPos.length); } @Test public void testReplaceLeftBorder() throws BadLocationException { fDoc.replace(4, 2, "yy"); - Assert.assertEquals(4, fPos.offset); - Assert.assertEquals(6, fPos.length); + Assertions.assertEquals(4, fPos.offset); + Assertions.assertEquals(6, fPos.length); } @Test public void testReplaceRightBorder() throws BadLocationException { fDoc.replace(9, 2, "yy"); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(6, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(6, fPos.length); } @Test public void testDeleteOverRightBorder() throws BadLocationException { fDoc.replace(9, 2, ""); - Assert.assertEquals(5, fPos.offset); - Assert.assertEquals(4, fPos.length); + Assertions.assertEquals(5, fPos.offset); + Assertions.assertEquals(4, fPos.length); } @Test public void testDeleted() throws BadLocationException { fDoc.replace(4, 7, ""); - Assert.assertTrue(fPos.isDeleted); + Assertions.assertTrue(fPos.isDeleted); } @Test public void testReplaced() throws BadLocationException { fDoc.replace(4, 7, "yyyyyyy"); - Assert.assertTrue(fPos.isDeleted); + Assertions.assertTrue(fPos.isDeleted); } } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkTestSuite.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkTestSuite.java index 0aac19cef41..b44b2204bc0 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkTestSuite.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkTestSuite.java @@ -14,8 +14,8 @@ package org.eclipse.text.tests.link; -import org.junit.platform.suite.api.Suite; import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * Test Suite org.eclipse.text.tests.link. diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java index b0088455230..55b3514d700 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java @@ -13,8 +13,9 @@ *******************************************************************************/ package org.eclipse.text.tests.link; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.Arrays; @@ -23,9 +24,9 @@ import java.util.LinkedList; import java.util.List; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; @@ -429,7 +430,7 @@ public void left(LinkedModeModel environment, int flags) { assertEquals(group1, "MARGARETE"); assertFalse(isExit[0]); - Assert.assertEquals(" MARGARETE:\n" + + Assertions.assertEquals(" MARGARETE:\n" + " Verbrich mir, Heinrich!", doc1.get(0, 36)); // assertUnchanged(group1); // would fail, since it was changed outside } @@ -458,7 +459,7 @@ public void left(LinkedModeModel environment, int flags) { assertEquals(group1, "MARGARINE-PLANTA"); assertFalse(isExit[0]); - Assert.assertEquals(" MARGARINE-PLANTA" + + Assertions.assertEquals(" MARGARINE-PLANTA" + "Versprich mir, Heinrich!", doc1.get(0, 41)); // assertUnchanged(group1); // would fail, since it was changed outside } @@ -487,7 +488,7 @@ public void left(LinkedModeModel environment, int flags) { assertEquals(group1, "MARGAR"); assertFalse(isExit[0]); - Assert.assertEquals(" MARGAR" + + Assertions.assertEquals(" MARGAR" + "Versprich mir, Heinrich!", doc1.get(0, 31)); // assertUnchanged(group1); // would fail, since it was changed outside } @@ -558,7 +559,7 @@ private void assertEquals(LinkedPositionGroup group, String expected) throws Bad LinkedPosition[] positions= group.getPositions(); for (LinkedPosition pos : positions) { if (!pos.isDeleted()) - Assert.assertEquals(expected, pos.getContent()); + Assertions.assertEquals(expected, pos.getContent()); } } @@ -576,7 +577,7 @@ private void assertUnchanged(LinkedPositionGroup actual1, LinkedPositionGroup ac Arrays.sort(act, new PositionComparator()); Arrays.sort(exp, new PositionComparator()); - Assert.assertEquals(exp.length, act.length); + Assertions.assertEquals(exp.length, act.length); LinkedPosition e_prev= null, a_prev= null; for (int i= 0; i <= exp.length; i++) { @@ -587,10 +588,10 @@ private void assertUnchanged(LinkedPositionGroup actual1, LinkedPositionGroup ac IDocument e_doc= e_prev != null ? e_prev.getDocument() : e_next.getDocument(); if (e_next != null && e_next.getDocument() != e_doc) { // split at document boundaries - Assert.assertEquals(getContentBetweenPositions(e_prev, null), getContentBetweenPositions(a_prev, null)); - Assert.assertEquals(getContentBetweenPositions(null, e_next), getContentBetweenPositions(null, a_next)); + Assertions.assertEquals(getContentBetweenPositions(e_prev, null), getContentBetweenPositions(a_prev, null)); + Assertions.assertEquals(getContentBetweenPositions(null, e_next), getContentBetweenPositions(null, a_next)); } else { - Assert.assertEquals(getContentBetweenPositions(e_prev, e_next), getContentBetweenPositions(a_prev, a_next)); + Assertions.assertEquals(getContentBetweenPositions(e_prev, e_next), getContentBetweenPositions(a_prev, a_next)); } e_prev= e_next; @@ -616,7 +617,7 @@ private String getContentBetweenPositions(LinkedPosition p1, LinkedPosition p2) } - @Before + @BeforeEach public void setUp() { fPositions.clear(); fDocumentMap.clear(); diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedPositionGroupTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedPositionGroupTest.java index cacec99346d..9d5d88709f6 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedPositionGroupTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedPositionGroupTest.java @@ -13,12 +13,14 @@ *******************************************************************************/ package org.eclipse.text.tests.link; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedPositionTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedPositionTest.java index 0fa99f0be9e..3c17d21864c 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedPositionTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedPositionTest.java @@ -13,12 +13,17 @@ *******************************************************************************/ package org.eclipse.text.tests.link; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import org.junit.Before; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import org.eclipse.core.runtime.AssertionFailedException; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; @@ -31,7 +36,7 @@ public class LinkedPositionTest { - @Before + @BeforeEach public void setUp() { fDoc= new Document(GARTEN1); fPos= new LinkedPosition(fDoc, 3, 10); @@ -45,10 +50,12 @@ public void testCreate() { LinkedPosition linkedPosition2 = new LinkedPosition(new Document(), 123, 234); } - @Test(expected=Throwable.class) + @Test public void testNullCreate() { - @SuppressWarnings("unused") - LinkedPosition linkedPosition = new LinkedPosition(null, 1, 9); + assertThrows(AssertionFailedException.class, () -> { + @SuppressWarnings("unused") + LinkedPosition linkedPosition = new LinkedPosition(null, 1, 9); + }); } /* @@ -182,17 +189,21 @@ public void testGetContent() throws BadLocationException { assertEquals("FAUST", p.getContent()); } - @Test(expected= BadLocationException.class) - public void testBadLocationContentNull() throws BadLocationException { - LinkedPosition p= new LinkedPosition(new Document(), 23, 3); - p.getContent(); + @Test + public void testBadLocationContentNull() { + assertThrows(BadLocationException.class, () -> { + LinkedPosition p= new LinkedPosition(new Document(), 23, 3); + p.getContent(); + }); } - @Test(expected= BadLocationException.class) - public void testBadLocationContentEmpty() throws BadLocationException { - LinkedPosition p= new LinkedPosition(fDoc, 23, 3); - fDoc.set(""); - p.getContent(); + @Test + public void testBadLocationContentEmpty() { + assertThrows(BadLocationException.class, () -> { + LinkedPosition p= new LinkedPosition(fDoc, 23, 3); + fDoc.set(""); + p.getContent(); + }); } @Test diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/GlobalTemplateVariablesDateTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/GlobalTemplateVariablesDateTest.java index 8a649f0112a..3a283904a3e 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/GlobalTemplateVariablesDateTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/GlobalTemplateVariablesDateTest.java @@ -14,15 +14,16 @@ *******************************************************************************/ package org.eclipse.text.tests.templates; -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.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Locale; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.templates.DocumentTemplateContext; @@ -40,7 +41,7 @@ public class GlobalTemplateVariablesDateTest { private TemplateContextType fType; - @Before + @BeforeEach public void setUp() { fTranslator= new TemplateTranslator(); diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateTranslatorTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateTranslatorTest.java index a6a27cc60bc..ff71a601d38 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateTranslatorTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateTranslatorTest.java @@ -14,17 +14,19 @@ *******************************************************************************/ package org.eclipse.text.tests.templates; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; + +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.assertThrows; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; 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.eclipse.jface.text.templates.TemplateBuffer; import org.eclipse.jface.text.templates.TemplateException; @@ -38,14 +40,16 @@ public class TemplateTranslatorTest { private TemplateTranslator fTranslator; - @Before + @BeforeEach public void setUp() { fTranslator= new TemplateTranslator(); } - @Test(expected= NullPointerException.class) - public void testNullTemplate() throws Exception { - fTranslator.translate((String) null); + @Test + public void testNullTemplate() { + assertThrows(NullPointerException.class, () -> { + fTranslator.translate((String) null); + }); } @Test @@ -152,19 +156,25 @@ public void testNumberAsIdentifier() throws Exception { assertEquals(Arrays.asList(new Object[] { "1", "2 ", "3" }), vars[0].getVariableType().getParams()); } - @Test(expected=TemplateException.class) - public void testIllegalSyntax1() throws Exception { - fTranslator.translate("foo ${var"); + @Test + public void testIllegalSyntax1() { + assertThrows(TemplateException.class, () -> { + fTranslator.translate("foo ${var"); + }); } - @Test(expected=TemplateException.class) - public void testIllegalSyntax2() throws Exception { - fTranslator.translate("foo $"); + @Test + public void testIllegalSyntax2() { + assertThrows(TemplateException.class, () -> { + fTranslator.translate("foo $"); + }); } - @Test(expected=TemplateException.class) - public void testIllegalSyntax3() throws Exception { - fTranslator.translate("foo ${] } bar"); + @Test + public void testIllegalSyntax3() { + assertThrows(TemplateException.class, () -> { + fTranslator.translate("foo ${] } bar"); + }); } @Test @@ -271,14 +281,18 @@ public void testMultiParameterizedTypeTemplate2() throws Exception { assertEquals(Collections.singletonList("param"), vars[0].getVariableType().getParams()); } - @Test(expected=TemplateException.class) - public void testIllegallyParameterizedTypeTemplate1() throws Exception { - fTranslator.translate("foo ${var:type(param)} bar ${var:type(other)} end"); + @Test + public void testIllegallyParameterizedTypeTemplate1() { + assertThrows(TemplateException.class, () -> { + fTranslator.translate("foo ${var:type(param)} bar ${var:type(other)} end"); + }); } - @Test(expected=TemplateException.class) - public void testIllegallyParameterizedTypeTemplate2() throws Exception { - fTranslator.translate("foo ${var:type(param)} bar ${var:type} end"); + @Test + public void testIllegallyParameterizedTypeTemplate2() { + assertThrows(TemplateException.class, () -> { + fTranslator.translate("foo ${var:type(param)} bar ${var:type} end"); + }); } @Test @@ -349,24 +363,32 @@ public void testTextParameterTemplate() throws Exception { assertEquals(params, vars[0].getVariableType().getParams()); } - @Test(expected=TemplateException.class) - public void testIllegalSyntax4() throws Exception { - fTranslator.translate("foo ${var:} bar"); + @Test + public void testIllegalSyntax4() { + assertThrows(TemplateException.class, () -> { + fTranslator.translate("foo ${var:} bar"); + }); } - @Test(expected=TemplateException.class) - public void testIllegalSyntax5() throws Exception { - fTranslator.translate("foo ${var:type(} bar"); + @Test + public void testIllegalSyntax5() { + assertThrows(TemplateException.class, () -> { + fTranslator.translate("foo ${var:type(} bar"); + }); } - @Test(expected=TemplateException.class) - public void testIllegalSyntax6() throws Exception { - fTranslator.translate("foo ${var:type(] )} bar"); + @Test + public void testIllegalSyntax6() { + assertThrows(TemplateException.class, () -> { + fTranslator.translate("foo ${var:type(] )} bar"); + }); } - @Test(expected=TemplateException.class) - public void testIllegalSyntax7() throws Exception { - fTranslator.translate("foo ${var:type((} bar"); + @Test + public void testIllegalSyntax7() { + assertThrows(TemplateException.class, () -> { + fTranslator.translate("foo ${var:type((} bar"); + }); } } diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateVariablesWordSelectionTest.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateVariablesWordSelectionTest.java index efbb97a54d9..0267005a85f 100644 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateVariablesWordSelectionTest.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateVariablesWordSelectionTest.java @@ -13,11 +13,13 @@ *******************************************************************************/ package org.eclipse.text.tests.templates; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import org.junit.Before; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.templates.DocumentTemplateContext; @@ -36,7 +38,7 @@ public class TemplateVariablesWordSelectionTest { private TemplateContextType fType; - @Before + @BeforeEach public void setUp() { fTranslator= new TemplateTranslator(); diff --git a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplatesTestSuite.java b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplatesTestSuite.java index e4d769ca4b7..94920bbbc03 100755 --- a/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplatesTestSuite.java +++ b/tests/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplatesTestSuite.java @@ -16,8 +16,8 @@ package org.eclipse.text.tests.templates; -import org.junit.platform.suite.api.Suite; import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * Test Suite for the org.eclipse.text plug-in