package be.iminds.ilabt.jfed.util;

import javafx.embed.swing.JFXPanel;
import org.testng.SkipException;
import org.testng.annotations.BeforeSuite;

/**
 * User: twalcari
 * Date: 4/8/2014
 * Time: 12:31
 */
public abstract class JavaFXTest {

    private static boolean javaFXInitialized = false;

    @BeforeSuite()
    public void setupSuite() throws InterruptedException {
        if (javaFXInitialized)
            return;

        try {
            long timeMillis = System.currentTimeMillis();
            new JFXPanel();
            System.out.println("JavaFX was initialised in " + (System.currentTimeMillis() - timeMillis) + "ms");

            javaFXInitialized = true;
        } catch (RuntimeException ex) {
            javaFXInitialized = true;
            throw new SkipException("Could not initialize JavaFX.. Skipping all dependent tests.");
        }
    }
}

