Pax Exam unit tests

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Pax Exam unit tests

Dominik Marciniszyn
This post has NOT been accepted by the mailing list yet.
Hi,

I'm trying to test my own custom commands which I've created. I used pax exam documentation to do needed configuration. I have:
       
        @Configuration
        public Option[] config() {
                MavenArtifactUrlReference karafUrl = maven()
                                .groupId("org.apache.karaf")
                                .artifactId("apache-karaf")
                                .version("4.1.1")
                                .type("zip");
               
                MavenUrlReference karafStandardRepository = maven()
                                .groupId("org.apache.karaf.features")
                                .artifactId("standard")
                                .classifier("features")
                                .type("xml")
                                .versionAsInProject();
               
                return new Option[] {
                                karafDistributionConfiguration()
                                .frameworkUrl(karafUrl)
                                .unpackDirectory(new File("target/exam"))
                                .useDeployFolder(false),
                                keepRuntimeFolder(),
                                features(karafStandardRepository, "scr")
                };
        }
       
And my simple test:
        @Test
        public void testKarafNativeCommand() throws IOException {
                String commandResult = executeCommand("bundle:list");
               
                assertThat(commandResult, notNullValue());
                System.out.println(commandResult);
        }
       
If I run this, everything is fine. Then I was trying to add my own bundle with commands and after features in config() method I've added:
mavenBundle().groupId("com.my.commands").artifactId("my-commands").versionAsInProject()

After run by 'mvn install' I must wait and in result I get:
<testcase name="com.my.commands.MyCommandTest" classname="org.apache.maven.surefire.junit4.JUnit4Provider" time="182.499">
    <error message="Container never came up" type="java.lang.RuntimeException">java.lang.RuntimeException: Container never came up
                at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:369)
                at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:275)
                at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:239)
                at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:160)
        </error>
</testcase>

Could you give me any advice what I'm doing wrong or how can I fix this?
I'll be glad for any help.