changeset 10921:a533bdce49bf

8196844: [TestBug] IllegalArgumentException gets logged in some of test.javafx.scene.* tests Reviewed-by: kcr, aghaisas
author arapte
date Fri, 11 May 2018 14:17:48 +0530
parents 9c4d93d56f75
children 80f2b4d0a9ab
files modules/javafx.graphics/src/test/java/test/javafx/scene/Node_bind_Test.java modules/javafx.graphics/src/test/java/test/javafx/scene/effect/BlendTest.java modules/javafx.graphics/src/test/java/test/javafx/scene/effect/EffectInputTest.java modules/javafx.graphics/src/test/java/test/javafx/scene/effect/LightingTest.java
diffstat 4 files changed, 59 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.graphics/src/test/java/test/javafx/scene/Node_bind_Test.java	Fri May 11 13:22:34 2018 +0530
+++ b/modules/javafx.graphics/src/test/java/test/javafx/scene/Node_bind_Test.java	Fri May 11 14:17:48 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,15 @@
          assertEquals(rectA.getClip(), clip2);
      }
 
+     int countIllegalArgumentException = 0;
      @Test public void testIllegalClip() {
+         Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> {
+             if (throwable instanceof IllegalArgumentException) {
+                 countIllegalArgumentException++;
+             } else {
+                 Thread.currentThread().getThreadGroup().uncaughtException(thread, throwable);
+             }
+         });
          Rectangle rectA = new Rectangle(300, 300);
          Rectangle clip1 = new Rectangle(10, 10);
          Rectangle clip2 = new Rectangle(100, 100);
@@ -64,9 +72,20 @@
          assertEquals(rectA.getClip(), clip1);
          v.set(clip2);
          assertNotSame(rectA.getClip(), clip2);
+
+         assertEquals("Cycle in effect chain detected, exception should occur once.", 1, countIllegalArgumentException);
+         Thread.currentThread().setUncaughtExceptionHandler(null);
      }
 
      @Test public void testBackToLegalClip() {
+         countIllegalArgumentException = 0;
+         Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> {
+             if (throwable instanceof IllegalArgumentException) {
+                 countIllegalArgumentException++;
+             } else {
+                 Thread.currentThread().getThreadGroup().uncaughtException(thread, throwable);
+             }
+         });
          Rectangle rectA = new Rectangle(300, 300);
          Rectangle clip1 = new Rectangle(10, 10);
          Rectangle clip2 = new Rectangle(100, 100);
@@ -76,6 +95,9 @@
          assertEquals(rectA.getClip(), clip1);
          v.set(clip2);
          assertEquals(rectA.getClip(), clip1);
+
+         assertEquals("Cycle in effect chain detected, exception should occur once.", 1, countIllegalArgumentException);
+         Thread.currentThread().setUncaughtExceptionHandler(null);
      }
 
      @Test public void testEffect() {
--- a/modules/javafx.graphics/src/test/java/test/javafx/scene/effect/BlendTest.java	Fri May 11 13:22:34 2018 +0530
+++ b/modules/javafx.graphics/src/test/java/test/javafx/scene/effect/BlendTest.java	Fri May 11 14:17:48 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -346,8 +346,16 @@
         assertEquals(f, effect.getTopInput());
     }
 
+    int countIllegalArgumentException = 0;
     @Test
     public void testCyclesForBoundInput() {
+        Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> {
+            if (throwable instanceof IllegalArgumentException) {
+                countIllegalArgumentException++;
+            } else {
+                Thread.currentThread().getThreadGroup().uncaughtException(thread, throwable);
+            }
+        });
         ObjectProperty vTop = new SimpleObjectProperty();
         effect.topInputProperty().bind(vTop);
 
@@ -403,6 +411,9 @@
         vTop.set(f);
         assertEquals(f, effect.getBottomInput());
         assertEquals(f, effect.getTopInput());
+
+        assertEquals("Cycle in effect chain detected, exception should occur 5 times.", 5, countIllegalArgumentException);
+        Thread.currentThread().setUncaughtExceptionHandler(null);
     }
 
     @Test
--- a/modules/javafx.graphics/src/test/java/test/javafx/scene/effect/EffectInputTest.java	Fri May 11 13:22:34 2018 +0530
+++ b/modules/javafx.graphics/src/test/java/test/javafx/scene/effect/EffectInputTest.java	Fri May 11 14:17:48 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -185,8 +185,16 @@
         }
     }
 
+    int countIllegalArgumentException = 0;
     @Test
     public void testCycleForBoundInput() throws Exception  {
+        Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> {
+            if (throwable instanceof IllegalArgumentException) {
+                countIllegalArgumentException++;
+            } else {
+                Thread.currentThread().getThreadGroup().uncaughtException(thread, throwable);
+            }
+        });
         final Class effect1Class = Class.forName("javafx.scene.effect." + effect1Name);
         final Class effect2Class = Class.forName("javafx.scene.effect." + effect2Name);
 
@@ -210,5 +218,8 @@
         setInput2.invoke(effect2, effect1);
         v.set(effect2);
         assertEquals(null, getInput1.invoke(effect1));
+
+        assertEquals("Cycle in effect chain detected, exception should occur 2 times.", 2, countIllegalArgumentException);
+        Thread.currentThread().setUncaughtExceptionHandler(null);
     }
 }
--- a/modules/javafx.graphics/src/test/java/test/javafx/scene/effect/LightingTest.java	Fri May 11 13:22:34 2018 +0530
+++ b/modules/javafx.graphics/src/test/java/test/javafx/scene/effect/LightingTest.java	Fri May 11 14:17:48 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -403,8 +403,16 @@
         assertEquals(null, effect.getBumpInput());
     }
 
+    int countIllegalArgumentException = 0;
     @Test
     public void testCyclesForBoundInput() {
+        Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> {
+            if (throwable instanceof IllegalArgumentException) {
+                countIllegalArgumentException++;
+            } else {
+                Thread.currentThread().getThreadGroup().uncaughtException(thread, throwable);
+            }
+        });
         ObjectProperty vContentInput = new SimpleObjectProperty();
         effect.contentInputProperty().bind(vContentInput);
         // try setting itself as content input
@@ -452,6 +460,9 @@
 
         assertEquals(null, effect.getContentInput());
         assertEquals(null, effect.getBumpInput());
+
+        assertEquals("Cycle in effect chain detected, exception should occur 5 times.", 5, countIllegalArgumentException);
+        Thread.currentThread().setUncaughtExceptionHandler(null);
     }
 
     @Test