|
15 | 15 |
|
16 | 16 | import static org.junit.Assert.assertArrayEquals;
|
17 | 17 | import static org.junit.Assert.assertEquals;
|
| 18 | +import static org.junit.Assert.assertThrows; |
18 | 19 | import static org.junit.Assert.assertTrue;
|
19 |
| -import static org.junit.Assert.fail; |
20 | 20 |
|
21 | 21 | import java.util.ArrayList;
|
22 | 22 | import java.util.List;
|
@@ -45,12 +45,7 @@ public void setUp() {
|
45 | 45 | @Override
|
46 | 46 | @Test
|
47 | 47 | public void test_ConstructorLorg_eclipse_swt_widgets_CompositeI() {
|
48 |
| - try { |
49 |
| - new ToolBar(null, 0); |
50 |
| - fail("No exception thrown for parent == null"); |
51 |
| - } |
52 |
| - catch (IllegalArgumentException e) { |
53 |
| - } |
| 48 | + assertThrows("No exception thrown for parent == null", IllegalArgumentException.class, () -> new ToolBar(null, 0)); |
54 | 49 | }
|
55 | 50 |
|
56 | 51 | @Override
|
@@ -84,17 +79,12 @@ public void test_getItemI() {
|
84 | 79 | }
|
85 | 80 |
|
86 | 81 | toolBar = new ToolBar(shell, 0);
|
87 |
| - number = 5; |
88 | 82 | items = new ToolItem[number];
|
89 | 83 | for (int i = 0; i<number ; i++){
|
90 | 84 | items[i] = new ToolItem(toolBar, 0);
|
91 | 85 | }
|
92 |
| - try { |
93 |
| - toolBar.getItem(number); |
94 |
| - fail("No exception thrown for illegal index argument"); |
95 |
| - } |
96 |
| - catch (IllegalArgumentException e) { |
97 |
| - } |
| 86 | + assertThrows("No exception thrown for illegal index argument", IllegalArgumentException.class, ()-> |
| 87 | + toolBar.getItem(number)); |
98 | 88 | }
|
99 | 89 |
|
100 | 90 | @Test
|
@@ -159,12 +149,8 @@ public void test_indexOfLorg_eclipse_swt_widgets_ToolItem() {
|
159 | 149 | tis[i] = new ToolItem(toolBar, 0);
|
160 | 150 | }
|
161 | 151 | for (int i = 0; i<number ; i++){
|
162 |
| - try { |
163 |
| - toolBar.indexOf(null); |
164 |
| - fail("No exception thrown for toolItem == null"); |
165 |
| - } |
166 |
| - catch (IllegalArgumentException e) { |
167 |
| - } |
| 152 | + assertThrows("No exception thrown for toolItem == null", IllegalArgumentException.class, |
| 153 | + () -> toolBar.indexOf(null)); |
168 | 154 | }
|
169 | 155 | }
|
170 | 156 |
|
|
0 commit comments