Package javax.ws.rs.core

Examples of javax.ws.rs.core.Form.asMap()


    @Test
    public void testPut() {
        Form form = new Form();
        form.param("text", "this is a test");
        String result = target("form-consumption/form-consumption").request().put(Entity.form(form), String.class);
        assertEquals(form.asMap().getFirst("text"), result);
    }

    @Test
    public void testPost() {
        Form form = new Form();
View Full Code Here


    @Test
    public void testPost() {
        Form form = new Form();
        form.param("text", "this is a test");
        String result = target("form-consumption/form-consumption").request().post(Entity.form(form), String.class);
        assertEquals(form.asMap().getFirst("text"), result);
    }

    @Test
    public void testPostWithEncoding() {
        Form form = new Form();
View Full Code Here

    @Test
    public void testPostWithEncoding() {
        Form form = new Form();
        form.param("text", "this is an encoding test +-*/=");
        String result = target("form-consumption/form-consumption/encoding").request().post(Entity.form(form), String.class);
        assertEquals(form.asMap().getFirst("text"), result);
    }
}
View Full Code Here

        // process method params (build maps of (Path|Form|Cookie|Matrix|Header..)Params
        // and extract entity type
        final MultivaluedHashMap<String, Object> headers = new MultivaluedHashMap<String, Object>(this.headers);
        final LinkedList<Cookie> cookies = new LinkedList<Cookie>(this.cookies);
        final Form form = new Form();
        form.asMap().putAll(this.form.asMap());
        final Annotation[][] paramAnns = method.getParameterAnnotations();
        Object entity = null;
        Type entityType = null;
        for (int i = 0; i < paramAnns.length; i++) {
            final Map<Class, Annotation> anns = new HashMap<Class, Annotation>();
View Full Code Here

            builder = builder.cookie(c);
        }

        final Object result;

        if (entity == null && !form.asMap().isEmpty()) {
            entity = form;
            contentType = MediaType.APPLICATION_FORM_URLENCODED;
        } else {
            if (contentType == null) {
                contentType = MediaType.APPLICATION_OCTET_STREAM;
View Full Code Here

            contentType = MediaType.APPLICATION_FORM_URLENCODED;
        } else {
            if (contentType == null) {
                contentType = MediaType.APPLICATION_OCTET_STREAM;
            }
            if (!form.asMap().isEmpty()) {
                if (entity instanceof Form) {
                    ((Form) entity).asMap().putAll(form.asMap());
                } else {
                    // TODO: should at least log some warning here
                }
View Full Code Here

            if (contentType == null) {
                contentType = MediaType.APPLICATION_OCTET_STREAM;
            }
            if (!form.asMap().isEmpty()) {
                if (entity instanceof Form) {
                    ((Form) entity).asMap().putAll(form.asMap());
                } else {
                    // TODO: should at least log some warning here
                }
            }
        }
View Full Code Here

        final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig);

        final Form form = new Form();
        final String formValue = "formValue";
        form.asMap().add("formParam", formValue);

        final Client client = ClientBuilder.newClient();
        final String entity = client.
                target(baseUri).
                path("/bean-validation").
View Full Code Here

        return paramBean;
    }

    private Response testInputParams(final String path, final ParamBean paramBean) throws Exception {
        final Form form = new Form();
        form.asMap().put("form", Arrays.asList(paramBean.getFormParam()));

        WebTarget target = target("beanvalidation").path(path);

        if (paramBean.getPathParam() != null) {
            target = target.path(paramBean.getPathParam());
View Full Code Here

        testSubResource(path, false);
    }

    private void testSubResource(final String path, final boolean omitEmail) throws Exception {
        final Form form = new Form();
        form.asMap().put("firstName", Arrays.asList("Jersey"));
        form.asMap().put("lastName", Arrays.asList("JAX-RS"));
        if (!omitEmail) {
            form.asMap().put("email", Arrays.asList("jersey@example.com"));
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.