changeset 8010:639e8a288cc2

RT-38520: Use Lambda in Snapshot1Test.java
author kcr
date Tue, 16 Sep 2014 10:30:57 -0700
parents a61ce4ef33ae
children a1563dbccd0e
files tests/system/src/test/java/javafx/scene/Snapshot1Test.java
diffstat 1 files changed, 54 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/tests/system/src/test/java/javafx/scene/Snapshot1Test.java	Tue Sep 16 12:06:03 2014 -0400
+++ b/tests/system/src/test/java/javafx/scene/Snapshot1Test.java	Tue Sep 16 10:30:57 2014 -0700
@@ -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(() -> {
+            tmpScene = new Scene(new Group(), 200, 100);
 
-                Callback<SnapshotResult, Void> cb = new Callback() {
-                    @Override public Object call(Object param) {
-                        assertNotNull(param);
+            // NOTE: cannot use a lambda expression for the following callback
+            Callback<SnapshotResult, Void> 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,19 @@
     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(() -> {
+            tmpScene = new Scene(new Group(), 200, 100);
 
-                Callback cb = new Callback<String, Integer>() {
-                    @Override public Integer call(String param) {
-                        // Should not get here
-                        latch.countDown();
-                        throw new AssertionFailedError("Should never get here");
-                    }
-                };
+            Callback cb = (Callback<String, Integer>) 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 +331,25 @@
     public void testBadNodeCallback1() {
         final CountDownLatch latch = new CountDownLatch(1);
 
-        Util.runAndWait(new Runnable() {
-            public void run() {
-                tmpNode = new Rectangle(10, 10);
+        Util.runAndWait(() -> {
+            tmpNode = new Rectangle(10, 10);
 
-                Callback<SnapshotResult, Void> cb = new Callback() {
-                    @Override public Object call(Object param) {
-                        assertNotNull(param);
+            // NOTE: cannot use a lambda expression for the following callback
+            Callback<SnapshotResult, Void> 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 +371,19 @@
     public void testBadNodeCallback2() {
         final CountDownLatch latch = new CountDownLatch(1);
 
-        Util.runAndWait(new Runnable() {
-            public void run() {
-                tmpNode = new Rectangle(10, 10);
+        Util.runAndWait(() -> {
+            tmpNode = new Rectangle(10, 10);
 
-                Callback cb = new Callback<String, Integer>() {
-                    @Override public Integer call(String param) {
-                        // Should not get here
-                        latch.countDown();
-                        throw new AssertionFailedError("Should never get here");
-                    }
-                };
+            Callback cb = (Callback<String, Integer>) 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");
-            }
+            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 {