Skip to content

Commit 937cbb2

Browse files
committed
Migrate org.eclipse.search.tests from JUnit 4 to JUnit 5
The tests in org.eclipse.search.tests.filesearch uses a JUnit4 rules, these will be migrated separately.
1 parent 45a17c9 commit 937cbb2

File tree

9 files changed

+41
-32
lines changed

9 files changed

+41
-32
lines changed

tests/org.eclipse.search.tests/META-INF/MANIFEST.MF

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ Require-Bundle:
1414
org.eclipse.search;bundle-version="[3.16.0,4.0.0)",
1515
org.eclipse.core.runtime;bundle-version="[3.29.100,4.0.0)",
1616
org.eclipse.core.resources;bundle-version="[3.19.200,4.0.0)",
17-
org.junit;bundle-version="4.13.0",
1817
org.eclipse.ui.workbench.texteditor;bundle-version="[3.17.200,4.0.0)",
1918
org.eclipse.jface.text;bundle-version="[3.24.200,4.0.0)",
2019
org.eclipse.ui.editors;bundle-version="[3.17.100,4.0.0)",
21-
org.eclipse.ltk.core.refactoring;bundle-version="[3.14.100,4.0.0)"
20+
org.eclipse.ltk.core.refactoring;bundle-version="[3.14.100,4.0.0)",
21+
org.junit;bundle-version="4.13.2"
2222
Import-Package: org.junit.jupiter.api;version="[5.14.0,6.0.0)",
23+
org.junit.jupiter.api.function;version="[5.14.0,6.0.0)",
2324
org.junit.platform.suite.api;version="[1.14.0,2.0.0)"
2425
Bundle-ActivationPolicy: lazy
2526
Bundle-RequiredExecutionEnvironment: JavaSE-17

tests/org.eclipse.search.tests/src/org/eclipse/search/core/tests/AllSearchModelTests.java

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

16-
import org.junit.platform.suite.api.Suite;
1716
import org.junit.platform.suite.api.SelectClasses;
17+
import org.junit.platform.suite.api.Suite;
1818

