All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.umlg.restlet.test.BaseRestletTest Maven / Gradle / Ivy

package org.umlg.restlet.test;

import org.eclipse.uml2.uml.Model;
import org.junit.After;
import org.junit.Before;
import org.umlg.framework.ModelLoadedEvent;
import org.umlg.framework.ModelLoader;
import org.restlet.Component;
import org.umlg.runtime.adaptor.UmlgGraphManager;

/**
 * Date: 2013/01/04
 * Time: 4:25 PM
 */
public abstract class BaseRestletTest implements ModelLoadedEvent {

    protected Component component;
    private boolean loaded = false;

    @Before
    public void before() throws Exception {
//        UmlgGraphManager.INSTANCE.deleteGraph();
        this.component = instantiateComponent();
        this.component.start();
        if (!ModelLoader.INSTANCE.isLoaded()) {
            ModelLoader.INSTANCE.subscribeModelLoaderEvent(this);
            while (!this.loaded) {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }

    @After
    public void after() throws Exception {
        this.component.stop();
    }

    protected abstract Component instantiateComponent();

    @Override
    public void loaded(Model model) {
        this.loaded = true;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy