Skip to content

Commit a6fca32

Browse files
committed
Use static imports in genericeditor tests
Will simplify migration to JUnit 5 as method names remain the same but class names change.
1 parent 8a511e3 commit a6fca32

File tree

6 files changed

+37
-32
lines changed

6 files changed

+37
-32
lines changed

tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AutoEditTest.java

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

16-
import org.junit.Assert;
16+
import static org.junit.Assert.assertEquals;
17+
1718
import org.junit.Test;
1819

1920
import org.eclipse.swt.custom.StyledText;
@@ -31,7 +32,7 @@ public void testAutoEdit() throws Exception {
3132
StyledText control= (StyledText) editor.getAdapter(Control.class);
3233
control.setText("");
3334
// order of auto-edits from most specialized to least specialized
34-
Assert.assertEquals("AutoAddedThird!AutoAddedSecond!AutoAddedFirst!", document.get());
35+
assertEquals("AutoAddedThird!AutoAddedSecond!AutoAddedFirst!", document.get());
3536
}
3637

3738
@Test
@@ -42,7 +43,7 @@ public void testEnabledWhenAutoEdit() throws Exception {
4243
StyledText control= (StyledText) editor.getAdapter(Control.class);
4344
control.setText("");
4445
// order of auto-edits from most specialized to least specialized
45-
Assert.assertEquals("AutoAddedFirst!", document.get());
46+
assertEquals("AutoAddedFirst!", document.get());
4647
cleanFileAndEditor();
4748

4849
EnabledPropertyTester.setEnabled(false);
@@ -51,6 +52,6 @@ public void testEnabledWhenAutoEdit() throws Exception {
5152
control= (StyledText) editor.getAdapter(Control.class);
5253
control.setText("");
5354
// order of auto-edits from most specialized to least specialized
54-
Assert.assertEquals("", document.get());
55+
assertEquals("", document.get());
5556
}
5657
}

tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/DoubleClickTest.java

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

1515
import static org.eclipse.ui.tests.harness.util.DisplayHelper.runEventLoop;
1616
import static org.eclipse.ui.tests.harness.util.DisplayHelper.waitForCondition;
17+
import static org.junit.Assert.assertEquals;
1718

18-
import org.junit.Assert;
1919
import org.junit.Test;
2020

2121
import org.eclipse.swt.SWT;
@@ -66,7 +66,7 @@ private void checkDoubleClickSelectionForCaretOffset(int pos, String expectedSel
6666
editorTextWidget.getShell().getDisplay().wake();
6767
Rectangle target = editorTextWidget.getCaret().getBounds();
6868
doubleClick(editorTextWidget, target.x + 5, target.y + 5);
69-
Assert.assertEquals(expectedSelection, editorTextWidget.getSelectionText());
69+
assertEquals(expectedSelection, editorTextWidget.getSelectionText());
7070
}
7171

7272
private void doubleClick(StyledText widget, int x, int y) {

tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/EditorTest.java

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

16-
import org.junit.Assert;
16+
import static org.junit.Assert.assertFalse;
17+
import static org.junit.Assert.assertTrue;
18+
1719
import org.junit.Test;
1820

1921
import org.eclipse.swt.custom.StyledText;
@@ -33,18 +35,18 @@ public class EditorTest extends AbstratGenericEditorTest{
3335
public void testGenericEditorHasWordWrap() throws Exception {
3436
this.editor.setFocus();
3537
final StyledText editorTextWidget = (StyledText) this.editor.getAdapter(Control.class);
36-
Assert.assertFalse(editorTextWidget.getWordWrap());
37-
Assert.assertFalse(this.editor.isWordWrapEnabled());
38+
assertFalse(editorTextWidget.getWordWrap());
39+
assertFalse(this.editor.isWordWrapEnabled());
3840
// Toggle word wrap
3941
ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
4042
Command wordWrapCommand = commandService.getCommand(ITextEditorActionDefinitionIds.WORD_WRAP);
41-
Assert.assertTrue(wordWrapCommand.isDefined());
42-
Assert.assertTrue(wordWrapCommand.isEnabled());
43-
Assert.assertTrue(wordWrapCommand.isHandled());
43+
assertTrue(wordWrapCommand.isDefined());
44+
assertTrue(wordWrapCommand.isEnabled());
45+
assertTrue(wordWrapCommand.isHandled());
4446
PlatformUI.getWorkbench().getService(IHandlerService.class).executeCommand(wordWrapCommand.getId(), null);
4547
//
46-
Assert.assertTrue(editorTextWidget.getWordWrap());
47-
Assert.assertTrue(this.editor.isWordWrapEnabled());
48+
assertTrue(editorTextWidget.getWordWrap());
49+
assertTrue(this.editor.isWordWrapEnabled());
4850
}
4951

5052
@Test
@@ -53,24 +55,24 @@ public void testGenericEditorCanShowWhitespaceCharacters() throws Exception {
5355
// Toggle word wrap
5456
ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
5557
Command wordWrapCommand = commandService.getCommand(ITextEditorActionDefinitionIds.SHOW_WHITESPACE_CHARACTERS);
56-
Assert.assertTrue(wordWrapCommand.isDefined());
57-
Assert.assertTrue(wordWrapCommand.isEnabled());
58-
Assert.assertTrue(wordWrapCommand.isHandled());
58+
assertTrue(wordWrapCommand.isDefined());
59+
assertTrue(wordWrapCommand.isEnabled());
60+
assertTrue(wordWrapCommand.isHandled());
5961
PlatformUI.getWorkbench().getService(IHandlerService.class).executeCommand(wordWrapCommand.getId(), null);
6062
}
6163

6264
@Test
6365
public void testGenericEditorCanUseBlockSelection() throws Exception {
6466
this.editor.setFocus();
65-
Assert.assertFalse(this.editor.isBlockSelectionModeEnabled());
67+
assertFalse(this.editor.isBlockSelectionModeEnabled());
6668
// Toggle word wrap
6769
ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
6870
Command wordWrapCommand = commandService.getCommand(ITextEditorActionDefinitionIds.BLOCK_SELECTION_MODE);
69-
Assert.assertTrue(wordWrapCommand.isDefined());
70-
Assert.assertTrue(wordWrapCommand.isEnabled());
71-
Assert.assertTrue(wordWrapCommand.isHandled());
71+
assertTrue(wordWrapCommand.isDefined());
72+
assertTrue(wordWrapCommand.isEnabled());
73+
assertTrue(wordWrapCommand.isHandled());
7274
PlatformUI.getWorkbench().getService(IHandlerService.class).executeCommand(wordWrapCommand.getId(), null);
7375
//
74-
Assert.assertTrue(this.editor.isBlockSelectionModeEnabled());
76+
assertTrue(this.editor.isBlockSelectionModeEnabled());
7577
}
7678
}

tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@
1818
import static org.junit.Assert.assertNull;
1919
import static org.junit.Assert.assertTrue;
2020
import static org.junit.Assert.fail;
21+
import static org.junit.Assume.assumeFalse;
2122

2223
import java.util.Collections;
2324
import java.util.Map;
2425

25-
import org.junit.Assume;
2626
import org.junit.BeforeClass;
2727
import org.junit.Rule;
2828
import org.junit.Test;
2929
import org.junit.rules.TestName;
3030

31+
import org.eclipse.test.Screenshots;
32+
3133
import org.eclipse.swt.SWT;
3234
import org.eclipse.swt.custom.StyledText;
3335
import org.eclipse.swt.widgets.Composite;
@@ -37,7 +39,7 @@
3739
import org.eclipse.swt.widgets.Link;
3840
import org.eclipse.swt.widgets.Shell;
3941
import org.eclipse.swt.widgets.Text;
40-
import org.eclipse.test.Screenshots;
42+
4143
import org.eclipse.core.runtime.Platform;
4244

4345
import org.eclipse.core.resources.IMarker;
@@ -68,8 +70,8 @@ public class HoverTest extends AbstratGenericEditorTest {
6870

6971
@BeforeClass
7072
public static void skipOnNonLinux() {
71-
Assume.assumeFalse("This test currently always fail on Windows (bug 505842), skipping", Platform.OS_WIN32.equals(Platform.getOS()));
72-
Assume.assumeFalse("This test currently always fail on macOS (bug 505842), skipping", Platform.OS_MACOSX.equals(Platform.getOS()));
73+
assumeFalse("This test currently always fail on Windows (bug 505842), skipping", Platform.OS_WIN32.equals(Platform.getOS()));
74+
assumeFalse("This test currently always fail on macOS (bug 505842), skipping", Platform.OS_MACOSX.equals(Platform.getOS()));
7375
}
7476

7577
@Test

tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/ShowInformationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
import static org.junit.Assert.assertNotNull;
1717
import static org.junit.Assert.assertTrue;
1818
import static org.junit.Assert.fail;
19+
import static org.junit.Assume.assumeFalse;
1920

20-
import org.junit.Assume;
2121
import org.junit.BeforeClass;
2222
import org.junit.Rule;
2323
import org.junit.Test;
@@ -57,8 +57,8 @@ public class ShowInformationTest extends AbstratGenericEditorTest {
5757

5858
@BeforeClass
5959
public static void skipOnNonLinux() {
60-
Assume.assumeFalse("This test currently always fail on Windows (bug 505842), skipping", Platform.OS_WIN32.equals(Platform.getOS()));
61-
Assume.assumeFalse("This test currently always fail on macOS (bug 505842), skipping", Platform.OS_MACOSX.equals(Platform.getOS()));
60+
assumeFalse("This test currently always fail on Windows (bug 505842), skipping", Platform.OS_WIN32.equals(Platform.getOS()));
61+
assumeFalse("This test currently always fail on macOS (bug 505842), skipping", Platform.OS_MACOSX.equals(Platform.getOS()));
6262
}
6363

6464
@Test

tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/StylingTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
package org.eclipse.ui.genericeditor.tests;
1515

1616
import static org.junit.Assert.assertNull;
17+
import static org.junit.Assert.assertTrue;
1718

18-
import org.junit.Assert;
1919
import org.junit.Test;
2020

2121
import org.eclipse.swt.custom.StyleRange;
@@ -33,7 +33,7 @@ public void testStyle() throws Exception {
3333
StyledText widget = (StyledText) editor.getAdapter(Control.class);
3434
StyleRange style= widget.getStyleRangeAtOffset(4);//get the style of first token
3535
boolean isRed= style.foreground.getRGB().equals(new RGB(255, 0, 0));//is it Red?
36-
Assert.assertTrue("Token is not of expected color", isRed);
36+
assertTrue("Token is not of expected color", isRed);
3737
}
3838

3939
@Test
@@ -44,7 +44,7 @@ public void testEnabledWhenStyle() throws Exception {
4444
StyledText widget = (StyledText) editor.getAdapter(Control.class);
4545
StyleRange style= widget.getStyleRangeAtOffset(4);//get the style of first token
4646
boolean isBlue= style.foreground.getRGB().equals(new RGB(0, 0, 255));//is it Blue?
47-
Assert.assertTrue("Token is not of expected color", isBlue);
47+
assertTrue("Token is not of expected color", isBlue);
4848
cleanFileAndEditor();
4949

5050
EnabledPropertyTester.setEnabled(false);

0 commit comments

Comments
 (0)