Search in sources :

Example 6 with Form

use of jakarta.ws.rs.core.Form in project resteasy by resteasy.

the class FormUrlEncodedCharsetTest method testFormUTF8.

/**
 * @tpTestDetails Test for UTF8 charset.
 * @tpSince RESTEasy 3.0.17
 */
@Test
public void testFormUTF8() throws UnsupportedEncodingException {
    Form form = new Form();
    form.param("name", alephBetGimel);
    Entity<Form> entity = Entity.entity(form, testMediaType8);
    Response response = target.request().post(entity);
    String result = response.readEntity(String.class);
    logger.info("result: " + result);
    Assert.assertEquals("EAP is unable to encode UTF8 charset", result, alephBetGimel);
}
Also used : Response(jakarta.ws.rs.core.Response) Form(jakarta.ws.rs.core.Form) Test(org.junit.Test)

Example 7 with Form

use of jakarta.ws.rs.core.Form in project resteasy by resteasy.

the class FormUrlEncodedCharsetTest method testFormDefault.

/**
 * @tpTestDetails Test for default charset.
 * @tpSince RESTEasy 3.0.17
 */
@Test
public void testFormDefault() throws UnsupportedEncodingException {
    Form form = new Form();
    form.param("name", alephBetGimel);
    Entity<Form> entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE);
    Response response = target.request().post(entity);
    String result = response.readEntity(String.class);
    logger.info("result: " + result);
    Assert.assertEquals("EAP is unable to encode default charset", result, alephBetGimel);
}
Also used : Response(jakarta.ws.rs.core.Response) Form(jakarta.ws.rs.core.Form) Test(org.junit.Test)

Example 8 with Form

use of jakarta.ws.rs.core.Form in project resteasy by resteasy.

the class FormUrlEncodedTest method testQueryParamIsNull.

/**
 * @tpTestDetails Send form with a missing query parameter.
 * @tpSince RESTEasy 3.0.20
 */
@Test
public void testQueryParamIsNull() {
    Builder builder = client.target(generateURL("/simple")).request();
    try {
        Response response = builder.post(Entity.form(new Form("hello", "world")));
        Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
        Assert.assertEquals("hello=world", response.readEntity(String.class));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Response(jakarta.ws.rs.core.Response) Form(jakarta.ws.rs.core.Form) Builder(jakarta.ws.rs.client.Invocation.Builder) ClientBuilder(jakarta.ws.rs.client.ClientBuilder) Test(org.junit.Test)

Example 9 with Form

use of jakarta.ws.rs.core.Form in project resteasy by resteasy.

the class ResteasyUseContainerFormParamsTest method testMap.

@Test
public void testMap() throws Exception {
    Builder builder = client.target(generateURL("/map")).request();
    Response response = builder.post(Entity.form(new Form("hello", "world").param("yo", "mama")));
    Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
}
Also used : Response(jakarta.ws.rs.core.Response) Form(jakarta.ws.rs.core.Form) Builder(jakarta.ws.rs.client.Invocation.Builder) ClientBuilder(jakarta.ws.rs.client.ClientBuilder) Test(org.junit.Test)

Example 10 with Form

use of jakarta.ws.rs.core.Form in project resteasy by resteasy.

the class ResteasyUseContainerFormParamsTest method testForm.

@Test
public void testForm() throws Exception {
    Builder builder = client.target(generateURL("/form")).request();
    Response response = builder.post(Entity.form(new Form("hello", "world").param("yo", "mama")));
    Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
}
Also used : Response(jakarta.ws.rs.core.Response) Form(jakarta.ws.rs.core.Form) Builder(jakarta.ws.rs.client.Invocation.Builder) ClientBuilder(jakarta.ws.rs.client.ClientBuilder) Test(org.junit.Test)

Aggregations

Form (jakarta.ws.rs.core.Form)80 Response (jakarta.ws.rs.core.Response)60 Test (org.junit.Test)33 Test (org.junit.jupiter.api.Test)24 MinijaxTest (org.minijax.rs.test.MinijaxTest)14 Builder (jakarta.ws.rs.client.Invocation.Builder)11 WebTarget (jakarta.ws.rs.client.WebTarget)10 MinijaxRequestContext (org.minijax.rs.MinijaxRequestContext)8 Cookie (jakarta.ws.rs.core.Cookie)7 MultivaluedHashMap (jakarta.ws.rs.core.MultivaluedHashMap)7 Client (jakarta.ws.rs.client.Client)6 ClientBuilder (jakarta.ws.rs.client.ClientBuilder)6 List (java.util.List)5 JsonBindingTest (org.jboss.resteasy.test.providers.jsonb.basic.JsonBindingTest)5 IOException (java.io.IOException)4 ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)4 PetClinicTest (com.example.PetClinicTest)3 Invocation (jakarta.ws.rs.client.Invocation)3 Owner (com.example.model.Owner)2 Holder (io.jans.as.model.common.Holder)2