Skip to content

Commit 0ff2fac

Browse files
committed
add test for put request
1 parent 7e0fa5d commit 0ff2fac

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

gateway-ha/src/test/java/io/trino/gateway/ha/TestPutRequestHandler.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@
3636
public class TestPutRequestHandler
3737
{
3838
private final OkHttpClient httpClient = new OkHttpClient();
39-
private MockWebServer mockTrinoServer = new MockWebServer();;
39+
private MockWebServer mockTrinoServer = new MockWebServer();
4040

4141
private final int routerPort = 21001 + (int) (Math.random() * 1000);
4242
private final int customBackendPort = 21000 + (int) (Math.random() * 1000);
4343

44-
private final static String CUSTOM_PUT_ENDPOINT = "/v1/custom"; // this is enabled in test-config-template.yml
45-
private final static String HEALTH_CHECK_ENDPOINT = "/v1/info";
46-
private final static String PUT = "PUT";
44+
private final String customPutEndpoint = "/v1/custom"; // this is enabled in test-config-template.yml
45+
private final String healthCheckEndpoint = "/v1/info";
4746

4847
@BeforeAll
4948
public void setup()
@@ -54,13 +53,13 @@ public void setup()
5453
@Override
5554
public MockResponse dispatch(RecordedRequest request)
5655
{
57-
if (request.getPath().equals(HEALTH_CHECK_ENDPOINT)) {
56+
if (request.getPath().equals(healthCheckEndpoint)) {
5857
return new MockResponse().setResponseCode(200)
5958
.setHeader(CONTENT_TYPE, JSON_UTF_8)
6059
.setBody("{\"starting\": false}");
6160
}
6261

63-
if (request.getMethod().equals(PUT) && request.getPath().equals(CUSTOM_PUT_ENDPOINT)) {
62+
if (request.getMethod().equals("PUT") && request.getPath().equals(customPutEndpoint)) {
6463
return new MockResponse().setResponseCode(200)
6564
.setHeader(CONTENT_TYPE, JSON_UTF_8)
6665
.setBody("ok");
@@ -100,7 +99,7 @@ public void testPutRequestHandler()
10099
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), "SELECT 1");
101100
Request putRequest =
102101
new Request.Builder()
103-
.url("http://localhost:" + routerPort + CUSTOM_PUT_ENDPOINT)
102+
.url("http://localhost:" + routerPort + customPutEndpoint)
104103
.put(requestBody)
105104
.build();
106105

@@ -110,7 +109,7 @@ public void testPutRequestHandler()
110109

111110
Request postRequest =
112111
new Request.Builder()
113-
.url("http://localhost:" + routerPort + CUSTOM_PUT_ENDPOINT)
112+
.url("http://localhost:" + routerPort + customPutEndpoint)
114113
.post(requestBody)
115114
.build();
116115
try (Response response = httpClient.newCall(postRequest).execute()) {

0 commit comments

Comments
 (0)