summaryrefslogtreecommitdiffstats
path: root/container-core
diff options
context:
space:
mode:
authorHenrik <henrik.hoiness@online.no>2018-06-25 10:24:24 +0200
committerHenrik <henrik.hoiness@online.no>2018-06-25 10:24:24 +0200
commit85c0a98e9306969231a2babbd358a0b607699361 (patch)
treea07a2c4368db4ef6c01857a1ccb9a703a8bae72f /container-core
parentd8cb472c08ef2bae48aa534030aa9ad97a1e73c2 (diff)
POST-queries seems to be working and tests and maven builds are successful.
Diffstat (limited to 'container-core')
-rw-r--r--container-core/src/main/java/com/yahoo/container/jdisc/RequestHandlerTestDriver.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/jdisc/RequestHandlerTestDriver.java b/container-core/src/main/java/com/yahoo/container/jdisc/RequestHandlerTestDriver.java
index 132b1153fc5..22933556d9f 100644
--- a/container-core/src/main/java/com/yahoo/container/jdisc/RequestHandlerTestDriver.java
+++ b/container-core/src/main/java/com/yahoo/container/jdisc/RequestHandlerTestDriver.java
@@ -63,10 +63,16 @@ public class RequestHandlerTestDriver implements AutoCloseable {
return sendRequest(uri, method, "");
}
+ /** Send a POST request */
public MockResponseHandler sendRequest(String uri, HttpRequest.Method method, String body) {
return sendRequest(uri, method, ByteBuffer.wrap(body.getBytes(StandardCharsets.UTF_8)));
}
+ /** Send a POST request with defined content type */
+ public MockResponseHandler sendRequest(String uri, HttpRequest.Method method, String body, String contentType) {
+ return sendRequest(uri, method, ByteBuffer.wrap(body.getBytes(StandardCharsets.UTF_8)), contentType);
+ }
+
public MockResponseHandler sendRequest(String uri, HttpRequest.Method method, ByteBuffer body) {
responseHandler = new MockResponseHandler();
Request request = HttpRequest.newServerRequest(driver, URI.create(uri), method);
@@ -78,6 +84,18 @@ public class RequestHandlerTestDriver implements AutoCloseable {
return responseHandler;
}
+ public MockResponseHandler sendRequest(String uri, HttpRequest.Method method, ByteBuffer body, String contentType) {
+ responseHandler = new MockResponseHandler();
+ Request request = HttpRequest.newServerRequest(driver, URI.create(uri), method);
+ request.context().put("contextVariable", 37); // TODO: Add a method for accepting a Request instead
+ request.headers().put(com.yahoo.jdisc.http.HttpHeaders.Names.CONTENT_TYPE, contentType);
+ ContentChannel requestContent = request.connect(responseHandler);
+ requestContent.write(body, null);
+ requestContent.close(null);
+ request.release();
+ return responseHandler;
+ }
+
/** Replaces all occurrences of 0-9 digits by d's */
public String censorDigits(String s) {
return s.replaceAll("[0-9]","d");