From a1b7f981fbf4cad000da0f361939440dd773b9e1 Mon Sep 17 00:00:00 2001 From: Zoltan Haindrich Date: Tue, 28 May 2024 15:09:42 +0000 Subject: [PATCH] cleanup --- .../org/apache/druid/quidem/Launcher.java | 42 +++---------------- .../druid/quidem/DruidAvaticaDriverTest.java | 3 +- .../druid/quidem/DruidAvaticaTestDriver.java | 28 +------------ .../sql/calcite/SqlTestFrameworkConfig.java | 22 ++++++++++ 4 files changed, 31 insertions(+), 64 deletions(-) diff --git a/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java b/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java index 5cc9009c427..712f5d8ff06 100644 --- a/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java +++ b/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java @@ -26,23 +26,15 @@ import org.apache.druid.sql.calcite.SqlTestFrameworkConfig; import org.apache.druid.sql.calcite.SqlTestFrameworkConfig.ConfigurationInstance; import org.apache.druid.sql.calcite.SqlTestFrameworkConfig.SqlTestFrameworkConfigStore; import org.apache.druid.sql.calcite.util.SqlTestFramework; -import org.apache.http.NameValuePair; -import org.apache.http.client.utils.URLEncodedUtils; import org.junit.Test; import java.io.IOException; import java.net.URI; -import java.net.URISyntaxException; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; -import java.nio.charset.StandardCharsets; import java.sql.SQLException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import static org.junit.Assert.assertNotEquals; public class Launcher @@ -51,24 +43,6 @@ public class Launcher private static Logger log = new Logger(Launcher.class); - public static SqlTestFrameworkConfig buildConfigfromURIParams(String url) throws SQLException - { - Map queryParams; - queryParams = new HashMap<>(); - try { - List params = URLEncodedUtils.parse(new URI(url), StandardCharsets.UTF_8); - for (NameValuePair pair : params) { - queryParams.put(pair.getName(), pair.getValue()); - } - // possible caveat: duplicate entries overwrite earlier ones - } - catch (URISyntaxException e) { - throw new SQLException("Can't decode URI", e); - } - - return new SqlTestFrameworkConfig(queryParams); - } - @Test public void runIt() throws Exception { @@ -77,7 +51,7 @@ public class Launcher private static ConfigurationInstance getCI2() throws SQLException, Exception { - SqlTestFrameworkConfig config = buildConfigfromURIParams("druidtest:///"); + SqlTestFrameworkConfig config = SqlTestFrameworkConfig.fromURL("druidtest:///"); ConfigurationInstance ci = CONFIG_STORE.getConfigurationInstance( config, @@ -91,18 +65,14 @@ public class Launcher SqlTestFramework framework = getCI2().framework; - if (true) { - Lifecycle lifecycle = GuiceRunnable.initLifecycle(framework.injector(), log); + Lifecycle lifecycle = GuiceRunnable.initLifecycle(framework.injector(), log); - chk1(); - chkStatus(); + chk1(); + chkStatus(); - System.out.println("-------------------booted up-------------------"); + System.out.println("-------------------booted up-------------------"); - lifecycle.join(); - } else { - - } + lifecycle.join(); } diff --git a/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaDriverTest.java b/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaDriverTest.java index efdf782d147..3f039814c0f 100644 --- a/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaDriverTest.java +++ b/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaDriverTest.java @@ -19,6 +19,7 @@ package org.apache.druid.quidem; +import org.apache.druid.sql.calcite.SqlTestFrameworkConfig; import org.junit.jupiter.api.Test; import java.sql.Connection; @@ -51,6 +52,6 @@ public class DruidAvaticaDriverTest @Test public void testURIParse() throws SQLException { - DruidAvaticaTestDriver.buildConfigfromURIParams("druidtest:///"); + SqlTestFrameworkConfig.fromURL("druidtest:///"); } } diff --git a/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaTestDriver.java b/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaTestDriver.java index 74888c89607..a10c9015ec0 100644 --- a/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaTestDriver.java +++ b/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaTestDriver.java @@ -70,25 +70,17 @@ import org.apache.druid.sql.calcite.util.SqlTestFramework.Builder; import org.apache.druid.sql.calcite.util.SqlTestFramework.PlannerComponentSupplier; import org.apache.druid.sql.calcite.util.SqlTestFramework.QueryComponentSupplier; import org.apache.druid.sql.guice.SqlModule; -import org.apache.http.NameValuePair; import org.apache.http.client.utils.URIBuilder; -import org.apache.http.client.utils.URLEncodedUtils; import org.eclipse.jetty.server.Server; import java.io.Closeable; import java.io.File; import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; import java.sql.Connection; import java.sql.Driver; import java.sql.DriverManager; import java.sql.DriverPropertyInfo; import java.sql.SQLException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import java.util.Properties; import java.util.logging.Logger; @@ -114,7 +106,7 @@ public class DruidAvaticaTestDriver implements Driver return null; } try { - SqlTestFrameworkConfig config = buildConfigfromURIParams(url); + SqlTestFrameworkConfig config = SqlTestFrameworkConfig.fromURL(url); ConfigurationInstance ci = CONFIG_STORE.getConfigurationInstance( config, @@ -349,24 +341,6 @@ public class DruidAvaticaTestDriver implements Driver return tempDir; } - public static SqlTestFrameworkConfig buildConfigfromURIParams(String url) throws SQLException - { - Map queryParams; - queryParams = new HashMap<>(); - try { - List params = URLEncodedUtils.parse(new URI(url), StandardCharsets.UTF_8); - for (NameValuePair pair : params) { - queryParams.put(pair.getName(), pair.getValue()); - } - // possible caveat: duplicate entries overwrite earlier ones - } - catch (URISyntaxException e) { - throw new SQLException("Can't decode URI", e); - } - - return new SqlTestFrameworkConfig(queryParams); - } - private void register() { try { diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java b/sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java index 4ff8796b74b..6aee6d4084b 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java @@ -35,7 +35,9 @@ import org.apache.druid.sql.calcite.util.CacheTestHelperModule.ResultCacheMode; import org.apache.druid.sql.calcite.util.SqlTestFramework; import org.apache.druid.sql.calcite.util.SqlTestFramework.QueryComponentSupplier; import org.apache.druid.sql.calcite.util.SqlTestFramework.StandardComponentSupplier; +import org.apache.http.NameValuePair; import org.apache.http.client.utils.URIBuilder; +import org.apache.http.client.utils.URLEncodedUtils; import org.junit.jupiter.api.extension.AfterAllCallback; import org.junit.jupiter.api.extension.BeforeEachCallback; import org.junit.jupiter.api.extension.ExtensionContext; @@ -53,6 +55,8 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.URI; import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; +import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -417,6 +421,24 @@ public class SqlTestFrameworkConfig return map; } + public static SqlTestFrameworkConfig fromURL(String url) throws SQLException + { + Map queryParams; + queryParams = new HashMap<>(); + try { + List params = URLEncodedUtils.parse(new URI(url), StandardCharsets.UTF_8); + for (NameValuePair pair : params) { + queryParams.put(pair.getName(), pair.getValue()); + } + // possible caveat: duplicate entries overwrite earlier ones + } + catch (URISyntaxException e) { + throw new SQLException("Can't decode URI", e); + } + + return new SqlTestFrameworkConfig(queryParams); + } + abstract static class ConfigOptionProcessor { final Class annotationClass;