Skip to content

Instantly share code, notes, and snippets.

@wombat
Last active December 21, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wombat/6317015 to your computer and use it in GitHub Desktop.
Save wombat/6317015 to your computer and use it in GitHub Desktop.
JAX-RS 2.0 Client + Arquillian = Dream Team
@RunWith(Arquillian.class)
public class FoodResourceTest {
@Deployment
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class, "test.war")
.addPackages(true, "eu.jugcologne.foodeys")
.addClass(RestApplication.class)
.addAsResource("test-persistence.xml", "META-INF/persistence.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
@Test
@RunAsClient
public void testAutocompleteWithoutQuery(@ArquillianResource URL base) throws Exception {
Client client = ClientBuilder.newClient();
WebTarget target = client.target(base.toURI() + RestApplication.REST_PATH + "/food/autocomplete/");
Response response = target.request().get();
Assert.assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<artifactId>foodeys-rest-impl</artifactId>
...
<dependencies>
...
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.0.2.Final</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment