Package org.apache.commons.httpclient.methods.multipart

Examples of org.apache.commons.httpclient.methods.multipart.StringPart


     * @param parameterName The name of the parameter.
     * @param parameterValue The value of the parameter.
     */
    public void addParameter(String parameterName, String parameterValue) {
        LOG.trace("enter addParameter(String parameterName, String parameterValue)");
        Part param = new StringPart(parameterName, parameterValue);
        parameters.add(param);
    }
View Full Code Here


       
        this.server.setHttpService(new EchoService());
       
        PostMethod method = new PostMethod();
        MultipartRequestEntity entity = new MultipartRequestEntity(
            new Part[] { new StringPart("param", "Hello", "ISO-8859-1") },
            method.getParams());
        method.setRequestEntity(entity);
        client.executeMethod(method);

        assertEquals(200,method.getStatusCode());
View Full Code Here

        file.delete();
        assertEquals(resp1, resp2);
    }

    public void testStringPartResendsData() throws Exception {
        StringPart part = new StringPart(NAME, PART_DATA);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        part.send(stream);
        String resp1 = stream.toString();
        stream = new ByteArrayOutputStream();
        part.send(stream);
        String resp2 = stream.toString();
        assertEquals(resp1, resp2);
    }
View Full Code Here

               HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
               String parameterName = arg.getName();
               if (arg.isSkippable(parameterName)){
                   continue;
               }
               partlist.add(new StringPart(arg.getName(), arg.getValue(), contentEncoding));
            }

            // Add any files
            for (int i=0; i < files.length; i++) {
                HTTPFileArg file = files[i];
View Full Code Here

   
    @Test
    public void testHttpClient() throws Exception {
        File jpg = new File("src/test/resources/java.jpg");
        String body = "TEST";
        Part[] parts = new Part[] {new StringPart("body", body), new FilePart(jpg.getName(), jpg)};
       
        PostMethod method = new PostMethod("http://localhost:" + port2 + "/test/hello");
        MultipartRequestEntity requestEntity = new MultipartRequestEntity(parts, method.getParams());
        method.setRequestEntity(requestEntity);
       
View Full Code Here

    public void testSendMultiPartForm() throws Exception {
        HttpClient httpclient = new HttpClient();
        File file = new File("src/main/resources/META-INF/NOTICE.txt");
        PostMethod httppost = new PostMethod("http://localhost:" + getPort() + "/test");
        Part[] parts = {
            new StringPart("comment", "A binary file of some kind"),
            new FilePart(file.getName(), file)
        };

        MultipartRequestEntity reqEntity = new MultipartRequestEntity(parts, httppost.getParams());
        httppost.setRequestEntity(reqEntity);
View Full Code Here

        File file = new File("src/main/resources/META-INF/NOTICE.txt");

        PostMethod httppost = new PostMethod("http://localhost:" + getPort() + "/test2");
        Part[] parts = {
            new StringPart("comment", "A binary file of some kind"),
            new FilePart(file.getName(), file)
        };

        MultipartRequestEntity reqEntity = new MultipartRequestEntity(parts, httppost.getParams());
        httppost.setRequestEntity(reqEntity);
View Full Code Here

        File file = new File("src/main/resources/META-INF/NOTICE.txt");

        PostMethod httppost = new PostMethod("http://localhost:" + getPort() + "/test");
        Part[] parts = {
            new StringPart("comment", "A binary file of some kind"),
            new FilePart(file.getName(), file)
        };

        MultipartRequestEntity reqEntity = new MultipartRequestEntity(parts, httppost.getParams());
        httppost.setRequestEntity(reqEntity);
View Full Code Here

   
    @Test
    public void testHttpClient() throws Exception {
        File jpg = new File("src/test/resources/java.jpg");
        String body = "TEST";
        Part[] parts = new Part[] {new StringPart("body", body), new FilePart(jpg.getName(), jpg)};
       
        PostMethod method = new PostMethod("http://localhost:" + port2 + "/test/hello");
        MultipartRequestEntity requestEntity = new MultipartRequestEntity(parts, method.getParams());
        method.setRequestEntity(requestEntity);
       
View Full Code Here

        file.delete();
        assertEquals(resp1, resp2);
    }

    public void testStringPartResendsData() throws Exception {
        StringPart part = new StringPart(NAME, PART_DATA);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        part.send(stream);
        String resp1 = stream.toString();
        stream = new ByteArrayOutputStream();
        part.send(stream);
        String resp2 = stream.toString();
        assertEquals(resp1, resp2);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.methods.multipart.StringPart

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.