package org.wso2.carbon.osgi.testcontainer; import org.ops4j.pax.exam.Configuration; import org.ops4j.pax.exam.ExamFactory; import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; import org.ops4j.pax.exam.spi.reactors.PerClass; import org.ops4j.pax.exam.testng.listener.PaxExam; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.testng.Assert; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import org.wso2.carbon.container.CarbonContainerFactory; import org.wso2.carbon.kernel.CarbonServerInfo; import java.nio.file.Paths; import javax.inject.Inject; import static org.wso2.carbon.container.options.CarbonDistributionOption.carbonDistribution; /** * To test the pax exam container using distribution zip. * * @since 5.2.0 */ @Listeners(PaxExam.class) @ExamReactorStrategy(PerClass.class) @ExamFactory(CarbonContainerFactory.class) public class DistributionZipTest { @Inject protected BundleContext bundleContext; @Inject private CarbonServerInfo carbonServerInfo; @Configuration public Option[] config() { String basedir = System.getProperty("basedir"); if (basedir == null) { basedir = Paths.get(".").toString(); } return new Option[] { carbonDistribution( Paths.get(basedir, "..", "test-distribution", "target", "wso2carbon-kernel-test-" + System.getProperty("carbon.kernel.version") + ".zip")) }; } @Test public void testCarbonCoreBundleStatus() { Bundle coreBundle = null; for (Bundle bundle : bundleContext.getBundles()) { if (bundle.getSymbolicName().equals("org.wso2.carbon.core")) { coreBundle = bundle; break; } } Assert.assertNotNull(coreBundle, "Carbon Core bundle not found"); Assert.assertEquals(coreBundle.getState(), Bundle.ACTIVE, "Carbon Core Bundle is not activated"); } }