use of javax.ws.rs.core.Response in project jersey by jersey.
the class HelloWorldTest method testFooBarOptions.
@Test
public void testFooBarOptions() {
Response response = target().path(ROOT_PATH).request().header("Accept", "foo/bar").options();
assertEquals(200, response.getStatus());
final String allowHeader = response.getHeaderString("Allow");
_checkAllowContent(allowHeader);
assertEquals("foo/bar", response.getMediaType().toString());
assertEquals(0, response.getLength());
}
use of javax.ws.rs.core.Response in project jersey by jersey.
the class HelloWorldTest method testTextPlainOptions.
@Test
public void testTextPlainOptions() {
Response response = target().path(ROOT_PATH).request().header("Accept", MediaType.TEXT_PLAIN).options();
assertEquals(200, response.getStatus());
final String allowHeader = response.getHeaderString("Allow");
_checkAllowContent(allowHeader);
assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType());
final String responseBody = response.readEntity(String.class);
_checkAllowContent(responseBody);
}
use of javax.ws.rs.core.Response in project jersey by jersey.
the class HelloWorldTest method testMissingResourceNotFound.
@Test
public void testMissingResourceNotFound() {
Response response;
response = target().path(ROOT_PATH + "arbitrary").request().get();
assertEquals(404, response.getStatus());
response.close();
response = target().path(ROOT_PATH).path("arbitrary").request().get();
assertEquals(404, response.getStatus());
response.close();
}
use of javax.ws.rs.core.Response in project jersey by jersey.
the class AuthTest method testAuthDelete.
@Test
public void testAuthDelete() {
CredentialsProvider credentialsProvider = new org.apache.http.impl.client.BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("name", "password"));
ClientConfig cc = new ClientConfig();
cc.property(ApacheClientProperties.CREDENTIALS_PROVIDER, credentialsProvider);
cc.connectorProvider(new ApacheConnectorProvider());
Client client = ClientBuilder.newClient(cc);
WebTarget r = client.target(getBaseUri()).path("test");
Response response = r.request().delete();
assertEquals(response.getStatus(), 204);
}
use of javax.ws.rs.core.Response in project jersey by jersey.
the class FollowRedirectsTest method testDoFollow.
@Test
public void testDoFollow() {
Response r = target("test/redirect").register(RedirectTestFilter.class).request().get();
assertEquals(200, r.getStatus());
assertEquals("GET", r.readEntity(String.class));
assertEquals(UriBuilder.fromUri(getBaseUri()).path(RedirectResource.class).build().toString(), r.getHeaderString(RedirectTestFilter.RESOLVED_URI_HEADER));
}
Aggregations