Skip to content

Commit 0495e6c

Browse files
committed
Migrate org.eclipse.text.quicksearch.tests from JUnit 4 to JUnit 5
1 parent 34e3f47 commit 0495e6c

File tree

5 files changed

+41
-39
lines changed

5 files changed

+41
-39
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ Bundle-Version: 1.3.0.qualifier
66
Require-Bundle: org.eclipse.core.runtime,
77
org.eclipse.text.quicksearch;bundle-version="1.0.300",
88
org.eclipse.core.resources,
9-
org.junit;bundle-version="4.8.0",
109
org.eclipse.ui.ide;bundle-version="3.17.0",
1110
org.eclipse.jface;bundle-version="3.20.0",
1211
org.eclipse.ui.tests.harness;bundle-version="1.6.0"
12+
Import-Package: org.junit.jupiter.api;version="[5.14.0,6.0.0)",
13+
org.junit.jupiter.api.function;version="[5.14.0,6.0.0)",
14+
org.junit.platform.launcher;version="[1.14.0,2.0.0)",
15+
org.junit.platform.suite.api;version="[1.14.0,2.0.0)"
1316
Bundle-ActivationPolicy: lazy
1417
Bundle-RequiredExecutionEnvironment: JavaSE-21
1518
Bundle-Vendor: %providerName

tests/org.eclipse.text.quicksearch.tests/src/org/eclipse/text/quicksearch/tests/DefaultPriorityFunctionTest.java

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

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

1919
import org.eclipse.core.resources.IFolder;
2020
import org.eclipse.core.resources.IProject;
@@ -24,21 +24,21 @@
2424
import org.eclipse.text.quicksearch.internal.core.priority.DefaultPriorityFunction;
2525
import org.eclipse.text.quicksearch.internal.core.priority.PriorityFunction;
2626
import org.eclipse.text.quicksearch.internal.ui.QuickSearchActivator;
27-
import org.junit.Before;
28-
import org.junit.Test;
27+
import org.junit.jupiter.api.BeforeEach;
28+
import org.junit.jupiter.api.Test;
2929

