Skip to content

Instantly share code, notes, and snippets.

@dansiviter
Last active May 25, 2017 15:53
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 dansiviter/dbe674942ff423d9281c7671f5c34880 to your computer and use it in GitHub Desktop.
Save dansiviter/dbe674942ff423d9281c7671f5c34880 to your computer and use it in GitHub Desktop.
JAX-RS Initialising without an Application instance present
package acme;
import static org.jboss.shrinkwrap.api.ShrinkWrap.create;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.net.URI;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.swarm.undertow.WARArchive;
@RunWith(Arquillian.class)
public class JaxRsTest {
@ArquillianResource
public URI deploymentUri;
@Test
@RunAsClient
public void test() throws IOException {
final Client client = ClientBuilder.newClient();
final Response response = client.target(this.deploymentUri).request().get();
assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus());
}
@Deployment
public static WARArchive createWebArchive() {
return create(WARArchive.class)
.addClasses(MyResource.class);
}
@Path("/")
public static class MyResource {
@GET
public String helloWorld() {
return "Hello world!";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment