Search in sources :

Example 71 with HttpPut

use of org.apache.http.client.methods.HttpPut in project indy by Commonjava.

the class IndyClientHttp method newJsonPut.

public HttpPut newJsonPut(final String url) {
    final HttpPut req = new HttpPut(url);
    addJsonHeaders(req);
    return req;
}
Also used : HttpPut(org.apache.http.client.methods.HttpPut)

Example 72 with HttpPut

use of org.apache.http.client.methods.HttpPut in project TaEmCasa by Dionen.

the class HttpClientStackTest method createPutRequestWithBody.

@Test
public void createPutRequestWithBody() throws Exception {
    TestRequest.PutWithBody request = new TestRequest.PutWithBody();
    assertEquals(request.getMethod(), Method.PUT);
    HttpUriRequest httpRequest = HttpClientStack.createHttpRequest(request, null);
    assertTrue(httpRequest instanceof HttpPut);
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) HttpPut(org.apache.http.client.methods.HttpPut) TestRequest(com.android.volley.mock.TestRequest) Test(org.junit.Test)

Example 73 with HttpPut

use of org.apache.http.client.methods.HttpPut in project stanbol by apache.

the class SessionTest method testCRUD.

@Test
public void testCRUD() throws Exception {
    RequestExecutor request;
    // The needed Web resources to GET from.
    executor.execute(builder.buildGetRequest(SESSION_URI).withHeader("Accept", KRFormat.TURTLE)).assertStatus(200);
    log.info("Request: " + SESSION_URI + " ... DONE");
    String tempScopeUri = SESSION_URI + "/" + getClass().getCanonicalName() + "-" + System.currentTimeMillis();
    // Scope should not be there
    request = executor.execute(builder.buildGetRequest(tempScopeUri).withHeader("Accept", KRFormat.TURTLE));
    request.assertStatus(404);
    log.info("Request: " + tempScopeUri + " (should return 404) ... DONE");
    // Create scope
    executor.execute(builder.buildOtherRequest(new HttpPut(builder.buildUrl(tempScopeUri))));
    log.info("PUT Request: " + tempScopeUri + " ... DONE");
    // Scope should be there now
    request = executor.execute(builder.buildGetRequest(tempScopeUri).withHeader("Accept", KRFormat.TURTLE));
    request.assertStatus(200).assertContentContains(tempScopeUri);
    log.info("Request: " + tempScopeUri + " ... DONE");
    // TODO the U of CRUD
    // Delete scope
    executor.execute(builder.buildOtherRequest(new HttpDelete(builder.buildUrl(tempScopeUri))));
    log.info("DELETE Request: " + tempScopeUri + " ... DONE");
    // Scope should not be there
    request = executor.execute(builder.buildGetRequest(tempScopeUri).withHeader("Accept", KRFormat.TURTLE));
    request.assertStatus(404);
    log.info("Request: " + tempScopeUri + " (should return 404) ... DONE");
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) RequestExecutor(org.apache.stanbol.commons.testing.http.RequestExecutor) HttpPut(org.apache.http.client.methods.HttpPut) Test(org.junit.Test)

Example 74 with HttpPut

use of org.apache.http.client.methods.HttpPut in project stanbol by apache.

the class ScopeTest method testCRUD.

