How create an Arquillian test that uses XStream?
How should the deployment method look like?
First thing I tried was adding my classes and the XStream package.
ShrinkWrap.create(WebArchive.class, "myTest.war")
.addClass(...) // my classes
.addClass(...) // my classes
.addPackages(true, "com.thoughtworks.xstream")
.addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
Got error complaining about missing XStream dependencies, so I added:
.addPackages(true, "org.dom4j")
.addPackages(true, "org.xmlpull")
After that, I'm still getting the following error:
com.thoughtworks.xstream.io.StreamException: Cannot create XmlPullParser at com.thoughtworks.xstream.io.xml.AbstractXppDriver.createReader(AbstractXppDriver.java:56) at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1040) at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1031) (...)
What else can I do?
Answering your question in the comment above: ShrinkWrap resolvers can be the way to go.
WebArchive archieve = ShrinkWrap
.create(WebArchive.class, "myTest.war")
.addPackages(true, "your.company.project")
// other resources ...
File[] xstreamLib = Maven.resolver().resolve("com.thoughtworks.xstream:xstream:1.4.7")
.withTransitivity().asFile();
archieve.addAsLibraries(xstreamLib);
Other sample usage here.
Why is this so good? Because of two reasons:
dom4j
and xmlpull
) - but there can be a lot more dependencies.ShrinkWrap resolvers are really useful piece of software.