< prev index next >

modules/controls/src/test/java/javafx/scene/control/MultipleSelectionModelImplTest.java

Print this page
rev 8906 : RT-46083: TimelineClipCore exceptions handling improvent

@@ -23,10 +23,11 @@
  * questions.
  */
 
 package javafx.scene.control;
 
+import com.sun.javafx.scene.control.infrastructure.ControlTestUtils;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;

@@ -1168,24 +1169,20 @@
         treeView.setRoot(null);
         treeTableView.setRoot(null);
     }
 
     @Test public void test_rt40804() {
-        final Thread.UncaughtExceptionHandler exceptionHandler = Thread.currentThread().getUncaughtExceptionHandler();
-        Thread.currentThread().setUncaughtExceptionHandler((t, e) -> {
-            e.printStackTrace();
-            fail("We don't expect any exceptions in this test!");
-        });
-
         StageLoader sl = new StageLoader(currentControl);
         model.setSelectionMode(SelectionMode.MULTIPLE);
         model.select(0);
         model.select(1);
         model.clearSelection();
+        final Thread.UncaughtExceptionHandler exceptionHandler = ControlTestUtils.setHandler();
+        try {
         model.select(3); // this is where the test failed
+        } finally {
+            ControlTestUtils.resetHandler(exceptionHandler);
+        }
 
         sl.dispose();
-
-        // reset the exception handler
-        Thread.currentThread().setUncaughtExceptionHandler(exceptionHandler);
     }
 }
< prev index next >