1919
@Suite
2020
@SelectClasses({

tests/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LineConversionTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414

1515
package org.eclipse.search.core.tests;
1616

17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertThrows;
17+
18+
import static org.junit.jupiter.api.Assertions.assertEquals;
19+
import static org.junit.jupiter.api.Assertions.assertThrows;
1920

2021
import java.io.ByteArrayInputStream;
2122

22-
import org.junit.After;
23-
import org.junit.Before;
24-
import org.junit.Test;
23+
import org.junit.jupiter.api.AfterEach;
24+
import org.junit.jupiter.api.BeforeEach;
25+
import org.junit.jupiter.api.Test;
2526

2627
import org.eclipse.core.resources.IFile;
2728
import org.eclipse.core.resources.IProject;
@@ -49,7 +50,7 @@ public class LineConversionTest {
4950

5051
private static final String LINE_THREE= "This is the third line";
5152

52-
@Before
53+
@BeforeEach
5354
public void setUp() throws Exception {
5455
IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject("Test");
5556
project.create(null);
@@ -58,7 +59,7 @@ public void setUp() throws Exception {
5859
fFile.create(new ByteArrayInputStream(getFileContents().getBytes()), true, null);
5960
}
6061

61-
@After
62+
@AfterEach
6263
public void tearDown() throws Exception {
6364
SearchPlugin.getActivePage().closeAllEditors(false);
6465
fFile.getProject().delete(true, true, null);

tests/org.eclipse.search.tests/src/org/eclipse/search/core/tests/NullSearchResult.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515

1616
import org.eclipse.jface.resource.ImageDescriptor;
1717

18+
import org.eclipse.search.internal.ui.text.FileSearchResult;
1819
import org.eclipse.search.ui.ISearchQuery;
1920
import org.eclipse.search.ui.text.IEditorMatchAdapter;
2021
import org.eclipse.search.ui.text.IFileMatchAdapter;
2122

22-
import org.eclipse.search.internal.ui.text.FileSearchResult;
23-
2423
public class NullSearchResult extends FileSearchResult { // inherit from FileSearchResult so a search result view can be found
2524

2625
private final NullQuery fNullQuery;

tests/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
*******************************************************************************/
1414
package org.eclipse.search.core.tests;
1515

16-
import static org.junit.Assert.assertFalse;
17-
import static org.junit.Assert.assertTrue;
1816

19-
import org.junit.Test;
17+
18+
import static org.junit.jupiter.api.Assertions.assertFalse;
19+
import static org.junit.jupiter.api.Assertions.assertTrue;
20+
21+
import org.junit.jupiter.api.Test;
2022

2123
import org.eclipse.search.ui.IQueryListener;
2224
import org.eclipse.search.ui.ISearchQuery;

tests/org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
package org.eclipse.search.core.tests;
1515

1616

17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertFalse;
19-
import static org.junit.Assert.assertSame;
20-
import static org.junit.Assert.assertTrue;
2117

22-
import org.junit.Test;
18+
19+
import static org.junit.jupiter.api.Assertions.assertEquals;
20+
import static org.junit.jupiter.api.Assertions.assertFalse;
21+
import static org.junit.jupiter.api.Assertions.assertSame;
22+
import static org.junit.jupiter.api.Assertions.assertTrue;
23+
24+
import org.junit.jupiter.api.Test;
2325

2426
import org.eclipse.search.ui.ISearchQuery;
2527
import org.eclipse.search.ui.text.AbstractTextSearchResult;
@@ -60,9 +62,9 @@ public void testAddMatchDifferentStart() {
6062
Match match3= new Match(object, 0, 2);
6163
result.addMatch(match3);
6264
Match[] matches= result.getMatches(object);
63-
assertSame("matches[0]", matches[0], match3);
64-
assertSame("matches[1]", matches[1], match2);
65-
assertSame("matches[2]", matches[2], match1);
65+
assertSame(matches[0], match3, "matches[0]");
66+
assertSame(matches[1], match2, "matches[1]");
67+
assertSame(matches[2], match1, "matches[2]");
6668
}
6769

6870
@Test
@@ -80,9 +82,9 @@ public void testAddMatchDifferentStartInOrder() {
8082
Match match3= new Match(object, 2, 2);
8183
result.addMatch(match3);
8284
Match[] matches= result.getMatches(object);
83-
assertSame("matches[0]", matches[0], match1);
84-
assertSame("matches[1]", matches[1], match2);
85-
assertSame("matches[2]", matches[2], match3);
85+
assertSame(matches[0], match1, "matches[0]");
86+
assertSame(matches[1], match2, "matches[1]");
87+
assertSame(matches[2], match3, "matches[2]");
8688
}
8789

8890
@Test
@@ -98,8 +100,8 @@ public void testAddMatchDifferentLength() {
98100
Match match2= new Match(object, 1, 0);
99101
result.addMatch(match2);
100102
Match[] matches= result.getMatches(object);
101-
assertSame("matches[0]", matches[0], match2);
102-
assertSame("matches[1]", matches[1], match1);
103+
assertSame(matches[0], match2, "matches[0]");
104+
assertSame(matches[1], match1, "matches[1]");
103105
}
104106

105107
@Test

tests/org.eclipse.search.tests/src/org/eclipse/search/tests/AllSearchTests.java

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

16-
import org.junit.platform.suite.api.Suite;
1716
import org.junit.platform.suite.api.SelectClasses;
17+
import org.junit.platform.suite.api.Suite;
1818

1919
import org.eclipse.search.core.tests.AllSearchModelTests;
2020
import org.eclipse.search.tests.filesearch.AllFileSearchTests;

tests/org.eclipse.search.tests/src/org/eclipse/search/tests/TestTextSearchEngine.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212

1313
import java.util.regex.Pattern;
1414

15-
import org.eclipse.core.resources.IFile;
1615
import org.eclipse.core.runtime.IProgressMonitor;
1716
import org.eclipse.core.runtime.IStatus;
17+
18+
import org.eclipse.core.resources.IFile;
19+
1820
import org.eclipse.search.core.text.TextSearchEngine;
1921
import org.eclipse.search.core.text.TextSearchRequestor;
2022
import org.eclipse.search.core.text.TextSearchScope;

tests/org.eclipse.search.tests/src/org/eclipse/search/tests/TextSearchRegistryTest.java

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

13-
import static org.junit.Assert.assertTrue;
13+
14+
import static org.junit.jupiter.api.Assertions.assertTrue;
1415

1516
import java.util.Arrays;
1617

18+
import org.junit.jupiter.api.Test;
19+
1720
import org.eclipse.search.internal.core.text.TextSearchEngineRegistry;
1821
import org.eclipse.search.internal.ui.SearchPlugin;
19-
import org.junit.Test;
2022

2123
public class TextSearchRegistryTest {
2224

0 commit comments

Comments
 (0)