You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Link.java
@@ -60,13 +60,7 @@ public void test_ConstructorLorg_eclipse_swt_widgets_CompositeI() {
60
60
link.dispose();
61
61
link = newLink(shell, SWT.BORDER);
62
62
link.dispose();
63
-
try {
64
-
link = newLink(null, 0);
65
-
fail("No exception thrown for parent == null");
66
-
}
67
-
catch (IllegalArgumentExceptione) {
68
-
// expected
69
-
}
63
+
assertThrows(IllegalArgumentException.class, () -> newLink(null, 0), "No exception thrown for parent == null");
70
64
}
71
65
72
66
@Test
@@ -82,23 +76,13 @@ public void widgetDefaultSelected(SelectionEvent e) {
82
76
}
83
77
};
84
78
85
-
try {
86
-
link.addSelectionListener(null);
87
-
fail("No exception thrown for addSelectionListener with null argument");
88
-
} catch (IllegalArgumentExceptione) {
89
-
// expected
90
-
}
79
+
assertThrows(IllegalArgumentException.class, () -> link.addSelectionListener(null), "No exception thrown for addSelectionListener with null argument");
91
80
92
81
link.addSelectionListener(listener);
93
82
link.notifyListeners(SWT.Selection, newEvent());
94
83
assertTrue(listenerCalled);
95
84
96
-
try {
97
-
link.removeSelectionListener(null);
98
-
fail("No exception thrown for removeSelectionListener with null argument");
99
-
} catch (IllegalArgumentExceptione) {
100
-
// expected
101
-
}
85
+
assertThrows(IllegalArgumentException.class, () -> link.removeSelectionListener(null), "No exception thrown for removeSelectionListener with null argument");
102
86
listenerCalled = false;
103
87
link.removeSelectionListener(listener);
104
88
link.notifyListeners(SWT.Selection, newEvent());
@@ -174,12 +158,7 @@ public void test_setTextLjava_lang_String() {
174
158
link.setText(text);
175
159
assertEquals(link.getText() , text);
176
160
}
177
-
try {
178
-
link.setText(null);
179
-
fail("No exception thrown for text == null");
180
-
} catch (IllegalArgumentExceptione) {
181
-
// expected
182
-
}
161
+
assertThrows(IllegalArgumentException.class, () -> link.setText(null), "No exception thrown for text == null");
183
162
}
184
163
185
164
@Test
@@ -189,7 +168,7 @@ public void test_setLinkForegroundLorg_eclipse_swt_graphics_Color() {
0 commit comments