Arquillian: Build WebArchive from Existing War Using ShrinkWrap

I am trying to deploy an existing war with another maven project in Arkillian. I resolved the war and copied it into the target directory of my Arquillian project.

I am trying to create it below:

@Deployment public static WebArchive createDeployment() { return (WebArchive) ShrinkWrap.create(ZipImporter.class, "MyWarToTest.war").importFrom( new File("target/MyWarToTest.war")); } 

However, I get a class exception.

Raised: java.lang.ClassCastException: org.jboss.shrinkwrap.impl.base.importer.zip.ZipImporterImpl cannot be thrown at org.jboss.shrinkwrap.api.Archive

I guess I should try to create a war differently?

+6
source share
2 answers

I have found the answer. I needed to add .as (WebArchive.class) to the end of the call.
It should look like this:

 @Deployment public static WebArchive createDeployment() { return ShrinkWrap.create(ZipImporter.class, "payloadPlan.war").importFrom(new File("target/payloadPlan.war")) .as(WebArchive.class); } 

I found the answer here: http://zezutom.blogspot.com/2012/08/going-mobile-with-arquillian.html

+11
source

Adding my two cents. Even faster (and with the same result) is the following method:

 @Deployment public static WebArchive createDeployment() { return ShrinkWrap.createFromZipFile(WebArchive.class, new File("target/payloadPlan.war")); } 
+13
source

Source: https://habr.com/ru/post/950085/


All Articles