Skip to content

Commit d8b0318

Browse files
committed
ModuleErroredEventTest: assert correct exception
1 parent f1e90a4 commit d8b0318

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/test/java/org/scijava/module/event/ModuleErroredEventTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929

3030
package org.scijava.module.event;
3131

32+
import static org.junit.Assert.assertEquals;
3233
import static org.junit.Assert.assertThrows;
33-
import static org.junit.Assert.assertTrue;
34+
import static org.junit.Assert.assertNotNull;
3435

3536
import org.junit.Before;
3637
import org.junit.Test;
@@ -48,6 +49,7 @@
4849
* Tests {@link ModuleErroredEvent} behavior.
4950
*
5051
* @author Gabriel Selzer
52+
* @author Curtis Rueden
5153
*/
5254
public class ModuleErroredEventTest {
5355

@@ -65,22 +67,23 @@ public void setUp() {
6567
public void testModuleErroredEvent() {
6668

6769
// Must be a final boolean array to be included in the below closure
68-
final boolean[] caughtException = { false };
70+
final Throwable[] caughtException = { null };
6971

7072
// Add a new EventHandler to change our state
7173
final Object interestedParty = new Object() {
7274

7375
@EventHandler
7476
void onEvent(final ModuleErroredEvent e) {
75-
caughtException[0] = true;
77+
caughtException[0] = e.getException();
7678
}
7779
};
7880
es.subscribe(interestedParty);
7981

8082
// Run the module, ensure we get the exception
8183
assertThrows(Exception.class, //
8284
() -> module.run(new TestModuleInfo(), false).get());
83-
assertTrue(caughtException[0]);
85+
assertNotNull(caughtException[0]);
86+
assertEquals("Yay!", caughtException[0].getMessage());
8487
}
8588

8689
static class TestModuleInfo extends AbstractModuleInfo {

0 commit comments

Comments
 (0)