Skip to content

Commit 3376fcf

Browse files
committed
test explaining issue #362
1 parent 087f7ab commit 3376fcf

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

unirest/src/test/java/BehaviorTests/UniBodyPostingTest.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,15 @@
2525

2626
package BehaviorTests;
2727

28-
import kong.unirest.JsonNode;
29-
import kong.unirest.MockCallback;
30-
import kong.unirest.Unirest;
31-
import kong.unirest.UnirestConfigException;
28+
import kong.unirest.*;
3229
import kong.unirest.json.JSONArray;
3330
import kong.unirest.json.JSONObject;
3431
import org.junit.jupiter.api.Test;
3532

3633
import java.nio.charset.StandardCharsets;
3734

3835
import static kong.unirest.TestUtil.assertException;
36+
import static org.junit.jupiter.api.Assertions.assertEquals;
3937

4038
public class UniBodyPostingTest extends BddTest {
4139
@Test
@@ -166,4 +164,16 @@ public void cantPostObjectWithoutObjectMapper(){
166164
UnirestConfigException.class,
167165
"No Object Mapper Configured. Please config one with Unirest.config().setObjectMapper");
168166
}
167+
168+
@Test
169+
void theRequestBodyIsAString() {
170+
RequestBodyEntity request = Unirest.post(MockServer.POST)
171+
.basicAuth("foo", "bar")
172+
.header("Content-Type", "application/json")
173+
.queryString("foo", "bar")
174+
.body("{\"body\": \"sample\"}");
175+
176+
Object value = request.getBody().get().uniPart().getValue();
177+
assertEquals("{\"body\": \"sample\"}", value);
178+
}
169179
}

0 commit comments

Comments
 (0)