Package org.apache.cxf.jaxrs.ext.form

Examples of org.apache.cxf.jaxrs.ext.form.Form


        return (MultivaluedMap<String, String>)clazz.newInstance();
    }
   
    @SuppressWarnings("unchecked")
    private Object getFormObject(Class<?> clazz, MultivaluedMap<String, String> params) {
        return Form.class.isAssignableFrom(clazz) ? new Form((MultivaluedMap)params) : params;
    }
View Full Code Here


                                                 "POST",
                                                 tokenService.getBaseURI().toString(),
                                                 parameters);
        try {
            tokenService.replaceHeader("Authorization", header);
            Form form = tokenService.post(null, Form.class);
            return new Token(form.getData().getFirst("oauth_token"),
                    form.getData().getFirst("oauth_token_secret"));
        } catch (ServerWebApplicationException ex) {
            throw new OAuthServiceException(ex);
        }
    }
View Full Code Here

       
        WebClient client = WebClient.create("http://localhost:" + PORT + "/test/services/rest");
        client.type(MediaType.TEXT_PLAIN_TYPE).accept(MediaType.APPLICATION_XML_TYPE);
        client.path("/bookstore/books/139/subresource4/139/CXF Rocks");
        Book bean = new Book("CXF Rocks", 139L);
        Form form = new Form();
        form.set("name", "CXF Rocks").set("id", Long.valueOf(139L));
        Book b = readBook((InputStream)client.matrix("", bean).query("", bean).form(form).getEntity());
        assertEquals(139, b.getId());
        assertEquals("CXF Rocks", b.getName());
    }
View Full Code Here

    public void testGetBookWebClientForm2() throws Exception {
       
        String baseAddress = "http://localhost:" + PORT
            + "/test/services/rest/bookstore/books/679/subresource3";
        WebClient wc = WebClient.create(baseAddress);
        Form f = new Form();
        f.set("id", "679").set("name", "CXF in Action - ")
            .set("nameid", "679");
        Book b = readBook((InputStream)wc.accept("application/xml")
                          .form(f).getEntity());
        assertEquals(679, b.getId());
        assertEquals("CXF in Action - 679", b.getName());
View Full Code Here

    @Test
    public void testTooManyFormParams() throws Exception {
        String endpointAddress =
            "http://localhost:" + PORT + "/the/thebooks9/depth-form";
        WebClient wc = WebClient.create(endpointAddress);
        Response r = wc.form(new Form().set("a", "b"));
        assertEquals(204, r.getStatus());
        r = wc.form(new Form().set("a", "b").set("c", "b"));
        assertEquals(413, r.getStatus());
    }
View Full Code Here

       
        WebClient client = WebClient.create("http://localhost:" + PORT + "/test/services/rest");
        client.type(MediaType.TEXT_PLAIN_TYPE).accept(MediaType.APPLICATION_XML_TYPE);
        client.path("/bookstore/books/139/subresource4/139/CXF Rocks");
        Book bean = new Book("CXF Rocks", 139L);
        Form form = new Form();
        form.set("name", "CXF Rocks").set("id", Long.valueOf(139L));
        Book b = readBook((InputStream)client.matrix("", bean).query("", bean).form(form).getEntity());
        assertEquals(139, b.getId());
        assertEquals("CXF Rocks", b.getName());
    }
View Full Code Here

    public void testGetBookWebClientForm2() throws Exception {
       
        String baseAddress = "http://localhost:" + PORT
            + "/test/services/rest/bookstore/books/679/subresource3";
        WebClient wc = WebClient.create(baseAddress);
        Form f = new Form();
        f.set("id", "679").set("name", "CXF in Action - ")
            .set("nameid", "679");
        Book b = readBook((InputStream)wc.accept("application/xml")
                          .form(f).getEntity());
        assertEquals(679, b.getId());
        assertEquals("CXF in Action - 679", b.getName());
View Full Code Here

        return (MultivaluedMap<String, String>)clazz.newInstance();
    }
   
    @SuppressWarnings("unchecked")
    private Object getFormObject(Class<?> clazz, MultivaluedMap<String, String> params) {
        return Form.class.isAssignableFrom(clazz) ? new Form((MultivaluedMap)params) : params;
    }
View Full Code Here

   
    @SuppressWarnings("unchecked")
    @Test
    public void testReadFromForm() throws Exception {
        InputStream is = getClass().getResourceAsStream("singleValPostBody.txt");
        Form form = (Form)ferp.readFrom((Class)Form.class, null,
                new Annotation[]{}, MediaType.APPLICATION_FORM_URLENCODED_TYPE, null, is);
        MultivaluedMap<String, String> mvMap = form.getData();
        assertEquals("Wrong entry for foo", "bar", mvMap.getFirst("foo"));
        assertEquals("Wrong entry for boo", "far", mvMap.getFirst("boo"));

    }
View Full Code Here

        assertEquals("Wrong value", "a=a1&b=b1", result)
    }
   
    @Test
    public void testWriteForm() throws Exception {
        Form form = new Form();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ferp.writeTo(form.set("a", "a1").set("b", "b1"), Form.class, Form.class,
                     new Annotation[0], MediaType.APPLICATION_FORM_URLENCODED_TYPE,
                     new MetadataMap<String, Object>(), bos);
        String result = bos.toString();
        assertEquals("Wrong value", "a=a1&b=b1", result)
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.ext.form.Form

Copyright © 2018 www.massapicom. 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.