< prev index next >

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

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

@@ -81,10 +81,11 @@
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 
 import com.sun.javafx.scene.control.TableColumnComparatorBase.TreeTableColumnComparator;
+import com.sun.javafx.scene.control.infrastructure.ControlTestUtils;
 import com.sun.javafx.scene.control.infrastructure.StageLoader;
 import com.sun.javafx.scene.control.infrastructure.VirtualFlowTestUtils;
 import com.sun.javafx.scene.control.skin.VirtualScrollBar;
 import com.sun.javafx.scene.control.test.Person;
 import com.sun.javafx.scene.control.test.RT_22463_Person;

@@ -3614,18 +3615,10 @@
 
         sl.dispose();
     }
 
     @Test public void test_rt_37429() {
-        // get the current exception handler before replacing with our own,
-        // as ListListenerHelp intercepts the exception otherwise
-        final Thread.UncaughtExceptionHandler exceptionHandler = Thread.currentThread().getUncaughtExceptionHandler();
-        Thread.currentThread().setUncaughtExceptionHandler((t, e) -> {
-            e.printStackTrace();
-            fail("We don't expect any exceptions in this test!");
-        });
-
         // table items - 3 items, 2nd item has 2 children
         TreeItem<String> root = new TreeItem<>();
 
         TreeItem<String> two = new TreeItem<>("two");
         two.getChildren().add(new TreeItem<>("childOne"));

@@ -3659,19 +3652,20 @@
                     c.getAddedSubList();
                 }
             }
         });
 
+        final Thread.UncaughtExceptionHandler exceptionHandler = ControlTestUtils.setHandler();
         StageLoader sl = new StageLoader(table);
 
+        try {
         table.getSelectionModel().select(0);
         table.getSortOrder().add(nameColumn);
-
+        } finally {
         sl.dispose();
-
-        // reset the exception handler
-        Thread.currentThread().setUncaughtExceptionHandler(exceptionHandler);
+            ControlTestUtils.resetHandler(exceptionHandler);
+        }
     }
 
     private int rt_37429_items_change_count = 0;
     private int rt_37429_cells_change_count = 0;
     @Test public void test_rt_37429_sortEventsShouldNotFireExtraChangeEvents() {
< prev index next >