|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2000, 2016 IBM Corporation and others. |
| 2 | + * Copyright (c) 2000, 2025 IBM Corporation and others. |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials |
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0 |
|
16 | 16 |
|
17 | 17 |
|
18 | 18 | import static org.junit.Assert.assertNotNull; |
| 19 | +import static org.junit.Assert.assertThrows; |
19 | 20 | import static org.junit.Assert.assertTrue; |
20 | | -import static org.junit.Assert.fail; |
21 | 21 |
|
22 | 22 | import java.io.IOException; |
23 | 23 | import java.io.InputStream; |
@@ -120,20 +120,12 @@ public void test_ConstructorLorg_eclipse_swt_graphics_DeviceI() { |
120 | 120 | cursor.dispose(); |
121 | 121 |
|
122 | 122 | // illegal argument, style > SWT.CURSOR_HAND (21) |
123 | | - try { |
124 | | - cursor = new Cursor(display, 100); |
125 | | - cursor.dispose(); |
126 | | - fail("No exception thrown for style > SWT.CURSOR_HAND (21)"); |
127 | | - } catch (IllegalArgumentException e) { |
128 | | - } |
| 123 | + assertThrows("No exception thrown for style > SWT.CURSOR_HAND (21)", |
| 124 | + IllegalArgumentException.class, () -> new Cursor(display, 100)); |
129 | 125 |
|
130 | 126 | // illegal argument, style < 0 |
131 | | - try { |
132 | | - cursor = new Cursor(display, -100); |
133 | | - cursor.dispose(); |
134 | | - fail("No exception thrown for style < 0"); |
135 | | - } catch (IllegalArgumentException e) { |
136 | | - } |
| 127 | + assertThrows("No exception thrown for style < 0", |
| 128 | + IllegalArgumentException.class, () -> new Cursor(display, -100)); |
137 | 129 | } |
138 | 130 |
|
139 | 131 | @Test |
@@ -164,12 +156,8 @@ public void test_ConstructorWithImageDataProvider() { |
164 | 156 | cursor.dispose(); |
165 | 157 | sourceImage.dispose(); |
166 | 158 |
|
167 | | - try { |
168 | | - cursor = new Cursor(display, (ImageDataProvider) null, 0, 0); |
169 | | - cursor.dispose(); |
170 | | - fail("No exception thrown when ImageDataProvider is null"); |
171 | | - } catch (IllegalArgumentException e) { |
172 | | - } |
| 159 | + assertThrows("No exception thrown when ImageDataProvider is null", |
| 160 | + IllegalArgumentException.class, () -> new Cursor(display, (ImageDataProvider) null, 0, 0)); |
173 | 161 | } |
174 | 162 |
|
175 | 163 | @Test |
|
0 commit comments