diff --git a/quidem-ut/pom.xml b/quidem-ut/pom.xml
index b936d54169a2..82c2352d0c8e 100644
--- a/quidem-ut/pom.xml
+++ b/quidem-ut/pom.xml
@@ -449,19 +449,10 @@
org.junit.jupiter
junit-jupiter
-
- org.junit.vintage
- junit-vintage-engine
- test
-
org.junit.jupiter
junit-jupiter-api
-
- junit
- junit
-
org.apache.calcite.avatica
avatica
@@ -494,12 +485,12 @@
org.hamcrest
hamcrest
- compile
+ test
org.hamcrest
hamcrest-core
- compile
+ test
org.mockito
diff --git a/quidem-ut/src/test/java/org/apache/druid/quidem/LauncherSmokeTest.java b/quidem-ut/src/test/java/org/apache/druid/quidem/LauncherSmokeTest.java
index 6402cd63e433..5e726da11824 100644
--- a/quidem-ut/src/test/java/org/apache/druid/quidem/LauncherSmokeTest.java
+++ b/quidem-ut/src/test/java/org/apache/druid/quidem/LauncherSmokeTest.java
@@ -26,26 +26,25 @@
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
-import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class LauncherSmokeTest
{
private static Launcher launcher;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception
{
launcher = new Launcher("druidtest:///");
launcher.start();
}
- @AfterClass
+ @AfterAll
public static void tearDown()
{
launcher.shutdown();
@@ -71,6 +70,6 @@ public void chkStatusWorks() throws Exception
CloseableHttpResponse response = client.execute(request);
assertEquals(200, response.getStatusLine().getStatusCode());
String responseStr = EntityUtils.toString(response.getEntity());
- MatcherAssert.assertThat(responseStr, Matchers.containsString("\"version\":\""));
+ Assertions.assertTrue(responseStr.contains("\"version\":\""));
}
}
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 3f039814c0f5..2593f3d579eb 100644
--- a/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaDriverTest.java
+++ b/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaDriverTest.java
@@ -28,9 +28,9 @@
import java.sql.SQLException;
import java.sql.Statement;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class DruidAvaticaDriverTest
{
diff --git a/sql/src/test/java/org/apache/druid/quidem/DruidQuidemCommandHandler.java b/sql/src/test/java/org/apache/druid/quidem/DruidQuidemCommandHandler.java
index af52f4feb57e..ad09ff1fb4f3 100644
--- a/sql/src/test/java/org/apache/druid/quidem/DruidQuidemCommandHandler.java
+++ b/sql/src/test/java/org/apache/druid/quidem/DruidQuidemCommandHandler.java
@@ -52,7 +52,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static org.junit.Assume.assumeFalse;
+import static org.junit.jupiter.api.Assumptions.assumeFalse;
public class DruidQuidemCommandHandler implements CommandHandler
{
@@ -357,7 +357,7 @@ public final void execute(Context context, boolean execute)
try {
Injector injector = DruidConnectionExtras.unwrapOrThrow(context.connection()).getInjector();
SqlTestFrameworkConfig cfg = injector.getInstance(SqlTestFrameworkConfig.class);
- assumeFalse(message, cfg.componentSupplier.getSimpleName().equals(supplierName));
+ assumeFalse(cfg.componentSupplier.getSimpleName().equals(supplierName), message);
}
catch (Exception e) {
// This is packaged as an Error because Quidem grabs anything else and pushes it into the output file
diff --git a/sql/src/test/java/org/apache/druid/quidem/DruidQuidemTestBase.java b/sql/src/test/java/org/apache/druid/quidem/DruidQuidemTestBase.java
index 4f5e03885aa2..7da83f33180d 100644
--- a/sql/src/test/java/org/apache/druid/quidem/DruidQuidemTestBase.java
+++ b/sql/src/test/java/org/apache/druid/quidem/DruidQuidemTestBase.java
@@ -40,11 +40,11 @@
import org.apache.druid.sql.calcite.MultiComponentSupplier;
import org.apache.druid.sql.calcite.SqlTestFrameworkConfig;
import org.apache.druid.sql.calcite.util.SqlTestFramework.QueryComponentSupplier;
-import org.junit.AssumptionViolatedException;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
+import org.opentest4j.TestAbortedException;
import java.io.File;
import java.io.FileNotFoundException;
@@ -323,10 +323,10 @@ public void test(QuidemTestCaseConfiguration testConfig) throws Exception
druidQuidemRunner.run(inFile, outFile, testConfig.componentSupplierName);
}
catch (Error e) {
- // This catch is needed to workaround the way Quidem currently handles AssumptionViolatedException
+ // This catch is needed to workaround the way Quidem currently handles TestAbortedException
Throwable cause = e.getCause();
- if (cause != null && cause instanceof AssumptionViolatedException) {
- AssumptionViolatedException assumptionViolatedException = (AssumptionViolatedException) cause;
+ if (cause != null && cause instanceof TestAbortedException) {
+ TestAbortedException assumptionViolatedException = (TestAbortedException) cause;
throw assumptionViolatedException;
}
throw e;
diff --git a/sql/src/test/java/org/apache/druid/sql/SqlLifecycleManagerTest.java b/sql/src/test/java/org/apache/druid/sql/SqlLifecycleManagerTest.java
index 74d5439fcec4..59b8c77860f9 100644
--- a/sql/src/test/java/org/apache/druid/sql/SqlLifecycleManagerTest.java
+++ b/sql/src/test/java/org/apache/druid/sql/SqlLifecycleManagerTest.java
@@ -22,9 +22,9 @@
import com.google.common.collect.ImmutableList;
import org.apache.druid.server.security.ResourceAction;
import org.apache.druid.sql.SqlLifecycleManager.Cancelable;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.List;
@@ -34,7 +34,7 @@ public class SqlLifecycleManagerTest
{
private SqlLifecycleManager lifecycleManager;
- @Before
+ @BeforeEach
public void setup()
{
lifecycleManager = new SqlLifecycleManager();
@@ -46,7 +46,7 @@ public void testAddAuthorizedLifecycle()
final String sqlId = "sqlId";
Cancelable lifecycle = mockLifecycle();
lifecycleManager.add(sqlId, lifecycle);
- Assert.assertEquals(ImmutableList.of(lifecycle), lifecycleManager.getAll(sqlId));
+ Assertions.assertEquals(ImmutableList.of(lifecycle), lifecycleManager.getAll(sqlId));
}
@Test
@@ -55,9 +55,9 @@ public void testRemoveValidLifecycle()
final String sqlId = "sqlId";
Cancelable lifecycle = mockLifecycle();
lifecycleManager.add(sqlId, lifecycle);
- Assert.assertEquals(ImmutableList.of(lifecycle), lifecycleManager.getAll(sqlId));
+ Assertions.assertEquals(ImmutableList.of(lifecycle), lifecycleManager.getAll(sqlId));
lifecycleManager.remove(sqlId, lifecycle);
- Assert.assertEquals(ImmutableList.of(), lifecycleManager.getAll(sqlId));
+ Assertions.assertEquals(ImmutableList.of(), lifecycleManager.getAll(sqlId));
}
@Test
@@ -66,9 +66,9 @@ public void testRemoveInvalidSqlQueryId()
final String sqlId = "sqlId";
Cancelable lifecycle = mockLifecycle();
lifecycleManager.add(sqlId, lifecycle);
- Assert.assertEquals(ImmutableList.of(lifecycle), lifecycleManager.getAll(sqlId));
+ Assertions.assertEquals(ImmutableList.of(lifecycle), lifecycleManager.getAll(sqlId));
lifecycleManager.remove("invalid", lifecycle);
- Assert.assertEquals(ImmutableList.of(lifecycle), lifecycleManager.getAll(sqlId));
+ Assertions.assertEquals(ImmutableList.of(lifecycle), lifecycleManager.getAll(sqlId));
}
@Test
@@ -77,9 +77,9 @@ public void testRemoveValidSqlQueryIdDifferntLifecycleObject()
final String sqlId = "sqlId";
Cancelable lifecycle = mockLifecycle();
lifecycleManager.add(sqlId, lifecycle);
- Assert.assertEquals(ImmutableList.of(lifecycle), lifecycleManager.getAll(sqlId));
+ Assertions.assertEquals(ImmutableList.of(lifecycle), lifecycleManager.getAll(sqlId));
lifecycleManager.remove(sqlId, mockLifecycle());
- Assert.assertEquals(ImmutableList.of(lifecycle), lifecycleManager.getAll(sqlId));
+ Assertions.assertEquals(ImmutableList.of(lifecycle), lifecycleManager.getAll(sqlId));
}
@Test
@@ -92,9 +92,9 @@ public void testRemoveAllValidSqlQueryIdSubsetOfLifecycles()
mockLifecycle()
);
lifecycles.forEach(lifecycle -> lifecycleManager.add(sqlId, lifecycle));
- Assert.assertEquals(lifecycles, lifecycleManager.getAll(sqlId));
+ Assertions.assertEquals(lifecycles, lifecycleManager.getAll(sqlId));
lifecycleManager.removeAll(sqlId, ImmutableList.of(lifecycles.get(0), lifecycles.get(1)));
- Assert.assertEquals(ImmutableList.of(lifecycles.get(2)), lifecycleManager.getAll(sqlId));
+ Assertions.assertEquals(ImmutableList.of(lifecycles.get(2)), lifecycleManager.getAll(sqlId));
}
@Test
@@ -107,9 +107,9 @@ public void testRemoveAllInvalidSqlQueryId()
mockLifecycle()
);
lifecycles.forEach(lifecycle -> lifecycleManager.add(sqlId, lifecycle));
- Assert.assertEquals(lifecycles, lifecycleManager.getAll(sqlId));
+ Assertions.assertEquals(lifecycles, lifecycleManager.getAll(sqlId));
lifecycleManager.removeAll("invalid", ImmutableList.of(lifecycles.get(0), lifecycles.get(1)));
- Assert.assertEquals(lifecycles, lifecycleManager.getAll(sqlId));
+ Assertions.assertEquals(lifecycles, lifecycleManager.getAll(sqlId));
}
@Test
@@ -124,8 +124,8 @@ public void testGetAllReturnsListCopy()
lifecycles.forEach(lifecycle -> lifecycleManager.add(sqlId, lifecycle));
final List lifecyclesFromGetAll = lifecycleManager.getAll(sqlId);
lifecycleManager.removeAll(sqlId, lifecyclesFromGetAll);
- Assert.assertEquals(lifecycles, lifecyclesFromGetAll);
- Assert.assertTrue(lifecycleManager.getAll(sqlId).isEmpty());
+ Assertions.assertEquals(lifecycles, lifecyclesFromGetAll);
+ Assertions.assertTrue(lifecycleManager.getAll(sqlId).isEmpty());
}
private static Cancelable mockLifecycle()
diff --git a/sql/src/test/java/org/apache/druid/sql/SqlQueryPlusTest.java b/sql/src/test/java/org/apache/druid/sql/SqlQueryPlusTest.java
index 1c793b9ef559..252460f65fe8 100644
--- a/sql/src/test/java/org/apache/druid/sql/SqlQueryPlusTest.java
+++ b/sql/src/test/java/org/apache/druid/sql/SqlQueryPlusTest.java
@@ -23,8 +23,8 @@
import org.apache.druid.error.DruidExceptionMatcher;
import org.apache.druid.sql.calcite.util.CalciteTests;
import org.hamcrest.MatcherAssert;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Map;
@@ -34,7 +34,7 @@ public class SqlQueryPlusTest
public void testSyntaxError()
{
// SqlQueryPlus throws parse errors on build() if the statement is invalid
- final DruidException e = Assert.assertThrows(
+ final DruidException e = Assertions.assertThrows(
DruidException.class,
() -> SqlQueryPlus.builder("SELECT COUNT(*) AS cnt, 'foo' AS")
.auth(CalciteTests.REGULAR_USER_AUTH_RESULT)
@@ -59,7 +59,7 @@ public void testSyntaxErrorJdbc()
.buildJdbc();
// It does throw exceptions on freshCopy(), though.
- final DruidException e = Assert.assertThrows(
+ final DruidException e = Assertions.assertThrows(
DruidException.class,
sqlQueryPlus::freshCopy
);
@@ -83,24 +83,24 @@ public void testUserProvidedContextOverridesSystemDefault()
.queryContext(userProvidedContext)
.auth(CalciteTests.REGULAR_USER_AUTH_RESULT);
- Assert.assertEquals(
+ Assertions.assertEquals(
Map.of("key", "user-provided-value", "key2", "system-default2"),
sqlQueryPlusBuilder.build().context()
);
- Assert.assertEquals(
+ Assertions.assertEquals(
Map.of("key", "user-provided-value", "key2", "system-default2"),
sqlQueryPlusBuilder.buildJdbc().context()
);
- Assert.assertEquals(
+ Assertions.assertEquals(
Map.of("key", "user-provided-value", "key2", "system-default2"),
sqlQueryPlusBuilder.build().withContext(systemDefaultContext, userProvidedContext).context()
);
- Assert.assertEquals(
+ Assertions.assertEquals(
Map.of("key", "system-default", "key2", "system-default2"),
sqlQueryPlusBuilder.build().withContext(systemDefaultContext, Map.of()).context()
);
- Assert.assertEquals(
+ Assertions.assertEquals(
Map.of("key", "user-provided-value"),
sqlQueryPlusBuilder.build().withContext(Map.of(), userProvidedContext).context()
);
diff --git a/sql/src/test/java/org/apache/druid/sql/SqlRowTransformerTest.java b/sql/src/test/java/org/apache/druid/sql/SqlRowTransformerTest.java
index 5286df34d6b7..bb0244636659 100644
--- a/sql/src/test/java/org/apache/druid/sql/SqlRowTransformerTest.java
+++ b/sql/src/test/java/org/apache/druid/sql/SqlRowTransformerTest.java
@@ -32,7 +32,7 @@
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.ISODateTimeFormat;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -84,7 +84,7 @@ public void testTransformUTC()
expectedRow[2],
null
};
- Assert.assertArrayEquals(
+ Assertions.assertArrayEquals(
expectedRow,
IntStream.range(0, expectedRow.length).mapToObj(i -> transformer.transform(row, i)).toArray()
);
@@ -112,7 +112,7 @@ public void testTransformNonUTC()
expectedRow[2],
null
};
- Assert.assertArrayEquals(
+ Assertions.assertArrayEquals(
expectedRow,
IntStream.range(0, expectedRow.length).mapToObj(i -> transformer.transform(row, i)).toArray()
);
@@ -126,7 +126,7 @@ public void testGetFieldList()
rowType
);
- Assert.assertEquals(
+ Assertions.assertEquals(
rowType.getFieldList().stream().map(RelDataTypeField::getName).collect(Collectors.toList()),
transformer.getFieldList()
);
diff --git a/sql/src/test/java/org/apache/druid/sql/SqlStatementTest.java b/sql/src/test/java/org/apache/druid/sql/SqlStatementTest.java
index 8856a19331f3..0f39507d0ab6 100644
--- a/sql/src/test/java/org/apache/druid/sql/SqlStatementTest.java
+++ b/sql/src/test/java/org/apache/druid/sql/SqlStatementTest.java
@@ -62,19 +62,21 @@
import org.apache.druid.sql.calcite.planner.PrepareResult;
import org.apache.druid.sql.calcite.schema.DruidSchemaCatalog;
import org.apache.druid.sql.calcite.util.CalciteTests;
+import org.apache.druid.sql.calcite.util.SqlTestQueryStack;
import org.apache.druid.sql.hook.DruidHookDispatcher;
import org.easymock.EasyMock;
import org.hamcrest.MatcherAssert;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import javax.servlet.http.HttpServletRequest;
+
+import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
@@ -82,19 +84,19 @@
import java.util.concurrent.TimeUnit;
import static org.apache.druid.sql.calcite.BaseCalciteQueryTest.assertResultsEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
public class SqlStatementTest
{
private static QueryRunnerFactoryConglomerate conglomerate;
private static SpecificSegmentsQuerySegmentWalker walker;
private static Closer resourceCloser;
- @ClassRule
- public static TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @TempDir
+ public static File temporaryFolder;
private ListeningExecutorService executorService;
private final DefaultQueryConfig defaultQueryConfig = new DefaultQueryConfig(
ImmutableMap.of("DEFAULT_KEY", "DEFAULT_VALUE"));
@@ -102,11 +104,11 @@ public class SqlStatementTest
private PolicyEnforcer policyEnforcer;
private SqlStatementFactory sqlStatementFactory;
- @BeforeClass
- public static void setUpClass() throws Exception
+ @BeforeAll
+ public static void setUpClass()
{
resourceCloser = Closer.create();
- conglomerate = QueryStackTests.createQueryRunnerFactoryConglomerate(resourceCloser);
+ conglomerate = SqlTestQueryStack.createQueryRunnerFactoryConglomerate(resourceCloser);
final QueryScheduler scheduler = new QueryScheduler(
5,
@@ -125,17 +127,17 @@ public Sequence run(Query> query, Sequence resultSequence)
}
};
- walker = CalciteTests.createMockWalker(conglomerate, temporaryFolder.newFolder(), scheduler);
+ walker = CalciteTests.createMockWalker(conglomerate, temporaryFolder, scheduler);
resourceCloser.register(walker);
}
- @AfterClass
+ @AfterAll
public static void tearDownClass() throws IOException
{
resourceCloser.close();
}
- @Before
+ @BeforeEach
public void setUp()
{
executorService = MoreExecutors.listeningDecorator(Execs.multiThreaded(8, "test_sql_resource_%s"));
@@ -144,7 +146,7 @@ public void setUp()
this.sqlStatementFactory = buildSqlStatementFactory();
}
- @After
+ @AfterEach
public void tearDown() throws Exception
{
executorService.shutdownNow();
@@ -254,11 +256,11 @@ public void testDirectPolicyEnforcerThrowsForNoPolicy()
);
DirectStatement stmt = sqlStatementFactory.directStatement(sqlReq);
ResultSet resultSet = stmt.plan();
- DruidException e = Assert.assertThrows(DruidException.class, () -> resultSet.run());
+ DruidException e = Assertions.assertThrows(DruidException.class, () -> resultSet.run());
- Assert.assertEquals(DruidException.Category.FORBIDDEN, e.getCategory());
- Assert.assertEquals(DruidException.Persona.OPERATOR, e.getTargetPersona());
- Assert.assertEquals("Failed security validation with dataSource [foo]", e.getMessage());
+ Assertions.assertEquals(DruidException.Category.FORBIDDEN, e.getCategory());
+ Assertions.assertEquals(DruidException.Persona.OPERATOR, e.getTargetPersona());
+ Assertions.assertEquals("Failed security validation with dataSource [foo]", e.getMessage());
}
@Test
@@ -390,11 +392,11 @@ public void testHttpPolicyEnforcerThrowsForNoPolicy() throws Exception
request(true)
);
ResultSet resultSet = stmt.plan();
- DruidException e = Assert.assertThrows(DruidException.class, () -> resultSet.run());
+ DruidException e = Assertions.assertThrows(DruidException.class, () -> resultSet.run());
- Assert.assertEquals(DruidException.Category.FORBIDDEN, e.getCategory());
- Assert.assertEquals(DruidException.Persona.OPERATOR, e.getTargetPersona());
- Assert.assertEquals("Failed security validation with dataSource [foo]", e.getMessage());
+ Assertions.assertEquals(DruidException.Category.FORBIDDEN, e.getCategory());
+ Assertions.assertEquals(DruidException.Persona.OPERATOR, e.getTargetPersona());
+ Assertions.assertEquals("Failed security validation with dataSource [foo]", e.getMessage());
}
@Test
@@ -495,11 +497,11 @@ public void testPreparePolicyEnforcerThrowsForNoPolicy()
CalciteTests.REGULAR_USER_AUTH_RESULT
);
PreparedStatement stmt = sqlStatementFactory.preparedStatement(sqlReq);
- DruidException e = Assert.assertThrows(DruidException.class, () -> stmt.execute(Collections.emptyList(), null).execute());
+ DruidException e = Assertions.assertThrows(DruidException.class, () -> stmt.execute(Collections.emptyList(), null).execute());
- Assert.assertEquals(DruidException.Category.FORBIDDEN, e.getCategory());
- Assert.assertEquals(DruidException.Persona.OPERATOR, e.getTargetPersona());
- Assert.assertEquals("Failed security validation with dataSource [foo]", e.getMessage());
+ Assertions.assertEquals(DruidException.Category.FORBIDDEN, e.getCategory());
+ Assertions.assertEquals(DruidException.Persona.OPERATOR, e.getTargetPersona());
+ Assertions.assertEquals("Failed security validation with dataSource [foo]", e.getMessage());
}
@Test
@@ -532,7 +534,7 @@ public void testIgnoredQueryContextParametersAreIgnored()
DirectStatement stmt = sqlStatementFactory.directStatement(sqlReq);
Map context = stmt.context();
// should contain only query id, not bySegment since it is not valid for SQL
- Assert.assertEquals(Collections.singleton(QueryContexts.CTX_SQL_QUERY_ID), context.keySet());
+ Assertions.assertEquals(Collections.singleton(QueryContexts.CTX_SQL_QUERY_ID), context.keySet());
}
private SqlStatementFactory buildSqlStatementFactory()
diff --git a/sql/src/test/java/org/apache/druid/sql/avatica/AvaticaModuleTest.java b/sql/src/test/java/org/apache/druid/sql/avatica/AvaticaModuleTest.java
index 1918736af32f..ec1554c3f25e 100644
--- a/sql/src/test/java/org/apache/druid/sql/avatica/AvaticaModuleTest.java
+++ b/sql/src/test/java/org/apache/druid/sql/avatica/AvaticaModuleTest.java
@@ -32,22 +32,21 @@
import org.apache.druid.java.util.metrics.Monitor;
import org.apache.druid.server.DruidNode;
import org.easymock.EasyMock;
-import org.easymock.EasyMockRunner;
+import org.easymock.EasyMockExtension;
import org.easymock.Mock;
import org.eclipse.jetty.server.Handler;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import javax.validation.Validation;
import javax.validation.Validator;
+
import java.util.Properties;
import java.util.Set;
-@RunWith(EasyMockRunner.class)
+@ExtendWith(EasyMockExtension.class)
public class AvaticaModuleTest
{
private static final String HOST_AND_PORT = "HOST_AND_PORT";
@@ -57,13 +56,10 @@ public class AvaticaModuleTest
@Mock
private DruidMeta druidMeta;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
private AvaticaModule target;
private Injector injector;
- @Before
+ @BeforeEach
public void setUp()
{
EasyMock.expect(druidNode.getHostAndPortToUse()).andStubReturn(HOST_AND_PORT);
@@ -85,9 +81,9 @@ public void setUp()
public void testAvaticaMonitorIsInjectedAsSingleton()
{
AvaticaMonitor monitor = injector.getInstance(AvaticaMonitor.class);
- Assert.assertNotNull(monitor);
+ Assertions.assertNotNull(monitor);
AvaticaMonitor other = injector.getInstance(AvaticaMonitor.class);
- Assert.assertSame(monitor, other);
+ Assertions.assertSame(monitor, other);
}
@Test
@@ -95,22 +91,22 @@ public void testAvaticaMonitorIsRegisterdWithMetricsModule()
{
Set> monitors =
injector.getInstance(Key.get(new TypeLiteral<>() {}));
- Assert.assertTrue(monitors.contains(AvaticaMonitor.class));
+ Assertions.assertTrue(monitors.contains(AvaticaMonitor.class));
}
@Test
public void testAvaticaServerConfigIsInjectable()
{
AvaticaServerConfig config = injector.getInstance(AvaticaServerConfig.class);
- Assert.assertNotNull(config);
- Assert.assertEquals(AvaticaServerConfig.DEFAULT_MAX_CONNECTIONS, config.getMaxConnections());
- Assert.assertEquals(
+ Assertions.assertNotNull(config);
+ Assertions.assertEquals(AvaticaServerConfig.DEFAULT_MAX_CONNECTIONS, config.getMaxConnections());
+ Assertions.assertEquals(
AvaticaServerConfig.DEFAULT_MAX_STATEMENTS_PER_CONNECTION,
config.getMaxStatementsPerConnection()
);
- Assert.assertEquals(AvaticaServerConfig.DEFAULT_CONNECTION_IDLE_TIMEOUT, config.getConnectionIdleTimeout());
- Assert.assertEquals(AvaticaServerConfig.DEFAULT_MIN_ROWS_PER_FRAME, config.getMinRowsPerFrame());
- Assert.assertEquals(AvaticaServerConfig.DEFAULT_MAX_ROWS_PER_FRAME, config.getMaxRowsPerFrame());
+ Assertions.assertEquals(AvaticaServerConfig.DEFAULT_CONNECTION_IDLE_TIMEOUT, config.getConnectionIdleTimeout());
+ Assertions.assertEquals(AvaticaServerConfig.DEFAULT_MIN_ROWS_PER_FRAME, config.getMinRowsPerFrame());
+ Assertions.assertEquals(AvaticaServerConfig.DEFAULT_MAX_ROWS_PER_FRAME, config.getMaxRowsPerFrame());
}
@Test
@@ -125,15 +121,15 @@ public void testAvaticaServerConfigProperties()
properties.setProperty("druid.sql.avatica.minRowsPerFrame", "10000");
provider.inject(properties, injector.getInstance(JsonConfigurator.class));
final AvaticaServerConfig config = provider.get();
- Assert.assertNotNull(config);
- Assert.assertEquals(AvaticaServerConfig.DEFAULT_MAX_CONNECTIONS, config.getMaxConnections());
- Assert.assertEquals(
+ Assertions.assertNotNull(config);
+ Assertions.assertEquals(AvaticaServerConfig.DEFAULT_MAX_CONNECTIONS, config.getMaxConnections());
+ Assertions.assertEquals(
AvaticaServerConfig.DEFAULT_MAX_STATEMENTS_PER_CONNECTION,
config.getMaxStatementsPerConnection()
);
- Assert.assertEquals(AvaticaServerConfig.DEFAULT_CONNECTION_IDLE_TIMEOUT, config.getConnectionIdleTimeout());
- Assert.assertEquals(10_000, config.getMinRowsPerFrame());
- Assert.assertEquals(50_000, config.getMaxRowsPerFrame());
+ Assertions.assertEquals(AvaticaServerConfig.DEFAULT_CONNECTION_IDLE_TIMEOUT, config.getConnectionIdleTimeout());
+ Assertions.assertEquals(10_000, config.getMinRowsPerFrame());
+ Assertions.assertEquals(50_000, config.getMaxRowsPerFrame());
}
@Test
@@ -147,22 +143,20 @@ public void testAvaticaServerConfigPropertiesSmallerMaxIsAlsoMin()
properties.setProperty("druid.sql.avatica.maxRowsPerFrame", "50");
provider.inject(properties, injector.getInstance(JsonConfigurator.class));
final AvaticaServerConfig config = provider.get();
- Assert.assertNotNull(config);
- Assert.assertEquals(AvaticaServerConfig.DEFAULT_MAX_CONNECTIONS, config.getMaxConnections());
- Assert.assertEquals(
+ Assertions.assertNotNull(config);
+ Assertions.assertEquals(AvaticaServerConfig.DEFAULT_MAX_CONNECTIONS, config.getMaxConnections());
+ Assertions.assertEquals(
AvaticaServerConfig.DEFAULT_MAX_STATEMENTS_PER_CONNECTION,
config.getMaxStatementsPerConnection()
);
- Assert.assertEquals(AvaticaServerConfig.DEFAULT_CONNECTION_IDLE_TIMEOUT, config.getConnectionIdleTimeout());
- Assert.assertEquals(50, config.getMinRowsPerFrame());
- Assert.assertEquals(50, config.getMaxRowsPerFrame());
+ Assertions.assertEquals(AvaticaServerConfig.DEFAULT_CONNECTION_IDLE_TIMEOUT, config.getConnectionIdleTimeout());
+ Assertions.assertEquals(50, config.getMinRowsPerFrame());
+ Assertions.assertEquals(50, config.getMaxRowsPerFrame());
}
@Test
public void testAvaticaServerConfigPropertiesBadMinRowsPerFrame()
{
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("'druid.sql.avatica.minRowsPerFrame' must be set to a value greater than 0");
Properties properties = new Properties();
final JsonConfigProvider provider = JsonConfigProvider.of(
"druid.sql.avatica",
@@ -171,26 +165,32 @@ public void testAvaticaServerConfigPropertiesBadMinRowsPerFrame()
properties.setProperty("druid.sql.avatica.minRowsPerFrame", "-1");
provider.inject(properties, injector.getInstance(JsonConfigurator.class));
final AvaticaServerConfig config = provider.get();
- Assert.assertNotNull(config);
- config.getMinRowsPerFrame();
+ Assertions.assertNotNull(config);
+ final IllegalArgumentException e = Assertions.assertThrows(
+ IllegalArgumentException.class,
+ config::getMinRowsPerFrame
+ );
+ Assertions.assertTrue(
+ e.getMessage().contains("'druid.sql.avatica.minRowsPerFrame' must be set to a value greater than 0")
+ );
}
@Test
public void testDruidAvaticaJsonHandlerIsInjected()
{
DruidAvaticaJsonHandler handler = injector.getInstance(DruidAvaticaJsonHandler.class);
- Assert.assertNotNull(handler);
+ Assertions.assertNotNull(handler);
DruidAvaticaJsonHandler other = injector.getInstance(DruidAvaticaJsonHandler.class);
- Assert.assertNotSame(handler, other);
+ Assertions.assertNotSame(handler, other);
}
@Test
public void testDruidAvaticaProtobufHandlerIsInjected()
{
DruidAvaticaProtobufHandler handler = injector.getInstance(DruidAvaticaProtobufHandler.class);
- Assert.assertNotNull(handler);
+ Assertions.assertNotNull(handler);
DruidAvaticaProtobufHandler other = injector.getInstance(DruidAvaticaProtobufHandler.class);
- Assert.assertNotSame(handler, other);
+ Assertions.assertNotSame(handler, other);
}
@Test
@@ -198,13 +198,13 @@ public void testDruidAvaticaJsonHandlerIsRegisterdWithJerseyModule()
{
Set handlers =
injector.getInstance(Key.get(new TypeLiteral<>() {}));
- Assert.assertTrue(handlers.stream().anyMatch(h -> DruidAvaticaJsonHandler.class.equals(h.getClass())));
+ Assertions.assertTrue(handlers.stream().anyMatch(h -> DruidAvaticaJsonHandler.class.equals(h.getClass())));
}
@Test
public void testDruidAvaticaProtobufHandlerIsRegisterdWithJerseyModule()
{
Set handlers = injector.getInstance(Key.get(new TypeLiteral<>() {}));
- Assert.assertTrue(handlers.stream().anyMatch(h -> DruidAvaticaProtobufHandler.class.equals(h.getClass())));
+ Assertions.assertTrue(handlers.stream().anyMatch(h -> DruidAvaticaProtobufHandler.class.equals(h.getClass())));
}
}
diff --git a/sql/src/test/java/org/apache/druid/sql/avatica/DruidAvaticaHandlerTest.java b/sql/src/test/java/org/apache/druid/sql/avatica/DruidAvaticaHandlerTest.java
index 416f04624c13..6278d00ca88e 100644
--- a/sql/src/test/java/org/apache/druid/sql/avatica/DruidAvaticaHandlerTest.java
+++ b/sql/src/test/java/org/apache/druid/sql/avatica/DruidAvaticaHandlerTest.java
@@ -65,7 +65,6 @@
import org.apache.druid.server.QueryLifecycleFactory;
import org.apache.druid.server.QueryScheduler;
import org.apache.druid.server.QuerySchedulerProvider;
-import org.apache.druid.server.QueryStackTests;
import org.apache.druid.server.RequestLogLine;
import org.apache.druid.server.SpecificSegmentsQuerySegmentWalker;
import org.apache.druid.server.initialization.ServerConfig;
@@ -93,15 +92,16 @@
import org.apache.druid.sql.calcite.util.CalciteTestBase;
import org.apache.druid.sql.calcite.util.CalciteTests;
import org.apache.druid.sql.calcite.util.QueryFrameworkUtils;
+import org.apache.druid.sql.calcite.util.SqlTestQueryStack;
import org.apache.druid.sql.calcite.util.datasets.TestDataSet;
import org.apache.druid.sql.guice.SqlModule;
import org.apache.druid.sql.hook.DruidHookDispatcher;
import org.eclipse.jetty.server.Server;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
-import org.junit.Assert;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -173,7 +173,7 @@ public class DruidAvaticaHandlerTest extends CalciteTestBase
public static void setUpClass(@TempDir File tempDir)
{
resourceCloser = Closer.create();
- conglomerate = QueryStackTests.createQueryRunnerFactoryConglomerate(resourceCloser);
+ conglomerate = SqlTestQueryStack.createQueryRunnerFactoryConglomerate(resourceCloser);
walker = CalciteTests.createMockWalker(conglomerate, tempDir);
resourceCloser.register(walker);
}
@@ -361,7 +361,7 @@ public void testSelectCount() throws SQLException
try (Statement stmt = client.createStatement()) {
final ResultSet resultSet = stmt.executeQuery("SELECT COUNT(*) AS cnt FROM druid.foo;");
final List