Skip to content

Commit b1b1a29

Browse files
committed
Migrate JUnit 4 tests to JUnit 5 in org.eclipse.text.tests
1 parent 8ff6a17 commit b1b1a29

File tree

50 files changed

+735
-694
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+735
-694
lines changed

tests/org.eclipse.jface.text.tests/META-INF/MANIFEST.MF

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ Import-Package: org.mockito,
3030
org.mockito.invocation,
3131
org.mockito.stubbing,
3232
org.junit.jupiter.api;version="[5.14.0,6.0.0)",
33+
org.junit.jupiter.params;version="[5.14.0,6.0.0)",
34+
org.junit.jupiter.params.provider;version="[5.14.0,6.0.0)",
3335
org.junit.platform.suite.api;version="[1.14.0,2.0.0)"

tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultTextDoubleClickStrategyTest.java

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

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

19-
import org.junit.Test;
19+
import org.junit.jupiter.api.Test;
2020

2121
import org.eclipse.jface.text.DefaultTextDoubleClickStrategy;
2222
import org.eclipse.jface.text.Document;
@@ -48,11 +48,11 @@ public void testClickAtLineEnd() throws Exception {
4848
IDocument document= new Document(content);
4949
TestSpecificDefaultTextDoubleClickStrategy doubleClickStrategy= new TestSpecificDefaultTextDoubleClickStrategy();
5050
IRegion selection= doubleClickStrategy.findWord(document, 11);
51-
assertNotNull("Should have selected a word", selection);
52-
assertEquals("Unexpected selection", "world", document.get(selection.getOffset(), selection.getLength()));
51+
assertNotNull(selection, "Should have selected a word");
52+
assertEquals("world", document.get(selection.getOffset(), selection.getLength()), "Unexpected selection");
5353
selection= doubleClickStrategy.findWord(document, document.getLength());
54-
assertNotNull("Should have selected a word", selection);
55-
assertEquals("Unexpected selection", "you", document.get(selection.getOffset(), selection.getLength()));
54+
assertNotNull(selection, "Should have selected a word");
55+
assertEquals("you", document.get(selection.getOffset(), selection.getLength()), "Unexpected selection");
5656
}
5757

5858
private static final class TestSpecificDefaultTextDoubleClickStrategy extends DefaultTextDoubleClickStrategy {

tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/FindReplaceDocumentAdapterContentProposalProviderTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
*******************************************************************************/
1111
package org.eclipse.jface.text.tests;
1212

13-
import static org.junit.Assert.assertEquals;
14-
import static org.junit.Assert.assertNotNull;
13+
import static org.junit.jupiter.api.Assertions.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertNotNull;
1515

16-
import org.junit.Test;
16+
import org.junit.jupiter.api.Test;
1717

1818
import org.eclipse.jface.fieldassist.IContentProposal;
1919

@@ -31,8 +31,8 @@ private void assertProposal(IContentProposal[] proposals, String prefix, String
3131
break;
3232
}
3333
}
34-
assertNotNull("No proposal for " + prefix + " found", match);
35-
assertEquals("Unexpected replacement", replacement, match.getContent());
34+
assertNotNull(match, "No proposal for " + prefix + " found");
35+
assertEquals(replacement, match.getContent(), "Unexpected replacement");
3636
}
3737

3838
@Test

tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/MultiSelectionTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
*******************************************************************************/
1111
package org.eclipse.jface.text.tests;
1212

13-
import static org.junit.Assert.assertArrayEquals;
14-
import static org.junit.Assert.assertEquals;
15-
import static org.junit.Assert.assertTrue;
13+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
14+
import static org.junit.jupiter.api.Assertions.assertEquals;
15+
import static org.junit.jupiter.api.Assertions.assertTrue;
1616

1717
import java.util.ArrayList;
1818
import java.util.Arrays;
1919
import java.util.List;
2020
import java.util.concurrent.atomic.AtomicInteger;
2121
import java.util.stream.Collectors;
2222

23-
import org.junit.Ignore;
24-
import org.junit.Test;
23+
import org.junit.jupiter.api.Disabled;
24+
import org.junit.jupiter.api.Test;
2525

