-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathWarmup.java
33 lines (28 loc) · 1.37 KB
/
Warmup.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
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse.BodyHandlers;
public class Warmup {
public static void main(String[] args) throws IOException, InterruptedException {
System.out.println("Warming up...");
HttpClient client = HttpClient.newHttpClient();
// HTTP GET request
HttpRequest getRequest = HttpRequest.newBuilder()
.uri(URI.create("http://127.0.0.1:9999/clientes/333/extrato"))
.build();
HttpResponse<String> getResponse = client.send(getRequest, BodyHandlers.ofString());
System.out.println("GET Response: " + getResponse.statusCode());
// HTTP POST request
HttpRequest postRequest = HttpRequest.newBuilder()
.uri(URI.create("http://127.0.0.1:9999/clientes/333/transacoes"))
.header("Content-Type", "application/json")
.POST(BodyPublishers.ofString("{\"valor\": 0, \"tipo\": \"d\", \"descricao\": \"warmup\"}"))
.build();
HttpResponse<String> postResponse = client.send(postRequest, BodyHandlers.ofString());
System.out.println("POST Response: " + postResponse.statusCode());
System.out.println("Warmup DONE!");
}
}