Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hgoebl/9dcb663243db3f5fcbd3 to your computer and use it in GitHub Desktop.
Save hgoebl/9dcb663243db3f5fcbd3 to your computer and use it in GitHub Desktop.
package com.goebl.david;
import junit.framework.TestCase;
import org.json.JSONObject;
public class TestWebb_LocalStackoverflow23678518 extends TestCase {
public void testPost() throws Exception {
JSONObject register = new JSONObject();
register.put("email", "abc@example.com");
register.put("password", "tiger");
Webb webb = Webb.create();
Response<JSONObject> response = webb
.post("http://secretserver.net/index.php")
.body(register)
.connectTimeout(3000)
.asJsonObject();
if (response.isSuccess()) {
assertEquals(200, response.getStatusCode());
assertNotNull(response.getBody());
JSONObject outcome = response.getBody();
System.out.println("userId=" + outcome.getString("userId"));
} else {
System.out.println(response.getStatusCode());
System.out.println(response.getResponseMessage());
System.out.println(response.getErrorBody());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment