Created
August 21, 2012 16:53
-
-
Save leadVisionary/3417239 to your computer and use it in GitHub Desktop.
Karaf Testing with Pax Exam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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