package org.ow2.chameleon.core;

import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.BundleException;

import java.io.File;

import static org.fest.assertions.Assertions.assertThat;

/**
 * Check the behavior of the Chameleon class.
 */
public class ChameleonTest {

    public static final File CHAMELEON = new File("target/test/chameleon");
    public static final File APPLICATION = new File(CHAMELEON, "application");
    private Chameleon chameleon;

    @Before
    public void init() throws Exception {
        FileUtils.deleteQuietly(APPLICATION);
        APPLICATION.mkdirs();
        chameleon = new Chameleon(CHAMELEON, false, null);
    }

    @After
    public void stop() throws BundleException, InterruptedException {
        chameleon.stop();
        chameleon = null;
    }

    @Test
    public void testStart() throws BundleException {
        assertThat(chameleon).isNotNull();
        assertThat(chameleon.context()).isNull();
        chameleon.start();
        assertThat(chameleon.context()).isNotNull();
        assertThat(chameleon.framework()).isNotNull();
    }

}

@@ -1169,10 +1169,602 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testInitializationFromConfiguration() throws Exception %7B%0A        File baseDirectory = new File(%22target/test-classes/configurations/regular%22);%0A        assertThat(baseDirectory).isDirectory();%0A        ChameleonConfiguration configuration = new ChameleonConfiguration(baseDirectory);%0A        chameleon = new Chameleon(configuration);%0A        assertThat(chameleon).isNotNull();%0A        assertThat(chameleon.context()).isNull();%0A        chameleon.start();%0A        assertThat(chameleon.context()).isNotNull();%0A        assertThat(chameleon.framework()).isNotNull();%0A    %7D%0A%0A
 %7D%0A

Check the initialization form a configuration