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 javax.inject.Inject; import static org.ops4j.pax.exam.CoreOptions.maven; import static org.wso2.carbon.container.options.CarbonDistributionOption.carbonDistribution; /** * To test the pax exam container using distribution as maven dependency. * * @since 5.2.0 */ @Listeners(PaxExam.class) @ExamReactorStrategy(PerClass.class) @ExamFactory(CarbonContainerFactory.class) public class DistributionMavenTest { @Inject protected BundleContext bundleContext; @Inject private CarbonServerInfo carbonServerInfo; @Configuration public Option[] config() { return new Option[] { carbonDistribution( maven().groupId("org.wso2.carbon").artifactId("wso2carbon-kernel-test").type("zip") .versionAsInProject()) }; } @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"); } }