private void doPost() {
HttpClient client = Vertx.vertx().createHttpClient();
CompletableFuture<Boolean> postRequestWorked = new CompletableFuture<>();
HttpClientRequest request = client.post(4747, "localhost", "/", response -> {
response.bodyHandler(body -> {
System.out.println("testPost() " + body.toString());
postRequestWorked.complete(response.statusCode() == HttpURLConnection.HTTP_OK);
});
}).setChunked(true);
for(int i= 0; i < 10; i++) {
// no json object to simplify string creation
String json = "{\"identifier\" : \""+i+"\", \"type_of_item\" : \"hardcover_book\", \"title_of_item\" : \"test record "+i+"\"}";
// happens almost never with such short strings:
//String json = "test record "+i;
if(i>0) json = ", " + json;
System.out.println(json);
request.write(json);
}
request.end("...");
try {
assertTrue(postRequestWorked.get(10, TimeUnit.SECONDS));
} catch (Exception e) {
fail(e.getMessage());
}
}
@Override
public void start(Future<Void> fut) {
vertx.createHttpServer(new HttpServerOptions().setReceiveBufferSize(5000)).requestHandler(request -> {
StringBuffer body = new StringBuffer();
request.handler(buffer -> {
System.out.println(buffer.toString());
body.append(buffer.toString());
});
request.endHandler(end -> {
int missingDoc = -1;
for (int i=0; i<10; i++) {
if (!body.toString().contains("test record " + i)) {
missingDoc = i;
break;
}
}
if (missingDoc >= 0) {
request.response().setStatusCode(500);
request.response().end("missing doc: " + missingDoc);
} else {
request.response().setStatusCode(200);
request.response().end("done processing");
}
});
}
).listen(4747, res -> {
if (res.succeeded()) {
System.out.println("listening on port " + 4747);
} else {
System.out.println("failed to bind port " + 4747);
}
});
}
...testPost() done processing{"identifier" : "0", "type_of_item" : "hardcover_book", "title_of_item" : "test record 0"}
, {"identifier" : "1", "type_of_item" : "hardcover_book", "title_of_item" : "test record 1"}
, {"identifier" : "2", "type_of_item" : "hardcover_book", "title_of_item" : "test record 2"}
, {"identifier" : "3", "type_of_item" : "hardcover_book", "title_of_item" : "test record 3"}
, {"identifier" : "4", "type_of_item" : "hardcover_book", "title_of_item" : "test record 4"}
, {"identifier" : "5", "type_of_item" : "hardcover_book", "title_of_item" : "test record 5"}
, {"identifier" : "6", "type_of_item" : "hardcover_book", "title_of_item" : "test record 6"}
, {"identifier" : "7", "type_of_item" : "hardcover_book", "title_of_item" : "test record 7"}
, {"identifier" : "8", "type_of_item" : "hardcover_book", "title_of_item" : "test record 8"}
, {"identifier" : "9", "type_of_item" : "hardcover_book", "title_of_item" : "test record 9"}
testPost() missing doc: 9
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/14aa1241-f1a3-4230-9f93-8ab105b5018b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/_dQhEVWNoQI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/571BAF7A.4060103%40gmail.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/571BB533.7030505%40gmx.net.
On May 2, 2016, at 8:31 AM, 'Peter Fischer' via vert.x <ve...@googlegroups.com> wrote:
did not find the correct place to report a vert.x bug in eclipse/bugzilla so I opened an "old fashioned" github issue: https://github.com/vert-x3/issues/issues/117
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/30e93b0a-5b51-44f0-94fe-f75f0a268ffc%40googlegroups.com.