@@ -0,0 +1,2664 @@
+package rules;%0A%0Aimport javafx.application.Platform;%0Aimport javafx.embed.swing.JFXPanel;%0Aimport org.junit.Rule;%0Aimport org.junit.rules.TestRule;%0Aimport org.junit.runner.Description;%0Aimport org.junit.runners.model.Statement;%0A%0Aimport javax.swing.*;%0Aimport java.util.concurrent.CountDownLatch;%0A%0A/**%0A * A JUnit %7B@link Rule%7D for running tests on the JavaFX thread and performing%0A * JavaFX initialisation.  To include in your test case, add the following code:%0A * %3Cpre%3E%0A * %7B@literal @%7DRule%0A * public JavaFXThreadingRule jfxRule = new JavaFXThreadingRule();%0A * %3C/pre%3E%0A *%0A * @author Andy Till%0A * @author Eivind Vegsundv%C3%A5g(small changes to use Java8)%0A */%0Apublic class JavaFXThreadingRule implements TestRule %7B%0A%0A    /**%0A     * Flag for setting up the JavaFX, we only need to do this once for all tests.%0A     */%0A    private static boolean jfxIsSetup;%0A%0A    @Override%0A    public Statement apply(Statement statement, Description description) %7B%0A%0A        return new OnJFXThreadStatement(statement);%0A    %7D%0A%0A    private static class OnJFXThreadStatement extends Statement %7B%0A%0A        private final Statement statement;%0A        private Throwable rethrownException = null;%0A%0A        public OnJFXThreadStatement(Statement aStatement) %7B%0A            statement = aStatement;%0A        %7D%0A%0A        @Override%0A        public void evaluate() throws Throwable %7B%0A%0A            if (!jfxIsSetup) %7B%0A                setupJavaFX();%0A%0A                jfxIsSetup = true;%0A            %7D%0A%0A            final CountDownLatch countDownLatch = new CountDownLatch(1);%0A%0A            Platform.runLater(() -%3E %7B%0A                try %7B%0A                    statement.evaluate();%0A                %7D catch (Throwable e) %7B%0A                    rethrownException = e;%0A                %7D%0A                countDownLatch.countDown();%0A            %7D);%0A%0A            countDownLatch.await();%0A%0A            // if an exception was thrown by the statement during evaluation,%0A            // then re-throw it to fail the test%0A            if (null != rethrownException) %7B%0A                throw rethrownException;%0A            %7D%0A        %7D%0A%0A        protected void setupJavaFX() throws InterruptedException %7B%0A%0A            long timeMillis = System.currentTimeMillis();%0A%0A            final CountDownLatch latch = new CountDownLatch(1);%0A%0A            SwingUtilities.invokeLater(() -%3E %7B%0A                // initializes JavaFX environment%0A                new JFXPanel();%0A%0A                latch.countDown();%0A            %7D);%0A%0A            System.out.println(%22Initializing JavaFX...%22);%0A            latch.await();%0A            System.out.println(%22JavaFX was initialized in %22 + ((double) (System.currentTimeMillis() - timeMillis) / 1000.0) + %22s%22);%0A        %7D%0A%0A    %7D%0A%7D%0A

add javafxthreadingrule