30-
public class DefaultPriorityFunctionTest {
30+
class DefaultPriorityFunctionTest {
3131

3232
private DefaultPriorityFunction fPriorityFunction;
3333

34-
@Before
35-
public void setup() {
34+
@BeforeEach
35+
void setup() {
3636
fPriorityFunction = new DefaultPriorityFunction();
3737
fPriorityFunction.configure(QuickSearchActivator.getDefault().getPreferences());
3838
}
3939

4040
@Test
41-
public void testIgnoreLinkedContainers() throws Exception {
41+
void testIgnoreLinkedContainers() throws Exception {
4242
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
4343
IProject p1 = root.getProject("p1");
4444
p1.create(null);
@@ -63,7 +63,7 @@ public void testIgnoreLinkedContainers() throws Exception {
6363
}
6464

6565
@Test
66-
public void testDoNotIgnoreVirtualFolder() throws Exception {
66+
void testDoNotIgnoreVirtualFolder() throws Exception {
6767
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
6868

6969
IProject p3 = root.getProject("p3");

tests/org.eclipse.text.quicksearch.tests/src/org/eclipse/text/quicksearch/tests/PrioriTreeTest.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@
1212

1313
import static org.eclipse.text.quicksearch.internal.core.priority.PriorityFunction.PRIORITY_DEFAULT;
1414
import static org.eclipse.text.quicksearch.internal.core.priority.PriorityFunction.PRIORITY_IGNORE;
15-
import static org.junit.Assert.assertEquals;
15+
import static org.junit.jupiter.api.Assertions.assertEquals;
1616

1717
import org.eclipse.core.runtime.IPath;
1818
import org.eclipse.text.quicksearch.internal.core.priority.PrioriTree;
19-
import org.junit.Before;
20-
import org.junit.Test;
19+
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.api.Test;
2121

22-
public class PrioriTreeTest {
22+
class PrioriTreeTest {
2323

2424
PrioriTree tree;
2525

26-
@Before
27-
public void setUp() throws Exception {
26+
@BeforeEach
27+
void setUp() throws Exception {
2828
tree = PrioriTree.create();
2929
}
3030

3131
@Test
32-
public void testWithEmptyTree() {
32+
void testWithEmptyTree() {
3333
//In the empty tree most paths are assigned 'DEFAULT' priority.
3434
checkPriority(PRIORITY_DEFAULT, "/");
3535
checkPriority(PRIORITY_DEFAULT, "/foo/bar/zor");
@@ -48,7 +48,7 @@ public void testWithEmptyTree() {
4848

4949
}
5050
@Test
51-
public void testSinglePathSet() {
51+
void testSinglePathSet() {
5252
setPriority("/foo/bar/zor", 100.0);
5353

5454
//Path itself should have the set priority
@@ -71,7 +71,7 @@ public void testSinglePathSet() {
7171
checkPriority(PRIORITY_IGNORE, "/foo/bar/zor/nested/big.zip");
7272
}
7373
@Test
74-
public void testSetOverlappingPaths() {
74+
void testSetOverlappingPaths() {
7575
setPriority("/shared/foo", 50.0);
7676
setPriority("/shared/bar", 100.0);
7777

@@ -94,7 +94,7 @@ public void testSetOverlappingPaths() {
9494
* be the same.
9595
*/
9696
@Test
97-
public void testSetOverlappingPaths2() {
97+
void testSetOverlappingPaths2() {
9898
setPriority("/shared/bar", 100.0);
9999
setPriority("/shared/foo", 50.0);
100100

@@ -113,7 +113,7 @@ public void testSetOverlappingPaths2() {
113113
* Need support for setting priority of an entire subtree.
114114
*/
115115
@Test
116-
public void testSetTreePriority() {
116+
void testSetTreePriority() {
117117
setPriority("/promoted", 100.0);
118118

119119
//Stuff not in the raised subtree should be unchanged
@@ -133,7 +133,7 @@ public void testSetTreePriority() {
133133
* children already had a priority assigned before.
134134
*/
135135
@Test
136-
public void testSetTreePriority2() {
136+
void testSetTreePriority2() {
137137
setPriority("/promoted/sub/sub", 50.0);
138138
checkPriority(50.0, "/promoted");
139139
checkPriority(50.0, "/promoted/sub");
@@ -161,8 +161,7 @@ private void setPriority(String pathStr, double pri) {
161161
}
162162

163163
private void checkPriority(double expected, String pathStr) {
164-
assertEquals(pathStr,
165-
expected, tree.priority(new MockResource(pathStr)), 0);
164+
assertEquals(expected, tree.priority(new MockResource(pathStr)), 0.0, pathStr);
166165
}
167166

168167
}

tests/org.eclipse.text.quicksearch.tests/src/org/eclipse/text/quicksearch/tests/QuickAccessComputerTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
*******************************************************************************/
1010
package org.eclipse.text.quicksearch.tests;
1111

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

1515
import java.io.IOException;
1616
import java.io.InputStream;
@@ -25,9 +25,9 @@
2525
import org.eclipse.ui.IWorkbenchWindow;
2626
import org.eclipse.ui.PlatformUI;
2727
import org.eclipse.ui.tests.harness.util.DisplayHelper;
28-
import org.junit.Test;
28+
import org.junit.jupiter.api.Test;
2929

30-
public class QuickAccessComputerTest {
30+
class QuickAccessComputerTest {
3131

3232
private final class QuickSearchDialogExtension extends QuickSearchDialog {
3333
private QuickSearchDialogExtension(IWorkbenchWindow window) {
@@ -42,7 +42,7 @@ public Object[] getResult() {
4242
}
4343

4444
@Test
45-
public void testQuickAccessComputer() throws CoreException, IOException {
45+
void testQuickAccessComputer() throws CoreException, IOException {
4646
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(getClass().getName() + System.currentTimeMillis());
4747
project.create(null);
4848
project.open(null);

tests/org.eclipse.text.quicksearch.tests/src/org/eclipse/text/quicksearch/tests/ResourceMatcherTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@
1212
*******************************************************************************/
1313
package org.eclipse.text.quicksearch.tests;
1414

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

1919
import org.eclipse.core.runtime.IPath;
2020
import org.eclipse.text.quicksearch.internal.core.pathmatch.ResourceMatcher;
2121
import org.eclipse.text.quicksearch.internal.core.pathmatch.ResourceMatchers;
22-
import org.junit.Test;
22+
import org.junit.jupiter.api.Test;
2323

2424
@SuppressWarnings("restriction")
25-
public class ResourceMatcherTest {
25+
class ResourceMatcherTest {
2626

2727
@Test
28-
public void simpleRelativePattern() throws Exception {
28+
void simpleRelativePattern() throws Exception {
2929
assertMatch(true, "*.java", "/myproject/something/nested/foo.java");
3030
assertMatch(false, "*.java", "/myproject/foo.class");
3131
}
3232

3333
@Test
34-
public void commaSeparatedPaths() throws Exception {
34+
void commaSeparatedPaths() throws Exception {
3535
String[] patterns = new String[] { //
3636
"*.java,*.properties", //
3737
"*.java, *.properties", //
@@ -50,21 +50,21 @@ public void commaSeparatedPaths() throws Exception {
5050
}
5151

5252
@Test
53-
public void complexRelativePattern() throws Exception {
53+
void complexRelativePattern() throws Exception {
5454
assertMatch(true, "src/**/*.java", "/myproject/src/my/package/Foo.java");
5555
assertMatch(false, "src/**/*.java", "/myproject/resources/my/package/Foo.java");
5656
}
5757

5858
@Test
59-
public void absolutePath() throws Exception {
59+
void absolutePath() throws Exception {
6060
assertMatch(true, "/myproject/**/*.java", "/myproject/src/my/package/Foo.java");
6161
assertMatch(false, "/myproject/**/*.java", "/otherproject/src/my/package/Foo.java");
6262
}
6363

6464
private void assertMatch(boolean expectedMatch, String patterns, String path) {
6565
assertTrue(IPath.fromOSString(path).isAbsolute());
6666
ResourceMatcher matcher = ResourceMatchers.commaSeparatedPaths(patterns);
67-
assertEquals("Wrong match with pattern: '" + patterns + "'", expectedMatch, matcher.matches(new MockResource(path)));
67+
assertEquals(expectedMatch, matcher.matches(new MockResource(path)), "Wrong match with pattern: '" + patterns + "'");
6868

6969
// Most ResourceMatchers have a custom toString. Do a quick test to check for thrown exceptions.
7070
assertNotNull(matcher.toString());

0 commit comments

Comments
 (0)