Examples of addPart()


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

    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

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

    }

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

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

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

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

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

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

    public Long addNoteWithImage(String note, File imageFile) throws Exception {
        HttpPost request = new HttpPost(DailyMileUtil.ENTRIES_URL);
        HttpResponse response = null;
        try {
            MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
            mpEntity.addPart("media[data]",
                    new FileBody(imageFile, "image/jpeg"));
            mpEntity.addPart("media[type]", new StringBody("image"));
            mpEntity.addPart("message", new StringBody(note));
            mpEntity.addPart("[share_on_services][facebook]", new StringBody("false"));
            mpEntity.addPart("[share_on_services][twitter]", new StringBody("false"));
View Full Code Here

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

        HttpResponse response = null;
        try {
            MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
            mpEntity.addPart("media[data]",
                    new FileBody(imageFile, "image/jpeg"));
            mpEntity.addPart("media[type]", new StringBody("image"));
            mpEntity.addPart("message", new StringBody(note));
            mpEntity.addPart("[share_on_services][facebook]", new StringBody("false"));
            mpEntity.addPart("[share_on_services][twitter]", new StringBody("false"));
            mpEntity.addPart("oauth_token", new StringBody(oauthToken));
View Full Code Here

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

    if (hasFile) {
      MultipartEntityBuilder builder = MultipartEntityBuilder.create();
      for(String key: keyOrder) {
        Object value = parameters.get(key);
        if (value instanceof File) {
          builder.addPart(key, new FileBody((File) value));
        } else {
          builder.addPart(key, new StringBody(value.toString(), ContentType.create(ContentType.APPLICATION_FORM_URLENCODED.getMimeType(), Charset.forName(UTF_8))));
        }
      }
      return builder.build();
View Full Code Here

Examples of org.apache.servicemix.soap.bindings.soap.impl.Wsdl1SoapMessageImpl.addPart()

                    part.setHeader(true);
                } else {
                    throw new IllegalStateException("Unbound part: " + part.getName());
                }
            }
            input.addPart(part);
        }
        if (operation.getStyle() == Style.RPC) {
            input.setElementName(new QName(input.getNamespace(), operation.getName().getLocalPart()));
        }
        operation.setInput(input);
View Full Code Here

Examples of org.apache.stanbol.enhancer.servicesapi.ContentItem.addPart()

            log.error("Failed to create contentitem with uri: {}", uri.getUnicodeString());
            throw new StoreException(String.format("Failed to create contentitem with uri: %s",
                uri.getUnicodeString()));
        }
        if (title != null && !title.trim().isEmpty()) {
            ci.addPart(TITLE_URI, title.trim());
        }
        return ci;
    }

    private void enhance(ContentItem ci, String chainName) throws StoreException {
View Full Code Here

Examples of org.apache.stanbol.enhancer.servicesapi.helper.ContentItemImpl.addPart()

  @Test
  public void addingAndRetrieving() {
    ContentItem ci = new ContentItemImpl(ciUri,blob,new SimpleMGraph()){};
    UriRef partUri = new UriRef("http://foo/");
    Date someObject = new Date();
    ci.addPart(partUri, someObject);
    ci.getMetadata().add(new TripleImpl(ciUri, new UriRef("http://example.org/ontology#hasPart"), partUri));
        ci.getMetadata().add(new TripleImpl(partUri, new UriRef("http://example.org/ontology#isPartOf"),ciUri));
    Assert.assertEquals(someObject, ci.getPart(partUri, Date.class));
    Assert.assertEquals(someObject, ci.getPart(1, Date.class));
    Assert.assertEquals(partUri, ci.getPartUri(1));
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.