adam bien's blog

JSON-P and JAX-RS 2 Client Maven Dependencies For RESTEasy 📎

RESTEasy is a JAX-RS 2.0 implementation and comes with JAX-RS 2.0 client implementation / provider.

To use RESTEasy as a JAX-RS 2.0 client implementation (e.g. for system testing) you will have to declare the following dependencies in pom.xml:


<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>3.0.10.Final</version>
</dependency>
<dependency>
	<groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-json-p-provider</artifactId>
    <version>3.0.10.Final</version>
</dependency>

The choice of the JAX-RS implementation does not have any effect at the code--it remains implementation independent:

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

@Test
public void oracle() {
	Client client = ClientBuilder.newClient();
	String content = client.target("http://www.oracle.com/technetwork/java/index.html").
			request().
			get(String.class);
	assertNotNull(content);
	assertTrue(content.contains("java"));
}

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting