Created
January 16, 2015 11:39
-
-
Save hgoebl/af5b54f76bace9d50f43 to your computer and use it in GitHub Desktop.
Example using DavidWebb HTTP-Client for a stackoverflow question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.goebl.david; | |
public class TestWebb_LocalStackoverflow27980798 extends AbstractTestWebb { | |
public static final String BASE_URL = "https://domain.com"; | |
public static final String API_VER = "/v1"; | |
public void testDownload() throws Exception { | |
String token = "token12345"; | |
Webb webb = Webb.create(); | |
webb.setBaseUri(BASE_URL + API_VER); | |
Response<String> response = webb | |
.get("/resource") | |
.param("token", token) | |
.header("Accept-Charset", "UTF-8") | |
.asString(); | |
assertEquals(200, response.getStatusCode()); | |
assertNotNull(response.getBody()); | |
assertTrue(response.getBody().contains("some text of the body")); | |
} | |
public void testDownloadShort() throws Exception { | |
String token = "token12345"; | |
Webb webb = Webb.create(); | |
webb.setBaseUri(BASE_URL + API_VER); | |
String xml = webb | |
.get("/resource") | |
.param("token", token) | |
.header("Accept-Charset", "UTF-8") | |
.asString() | |
.getBody(); | |
assertTrue(xml.contains("some text of the body")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment