mercredi 30 mai 2018

Arquillian test againt full war not working, NullPointerException

I am running integration test on a Java ee application.

the code works perfectly this way

Dependencies

repositories {
    mavenLocal()
    maven { url "http://repo.maven.apache.org/maven2" }
    jcenter()
}
dependencies {
    providedCompile "javax:javaee-api:7.0"

    testCompile 'org.jboss.arquillian:arquillian-bom:1.4.0.Final'
    testCompile 'org.jboss.arquillian.junit:arquillian-junit-container:1.4.0.Final'
    testCompile group: 'org.arquillian.container', name: 'arquillian-container-chameleon', version: '1.0.0.CR2'
    compile group: 'org.jboss.shrinkwrap.resolver', name: 'shrinkwrap-resolver-gradle-depchain', version: '2.2.0'

    testCompile 'junit:junit:4.12'

}

and the test

@RunWith(Arquillian.class)
public class GreeterTest {

    @Deployment
    public static JavaArchive createDeployment() {
        return ShrinkWrap.create(JavaArchive.class)
                .addClass(Greeter.class)
                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    }

    @Inject
    Greeter greeter;

    @Test
    public void should_create_greeting() {
        assertEquals("Hello, toumi!", greeter.createGreeting("toumi"));
    }

the needed setup

I do not want to import my classes manually like done in this example, but I want to test against a full ready war.

So I change the deployment block this way

@Deployment
public static WebArchive createTestArchive() {
    return ShrinkWrap.create(EmbeddedGradleImporter.class)
            .forThisProjectDirectory()
            .importBuildOutput(<Full path to my war>)
            .as(WebArchive.class);
}

Questions

  1. how to test arquillian against full war
  2. I am also unable to run this test from github examples

Is there something wrong with the plugin, or missed step in the setup.

Aucun commentaire:

Enregistrer un commentaire