2626
import org.eclipse.swt.SWT;
2727
import org.eclipse.swt.events.SelectionListener;
@@ -165,7 +165,7 @@ public void testBackspace() throws MalformedTreeException {
165165
}
166166

167167
@Test
168-
@Ignore(value = "this is currently for manual testing")
168+
@Disabled("this is currently for manual testing")
169169
public void testViewer() {
170170
Shell shell= new Shell();
171171
Button b = new Button(shell, SWT.PUSH);

tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/ProjectionViewerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
*******************************************************************************/
1111
package org.eclipse.jface.text.tests;
1212

13-
import static org.junit.Assert.assertEquals;
13+
import static org.junit.jupiter.api.Assertions.assertEquals;
1414

15-
import org.junit.Test;
15+
import org.junit.jupiter.api.Test;
1616

1717
import org.eclipse.swt.SWT;
1818
import org.eclipse.swt.dnd.Clipboard;

tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestWhitespaceCharacterPainter.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
*******************************************************************************/
1212
package org.eclipse.jface.text.tests;
1313

14-
import static org.junit.Assert.assertEquals;
15-
import static org.junit.Assert.assertNotEquals;
14+
import static org.junit.jupiter.api.Assertions.assertEquals;
15+
import static org.junit.jupiter.api.Assertions.assertNotEquals;
1616
import static org.mockito.ArgumentMatchers.anyBoolean;
1717
import static org.mockito.ArgumentMatchers.anyInt;
1818
import static org.mockito.ArgumentMatchers.anyString;
@@ -26,9 +26,9 @@
2626
import java.util.Arrays;
2727
import java.util.List;
2828

29-
import org.junit.After;
30-
import org.junit.Before;
31-
import org.junit.Test;
29+
import org.junit.jupiter.api.AfterEach;
30+
import org.junit.jupiter.api.BeforeEach;
31+
import org.junit.jupiter.api.Test;
3232
import org.mockito.invocation.InvocationOnMock;
3333
import org.mockito.stubbing.Answer;
3434

@@ -55,14 +55,14 @@ public class TestWhitespaceCharacterPainter {
5555

5656
private Shell shell;
5757

58-
@Before
58+
@BeforeEach
5959
public void before() {
6060
shell= new Shell();
6161
shell.setSize(500, 200);
6262
shell.setLayout(new FillLayout());
6363
}
6464

65-
@After
65+
@AfterEach
6666
public void after() {
6767
shell.dispose();
6868
}

tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningLineHeaderAnnotationTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
*******************************************************************************/
1111
package org.eclipse.jface.text.tests.codemining;
1212

13-
import static org.junit.Assert.assertNotEquals;
13+
import static org.junit.jupiter.api.Assertions.assertNotEquals;
1414

1515
import java.util.Arrays;
1616

17-
import org.junit.After;
18-
import org.junit.Assert;
19-
import org.junit.Before;
20-
import org.junit.Test;
17+
import org.junit.jupiter.api.AfterEach;
18+
import org.junit.jupiter.api.Assertions;
19+
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.api.Test;
2121

2222
import org.eclipse.swt.SWT;
2323
import org.eclipse.swt.custom.StyledText;
@@ -46,7 +46,7 @@ public class CodeMiningLineHeaderAnnotationTest {
4646

4747
private Document document;
4848

49-
@Before
49+
@BeforeEach
5050
public void setUp() {
5151
fShell= new Shell(Display.getDefault());
5252
fShell.setSize(500, 200);
@@ -58,7 +58,7 @@ public void setUp() {
5858
fViewer.setDocument(document, new AnnotationModel());
5959
final Display display= textWidget.getDisplay();
6060
fShell.open();
61-
Assert.assertTrue(new DisplayHelper() {
61+
Assertions.assertTrue(new DisplayHelper() {
6262
@Override
6363
protected boolean condition() {
6464
return fViewer.getTextWidget().isVisible();
@@ -67,7 +67,7 @@ protected boolean condition() {
6767
DisplayHelper.sleep(textWidget.getDisplay(), 1000);
6868
}
6969

70-
@After
70+
@AfterEach
7171
public void tearDown() {
7272
fViewer= null;
7373
}

tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningProjectionViewerTest.java

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

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

1818
import java.util.ArrayList;
1919
import java.util.Arrays;
@@ -22,10 +22,10 @@
2222
import java.util.concurrent.CompletableFuture;
2323
import java.util.concurrent.atomic.AtomicReference;
2424

25-
import org.junit.After;
26-
import org.junit.Assert;
27-
import org.junit.Before;
28-
import org.junit.Test;
25+
import org.junit.jupiter.api.AfterEach;
26+
import org.junit.jupiter.api.Assertions;
27+
import org.junit.jupiter.api.BeforeEach;
28+
import org.junit.jupiter.api.Test;
2929
import org.osgi.framework.Bundle;
3030

3131
import org.eclipse.swt.SWT;
@@ -90,7 +90,7 @@ public void dispose() {
9090
private Shell fParent;
9191
private ProjectionViewer fViewer;
9292

93-
@Before
93+
@BeforeEach
9494
public void setUp() {
9595
Shell[] shells= Display.getDefault().getShells();
9696
for (Shell shell : shells) {
@@ -112,7 +112,7 @@ public void setUp() {
112112
fViewer.doOperation(ProjectionViewer.TOGGLE);
113113
}
114114

115-
@After
115+
@AfterEach
116116
public void tearDown() {
117117
fParent.dispose();
118118
}
@@ -137,7 +137,7 @@ protected Shell findNewShell(Collection<Shell> beforeShells) {
137137
DisplayHelper.sleep(fParent.getDisplay(), 1000);
138138
}
139139
afterShells= findNewShells(beforeShells);
140-
assertTrue("No new shell found, existing: " + beforeShells, afterShells.size() > beforeShells.size());
140+
assertTrue(afterShells.size() > beforeShells.size(), "No new shell found, existing: " + beforeShells);
141141
return afterShells.get(0);
142142
}
143143

@@ -166,7 +166,7 @@ public void testCollapse() throws Exception {
166166
try {
167167
// without workbench, next line throws Exception directly
168168
DisplayHelper.sleep(fParent.getDisplay(), 1000);
169-
Assert.assertNull(logError.get());
169+
Assertions.assertNull(logError.get());
170170
} finally {
171171
if (log != null) {
172172
log.removeLogListener(logListener);

tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/contentassist/AsyncContentAssistTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
*******************************************************************************/
1515
package org.eclipse.jface.text.tests.contentassist;
1616

17-
import static org.junit.Assert.assertNotNull;
18-
import static org.junit.Assert.assertNull;
19-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.assertNotNull;
18+
import static org.junit.jupiter.api.Assertions.assertNull;
19+
import static org.junit.jupiter.api.Assertions.assertTrue;
2020
import static org.junit.Assume.assumeFalse;
2121

2222
import java.util.Arrays;
2323
import java.util.Collection;
2424

25-
import org.junit.After;
26-
import org.junit.Before;
27-
import org.junit.Test;
25+
import org.junit.jupiter.api.AfterEach;
26+
import org.junit.jupiter.api.BeforeEach;
27+
import org.junit.jupiter.api.Test;
2828

2929
import org.eclipse.swt.SWT;
3030
import org.eclipse.swt.layout.FillLayout;
@@ -58,7 +58,7 @@ public class AsyncContentAssistTest {
5858

5959
private Shell shell;
6060

61-
@Before
61+
@BeforeEach
6262
public void setUp() {
6363
shell= new Shell();
6464
listener= (status, plugin) -> {
@@ -69,7 +69,7 @@ public void setUp() {
6969
Platform.addLogListener(listener);
7070
}
7171

72-
@After
72+
@AfterEach
7373
public void tearDown() {
7474
shell.dispose();
7575
Platform.removeLogListener(listener);
@@ -123,13 +123,13 @@ public void testCompletePrefix() {
123123
final Collection<Shell> beforeShells= AbstractContentAssistTest.getCurrentShells();
124124
contentAssistant.showPossibleCompletions();
125125
Shell newShell= AbstractContentAssistTest.findNewShell(beforeShells);
126-
assertTrue("Completion item not shown", new DisplayHelper() {
126+
assertTrue(new DisplayHelper() {
127127
@Override
128128
protected boolean condition() {
129129
Table completionTable= findCompletionSelectionControl(newShell);
130130
return Arrays.stream(completionTable.getItems()).map(TableItem::getText).anyMatch(item -> item.contains(BarContentAssistProcessor.PROPOSAL.substring(document.getLength())));
131131
}
132-
}.waitForCondition(display, 2000));
132+
}.waitForCondition(display, 2000), "Completion item not shown");
133133
}
134134

135135
@Test
@@ -164,13 +164,13 @@ public void testCompleteActivationChar() {
164164
final Collection<Shell> beforeShells= AbstractContentAssistTest.getCurrentShells();
165165
AbstractContentAssistTest.processEvents();
166166
Shell newShell= AbstractContentAssistTest.findNewShell(beforeShells);
167-
assertTrue("Completion item not shown", new DisplayHelper() {
167+
assertTrue(new DisplayHelper() {
168168
@Override
169169
protected boolean condition() {
170170
Table completionTable= findCompletionSelectionControl(newShell);
171171
return Arrays.stream(completionTable.getItems()).map(TableItem::getText).anyMatch(item -> item.contains(BarContentAssistProcessor.PROPOSAL.substring(document.getLength())));
172172
}
173-
}.waitForCondition(display, 4000));
173+
}.waitForCondition(display, 4000), "Completion item not shown");
174174
}
175175

176176
private static Table findCompletionSelectionControl(Widget control) {

tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/contentassist/FilteringAsyncContentAssistTests.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
package org.eclipse.jface.text.tests.contentassist;
1212

1313
import static java.util.Collections.singletonList;
14-
import static org.junit.Assert.assertEquals;
15-
import static org.junit.Assert.assertNotNull;
16-
import static org.junit.Assert.assertTrue;
14+
import static org.junit.jupiter.api.Assertions.assertEquals;
15+
import static org.junit.jupiter.api.Assertions.assertNotNull;
16+
import static org.junit.jupiter.api.Assertions.assertTrue;
1717

1818
import java.lang.reflect.Field;
1919
import java.util.ArrayList;
@@ -22,10 +22,10 @@
2222
import java.util.concurrent.CountDownLatch;
2323
import java.util.function.Predicate;
2424

25-
import org.junit.After;
26-
import org.junit.Before;
27-
import org.junit.Ignore;
28-
import org.junit.Test;
25+
import org.junit.jupiter.api.AfterEach;
26+
import org.junit.jupiter.api.BeforeEach;
27+
import org.junit.jupiter.api.Disabled;
28+
import org.junit.jupiter.api.Test;
2929

3030
import org.eclipse.swt.SWT;
3131
import org.eclipse.swt.graphics.Image;
@@ -64,7 +64,7 @@ public class FilteringAsyncContentAssistTests {
6464
private SourceViewer viewer;
6565
private ContentAssistant ca;
6666

67-
@Before
67+
@BeforeEach
6868
public void setup() {
6969
tearDown();
7070

@@ -79,7 +79,7 @@ public void setup() {
7979
ca = new ContentAssistant(true);
8080
}
8181

82-
@After
82+
@AfterEach
8383
public void tearDown() {
8484
if (shell != null) {
8585
ca.uninstall();
@@ -288,7 +288,8 @@ public void testCA_WithFirstDelayedThenImmediateProposals() throws Exception {
288288
*
289289
* @throws Exception exception
290290
*/
291-
@Test @Ignore
291+
@Test
292+
@Disabled("Bug: filtering only applied after all CA processors have completed")
292293
public void testFastCompletionsNotFilteredUntilLongComplitionsCalculated() throws Exception {
293294
IDocument document = viewer.getDocument();
294295

0 commit comments

Comments
 (0)