# HG changeset patch # User kcr # Date 1402427071 25200 # Node ID 0b9b61215ac411a6737a184b47c9e17677503df1 # Parent 7dbf508c233466dd578649b2ac8acba13be083dd [mq]: Snapshot1Test-lambda.patch diff --git a/tests/system/src/test/java/javafx/scene/Snapshot1Test.java b/tests/system/src/test/java/javafx/scene/Snapshot1Test.java --- a/tests/system/src/test/java/javafx/scene/Snapshot1Test.java +++ b/tests/system/src/test/java/javafx/scene/Snapshot1Test.java @@ -205,26 +205,25 @@ public void testBadSceneCallback1() { final CountDownLatch latch = new CountDownLatch(1); - Util.runAndWait(new Runnable() { - public void run() { - tmpScene = new Scene(new Group(), 200, 100); + Util.runAndWait((Runnable) () -> { + tmpScene = new Scene(new Group(), 200, 100); - Callback cb = new Callback() { - @Override public Object call(Object param) { - assertNotNull(param); + // NOTE: cannot use a lambda expression for the following... + Callback cb = new Callback() { + @Override public Object call(Object param) { + assertNotNull(param); - latch.countDown(); - // The following will cause a ClassCastException warning - // message to be printed. - return ""; - } - }; + latch.countDown(); + // The following will cause a ClassCastException warning + // message to be printed. + return ""; + } + }; - tmpScene.snapshot(cb, null); - Util.sleep(SLEEP_TIME); - assertEquals(1, latch.getCount()); - System.err.println("testBadSceneCallback1: a ClassCastException warning message is expected here"); - } + tmpScene.snapshot(cb, null); + Util.sleep(SLEEP_TIME); + assertEquals(1, latch.getCount()); + System.err.println("testBadSceneCallback1: a ClassCastException warning message is expected here"); }); try { @@ -246,23 +245,18 @@ public void testBadSceneCallback2() { final CountDownLatch latch = new CountDownLatch(1); - Util.runAndWait(new Runnable() { - public void run() { - tmpScene = new Scene(new Group(), 200, 100); + Util.runAndWait((Runnable) () -> { + tmpScene = new Scene(new Group(), 200, 100); + + Callback cb = (Callback) (String param) -> { + latch.countDown(); + throw new AssertionFailedError("Should never get here"); + }; - Callback cb = new Callback() { - @Override public Integer call(String param) { - // Should not get here - latch.countDown(); - throw new AssertionFailedError("Should never get here"); - } - }; - - tmpScene.snapshot(cb, null); - Util.sleep(SLEEP_TIME); - assertEquals(1, latch.getCount()); - System.err.println("testBadSceneCallback2: a ClassCastException warning message is expected here"); - } + tmpScene.snapshot(cb, null); + Util.sleep(SLEEP_TIME); + assertEquals(1, latch.getCount()); + System.err.println("testBadSceneCallback2: a ClassCastException warning message is expected here"); }); try { @@ -336,26 +330,25 @@ public void testBadNodeCallback1() { final CountDownLatch latch = new CountDownLatch(1); - Util.runAndWait(new Runnable() { - public void run() { - tmpNode = new Rectangle(10, 10); + Util.runAndWait((Runnable) () -> { + tmpNode = new Rectangle(10, 10); - Callback cb = new Callback() { - @Override public Object call(Object param) { - assertNotNull(param); + // NOTE: cannot use a lambda expression for the following... + Callback cb = new Callback() { + @Override public Object call(Object param) { + assertNotNull(param); - latch.countDown(); - // The following will cause a ClassCastException warning - // message to be printed. - return ""; - } - }; + latch.countDown(); + // The following will cause a ClassCastException warning + // message to be printed. + return ""; + } + }; - tmpNode.snapshot(cb, null, null); - Util.sleep(SLEEP_TIME); - assertEquals(1, latch.getCount()); - System.err.println("testBadNodeCallback1: a ClassCastException warning message is expected here"); - } + tmpNode.snapshot(cb, null, null); + Util.sleep(SLEEP_TIME); + assertEquals(1, latch.getCount()); + System.err.println("testBadNodeCallback1: a ClassCastException warning message is expected here"); }); try { @@ -377,23 +370,18 @@ public void testBadNodeCallback2() { final CountDownLatch latch = new CountDownLatch(1); - Util.runAndWait(new Runnable() { - public void run() { - tmpNode = new Rectangle(10, 10); - - Callback cb = new Callback() { - @Override public Integer call(String param) { - // Should not get here - latch.countDown(); - throw new AssertionFailedError("Should never get here"); - } - }; - - tmpNode.snapshot(cb, null, null); - Util.sleep(SLEEP_TIME); - assertEquals(1, latch.getCount()); - System.err.println("testBadNodeCallback2: a ClassCastException warning message is expected here"); - } + Util.runAndWait((Runnable) () -> { + tmpNode = new Rectangle(10, 10); + + Callback cb = (Callback) (String param) -> { + latch.countDown(); + throw new AssertionFailedError("Should never get here"); + }; + + tmpNode.snapshot(cb, null, null); + Util.sleep(SLEEP_TIME); + assertEquals(1, latch.getCount()); + System.err.println("testBadNodeCallback2: a ClassCastException warning message is expected here"); }); try {