@Test
public void testCRUD() throws Exception {
    RequestExecutor request;
    // The needed Web resources to GET from.
    executor.execute(builder.buildGetRequest(BASE_SCOPES_URI).withHeader("Accept", KRFormat.TURTLE)).assertStatus(200);
    log.info("Request: " + BASE_SCOPES_URI + " ... DONE");
    String tempScopeUri = BASE_SCOPES_URI + "/" + getClass().getCanonicalName() + "-" + System.currentTimeMillis();
    // Scope should not be there
    request = executor.execute(builder.buildGetRequest(tempScopeUri).withHeader("Accept", KRFormat.TURTLE));
    request.assertStatus(404);
    log.info("Request: " + tempScopeUri + " (should return 404) ... DONE");
    // Create scope
    executor.execute(builder.buildOtherRequest(new HttpPut(builder.buildUrl(tempScopeUri))));
    log.info("PUT Request: " + tempScopeUri + " ... DONE");
    // Scope should be there now
    request = executor.execute(builder.buildGetRequest(tempScopeUri).withHeader("Accept", KRFormat.TURTLE));
    request.assertStatus(200).assertContentContains(tempScopeUri);
    log.info("Request: " + tempScopeUri + " ... DONE");
    // TODO the U of CRUD
    // Delete scope
    executor.execute(builder.buildOtherRequest(new HttpDelete(builder.buildUrl(tempScopeUri))));
    log.info("DELETE Request: " + tempScopeUri + " ... DONE");
    // Scope should not be there
    request = executor.execute(builder.buildGetRequest(tempScopeUri).withHeader("Accept", KRFormat.TURTLE));
    request.assertStatus(404);
    log.info("Request: " + tempScopeUri + " (should return 404) ... DONE");
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) RequestExecutor(org.apache.stanbol.commons.testing.http.RequestExecutor) HttpPut(org.apache.http.client.methods.HttpPut) Test(org.junit.Test)

Example 75 with HttpPut

use of org.apache.http.client.methods.HttpPut in project stanbol by apache.

the class EntityhubTest method buildImportRdfData.

/**
     * Imports/updates RDF data of the file to the entityhub with the possibility
     * to restrict imports/updates to the parsed uri
     * @param file the file with the RDF data (needs to be in the classpath)
     * @param create if <code>true</code> the data are created (POST) otherwise
     * updated (PUT). 
     * @param uri if not <code>null</code> only data of this URI are imported by
     * specifying the id parameter
     */
protected Request buildImportRdfData(InputStream in, String contentType, boolean create, String uri) {
    Assert.assertNotNull(in);
    Assert.assertNotNull(contentType);
    Request request;
    String path;
    if (uri != null) {
        path = builder.buildUrl("/entityhub/entity", "id", uri);
    } else {
        path = builder.buildUrl("/entityhub/entity");
    }
    if (create) {
        request = builder.buildOtherRequest(new HttpPost(path));
    } else {
        request = builder.buildOtherRequest(new HttpPut(path));
    }
    //set the HttpEntity (both PUT and POST are HttpEntityEnclosingRequests)
    ((HttpEntityEnclosingRequest) request.getRequest()).setEntity(new InputStreamEntity(in, -1));
    //finally set the correct content-type of the provided data
    //currently fixed to "application/rdf+xml"
    request.getRequest().setHeader("Content-Type", contentType);
    return request;
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) HttpEntityEnclosingRequest(org.apache.http.HttpEntityEnclosingRequest) Request(org.apache.stanbol.commons.testing.http.Request) HttpEntityEnclosingRequest(org.apache.http.HttpEntityEnclosingRequest) HttpPut(org.apache.http.client.methods.HttpPut) InputStreamEntity(org.apache.http.entity.InputStreamEntity)

Aggregations

HttpPut (org.apache.http.client.methods.HttpPut)153 StringEntity (org.apache.http.entity.StringEntity)89 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)50 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)40 HttpResponse (org.apache.http.HttpResponse)29 Test (org.junit.Test)29 JsonNode (com.fasterxml.jackson.databind.JsonNode)27 Deployment (org.activiti.engine.test.Deployment)27 HttpPost (org.apache.http.client.methods.HttpPost)19 HttpGet (org.apache.http.client.methods.HttpGet)17 IOException (java.io.IOException)16 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)16 HttpDelete (org.apache.http.client.methods.HttpDelete)14 HttpEntity (org.apache.http.HttpEntity)13 URI (java.net.URI)12 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)12 HttpHead (org.apache.http.client.methods.HttpHead)11 Execution (org.activiti.engine.runtime.Execution)10 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)9 HttpEntityEnclosingRequestBase (org.apache.http.client.methods.HttpEntityEnclosingRequestBase)9