4343import org .junit .jupiter .api .BeforeAll ;
4444import org .junit .jupiter .api .Test ;
4545
46+ import test .javafx .util .OutputRedirect ;
4647import test .util .Util ;
4748
4849public class JFXPanelNPETest {
@@ -86,23 +87,19 @@ public void doCleanup() {
8687
8788 @ Test
8889 public void testSceneNPE () throws Exception {
89- failure = new AtomicBoolean (false );
90- Thread .setDefaultUncaughtExceptionHandler (new Thread .UncaughtExceptionHandler () {
91- @ Override
92- public void uncaughtException (Thread t , Throwable e ) {
93- e .printStackTrace ();
94- failure .set (true );
90+ OutputRedirect .suppressStderr ();
91+ try {
92+ SwingUtilities .invokeAndWait (JFXPanelNPETest ::createUI );
93+ for (int i = 0 ; i < 300 ; i ++) {
94+ SwingUtilities .invokeLater (contentPane ::repaint );
95+ Platform .runLater (() -> contentPane .setScene (null ));
96+ Thread .sleep (1 );
97+ Platform .runLater (() -> contentPane .setScene (webView .getScene ()));
98+ Thread .sleep (1 );
9599 }
96- });
97- SwingUtilities .invokeAndWait (JFXPanelNPETest ::createUI );
98- for (int i = 0 ; i < 300 ; i ++) {
99- SwingUtilities .invokeLater (contentPane ::repaint );
100- Platform .runLater (() -> contentPane .setScene (null ));
101- Thread .sleep (1 );
102- Platform .runLater (() -> contentPane .setScene (webView .getScene ()));
103- Thread .sleep (1 );
100+ } finally {
101+ OutputRedirect .checkAndRestoreStderr ();
104102 }
105- Assertions .assertFalse (failure .get ());
106103 }
107104
108105 protected static void createUI () {
@@ -122,4 +119,3 @@ private static void fx(final JFXPanel contentPane) {
122119 contentPane .setScene (new Scene (webView ));
123120 }
124121}
125-
0 commit comments