2929
3030package org .scijava .module .event ;
3131
32+ import static org .junit .Assert .assertEquals ;
3233import static org .junit .Assert .assertThrows ;
33- import static org .junit .Assert .assertTrue ;
34+ import static org .junit .Assert .assertNotNull ;
3435
3536import org .junit .Before ;
3637import org .junit .Test ;
4849 * Tests {@link ModuleErroredEvent} behavior.
4950 *
5051 * @author Gabriel Selzer
52+ * @author Curtis Rueden
5153 */
5254public 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