Search in sources :

Example 46 with WebTarget

use of javax.ws.rs.client.WebTarget in project jersey by jersey.

the class ValidateOnExecutionBasicTest method testOnMethodGetterMiss.

@Test
public void testOnMethodGetterMiss() throws Exception {
    final WebTarget target = target("getter-on-method-miss");
    Response response = target.request().get();
    assertThat(response.getStatus(), equalTo(400));
    response = target.path("sanity").request().get();
    assertThat(response.getStatus(), equalTo(400));
}
Also used : Response(javax.ws.rs.core.Response) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test)

Example 47 with WebTarget

use of javax.ws.rs.client.WebTarget in project jersey by jersey.

the class ValidateOnExecutionBasicTest method testOnTypeGetterMatch.

@Test
public void testOnTypeGetterMatch() throws Exception {
    final WebTarget target = target("getter-on-type-match");
    assertThat(target.request().get().getStatus(), equalTo(400));
    assertThat(target.path("sanity").request().get().getStatus(), equalTo(400));
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test)

Example 48 with WebTarget

use of javax.ws.rs.client.WebTarget in project jersey by jersey.

the class ValidateOnExecutionBasicTest method testGetterResourceMethod.

/**
     * Validation should fail when getter (also a resource method) is invoked and not when the resource class is validated.
     */
@Test
public void testGetterResourceMethod() throws Exception {
    final WebTarget target = target("getter-resource-method");
    final Response response = target.request().get();
    assertThat(response.getStatus(), equalTo(500));
}
Also used : Response(javax.ws.rs.core.Response) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test)

Example 49 with WebTarget

use of javax.ws.rs.client.WebTarget in project jersey by jersey.

the class ValidateOnExecutionBasicTest method testOnTypeGetterNull.

@Test
public void testOnTypeGetterNull() throws Exception {
    final WebTarget target = target("on-type-getter-null");
    Response response = target.path("nogetter").request().get();
    assertThat(response.getStatus(), equalTo(400));
    response = target.path("getter").request().get();
    assertThat(response.getStatus(), equalTo(400));
}
Also used : Response(javax.ws.rs.core.Response) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test)

Example 50 with WebTarget

use of javax.ws.rs.client.WebTarget in project jersey by jersey.

the class ValidateOnExecutionBasicTest method testBeansValidateGetterInvalidReturnPhone.

@Test
public void testBeansValidateGetterInvalidReturnPhone() throws Exception {
    final WebTarget target = target("getter-on-beans").path("invalidPhone");
    final AnotherContactBean contactBean = new AnotherContactBean("jersey@example.com", null, "Jersey JAX-RS", null);
    final Response response = target.request().post(Entity.xml(contactBean));
    contactBean.setPhone("12");
    assertThat(response.getStatus(), equalTo(200));
    assertThat(response.readEntity(AnotherContactBean.class), equalTo(contactBean));
}
Also used : Response(javax.ws.rs.core.Response) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test)

Aggregations

WebTarget (javax.ws.rs.client.WebTarget)1393 Response (javax.ws.rs.core.Response)712 Test (org.junit.Test)702 Client (javax.ws.rs.client.Client)318 JerseyTest (org.glassfish.jersey.test.JerseyTest)297 Invocation (javax.ws.rs.client.Invocation)106 List (java.util.List)76 ProcessingException (javax.ws.rs.ProcessingException)71 Builder (javax.ws.rs.client.Invocation.Builder)71 ClientBuilder (javax.ws.rs.client.ClientBuilder)69 GenericType (javax.ws.rs.core.GenericType)64 ArrayList (java.util.ArrayList)61 IOException (java.io.IOException)59 Message (com.remswork.project.alice.model.support.Message)58 PulsarAdminException (org.apache.pulsar.client.admin.PulsarAdminException)58 InputStream (java.io.InputStream)52 NamespaceName (org.apache.pulsar.common.naming.NamespaceName)52 ClientConfig (org.glassfish.jersey.client.ClientConfig)52 Form (javax.ws.rs.core.Form)42 MultiPart (org.glassfish.jersey.media.multipart.MultiPart)42