Skip to content

Commit 009532c

Browse files
committed
Replace "expected" parameter in browser tests with assertThrows
This change replaces the "expected" parameter for specifying an exception to be thrown by a test method with the more fine-grained and JUnit-5-compatible usage of assertThrows.
1 parent c1dfe39 commit 009532c

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java

+34-34
Original file line numberDiff line numberDiff line change
@@ -514,14 +514,14 @@ public void test_CloseWindowListener_closeShell() {
514514
shell.close();
515515
}
516516

517-
@Test(expected = IllegalArgumentException.class)
517+
@Test
518518
public void test_CloseWindowListener_addWithNullArg() {
519-
browser.addCloseWindowListener(null);
519+
assertThrows(IllegalArgumentException.class, () -> browser.addCloseWindowListener(null));
520520
}
521521

522-
@Test(expected = IllegalArgumentException.class)
522+
@Test
523523
public void test_CloseWindowListener_removeWithNullArg() {
524-
browser.removeCloseWindowListener(null);
524+
assertThrows(IllegalArgumentException.class, () -> browser.removeCloseWindowListener(null));
525525
}
526526

527527
@Test
@@ -554,14 +554,14 @@ public void test_LocationListener_adapter_closeShell() {
554554
shell.close();
555555
}
556556

557-
@Test(expected = IllegalArgumentException.class)
557+
@Test
558558
public void test_LocationListener_addWithNullArg() {
559-
browser.addLocationListener(null);
559+
assertThrows(IllegalArgumentException.class, () -> browser.addLocationListener(null));
560560
}
561561

562-
@Test(expected = IllegalArgumentException.class)
562+
@Test
563563
public void test_LocationListener_removeWithNullArg() {
564-
browser.removeLocationListener(null);
564+
assertThrows(IllegalArgumentException.class, () -> browser.removeLocationListener(null));
565565
}
566566

567567
@Test
@@ -806,14 +806,14 @@ public void test_OpenWindowListener_closeShell() {
806806
shell.close();
807807
}
808808

809-
@Test(expected = IllegalArgumentException.class)
809+
@Test
810810
public void test_OpenWindowListener_addWithNulArg() {
811-
browser.addOpenWindowListener(null);
811+
assertThrows(IllegalArgumentException.class, () -> browser.addOpenWindowListener(null));
812812
}
813813

814-
@Test(expected = IllegalArgumentException.class)
814+
@Test
815815
public void test_OpenWindowListener_removeWithNullArg() {
816-
browser.removeOpenWindowListener(null);
816+
assertThrows(IllegalArgumentException.class, () -> browser.removeOpenWindowListener(null));
817817
}
818818

819819
@Test
@@ -967,14 +967,14 @@ public void completed(ProgressEvent event) {
967967
shell.close();
968968
}
969969

970-
@Test(expected = IllegalArgumentException.class)
970+
@Test
971971
public void test_ProgressListener_addWithNullArg() {
972-
browser.addProgressListener(null);
972+
assertThrows(IllegalArgumentException.class, () -> browser.addProgressListener(null));
973973
}
974974

975-
@Test(expected = IllegalArgumentException.class)
975+
@Test
976976
public void test_ProgressListener_removeWithNullArg() {
977-
browser.removeProgressListener(null);
977+
assertThrows(IllegalArgumentException.class, () -> browser.removeProgressListener(null));
978978
}
979979

980980
@Test
@@ -1013,14 +1013,14 @@ public void changed(ProgressEvent event) {
10131013
assertTrue(passed);
10141014
}
10151015

1016-
@Test(expected = IllegalArgumentException.class)
1016+
@Test
10171017
public void test_StatusTextListener_addWithNull() {
1018-
browser.addStatusTextListener(null);
1018+
assertThrows(IllegalArgumentException.class, () -> browser.addStatusTextListener(null));
10191019
}
10201020

1021-
@Test(expected = IllegalArgumentException.class)
1021+
@Test
10221022
public void test_StatusTextListener_removeWithNullArg() {
1023-
browser.removeStatusTextListener(null);
1023+
assertThrows(IllegalArgumentException.class, () -> browser.removeStatusTextListener(null));
10241024
}
10251025

10261026
@Test
@@ -1104,14 +1104,14 @@ public void test_TitleListener_addListener_closeShell() {
11041104
shell.close();
11051105
}
11061106

1107-
@Test(expected = IllegalArgumentException.class)
1107+
@Test
11081108
public void test_TitleListener_addwithNull() {
1109-
browser.addTitleListener(null);
1109+
assertThrows(IllegalArgumentException.class, () -> browser.addTitleListener(null));
11101110
}
11111111

1112-
@Test(expected = IllegalArgumentException.class)
1112+
@Test
11131113
public void test_TitleListener_removeWithNullArg() {
1114-
browser.removeTitleListener(null);
1114+
assertThrows(IllegalArgumentException.class, () -> browser.removeTitleListener(null));
11151115
}
11161116

11171117
@Test
@@ -1298,14 +1298,14 @@ public void show(WindowEvent event) {
12981298
shell.close();
12991299
}
13001300

1301-
@Test(expected = IllegalArgumentException.class)
1301+
@Test
13021302
public void test_VisibilityWindowListener_addWithNull() {
1303-
browser.addVisibilityWindowListener(null);
1303+
assertThrows(IllegalArgumentException.class, () -> browser.addVisibilityWindowListener(null));
13041304
}
13051305

1306-
@Test(expected = IllegalArgumentException.class)
1306+
@Test
13071307
public void test_VisibilityWindowListener_removeWithNullArg() {
1308-
browser.removeVisibilityWindowListener(null);
1308+
assertThrows(IllegalArgumentException.class, () -> browser.removeVisibilityWindowListener(null));
13091309
}
13101310

13111311
@Test
@@ -1457,14 +1457,14 @@ public void test_back() {
14571457
assertFalse(result);
14581458
}
14591459

1460-
@Test(expected = IllegalArgumentException.class)
1460+
@Test
14611461
public void test_setTextNull() {
1462-
browser.setText(null);
1462+
assertThrows(IllegalArgumentException.class, () -> browser.setText(null));
14631463
}
14641464

1465-
@Test(expected = IllegalArgumentException.class)
1465+
@Test
14661466
public void test_setUrlWithNullArg() {
1467-
browser.setUrl(null);
1467+
assertThrows(IllegalArgumentException.class, () -> browser.setUrl(null));
14681468
}
14691469

14701470

@@ -1831,9 +1831,9 @@ public void test_stop() {
18311831
browser.stop();
18321832
}
18331833

1834-
@Test(expected = IllegalArgumentException.class)
1834+
@Test
18351835
public void test_execute_withNullArg() {
1836-
browser.execute(null);
1836+
assertThrows(IllegalArgumentException.class, () -> browser.execute(null));
18371837
}
18381838

18391839
/**

0 commit comments

Comments
 (0)