Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,28 @@ public void aNewUserShouldBeCreated() {
}

private TestResponse request(String method, String path) {
HttpURLConnection connection;
try {
URL url = new URL("http://localhost:4567" + path);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod(method);
connection.setDoOutput(true);
connection.connect();
String body = IOUtils.toString(connection.getInputStream());
return new TestResponse(connection.getResponseCode(), body);
} catch (IOException e) {
//connection.connect();
if(connection.getResponseCode()>=200 && connection.getResponseCode()<300) {
String body = IOUtils.toString(connection.getInputStream());
return new TestResponse(connection.getResponseCode(), body);
} else {
String body = IOUtils.toString(connection.getErrorStream());
return new TestResponse(connection.getResponseCode(), body);
}
} catch (IOException e) {
e.printStackTrace();
fail("Sending request failed: " + e.getMessage());
org.junit.Assert.fail("Sending request failed: " + e.getMessage());
return null;
}
}


private static class TestResponse {

public final String body;
Expand Down