modules/graphics/src/test/java/test/javafx/concurrent/ServiceTest.java

Print this page
rev 9250 : 8134762: Refactor Javafx graphics module tests for clear separation of tests
Reviewed-by:

@@ -21,18 +21,26 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
-package javafx.concurrent;
+package test.javafx.concurrent;
 
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleObjectProperty;
-import javafx.concurrent.mocks.SimpleTask;
+import test.javafx.concurrent.mocks.SimpleTask;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicBoolean;
+import javafx.concurrent.Service;
+import javafx.concurrent.Service;
+import javafx.concurrent.ServiceShim;
+import javafx.concurrent.Task;
+import javafx.concurrent.Task;
+import javafx.concurrent.TaskShim;
+import javafx.concurrent.Worker;
+import javafx.concurrent.Worker;
 import org.junit.Before;
 import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;

@@ -45,17 +53,17 @@
     private Service<String> service;
 
     @Before public void setup() {
         // I don't use the AbstractService here because I don't want to
         // take advantage of the built in executor / threading stuff
-        service = new Service<String>() {
-            @Override protected Task<String> createTask() {
+        service = new ServiceShim<String>() {
+            @Override public Task<String> createTask() {
                 return new SimpleTask();
             }
 
-            @Override void checkThread() { }
-            @Override void runLater(Runnable r) {
+            @Override public void checkThread() { }
+            @Override public void runLater(Runnable r) {
                 r.run();
             }
         };
     }
 

@@ -166,27 +174,27 @@
     // and several micro / milliseconds to get setup and execute. So 2 seconds should be more
     // than enough time.
     @Test(timeout = 2000) public void testManyServicesRunConcurrently() throws Exception {
         final CountDownLatch latch = new CountDownLatch(32);
         for (int i=0; i<32; i++) {
-            Service<Void> s = new Service<Void>() {
-                @Override void checkThread() { }
-                @Override void runLater(Runnable r) { r.run(); }
+            Service<Void> s = new ServiceShim<Void>() {
+                @Override public void checkThread() { }
+                @Override public void runLater(Runnable r) { r.run(); }
 
                 @Override protected Task<Void> createTask() {
-                    return new Task<Void>() {
+                    return new TaskShim<Void>() {
                         @Override protected Void call() throws Exception {
                             Thread.sleep(1000);
                             latch.countDown();
                             return null;
                         }
 
-                        @Override void runLater(Runnable r) {
+                        @Override public void runLater(Runnable r) {
                             r.run();
                         }
 
-                        @Override boolean isFxApplicationThread() {
+                        @Override public boolean isFxApplicationThread() {
                             return true;
                         }
                     };
 
                 }