package de.bmoth.app;

import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.stage.Stage;
import org.junit.Test;
import org.testfx.util.WaitForAsyncUtils;

import java.io.IOException;
import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;

import static org.junit.Assert.assertEquals;

public class AppTest {
    private final Logger logger = Logger.getLogger(getClass().getName());
    private Stage stage;

    @Test
    public void testApp() throws InterruptedException {

        new JFXPanel(); // Initializes the JavaFx Platform
        Future<Void> f = WaitForAsyncUtils.asyncFx(() -> {
            try {
                stage = new Stage();
                new App().start(stage);
            } catch (IOException e) {
                logger.log(Level.SEVERE, "exception during test", e);
            }

        });
        WaitForAsyncUtils.waitFor(f);
        assertEquals(true, stage.isShowing());
        Platform.runLater(() -> stage.close());
    }


}

@@ -378,16 +378,39 @@
 AppTest 
+extends HeadlessUITest 
 %7B%0A    pr
@@ -503,16 +503,120 @@
 stage;%0A%0A
+%0A    @Override%0A    public void start(Stage stage) throws Exception %7B%0A        this.stage = stage;%0A    %7D%0A%0A
     @Tes
@@ -1161,12 +1161,10 @@
 ;%0A    %7D%0A
-%0A%0A
 %7D%0A

make AppTest run using the headless ui tests