Skip to content

Commit

Permalink
Add test for createRestRequest
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <cwperx@amazon.com>
  • Loading branch information
cwperks committed Sep 28, 2023
1 parent 0a0214d commit 104c512
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@

import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -150,6 +151,21 @@ public void testHttpPublishPort() throws Exception {
}
}

public void testCreateRestRequestDoesNotGenerateRequestID() {
FakeRestRequest fakeRestRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY).withContent(
new BytesArray("bar".getBytes(StandardCharsets.UTF_8)),
null
).withPath("/foo").withHeaders(Collections.singletonMap("Content-Type", Collections.singletonList("text/plain"))).build();

RestRequest request = AbstractHttpServerTransport.createRestRequest(
xContentRegistry(),
fakeRestRequest.getHttpRequest(),
fakeRestRequest.getHttpChannel()
);

assertEquals("request should not generate id", -1, request.getRequestId());
}

public void testDispatchDoesNotModifyThreadContext() {
final HttpServerTransport.Dispatcher dispatcher = new HttpServerTransport.Dispatcher() {

Expand Down

0 comments on commit 104c512

Please sign in to comment.