Examples of addPart()


Examples of org.apache.http.entity.mime.MultipartEntity.addPart()

    try {
      Charset utf8 = Charset.forName("UTF-8");
      for(Parameter param : parameters)
        if(param.isSingleValue())
          multiPartEntity.addPart(param.getName(), new StringBody(param.getValue(), utf8));
        else
          for(String value : param.getValues())
            multiPartEntity.addPart(param.getName(), new StringBody(value, utf8));
    } catch (UnsupportedEncodingException e) {
      throw MechanizeExceptionFactory.newException(e);
View Full Code Here

Examples of org.apache.http.entity.mime.MultipartEntity.addPart()

      for(Parameter param : parameters)
        if(param.isSingleValue())
          multiPartEntity.addPart(param.getName(), new StringBody(param.getValue(), utf8));
        else
          for(String value : param.getValues())
            multiPartEntity.addPart(param.getName(), new StringBody(value, utf8));
    } catch (UnsupportedEncodingException e) {
      throw MechanizeExceptionFactory.newException(e);
    }

    List<String> fileNames = new ArrayList<String>(files.keySet());
View Full Code Here

Examples of org.apache.http.entity.mime.MultipartEntity.addPart()

    List<String> fileNames = new ArrayList<String>(files.keySet());
    Collections.sort(fileNames);
    for(String name : fileNames) {
      ContentBody contentBody = files.get(name);
      multiPartEntity.addPart(name, contentBody);
    }
    request.setEntity(multiPartEntity);
    return request;
  }
}
View Full Code Here

Examples of org.apache.http.entity.mime.MultipartEntity.addPart()

    public void testResourceResolver() throws Exception {
        RequestBuilder rb = new RequestBuilder("http://localhost:9000");

        final MultipartEntity entity = new MultipartEntity();
        // Add Sling POST options
        entity.addPart("lang", new StringBody("esp"));
        entity.addPart("code", new InputStreamBody(getClass().getResourceAsStream("/test.js"), "test.js"));
        executor.execute(
                rb.buildPostRequest("/system/console/scriptconsole.json")
                 .withEntity(entity)
                 .withCredentials("admin","admin")
View Full Code Here

Examples of org.apache.http.entity.mime.MultipartEntity.addPart()

        RequestBuilder rb = new RequestBuilder("http://localhost:9000");

        final MultipartEntity entity = new MultipartEntity();
        // Add Sling POST options
        entity.addPart("lang", new StringBody("esp"));
        entity.addPart("code", new InputStreamBody(getClass().getResourceAsStream("/test.js"), "test.js"));
        executor.execute(
                rb.buildPostRequest("/system/console/scriptconsole.json")
                 .withEntity(entity)
                 .withCredentials("admin","admin")
            ).assertStatus(200);
View Full Code Here

Examples of org.apache.http.entity.mime.MultipartEntity.addPart()

        HttpPost httppost = new HttpPost(getRequestBuilder().buildUrl(path));
        if (reqParams != null) {
            for (Map.Entry<String, String> entry : reqParams.entrySet()) {
                String key = entry.getKey();
                String value = entry.getValue();
                reqEntity.addPart(key, new StringBody(value, utf8));
            }
        }
        if (ins != null) {
            ContentBody contentBody = new InputStreamBody(ins, fileName);
            reqEntity.addPart(fileName, contentBody);
View Full Code Here

Examples of org.apache.http.entity.mime.MultipartEntity.addPart()

                reqEntity.addPart(key, new StringBody(value, utf8));
            }
        }
        if (ins != null) {
            ContentBody contentBody = new InputStreamBody(ins, fileName);
            reqEntity.addPart(fileName, contentBody);
        }
        httppost.setEntity(reqEntity);
        HttpResponse response = getRequestExecutor().execute(
            getRequestBuilder().buildOtherRequest(httppost).withCredentials(
                getServerUsername(), getServerPassword())).getResponse();
View Full Code Here

Examples of org.apache.http.entity.mime.MultipartEntity.addPart()

public class ValidationServiceTest extends SlingTestBase {

    @Test
    public void testValidRequestModel1() throws IOException, JSONException {
        MultipartEntity entity = new MultipartEntity();
        entity.addPart("sling:resourceType", new StringBody("validation/test/resourceType1"));
        entity.addPart("field1", new StringBody("HelloWorld"));
        entity.addPart("field2", new StringBody("30.01.1988"));
        entity.addPart(SlingPostConstants.RP_OPERATION, new StringBody("validation"));
        RequestExecutor re = getRequestExecutor().execute(getRequestBuilder().buildPostRequest
                ("/validation/testing/fakeFolder1/resource").withEntity(entity)).assertStatus(200);
View Full Code Here

Examples of org.apache.http.entity.mime.MultipartEntity.addPart()

    @Test
    public void testValidRequestModel1() throws IOException, JSONException {
        MultipartEntity entity = new MultipartEntity();
        entity.addPart("sling:resourceType", new StringBody("validation/test/resourceType1"));
        entity.addPart("field1", new StringBody("HelloWorld"));
        entity.addPart("field2", new StringBody("30.01.1988"));
        entity.addPart(SlingPostConstants.RP_OPERATION, new StringBody("validation"));
        RequestExecutor re = getRequestExecutor().execute(getRequestBuilder().buildPostRequest
                ("/validation/testing/fakeFolder1/resource").withEntity(entity)).assertStatus(200);
        JSONObject jsonResponse = new JSONObject(re.getContent());
View Full Code Here

Examples of org.apache.http.entity.mime.MultipartEntity.addPart()

    @Test
    public void testValidRequestModel1() throws IOException, JSONException {
        MultipartEntity entity = new MultipartEntity();
        entity.addPart("sling:resourceType", new StringBody("validation/test/resourceType1"));
        entity.addPart("field1", new StringBody("HelloWorld"));
        entity.addPart("field2", new StringBody("30.01.1988"));
        entity.addPart(SlingPostConstants.RP_OPERATION, new StringBody("validation"));
        RequestExecutor re = getRequestExecutor().execute(getRequestBuilder().buildPostRequest
                ("/validation/testing/fakeFolder1/resource").withEntity(entity)).assertStatus(200);
        JSONObject jsonResponse = new JSONObject(re.getContent());
        assertTrue(jsonResponse.getBoolean("valid"));
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.