Package org.jrebirth.af.core.command.basic

Source Code of org.jrebirth.af.core.command.basic.BasicCommandTest

package org.jrebirth.af.core.command.basic;

import javafx.application.Application;

import org.jrebirth.af.core.application.TestApplication;
import org.jrebirth.af.core.command.Command;
import org.jrebirth.af.core.concurrent.JRebirthThread;
import org.jrebirth.af.core.facade.GlobalFacadeBase;
import org.jrebirth.af.core.wave.DefaultWaveListener;
import org.jrebirth.af.core.wave.Wave;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;

/**
* The class <strong>StageTest</strong>.
*
* @author Sébastien Bordes
*/
public class BasicCommandTest {

    private static GlobalFacadeBase globalFacade;

    // private CommandFacade commandFacade;.

    private boolean wait = false;

    /**
     * TODO To complete.
     *
     * @throws java.lang.Exception
     */
    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        // globalFacade = new GlobalFacadeBase(new TestApplication());
        // JRebirthThread.getThread().launch(globalFacade.getApplication());
        new Thread(new Runnable() {

            @Override
            public void run() {
                Application.launch(TestApplication.class);

            }
        }).start();
        Thread.sleep(1000);
        globalFacade = (GlobalFacadeBase) JRebirthThread.getThread().getFacade();
    }

    /**
     * TODO To complete.
     *
     * @throws java.lang.Exception
     */
    @Before
    public void setUp() throws Exception {

        // new TestApplication().start(new Stage());
        // this.commandFacade = globalFacade.getCommandFacade();
    }

    /**
     * TODO To complete.
     *
     * @throws java.lang.Exception
     */
    @After
    public void tearDown() throws Exception {
        // this.commandFacade = null;
    }

    /**
     * TODO To complete.
     *
     * @throws java.lang.Exception
     */
    @AfterClass
    public static void tearDownAfterClass() throws Exception {
        globalFacade.stop();
        globalFacade = null;
    }

    public void runCommand(Class<? extends Command> commandClass) {

        wait = true;

        Wave wave = globalFacade.getCommandFacade().retrieve(commandClass).run();

        wave.addWaveListener(new DefaultWaveListener() {

            /**
             * {@inheritDoc}
             */
            @Override
            public void waveConsumed(Wave wave) {
                wait = false;
            }

        });

        while (wait) {
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
TOP

Related Classes of org.jrebirth.af.core.command.basic.BasicCommandTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.