|
20 | 20 | import static org.assertj.core.api.Assertions.assertThat; |
21 | 21 |
|
22 | 22 | import java.net.URI; |
23 | | -import java.util.Random; |
24 | 23 |
|
25 | 24 | import org.eclipse.jetty.client.HttpClient; |
26 | 25 | import org.eclipse.jetty.client.api.ContentResponse; |
27 | | -import org.eclipse.jetty.client.util.BytesContentProvider; |
| 26 | +import org.eclipse.jetty.client.util.StringContentProvider; |
| 27 | +import org.json.JSONObject; |
28 | 28 | import org.junit.After; |
29 | 29 | import org.junit.Before; |
30 | 30 | import org.junit.Test; |
@@ -68,24 +68,24 @@ public void tearDown() throws Exception { |
68 | 68 |
|
69 | 69 | @Test |
70 | 70 | public void testPostData() throws Exception { |
71 | | - byte[] input = new byte[1024]; |
72 | | - new Random().nextBytes(input); |
| 71 | + String input = "{\"foo\": 42}"; |
73 | 72 | ContentResponse response = client.POST(httpBinEndpoint + "/post") |
74 | | - .content(new BytesContentProvider(input)) |
| 73 | + .content(new StringContentProvider(input)) |
75 | 74 | .send(); |
76 | 75 | assertThat(response.getStatus()).as("status").isEqualTo(200); |
77 | | - assertThat(response.getContent()).isEqualTo(input); |
| 76 | + JSONObject object = new JSONObject(response.getContentAsString()); |
| 77 | + assertThat(object.getJSONObject("data").getInt("foo")).isEqualTo(42); |
78 | 78 | } |
79 | 79 |
|
80 | 80 | @Test |
81 | 81 | public void testPutData() throws Exception { |
82 | | - byte[] input = new byte[1024]; |
83 | | - new Random().nextBytes(input); |
| 82 | + String input = "{\"foo\": 42}"; |
84 | 83 | ContentResponse response = client.newRequest(httpBinEndpoint + "/put") |
85 | 84 | .method("PUT") |
86 | | - .content(new BytesContentProvider(input)) |
| 85 | + .content(new StringContentProvider(input)) |
87 | 86 | .send(); |
88 | 87 | assertThat(response.getStatus()).as("status").isEqualTo(200); |
89 | | - assertThat(response.getContent()).isEqualTo(input); |
| 88 | + JSONObject object = new JSONObject(response.getContentAsString()); |
| 89 | + assertThat(object.getJSONObject("data").getInt("foo")).isEqualTo(42); |
90 | 90 | } |
91 | 91 | } |
0 commit comments