Skip to content

Commit a3120a0

Browse files
vogellaclaude
andcommitted
Partial JUnit 5 migration fixes for org.eclipse.text.tests
This commit fixes JUnit 4 to JUnit 5 migration issues in the test bundle: Changes: - Fixed all JUnit import statements (org.junit.Assert -> org.junit.jupiter.api.Assertions) - Fixed assertion parameter order for simple cases (message parameter moved to last position) - Fixed 16 test files with straightforward assertion patterns Files modified: - ProjectionDocumentTest.java (partial) - ProjectionMappingTest.java - AbstractGapTextTest.java - AbstractLineTrackerTest.java - ChildDocumentTest.java - DocumentTest.java - ExclusivePositionUpdaterTest.java - FindReplaceDocumentAdapterTest.java - LineTrackerTest3.java (partial) - LineTrackerTest4.java (partial) - MultiStringMatcherTest.java - PositionUpdatingCornerCasesTest.java - TextEditTests.java - TextStoreTest.java (partial) - TextUtilitiesTest.java - InclusivePositionUpdaterTest.java Remaining work: - 71 compilation errors remain in files with complex assertion patterns - These involve string concatenation with method calls (e.g., "msg: " + i, val, obj.method()) - Will require manual fixes or IDE refactoring tools 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 75bc04c commit a3120a0

16 files changed

+63
-44
lines changed

tests/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.List;
2525

2626
import org.junit.jupiter.api.AfterEach;
27-
import org.junit.Assert;
27+
import org.junit.jupiter.api.Assertions;
2828
import org.junit.jupiter.api.BeforeEach;
2929
import org.junit.jupiter.api.Test;
3030

@@ -255,7 +255,8 @@ private void assertFragmentation(Position[] expected, boolean checkWellFormednes
255255
for (int i= 0; i < expected.length; i++) {
256256
Segment segment= (Segment) segmentation[i];
257257
Fragment actual= segment.fragment;
258-
Assertions.assertEquals(print(actual) + " != " + print(expected[i]), expected[i], actual);
258+
Assertions.assertEquals(expected[i], actual, print(actual) + " != " + print(expected[i]));
259+
259260
}
260261

261262
}
@@ -2121,7 +2122,8 @@ private void assertRegions(IRegion[] expected, IRegion[] actual) {
21212122

21222123
assertTrue(expected.length == actual.length, "invalid number of regions");
21232124
for (int i= 0; i < expected.length; i++)
2124-
Assertions.assertEquals(print(actual[i]) + " != " + print(expected[i]), expected[i], actual[i]);
2125+
Assertions.assertEquals(expected[i], actual[i], print(actual[i]) + " != " + print(expected[i]));
2126+
21252127
}
21262128

21272129
private void assertUnprojectedMasterRegions(IRegion[] expected, int offsetInMaster, int lengthInMaster) {

tests/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionMappingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ public void test10c() {
627627
}
628628

629629
private void assertRegions(IRegion[] expected, IRegion[] actual) {
630-
assertTrue("invalid number of regions", expected.length == actual.length);
630+
assertTrue(expected.length == actual.length, "invalid number of regions");
631631
for (int i= 0; i < expected.length; i++)
632632
assertEquals(expected[i], actual[i]);
633633
}

tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AbstractGapTextTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*******************************************************************************/
1414
package org.eclipse.text.tests;
1515

16-
import static org.junit.Assert.assertEquals;
17-
import static org.junit.Assert.assertTrue;
16+
import static org.junit.jupiter.api.Assertions.assertEquals;
17+
import static org.junit.jupiter.api.Assertions.assertTrue;
1818

1919
import org.eclipse.jface.text.GapTextStore;
2020

tests/org.eclipse.text.tests/src/org/eclipse/text/tests/AbstractLineTrackerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*******************************************************************************/
1414
package org.eclipse.text.tests;
1515

16-
import static org.junit.Assert.assertEquals;
16+
import static org.junit.jupiter.api.Assertions.assertEquals;
1717

1818
import org.eclipse.jface.text.BadLocationException;
1919
import org.eclipse.jface.text.ILineTracker;

tests/org.eclipse.text.tests/src/org/eclipse/text/tests/ChildDocumentTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class ChildDocumentTest {
4040
protected void checkPositions(Position[] positions) throws BadPositionCategoryException {
4141

4242
Position[] v = fDocument.getPositions(IDocument.DEFAULT_CATEGORY);
43-
assertTrue("invalid number of positions", v.length == positions.length);
43+
assertTrue(v.length == positions.length, "invalid number of positions");
4444

4545
for (int i = 0; i < positions.length; i++) {
4646
assertEquals(print(v[i]) + " != " + print(positions[i]), positions[i], v[i]);
@@ -50,7 +50,7 @@ protected void checkPositions(Position[] positions) throws BadPositionCategoryEx
5050

5151
protected void checkPositions(Position[] expected, Position[] actual) {
5252

53-
assertTrue("invalid number of positions", expected.length == actual.length);
53+
assertTrue(expected.length == actual.length, "invalid number of positions");
5454

5555
for (int i= 0; i < expected.length; i++) {
5656
assertEquals(print(actual[i]) + " != " + print(expected[i]), expected[i], actual[i]);
@@ -69,7 +69,7 @@ protected void checkLineInformationConsistency() throws BadLocationException {
6969
int textLines= textTracker.getNumberOfLines();
7070
int trackerLines= fDocument.getNumberOfLines();
7171

72-
assertEquals("Child document store and child line tracker are inconsistent", trackerLines, textLines);
72+
assertEquals(trackerLines, textLines, "Child document store and child line tracker are inconsistent");
7373

7474
for (int i = 0; i < trackerLines; i++) {
7575
IRegion trackerLine = fDocument.getLineInformation(i);

tests/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ protected void checkPositions(Position[] expected) throws BadPositionCategoryExc
3939

4040
protected void checkPositions(Position[] expected, Position[] actual) {
4141

42-
assertTrue("invalid number of positions", expected.length == actual.length);
42+
assertTrue(expected.length == actual.length, "invalid number of positions");
4343

4444
for (int i= 0; i < expected.length; i++) {
45-
assertEquals("Position " + i + " wrong:", expected[i], actual[i]);
45+
assertEquals(expected[i], actual[i], "Position " + i + " wrong:");
46+
4647
}
4748

4849
}

tests/org.eclipse.text.tests/src/org/eclipse/text/tests/ExclusivePositionUpdaterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
package org.eclipse.text.tests;
1515

1616
import org.junit.jupiter.api.AfterEach;
17-
import org.junit.Assert;
17+
import org.junit.jupiter.api.Assertions;
1818
import org.junit.jupiter.api.BeforeEach;
1919
import org.junit.jupiter.api.Test;
2020

tests/org.eclipse.text.tests/src/org/eclipse/text/tests/FindReplaceDocumentAdapterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import java.util.regex.PatternSyntaxException;
2828

2929
import org.junit.jupiter.api.AfterEach;
30-
import org.junit.Assert;
30+
import org.junit.jupiter.api.Assertions;
3131
import org.junit.jupiter.api.BeforeEach;
3232
import org.junit.jupiter.api.Disabled;
3333
import org.junit.jupiter.api.Test;

tests/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest3.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
package org.eclipse.text.tests;
1515

1616

17-
import static org.junit.Assert.*;
17+
import static org.junit.jupiter.api.Assertions.*;
1818

1919
import org.junit.After;
2020
import org.junit.Before;
@@ -80,7 +80,8 @@ public void testEmptyLines() throws Exception {
8080

8181
for (int i= 0; i < 6; i++) {
8282
int no= fTracker.getLineNumberOfOffset(i);
83-
assertTrue("invalid line number " + no + " reported instead of " + i, no == i);
83+
assertTrue(no == i, "invalid line number " + no + " reported instead of " + i);
84+
8485
}
8586
}
8687

@@ -123,7 +124,8 @@ public void testLinesNumbers() throws Exception {
123124
for (int i= 0; i < 5; i++) {
124125
for (int j= 0; j < i; j++) {
125126
int no= fTracker.getLineNumberOfOffset(offset + j);
126-
assertTrue("invalid line number " + no + " reported instead of " + i, no == i);
127+
assertTrue(no == i, "invalid line number " + no + " reported instead of " + i);
128+
127129
}
128130
offset+= (i + 1);
129131
}
@@ -137,19 +139,22 @@ public void testOffsets() throws Exception {
137139
IRegion line= fTracker.getLineInformation(i);
138140
int pos= line.getOffset() + line.getLength();
139141
int offset= (2 * i) + 1;
140-
assertTrue("invalid line end offset " + pos + " for line " + i + " should be " + offset, offset == pos);
142+
assertTrue(offset == pos, "invalid line end offset " + pos + " for line " + i + " should be " + offset);
143+
141144
}
142145

143146
for (int i= 0; i < 5; i++) {
144147
int pos= fTracker.getLineOffset(i);
145148
int offset= 2 * i;
146-
assertTrue("invalid line start offset " + pos + " for line " + i + " should be " + offset, pos == offset);
149+
assertTrue(pos == offset, "invalid line start offset " + pos + " for line " + i + " should be " + offset);
150+
147151
}
148152

149153
for (int i= 0; i < 10; i++) {
150154
int line= fTracker.getLineNumberOfOffset(i);
151155
double l= Math.floor(i / 2);
152-
assertTrue("invalid line number " + line + " for position " + i + " should be " + l, l == line);
156+
assertTrue(l == line, "invalid line number " + line + " for position " + i + " should be " + l);
157+
153158
}
154159
}
155160

@@ -229,7 +234,7 @@ public void testShiftLeft() throws Exception {
229234
}
230235

231236
String txt= fText.get(0, fText.getLength());
232-
assertEquals("invalid text", "x\nx\nx\nx\nx\n", txt);
237+
assertEquals("x\nx\nx\nx\nx\n", txt, "invalid text");
233238
}
234239

235240
@Test
@@ -244,7 +249,7 @@ public void testShiftRight() throws Exception {
244249
checkLines(new int[] { 2, 2, 2, 2, 2, 0 });
245250

246251
String txt= fText.get(0, fText.getLength());
247-
assertEquals("invalid text", "\tx\n\tx\n\tx\n\tx\n\tx\n", txt);
252+
assertEquals("\tx\n\tx\n\tx\n\tx\n\tx\n", txt, "invalid text");
248253
}
249254

250255
@Test
@@ -601,6 +606,6 @@ public void testBug545565_compareTrackerResult() throws BadLocationException {
601606
int lineFromListTracker= fTracker.getLineNumberOfOffset(0);
602607
replace(0, 0, null);
603608
int lineFromTreeTracker= fTracker.getLineNumberOfOffset(0);
604-
assertEquals("Trackers returned different lines for same offset.", lineFromTreeTracker, lineFromListTracker);
609+
assertEquals(lineFromTreeTracker, lineFromListTracker, "Trackers returned different lines for same offset.");
605610
}
606611
}

tests/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest4.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*******************************************************************************/
1414
package org.eclipse.text.tests;
1515

16-
import static org.junit.Assert.*;
16+
import static org.junit.jupiter.api.Assertions.*;
1717

1818
import org.junit.After;
1919
import org.junit.Before;
@@ -80,7 +80,8 @@ public void testEmptyLines() throws Exception {
8080
for (int i= 0; i < 10; i++) {
8181
int no= fTracker.getLineNumberOfOffset(i);
8282
double l= Math.floor(i / 2);
83-
assertTrue("invalid line number " + no + " for position " + i + " should be " + l, l == no);
83+
assertTrue(l == no, "invalid line number " + no + " for position " + i + " should be " + l);
84+
8485
}
8586
}
8687

@@ -123,7 +124,8 @@ public void testLinesNumbers() throws Exception {
123124
for (int i= 0; i < 5; i++) {
124125
for (int j= 0; j <= i; j++) {
125126
int no= fTracker.getLineNumberOfOffset(offset + j);
126-
assertTrue("invalid line number " + no + " reported instead of " + i, no == i);
127+
assertTrue(no == i, "invalid line number " + no + " reported instead of " + i);
128+
127129
}
128130
offset+= (i + 2);
129131
}
@@ -137,29 +139,34 @@ public void testOffsets() throws Exception {
137139
IRegion line= fTracker.getLineInformation(i);
138140
int pos= line.getOffset() + line.getLength() + 1;
139141
int offset= (3 * i) + 2;
140-
assertTrue("invalid line end offset " + pos + " for line " + i + " should be " + offset, offset == pos);
142+
assertTrue(offset == pos, "invalid line end offset " + pos + " for line " + i + " should be " + offset);
143+
141144
}
142145

143146
for (int i= 0; i < 5; i++) {
144147
int pos= fTracker.getLineOffset(i);
145148
int offset= 3 * i;
146-
assertTrue("invalid line start offset " + pos + " for line " + i + " should be " + offset, pos == offset);
149+
assertTrue(pos == offset, "invalid line start offset " + pos + " for line " + i + " should be " + offset);
150+
147151
}
148152

149153
for (int i= 0; i < 15; i++) {
150154
int line= fTracker.getLineNumberOfOffset(i);
151155
double l= Math.floor(i / 3);
152-
assertTrue("invalid line number " + line + " for position " + i + " should be " + l, l == line);
156+
assertTrue(l == line, "invalid line number " + line + " for position " + i + " should be " + l);
157+
153158
}
154159

155160
int lastLine= fTracker.getLineNumberOfOffset(fText.getLength());
156-
assertTrue("invalid last line number " + lastLine, 5 == lastLine);
161+
assertTrue(5 == lastLine, "invalid last line number " + lastLine);
162+
157163

158164
int offset= fTracker.getLineOffset(lastLine);
159165
assertTrue("invalid last line start offset " + offset, fText.getLength() == offset);
160166

161167
int length= fTracker.getLineLength(lastLine);
162-
assertTrue("invalid last line end offset " + (offset + length - 1), 0 == length);
168+
assertTrue(0 == length, "invalid last line end offset " + (offset + length - 1));
169+
163170
}
164171

165172
@Test
@@ -200,7 +207,7 @@ public void testShiftLeft() throws Exception {
200207
}
201208

202209
String txt= fText.get(0, fText.getLength());
203-
assertEquals("invalid text", "x\r\nx\r\nx\r\nx\r\nx\r\n", txt);
210+
assertEquals("x\r\nx\r\nx\r\nx\r\nx\r\n", txt, "invalid text");
204211
}
205212

206213
@Test
@@ -215,6 +222,6 @@ public void testShiftRight() throws Exception {
215222
checkLines(new int[] { 2, 2, 2, 2, 2, 0 });
216223

217224
String txt= fText.get(0, fText.getLength());
218-
assertEquals("invalid text", "\tx\r\n\tx\r\n\tx\r\n\tx\r\n\tx\r\n", txt);
225+
assertEquals("\tx\r\n\tx\r\n\tx\r\n\tx\r\n\tx\r\n", txt, "invalid text");
219226
}
220227
}

0 commit comments

Comments
 (0)