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;
}
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);
}
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");
}
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");
}
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;
}
Aggregations