Monthly Archives: September 2013

JAXRS 1 and unmarshalling of response.getEntity()

JAXRS 2 provides a simple way to unmarshal using JAXRS providers a Response entity (got from response#getEntity() method): readEntity(…).

However if you still have to stick to JAXRS 1 you’ll often get an InputStream as entity…not that fun.

The worse is when you use an interface with the JAXRS metadatas to generate a client. To avoid to need to play with stream there is a simple solution.

Continue reading

TomEE Maven Plugin and integration tests (without arquillian)

Arquillian is great but some apps would prefer to use maven failsafe plugin to do their integration tests. If all your tests are client tests you can simply start the container and deploy the app before the tests are executed (pre-integration-test phase) and undeploy/stop the container after the test (post-integration-test phase). If it is not you can still write a servlet to execute the tests on the server side…wait, you are redoing Arquillian so maybe something is wrong in this case ;).

It is generally complicated/long to configure because you need to find how to start your container then to deploy an application on it etc…boring.

The solution is quite easy if you want to test against TomEE: the tomee maven plugin of course!

Continue reading

Maven and ShrinkWrap/Arquillian made easy?

If you read this post you surely know ShrinkWrap and Maven. The main issue is the boilerplate code needed to create a WebArchive in a Maven project. This is really easier since ShrinkWrap resolver has a correct implementation of the Maven resolver but it still looks useless. All projects end with a ShrinkWrapUtil utility class to do it.

On another side TomEE provides an utility module to ease ShrinkWrap usage called ziplock. It allows you, for instance, to find a File from a class (see JarLocation) or provides you some shortcuts to create Archives (see WebModule). These utilities were created because of TomEE tests need.

However since few days it includes something more general and interesting for any maven user: the Mvn class.

Continue reading