|
35 | 35 | import org.opensearch.client.node.NodeClient;
|
36 | 36 | import org.opensearch.common.Table;
|
37 | 37 | import org.opensearch.common.settings.Settings;
|
38 |
| -import org.opensearch.common.xcontent.json.JsonXContent; |
39 |
| -import org.opensearch.core.common.bytes.BytesArray; |
40 |
| -import org.opensearch.core.xcontent.MediaTypeRegistry; |
41 |
| -import org.opensearch.core.xcontent.XContentBuilder; |
42 | 38 | import org.opensearch.rest.RestHandler.ReplacedRoute;
|
43 | 39 | import org.opensearch.rest.RestHandler.Route;
|
44 | 40 | import org.opensearch.rest.RestRequest.Method;
|
@@ -281,81 +277,6 @@ public String getName() {
|
281 | 277 | assertTrue(executed.get());
|
282 | 278 | }
|
283 | 279 |
|
284 |
| - public void testConsumedBody() throws Exception { |
285 |
| - final AtomicBoolean executed = new AtomicBoolean(); |
286 |
| - final BaseRestHandler handler = new BaseRestHandler() { |
287 |
| - @Override |
288 |
| - protected RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { |
289 |
| - request.content(); |
290 |
| - return channel -> executed.set(true); |
291 |
| - } |
292 |
| - |
293 |
| - @Override |
294 |
| - public String getName() { |
295 |
| - return "test_consumed_body"; |
296 |
| - } |
297 |
| - }; |
298 |
| - |
299 |
| - try (XContentBuilder builder = JsonXContent.contentBuilder().startObject().endObject()) { |
300 |
| - final RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withContent( |
301 |
| - new BytesArray(builder.toString()), |
302 |
| - MediaTypeRegistry.JSON |
303 |
| - ).build(); |
304 |
| - final RestChannel channel = new FakeRestChannel(request, randomBoolean(), 1); |
305 |
| - handler.handleRequest(request, channel, mockClient); |
306 |
| - assertTrue(executed.get()); |
307 |
| - } |
308 |
| - } |
309 |
| - |
310 |
| - public void testUnconsumedNoBody() throws Exception { |
311 |
| - final AtomicBoolean executed = new AtomicBoolean(); |
312 |
| - final BaseRestHandler handler = new BaseRestHandler() { |
313 |
| - @Override |
314 |
| - protected RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { |
315 |
| - return channel -> executed.set(true); |
316 |
| - } |
317 |
| - |
318 |
| - @Override |
319 |
| - public String getName() { |
320 |
| - return "test_unconsumed_body"; |
321 |
| - } |
322 |
| - }; |
323 |
| - |
324 |
| - final RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).build(); |
325 |
| - final RestChannel channel = new FakeRestChannel(request, randomBoolean(), 1); |
326 |
| - handler.handleRequest(request, channel, mockClient); |
327 |
| - assertTrue(executed.get()); |
328 |
| - } |
329 |
| - |
330 |
| - public void testUnconsumedBody() throws IOException { |
331 |
| - final AtomicBoolean executed = new AtomicBoolean(); |
332 |
| - final BaseRestHandler handler = new BaseRestHandler() { |
333 |
| - @Override |
334 |
| - protected RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { |
335 |
| - return channel -> executed.set(true); |
336 |
| - } |
337 |
| - |
338 |
| - @Override |
339 |
| - public String getName() { |
340 |
| - return "test_unconsumed_body"; |
341 |
| - } |
342 |
| - }; |
343 |
| - |
344 |
| - try (XContentBuilder builder = JsonXContent.contentBuilder().startObject().endObject()) { |
345 |
| - final RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withContent( |
346 |
| - new BytesArray(builder.toString()), |
347 |
| - MediaTypeRegistry.JSON |
348 |
| - ).build(); |
349 |
| - final RestChannel channel = new FakeRestChannel(request, randomBoolean(), 1); |
350 |
| - final IllegalArgumentException e = expectThrows( |
351 |
| - IllegalArgumentException.class, |
352 |
| - () -> handler.handleRequest(request, channel, mockClient) |
353 |
| - ); |
354 |
| - assertThat(e, hasToString(containsString("request [GET /] does not support having a body"))); |
355 |
| - assertFalse(executed.get()); |
356 |
| - } |
357 |
| - } |
358 |
| - |
359 | 280 | public void testReplaceRoutesMethod() throws Exception {
|
360 | 281 | List<Route> routes = Arrays.asList(new Route(Method.GET, "/path/test"), new Route(Method.PUT, "/path2/test"));
|
361 | 282 | List<ReplacedRoute> replacedRoutes = RestHandler.replaceRoutes(routes, "/prefix", "/deprecatedPrefix");
|
|
0 commit comments