This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GreetingIT.java
74 lines (59 loc) · 2.27 KB
/
GreetingIT.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package io.quarkus;
import io.restassured.RestAssured;
import io.restassured.config.HttpClientConfig;
import io.restassured.config.RestAssuredConfig;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import java.nio.charset.StandardCharsets;
import org.apache.http.params.CoreConnectionPNames;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class GreetingIT {
RestAssuredConfig config;
@BeforeEach
void setUp() {
config = RestAssured.config()
.httpClient(HttpClientConfig.httpClientConfig()
.setParam(CoreConnectionPNames.CONNECTION_TIMEOUT, 5000)
.setParam(CoreConnectionPNames.SO_TIMEOUT, 5000));
}
@Test
public void testGetStringLessThen8KB_text() {
Response response = RestAssured.given().config(config)
.queryParam("times", "78")
.accept(ContentType.TEXT)
.get("http://localhost:7071/api/hello/getString");
assertResponse(response);
}
@Test
public void testGetStringGreaterThen8KB_text() {
Response response = RestAssured.given().config(config)
.queryParam("times", "300")
.accept(ContentType.TEXT)
.get("http://localhost:7071/api/hello/getString");
assertResponse(response);
}
@Test
public void testGetStringLessThen8KB_json() {
Response response = RestAssured.given().config(config)
.queryParam("times", "78")
.accept(ContentType.JSON)
.get("http://localhost:7071/api/hello/getString");
assertResponse(response);
}
@Test
public void testGetStringGreaterThen8KB_json() {
Response response = RestAssured.given().config(config)
.queryParam("times", "300")
.accept(ContentType.JSON)
.get("http://localhost:7071/api/hello/getString");
assertResponse(response);
}
private static void assertResponse(Response response) {
response.then()
.statusCode(200);
String bodyString = response.body().asPrettyString();
System.out.println("response body size=" + bodyString.getBytes(StandardCharsets.UTF_8).length);
bodyString.startsWith(GreetingResource.BASIC_STRING);
}
}