Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Karaf Testing with Pax Exam
@RunWith(JUnit4TestRunner.class)
@ExamReactorStrategy(AllConfinedStagedReactorFactory.class)
public class KarafTest {
@Inject
CommandProcessor commandProcessor;
@ProbeBuilder
public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
probe.setHeader(Constants.DYNAMICIMPORT_PACKAGE,
"*,org.apache.felix.service.*;status=provisional");
return probe;
}
@Configuration
public static Option[] karafConfig(){
return options(
karafDistributionConfiguration().frameworkUrl(maven()
.groupId("org.apache.karaf")
.artifactId("apache-karaf")
.type("zip")
.versionAsInProject())
.karafVersion("2.2.7")
.name("Apache Karaf"),
keepRuntimeFolder(),
felix()
);
}
@Test
public void testStartKarafAndListBundles() throws Exception {
ByteArrayOutputStream result = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(result);
CommandSession cs = commandProcessor.createSession(System.in, ps, System.err);
cs.execute("osgi:list");
cs.close();
ps.flush();
String output = result.toString();
System.out.println(output);
Assert.assertTrue(output.contains("PAXEXAM"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.