This is an automated email from the ASF dual-hosted git repository.

kfaraz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new d9bd137dec3 Migrate ITSqlQueryTest to embedded test suite (#18752)
d9bd137dec3 is described below

commit d9bd137dec3926d2c77e319b2749e1080a888cef
Author: Sasha Syrotenko <[email protected]>
AuthorDate: Wed Nov 19 16:26:36 2025 +0200

    Migrate ITSqlQueryTest to embedded test suite (#18752)
    
    * ITSqlQueryTest migration to embedded test suite
    * Post-submit cleanup
    * Add license
    * Checkstyle and rename
    * Post-review: cleanup
    * Better name for flags list
---
 .../auth/AbstractAuthConfigurationTest.java        |  12 -
 .../query/SqlQueryHttpRequestHeadersTest.java      | 349 +++++++++++++++++++++
 .../apache/druid/tests/query/ITSqlQueryTest.java   | 328 -------------------
 .../apache/druid/query/http/ClientSqlQuery.java    |   3 +
 .../embedded/junit5/EmbeddedClusterTestBase.java   |  16 +
 5 files changed, 368 insertions(+), 340 deletions(-)

diff --git 
a/embedded-tests/src/test/java/org/apache/druid/testing/embedded/auth/AbstractAuthConfigurationTest.java
 
b/embedded-tests/src/test/java/org/apache/druid/testing/embedded/auth/AbstractAuthConfigurationTest.java
index 429c4e31559..edead48abc8 100644
--- 
a/embedded-tests/src/test/java/org/apache/druid/testing/embedded/auth/AbstractAuthConfigurationTest.java
+++ 
b/embedded-tests/src/test/java/org/apache/druid/testing/embedded/auth/AbstractAuthConfigurationTest.java
@@ -38,7 +38,6 @@ import org.apache.druid.msq.dart.controller.sql.DartSqlEngine;
 import org.apache.druid.query.QueryContexts;
 import org.apache.druid.query.http.SqlTaskStatus;
 import org.apache.druid.segment.TestHelper;
-import org.apache.druid.server.DruidNode;
 import org.apache.druid.server.security.Access;
 import org.apache.druid.server.security.Action;
 import org.apache.druid.server.security.Resource;
@@ -48,7 +47,6 @@ import org.apache.druid.sql.avatica.DruidAvaticaJsonHandler;
 import org.apache.druid.testing.embedded.EmbeddedBroker;
 import org.apache.druid.testing.embedded.EmbeddedCoordinator;
 import org.apache.druid.testing.embedded.EmbeddedDruidCluster;
-import org.apache.druid.testing.embedded.EmbeddedDruidServer;
 import org.apache.druid.testing.embedded.EmbeddedHistorical;
 import org.apache.druid.testing.embedded.EmbeddedIndexer;
 import org.apache.druid.testing.embedded.EmbeddedOverlord;
@@ -1017,16 +1015,6 @@ public abstract class AbstractAuthConfigurationTest 
extends EmbeddedClusterTestB
   {
     return getServerUrl(broker);
   }
-  
-  private static String getServerUrl(EmbeddedDruidServer<?> server)
-  {
-    final DruidNode node = server.bindings().selfNode();
-    return StringUtils.format(
-        "http://%s:%s";,
-        node.getHost(),
-        node.getPlaintextPort()
-    );
-  }
 
   /**
    * curr_size on historicals changes because cluster state is not isolated 
across
diff --git 
a/embedded-tests/src/test/java/org/apache/druid/testing/embedded/query/SqlQueryHttpRequestHeadersTest.java
 
b/embedded-tests/src/test/java/org/apache/druid/testing/embedded/query/SqlQueryHttpRequestHeadersTest.java
new file mode 100644
index 00000000000..5914001163a
--- /dev/null
+++ 
b/embedded-tests/src/test/java/org/apache/druid/testing/embedded/query/SqlQueryHttpRequestHeadersTest.java
@@ -0,0 +1,349 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.testing.embedded.query;
+
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.java.util.http.client.HttpClient;
+import org.apache.druid.java.util.http.client.Request;
+import org.apache.druid.java.util.http.client.response.StatusResponseHandler;
+import org.apache.druid.java.util.http.client.response.StatusResponseHolder;
+import org.apache.druid.testing.embedded.EmbeddedBroker;
+import org.apache.druid.testing.embedded.EmbeddedCoordinator;
+import org.apache.druid.testing.embedded.EmbeddedDruidCluster;
+import org.apache.druid.testing.embedded.EmbeddedIndexer;
+import org.apache.druid.testing.embedded.EmbeddedOverlord;
+import org.apache.druid.testing.embedded.EmbeddedRouter;
+import org.apache.druid.testing.embedded.junit5.EmbeddedClusterTestBase;
+import org.jboss.netty.handler.codec.http.HttpMethod;
+import org.jboss.netty.handler.codec.http.HttpResponseStatus;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.FieldSource;
+
+import javax.ws.rs.core.MediaType;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+
+/**
+ * Suite to test various Content-Type headers attached
+ * to SQL query HTTP requests to brokers and routers.
+ */
+public class SqlQueryHttpRequestHeadersTest extends EmbeddedClusterTestBase
+{
+  private static final String SQL_QUERY_ROUTE = "%s/druid/v2/sql/";
+
+  public static List<Boolean> shouldUseQueryBroker = List.of(true, false);
+
+  private final EmbeddedBroker broker = new EmbeddedBroker();
+  private final EmbeddedRouter router = new EmbeddedRouter();
+
+  private HttpClient httpClientRef;
+  private String brokerEndpoint;
+  private String routerEndpoint;
+
+  @Override
+  protected EmbeddedDruidCluster createCluster()
+  {
+    return EmbeddedDruidCluster.withEmbeddedDerbyAndZookeeper()
+                               .useLatchableEmitter()
+                               .addServer(new EmbeddedOverlord())
+                               .addServer(new EmbeddedCoordinator())
+                               .addServer(broker)
+                               .addServer(router)
+                               .addServer(new EmbeddedIndexer());
+  }
+
+  @BeforeEach
+  void setUp()
+  {
+    httpClientRef = router.bindings().globalHttpClient();
+    brokerEndpoint = StringUtils.format(SQL_QUERY_ROUTE, getServerUrl(broker));
+    routerEndpoint = StringUtils.format(SQL_QUERY_ROUTE, getServerUrl(router));
+  }
+
+  private void executeQuery(
+      String endpoint,
+      String contentType,
+      String query,
+      Consumer<Request> onRequest,
+      BiConsumer<Integer, String> onResponse
+  )
+  {
+    URL url;
+    try {
+      url = new URL(endpoint);
+    }
+    catch (MalformedURLException e) {
+      throw new AssertionError("Malformed URL");
+    }
+
+    Request request = new Request(HttpMethod.POST, url);
+    if (contentType != null) {
+      request.addHeader("Content-Type", contentType);
+    }
+
+    if (query != null) {
+      request.setContent(query.getBytes(StandardCharsets.UTF_8));
+    }
+
+    if (onRequest != null) {
+      onRequest.accept(request);
+    }
+
+    StatusResponseHolder response;
+    try {
+      response = httpClientRef.go(request, StatusResponseHandler.getInstance())
+                              .get();
+    }
+    catch (InterruptedException | ExecutionException e) {
+      throw new AssertionError("Failed to execute a request", e);
+    }
+
+    Assertions.assertNotNull(response);
+
+    onResponse.accept(
+        response.getStatus().getCode(),
+        response.getContent().trim()
+    );
+  }
+
+  @ParameterizedTest
+  @FieldSource("shouldUseQueryBroker")
+  public void testNullContentType(boolean shouldQueryBroker)
+  {
+    executeQuery(
+        shouldQueryBroker ? brokerEndpoint : routerEndpoint,
+        null,
+        "select 1",
+        (request) -> {
+        },
+        (statusCode, responseBody) -> {
+          Assertions.assertEquals(statusCode, 
HttpResponseStatus.BAD_REQUEST.getCode());
+        }
+    );
+  }
+
+  @ParameterizedTest
+  @FieldSource("shouldUseQueryBroker")
+  public void testUnsupportedContentType(boolean shouldQueryBroker)
+  {
+    executeQuery(
+        shouldQueryBroker ? brokerEndpoint : routerEndpoint,
+        "application/xml",
+        "select 1",
+        (request) -> {
+        },
+        (statusCode, responseBody) -> {
+          Assertions.assertEquals(statusCode, 
HttpResponseStatus.UNSUPPORTED_MEDIA_TYPE.getCode());
+        }
+    );
+  }
+
+  @ParameterizedTest
+  @FieldSource("shouldUseQueryBroker")
+  public void testTextPlain(boolean shouldQueryBroker)
+  {
+    executeQuery(
+        shouldQueryBroker ? brokerEndpoint : routerEndpoint,
+        MediaType.TEXT_PLAIN,
+        "select \n1",
+        (request) -> {
+        },
+        (statusCode, responseBody) -> {
+          Assertions.assertEquals(200, statusCode);
+          Assertions.assertEquals("[{\"EXPR$0\":1}]", responseBody);
+        }
+    );
+  }
+
+  @ParameterizedTest
+  @FieldSource("shouldUseQueryBroker")
+  public void testFormURLEncoded(boolean shouldQueryBroker)
+  {
+    executeQuery(
+        shouldQueryBroker ? brokerEndpoint : routerEndpoint,
+        MediaType.APPLICATION_FORM_URLENCODED,
+        URLEncoder.encode("select 'x % y'", StandardCharsets.UTF_8),
+        (request) -> {
+        },
+        (statusCode, responseBody) -> {
+          Assertions.assertEquals(200, statusCode);
+          Assertions.assertEquals("[{\"EXPR$0\":\"x % y\"}]", responseBody);
+        }
+    );
+  }
+
+  @ParameterizedTest
+  @FieldSource("shouldUseQueryBroker")
+  public void testFormURLEncoded_InvalidEncoding(boolean shouldQueryBroker)
+  {
+    executeQuery(
+        shouldQueryBroker ? brokerEndpoint : routerEndpoint,
+        MediaType.APPLICATION_FORM_URLENCODED,
+        "select 'x % y'",
+        (request) -> {
+        },
+        (statusCode, responseBody) -> {
+          Assertions.assertEquals(400, statusCode);
+          Assertions.assertTrue(responseBody.contains("Unable to decode"));
+        }
+    );
+  }
+
+  @ParameterizedTest
+  @FieldSource("shouldUseQueryBroker")
+  public void testJSON(boolean shouldQueryBroker)
+  {
+    executeQuery(
+        shouldQueryBroker ? brokerEndpoint : routerEndpoint,
+        MediaType.APPLICATION_JSON,
+        "{\"query\":\"select 567\"}",
+        (request) -> {
+        },
+        (statusCode, responseBody) -> {
+          Assertions.assertEquals(200, statusCode);
+          Assertions.assertEquals("[{\"EXPR$0\":567}]", responseBody);
+        }
+    );
+
+    executeQuery(
+        shouldQueryBroker ? brokerEndpoint : routerEndpoint,
+        "application/json; charset=UTF-8",
+        "{\"query\":\"select 567\"}",
+        (request) -> {
+        },
+        (statusCode, responseBody) -> {
+          Assertions.assertEquals(200, statusCode);
+          Assertions.assertEquals("[{\"EXPR$0\":567}]", responseBody);
+        }
+    );
+  }
+
+  @ParameterizedTest
+  @FieldSource("shouldUseQueryBroker")
+  public void testInvalidJSONFormat(boolean shouldQueryBroker)
+  {
+    executeQuery(
+        shouldQueryBroker ? brokerEndpoint : routerEndpoint,
+        MediaType.APPLICATION_JSON,
+        "{\"query\":select 567}",
+        (request) -> {
+        },
+        (statusCode, responseBody) -> {
+          Assertions.assertEquals(400, statusCode);
+          Assertions.assertTrue(responseBody.contains("Malformed SQL query"));
+        }
+    );
+  }
+
+  @ParameterizedTest
+  @FieldSource("shouldUseQueryBroker")
+  public void testEmptyQuery_TextPlain(boolean shouldQueryBroker)
+  {
+    executeQuery(
+        shouldQueryBroker ? brokerEndpoint : routerEndpoint,
+        MediaType.TEXT_PLAIN,
+        null,
+        (request) -> {
+        },
+        (statusCode, responseBody) -> {
+          Assertions.assertEquals(400, statusCode);
+          Assertions.assertTrue(responseBody.contains("Empty query"));
+        }
+    );
+  }
+
+  @ParameterizedTest
+  @FieldSource("shouldUseQueryBroker")
+  public void testEmptyQuery_UrlEncoded(boolean shouldQueryBroker)
+  {
+    executeQuery(
+        shouldQueryBroker ? brokerEndpoint : routerEndpoint,
+        MediaType.APPLICATION_FORM_URLENCODED,
+        null,
+        (request) -> {
+        },
+        (statusCode, responseBody) -> {
+          Assertions.assertEquals(400, statusCode);
+          Assertions.assertTrue(responseBody.contains("Empty query"));
+        }
+    );
+  }
+
+  @ParameterizedTest
+  @FieldSource("shouldUseQueryBroker")
+  public void testBlankQuery_TextPlain(boolean shouldQueryBroker)
+  {
+    executeQuery(
+        shouldQueryBroker ? brokerEndpoint : routerEndpoint,
+        MediaType.TEXT_PLAIN,
+        "     ",
+        (request) -> {
+        },
+        (statusCode, responseBody) -> {
+          Assertions.assertEquals(400, statusCode);
+          Assertions.assertTrue(responseBody.contains("Empty query"));
+        }
+    );
+  }
+
+  @ParameterizedTest
+  @FieldSource("shouldUseQueryBroker")
+  public void testEmptyQuery_JSON(boolean shouldQueryBroker)
+  {
+    executeQuery(
+        shouldQueryBroker ? brokerEndpoint : routerEndpoint,
+        MediaType.APPLICATION_JSON,
+        null,
+        (request) -> {
+        },
+        (statusCode, responseBody) -> {
+          Assertions.assertEquals(400, statusCode);
+          Assertions.assertTrue(responseBody.contains("Empty query"));
+        }
+    );
+  }
+
+  @ParameterizedTest
+  @FieldSource("shouldUseQueryBroker")
+  public void testMultipleContentType_usesFirstOne(boolean shouldQueryBroker)
+  {
+    executeQuery(
+        shouldQueryBroker ? brokerEndpoint : routerEndpoint,
+        MediaType.TEXT_PLAIN,
+        "SELECT 1",
+        (request) -> {
+          // Add one more Content-Type header
+          request.addHeader("Content-Type", MediaType.APPLICATION_JSON);
+        },
+        (statusCode, responseBody) -> {
+          Assertions.assertEquals(200, statusCode);
+          Assertions.assertEquals("[{\"EXPR$0\":1}]", responseBody);
+        }
+    );
+  }
+}
diff --git 
a/integration-tests/src/test/java/org/apache/druid/tests/query/ITSqlQueryTest.java
 
b/integration-tests/src/test/java/org/apache/druid/tests/query/ITSqlQueryTest.java
deleted file mode 100644
index eb5480767a0..00000000000
--- 
a/integration-tests/src/test/java/org/apache/druid/tests/query/ITSqlQueryTest.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.druid.tests.query;
-
-import com.google.inject.Inject;
-import org.apache.druid.java.util.common.ISE;
-import org.apache.druid.java.util.common.StringUtils;
-import org.apache.druid.java.util.http.client.HttpClient;
-import org.apache.druid.java.util.http.client.Request;
-import org.apache.druid.java.util.http.client.response.StatusResponseHandler;
-import org.apache.druid.java.util.http.client.response.StatusResponseHolder;
-import org.apache.druid.testing.guice.DruidTestModuleFactory;
-import org.apache.druid.testing.guice.TestClient;
-import org.apache.druid.testing.tools.ITRetryUtil;
-import org.apache.druid.testing.tools.IntegrationTestingConfig;
-import org.apache.druid.tests.TestNGGroup;
-import org.jboss.netty.handler.codec.http.HttpMethod;
-import org.jboss.netty.handler.codec.http.HttpResponseStatus;
-import org.testng.Assert;
-import org.testng.annotations.Guice;
-import org.testng.annotations.Test;
-
-import javax.ws.rs.core.MediaType;
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-import java.util.function.Function;
-
-/**
- * Test the SQL endpoint with different Content-Type
- */
-@Test(groups = {TestNGGroup.QUERY})
-@Guice(moduleFactory = DruidTestModuleFactory.class)
-public class ITSqlQueryTest
-{
-  @Inject
-  IntegrationTestingConfig config;
-
-  @Inject
-  @TestClient
-  HttpClient httpClient;
-
-  interface IExecutable
-  {
-    void execute(String endpoint) throws Exception;
-  }
-
-  interface OnRequest
-  {
-    void on(Request request) throws IOException;
-  }
-
-  interface OnResponse
-  {
-    void on(int statusCode, String response) throws IOException;
-  }
-
-  private void executeWithRetry(String endpoint, String contentType, 
IExecutable executable)
-  {
-    // Retry 5 times with 200 ms delay
-    ITRetryUtil.retryUntilEquals(
-        () -> {
-          executable.execute(endpoint);
-          return true;
-        }, true,
-        200,
-        5,
-        StringUtils.format("Query to %s with Content-Type = %s", endpoint, 
contentType)
-    );
-  }
-
-  private void executeQuery(
-      String contentType,
-      String query,
-      OnRequest onRequest,
-      OnResponse onResponse
-  )
-  {
-    IExecutable executable = (endpoint) -> {
-      Request request = new Request(HttpMethod.POST, new URL(endpoint));
-      if (contentType != null) {
-        request.addHeader("Content-Type", contentType);
-      }
-
-      if (query != null) {
-        request.setContent(query.getBytes(StandardCharsets.UTF_8));
-      }
-
-      if (onRequest != null) {
-        onRequest.on(request);
-      }
-
-      StatusResponseHolder response = httpClient.go(request, 
StatusResponseHandler.getInstance())
-                                                .get();
-      Assert.assertNotNull(response);
-
-      onResponse.on(
-          response.getStatus().getCode(),
-          response.getContent().trim()
-      );
-    };
-
-    // Send query to broker to exeucte
-    executeWithRetry(StringUtils.format("%s/druid/v2/sql/", 
config.getBrokerUrl()), contentType, executable);
-
-    // Send query to router to execute
-    executeWithRetry(StringUtils.format("%s/druid/v2/sql/", 
config.getRouterUrl()), contentType, executable);
-  }
-
-  private void assertStringCompare(String expected, String actual, 
Function<String, Boolean> predicate)
-  {
-    if (!predicate.apply(expected)) {
-      throw new ISE("Expected: [%s] but got [%s]", expected, actual);
-    }
-  }
-
-  @Test
-  public void testNullContentType()
-  {
-    executeQuery(
-        null,
-        "select 1",
-        (request) -> {
-        },
-        (statusCode, responseBody) -> {
-          Assert.assertEquals(statusCode, 
HttpResponseStatus.BAD_REQUEST.getCode(), responseBody);
-        }
-    );
-  }
-
-  @Test
-  public void testUnsupportedContentType()
-  {
-    executeQuery(
-        "application/xml",
-        "select 1",
-        (request) -> {
-        },
-        (statusCode, responseBody) -> {
-          Assert.assertEquals(statusCode, 
HttpResponseStatus.UNSUPPORTED_MEDIA_TYPE.getCode(), responseBody);
-        }
-    );
-  }
-
-  @Test
-  public void testTextPlain()
-  {
-    executeQuery(
-        MediaType.TEXT_PLAIN,
-        "select \n1",
-        (request) -> {
-        },
-        (statusCode, responseBody) -> {
-          Assert.assertEquals(statusCode, 200, responseBody);
-          Assert.assertEquals(responseBody, "[{\"EXPR$0\":1}]");
-        }
-    );
-  }
-
-  @Test
-  public void testFormURLEncoded()
-  {
-    executeQuery(
-        MediaType.APPLICATION_FORM_URLENCODED,
-        URLEncoder.encode("select 'x % y'", StandardCharsets.UTF_8),
-        (request) -> {
-        },
-        (statusCode, responseBody) -> {
-          Assert.assertEquals(statusCode, 200, responseBody);
-          Assert.assertEquals(responseBody, "[{\"EXPR$0\":\"x % y\"}]");
-        }
-    );
-  }
-
-  @Test
-  public void testFormURLEncoded_InvalidEncoding()
-  {
-    executeQuery(
-        MediaType.APPLICATION_FORM_URLENCODED,
-        "select 'x % y'",
-        (request) -> {
-        },
-        (statusCode, responseBody) -> {
-          Assert.assertEquals(statusCode, 400, responseBody);
-          assertStringCompare("Unable to decode", responseBody, 
responseBody::contains);
-        }
-    );
-  }
-
-  @Test
-  public void testJSON()
-  {
-    executeQuery(
-        MediaType.APPLICATION_JSON,
-        "{\"query\":\"select 567\"}",
-        (request) -> {
-        },
-        (statusCode, responseBody) -> {
-          Assert.assertEquals(statusCode, 200, responseBody);
-          Assert.assertEquals(responseBody, "[{\"EXPR$0\":567}]");
-        }
-    );
-
-    executeQuery(
-        "application/json; charset=UTF-8",
-        "{\"query\":\"select 567\"}",
-        (request) -> {
-        },
-        (statusCode, responseBody) -> {
-          Assert.assertEquals(statusCode, 200, responseBody);
-          Assert.assertEquals(responseBody, "[{\"EXPR$0\":567}]");
-        }
-    );
-  }
-
-  @Test
-  public void testInvalidJSONFormat()
-  {
-    executeQuery(
-        MediaType.APPLICATION_JSON,
-        "{\"query\":select 567}",
-        (request) -> {
-        },
-        (statusCode, responseBody) -> {
-          Assert.assertEquals(statusCode, 400, responseBody);
-          assertStringCompare("Malformed SQL query", responseBody, 
responseBody::contains);
-        }
-    );
-  }
-
-  @Test
-  public void testEmptyQuery_TextPlain()
-  {
-    executeQuery(
-        MediaType.TEXT_PLAIN,
-        null,
-        (request) -> {
-        },
-        (statusCode, responseBody) -> {
-          Assert.assertEquals(statusCode, 400, responseBody);
-          assertStringCompare("Empty query", responseBody, 
responseBody::contains);
-        }
-    );
-  }
-
-  @Test
-  public void testEmptyQuery_UrlEncoded()
-  {
-    executeQuery(
-        MediaType.APPLICATION_FORM_URLENCODED,
-        null,
-        (request) -> {
-        },
-        (statusCode, responseBody) -> {
-          Assert.assertEquals(statusCode, 400, responseBody);
-          assertStringCompare("Empty query", responseBody, 
responseBody::contains);
-        }
-    );
-  }
-
-  @Test
-  public void testBlankQuery_TextPlain()
-  {
-    executeQuery(
-        MediaType.TEXT_PLAIN,
-        "     ",
-        (request) -> {
-        },
-        (statusCode, responseBody) -> {
-          Assert.assertEquals(statusCode, 400, responseBody);
-          assertStringCompare("Empty query", responseBody, 
responseBody::contains);
-        }
-    );
-  }
-
-  @Test
-  public void testEmptyQuery_JSON()
-  {
-    executeQuery(
-        MediaType.APPLICATION_JSON,
-        null,
-        (request) -> {
-        },
-        (statusCode, responseBody) -> {
-          Assert.assertEquals(statusCode, 400, responseBody);
-          assertStringCompare("Empty query", responseBody, 
responseBody::contains);
-        }
-    );
-  }
-
-  /**
-   * When multiple Content-Type headers are set, the first one (in this case, 
it's the text format) should be used.
-   */
-  @Test
-  public void testMultipleContentType()
-  {
-    executeQuery(
-        MediaType.TEXT_PLAIN,
-        "SELECT 1",
-        (request) -> {
-          // Add one more Content-Type header
-          request.addHeader("Content-Type", MediaType.APPLICATION_JSON);
-        },
-        (statusCode, responseBody) -> {
-          Assert.assertEquals(statusCode, 200, responseBody);
-          Assert.assertEquals(responseBody, "[{\"EXPR$0\":1}]");
-        }
-    );
-  }
-}
diff --git 
a/processing/src/main/java/org/apache/druid/query/http/ClientSqlQuery.java 
b/processing/src/main/java/org/apache/druid/query/http/ClientSqlQuery.java
index 663714b4d90..83484551b5d 100644
--- a/processing/src/main/java/org/apache/druid/query/http/ClientSqlQuery.java
+++ b/processing/src/main/java/org/apache/druid/query/http/ClientSqlQuery.java
@@ -39,6 +39,9 @@ public class ClientSqlQuery
   @JsonProperty
   private final String resultFormat;
 
+  /**
+   * Indicates whether the query result should include a header.
+   */
   @JsonProperty
   private final boolean header;
 
diff --git 
a/services/src/test/java/org/apache/druid/testing/embedded/junit5/EmbeddedClusterTestBase.java
 
b/services/src/test/java/org/apache/druid/testing/embedded/junit5/EmbeddedClusterTestBase.java
index 69ed752642e..09bbc097546 100644
--- 
a/services/src/test/java/org/apache/druid/testing/embedded/junit5/EmbeddedClusterTestBase.java
+++ 
b/services/src/test/java/org/apache/druid/testing/embedded/junit5/EmbeddedClusterTestBase.java
@@ -19,8 +19,11 @@
 
 package org.apache.druid.testing.embedded.junit5;
 
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.server.DruidNode;
 import org.apache.druid.testing.embedded.EmbeddedClusterApis;
 import org.apache.druid.testing.embedded.EmbeddedDruidCluster;
+import org.apache.druid.testing.embedded.EmbeddedDruidServer;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
@@ -53,6 +56,19 @@ public abstract class EmbeddedClusterTestBase
    */
   protected String dataSource;
 
+  /**
+   * Returns the URL of the requested server.
+   */
+  protected static String getServerUrl(EmbeddedDruidServer<?> server)
+  {
+    final DruidNode node = server.bindings().selfNode();
+    return StringUtils.format(
+        "http://%s:%s";,
+        node.getHost(),
+        node.getPlaintextPort()
+    );
+  }
+
   /**
    * Creates the cluster to be used in this test class. This method is invoked
    * only once before any of the {@code @Test} methods have run.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to