lundi 7 octobre 2019

Testing real EAR with arquillian issues

I have this EAR file that i want to test with arquillian. The EAR file have two WAR inside (and some jars ofc).

During the test i'm falling into Dependency injection issues caused by a Stream exception...

java.io.StreamCorruptedException: invalid stream header: 3C3F786D
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:857)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:349)
    at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.execute(ServletMethodExecutor.java:194)
    at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor$1.run(ServletMethodExecutor.java:250)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)

I'm using a flyway 14.0.1 for the tests, and the ear seems to deploy well.

The code look like this:

@RunWith(Arquillian.class)
public class ArquillianTest {

    @PersistenceContext(unitName = "SerphyDose-PU")
    EntityManager em;

    @Deployment
    public static EnterpriseArchive createDeployment() {
        final String warToTest = "war-name.war";
        File earFile = new File("my file path");

        EnterpriseArchive ear = ShrinkWrap.createFromZipFile(EnterpriseArchive.class, earFile);
        WebArchive war = ear.getAsType(WebArchive.class, warToTest);
        war.addClass(ArquillianTest.class);

        ear.addAsModule(Testable.archiveToTest(war)); // I had to do this step or arquillian will not know which war he have to test
        return ear;

    }


    @Test
    public void init() throws Exception {
        Assert.assertTrue(true);
    }

}

Aucun commentaire:

Enregistrer un commentaire