You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by fr...@apache.org on 2026/08/21 10:47:41 UTC
(druid) branch master updated: test(server): migrate PR3 tests to JUnit 5 (#20061)
This is an automated email from the ASF dual-hosted git repository.
FrankChen021 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 1bbb70423e5 test(server): migrate PR3 tests to JUnit 5 (#20061)
1bbb70423e5 is described below
commit 1bbb70423e50b4ee73e98ecb25c5a859ff1277a4
Author: Frank Chen <fr...@outlook.com>
AuthorDate: Fri Aug 21 18:47:33 2026 +0800
test(server): migrate PR3 tests to JUnit 5 (#20061)
* test(server): migrate PR3 tests to JUnit 5
* test(server): migrate remaining segment loading tests to JUnit 5
* test(server): defer config test migrations
* test(server): restore strict Mockito stubs
* test(server): preserve Mockito rule semantics
---
.../apache/druid/curator/CuratorModuleTest.java | 38 +-
.../org/apache/druid/curator/CuratorUtilsTest.java | 45 +-
.../curator/DruidConnectionStateListenerTest.java | 36 +-
.../announcement/PathChildrenAnnouncerTest.java | 98 ++--
.../discovery/CuratorDruidLeaderSelectorTest.java | 38 +-
.../CuratorDruidNodeAnnouncerAndDiscoveryTest.java | 15 +-
.../druid/discovery/BaseNodeRoleWatcherTest.java | 83 +--
.../druid/discovery/DataNodeServiceTest.java | 6 +-
.../druid/discovery/DataServerClientTest.java | 14 +-
.../druid/discovery/DiscoveryDruidNodeTest.java | 10 +-
.../discovery/DruidNodeDiscoveryProviderTest.java | 30 +-
.../druid/discovery/LookupNodeServiceTest.java | 6 +-
.../druid/discovery/WorkerNodeServiceTest.java | 6 +-
.../initialization/AuthorizationResultTest.java | 42 +-
.../initialization/ComposingEmitterModuleTest.java | 6 +-
.../druid/initialization/ServerConfigTest.java | 38 +-
.../initialization/ServerInjectorBuilderTest.java | 61 +--
.../initialization/SwitchingEmitterModuleTest.java | 6 +-
.../apache/druid/messages/MessageBatchTest.java | 6 +-
.../client/MessageRelayClientImplTest.java | 16 +-
.../druid/messages/client/MessageRelaysTest.java | 32 +-
.../druid/messages/server/OutboxImplTest.java | 74 +--
.../druid/rpc/DiscoveryServiceLocatorTest.java | 36 +-
.../apache/druid/rpc/FixedServiceLocatorTest.java | 14 +-
.../org/apache/druid/rpc/RequestBuilderTest.java | 84 ++-
.../apache/druid/rpc/ServiceClientImplTest.java | 202 +++-----
.../org/apache/druid/rpc/ServiceLocationTest.java | 38 +-
.../org/apache/druid/rpc/ServiceLocationsTest.java | 16 +-
.../druid/rpc/guice/ServiceClientModuleTest.java | 35 +-
.../druid/rpc/indexing/OverlordClientImplTest.java | 72 +--
.../indexing/SpecificTaskServiceLocatorTest.java | 36 +-
.../druid/segment/InlineSegmentWranglerTest.java | 21 +-
...CoordinatorBasedSegmentHandoffNotifierTest.java | 18 +-
.../apache/druid/segment/loading/LoadSpecTest.java | 18 +-
.../loading/LocalDataSegmentKillerTest.java | 74 +--
.../loading/LocalDataSegmentPullerTest.java | 37 +-
.../loading/LocalDataSegmentPusherTest.java | 90 ++--
.../LocalFileTimestampVersionFinderTest.java | 48 +-
.../loading/OmniDataSegmentArchiverTest.java | 10 +-
.../segment/loading/OmniDataSegmentKillerTest.java | 22 +-
.../segment/loading/OmniDataSegmentMoverTest.java | 10 +-
.../loading/SegmentLocalCacheManagerTest.java | 348 +++++++------
.../StorageLocationSelectorStrategyTest.java | 181 ++++---
.../segment/realtime/ChatHandlerProviderTest.java | 18 +-
.../segment/realtime/ChatHandlerResourceTest.java | 12 +-
.../druid/segment/realtime/FireHydrantTest.java | 68 +--
.../realtime/SegmentGenerationMetricsTest.java | 50 +-
.../appenderator/BatchAppenderatorDriverTest.java | 40 +-
.../appenderator/BatchAppenderatorTest.java | 389 +++++++-------
.../realtime/appenderator/CommittedTest.java | 22 +-
.../appenderator/SegmentIdWithShardSpecTest.java | 20 +-
.../appenderator/SegmentPublisherHelperTest.java | 43 +-
.../appenderator/SegmentWithStateTest.java | 10 +-
.../SegmentsAndCommitMetadataTest.java | 2 +-
.../realtime/appenderator/SinkSchemaUtilTest.java | 86 +--
.../StreamAppenderatorDriverFailTest.java | 123 ++---
.../appenderator/StreamAppenderatorDriverTest.java | 109 ++--
.../appenderator/StreamAppenderatorTest.java | 576 ++++++++++-----------
.../TransactionalSegmentPublisherTest.java | 21 +-
.../UnifiedIndexerAppenderatorsManagerTest.java | 62 ++-
.../druid/segment/realtime/sink/SinkTest.java | 66 +--
.../lookup/cache/LookupNodeDiscoveryTest.java | 16 +-
62 files changed, 1932 insertions(+), 1917 deletions(-)
diff --git a/server/src/test/java/org/apache/druid/curator/CuratorModuleTest.java b/server/src/test/java/org/apache/druid/curator/CuratorModuleTest.java
index 03939f38e0a..bc6389a27a9 100644
--- a/server/src/test/java/org/apache/druid/curator/CuratorModuleTest.java
+++ b/server/src/test/java/org/apache/druid/curator/CuratorModuleTest.java
@@ -29,16 +29,17 @@ import org.apache.druid.guice.LifecycleModule;
import org.apache.druid.guice.StartupInjectorBuilder;
import org.apache.druid.java.util.emitter.service.ServiceEmitter;
import org.apache.druid.server.metrics.NoopServiceEmitter;
-import org.apache.druid.testing.junit.LoggerCaptureRule;
+import org.apache.druid.testing.junit.LoggerCaptureExtension;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.LogEvent;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.extension.RegisterExtension;
import java.util.List;
import java.util.Properties;
@@ -50,8 +51,8 @@ public final class CuratorModuleTest
private static final String CURATOR_CONNECTION_TIMEOUT_MS_KEY =
CuratorConfig.CONFIG_PREFIX + "." + CuratorConfig.CONNECTION_TIMEOUT_MS;
- @Rule
- public final LoggerCaptureRule logger = new LoggerCaptureRule(CuratorModule.class);
+ @RegisterExtension
+ public final LoggerCaptureExtension logger = new LoggerCaptureExtension(CuratorModule.class);
@Test
public void createsCuratorFrameworkAsConfigured()
@@ -60,16 +61,17 @@ public final class CuratorModuleTest
CuratorFramework curatorFramework = CuratorModule.createCurator(config);
CuratorZookeeperClient client = curatorFramework.getZookeeperClient();
- Assert.assertEquals(config.getZkHosts(), client.getCurrentConnectionString());
- Assert.assertEquals(config.getZkConnectionTimeoutMs(), client.getConnectionTimeoutMs());
+ Assertions.assertEquals(config.getZkHosts(), client.getCurrentConnectionString());
+ Assertions.assertEquals(config.getZkConnectionTimeoutMs(), client.getConnectionTimeoutMs());
MatcherAssert.assertThat(client.getRetryPolicy(), Matchers.instanceOf(BoundedExponentialBackoffRetry.class));
BoundedExponentialBackoffRetry retryPolicy = (BoundedExponentialBackoffRetry) client.getRetryPolicy();
- Assert.assertEquals(CuratorModule.BASE_SLEEP_TIME_MS, retryPolicy.getBaseSleepTimeMs());
- Assert.assertEquals(CuratorModule.MAX_SLEEP_TIME_MS, retryPolicy.getMaxSleepTimeMs());
+ Assertions.assertEquals(CuratorModule.BASE_SLEEP_TIME_MS, retryPolicy.getBaseSleepTimeMs());
+ Assertions.assertEquals(CuratorModule.MAX_SLEEP_TIME_MS, retryPolicy.getMaxSleepTimeMs());
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void exitsJvmWhenMaxRetriesExceeded() throws Exception
{
CountDownLatch exitCalled = new CountDownLatch(1);
@@ -88,21 +90,21 @@ public final class CuratorModuleTest
logger.awaitLogEvents();
List<LogEvent> loggingEvents = logger.getLogEvents();
- Assert.assertTrue(
- "Logging events: " + loggingEvents,
+ Assertions.assertTrue(
loggingEvents.stream()
.anyMatch(l ->
l.getLevel().equals(Level.ERROR)
&& l.getMessage()
.getFormattedMessage()
.equals("Unhandled error in Curator, stopping server.")
- )
+ ),
+ "Logging events: " + loggingEvents
);
- Assert.assertTrue("System.exit was not called within timeout", exitCalled.await(10, TimeUnit.SECONDS));
+ Assertions.assertTrue(exitCalled.await(10, TimeUnit.SECONDS), "System.exit was not called within timeout");
}
- @Ignore("Verifies changes in https://github.com/apache/druid/pull/8458, but overkill for regular testing")
+ @Disabled("Verifies changes in https://github.com/apache/druid/pull/8458, but overkill for regular testing")
@Test
public void ignoresDeprecatedCuratorConfigProperties()
{
@@ -115,7 +117,7 @@ public final class CuratorModuleTest
injector.getInstance(CuratorFramework.class);
}
catch (Exception e) {
- Assert.fail("Deprecated curator config was not ignored:\n" + e);
+ Assertions.fail("Deprecated curator config was not ignored:\n" + e);
}
}
diff --git a/server/src/test/java/org/apache/druid/curator/CuratorUtilsTest.java b/server/src/test/java/org/apache/druid/curator/CuratorUtilsTest.java
index 21e0dd35345..84e39ba0bfe 100644
--- a/server/src/test/java/org/apache/druid/curator/CuratorUtilsTest.java
+++ b/server/src/test/java/org/apache/druid/curator/CuratorUtilsTest.java
@@ -21,26 +21,30 @@ package org.apache.druid.curator;
import org.apache.druid.java.util.common.StringUtils;
import org.apache.zookeeper.CreateMode;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+
+import java.util.concurrent.TimeUnit;
public class CuratorUtilsTest extends CuratorTestBase
{
- @Before
+ @BeforeEach
public void setUp() throws Exception
{
setupServerAndCurator();
}
- @After
+ @AfterEach
public void tearDown()
{
tearDownServerAndCurator();
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testCreateIfNotExists() throws Exception
{
curator.start();
@@ -53,7 +57,7 @@ public class CuratorUtilsTest extends CuratorTestBase
StringUtils.toUtf8("baz"),
CuratorUtils.DEFAULT_MAX_ZNODE_BYTES
);
- Assert.assertEquals("baz", StringUtils.fromUtf8(curator.getData().forPath("/foo/bar")));
+ Assertions.assertEquals("baz", StringUtils.fromUtf8(curator.getData().forPath("/foo/bar")));
CuratorUtils.createIfNotExists(
curator,
@@ -62,10 +66,11 @@ public class CuratorUtilsTest extends CuratorTestBase
StringUtils.toUtf8("qux"),
CuratorUtils.DEFAULT_MAX_ZNODE_BYTES
);
- Assert.assertEquals("baz", StringUtils.fromUtf8(curator.getData().forPath("/foo/bar")));
+ Assertions.assertEquals("baz", StringUtils.fromUtf8(curator.getData().forPath("/foo/bar")));
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testCreateIfNotExistsPayloadTooLarge() throws Exception
{
curator.start();
@@ -85,17 +90,18 @@ public class CuratorUtilsTest extends CuratorTestBase
thrown = e;
}
- Assert.assertTrue(thrown instanceof IllegalArgumentException);
- Assert.assertNull(curator.checkExists().forPath("/foo/bar"));
+ Assertions.assertTrue(thrown instanceof IllegalArgumentException);
+ Assertions.assertNull(curator.checkExists().forPath("/foo/bar"));
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testCreateOrSet() throws Exception
{
curator.start();
curator.blockUntilConnected();
- Assert.assertNull(curator.checkExists().forPath("/foo/bar"));
+ Assertions.assertNull(curator.checkExists().forPath("/foo/bar"));
CuratorUtils.createOrSet(
curator,
@@ -104,7 +110,7 @@ public class CuratorUtilsTest extends CuratorTestBase
StringUtils.toUtf8("baz"),
3
);
- Assert.assertEquals("baz", StringUtils.fromUtf8(curator.getData().forPath("/foo/bar")));
+ Assertions.assertEquals("baz", StringUtils.fromUtf8(curator.getData().forPath("/foo/bar")));
CuratorUtils.createOrSet(
curator,
@@ -113,10 +119,11 @@ public class CuratorUtilsTest extends CuratorTestBase
StringUtils.toUtf8("qux"),
3
);
- Assert.assertEquals("qux", StringUtils.fromUtf8(curator.getData().forPath("/foo/bar")));
+ Assertions.assertEquals("qux", StringUtils.fromUtf8(curator.getData().forPath("/foo/bar")));
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testCreateOrSetPayloadTooLarge() throws Exception
{
curator.start();
@@ -136,7 +143,7 @@ public class CuratorUtilsTest extends CuratorTestBase
thrown = e;
}
- Assert.assertTrue(thrown instanceof IllegalArgumentException);
- Assert.assertNull(curator.checkExists().forPath("/foo/bar"));
+ Assertions.assertTrue(thrown instanceof IllegalArgumentException);
+ Assertions.assertNull(curator.checkExists().forPath("/foo/bar"));
}
}
diff --git a/server/src/test/java/org/apache/druid/curator/DruidConnectionStateListenerTest.java b/server/src/test/java/org/apache/druid/curator/DruidConnectionStateListenerTest.java
index 4a9b7a4e36f..83245e40737 100644
--- a/server/src/test/java/org/apache/druid/curator/DruidConnectionStateListenerTest.java
+++ b/server/src/test/java/org/apache/druid/curator/DruidConnectionStateListenerTest.java
@@ -22,16 +22,16 @@ package org.apache.druid.curator;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.druid.java.util.emitter.service.AlertEvent;
import org.apache.druid.java.util.metrics.StubServiceEmitter;
-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;
public class DruidConnectionStateListenerTest
{
private StubServiceEmitter emitter;
private DruidConnectionStateListener listener;
- @Before
+ @BeforeEach
public void setUp()
{
emitter = new StubServiceEmitter("DruidConnectionStateListenerTest", "localhost");
@@ -41,26 +41,26 @@ public class DruidConnectionStateListenerTest
@Test
public void test_isConnected()
{
- Assert.assertFalse(listener.isConnected());
+ Assertions.assertFalse(listener.isConnected());
listener.stateChanged(null, ConnectionState.CONNECTED);
- Assert.assertTrue(listener.isConnected());
+ Assertions.assertTrue(listener.isConnected());
listener.stateChanged(null, ConnectionState.SUSPENDED);
- Assert.assertFalse(listener.isConnected());
+ Assertions.assertFalse(listener.isConnected());
listener.stateChanged(null, ConnectionState.RECONNECTED);
- Assert.assertTrue(listener.isConnected());
+ Assertions.assertTrue(listener.isConnected());
listener.stateChanged(null, ConnectionState.LOST);
- Assert.assertFalse(listener.isConnected());
+ Assertions.assertFalse(listener.isConnected());
}
@Test
public void test_doMonitor_init()
{
listener.doMonitor(emitter);
- Assert.assertEquals(1, emitter.getNumEmittedEvents());
+ Assertions.assertEquals(1, emitter.getNumEmittedEvents());
emitter.verifyValue("zk/connected", 0);
}
@@ -69,7 +69,7 @@ public class DruidConnectionStateListenerTest
{
listener.stateChanged(null, ConnectionState.CONNECTED);
listener.doMonitor(emitter);
- Assert.assertEquals(1, emitter.getNumEmittedEvents());
+ Assertions.assertEquals(1, emitter.getNumEmittedEvents());
emitter.verifyValue("zk/connected", 1);
}
@@ -79,7 +79,7 @@ public class DruidConnectionStateListenerTest
{
listener.stateChanged(null, ConnectionState.SUSPENDED);
listener.doMonitor(emitter);
- Assert.assertEquals(2, emitter.getNumEmittedEvents()); // 2 because stateChanged emitted an alert
+ Assertions.assertEquals(2, emitter.getNumEmittedEvents()); // 2 because stateChanged emitted an alert
emitter.verifyValue("zk/connected", 0);
}
@@ -88,24 +88,24 @@ public class DruidConnectionStateListenerTest
public void test_suspendedAlert()
{
listener.stateChanged(null, ConnectionState.SUSPENDED);
- Assert.assertEquals(1, emitter.getNumEmittedEvents());
+ Assertions.assertEquals(1, emitter.getNumEmittedEvents());
final AlertEvent alert = emitter.getAlerts().get(0);
- Assert.assertEquals("alerts", alert.getFeed());
- Assert.assertEquals("ZooKeeper connection[SUSPENDED]", alert.getDescription());
+ Assertions.assertEquals("alerts", alert.getFeed());
+ Assertions.assertEquals("ZooKeeper connection[SUSPENDED]", alert.getDescription());
}
@Test
public void test_reconnectedMetric()
{
listener.stateChanged(null, ConnectionState.SUSPENDED);
- Assert.assertEquals(1, emitter.getNumEmittedEvents()); // the first stateChanged emits an alert
+ Assertions.assertEquals(1, emitter.getNumEmittedEvents()); // the first stateChanged emits an alert
listener.stateChanged(null, ConnectionState.RECONNECTED);
- Assert.assertEquals(2, emitter.getNumEmittedEvents()); // the second stateChanged emits a metric
+ Assertions.assertEquals(2, emitter.getNumEmittedEvents()); // the second stateChanged emits a metric
long observedReconnectTime = emitter.getValue("zk/reconnect/time", null).longValue();
- Assert.assertTrue(observedReconnectTime >= 0);
+ Assertions.assertTrue(observedReconnectTime >= 0);
}
}
diff --git a/server/src/test/java/org/apache/druid/curator/announcement/PathChildrenAnnouncerTest.java b/server/src/test/java/org/apache/druid/curator/announcement/PathChildrenAnnouncerTest.java
index 095a38f69ce..54d955b4ce4 100644
--- a/server/src/test/java/org/apache/druid/curator/announcement/PathChildrenAnnouncerTest.java
+++ b/server/src/test/java/org/apache/druid/curator/announcement/PathChildrenAnnouncerTest.java
@@ -33,15 +33,17 @@ import org.apache.druid.java.util.common.concurrent.Execs;
import org.apache.druid.java.util.common.logger.Logger;
import org.apache.zookeeper.KeeperException.Code;
import org.apache.zookeeper.data.Stat;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
/**
*
@@ -51,7 +53,7 @@ public class PathChildrenAnnouncerTest extends CuratorTestBase
private static final Logger log = new Logger(PathChildrenAnnouncerTest.class);
private ExecutorService exec;
- @Before
+ @BeforeEach
public void setUp() throws Exception
{
setupServerAndCurator();
@@ -60,13 +62,14 @@ public class PathChildrenAnnouncerTest extends CuratorTestBase
curator.blockUntilConnected();
}
- @After
+ @AfterEach
public void tearDown()
{
tearDownServerAndCurator();
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testSanity() throws Exception
{
PathChildrenAnnouncer announcer = new PathChildrenAnnouncer(curator, exec);
@@ -77,8 +80,8 @@ public class PathChildrenAnnouncerTest extends CuratorTestBase
final String testPath2 = "/somewhere/test2";
announcer.announce(testPath1, billy);
- Assert.assertNull("/test1 does not exists", curator.checkExists().forPath(testPath1));
- Assert.assertNull("/somewhere/test2 does not exists", curator.checkExists().forPath(testPath2));
+ Assertions.assertNull(curator.checkExists().forPath(testPath1), "/test1 does not exists");
+ Assertions.assertNull(curator.checkExists().forPath(testPath2), "/somewhere/test2 does not exists");
announcer.start();
while (!announcer.getAddedChildren().contains("/test1")) {
@@ -86,56 +89,57 @@ public class PathChildrenAnnouncerTest extends CuratorTestBase
}
try {
- Assert.assertArrayEquals("/test1 has data", billy, curator.getData().decompressed().forPath(testPath1));
- Assert.assertNull("/somewhere/test2 still does not exist", curator.checkExists().forPath(testPath2));
+ Assertions.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1), "/test1 has data");
+ Assertions.assertNull(curator.checkExists().forPath(testPath2), "/somewhere/test2 still does not exist");
announcer.announce(testPath2, billy);
- Assert.assertArrayEquals("/test1 still has data", billy, curator.getData().decompressed().forPath(testPath1));
- Assert.assertArrayEquals(
- "/somewhere/test2 has data",
+ Assertions.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1), "/test1 still has data");
+ Assertions.assertArrayEquals(
billy,
- curator.getData().decompressed().forPath(testPath2)
+ curator.getData().decompressed().forPath(testPath2),
+ "/somewhere/test2 has data"
);
final CountDownLatch latch = createCountdownLatchForPaths(testPath1);
final CuratorOp deleteOp = curator.transactionOp().delete().forPath(testPath1);
final Collection<CuratorTransactionResult> results = curator.transaction().forOperations(deleteOp);
- Assert.assertEquals(1, results.size());
+ Assertions.assertEquals(1, results.size());
final CuratorTransactionResult result = results.iterator().next();
- Assert.assertEquals(Code.OK.intValue(), result.getError()); // assert delete
+ Assertions.assertEquals(Code.OK.intValue(), result.getError()); // assert delete
- Assert.assertTrue("Wait for /test1 to be created", timing.forWaiting().awaitLatch(latch));
+ Assertions.assertTrue(timing.forWaiting().awaitLatch(latch), "Wait for /test1 to be created");
- Assert.assertArrayEquals(
- "expect /test1 data is restored",
+ Assertions.assertArrayEquals(
billy,
- curator.getData().decompressed().forPath(testPath1)
+ curator.getData().decompressed().forPath(testPath1),
+ "expect /test1 data is restored"
);
- Assert.assertArrayEquals(
- "expect /somewhere/test2 is still there",
+ Assertions.assertArrayEquals(
billy,
- curator.getData().decompressed().forPath(testPath2)
+ curator.getData().decompressed().forPath(testPath2),
+ "expect /somewhere/test2 is still there"
);
announcer.unannounce(testPath1);
- Assert.assertNull("expect /test1 unannounced", curator.checkExists().forPath(testPath1));
- Assert.assertArrayEquals(
- "expect /somewhere/test2 is still still there",
+ Assertions.assertNull(curator.checkExists().forPath(testPath1), "expect /test1 unannounced");
+ Assertions.assertArrayEquals(
billy,
- curator.getData().decompressed().forPath(testPath2)
+ curator.getData().decompressed().forPath(testPath2),
+ "expect /somewhere/test2 is still still there"
);
}
finally {
announcer.stop();
}
- Assert.assertNull("expect /test1 remains unannounced", curator.checkExists().forPath(testPath1));
- Assert.assertNull("expect /somewhere/test2 unannounced", curator.checkExists().forPath(testPath2));
+ Assertions.assertNull(curator.checkExists().forPath(testPath1), "expect /test1 remains unannounced");
+ Assertions.assertNull(curator.checkExists().forPath(testPath2), "expect /somewhere/test2 unannounced");
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testSessionKilled() throws Exception
{
PathChildrenAnnouncer announcer = new PathChildrenAnnouncer(curator, exec);
@@ -151,17 +155,17 @@ public class PathChildrenAnnouncerTest extends CuratorTestBase
announcer.announce(testPath1, billy);
announcer.announce(testPath2, billy);
- Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1));
- Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath2));
+ Assertions.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1));
+ Assertions.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath2));
final CountDownLatch latch = createCountdownLatchForPaths(paths);
KillSession.kill(curator.getZookeeperClient().getZooKeeper(), server.getConnectString());
- Assert.assertTrue(timing.forWaiting().awaitLatch(latch));
+ Assertions.assertTrue(timing.forWaiting().awaitLatch(latch));
- Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1));
- Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath2));
+ Assertions.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1));
+ Assertions.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath2));
announcer.stop();
@@ -169,8 +173,8 @@ public class PathChildrenAnnouncerTest extends CuratorTestBase
Thread.sleep(100);
}
- Assert.assertNull(curator.checkExists().forPath(testPath1));
- Assert.assertNull(curator.checkExists().forPath(testPath2));
+ Assertions.assertNull(curator.checkExists().forPath(testPath1));
+ Assertions.assertNull(curator.checkExists().forPath(testPath2));
}
finally {
announcer.stop();
@@ -188,17 +192,17 @@ public class PathChildrenAnnouncerTest extends CuratorTestBase
announcer.start();
try {
- Assert.assertNull(curator.checkExists().forPath(parent));
+ Assertions.assertNull(curator.checkExists().forPath(parent));
awaitAnnounce(announcer, testPath, billy, true);
- Assert.assertNotNull(curator.checkExists().forPath(parent));
+ Assertions.assertNotNull(curator.checkExists().forPath(parent));
}
finally {
announcer.stop();
}
- Assert.assertNull(curator.checkExists().forPath(parent));
+ Assertions.assertNull(curator.checkExists().forPath(parent));
}
@Test
@@ -215,17 +219,17 @@ public class PathChildrenAnnouncerTest extends CuratorTestBase
announcer.start();
try {
- Assert.assertEquals(initialStat.getMzxid(), curator.checkExists().forPath(parent).getMzxid());
+ Assertions.assertEquals(initialStat.getMzxid(), curator.checkExists().forPath(parent).getMzxid());
awaitAnnounce(announcer, testPath, billy, true);
- Assert.assertEquals(initialStat.getMzxid(), curator.checkExists().forPath(parent).getMzxid());
+ Assertions.assertEquals(initialStat.getMzxid(), curator.checkExists().forPath(parent).getMzxid());
}
finally {
announcer.stop();
}
- Assert.assertEquals(initialStat.getMzxid(), curator.checkExists().forPath(parent).getMzxid());
+ Assertions.assertEquals(initialStat.getMzxid(), curator.checkExists().forPath(parent).getMzxid());
}
@Test
@@ -239,17 +243,17 @@ public class PathChildrenAnnouncerTest extends CuratorTestBase
announcer.start();
try {
- Assert.assertNull(curator.checkExists().forPath(parent));
+ Assertions.assertNull(curator.checkExists().forPath(parent));
awaitAnnounce(announcer, testPath, billy, false);
- Assert.assertNotNull(curator.checkExists().forPath(parent));
+ Assertions.assertNotNull(curator.checkExists().forPath(parent));
}
finally {
announcer.stop();
}
- Assert.assertNotNull(curator.checkExists().forPath(parent));
+ Assertions.assertNotNull(curator.checkExists().forPath(parent));
}
private void awaitAnnounce(
diff --git a/server/src/test/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelectorTest.java b/server/src/test/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelectorTest.java
index 66b76125235..f174b14222a 100644
--- a/server/src/test/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelectorTest.java
+++ b/server/src/test/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelectorTest.java
@@ -26,11 +26,13 @@ import org.apache.druid.java.util.common.logger.Logger;
import org.apache.druid.java.util.emitter.EmittingLogger;
import org.apache.druid.java.util.metrics.StubServiceEmitter;
import org.apache.druid.server.DruidNode;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
@@ -42,7 +44,7 @@ public class CuratorDruidLeaderSelectorTest extends CuratorTestBase
private final StubServiceEmitter emitter = new StubServiceEmitter();
- @Before
+ @BeforeEach
public void setUp() throws Exception
{
emitter.flush();
@@ -50,7 +52,8 @@ public class CuratorDruidLeaderSelectorTest extends CuratorTestBase
setupServerAndCurator();
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testSimple() throws Exception
{
curator.start();
@@ -89,7 +92,7 @@ public class CuratorDruidLeaderSelectorTest extends CuratorTestBase
Thread.sleep(100);
}
- Assert.assertTrue(leaderSelector1.localTerm() >= 1);
+ Assertions.assertTrue(leaderSelector1.localTerm() >= 1);
CuratorDruidLeaderSelector leaderSelector2 = new CuratorDruidLeaderSelector(
curator,
@@ -126,9 +129,9 @@ public class CuratorDruidLeaderSelectorTest extends CuratorTestBase
Thread.sleep(100);
}
- Assert.assertTrue(leaderSelector2.isLeader());
- Assert.assertEquals("http://h2:8080", leaderSelector1.getCurrentLeader());
- Assert.assertEquals(2, leaderSelector2.localTerm());
+ Assertions.assertTrue(leaderSelector2.isLeader());
+ Assertions.assertEquals("http://h2:8080", leaderSelector1.getCurrentLeader());
+ Assertions.assertEquals(2, leaderSelector2.localTerm());
CuratorDruidLeaderSelector leaderSelector3 = new CuratorDruidLeaderSelector(
curator,
@@ -159,12 +162,13 @@ public class CuratorDruidLeaderSelectorTest extends CuratorTestBase
Thread.sleep(100);
}
- Assert.assertTrue(leaderSelector3.isLeader());
- Assert.assertEquals("http://h3:8080", leaderSelector1.getCurrentLeader());
- Assert.assertEquals(1, leaderSelector3.localTerm());
+ Assertions.assertTrue(leaderSelector3.isLeader());
+ Assertions.assertEquals("http://h3:8080", leaderSelector1.getCurrentLeader());
+ Assertions.assertEquals(1, leaderSelector3.localTerm());
}
- @Test(timeout = 10_000)
+ @Test
+ @Timeout(value = 10_000L, unit = TimeUnit.MILLISECONDS)
public void test_becomeLeader_triggersCleanup_onFailure() throws InterruptedException
{
curator.start();
@@ -201,11 +205,11 @@ public class CuratorDruidLeaderSelectorTest extends CuratorTestBase
Thread.sleep(100);
}
- Assert.assertEquals(1, becomeLeaderCalled.get());
- Assert.assertEquals(1, stopBeingLeaderCalled.get());
+ Assertions.assertEquals(1, becomeLeaderCalled.get());
+ Assertions.assertEquals(1, stopBeingLeaderCalled.get());
}
- @After
+ @AfterEach
public void tearDown()
{
tearDownServerAndCurator();
diff --git a/server/src/test/java/org/apache/druid/curator/discovery/CuratorDruidNodeAnnouncerAndDiscoveryTest.java b/server/src/test/java/org/apache/druid/curator/discovery/CuratorDruidNodeAnnouncerAndDiscoveryTest.java
index 7d9368a8e1e..5076e8c94f6 100644
--- a/server/src/test/java/org/apache/druid/curator/discovery/CuratorDruidNodeAnnouncerAndDiscoveryTest.java
+++ b/server/src/test/java/org/apache/druid/curator/discovery/CuratorDruidNodeAnnouncerAndDiscoveryTest.java
@@ -33,13 +33,15 @@ import org.apache.druid.java.util.common.concurrent.Execs;
import org.apache.druid.server.DruidNode;
import org.apache.druid.server.initialization.ServerConfig;
import org.apache.druid.server.initialization.ZkPathsConfig;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import java.util.function.BooleanSupplier;
/**
@@ -47,13 +49,14 @@ import java.util.function.BooleanSupplier;
*/
public class CuratorDruidNodeAnnouncerAndDiscoveryTest extends CuratorTestBase
{
- @Before
+ @BeforeEach
public void setUp() throws Exception
{
setupServerAndCurator();
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testAnnouncementAndDiscovery() throws Exception
{
ObjectMapper objectMapper = new DefaultObjectMapper();
@@ -212,7 +215,7 @@ public class CuratorDruidNodeAnnouncerAndDiscoveryTest extends CuratorTestBase
return expected.equals(ImmutableSet.copyOf(actual));
}
- @After
+ @AfterEach
public void tearDown()
{
tearDownServerAndCurator();
diff --git a/server/src/test/java/org/apache/druid/discovery/BaseNodeRoleWatcherTest.java b/server/src/test/java/org/apache/druid/discovery/BaseNodeRoleWatcherTest.java
index ec7b24cbdc0..8295a3e9bd7 100644
--- a/server/src/test/java/org/apache/druid/discovery/BaseNodeRoleWatcherTest.java
+++ b/server/src/test/java/org/apache/druid/discovery/BaseNodeRoleWatcherTest.java
@@ -25,10 +25,11 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.Futures;
import org.apache.druid.java.util.common.concurrent.Execs;
import org.apache.druid.server.DruidNode;
-import org.junit.AfterClass;
-import org.junit.Assert;
-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 org.junit.jupiter.api.Timeout;
import java.util.ArrayList;
import java.util.Collection;
@@ -40,25 +41,27 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
public class BaseNodeRoleWatcherTest
{
private static ScheduledExecutorService exec;
- @BeforeClass
+ @BeforeAll
public static void setup()
{
exec = createScheduledSingleThreadedExecutor();
}
- @AfterClass
+ @AfterAll
public static void teardown()
{
exec.shutdown();
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testGeneralUseSimulation()
{
BaseNodeRoleWatcher nodeRoleWatcher = BaseNodeRoleWatcher.create(exec, NodeRole.BROKER);
@@ -93,9 +96,9 @@ public class BaseNodeRoleWatcherTest
nodeRoleWatcher.registerListener(listener3);
List<DiscoveryDruidNode> presentNodes = new ArrayList<>(nodeRoleWatcher.getAllNodes());
- Assert.assertEquals(2, presentNodes.size());
- Assert.assertTrue(presentNodes.contains(broker1));
- Assert.assertTrue(presentNodes.contains(broker3));
+ Assertions.assertEquals(2, presentNodes.size());
+ Assertions.assertTrue(presentNodes.contains(broker1));
+ Assertions.assertTrue(presentNodes.contains(broker3));
assertListener(listener1, true, presentNodes, Collections.emptyList());
assertListener(listener2, true, presentNodes, Collections.emptyList());
@@ -107,7 +110,7 @@ public class BaseNodeRoleWatcherTest
nodeRoleWatcher.childRemoved(broker3);
nodeRoleWatcher.childAdded(broker1);
- Assert.assertEquals(ImmutableSet.of(broker2, broker1), new HashSet<>(nodeRoleWatcher.getAllNodes()));
+ Assertions.assertEquals(ImmutableSet.of(broker2, broker1), new HashSet<>(nodeRoleWatcher.getAllNodes()));
List<DiscoveryDruidNode> nodesAdded = new ArrayList<>(presentNodes);
nodesAdded.add(broker2);
@@ -125,7 +128,7 @@ public class BaseNodeRoleWatcherTest
nodeRoleWatcher.resetNodes(resetNodes);
- Assert.assertEquals(ImmutableSet.of(broker2, broker3), new HashSet<>(nodeRoleWatcher.getAllNodes()));
+ Assertions.assertEquals(ImmutableSet.of(broker2, broker3), new HashSet<>(nodeRoleWatcher.getAllNodes()));
nodesAdded.add(broker3);
nodesRemoved.add(broker1);
@@ -135,7 +138,8 @@ public class BaseNodeRoleWatcherTest
assertListener(listener3, true, nodesAdded, nodesRemoved);
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testRegisterListenerBeforeTimeout() throws InterruptedException
{
BaseNodeRoleWatcher nodeRoleWatcher = new BaseNodeRoleWatcher(exec, NodeRole.BROKER);
@@ -163,12 +167,13 @@ public class BaseNodeRoleWatcherTest
nodeRoleWatcher.scheduleTimeout(0);
nodeRoleWatcher.awaitInitialization();
- Assert.assertTrue(listener1.nodeViewInitializationTimedOut.get());
+ Assertions.assertTrue(listener1.nodeViewInitializationTimedOut.get());
assertListener(listener1, true, ImmutableList.of(broker1, broker3), ImmutableList.of());
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testGetAllNodesBeforeTimeout() throws InterruptedException
{
BaseNodeRoleWatcher nodeRoleWatcher = new BaseNodeRoleWatcher(exec, NodeRole.BROKER);
@@ -197,13 +202,14 @@ public class BaseNodeRoleWatcherTest
nodeRoleWatcher.scheduleTimeout(0);
nodeRoleWatcher.awaitInitialization();
- Assert.assertEquals(2, nodeRoleWatcher.getAllNodes().size());
+ Assertions.assertEquals(2, nodeRoleWatcher.getAllNodes().size());
- Assert.assertTrue(listener1.nodeViewInitializationTimedOut.get());
+ Assertions.assertTrue(listener1.nodeViewInitializationTimedOut.get());
assertListener(listener1, true, ImmutableList.of(broker1, broker3), ImmutableList.of());
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testDuplicateChildAddedAfterResetNodesDoesNotNotifyListeners()
{
BaseNodeRoleWatcher nodeRoleWatcher = BaseNodeRoleWatcher.create(exec, NodeRole.BROKER);
@@ -220,7 +226,7 @@ public class BaseNodeRoleWatcherTest
nodeRoleWatcher.registerListener(listener);
// Verify listener received the initial nodes
- Assert.assertEquals(ImmutableList.of(broker1, broker2), listener.nodesAddedList);
+ Assertions.assertEquals(ImmutableList.of(broker1, broker2), listener.nodesAddedList);
// Simulate watch reconnect: resetNodes with the same set of nodes
LinkedHashMap<String, DiscoveryDruidNode> resetMap = new LinkedHashMap<>();
@@ -229,22 +235,23 @@ public class BaseNodeRoleWatcherTest
nodeRoleWatcher.resetNodes(resetMap);
// No new additions or removals since the node set is unchanged
- Assert.assertEquals(ImmutableList.of(broker1, broker2), listener.nodesAddedList);
- Assert.assertTrue(listener.nodesRemovedList.isEmpty());
+ Assertions.assertEquals(ImmutableList.of(broker1, broker2), listener.nodesAddedList);
+ Assertions.assertTrue(listener.nodesRemovedList.isEmpty());
// Simulate K8s watch replaying ADDED events for already-present nodes
nodeRoleWatcher.childAdded(broker1);
nodeRoleWatcher.childAdded(broker2);
// Listeners should NOT be notified again — the duplicate adds are no-ops
- Assert.assertEquals(ImmutableList.of(broker1, broker2), listener.nodesAddedList);
- Assert.assertTrue(listener.nodesRemovedList.isEmpty());
+ Assertions.assertEquals(ImmutableList.of(broker1, broker2), listener.nodesAddedList);
+ Assertions.assertTrue(listener.nodesRemovedList.isEmpty());
// The nodes map should still contain exactly the same two nodes
- Assert.assertEquals(ImmutableSet.of(broker1, broker2), new HashSet<>(nodeRoleWatcher.getAllNodes()));
+ Assertions.assertEquals(ImmutableSet.of(broker1, broker2), new HashSet<>(nodeRoleWatcher.getAllNodes()));
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testChildRemovedIfPresentRemovesKnownNode()
{
BaseNodeRoleWatcher nodeRoleWatcher = BaseNodeRoleWatcher.create(exec, NodeRole.BROKER);
@@ -257,16 +264,17 @@ public class BaseNodeRoleWatcherTest
TestListener listener = new TestListener();
nodeRoleWatcher.registerListener(listener);
- Assert.assertEquals(ImmutableList.of(broker1), listener.nodesAddedList);
+ Assertions.assertEquals(ImmutableList.of(broker1), listener.nodesAddedList);
// Remove with skipIfUnknown=true — node IS in cache, should remove and notify
nodeRoleWatcher.childRemoved(broker1, true);
- Assert.assertEquals(ImmutableList.of(broker1), listener.nodesRemovedList);
- Assert.assertTrue(nodeRoleWatcher.getAllNodes().isEmpty());
+ Assertions.assertEquals(ImmutableList.of(broker1), listener.nodesRemovedList);
+ Assertions.assertTrue(nodeRoleWatcher.getAllNodes().isEmpty());
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testChildRemovedIfPresentSkipsUnknownNode()
{
BaseNodeRoleWatcher nodeRoleWatcher = BaseNodeRoleWatcher.create(exec, NodeRole.BROKER);
@@ -283,11 +291,12 @@ public class BaseNodeRoleWatcherTest
// Remove broker2 with skipIfUnknown=true — node is NOT in cache, should silently skip
nodeRoleWatcher.childRemoved(broker2, true);
- Assert.assertTrue(listener.nodesRemovedList.isEmpty());
- Assert.assertEquals(1, nodeRoleWatcher.getAllNodes().size());
+ Assertions.assertTrue(listener.nodesRemovedList.isEmpty());
+ Assertions.assertEquals(1, nodeRoleWatcher.getAllNodes().size());
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testChildRemovedIfPresentRepeatedRemovalsAreIdempotent()
{
BaseNodeRoleWatcher nodeRoleWatcher = BaseNodeRoleWatcher.create(exec, NodeRole.BROKER);
@@ -302,12 +311,12 @@ public class BaseNodeRoleWatcherTest
// First removal should remove and notify
nodeRoleWatcher.childRemoved(broker1, true);
- Assert.assertEquals(ImmutableList.of(broker1), listener.nodesRemovedList);
+ Assertions.assertEquals(ImmutableList.of(broker1), listener.nodesRemovedList);
// Second removal should silently skip (node already removed)
nodeRoleWatcher.childRemoved(broker1, true);
// Still only one removal notification
- Assert.assertEquals(ImmutableList.of(broker1), listener.nodesRemovedList);
+ Assertions.assertEquals(ImmutableList.of(broker1), listener.nodesRemovedList);
}
private DiscoveryDruidNode buildDiscoveryDruidNode(NodeRole role, String host)
@@ -327,9 +336,9 @@ public class BaseNodeRoleWatcherTest
)
{
final int count = ready ? 0 : 1;
- Assert.assertEquals(count, listener.ready.getCount());
- Assert.assertEquals(nodesAdded, listener.nodesAddedList);
- Assert.assertEquals(nodesRemoved, listener.nodesRemovedList);
+ Assertions.assertEquals(count, listener.ready.getCount());
+ Assertions.assertEquals(nodesAdded, listener.nodesAddedList);
+ Assertions.assertEquals(nodesRemoved, listener.nodesRemovedList);
}
private static ScheduledExecutorService createScheduledSingleThreadedExecutor()
diff --git a/server/src/test/java/org/apache/druid/discovery/DataNodeServiceTest.java b/server/src/test/java/org/apache/druid/discovery/DataNodeServiceTest.java
index 893959af592..3a2cabfe79c 100644
--- a/server/src/test/java/org/apache/druid/discovery/DataNodeServiceTest.java
+++ b/server/src/test/java/org/apache/druid/discovery/DataNodeServiceTest.java
@@ -22,8 +22,8 @@ package org.apache.druid.discovery;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.druid.segment.TestHelper;
import org.apache.druid.server.coordination.ServerType;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
/**
*/
@@ -47,6 +47,6 @@ public class DataNodeServiceTest
DruidService.class
);
- Assert.assertEquals(expected, actual);
+ Assertions.assertEquals(expected, actual);
}
}
diff --git a/server/src/test/java/org/apache/druid/discovery/DataServerClientTest.java b/server/src/test/java/org/apache/druid/discovery/DataServerClientTest.java
index 3577c610e6d..f51af9480f2 100644
--- a/server/src/test/java/org/apache/druid/discovery/DataServerClientTest.java
+++ b/server/src/test/java/org/apache/druid/discovery/DataServerClientTest.java
@@ -44,9 +44,9 @@ import org.apache.druid.segment.TestHelper;
import org.apache.druid.server.QueryResource;
import org.jboss.netty.handler.codec.http.HttpMethod;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
-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 javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
@@ -65,7 +65,7 @@ public class DataServerClientTest
private ScanQuery query;
private DataServerClient target;
- @Before
+ @BeforeEach
public void setUp()
{
jsonMapper = TestHelper.makeJsonMapper();
@@ -116,7 +116,7 @@ public class DataServerClientTest
Closer.create()
).get();
- Assert.assertEquals(ImmutableList.of(scanResultValue), result.toList());
+ Assertions.assertEquals(ImmutableList.of(scanResultValue), result.toList());
}
@Test
@@ -140,7 +140,7 @@ public class DataServerClientTest
Closer.create()
);
- Assert.assertEquals(1, responseContext.getMissingSegments().size());
+ Assertions.assertEquals(1, responseContext.getMissingSegments().size());
}
@Test
@@ -165,7 +165,7 @@ public class DataServerClientTest
);
ResponseContext responseContext = new DefaultResponseContext();
- Assert.assertThrows(
+ Assertions.assertThrows(
QueryTimeoutException.class,
() -> target.run(
scanQueryWithTimeout,
diff --git a/server/src/test/java/org/apache/druid/discovery/DiscoveryDruidNodeTest.java b/server/src/test/java/org/apache/druid/discovery/DiscoveryDruidNodeTest.java
index 588a8e86923..fa12cde34aa 100644
--- a/server/src/test/java/org/apache/druid/discovery/DiscoveryDruidNodeTest.java
+++ b/server/src/test/java/org/apache/druid/discovery/DiscoveryDruidNodeTest.java
@@ -29,8 +29,8 @@ import org.apache.druid.guice.ServerModule;
import org.apache.druid.jackson.DefaultObjectMapper;
import org.apache.druid.server.DruidNode;
import org.apache.druid.server.coordination.ServerType;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Collection;
@@ -75,7 +75,7 @@ public class DiscoveryDruidNodeTest
);
final String json = mapper.writeValueAsString(node);
final DiscoveryDruidNode fromJson = mapper.readValue(json, DiscoveryDruidNode.class);
- Assert.assertEquals(node, fromJson);
+ Assertions.assertEquals(node, fromJson);
}
@Test
@@ -89,7 +89,7 @@ public class DiscoveryDruidNodeTest
);
final String json = mapper.writeValueAsString(node);
final DiscoveryDruidNode fromJson = mapper.readValue(json, DiscoveryDruidNode.class);
- Assert.assertEquals(
+ Assertions.assertEquals(
new DiscoveryDruidNode(
druidNode,
nodeRole,
@@ -124,7 +124,7 @@ public class DiscoveryDruidNodeTest
)
);
final String json = mapper.writeValueAsString(node);
- Assert.assertEquals(
+ Assertions.assertEquals(
node,
mapper.readValue(json, DiscoveryDruidNode.class)
);
diff --git a/server/src/test/java/org/apache/druid/discovery/DruidNodeDiscoveryProviderTest.java b/server/src/test/java/org/apache/druid/discovery/DruidNodeDiscoveryProviderTest.java
index 0e7613cf410..8a4347dd08b 100644
--- a/server/src/test/java/org/apache/druid/discovery/DruidNodeDiscoveryProviderTest.java
+++ b/server/src/test/java/org/apache/druid/discovery/DruidNodeDiscoveryProviderTest.java
@@ -24,8 +24,8 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import org.apache.druid.server.DruidNode;
import org.apache.druid.server.coordination.ServerType;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collection;
@@ -81,11 +81,11 @@ public class DruidNodeDiscoveryProviderTest
}
);
- Assert.assertTrue(dataNodes.isEmpty());
- Assert.assertTrue(dataNodes.isEmpty());
- Assert.assertTrue(dataNodeDiscovery.getAllNodes().isEmpty());
- Assert.assertTrue(lookupNodes.isEmpty());
- Assert.assertTrue(lookupNodeDiscovery.getAllNodes().isEmpty());
+ Assertions.assertTrue(dataNodes.isEmpty());
+ Assertions.assertTrue(dataNodes.isEmpty());
+ Assertions.assertTrue(dataNodeDiscovery.getAllNodes().isEmpty());
+ Assertions.assertTrue(lookupNodes.isEmpty());
+ Assertions.assertTrue(lookupNodeDiscovery.getAllNodes().isEmpty());
DiscoveryDruidNode node1 = new DiscoveryDruidNode(
new DruidNode("s1", "h1", false, 8080, null, true, false),
@@ -161,11 +161,11 @@ public class DruidNodeDiscoveryProviderTest
provider.add(node7Clone);
provider.add(node8);
- Assert.assertEquals(ImmutableSet.of(node1, node2, node4, node5), ImmutableSet.copyOf(dataNodeDiscovery.getAllNodes()));
- Assert.assertEquals(ImmutableSet.of(node1, node2, node4, node5), dataNodes);
+ Assertions.assertEquals(ImmutableSet.of(node1, node2, node4, node5), ImmutableSet.copyOf(dataNodeDiscovery.getAllNodes()));
+ Assertions.assertEquals(ImmutableSet.of(node1, node2, node4, node5), dataNodes);
- Assert.assertEquals(ImmutableSet.of(node1, node3, node4, node6, node7), ImmutableSet.copyOf(lookupNodeDiscovery.getAllNodes()));
- Assert.assertEquals(ImmutableSet.of(node1, node3, node4, node6, node7), lookupNodes);
+ Assertions.assertEquals(ImmutableSet.of(node1, node3, node4, node6, node7), ImmutableSet.copyOf(lookupNodeDiscovery.getAllNodes()));
+ Assertions.assertEquals(ImmutableSet.of(node1, node3, node4, node6, node7), lookupNodes);
provider.remove(node8);
provider.remove(node7Clone);
@@ -173,11 +173,11 @@ public class DruidNodeDiscoveryProviderTest
provider.remove(node5);
provider.remove(node4);
- Assert.assertEquals(ImmutableSet.of(node1, node2), ImmutableSet.copyOf(dataNodeDiscovery.getAllNodes()));
- Assert.assertEquals(ImmutableSet.of(node1, node2), dataNodes);
+ Assertions.assertEquals(ImmutableSet.of(node1, node2), ImmutableSet.copyOf(dataNodeDiscovery.getAllNodes()));
+ Assertions.assertEquals(ImmutableSet.of(node1, node2), dataNodes);
- Assert.assertEquals(ImmutableSet.of(node1, node3), ImmutableSet.copyOf(lookupNodeDiscovery.getAllNodes()));
- Assert.assertEquals(ImmutableSet.of(node1, node3), lookupNodes);
+ Assertions.assertEquals(ImmutableSet.of(node1, node3), ImmutableSet.copyOf(lookupNodeDiscovery.getAllNodes()));
+ Assertions.assertEquals(ImmutableSet.of(node1, node3), lookupNodes);
}
@Test
diff --git a/server/src/test/java/org/apache/druid/discovery/LookupNodeServiceTest.java b/server/src/test/java/org/apache/druid/discovery/LookupNodeServiceTest.java
index fb1c3d79b49..be49d56e868 100644
--- a/server/src/test/java/org/apache/druid/discovery/LookupNodeServiceTest.java
+++ b/server/src/test/java/org/apache/druid/discovery/LookupNodeServiceTest.java
@@ -21,8 +21,8 @@ package org.apache.druid.discovery;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.druid.segment.TestHelper;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
/**
*/
@@ -41,6 +41,6 @@ public class LookupNodeServiceTest
DruidService.class
);
- Assert.assertEquals(expected, actual);
+ Assertions.assertEquals(expected, actual);
}
}
diff --git a/server/src/test/java/org/apache/druid/discovery/WorkerNodeServiceTest.java b/server/src/test/java/org/apache/druid/discovery/WorkerNodeServiceTest.java
index b4a08e942b9..45c38046514 100644
--- a/server/src/test/java/org/apache/druid/discovery/WorkerNodeServiceTest.java
+++ b/server/src/test/java/org/apache/druid/discovery/WorkerNodeServiceTest.java
@@ -21,8 +21,8 @@ package org.apache.druid.discovery;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.druid.segment.TestHelper;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
/**
*/
@@ -44,6 +44,6 @@ public class WorkerNodeServiceTest
DruidService.class
);
- Assert.assertEquals(expected, actual);
+ Assertions.assertEquals(expected, actual);
}
}
diff --git a/server/src/test/java/org/apache/druid/initialization/AuthorizationResultTest.java b/server/src/test/java/org/apache/druid/initialization/AuthorizationResultTest.java
index c6d62ce5713..63e654172ab 100644
--- a/server/src/test/java/org/apache/druid/initialization/AuthorizationResultTest.java
+++ b/server/src/test/java/org/apache/druid/initialization/AuthorizationResultTest.java
@@ -27,15 +27,11 @@ import org.apache.druid.query.policy.NoRestrictionPolicy;
import org.apache.druid.query.policy.RowFilterPolicy;
import org.apache.druid.segment.column.ColumnType;
import org.apache.druid.server.security.AuthorizationResult;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Optional;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
public class AuthorizationResultTest
{
@Test
@@ -58,7 +54,7 @@ public class AuthorizationResultTest
RowFilterPolicy.from(new EqualityFilter("column1", ColumnType.STRING, "val1", null)))
)
);
- assertEquals(
+ Assertions.assertEquals(
"AuthorizationResult [permission=ALLOW_WITH_RESTRICTION, failureMessage=null, policyRestrictions={table1=Optional[NO_RESTRICTION], table2=Optional[RowFilterPolicy{rowFilter=column1 = val1}]}]",
result.toString()
);
@@ -68,35 +64,35 @@ public class AuthorizationResultTest
public void testNoAccess()
{
AuthorizationResult result = AuthorizationResult.deny("this data source is not permitted");
- assertFalse(result.allowBasicAccess());
- assertFalse(result.allowAccessWithNoRestriction());
- assertEquals("this data source is not permitted", result.getErrorMessage());
- assertFalse(result.allowAccessWithNoRestriction());
+ Assertions.assertFalse(result.allowBasicAccess());
+ Assertions.assertFalse(result.allowAccessWithNoRestriction());
+ Assertions.assertEquals("this data source is not permitted", result.getErrorMessage());
+ Assertions.assertFalse(result.allowAccessWithNoRestriction());
}
@Test
public void testFullAccess()
{
AuthorizationResult result = AuthorizationResult.allowWithRestriction(ImmutableMap.of());
- assertTrue(result.allowBasicAccess());
- assertTrue(result.allowAccessWithNoRestriction());
- assertThrows(DruidException.class, result::getErrorMessage);
+ Assertions.assertTrue(result.allowBasicAccess());
+ Assertions.assertTrue(result.allowAccessWithNoRestriction());
+ Assertions.assertThrows(DruidException.class, result::getErrorMessage);
AuthorizationResult resultWithEmptyPolicy = AuthorizationResult.allowWithRestriction(ImmutableMap.of(
"table1",
Optional.empty()
));
- assertTrue(resultWithEmptyPolicy.allowBasicAccess());
- assertTrue(resultWithEmptyPolicy.allowAccessWithNoRestriction());
- assertThrows(DruidException.class, resultWithEmptyPolicy::getErrorMessage);
+ Assertions.assertTrue(resultWithEmptyPolicy.allowBasicAccess());
+ Assertions.assertTrue(resultWithEmptyPolicy.allowAccessWithNoRestriction());
+ Assertions.assertThrows(DruidException.class, resultWithEmptyPolicy::getErrorMessage);
AuthorizationResult resultWithNoRestrictionPolicy = AuthorizationResult.allowWithRestriction(ImmutableMap.of(
"table1",
Optional.of(NoRestrictionPolicy.instance())
));
- assertTrue(resultWithNoRestrictionPolicy.allowBasicAccess());
- assertTrue(resultWithNoRestrictionPolicy.allowAccessWithNoRestriction());
- assertThrows(DruidException.class, resultWithNoRestrictionPolicy::getErrorMessage);
+ Assertions.assertTrue(resultWithNoRestrictionPolicy.allowBasicAccess());
+ Assertions.assertTrue(resultWithNoRestrictionPolicy.allowAccessWithNoRestriction());
+ Assertions.assertThrows(DruidException.class, resultWithNoRestrictionPolicy::getErrorMessage);
}
@Test
@@ -111,8 +107,8 @@ public class AuthorizationResultTest
null
)))
));
- assertTrue(result.allowBasicAccess());
- assertFalse(result.allowAccessWithNoRestriction());
- assertEquals("Unauthorized", result.getErrorMessage());
+ Assertions.assertTrue(result.allowBasicAccess());
+ Assertions.assertFalse(result.allowAccessWithNoRestriction());
+ Assertions.assertEquals("Unauthorized", result.getErrorMessage());
}
}
diff --git a/server/src/test/java/org/apache/druid/initialization/ComposingEmitterModuleTest.java b/server/src/test/java/org/apache/druid/initialization/ComposingEmitterModuleTest.java
index 4a12f8d9513..f38d72b77c1 100644
--- a/server/src/test/java/org/apache/druid/initialization/ComposingEmitterModuleTest.java
+++ b/server/src/test/java/org/apache/druid/initialization/ComposingEmitterModuleTest.java
@@ -34,8 +34,8 @@ import org.apache.druid.java.util.emitter.core.Event;
import org.apache.druid.server.emitter.ComposingEmitterConfig;
import org.apache.druid.server.emitter.ComposingEmitterModule;
import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Properties;
@@ -47,7 +47,7 @@ public class ComposingEmitterModuleTest
private final String testEmitterType = "http";
private Emitter emitter;
- @Before
+ @BeforeEach
public void setup()
{
emitter = EasyMock.createMock(Emitter.class);
diff --git a/server/src/test/java/org/apache/druid/initialization/ServerConfigTest.java b/server/src/test/java/org/apache/druid/initialization/ServerConfigTest.java
index a6947be39d5..44323cde3e6 100644
--- a/server/src/test/java/org/apache/druid/initialization/ServerConfigTest.java
+++ b/server/src/test/java/org/apache/druid/initialization/ServerConfigTest.java
@@ -26,8 +26,8 @@ import org.apache.druid.common.exception.AllowedRegexErrorResponseTransformStrat
import org.apache.druid.jackson.DefaultObjectMapper;
import org.apache.druid.server.initialization.ServerConfig;
import org.eclipse.jetty.http.UriCompliance;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import javax.ws.rs.HttpMethod;
@@ -41,11 +41,11 @@ public class ServerConfigTest
ServerConfig defaultConfig = new ServerConfig();
String defaultConfigJson = OBJECT_MAPPER.writeValueAsString(defaultConfig);
ServerConfig defaultConfig2 = OBJECT_MAPPER.readValue(defaultConfigJson, ServerConfig.class);
- Assert.assertEquals(defaultConfig, defaultConfig2);
- Assert.assertFalse(defaultConfig2.isEnableForwardedRequestCustomizer());
- Assert.assertFalse(defaultConfig2.isEnableHSTS());
- Assert.assertEquals(UriCompliance.LEGACY, defaultConfig.getUriCompliance());
- Assert.assertEquals(true, defaultConfig.isEnforceStrictSNIHostChecking());
+ Assertions.assertEquals(defaultConfig, defaultConfig2);
+ Assertions.assertFalse(defaultConfig2.isEnableForwardedRequestCustomizer());
+ Assertions.assertFalse(defaultConfig2.isEnableHSTS());
+ Assertions.assertEquals(UriCompliance.LEGACY, defaultConfig.getUriCompliance());
+ Assertions.assertEquals(true, defaultConfig.isEnforceStrictSNIHostChecking());
ServerConfig modifiedConfig = new ServerConfig(
999,
@@ -74,18 +74,18 @@ public class ServerConfigTest
);
String modifiedConfigJson = OBJECT_MAPPER.writeValueAsString(modifiedConfig);
ServerConfig modifiedConfig2 = OBJECT_MAPPER.readValue(modifiedConfigJson, ServerConfig.class);
- Assert.assertEquals(modifiedConfig, modifiedConfig2);
- Assert.assertEquals(999, modifiedConfig2.getNumThreads());
- Assert.assertEquals(888, modifiedConfig2.getQueueSize());
- Assert.assertTrue(modifiedConfig2.getErrorResponseTransformStrategy() instanceof AllowedRegexErrorResponseTransformStrategy);
- Assert.assertTrue(modifiedConfig2.isEnableForwardedRequestCustomizer());
- Assert.assertEquals(1, modifiedConfig2.getAllowedHttpMethods().size());
- Assert.assertTrue(modifiedConfig2.getAllowedHttpMethods().contains(HttpMethod.OPTIONS));
- Assert.assertEquals("my-cool-policy", modifiedConfig.getContentSecurityPolicy());
- Assert.assertEquals("my-cool-policy", modifiedConfig2.getContentSecurityPolicy());
- Assert.assertTrue(modifiedConfig2.isEnableHSTS());
- Assert.assertEquals(UriCompliance.RFC3986, modifiedConfig2.getUriCompliance());
- Assert.assertFalse(modifiedConfig2.isEnforceStrictSNIHostChecking());
+ Assertions.assertEquals(modifiedConfig, modifiedConfig2);
+ Assertions.assertEquals(999, modifiedConfig2.getNumThreads());
+ Assertions.assertEquals(888, modifiedConfig2.getQueueSize());
+ Assertions.assertTrue(modifiedConfig2.getErrorResponseTransformStrategy() instanceof AllowedRegexErrorResponseTransformStrategy);
+ Assertions.assertTrue(modifiedConfig2.isEnableForwardedRequestCustomizer());
+ Assertions.assertEquals(1, modifiedConfig2.getAllowedHttpMethods().size());
+ Assertions.assertTrue(modifiedConfig2.getAllowedHttpMethods().contains(HttpMethod.OPTIONS));
+ Assertions.assertEquals("my-cool-policy", modifiedConfig.getContentSecurityPolicy());
+ Assertions.assertEquals("my-cool-policy", modifiedConfig2.getContentSecurityPolicy());
+ Assertions.assertTrue(modifiedConfig2.isEnableHSTS());
+ Assertions.assertEquals(UriCompliance.RFC3986, modifiedConfig2.getUriCompliance());
+ Assertions.assertFalse(modifiedConfig2.isEnforceStrictSNIHostChecking());
}
@Test
diff --git a/server/src/test/java/org/apache/druid/initialization/ServerInjectorBuilderTest.java b/server/src/test/java/org/apache/druid/initialization/ServerInjectorBuilderTest.java
index a4e47487bf8..21e7240b2de 100644
--- a/server/src/test/java/org/apache/druid/initialization/ServerInjectorBuilderTest.java
+++ b/server/src/test/java/org/apache/druid/initialization/ServerInjectorBuilderTest.java
@@ -37,10 +37,8 @@ import org.apache.druid.guice.TestDruidModule;
import org.apache.druid.guice.annotations.LoadScope;
import org.apache.druid.guice.annotations.Self;
import org.apache.druid.server.DruidNode;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import javax.annotation.Nullable;
import java.util.Collection;
@@ -48,9 +46,6 @@ import java.util.Set;
public class ServerInjectorBuilderTest
{
- @Rule
- public final TemporaryFolder temporaryFolder = new TemporaryFolder();
-
private Injector startupInjector()
{
return new StartupInjectorBuilder()
@@ -79,9 +74,9 @@ public class ServerInjectorBuilderTest
DruidModule.class
);
- Assert.assertTrue(
- "modules contains TestDruidModule",
- Collections2.transform(modules, fnClassName).contains(TestDruidModule.class.getName())
+ Assertions.assertTrue(
+ Collections2.transform(modules, fnClassName).contains(TestDruidModule.class.getName()),
+ "modules contains TestDruidModule"
);
}
@@ -108,9 +103,9 @@ public class ServerInjectorBuilderTest
}
)
);
- Assert.assertNotNull(injector);
- Assert.assertNotNull(ExtensionsLoader.instance(injector));
- Assert.assertSame(extnLoader, ExtensionsLoader.instance(injector));
+ Assertions.assertNotNull(injector);
+ Assertions.assertNotNull(ExtensionsLoader.instance(injector));
+ Assertions.assertSame(extnLoader, ExtensionsLoader.instance(injector));
}
@Test
@@ -129,8 +124,8 @@ public class ServerInjectorBuilderTest
)
)
);
- Assert.assertNotNull(injector);
- Assert.assertEquals(expected, injector.getInstance(Key.get(DruidNode.class, Self.class)));
+ Assertions.assertNotNull(injector);
+ Assertions.assertEquals(expected, injector.getInstance(Key.get(DruidNode.class, Self.class)));
}
@Test
@@ -147,7 +142,7 @@ public class ServerInjectorBuilderTest
@Inject
public void setNodeRoles(@Self Set<NodeRole> nodeRoles)
{
- Assert.assertTrue(nodeRoles.isEmpty());
+ Assertions.assertTrue(nodeRoles.isEmpty());
}
@Override
@@ -163,7 +158,7 @@ public class ServerInjectorBuilderTest
)
)
);
- Assert.assertNotNull(injector);
+ Assertions.assertNotNull(injector);
}
@Test
@@ -183,12 +178,12 @@ public class ServerInjectorBuilderTest
new LoadOnAnnotationTestModule()
)
);
- Assert.assertNotNull(injector);
- Assert.assertEquals(expected, injector.getInstance(Key.get(DruidNode.class, Self.class)));
- Assert.assertThrows(
- "Guice configuration errors",
+ Assertions.assertNotNull(injector);
+ Assertions.assertEquals(expected, injector.getInstance(Key.get(DruidNode.class, Self.class)));
+ Assertions.assertThrows(
ConfigurationException.class,
- () -> injector.getInstance(Key.get(String.class, Names.named("emperor")))
+ () -> injector.getInstance(Key.get(String.class, Names.named("emperor"))),
+ "Guice configuration errors"
);
}
@@ -209,9 +204,9 @@ public class ServerInjectorBuilderTest
new LoadOnAnnotationTestModule()
)
);
- Assert.assertNotNull(injector);
- Assert.assertEquals(expected, injector.getInstance(Key.get(DruidNode.class, Self.class)));
- Assert.assertEquals("I am Druid", injector.getInstance(Key.get(String.class, Names.named("emperor"))));
+ Assertions.assertNotNull(injector);
+ Assertions.assertEquals(expected, injector.getInstance(Key.get(DruidNode.class, Self.class)));
+ Assertions.assertEquals("I am Druid", injector.getInstance(Key.get(String.class, Names.named("emperor"))));
}
@LoadScope(roles = {"emperor", "druid"})
@@ -242,12 +237,12 @@ public class ServerInjectorBuilderTest
new NodeRolesInjectTestModule()
)
);
- Assert.assertNotNull(injector);
- Assert.assertEquals(expected, injector.getInstance(Key.get(DruidNode.class, Self.class)));
- Assert.assertThrows(
- "Guice configuration errors",
+ Assertions.assertNotNull(injector);
+ Assertions.assertEquals(expected, injector.getInstance(Key.get(DruidNode.class, Self.class)));
+ Assertions.assertThrows(
ConfigurationException.class,
- () -> injector.getInstance(Key.get(String.class, Names.named("emperor")))
+ () -> injector.getInstance(Key.get(String.class, Names.named("emperor"))),
+ "Guice configuration errors"
);
}
@@ -269,9 +264,9 @@ public class ServerInjectorBuilderTest
new NodeRolesInjectTestModule()
)
);
- Assert.assertNotNull(injector);
- Assert.assertEquals(expected, injector.getInstance(Key.get(DruidNode.class, Self.class)));
- Assert.assertEquals("I am Druid", injector.getInstance(Key.get(String.class, Names.named("emperor"))));
+ Assertions.assertNotNull(injector);
+ Assertions.assertEquals(expected, injector.getInstance(Key.get(DruidNode.class, Self.class)));
+ Assertions.assertEquals("I am Druid", injector.getInstance(Key.get(String.class, Names.named("emperor"))));
}
private static class NodeRolesInjectTestModule implements com.google.inject.Module
diff --git a/server/src/test/java/org/apache/druid/initialization/SwitchingEmitterModuleTest.java b/server/src/test/java/org/apache/druid/initialization/SwitchingEmitterModuleTest.java
index 78c8eb5a7fa..7f655faecbb 100644
--- a/server/src/test/java/org/apache/druid/initialization/SwitchingEmitterModuleTest.java
+++ b/server/src/test/java/org/apache/druid/initialization/SwitchingEmitterModuleTest.java
@@ -36,8 +36,8 @@ import org.apache.druid.java.util.emitter.core.Emitter;
import org.apache.druid.server.emitter.SwitchingEmitterConfig;
import org.apache.druid.server.emitter.SwitchingEmitterModule;
import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.Properties;
@@ -50,7 +50,7 @@ public class SwitchingEmitterModuleTest
private Emitter defaultEmitter;
private Emitter feed1Emitter;
- @Before
+ @BeforeEach
public void setup()
{
defaultEmitter = EasyMock.createMock(Emitter.class);
diff --git a/server/src/test/java/org/apache/druid/messages/MessageBatchTest.java b/server/src/test/java/org/apache/druid/messages/MessageBatchTest.java
index 840ee9b8872..27d0192958b 100644
--- a/server/src/test/java/org/apache/druid/messages/MessageBatchTest.java
+++ b/server/src/test/java/org/apache/druid/messages/MessageBatchTest.java
@@ -24,8 +24,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.apache.druid.segment.TestHelper;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
@@ -38,7 +38,7 @@ public class MessageBatchTest
final MessageBatch<String> batch = new MessageBatch<>(ImmutableList.of("foo", "bar"), 123L, 456L);
final MessageBatch<String> batch2 =
objectMapper.readValue(objectMapper.writeValueAsBytes(batch), new TypeReference<>() {});
- Assert.assertEquals(batch, batch2);
+ Assertions.assertEquals(batch, batch2);
}
@Test
diff --git a/server/src/test/java/org/apache/druid/messages/client/MessageRelayClientImplTest.java b/server/src/test/java/org/apache/druid/messages/client/MessageRelayClientImplTest.java
index 7b8af75c8d4..d95404ba316 100644
--- a/server/src/test/java/org/apache/druid/messages/client/MessageRelayClientImplTest.java
+++ b/server/src/test/java/org/apache/druid/messages/client/MessageRelayClientImplTest.java
@@ -32,10 +32,10 @@ import org.apache.druid.rpc.MockServiceClient;
import org.apache.druid.rpc.RequestBuilder;
import org.jboss.netty.handler.codec.http.HttpMethod;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import javax.ws.rs.core.HttpHeaders;
import java.util.Collections;
@@ -46,7 +46,7 @@ public class MessageRelayClientImplTest
private MockServiceClient serviceClient;
private MessageRelayClient<String> messageRelayClient;
- @Before
+ @BeforeEach
public void setup()
{
smileMapper = new DefaultObjectMapper(new SmileFactory(), null);
@@ -54,7 +54,7 @@ public class MessageRelayClientImplTest
messageRelayClient = new MessageRelayClientImpl<>(serviceClient, smileMapper, String.class);
}
- @After
+ @AfterEach
public void tearDown()
{
serviceClient.verify();
@@ -73,7 +73,7 @@ public class MessageRelayClientImplTest
);
final ListenableFuture<MessageBatch<String>> result = messageRelayClient.getMessages("me", MessageRelay.INIT, 0);
- Assert.assertEquals(batch, result.get());
+ Assertions.assertEquals(batch, result.get());
}
@Test
@@ -87,6 +87,6 @@ public class MessageRelayClientImplTest
);
final ListenableFuture<MessageBatch<String>> result = messageRelayClient.getMessages("me", MessageRelay.INIT, 0);
- Assert.assertEquals(new MessageBatch<>(Collections.emptyList(), MessageRelay.INIT, 0), result.get());
+ Assertions.assertEquals(new MessageBatch<>(Collections.emptyList(), MessageRelay.INIT, 0), result.get());
}
}
diff --git a/server/src/test/java/org/apache/druid/messages/client/MessageRelaysTest.java b/server/src/test/java/org/apache/druid/messages/client/MessageRelaysTest.java
index b2014450d81..d6bf3b81273 100644
--- a/server/src/test/java/org/apache/druid/messages/client/MessageRelaysTest.java
+++ b/server/src/test/java/org/apache/druid/messages/client/MessageRelaysTest.java
@@ -29,10 +29,10 @@ import org.apache.druid.messages.MessageBatch;
import org.apache.druid.messages.server.Outbox;
import org.apache.druid.messages.server.OutboxImpl;
import org.apache.druid.server.DruidNode;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collection;
@@ -55,7 +55,7 @@ public class MessageRelaysTest
private TestDiscovery discovery;
private MessageRelays<String> messageRelays;
- @Before
+ @BeforeEach
public void setUp()
{
outbox = new OutboxImpl<>();
@@ -64,7 +64,7 @@ public class MessageRelaysTest
messageRelays = new MessageRelays<>(
() -> discovery,
node -> {
- Assert.assertEquals(OUTBOX_NODE, node);
+ Assertions.assertEquals(OUTBOX_NODE, node);
return new MessageRelay<>(
MY_HOST,
node,
@@ -76,11 +76,11 @@ public class MessageRelaysTest
messageRelays.start();
}
- @After
+ @AfterEach
public void tearDown()
{
messageRelays.stop();
- Assert.assertEquals(Collections.emptyList(), discovery.getListeners());
+ Assertions.assertEquals(Collections.emptyList(), discovery.getListeners());
}
@Test
@@ -88,24 +88,24 @@ public class MessageRelaysTest
{
discovery.fire(listener -> listener.nodesAdded(Collections.singletonList(OUTBOX_DISCO_NODE)));
discovery.fire(listener -> listener.nodesRemoved(Collections.singletonList(OUTBOX_DISCO_NODE)));
- Assert.assertEquals(1, messageListener.getAdds());
- Assert.assertEquals(1, messageListener.getRemoves());
+ Assertions.assertEquals(1, messageListener.getAdds());
+ Assertions.assertEquals(1, messageListener.getRemoves());
}
@Test
public void test_messageListener()
{
discovery.fire(listener -> listener.nodesAdded(Collections.singletonList(OUTBOX_DISCO_NODE)));
- Assert.assertEquals(1, messageListener.getAdds());
- Assert.assertEquals(0, messageListener.getRemoves());
+ Assertions.assertEquals(1, messageListener.getAdds());
+ Assertions.assertEquals(0, messageListener.getRemoves());
final ListenableFuture<?> sendFuture = outbox.sendMessage(MY_HOST, "foo");
- Assert.assertEquals(ImmutableList.of("foo"), messageListener.getMessages());
- Assert.assertTrue(sendFuture.isDone());
+ Assertions.assertEquals(ImmutableList.of("foo"), messageListener.getMessages());
+ Assertions.assertTrue(sendFuture.isDone());
final ListenableFuture<?> sendFuture2 = outbox.sendMessage(MY_HOST, "bar");
- Assert.assertEquals(ImmutableList.of("foo", "bar"), messageListener.getMessages());
- Assert.assertTrue(sendFuture2.isDone());
+ Assertions.assertEquals(ImmutableList.of("foo", "bar"), messageListener.getMessages());
+ Assertions.assertTrue(sendFuture2.isDone());
}
/**
diff --git a/server/src/test/java/org/apache/druid/messages/server/OutboxImplTest.java b/server/src/test/java/org/apache/druid/messages/server/OutboxImplTest.java
index 727c1c6ee2f..cf46706d82d 100644
--- a/server/src/test/java/org/apache/druid/messages/server/OutboxImplTest.java
+++ b/server/src/test/java/org/apache/druid/messages/server/OutboxImplTest.java
@@ -25,10 +25,10 @@ import org.apache.druid.messages.MessageBatch;
import org.apache.druid.messages.client.MessageRelay;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+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.concurrent.ExecutionException;
@@ -39,13 +39,13 @@ public class OutboxImplTest
private OutboxImpl<String> outbox;
- @Before
+ @BeforeEach
public void setUp()
{
outbox = new OutboxImpl<>();
}
- @After
+ @AfterEach
public void tearDown()
{
outbox.stop();
@@ -62,49 +62,49 @@ public class OutboxImplTest
final long outboxEpoch = outbox.getOutboxEpoch(HOST);
// No messages are acknowledged.
- Assert.assertFalse(sendFuture1.isDone());
- Assert.assertFalse(sendFuture2.isDone());
- Assert.assertFalse(sendFuture3.isDone());
+ Assertions.assertFalse(sendFuture1.isDone());
+ Assertions.assertFalse(sendFuture2.isDone());
+ Assertions.assertFalse(sendFuture3.isDone());
// Request all three messages (startWatermark = 0).
- Assert.assertEquals(
+ Assertions.assertEquals(
new MessageBatch<>(ImmutableList.of("1", "2", "3"), outboxEpoch, 0),
outbox.getMessages(HOST, MessageRelay.INIT, 0).get()
);
// No messages are acknowledged.
- Assert.assertFalse(sendFuture1.isDone());
- Assert.assertFalse(sendFuture2.isDone());
- Assert.assertFalse(sendFuture3.isDone());
+ Assertions.assertFalse(sendFuture1.isDone());
+ Assertions.assertFalse(sendFuture2.isDone());
+ Assertions.assertFalse(sendFuture3.isDone());
// Request two of those messages again (startWatermark = 1).
- Assert.assertEquals(
+ Assertions.assertEquals(
new MessageBatch<>(ImmutableList.of("2", "3"), outboxEpoch, 1),
outbox.getMessages(HOST, outboxEpoch, 1).get()
);
// First message is acknowledged.
- Assert.assertTrue(sendFuture1.isDone());
- Assert.assertFalse(sendFuture2.isDone());
- Assert.assertFalse(sendFuture3.isDone());
+ Assertions.assertTrue(sendFuture1.isDone());
+ Assertions.assertFalse(sendFuture2.isDone());
+ Assertions.assertFalse(sendFuture3.isDone());
// Request the high watermark (startWatermark = 3).
final ListenableFuture<MessageBatch<String>> futureBatch = outbox.getMessages(HOST, outboxEpoch, 3);
// It's not available yet.
- Assert.assertFalse(futureBatch.isDone());
+ Assertions.assertFalse(futureBatch.isDone());
// All messages are acknowledged.
- Assert.assertTrue(sendFuture1.isDone());
- Assert.assertTrue(sendFuture2.isDone());
- Assert.assertTrue(sendFuture3.isDone());
+ Assertions.assertTrue(sendFuture1.isDone());
+ Assertions.assertTrue(sendFuture2.isDone());
+ Assertions.assertTrue(sendFuture3.isDone());
// Send one more message; futureBatch resolves.
final ListenableFuture<?> sendFuture4 = outbox.sendMessage(HOST, "4");
- Assert.assertTrue(futureBatch.isDone());
+ Assertions.assertTrue(futureBatch.isDone());
// sendFuture4 is not resolved.
- Assert.assertFalse(sendFuture4.isDone());
+ Assertions.assertFalse(sendFuture4.isDone());
}
@Test
@@ -115,12 +115,12 @@ public class OutboxImplTest
// Fetch with the wrong epoch.
final MessageBatch<String> batch = outbox.getMessages(HOST, outboxEpoch + 1, 0).get();
- Assert.assertEquals(
+ Assertions.assertEquals(
new MessageBatch<>(Collections.emptyList(), outboxEpoch, 0),
batch
);
- Assert.assertFalse(sendFuture.isDone());
+ Assertions.assertFalse(sendFuture.isDone());
}
@Test
@@ -133,28 +133,28 @@ public class OutboxImplTest
MessageRelay.INIT,
0
);
- Assert.assertFalse(batchFuture.isDone());
+ Assertions.assertFalse(batchFuture.isDone());
// Check that an outbox was created (it has an epoch).
MatcherAssert.assertThat(outbox.getOutboxEpoch(nonexistentHost), Matchers.greaterThanOrEqualTo(0L));
// getMessages future resolves when a message is sent.
final ListenableFuture<?> sendFuture = outbox.sendMessage(nonexistentHost, "foo");
- Assert.assertTrue(batchFuture.isDone());
- Assert.assertEquals(
+ Assertions.assertTrue(batchFuture.isDone());
+ Assertions.assertEquals(
new MessageBatch<>(ImmutableList.of("foo"), outbox.getOutboxEpoch(nonexistentHost), 0),
batchFuture.get()
);
// As usual, sendFuture resolves when the high watermark is requested.
- Assert.assertFalse(sendFuture.isDone());
+ Assertions.assertFalse(sendFuture.isDone());
final ListenableFuture<MessageBatch<String>> batchFuture2 =
outbox.getMessages(nonexistentHost, outbox.getOutboxEpoch(nonexistentHost), 1);
- Assert.assertTrue(sendFuture.isDone());
+ Assertions.assertTrue(sendFuture.isDone());
outbox.resetOutbox(nonexistentHost);
- Assert.assertTrue(batchFuture2.isDone());
+ Assertions.assertTrue(batchFuture2.isDone());
}
@Test
@@ -162,7 +162,7 @@ public class OutboxImplTest
{
final ListenableFuture<?> sendFuture = outbox.sendMessage(HOST, "1");
outbox.stop();
- Assert.assertTrue(sendFuture.isCancelled());
+ Assertions.assertTrue(sendFuture.isCancelled());
}
@Test
@@ -170,7 +170,7 @@ public class OutboxImplTest
{
final ListenableFuture<MessageBatch<String>> futureBatch = outbox.getMessages(HOST, MessageRelay.INIT, 0);
outbox.stop();
- Assert.assertTrue(futureBatch.isCancelled());
+ Assertions.assertTrue(futureBatch.isCancelled());
}
@Test
@@ -178,7 +178,7 @@ public class OutboxImplTest
{
final ListenableFuture<?> sendFuture = outbox.sendMessage(HOST, "1");
outbox.resetOutbox(HOST);
- Assert.assertTrue(sendFuture.isCancelled());
+ Assertions.assertTrue(sendFuture.isCancelled());
}
@Test
@@ -186,7 +186,7 @@ public class OutboxImplTest
{
final ListenableFuture<MessageBatch<String>> futureBatch = outbox.getMessages(HOST, MessageRelay.INIT, 0);
outbox.resetOutbox(HOST);
- Assert.assertTrue(futureBatch.isCancelled());
+ Assertions.assertTrue(futureBatch.isCancelled());
}
@Test
@@ -200,7 +200,7 @@ public class OutboxImplTest
{
outbox.stop();
final ListenableFuture<?> sendFuture = outbox.sendMessage(HOST, "1");
- Assert.assertTrue(sendFuture.isCancelled());
+ Assertions.assertTrue(sendFuture.isCancelled());
}
@Test
@@ -208,6 +208,6 @@ public class OutboxImplTest
{
outbox.stop();
final ListenableFuture<MessageBatch<String>> futureBatch = outbox.getMessages(HOST, MessageRelay.INIT, 0);
- Assert.assertTrue(futureBatch.isCancelled());
+ Assertions.assertTrue(futureBatch.isCancelled());
}
}
diff --git a/server/src/test/java/org/apache/druid/rpc/DiscoveryServiceLocatorTest.java b/server/src/test/java/org/apache/druid/rpc/DiscoveryServiceLocatorTest.java
index 48ae02708c7..21ca8c762c6 100644
--- a/server/src/test/java/org/apache/druid/rpc/DiscoveryServiceLocatorTest.java
+++ b/server/src/test/java/org/apache/druid/rpc/DiscoveryServiceLocatorTest.java
@@ -28,14 +28,15 @@ import org.apache.druid.discovery.DruidNodeDiscovery;
import org.apache.druid.discovery.DruidNodeDiscoveryProvider;
import org.apache.druid.discovery.NodeRole;
import org.apache.druid.server.DruidNode;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
import java.util.ArrayList;
import java.util.Collection;
@@ -43,6 +44,8 @@ import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
public class DiscoveryServiceLocatorTest
{
private static final DiscoveryDruidNode NODE1 = new DiscoveryDruidNode(
@@ -57,15 +60,12 @@ public class DiscoveryServiceLocatorTest
Collections.emptyMap()
);
- @Rule
- public MockitoRule mockitoRule = MockitoJUnit.rule();
-
@Mock
public DruidNodeDiscoveryProvider discoveryProvider;
private DiscoveryServiceLocator locator;
- @After
+ @AfterEach
public void tearDown()
{
if (locator != null) {
@@ -82,10 +82,10 @@ public class DiscoveryServiceLocatorTest
locator.start();
final ListenableFuture<ServiceLocations> future = locator.locate();
- Assert.assertFalse(future.isDone());
+ Assertions.assertFalse(future.isDone());
discovery.fire(DruidNodeDiscovery.Listener::nodeViewInitialized);
- Assert.assertEquals(ServiceLocations.forLocations(Collections.emptySet()), future.get());
+ Assertions.assertEquals(ServiceLocations.forLocations(Collections.emptySet()), future.get());
}
@Test
@@ -97,7 +97,7 @@ public class DiscoveryServiceLocatorTest
locator.start();
final ListenableFuture<ServiceLocations> future = locator.locate();
- Assert.assertFalse(future.isDone());
+ Assertions.assertFalse(future.isDone());
discovery.fire(listener -> {
listener.nodesAdded(ImmutableSet.of(NODE1));
@@ -105,7 +105,7 @@ public class DiscoveryServiceLocatorTest
listener.nodeViewInitialized();
});
- Assert.assertEquals(
+ Assertions.assertEquals(
ServiceLocations.forLocations(
ImmutableSet.of(
ServiceLocation.fromDruidNode(NODE1.getDruidNode()),
@@ -131,7 +131,7 @@ public class DiscoveryServiceLocatorTest
listener.nodesRemoved(ImmutableSet.of(NODE1));
});
- Assert.assertEquals(
+ Assertions.assertEquals(
ServiceLocations.forLocations(
ImmutableSet.of(
ServiceLocation.fromDruidNode(NODE2.getDruidNode())
@@ -152,10 +152,10 @@ public class DiscoveryServiceLocatorTest
final ListenableFuture<ServiceLocations> future = locator.locate();
locator.close();
- Assert.assertEquals(ServiceLocations.closed(), future.get()); // Call made prior to close()
- Assert.assertEquals(ServiceLocations.closed(), locator.locate().get()); // Call made after close()
+ Assertions.assertEquals(ServiceLocations.closed(), future.get()); // Call made prior to close()
+ Assertions.assertEquals(ServiceLocations.closed(), locator.locate().get()); // Call made after close()
- Assert.assertEquals(0, discovery.getListeners().size());
+ Assertions.assertEquals(0, discovery.getListeners().size());
}
private static class TestDiscovery implements DruidNodeDiscovery
diff --git a/server/src/test/java/org/apache/druid/rpc/FixedServiceLocatorTest.java b/server/src/test/java/org/apache/druid/rpc/FixedServiceLocatorTest.java
index ce58730aa31..62f88c1c698 100644
--- a/server/src/test/java/org/apache/druid/rpc/FixedServiceLocatorTest.java
+++ b/server/src/test/java/org/apache/druid/rpc/FixedServiceLocatorTest.java
@@ -22,8 +22,8 @@ package org.apache.druid.rpc;
import com.google.common.collect.ImmutableSet;
import org.apache.druid.server.coordination.DruidServerMetadata;
import org.apache.druid.server.coordination.ServerType;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.ExecutionException;
@@ -54,12 +54,12 @@ public class FixedServiceLocatorTest
@Test
public void test_constructor_rejectsNull()
{
- Assert.assertThrows(
+ Assertions.assertThrows(
NullPointerException.class,
() -> new FixedServiceLocator((ServiceLocation) null)
);
- Assert.assertThrows(
+ Assertions.assertThrows(
NullPointerException.class,
() -> new FixedServiceLocator((ServiceLocations) null)
);
@@ -71,7 +71,7 @@ public class FixedServiceLocatorTest
FixedServiceLocator serviceLocator =
new FixedServiceLocator(ServiceLocation.fromDruidServerMetadata(DATA_SERVER_1));
- Assert.assertEquals(
+ Assertions.assertEquals(
ServiceLocations.forLocation(ServiceLocation.fromDruidServerMetadata(DATA_SERVER_1)),
serviceLocator.locate().get()
);
@@ -85,7 +85,7 @@ public class FixedServiceLocatorTest
serviceLocator.close();
- Assert.assertEquals(
+ Assertions.assertEquals(
ServiceLocations.closed(),
serviceLocator.locate().get()
);
@@ -102,6 +102,6 @@ public class FixedServiceLocatorTest
);
FixedServiceLocator serviceLocator = new FixedServiceLocator(locations);
- Assert.assertEquals(locations, serviceLocator.locate().get());
+ Assertions.assertEquals(locations, serviceLocator.locate().get());
}
}
diff --git a/server/src/test/java/org/apache/druid/rpc/RequestBuilderTest.java b/server/src/test/java/org/apache/druid/rpc/RequestBuilderTest.java
index 03ca63d6198..db911bbaa60 100644
--- a/server/src/test/java/org/apache/druid/rpc/RequestBuilderTest.java
+++ b/server/src/test/java/org/apache/druid/rpc/RequestBuilderTest.java
@@ -25,14 +25,11 @@ import com.google.common.io.ByteStreams;
import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.java.util.http.client.Request;
import org.apache.druid.segment.TestHelper;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.MatcherAssert;
import org.jboss.netty.buffer.ChannelBufferInputStream;
import org.jboss.netty.handler.codec.http.HttpMethod;
import org.joda.time.Duration;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.internal.matchers.ThrowableMessageMatcher;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.net.URI;
@@ -41,15 +38,12 @@ public class RequestBuilderTest
@Test
public void test_constructor_noLeadingSlash()
{
- final IllegalArgumentException e = Assert.assertThrows(
+ final IllegalArgumentException e = Assertions.assertThrows(
IllegalArgumentException.class,
() -> new RequestBuilder(HttpMethod.GET, "q")
);
- MatcherAssert.assertThat(
- e,
- ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString("Path must start with '/'"))
- );
+ Assertions.assertTrue(e.getMessage().contains("Path must start with '/'"));
}
@Test
@@ -60,11 +54,11 @@ public class RequestBuilderTest
.header("x-test-header-2", "def")
.build(new ServiceLocation("example.com", 8888, -1, ""));
- Assert.assertEquals(HttpMethod.GET, request.getMethod());
- Assert.assertEquals(new URI("http://example.com:8888/q").toURL(), request.getUrl());
- Assert.assertEquals("abc", Iterables.getOnlyElement(request.getHeaders().get("x-test-header")));
- Assert.assertEquals("def", Iterables.getOnlyElement(request.getHeaders().get("x-test-header-2")));
- Assert.assertFalse(request.hasContent());
+ Assertions.assertEquals(HttpMethod.GET, request.getMethod());
+ Assertions.assertEquals(new URI("http://example.com:8888/q").toURL(), request.getUrl());
+ Assertions.assertEquals("abc", Iterables.getOnlyElement(request.getHeaders().get("x-test-header")));
+ Assertions.assertEquals("def", Iterables.getOnlyElement(request.getHeaders().get("x-test-header-2")));
+ Assertions.assertFalse(request.hasContent());
}
@Test
@@ -75,11 +69,11 @@ public class RequestBuilderTest
.header("x-test-header-2", "def")
.build(new ServiceLocation("example.com", 9999, 8888, "")) /* TLS preferred over plaintext */;
- Assert.assertEquals(HttpMethod.GET, request.getMethod());
- Assert.assertEquals(new URI("https://example.com:8888/q").toURL(), request.getUrl());
- Assert.assertEquals("abc", Iterables.getOnlyElement(request.getHeaders().get("x-test-header")));
- Assert.assertEquals("def", Iterables.getOnlyElement(request.getHeaders().get("x-test-header-2")));
- Assert.assertFalse(request.hasContent());
+ Assertions.assertEquals(HttpMethod.GET, request.getMethod());
+ Assertions.assertEquals(new URI("https://example.com:8888/q").toURL(), request.getUrl());
+ Assertions.assertEquals("abc", Iterables.getOnlyElement(request.getHeaders().get("x-test-header")));
+ Assertions.assertEquals("def", Iterables.getOnlyElement(request.getHeaders().get("x-test-header-2")));
+ Assertions.assertFalse(request.hasContent());
}
@Test
@@ -90,11 +84,11 @@ public class RequestBuilderTest
.header("x-test-header-2", "def")
.build(new ServiceLocation("example.com", 9999, 8888, "/base")) /* TLS preferred over plaintext */;
- Assert.assertEquals(HttpMethod.GET, request.getMethod());
- Assert.assertEquals(new URI("https://example.com:8888/base/q").toURL(), request.getUrl());
- Assert.assertEquals("abc", Iterables.getOnlyElement(request.getHeaders().get("x-test-header")));
- Assert.assertEquals("def", Iterables.getOnlyElement(request.getHeaders().get("x-test-header-2")));
- Assert.assertFalse(request.hasContent());
+ Assertions.assertEquals(HttpMethod.GET, request.getMethod());
+ Assertions.assertEquals(new URI("https://example.com:8888/base/q").toURL(), request.getUrl());
+ Assertions.assertEquals("abc", Iterables.getOnlyElement(request.getHeaders().get("x-test-header")));
+ Assertions.assertEquals("def", Iterables.getOnlyElement(request.getHeaders().get("x-test-header-2")));
+ Assertions.assertFalse(request.hasContent());
}
@Test
@@ -105,11 +99,11 @@ public class RequestBuilderTest
.header("x-test-header-2", "def")
.build(new ServiceLocation("example.com", 9999, 8888, "")) /* TLS preferred over plaintext */;
- Assert.assertEquals(HttpMethod.POST, request.getMethod());
- Assert.assertEquals(new URI("https://example.com:8888/q").toURL(), request.getUrl());
- Assert.assertEquals("abc", Iterables.getOnlyElement(request.getHeaders().get("x-test-header")));
- Assert.assertEquals("def", Iterables.getOnlyElement(request.getHeaders().get("x-test-header-2")));
- Assert.assertFalse(request.hasContent());
+ Assertions.assertEquals(HttpMethod.POST, request.getMethod());
+ Assertions.assertEquals(new URI("https://example.com:8888/q").toURL(), request.getUrl());
+ Assertions.assertEquals("abc", Iterables.getOnlyElement(request.getHeaders().get("x-test-header")));
+ Assertions.assertEquals("def", Iterables.getOnlyElement(request.getHeaders().get("x-test-header-2")));
+ Assertions.assertFalse(request.hasContent());
}
@Test
@@ -122,15 +116,15 @@ public class RequestBuilderTest
.content("application/json", StringUtils.toUtf8(json))
.build(new ServiceLocation("example.com", 9999, 8888, "")) /* TLS preferred over plaintext */;
- Assert.assertEquals(HttpMethod.POST, request.getMethod());
- Assert.assertEquals(new URI("https://example.com:8888/q").toURL(), request.getUrl());
- Assert.assertEquals("abc", Iterables.getOnlyElement(request.getHeaders().get("x-test-header")));
- Assert.assertEquals("def", Iterables.getOnlyElement(request.getHeaders().get("x-test-header-2")));
- Assert.assertTrue(request.hasContent());
+ Assertions.assertEquals(HttpMethod.POST, request.getMethod());
+ Assertions.assertEquals(new URI("https://example.com:8888/q").toURL(), request.getUrl());
+ Assertions.assertEquals("abc", Iterables.getOnlyElement(request.getHeaders().get("x-test-header")));
+ Assertions.assertEquals("def", Iterables.getOnlyElement(request.getHeaders().get("x-test-header-2")));
+ Assertions.assertTrue(request.hasContent());
// Read and verify content.
try (final ChannelBufferInputStream inputStream = new ChannelBufferInputStream(request.getContent())) {
- Assert.assertEquals(
+ Assertions.assertEquals(
json,
StringUtils.fromUtf8(ByteStreams.toByteArray(inputStream))
);
@@ -146,15 +140,15 @@ public class RequestBuilderTest
.jsonContent(TestHelper.makeJsonMapper(), ImmutableMap.of("foo", 3))
.build(new ServiceLocation("example.com", 9999, 8888, "")) /* TLS preferred over plaintext */;
- Assert.assertEquals(HttpMethod.POST, request.getMethod());
- Assert.assertEquals(new URI("https://example.com:8888/q").toURL(), request.getUrl());
- Assert.assertEquals("abc", Iterables.getOnlyElement(request.getHeaders().get("x-test-header")));
- Assert.assertEquals("def", Iterables.getOnlyElement(request.getHeaders().get("x-test-header-2")));
- Assert.assertTrue(request.hasContent());
+ Assertions.assertEquals(HttpMethod.POST, request.getMethod());
+ Assertions.assertEquals(new URI("https://example.com:8888/q").toURL(), request.getUrl());
+ Assertions.assertEquals("abc", Iterables.getOnlyElement(request.getHeaders().get("x-test-header")));
+ Assertions.assertEquals("def", Iterables.getOnlyElement(request.getHeaders().get("x-test-header-2")));
+ Assertions.assertTrue(request.hasContent());
// Read and verify content.
try (final ChannelBufferInputStream inputStream = new ChannelBufferInputStream(request.getContent())) {
- Assert.assertEquals(
+ Assertions.assertEquals(
"{\"foo\":3}",
StringUtils.fromUtf8(ByteStreams.toByteArray(inputStream))
);
@@ -164,12 +158,12 @@ public class RequestBuilderTest
@Test
public void test_timeout()
{
- Assert.assertEquals(RequestBuilder.DEFAULT_TIMEOUT, new RequestBuilder(HttpMethod.GET, "/q").getTimeout());
- Assert.assertEquals(
+ Assertions.assertEquals(RequestBuilder.DEFAULT_TIMEOUT, new RequestBuilder(HttpMethod.GET, "/q").getTimeout());
+ Assertions.assertEquals(
Duration.standardSeconds(1),
new RequestBuilder(HttpMethod.GET, "/q").timeout(Duration.standardSeconds(1)).getTimeout()
);
- Assert.assertEquals(
+ Assertions.assertEquals(
Duration.ZERO,
new RequestBuilder(HttpMethod.GET, "/q").timeout(Duration.ZERO).getTimeout()
);
diff --git a/server/src/test/java/org/apache/druid/rpc/ServiceClientImplTest.java b/server/src/test/java/org/apache/druid/rpc/ServiceClientImplTest.java
index 0b2bb7fe264..0f58ccd3a05 100644
--- a/server/src/test/java/org/apache/druid/rpc/ServiceClientImplTest.java
+++ b/server/src/test/java/org/apache/druid/rpc/ServiceClientImplTest.java
@@ -39,17 +39,16 @@ import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
import org.jboss.netty.handler.codec.http.HttpMethod;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.jboss.netty.handler.codec.http.HttpVersion;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.internal.matchers.ThrowableMessageMatcher;
+import org.junit.jupiter.api.AfterEach;
+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 org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.mockito.stubbing.OngoingStubbing;
@@ -62,6 +61,8 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.STRICT_STUBS)
public class ServiceClientImplTest
{
private static final String SERVICE_NAME = "test-service";
@@ -75,9 +76,6 @@ public class ServiceClientImplTest
private ScheduledExecutorService exec;
- @Rule
- public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);
-
@Mock
private HttpClient httpClient;
@@ -86,13 +84,13 @@ public class ServiceClientImplTest
private ServiceClient serviceClient;
- @Before
+ @BeforeEach
public void setUp()
{
exec = new NoDelayScheduledExecutorService(Execs.directExecutor());
}
- @After
+ @AfterEach
public void tearDown() throws Exception
{
exec.shutdownNow();
@@ -115,7 +113,7 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.noRetries());
final Map<String, String> response = doRequest(serviceClient, requestBuilder);
- Assert.assertEquals(expectedResponseObject, response);
+ Assertions.assertEquals(expectedResponseObject, response);
}
@Test
@@ -130,7 +128,7 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.builder().maxAttempts(2).build());
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
() -> doRequest(serviceClient, requestBuilder)
);
@@ -138,8 +136,8 @@ public class ServiceClientImplTest
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(HttpResponseException.class));
final HttpResponseException httpResponseException = (HttpResponseException) e.getCause();
- Assert.assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR, httpResponseException.getResponse().getStatus());
- Assert.assertEquals("oh no", httpResponseException.getResponse().getContent());
+ Assertions.assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR, httpResponseException.getResponse().getStatus());
+ Assertions.assertEquals("oh no", httpResponseException.getResponse().getContent());
}
@Test
@@ -156,7 +154,7 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.unlimited());
final Map<String, String> response = doRequest(serviceClient, requestBuilder);
- Assert.assertEquals(expectedResponseObject, response);
+ Assertions.assertEquals(expectedResponseObject, response);
}
@Test
@@ -171,25 +169,17 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.builder().maxAttempts(2).build());
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
() -> doRequest(serviceClient, requestBuilder)
);
- MatcherAssert.assertThat(
- e.getCause(),
- ThrowableMessageMatcher.hasMessage(
- CoreMatchers.containsString(
- "Service [test-service] request [GET https://example.com:8888/q/foo] encountered exception on attempt #2"
- )
- )
- );
+ Assertions.assertTrue(e.getCause().getMessage().contains(
+ "Service [test-service] request [GET https://example.com:8888/q/foo] encountered exception on attempt #2"
+ ));
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(RpcException.class));
MatcherAssert.assertThat(e.getCause().getCause(), CoreMatchers.instanceOf(IOException.class));
- MatcherAssert.assertThat(
- e.getCause().getCause(),
- ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString("oh no"))
- );
+ Assertions.assertTrue(e.getCause().getCause().getMessage().contains("oh no"));
}
@Test
@@ -207,7 +197,7 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.unlimited());
final Map<String, String> response = doRequest(serviceClient, requestBuilder);
- Assert.assertEquals(expectedResponseObject, response);
+ Assertions.assertEquals(expectedResponseObject, response);
}
@Test
@@ -221,20 +211,15 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.builder().maxAttempts(2).build());
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
() -> doRequest(serviceClient, requestBuilder)
);
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(RpcException.class));
- MatcherAssert.assertThat(
- e.getCause(),
- ThrowableMessageMatcher.hasMessage(
- CoreMatchers.containsString(
- "Service [test-service] request [GET https://example.com:8888/q/foo] encountered exception on attempt #2"
- )
- )
- );
+ Assertions.assertTrue(e.getCause().getMessage().contains(
+ "Service [test-service] request [GET https://example.com:8888/q/foo] encountered exception on attempt #2"
+ ));
}
@Test
@@ -253,7 +238,7 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.unlimited());
final Map<String, String> response = doRequest(serviceClient, requestBuilder);
- Assert.assertEquals(expectedResponseObject, response);
+ Assertions.assertEquals(expectedResponseObject, response);
}
@Test
@@ -271,7 +256,7 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.noRetries());
final Map<String, String> response = doRequest(serviceClient, requestBuilder);
- Assert.assertEquals(expectedResponseObject, response);
+ Assertions.assertEquals(expectedResponseObject, response);
}
@Test
@@ -289,7 +274,7 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.noRetries());
final Map<String, String> response = doRequest(serviceClient, requestBuilder);
- Assert.assertEquals(expectedResponseObject, response);
+ Assertions.assertEquals(expectedResponseObject, response);
}
@Test
@@ -310,16 +295,13 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.noRetries());
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
() -> doRequest(serviceClient, requestBuilder)
);
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(ServiceNotAvailableException.class));
- MatcherAssert.assertThat(
- e.getCause(),
- ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString("issued too many redirects"))
- );
+ Assertions.assertTrue(e.getCause().getMessage().contains("issued too many redirects"));
}
@Test
@@ -345,7 +327,7 @@ public class ServiceClientImplTest
final Map<String, String> response = doRequest(serviceClient, requestBuilder);
- Assert.assertEquals(expectedResponseObject, response);
+ Assertions.assertEquals(expectedResponseObject, response);
}
@Test
@@ -360,16 +342,13 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.builder().maxAttempts(10).build());
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
() -> doRequest(serviceClient, requestBuilder)
);
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(ServiceNotAvailableException.class));
- MatcherAssert.assertThat(
- e.getCause(),
- ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString("issued too many redirects"))
- );
+ Assertions.assertTrue(e.getCause().getMessage().contains("issued too many redirects"));
}
@Test
@@ -386,16 +365,13 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.builder().maxAttempts(10).build());
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
() -> doRequest(serviceClient, requestBuilder)
);
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(ServiceNotAvailableException.class));
- MatcherAssert.assertThat(
- e.getCause(),
- ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString("issued too many redirects"))
- );
+ Assertions.assertTrue(e.getCause().getMessage().contains("issued too many redirects"));
}
@Test
@@ -410,17 +386,13 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.unlimited());
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
() -> doRequest(serviceClient, requestBuilder)
);
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(RpcException.class));
- MatcherAssert.assertThat(
- e.getCause(),
- ThrowableMessageMatcher.hasMessage(
- CoreMatchers.containsString("redirected to invalid URL [invalid-url]"))
- );
+ Assertions.assertTrue(e.getCause().getMessage().contains("redirected to invalid URL [invalid-url]"));
}
@Test
@@ -435,16 +407,13 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.unlimited());
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
() -> doRequest(serviceClient, requestBuilder)
);
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(RpcException.class));
- MatcherAssert.assertThat(
- e.getCause(),
- ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString("redirected to invalid URL [null]"))
- );
+ Assertions.assertTrue(e.getCause().getMessage().contains("redirected to invalid URL [null]"));
}
@Test
@@ -459,17 +428,15 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.noRetries());
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
() -> doRequest(serviceClient, requestBuilder)
);
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(ServiceNotAvailableException.class));
- MatcherAssert.assertThat(
- e.getCause(),
- ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString(
- "issued redirect to unknown URL [https://example.com:9999/q/foo]"))
- );
+ Assertions.assertTrue(e.getCause().getMessage().contains(
+ "issued redirect to unknown URL [https://example.com:9999/q/foo]"
+ ));
}
@Test
@@ -482,16 +449,13 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.noRetries());
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
() -> doRequest(serviceClient, requestBuilder)
);
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(ServiceNotAvailableException.class));
- MatcherAssert.assertThat(
- e.getCause(),
- ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString("Service [test-service] is not available"))
- );
+ Assertions.assertTrue(e.getCause().getMessage().contains("Service [test-service] is not available"));
}
@Test
@@ -509,7 +473,7 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.builder().maxAttempts(2).build());
final Map<String, String> response = doRequest(serviceClient, requestBuilder);
- Assert.assertEquals(expectedResponseObject, response);
+ Assertions.assertEquals(expectedResponseObject, response);
}
@Test
@@ -527,16 +491,13 @@ public class ServiceClientImplTest
.build()
);
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
() -> doRequest(serviceClient, requestBuilder)
);
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(ServiceNotAvailableException.class));
- MatcherAssert.assertThat(
- e.getCause(),
- ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString("Service [test-service] is not available"))
- );
+ Assertions.assertTrue(e.getCause().getMessage().contains("Service [test-service] is not available"));
}
@Test
@@ -551,16 +512,13 @@ public class ServiceClientImplTest
// Use an unlimited retry policy to ensure that the future actually resolves.
serviceClient = makeServiceClient(StandardRetryPolicy.unlimited());
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
() -> doRequest(serviceClient, requestBuilder)
);
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(ServiceClosedException.class));
- MatcherAssert.assertThat(
- e.getCause(),
- ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString("Service [test-service] is closed"))
- );
+ Assertions.assertTrue(e.getCause().getMessage().contains("Service [test-service] is closed"));
}
@Test
@@ -575,23 +533,15 @@ public class ServiceClientImplTest
// Use an unlimited retry policy to ensure that the future actually resolves.
serviceClient = makeServiceClient(StandardRetryPolicy.unlimited());
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
() -> doRequest(serviceClient, requestBuilder)
);
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(RpcException.class));
MatcherAssert.assertThat(e.getCause().getCause(), CoreMatchers.instanceOf(IllegalStateException.class));
- MatcherAssert.assertThat(
- e.getCause(),
- ThrowableMessageMatcher.hasMessage(
- CoreMatchers.containsString("Service [test-service] locator encountered exception")
- )
- );
- MatcherAssert.assertThat(
- e.getCause().getCause(),
- ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString("oh no"))
- );
+ Assertions.assertTrue(e.getCause().getMessage().contains("Service [test-service] locator encountered exception"));
+ Assertions.assertTrue(e.getCause().getCause().getMessage().contains("oh no"));
}
@Test
@@ -606,8 +556,8 @@ public class ServiceClientImplTest
final ListenableFuture<Map<String, String>> response = doAsyncRequest(serviceClient, requestBuilder);
- Assert.assertTrue(response.cancel(true));
- Assert.assertTrue(response.isCancelled());
+ Assertions.assertTrue(response.cancel(true));
+ Assertions.assertTrue(response.isCancelled());
}
@Test
@@ -624,8 +574,8 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.unlimited());
final ListenableFuture<Map<String, String>> response = doAsyncRequest(serviceClient, requestBuilder);
- Assert.assertTrue(response.cancel(true));
- Assert.assertTrue(response.isCancelled());
+ Assertions.assertTrue(response.cancel(true));
+ Assertions.assertTrue(response.isCancelled());
}
@Test
@@ -633,53 +583,53 @@ public class ServiceClientImplTest
{
final StandardRetryPolicy retryPolicy = StandardRetryPolicy.unlimited();
- Assert.assertEquals(100, ServiceClientImpl.computeBackoffMs(retryPolicy, 0));
- Assert.assertEquals(200, ServiceClientImpl.computeBackoffMs(retryPolicy, 1));
- Assert.assertEquals(3200, ServiceClientImpl.computeBackoffMs(retryPolicy, 5));
- Assert.assertEquals(30000, ServiceClientImpl.computeBackoffMs(retryPolicy, 20));
+ Assertions.assertEquals(100, ServiceClientImpl.computeBackoffMs(retryPolicy, 0));
+ Assertions.assertEquals(200, ServiceClientImpl.computeBackoffMs(retryPolicy, 1));
+ Assertions.assertEquals(3200, ServiceClientImpl.computeBackoffMs(retryPolicy, 5));
+ Assertions.assertEquals(30000, ServiceClientImpl.computeBackoffMs(retryPolicy, 20));
}
@Test
public void test_serviceLocationNoPathFromUri()
{
- Assert.assertNull(ServiceClientImpl.serviceLocationNoPathFromUri("/"));
+ Assertions.assertNull(ServiceClientImpl.serviceLocationNoPathFromUri("/"));
- Assert.assertEquals(
+ Assertions.assertEquals(
new ServiceLocation("1.2.3.4", 9999, -1, ""),
ServiceClientImpl.serviceLocationNoPathFromUri("http://1.2.3.4:9999/foo")
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new ServiceLocation("1.2.3.4", 80, -1, ""),
ServiceClientImpl.serviceLocationNoPathFromUri("http://1.2.3.4/foo")
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new ServiceLocation("1.2.3.4", -1, 9999, ""),
ServiceClientImpl.serviceLocationNoPathFromUri("https://1.2.3.4:9999/foo")
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new ServiceLocation("1.2.3.4", -1, 443, ""),
ServiceClientImpl.serviceLocationNoPathFromUri("https://1.2.3.4/foo")
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new ServiceLocation("1:2:3:4:5:6:7:8", 9999, -1, ""),
ServiceClientImpl.serviceLocationNoPathFromUri("http://[1:2:3:4:5:6:7:8]:9999/foo")
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new ServiceLocation("1:2:3:4:5:6:7:8", 80, -1, ""),
ServiceClientImpl.serviceLocationNoPathFromUri("http://[1:2:3:4:5:6:7:8]/foo")
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new ServiceLocation("1:2:3:4:5:6:7:8", -1, 9999, ""),
ServiceClientImpl.serviceLocationNoPathFromUri("https://[1:2:3:4:5:6:7:8]:9999/foo")
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new ServiceLocation("1:2:3:4:5:6:7:8", -1, 443, ""),
ServiceClientImpl.serviceLocationNoPathFromUri("https://[1:2:3:4:5:6:7:8]/foo")
);
@@ -688,10 +638,10 @@ public class ServiceClientImplTest
@Test
public void test_isRedirect()
{
- Assert.assertTrue(ServiceClientImpl.isRedirect(HttpResponseStatus.FOUND));
- Assert.assertTrue(ServiceClientImpl.isRedirect(HttpResponseStatus.MOVED_PERMANENTLY));
- Assert.assertTrue(ServiceClientImpl.isRedirect(HttpResponseStatus.TEMPORARY_REDIRECT));
- Assert.assertFalse(ServiceClientImpl.isRedirect(HttpResponseStatus.OK));
+ Assertions.assertTrue(ServiceClientImpl.isRedirect(HttpResponseStatus.FOUND));
+ Assertions.assertTrue(ServiceClientImpl.isRedirect(HttpResponseStatus.MOVED_PERMANENTLY));
+ Assertions.assertTrue(ServiceClientImpl.isRedirect(HttpResponseStatus.TEMPORARY_REDIRECT));
+ Assertions.assertFalse(ServiceClientImpl.isRedirect(HttpResponseStatus.OK));
}
private <T> OngoingStubbing<ListenableFuture<Either<StringFullResponseHolder, T>>> expectHttpCall(
@@ -729,7 +679,7 @@ public class ServiceClientImplTest
serviceClient = makeServiceClient(StandardRetryPolicy.unlimited());
final Map<String, String> response = doRequest(serviceClient, requestBuilder);
- Assert.assertEquals(expectedResponseObject, response);
+ Assertions.assertEquals(expectedResponseObject, response);
}
private void stubLocatorCall(final ServiceLocations locations)
diff --git a/server/src/test/java/org/apache/druid/rpc/ServiceLocationTest.java b/server/src/test/java/org/apache/druid/rpc/ServiceLocationTest.java
index 124a0e5eb7f..b5b8af06830 100644
--- a/server/src/test/java/org/apache/druid/rpc/ServiceLocationTest.java
+++ b/server/src/test/java/org/apache/druid/rpc/ServiceLocationTest.java
@@ -22,8 +22,8 @@ package org.apache.druid.rpc;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.apache.druid.server.coordination.DruidServerMetadata;
import org.apache.druid.server.coordination.ServerType;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.net.URI;
@@ -32,39 +32,39 @@ public class ServiceLocationTest
@Test
public void test_stripBrackets()
{
- Assert.assertEquals("1:2:3:4:5:6:7:8", ServiceLocation.stripBrackets("[1:2:3:4:5:6:7:8]"));
- Assert.assertEquals("1:2:3:4:5:6:7:8", ServiceLocation.stripBrackets("1:2:3:4:5:6:7:8"));
- Assert.assertEquals("1.2.3.4", ServiceLocation.stripBrackets("1.2.3.4"));
+ Assertions.assertEquals("1:2:3:4:5:6:7:8", ServiceLocation.stripBrackets("[1:2:3:4:5:6:7:8]"));
+ Assertions.assertEquals("1:2:3:4:5:6:7:8", ServiceLocation.stripBrackets("1:2:3:4:5:6:7:8"));
+ Assertions.assertEquals("1.2.3.4", ServiceLocation.stripBrackets("1.2.3.4"));
}
@Test
public void test_fromUri_http()
{
final ServiceLocation location = ServiceLocation.fromUri(URI.create("http://example.com:8100/xyz"));
- Assert.assertEquals("example.com", location.getHost());
- Assert.assertEquals(-1, location.getTlsPort());
- Assert.assertEquals(8100, location.getPlaintextPort());
- Assert.assertEquals("/xyz", location.getBasePath());
+ Assertions.assertEquals("example.com", location.getHost());
+ Assertions.assertEquals(-1, location.getTlsPort());
+ Assertions.assertEquals(8100, location.getPlaintextPort());
+ Assertions.assertEquals("/xyz", location.getBasePath());
}
@Test
public void test_fromUri_https_defaultPort()
{
final ServiceLocation location = ServiceLocation.fromUri(URI.create("https://example.com/xyz"));
- Assert.assertEquals("example.com", location.getHost());
- Assert.assertEquals(443, location.getTlsPort());
- Assert.assertEquals(-1, location.getPlaintextPort());
- Assert.assertEquals("/xyz", location.getBasePath());
+ Assertions.assertEquals("example.com", location.getHost());
+ Assertions.assertEquals(443, location.getTlsPort());
+ Assertions.assertEquals(-1, location.getPlaintextPort());
+ Assertions.assertEquals("/xyz", location.getBasePath());
}
@Test
public void test_fromUri_https()
{
final ServiceLocation location = ServiceLocation.fromUri(URI.create("https://example.com:8100/xyz"));
- Assert.assertEquals("example.com", location.getHost());
- Assert.assertEquals(8100, location.getTlsPort());
- Assert.assertEquals(-1, location.getPlaintextPort());
- Assert.assertEquals("/xyz", location.getBasePath());
+ Assertions.assertEquals("example.com", location.getHost());
+ Assertions.assertEquals(8100, location.getTlsPort());
+ Assertions.assertEquals(-1, location.getPlaintextPort());
+ Assertions.assertEquals("/xyz", location.getBasePath());
}
@Test
@@ -81,7 +81,7 @@ public class ServiceLocationTest
2
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new ServiceLocation("hostName", 9092, -1, ""),
ServiceLocation.fromDruidServerMetadata(druidServerMetadata)
);
@@ -101,7 +101,7 @@ public class ServiceLocationTest
2
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new ServiceLocation("hostName", -1, 8100, ""),
ServiceLocation.fromDruidServerMetadata(druidServerMetadata)
);
diff --git a/server/src/test/java/org/apache/druid/rpc/ServiceLocationsTest.java b/server/src/test/java/org/apache/druid/rpc/ServiceLocationsTest.java
index 811c4c9a909..4599cd9aa2b 100644
--- a/server/src/test/java/org/apache/druid/rpc/ServiceLocationsTest.java
+++ b/server/src/test/java/org/apache/druid/rpc/ServiceLocationsTest.java
@@ -21,8 +21,8 @@ package org.apache.druid.rpc;
import com.google.common.collect.ImmutableSet;
import nl.jqno.equalsverifier.EqualsVerifier;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
@@ -34,8 +34,8 @@ public class ServiceLocationsTest
final ServiceLocation location = new ServiceLocation("h", -1, 2, "");
final ServiceLocations locations = ServiceLocations.forLocation(location);
- Assert.assertEquals(ImmutableSet.of(location), locations.getLocations());
- Assert.assertFalse(locations.isClosed());
+ Assertions.assertEquals(ImmutableSet.of(location), locations.getLocations());
+ Assertions.assertFalse(locations.isClosed());
}
@Test
@@ -46,8 +46,8 @@ public class ServiceLocationsTest
final ServiceLocations locations = ServiceLocations.forLocations(ImmutableSet.of(location1, location2));
- Assert.assertEquals(ImmutableSet.of(location1, location2), locations.getLocations());
- Assert.assertFalse(locations.isClosed());
+ Assertions.assertEquals(ImmutableSet.of(location1, location2), locations.getLocations());
+ Assertions.assertFalse(locations.isClosed());
}
@Test
@@ -55,8 +55,8 @@ public class ServiceLocationsTest
{
final ServiceLocations locations = ServiceLocations.closed();
- Assert.assertEquals(Collections.emptySet(), locations.getLocations());
- Assert.assertTrue(locations.isClosed());
+ Assertions.assertEquals(Collections.emptySet(), locations.getLocations());
+ Assertions.assertTrue(locations.isClosed());
}
@Test
diff --git a/server/src/test/java/org/apache/druid/rpc/guice/ServiceClientModuleTest.java b/server/src/test/java/org/apache/druid/rpc/guice/ServiceClientModuleTest.java
index f039a023ad9..f667cb8db5f 100644
--- a/server/src/test/java/org/apache/druid/rpc/guice/ServiceClientModuleTest.java
+++ b/server/src/test/java/org/apache/druid/rpc/guice/ServiceClientModuleTest.java
@@ -38,22 +38,21 @@ import org.apache.druid.rpc.ServiceClient;
import org.apache.druid.rpc.ServiceClientFactory;
import org.apache.druid.rpc.ServiceLocator;
import org.apache.druid.rpc.indexing.OverlordClient;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+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 org.mockito.Mock;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
-
-import static org.junit.Assert.assertNotNull;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.WARN)
public class ServiceClientModuleTest
{
private Injector injector;
- @Rule
- public MockitoRule mockitoRule = MockitoJUnit.rule();
-
@Mock
private HttpClient httpClient;
@@ -66,7 +65,7 @@ public class ServiceClientModuleTest
@Mock
private ServiceClientFactory serviceClientFactory;
- @Before
+ @BeforeEach
public void setUp()
{
injector = Guice.createInjector(
@@ -88,42 +87,42 @@ public class ServiceClientModuleTest
@Test
public void testGetServiceClientFactory()
{
- assertNotNull(injector.getInstance(ServiceClientFactory.class));
+ Assertions.assertNotNull(injector.getInstance(ServiceClientFactory.class));
}
@Test
public void testGetOverlordClient()
{
- assertNotNull(injector.getInstance(OverlordClient.class));
+ Assertions.assertNotNull(injector.getInstance(OverlordClient.class));
}
@Test
public void testGetCoordinatorClient()
{
- assertNotNull(injector.getInstance(CoordinatorClient.class));
+ Assertions.assertNotNull(injector.getInstance(CoordinatorClient.class));
}
@Test
public void testGetBrokerClient()
{
- assertNotNull(injector.getInstance(BrokerClient.class));
+ Assertions.assertNotNull(injector.getInstance(BrokerClient.class));
}
@Test
public void testGetCoordinatorServiceClient()
{
- assertNotNull(injector.getInstance(Key.get(ServiceClient.class, Coordinator.class)));
+ Assertions.assertNotNull(injector.getInstance(Key.get(ServiceClient.class, Coordinator.class)));
}
@Test
public void testGetOverlordServiceClient()
{
- assertNotNull(injector.getInstance(Key.get(ServiceClient.class, IndexingService.class)));
+ Assertions.assertNotNull(injector.getInstance(Key.get(ServiceClient.class, IndexingService.class)));
}
@Test
public void testGetBrokerServiceClient()
{
- assertNotNull(injector.getInstance(Key.get(ServiceClient.class, Broker.class)));
+ Assertions.assertNotNull(injector.getInstance(Key.get(ServiceClient.class, Broker.class)));
}
}
diff --git a/server/src/test/java/org/apache/druid/rpc/indexing/OverlordClientImplTest.java b/server/src/test/java/org/apache/druid/rpc/indexing/OverlordClientImplTest.java
index 290f69d693e..575cb55fbeb 100644
--- a/server/src/test/java/org/apache/druid/rpc/indexing/OverlordClientImplTest.java
+++ b/server/src/test/java/org/apache/druid/rpc/indexing/OverlordClientImplTest.java
@@ -63,10 +63,10 @@ import org.jboss.netty.handler.codec.http.HttpMethod;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.joda.time.Interval;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
@@ -99,7 +99,7 @@ public class OverlordClientImplTest
private MockServiceClient serviceClient;
private OverlordClient overlordClient;
- @Before
+ @BeforeEach
public void setup()
{
jsonMapper = new DefaultObjectMapper();
@@ -107,7 +107,7 @@ public class OverlordClientImplTest
overlordClient = new OverlordClientImpl(serviceClient, jsonMapper);
}
- @After
+ @AfterEach
public void tearDown()
{
serviceClient.verify();
@@ -123,7 +123,7 @@ public class OverlordClientImplTest
StringUtils.toUtf8("http://followTheLeader")
);
- Assert.assertEquals(URI.create("http://followTheLeader"), overlordClient.findCurrentLeader().get());
+ Assertions.assertEquals(URI.create("http://followTheLeader"), overlordClient.findCurrentLeader().get());
}
@Test
@@ -136,7 +136,7 @@ public class OverlordClientImplTest
jsonMapper.writeValueAsBytes(STATUSES)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
STATUSES,
ImmutableList.copyOf(overlordClient.taskStatuses(null, null, null).get())
);
@@ -152,7 +152,7 @@ public class OverlordClientImplTest
jsonMapper.writeValueAsBytes(STATUSES)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
STATUSES,
ImmutableList.copyOf(overlordClient.taskStatuses("RUNNING", null, null).get())
);
@@ -168,7 +168,7 @@ public class OverlordClientImplTest
jsonMapper.writeValueAsBytes(STATUSES)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
STATUSES,
ImmutableList.copyOf(overlordClient.taskStatuses("RUNNING", "foo", null).get())
);
@@ -184,7 +184,7 @@ public class OverlordClientImplTest
jsonMapper.writeValueAsBytes(STATUSES)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
STATUSES,
ImmutableList.copyOf(overlordClient.taskStatuses(null, "foo", null).get())
);
@@ -203,7 +203,7 @@ public class OverlordClientImplTest
jsonMapper.writeValueAsBytes(STATUSES)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
STATUSES,
ImmutableList.copyOf(overlordClient.taskStatuses("RUNNING", "foo?", 0).get())
);
@@ -222,7 +222,7 @@ public class OverlordClientImplTest
jsonMapper.writeValueAsBytes(STATUSES)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
STATUSES,
ImmutableList.copyOf(overlordClient.taskStatuses(null, null, 0).get())
);
@@ -245,7 +245,7 @@ public class OverlordClientImplTest
jsonMapper.writeValueAsBytes(lockMap)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
lockMap,
overlordClient.findLockedIntervals(requests).get()
);
@@ -266,7 +266,7 @@ public class OverlordClientImplTest
jsonMapper.writeValueAsBytes(null)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
Collections.emptyMap(),
overlordClient.findLockedIntervals(requests).get()
);
@@ -286,7 +286,7 @@ public class OverlordClientImplTest
jsonMapper.writeValueAsBytes(Map.of("id", supervisorId, "restarted", true))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
Map.of("id", supervisorId, "restarted", "true"),
overlordClient.postSupervisor(supervisorSpec).get()
);
@@ -310,7 +310,7 @@ public class OverlordClientImplTest
jsonMapper.writeValueAsBytes(statuses)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
statuses,
ImmutableList.copyOf(overlordClient.supervisorStatuses().get())
);
@@ -330,7 +330,7 @@ public class OverlordClientImplTest
);
final ListenableFuture<TaskReport.ReportMap> future = overlordClient.taskReportAsMap(taskId);
- Assert.assertEquals(response, future.get());
+ Assertions.assertEquals(response, future.get());
}
@Test
@@ -352,13 +352,13 @@ public class OverlordClientImplTest
final ListenableFuture<TaskReport.ReportMap> future = overlordClient.taskReportAsMap(taskId);
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
future::get
);
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(HttpResponseException.class));
- Assert.assertEquals(
+ Assertions.assertEquals(
HttpResponseStatus.NOT_FOUND.getCode(),
((HttpResponseException) e.getCause()).getResponse().getStatus().getCode()
);
@@ -378,7 +378,7 @@ public class OverlordClientImplTest
final TaskReport.ReportMap actualResponse =
FutureUtils.getUnchecked(overlordClient.taskReportAsMap(taskID), true);
- Assert.assertEquals(Collections.emptyMap(), actualResponse);
+ Assertions.assertEquals(Collections.emptyMap(), actualResponse);
}
@Test
@@ -400,7 +400,7 @@ public class OverlordClientImplTest
jsonMapper.writeValueAsBytes(indexingTotalWorkerCapacityInfo)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
indexingTotalWorkerCapacityInfo,
FutureUtils.getUnchecked(overlordClient.getTotalWorkerCapacity(), true)
);
@@ -427,7 +427,7 @@ public class OverlordClientImplTest
jsonMapper.writeValueAsBytes(workers)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
workers,
FutureUtils.getUnchecked(overlordClient.getWorkers(), true)
);
@@ -448,7 +448,7 @@ public class OverlordClientImplTest
)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
Integer.valueOf(2),
FutureUtils.getUnchecked(overlordClient.killPendingSegments("foo", Intervals.of("2000/2001")), true)
);
@@ -475,7 +475,7 @@ public class OverlordClientImplTest
DefaultObjectMapper.INSTANCE.writeValueAsBytes(new TaskPayloadResponse(taskID, clientTaskQuery))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
clientTaskQuery,
overlordClient.taskPayload(taskID).get().getPayload()
);
@@ -492,7 +492,7 @@ public class OverlordClientImplTest
DefaultObjectMapper.INSTANCE.writeValueAsBytes(false)
);
- Assert.assertFalse(overlordClient.isCompactionSupervisorEnabled().get());
+ Assertions.assertFalse(overlordClient.isCompactionSupervisorEnabled().get());
}
@Test
@@ -514,7 +514,7 @@ public class OverlordClientImplTest
DefaultObjectMapper.INSTANCE.writeValueAsBytes(config)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
config,
overlordClient.getClusterCompactionConfig().get()
);
@@ -533,7 +533,7 @@ public class OverlordClientImplTest
DefaultObjectMapper.INSTANCE.writeValueAsBytes(new UpdateResponse(true))
);
- Assert.assertTrue(
+ Assertions.assertTrue(
overlordClient.updateClusterCompactionConfig(config).get().isSuccess()
);
}
@@ -559,7 +559,7 @@ public class OverlordClientImplTest
DefaultObjectMapper.INSTANCE.writeValueAsBytes(new SegmentUpdateResponse(1))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new SegmentUpdateResponse(1),
overlordClient.markSegmentAsUsed(wikiSegment.getId()).get()
);
@@ -586,7 +586,7 @@ public class OverlordClientImplTest
DefaultObjectMapper.INSTANCE.writeValueAsBytes(new SegmentUpdateResponse(1))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new SegmentUpdateResponse(1),
overlordClient.markSegmentAsUnused(wikiSegment.getId()).get()
);
@@ -620,7 +620,7 @@ public class OverlordClientImplTest
DefaultObjectMapper.INSTANCE.writeValueAsBytes(new SegmentUpdateResponse(1))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new SegmentUpdateResponse(1),
overlordClient.markNonOvershadowedSegmentsAsUsed(TestDataSource.WIKI, segmentFilter).get()
);
@@ -654,7 +654,7 @@ public class OverlordClientImplTest
DefaultObjectMapper.INSTANCE.writeValueAsBytes(new SegmentUpdateResponse(1))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new SegmentUpdateResponse(1),
overlordClient.markSegmentsAsUnused(TestDataSource.WIKI, segmentFilter).get()
);
@@ -678,7 +678,7 @@ public class OverlordClientImplTest
DefaultObjectMapper.INSTANCE.writeValueAsBytes(new SegmentUpdateResponse(3))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new SegmentUpdateResponse(3),
overlordClient.markNonOvershadowedSegmentsAsUsed(TestDataSource.WIKI, segmentFilter).get()
);
@@ -702,7 +702,7 @@ public class OverlordClientImplTest
DefaultObjectMapper.INSTANCE.writeValueAsBytes(new SegmentUpdateResponse(5))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new SegmentUpdateResponse(5),
overlordClient.markSegmentsAsUnused(TestDataSource.WIKI, segmentFilter).get()
);
@@ -723,7 +723,7 @@ public class OverlordClientImplTest
DefaultObjectMapper.INSTANCE.writeValueAsBytes(new SegmentUpdateResponse(10))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new SegmentUpdateResponse(10),
overlordClient.markNonOvershadowedSegmentsAsUsed(TestDataSource.WIKI).get()
);
@@ -744,7 +744,7 @@ public class OverlordClientImplTest
DefaultObjectMapper.INSTANCE.writeValueAsBytes(new SegmentUpdateResponse(11))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
new SegmentUpdateResponse(11),
overlordClient.markSegmentsAsUnused(TestDataSource.WIKI).get()
);
diff --git a/server/src/test/java/org/apache/druid/rpc/indexing/SpecificTaskServiceLocatorTest.java b/server/src/test/java/org/apache/druid/rpc/indexing/SpecificTaskServiceLocatorTest.java
index f7545679724..7e30bb71197 100644
--- a/server/src/test/java/org/apache/druid/rpc/indexing/SpecificTaskServiceLocatorTest.java
+++ b/server/src/test/java/org/apache/druid/rpc/indexing/SpecificTaskServiceLocatorTest.java
@@ -33,20 +33,21 @@ import org.apache.druid.rpc.ServiceLocation;
import org.apache.druid.rpc.ServiceLocations;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.internal.matchers.ThrowableMessageMatcher;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ExecutionException;
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.STRICT_STUBS)
public class SpecificTaskServiceLocatorTest
{
private static final String TASK_ID = "test-task";
@@ -54,9 +55,6 @@ public class SpecificTaskServiceLocatorTest
private static final ServiceLocation SERVICE_LOCATION1 =
new ServiceLocation("example.com", -1, 9998, "/druid/worker/v1/chat/test-task");
- @Rule
- public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);
-
@Mock
private OverlordClient overlordClient;
@@ -87,7 +85,7 @@ public class SpecificTaskServiceLocatorTest
final SpecificTaskServiceLocator locator = new SpecificTaskServiceLocator(TASK_ID, overlordClient);
final ListenableFuture<ServiceLocations> future = locator.locate();
- Assert.assertEquals(ServiceLocations.forLocations(Collections.emptySet()), future.get());
+ Assertions.assertEquals(ServiceLocations.forLocations(Collections.emptySet()), future.get());
}
@Test
@@ -97,7 +95,7 @@ public class SpecificTaskServiceLocatorTest
.thenReturn(status(TaskState.RUNNING, TASK_LOCATION1));
final SpecificTaskServiceLocator locator = new SpecificTaskServiceLocator(TASK_ID, overlordClient);
- Assert.assertEquals(ServiceLocations.forLocation(SERVICE_LOCATION1), locator.locate().get());
+ Assertions.assertEquals(ServiceLocations.forLocation(SERVICE_LOCATION1), locator.locate().get());
}
@Test
@@ -108,7 +106,7 @@ public class SpecificTaskServiceLocatorTest
final SpecificTaskServiceLocator locator = new SpecificTaskServiceLocator(TASK_ID, overlordClient);
final ListenableFuture<ServiceLocations> future = locator.locate();
- Assert.assertEquals(ServiceLocations.closed(), future.get());
+ Assertions.assertEquals(ServiceLocations.closed(), future.get());
}
@Test
@@ -138,7 +136,7 @@ public class SpecificTaskServiceLocatorTest
final SpecificTaskServiceLocator locator = new SpecificTaskServiceLocator(TASK_ID, overlordClient);
final ListenableFuture<ServiceLocations> future = locator.locate();
- Assert.assertEquals(ServiceLocations.closed(), future.get());
+ Assertions.assertEquals(ServiceLocations.closed(), future.get());
}
@Test
@@ -168,7 +166,7 @@ public class SpecificTaskServiceLocatorTest
final SpecificTaskServiceLocator locator = new SpecificTaskServiceLocator(TASK_ID, overlordClient);
final ListenableFuture<ServiceLocations> future = locator.locate();
- Assert.assertEquals(ServiceLocations.closed(), future.get());
+ Assertions.assertEquals(ServiceLocations.closed(), future.get());
}
@Test
@@ -180,12 +178,12 @@ public class SpecificTaskServiceLocatorTest
final SpecificTaskServiceLocator locator = new SpecificTaskServiceLocator(TASK_ID, overlordClient);
final ListenableFuture<ServiceLocations> future = locator.locate();
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
future::get
);
- MatcherAssert.assertThat(e, ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString("oh no")));
+ Assertions.assertTrue(e.getMessage().contains("oh no"));
MatcherAssert.assertThat(e.getCause(), CoreMatchers.instanceOf(IllegalStateException.class));
}
@@ -201,9 +199,9 @@ public class SpecificTaskServiceLocatorTest
final ListenableFuture<ServiceLocations> future = locator.locate();
locator.close();
- Assert.assertEquals(ServiceLocations.closed(), future.get()); // Call prior to close
- Assert.assertEquals(ServiceLocations.closed(), locator.locate().get()); // Call after close
- Assert.assertTrue(overlordFuture.isCancelled());
+ Assertions.assertEquals(ServiceLocations.closed(), future.get()); // Call prior to close
+ Assertions.assertEquals(ServiceLocations.closed(), locator.locate().get()); // Call after close
+ Assertions.assertTrue(overlordFuture.isCancelled());
}
private static ListenableFuture<Map<String, TaskStatus>> status(final TaskState state, final TaskLocation location)
diff --git a/server/src/test/java/org/apache/druid/segment/InlineSegmentWranglerTest.java b/server/src/test/java/org/apache/druid/segment/InlineSegmentWranglerTest.java
index 3e2ad02c9d6..536c16930e6 100644
--- a/server/src/test/java/org/apache/druid/segment/InlineSegmentWranglerTest.java
+++ b/server/src/test/java/org/apache/druid/segment/InlineSegmentWranglerTest.java
@@ -28,18 +28,13 @@ import org.apache.druid.segment.column.ColumnType;
import org.apache.druid.segment.column.RowSignature;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.List;
public class InlineSegmentWranglerTest
{
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
private final InlineSegmentWrangler factory = new InlineSegmentWrangler();
private final InlineDataSource inlineDataSource = InlineDataSource.fromIterable(
@@ -53,13 +48,11 @@ public class InlineSegmentWranglerTest
@Test
public void test_getSegmentsForIntervals_nonInline()
{
- expectedException.expect(ClassCastException.class);
- expectedException.expectMessage("TableDataSource cannot be cast");
-
- final Iterable<Segment> ignored = factory.getSegmentsForIntervals(
- new TableDataSource("foo"),
- Intervals.ONLY_ETERNITY
+ final ClassCastException exception = Assertions.assertThrows(
+ ClassCastException.class,
+ () -> factory.getSegmentsForIntervals(new TableDataSource("foo"), Intervals.ONLY_ETERNITY)
);
+ Assertions.assertTrue(exception.getMessage().contains("TableDataSource cannot be cast"));
}
@Test
@@ -72,7 +65,7 @@ public class InlineSegmentWranglerTest
)
);
- Assert.assertEquals(1, segments.size());
+ Assertions.assertEquals(1, segments.size());
final Segment segment = Iterables.getOnlyElement(segments);
MatcherAssert.assertThat(segment, CoreMatchers.instanceOf(RowBasedSegment.class));
diff --git a/server/src/test/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifierTest.java b/server/src/test/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifierTest.java
index 86fde003cfa..393d33a710b 100644
--- a/server/src/test/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifierTest.java
+++ b/server/src/test/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifierTest.java
@@ -27,8 +27,8 @@ import org.apache.druid.query.SegmentDescriptor;
import org.easymock.EasyMock;
import org.joda.time.Duration;
import org.joda.time.Interval;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -69,9 +69,9 @@ public class CoordinatorBasedSegmentHandoffNotifierTest
);
notifier.checkForSegmentHandoffs();
// callback should have registered
- Assert.assertEquals(1, notifier.getHandOffCallbacks().size());
- Assert.assertTrue(notifier.getHandOffCallbacks().containsKey(descriptor));
- Assert.assertFalse(callbackCalled.get());
+ Assertions.assertEquals(1, notifier.getHandOffCallbacks().size());
+ Assertions.assertTrue(notifier.getHandOffCallbacks().containsKey(descriptor));
+ Assertions.assertFalse(callbackCalled.get());
EasyMock.verify(coordinatorClient);
}
@@ -99,12 +99,12 @@ public class CoordinatorBasedSegmentHandoffNotifierTest
Execs.directExecutor(),
() -> callbackCalled.set(true)
);
- Assert.assertEquals(1, notifier.getHandOffCallbacks().size());
- Assert.assertTrue(notifier.getHandOffCallbacks().containsKey(descriptor));
+ Assertions.assertEquals(1, notifier.getHandOffCallbacks().size());
+ Assertions.assertTrue(notifier.getHandOffCallbacks().containsKey(descriptor));
notifier.checkForSegmentHandoffs();
// callback should have been removed
- Assert.assertTrue(notifier.getHandOffCallbacks().isEmpty());
- Assert.assertTrue(callbackCalled.get());
+ Assertions.assertTrue(notifier.getHandOffCallbacks().isEmpty());
+ Assertions.assertTrue(callbackCalled.get());
EasyMock.verify(coordinatorClient);
}
}
diff --git a/server/src/test/java/org/apache/druid/segment/loading/LoadSpecTest.java b/server/src/test/java/org/apache/druid/segment/loading/LoadSpecTest.java
index 57b322aa87b..eeed47a02b9 100644
--- a/server/src/test/java/org/apache/druid/segment/loading/LoadSpecTest.java
+++ b/server/src/test/java/org/apache/druid/segment/loading/LoadSpecTest.java
@@ -31,11 +31,11 @@ import org.apache.druid.guice.GuiceAnnotationIntrospector;
import org.apache.druid.guice.GuiceInjectableValues;
import org.apache.druid.guice.GuiceInjectors;
import org.apache.druid.jackson.DefaultObjectMapper;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedClass;
+import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.util.Collection;
@@ -43,10 +43,10 @@ import java.util.Collection;
/**
*
*/
-@RunWith(Parameterized.class)
+@ParameterizedClass
+@MethodSource("getParameters")
public class LoadSpecTest
{
- @Parameterized.Parameters
public static Collection<Object[]> getParameters()
{
return ImmutableList.of(
@@ -65,7 +65,7 @@ public class LoadSpecTest
private static ObjectMapper mapper;
- @BeforeClass
+ @BeforeAll
public static void setUp()
{
final Injector injector = GuiceInjectors.makeStartupInjectorWithModules(
@@ -95,6 +95,6 @@ public class LoadSpecTest
public void testStringResolve() throws IOException
{
LoadSpec loadSpec = mapper.readValue(value, LoadSpec.class);
- Assert.assertEquals(expectedId, loadSpec.getClass().getAnnotation(JsonTypeName.class).value());
+ Assertions.assertEquals(expectedId, loadSpec.getClass().getAnnotation(JsonTypeName.class).value());
}
}
diff --git a/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentKillerTest.java b/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentKillerTest.java
index 2dd6667165a..ef0875e4e08 100644
--- a/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentKillerTest.java
+++ b/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentKillerTest.java
@@ -23,20 +23,21 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.druid.java.util.common.FileUtils;
import org.apache.druid.java.util.common.Intervals;
+import org.apache.druid.testing.TemporaryFolderExtension;
import org.apache.druid.timeline.DataSegment;
import org.apache.druid.timeline.partition.NoneShardSpec;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.params.ParameterizedClass;
+import org.junit.jupiter.params.provider.MethodSource;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
-@RunWith(Parameterized.class)
+@ParameterizedClass(name = "zip = {0}")
+@MethodSource("constructorFeeder")
public class LocalDataSegmentKillerTest
{
private static final String DATASOURCE_NAME = "ds";
@@ -48,14 +49,13 @@ public class LocalDataSegmentKillerTest
this.zip = zip;
}
- @Parameterized.Parameters(name = "zip = {0}")
public static Iterable<Object[]> constructorFeeder()
{
return ImmutableList.of(new Object[]{false}, new Object[]{true});
}
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @RegisterExtension
+ public final TemporaryFolderExtension temporaryFolder = new TemporaryFolderExtension();
@Test
public void testKill() throws Exception
@@ -91,26 +91,26 @@ public class LocalDataSegmentKillerTest
killer.kill(getSegmentWithPath(partition011Dir));
- Assert.assertFalse(partition011Dir.exists());
- Assert.assertTrue(partition111Dir.exists());
- Assert.assertTrue(partition021Dir.exists());
- Assert.assertTrue(partition012Dir.exists());
+ Assertions.assertFalse(partition011Dir.exists());
+ Assertions.assertTrue(partition111Dir.exists());
+ Assertions.assertTrue(partition021Dir.exists());
+ Assertions.assertTrue(partition012Dir.exists());
killer.kill(getSegmentWithPath(partition111Dir));
- Assert.assertFalse(version11Dir.exists());
- Assert.assertTrue(partition021Dir.exists());
- Assert.assertTrue(partition012Dir.exists());
+ Assertions.assertFalse(version11Dir.exists());
+ Assertions.assertTrue(partition021Dir.exists());
+ Assertions.assertTrue(partition012Dir.exists());
killer.kill(getSegmentWithPath(partition021Dir));
- Assert.assertFalse(interval1Dir.exists());
- Assert.assertTrue(partition012Dir.exists());
+ Assertions.assertFalse(interval1Dir.exists());
+ Assertions.assertTrue(partition012Dir.exists());
killer.kill(getSegmentWithPath(partition012Dir));
- Assert.assertFalse(dataSourceDir.exists());
- Assert.assertTrue(dataSourceDir.getParentFile().exists());
+ Assertions.assertFalse(dataSourceDir.exists());
+ Assertions.assertTrue(dataSourceDir.getParentFile().exists());
}
@Test
@@ -129,15 +129,15 @@ public class LocalDataSegmentKillerTest
killer.kill(getSegmentWithPath(uuidDir));
- Assert.assertFalse(uuidDir.exists());
- Assert.assertFalse(partitionDir.exists());
- Assert.assertFalse(versionDir.exists());
- Assert.assertFalse(intervalDir.exists());
- Assert.assertFalse(dataSourceDir.exists());
+ Assertions.assertFalse(uuidDir.exists());
+ Assertions.assertFalse(partitionDir.exists());
+ Assertions.assertFalse(versionDir.exists());
+ Assertions.assertFalse(intervalDir.exists());
+ Assertions.assertFalse(dataSourceDir.exists());
// Verify that we stop after the datasource dir, even though the parent is empty.
- Assert.assertTrue(emptyParentDir.exists());
- Assert.assertEquals(0, emptyParentDir.listFiles().length);
+ Assertions.assertTrue(emptyParentDir.exists());
+ Assertions.assertEquals(0, emptyParentDir.listFiles().length);
}
@Test
@@ -157,15 +157,15 @@ public class LocalDataSegmentKillerTest
killer.kill(getSegmentWithPath(uuidDir));
- Assert.assertFalse(uuidDir.exists());
- Assert.assertFalse(partitionDir.exists());
- Assert.assertFalse(versionDir.exists());
- Assert.assertFalse(intervalDir.exists());
- Assert.assertFalse(dataSourceDir.exists());
+ Assertions.assertFalse(uuidDir.exists());
+ Assertions.assertFalse(partitionDir.exists());
+ Assertions.assertFalse(versionDir.exists());
+ Assertions.assertFalse(intervalDir.exists());
+ Assertions.assertFalse(dataSourceDir.exists());
// Verify that we stop at 4 pruned paths, even if we don't encounter the datasource-named directory.
- Assert.assertTrue(emptyParentDir.exists());
- Assert.assertEquals(0, emptyParentDir.listFiles().length);
+ Assertions.assertTrue(emptyParentDir.exists());
+ Assertions.assertEquals(0, emptyParentDir.listFiles().length);
}
private void makePartitionDirWithIndex(File path) throws IOException
@@ -173,9 +173,9 @@ public class LocalDataSegmentKillerTest
FileUtils.mkdirp(path);
if (zip) {
- Assert.assertTrue(new File(path, LocalDataSegmentPusher.INDEX_ZIP_FILENAME).createNewFile());
+ Assertions.assertTrue(new File(path, LocalDataSegmentPusher.INDEX_ZIP_FILENAME).createNewFile());
} else {
- Assert.assertTrue(new File(path, LocalDataSegmentPusher.INDEX_DIR).mkdir());
+ Assertions.assertTrue(new File(path, LocalDataSegmentPusher.INDEX_DIR).mkdir());
}
}
diff --git a/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPullerTest.java b/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPullerTest.java
index 12ba9260595..1ede3aff310 100644
--- a/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPullerTest.java
+++ b/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPullerTest.java
@@ -21,13 +21,13 @@ package org.apache.druid.segment.loading;
import com.google.common.io.Files;
import org.apache.druid.java.util.common.FileUtils;
+import org.apache.druid.testing.TemporaryFolderExtension;
import org.apache.druid.utils.CompressionUtils;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import java.io.File;
import java.io.FileOutputStream;
@@ -40,19 +40,19 @@ import java.util.zip.GZIPOutputStream;
*/
public class LocalDataSegmentPullerTest
{
- @Rule
- public final TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @RegisterExtension
+ public final TemporaryFolderExtension temporaryFolder = new TemporaryFolderExtension();
private File tmpDir;
private LocalDataSegmentPuller puller;
- @Before
+ @BeforeEach
public void setup() throws IOException
{
tmpDir = temporaryFolder.newFolder();
puller = new LocalDataSegmentPuller();
}
- @After
+ @AfterEach
public void after() throws IOException
{
FileUtils.deleteDirectory(tmpDir);
@@ -70,10 +70,10 @@ public class LocalDataSegmentPullerTest
CompressionUtils.zip(tmpDir, zipFile);
file.delete();
- Assert.assertFalse(file.exists());
- Assert.assertTrue(zipFile.exists());
+ Assertions.assertFalse(file.exists());
+ Assertions.assertTrue(zipFile.exists());
puller.getSegmentFiles(zipFile, tmpDir);
- Assert.assertTrue(file.exists());
+ Assertions.assertTrue(file.exists());
}
@Test
@@ -95,10 +95,10 @@ public class LocalDataSegmentPullerTest
}
}
- Assert.assertTrue(zipFile.exists());
- Assert.assertFalse(unZipFile.exists());
+ Assertions.assertTrue(zipFile.exists());
+ Assertions.assertFalse(unZipFile.exists());
puller.getSegmentFiles(zipFile, tmpDir);
- Assert.assertTrue(unZipFile.exists());
+ Assertions.assertTrue(unZipFile.exists());
}
@Test
@@ -107,9 +107,8 @@ public class LocalDataSegmentPullerTest
File srcDir = temporaryFolder.newFolder();
File tmpFile = File.createTempFile("test", "file", srcDir);
File expectedOutput = new File(tmpDir, Files.getNameWithoutExtension(tmpFile.getAbsolutePath()));
- Assert.assertFalse(expectedOutput.exists());
+ Assertions.assertFalse(expectedOutput.exists());
puller.getSegmentFiles(srcDir, tmpDir);
- Assert.assertTrue(expectedOutput.exists());
+ Assertions.assertTrue(expectedOutput.exists());
}
}
-
diff --git a/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPusherTest.java b/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPusherTest.java
index 1512fedc4b4..d4a4e5ef642 100644
--- a/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPusherTest.java
+++ b/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPusherTest.java
@@ -25,15 +25,14 @@ import com.google.common.primitives.Ints;
import org.apache.druid.java.util.common.FileUtils;
import org.apache.druid.java.util.common.Intervals;
import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.testing.TemporaryFolderExtension;
import org.apache.druid.timeline.DataSegment;
import org.apache.druid.timeline.partition.NoneShardSpec;
import org.apache.druid.utils.CompressionUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import java.io.File;
import java.io.IOException;
@@ -41,11 +40,8 @@ import java.util.regex.Pattern;
public class LocalDataSegmentPusherTest
{
- @Rule
- public final TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- @Rule
- public ExpectedException exception = ExpectedException.none();
+ @RegisterExtension
+ public final TemporaryFolderExtension temporaryFolder = new TemporaryFolderExtension();
LocalDataSegmentPusher localDataSegmentPusher;
LocalDataSegmentPusher localDataSegmentPusherZip;
@@ -75,7 +71,7 @@ public class LocalDataSegmentPusherTest
0
);
- @Before
+ @BeforeEach
public void setUp() throws IOException
{
config = new LocalDataSegmentPusherConfig();
@@ -103,13 +99,13 @@ public class LocalDataSegmentPusherTest
DataSegment returnSegment1 = localDataSegmentPusherZip.push(dataSegmentFiles, dataSegment, false);
DataSegment returnSegment2 = localDataSegmentPusherZip.push(dataSegmentFiles, dataSegment2, false);
- Assert.assertNotNull(returnSegment1);
- Assert.assertEquals(dataSegment, returnSegment1);
+ Assertions.assertNotNull(returnSegment1);
+ Assertions.assertEquals(dataSegment, returnSegment1);
- Assert.assertNotNull(returnSegment2);
- Assert.assertEquals(dataSegment2, returnSegment2);
+ Assertions.assertNotNull(returnSegment2);
+ Assertions.assertEquals(dataSegment2, returnSegment2);
- Assert.assertNotEquals(
+ Assertions.assertNotEquals(
localDataSegmentPusherZip.getStorageDir(dataSegment, false),
localDataSegmentPusherZip.getStorageDir(dataSegment2, false)
);
@@ -120,7 +116,7 @@ public class LocalDataSegmentPusherTest
localDataSegmentPusherZip.getStorageDir(returnSegment, false)
);
File versionFile = new File(outDir, "index.zip");
- Assert.assertTrue(versionFile.exists());
+ Assertions.assertTrue(versionFile.exists());
}
}
@@ -135,13 +131,13 @@ public class LocalDataSegmentPusherTest
DataSegment returnSegment1 = localDataSegmentPusher.push(dataSegmentFiles, dataSegment, false);
DataSegment returnSegment2 = localDataSegmentPusher.push(dataSegmentFiles, dataSegment2, false);
- Assert.assertNotNull(returnSegment1);
- Assert.assertEquals(dataSegment, returnSegment1);
+ Assertions.assertNotNull(returnSegment1);
+ Assertions.assertEquals(dataSegment, returnSegment1);
- Assert.assertNotNull(returnSegment2);
- Assert.assertEquals(dataSegment2, returnSegment2);
+ Assertions.assertNotNull(returnSegment2);
+ Assertions.assertEquals(dataSegment2, returnSegment2);
- Assert.assertNotEquals(
+ Assertions.assertNotEquals(
localDataSegmentPusher.getStorageDir(dataSegment, false),
localDataSegmentPusher.getStorageDir(dataSegment2, false)
);
@@ -156,14 +152,14 @@ public class LocalDataSegmentPusherTest
);
// Check against loadSpec.
- Assert.assertEquals(
+ Assertions.assertEquals(
outDir.toURI().getPath(),
returnSegment.getLoadSpec().get("path")
);
// Check for version.bin.
File versionFile = new File(outDir, "version.bin");
- Assert.assertTrue(versionFile.exists());
+ Assertions.assertTrue(versionFile.exists());
}
}
@@ -176,8 +172,8 @@ public class LocalDataSegmentPusherTest
Pattern pattern = Pattern.compile(
".*/ds/1970-01-01T00:00:00\\.000Z_1970-01-01T00:00:00\\.001Z/v1/0/[A-Za-z0-9-]{36}/index/$"
);
- Assert.assertTrue(path, pattern.matcher(path).matches());
- Assert.assertTrue(new File(path).exists());
+ Assertions.assertTrue(pattern.matcher(path).matches(), path);
+ Assertions.assertTrue(new File(path).exists());
}
@Test
@@ -189,8 +185,8 @@ public class LocalDataSegmentPusherTest
Pattern pattern = Pattern.compile(
".*/ds/1970-01-01T00:00:00\\.000Z_1970-01-01T00:00:00\\.001Z/v1/0/[A-Za-z0-9-]{36}/index\\.zip"
);
- Assert.assertTrue(path, pattern.matcher(path).matches());
- Assert.assertTrue(new File(path).exists());
+ Assertions.assertTrue(pattern.matcher(path).matches(), path);
+ Assertions.assertTrue(new File(path).exists());
}
@Test
@@ -205,8 +201,8 @@ public class LocalDataSegmentPusherTest
DataSegment returnSegment1 = localDataSegmentPusher.push(dataSegmentFiles, dataSegment, false);
DataSegment returnSegment2 = localDataSegmentPusher.push(replicatedDataSegmentFiles, dataSegment2, false);
- Assert.assertEquals(dataSegment.getDimensions(), returnSegment1.getDimensions());
- Assert.assertEquals(dataSegment2.getDimensions(), returnSegment2.getDimensions());
+ Assertions.assertEquals(dataSegment.getDimensions(), returnSegment1.getDimensions());
+ Assertions.assertEquals(dataSegment2.getDimensions(), returnSegment2.getDimensions());
final String expectedPath = StringUtils.format(
"%s/%s",
@@ -214,11 +210,11 @@ public class LocalDataSegmentPusherTest
"ds/1970-01-01T00:00:00.000Z_1970-01-01T00:00:00.001Z/v1/0/index/"
);
- Assert.assertEquals(expectedPath, returnSegment1.getLoadSpec().get("path"));
- Assert.assertEquals(expectedPath, returnSegment2.getLoadSpec().get("path"));
+ Assertions.assertEquals(expectedPath, returnSegment1.getLoadSpec().get("path"));
+ Assertions.assertEquals(expectedPath, returnSegment2.getLoadSpec().get("path"));
final File versionFile = new File(expectedPath, "version.bin");
- Assert.assertEquals(0x8, Ints.fromByteArray(Files.toByteArray(versionFile)));
+ Assertions.assertEquals(0x8, Ints.fromByteArray(Files.toByteArray(versionFile)));
}
@Test
@@ -233,8 +229,8 @@ public class LocalDataSegmentPusherTest
DataSegment returnSegment1 = localDataSegmentPusherZip.push(dataSegmentFiles, dataSegment, false);
DataSegment returnSegment2 = localDataSegmentPusherZip.push(replicatedDataSegmentFiles, dataSegment2, false);
- Assert.assertEquals(dataSegment.getDimensions(), returnSegment1.getDimensions());
- Assert.assertEquals(dataSegment2.getDimensions(), returnSegment2.getDimensions());
+ Assertions.assertEquals(dataSegment.getDimensions(), returnSegment1.getDimensions());
+ Assertions.assertEquals(dataSegment2.getDimensions(), returnSegment2.getDimensions());
File unzipDir = new File(configZip.storageDirectory, "unzip");
FileUtils.mkdirp(unzipDir);
@@ -243,28 +239,32 @@ public class LocalDataSegmentPusherTest
unzipDir
);
- Assert.assertEquals(0x8, Ints.fromByteArray(Files.toByteArray(new File(unzipDir, "version.bin"))));
+ Assertions.assertEquals(0x8, Ints.fromByteArray(Files.toByteArray(new File(unzipDir, "version.bin"))));
}
@Test
public void testPushCannotCreateDirectory() throws IOException
{
- exception.expect(IOException.class);
- exception.expectMessage("Cannot create directory");
config.storageDirectory = new File(config.storageDirectory, "xxx");
- Assert.assertTrue(config.storageDirectory.mkdir());
+ Assertions.assertTrue(config.storageDirectory.mkdir());
config.storageDirectory.setWritable(false);
- localDataSegmentPusher.push(dataSegmentFiles, dataSegment, false);
+ final IOException exception = Assertions.assertThrows(
+ IOException.class,
+ () -> localDataSegmentPusher.push(dataSegmentFiles, dataSegment, false)
+ );
+ Assertions.assertTrue(exception.getMessage().contains("Cannot create directory"));
}
@Test
public void testPushZipCannotCreateDirectory() throws IOException
{
- exception.expect(IOException.class);
- exception.expectMessage("Cannot create directory");
configZip.storageDirectory = new File(configZip.storageDirectory, "xxx");
- Assert.assertTrue(configZip.storageDirectory.mkdir());
+ Assertions.assertTrue(configZip.storageDirectory.mkdir());
configZip.storageDirectory.setWritable(false);
- localDataSegmentPusherZip.push(dataSegmentFiles, dataSegment, false);
+ final IOException exception = Assertions.assertThrows(
+ IOException.class,
+ () -> localDataSegmentPusherZip.push(dataSegmentFiles, dataSegment, false)
+ );
+ Assertions.assertTrue(exception.getMessage().contains("Cannot create directory"));
}
}
diff --git a/server/src/test/java/org/apache/druid/segment/loading/LocalFileTimestampVersionFinderTest.java b/server/src/test/java/org/apache/druid/segment/loading/LocalFileTimestampVersionFinderTest.java
index 3e8b5aee472..79f3e51d447 100644
--- a/server/src/test/java/org/apache/druid/segment/loading/LocalFileTimestampVersionFinderTest.java
+++ b/server/src/test/java/org/apache/druid/segment/loading/LocalFileTimestampVersionFinderTest.java
@@ -19,11 +19,11 @@
package org.apache.druid.segment.loading;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.apache.druid.testing.TemporaryFolderExtension;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import java.io.File;
import java.io.IOException;
@@ -32,12 +32,12 @@ import java.util.regex.Pattern;
public class LocalFileTimestampVersionFinderTest
{
- @Rule
- public final TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @RegisterExtension
+ public final TemporaryFolderExtension temporaryFolder = new TemporaryFolderExtension();
private File tmpDir;
private LocalFileTimestampVersionFinder finder;
- @Before
+ @BeforeEach
public void setup() throws IOException
{
tmpDir = temporaryFolder.newFolder();
@@ -52,11 +52,11 @@ public class LocalFileTimestampVersionFinderTest
Thread.sleep(1_000); // In order to roll over to the next unix second
File newFile = File.createTempFile("new", ".txt", tmpDir);
newFile.createNewFile();
- Assert.assertTrue(oldFile.exists());
- Assert.assertTrue(newFile.exists());
- Assert.assertNotEquals(oldFile.lastModified(), newFile.lastModified());
- Assert.assertEquals(oldFile.getParentFile(), newFile.getParentFile());
- Assert.assertEquals(
+ Assertions.assertTrue(oldFile.exists());
+ Assertions.assertTrue(newFile.exists());
+ Assertions.assertNotEquals(oldFile.lastModified(), newFile.lastModified());
+ Assertions.assertEquals(oldFile.getParentFile(), newFile.getParentFile());
+ Assertions.assertEquals(
newFile.getAbsolutePath(),
finder.getLatestVersion(oldFile.toURI(), Pattern.compile(".*\\.txt")).getPath()
);
@@ -66,8 +66,8 @@ public class LocalFileTimestampVersionFinderTest
public void testSimpleOneFileLatestVersion() throws IOException
{
File oldFile = File.createTempFile("old", ".txt", tmpDir);
- Assert.assertTrue(oldFile.exists());
- Assert.assertEquals(
+ Assertions.assertTrue(oldFile.exists());
+ Assertions.assertEquals(
oldFile.getAbsolutePath(),
finder.getLatestVersion(oldFile.toURI(), Pattern.compile(".*\\.txt")).getPath()
);
@@ -77,8 +77,8 @@ public class LocalFileTimestampVersionFinderTest
public void testSimpleOneFileLatestVersionNullMatcher() throws IOException
{
File oldFile = File.createTempFile("old", ".txt", tmpDir);
- Assert.assertTrue(oldFile.exists());
- Assert.assertEquals(
+ Assertions.assertTrue(oldFile.exists());
+ Assertions.assertEquals(
oldFile.getAbsolutePath(),
finder.getLatestVersion(oldFile.toURI(), null).getPath()
);
@@ -90,7 +90,7 @@ public class LocalFileTimestampVersionFinderTest
File oldFile = File.createTempFile("test", ".txt", tmpDir);
oldFile.delete();
URI uri = oldFile.toURI();
- Assert.assertNull(
+ Assertions.assertNull(
finder.getLatestVersion(uri, Pattern.compile(".*\\.txt"))
);
}
@@ -103,9 +103,9 @@ public class LocalFileTimestampVersionFinderTest
Thread.sleep(1_000); // In order to roll over to the next unix second
File newFile = File.createTempFile("new", ".txt", tmpDir);
newFile.createNewFile();
- Assert.assertTrue(oldFile.exists());
- Assert.assertTrue(newFile.exists());
- Assert.assertEquals(
+ Assertions.assertTrue(oldFile.exists());
+ Assertions.assertTrue(newFile.exists());
+ Assertions.assertEquals(
newFile.getAbsolutePath(),
finder.getLatestVersion(oldFile.getParentFile().toURI(), Pattern.compile(".*\\.txt")).getPath()
);
@@ -116,9 +116,9 @@ public class LocalFileTimestampVersionFinderTest
{
File tmpFile = new File(tmpDir, "renames-123.gz");
tmpFile.createNewFile();
- Assert.assertTrue(tmpFile.exists());
- Assert.assertFalse(tmpFile.isDirectory());
- Assert.assertEquals(
+ Assertions.assertTrue(tmpFile.exists());
+ Assertions.assertFalse(tmpFile.isDirectory());
+ Assertions.assertEquals(
tmpFile.getAbsolutePath(),
finder.getLatestVersion(tmpDir.toURI(), Pattern.compile("renames-[0-9]*\\.gz")).getPath()
);
diff --git a/server/src/test/java/org/apache/druid/segment/loading/OmniDataSegmentArchiverTest.java b/server/src/test/java/org/apache/druid/segment/loading/OmniDataSegmentArchiverTest.java
index 0d09c750814..c7f060d000a 100644
--- a/server/src/test/java/org/apache/druid/segment/loading/OmniDataSegmentArchiverTest.java
+++ b/server/src/test/java/org/apache/druid/segment/loading/OmniDataSegmentArchiverTest.java
@@ -28,8 +28,8 @@ import org.apache.druid.guice.Binders;
import org.apache.druid.guice.GuiceInjectors;
import org.apache.druid.guice.LazySingleton;
import org.apache.druid.timeline.DataSegment;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import javax.annotation.Nullable;
@@ -57,8 +57,7 @@ public class OmniDataSegmentArchiverTest
final Injector injector = createInjector(null);
final OmniDataSegmentArchiver segmentArchiver = injector.getInstance(OmniDataSegmentArchiver.class);
- Assert.assertThrows(
- "Unknown loader type[unknown-type]. Known types are [explode]",
+ Assertions.assertThrows(
SegmentLoadingException.class,
() -> segmentArchiver.archive(segment)
);
@@ -72,8 +71,7 @@ public class OmniDataSegmentArchiverTest
final Injector injector = createInjector(null);
final OmniDataSegmentArchiver segmentArchiver = injector.getInstance(OmniDataSegmentArchiver.class);
- Assert.assertThrows(
- "BadSegmentArchiver must not have been initialized",
+ Assertions.assertThrows(
RuntimeException.class,
() -> segmentArchiver.archive(segment)
);
diff --git a/server/src/test/java/org/apache/druid/segment/loading/OmniDataSegmentKillerTest.java b/server/src/test/java/org/apache/druid/segment/loading/OmniDataSegmentKillerTest.java
index bd7d6526fec..58353060b26 100644
--- a/server/src/test/java/org/apache/druid/segment/loading/OmniDataSegmentKillerTest.java
+++ b/server/src/test/java/org/apache/druid/segment/loading/OmniDataSegmentKillerTest.java
@@ -32,8 +32,9 @@ import org.apache.druid.guice.LazySingleton;
import org.apache.druid.java.util.common.Intervals;
import org.apache.druid.timeline.DataSegment;
import org.apache.druid.timeline.partition.TombstoneShardSpec;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
import javax.annotation.Nullable;
@@ -41,9 +42,6 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.mockito.hamcrest.MockitoHamcrest.argThat;
-
public class OmniDataSegmentKillerTest
{
@Test
@@ -68,8 +66,7 @@ public class OmniDataSegmentKillerTest
final Injector injector = createInjector(null);
final OmniDataSegmentKiller segmentKiller = injector.getInstance(OmniDataSegmentKiller.class);
- Assert.assertThrows(
- "Unknown loader type[unknown-type]. Known types are [explode]",
+ Assertions.assertThrows(
SegmentLoadingException.class,
() -> segmentKiller.kill(segment)
);
@@ -83,8 +80,7 @@ public class OmniDataSegmentKillerTest
final Injector injector = createInjector(null);
final OmniDataSegmentKiller segmentKiller = injector.getInstance(OmniDataSegmentKiller.class);
- Assert.assertThrows(
- "BadSegmentKiller must not have been initialized",
+ Assertions.assertThrows(
RuntimeException.class,
() -> segmentKiller.kill(segment)
);
@@ -177,9 +173,13 @@ public class OmniDataSegmentKillerTest
segmentKiller.kill(ImmutableList.of(segment1, segment2, segment3));
Mockito.verify(killerSane, Mockito.times(1))
- .kill((List<DataSegment>) argThat(containsInAnyOrder(segment1, segment2)));
+ .kill(ArgumentMatchers.<List<DataSegment>>argThat(
+ segments -> segments.size() == 2 && segments.containsAll(ImmutableList.of(segment1, segment2))
+ ));
Mockito.verify(killerSaneTwo, Mockito.times(1))
- .kill((List<DataSegment>) argThat(containsInAnyOrder(segment3)));
+ .kill(ArgumentMatchers.<List<DataSegment>>argThat(
+ segments -> segments.size() == 1 && segments.contains(segment3)
+ ));
}
@LazySingleton
diff --git a/server/src/test/java/org/apache/druid/segment/loading/OmniDataSegmentMoverTest.java b/server/src/test/java/org/apache/druid/segment/loading/OmniDataSegmentMoverTest.java
index 9c0c26ec469..a12010e15d2 100644
--- a/server/src/test/java/org/apache/druid/segment/loading/OmniDataSegmentMoverTest.java
+++ b/server/src/test/java/org/apache/druid/segment/loading/OmniDataSegmentMoverTest.java
@@ -28,8 +28,8 @@ import org.apache.druid.guice.Binders;
import org.apache.druid.guice.GuiceInjectors;
import org.apache.druid.guice.LazySingleton;
import org.apache.druid.timeline.DataSegment;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import javax.annotation.Nullable;
@@ -59,8 +59,7 @@ public class OmniDataSegmentMoverTest
final Injector injector = createInjector(null);
final OmniDataSegmentMover segmentMover = injector.getInstance(OmniDataSegmentMover.class);
- Assert.assertThrows(
- "Unknown loader type[unknown-type]. Known types are [explode]",
+ Assertions.assertThrows(
SegmentLoadingException.class,
() -> segmentMover.move(segment, ImmutableMap.of())
);
@@ -74,8 +73,7 @@ public class OmniDataSegmentMoverTest
final Injector injector = createInjector(null);
final OmniDataSegmentMover segmentMover = injector.getInstance(OmniDataSegmentMover.class);
- Assert.assertThrows(
- "BadSegmentMover must not have been initialized",
+ Assertions.assertThrows(
RuntimeException.class,
() -> segmentMover.move(segment, null)
);
diff --git a/server/src/test/java/org/apache/druid/segment/loading/SegmentLocalCacheManagerTest.java b/server/src/test/java/org/apache/druid/segment/loading/SegmentLocalCacheManagerTest.java
index e7a9e96b3d1..59bd0d30de8 100644
--- a/server/src/test/java/org/apache/druid/segment/loading/SegmentLocalCacheManagerTest.java
+++ b/server/src/test/java/org/apache/druid/segment/loading/SegmentLocalCacheManagerTest.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.jsontype.NamedType;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
import org.apache.druid.error.DruidException;
import org.apache.druid.error.DruidExceptionMatcher;
import org.apache.druid.guice.LocalDataStorageDruidModule;
@@ -46,16 +47,16 @@ import org.apache.druid.segment.TestSegmentUtils;
import org.apache.druid.segment.column.ColumnConfig;
import org.apache.druid.server.metrics.NoopServiceEmitter;
import org.apache.druid.testing.InitializedNullHandlingTest;
+import org.apache.druid.testing.TemporaryFolderExtension;
import org.apache.druid.timeline.DataSegment;
import org.apache.druid.timeline.partition.LinearShardSpec;
import org.apache.druid.timeline.partition.TombstoneShardSpec;
import org.apache.druid.utils.CompressionUtils;
import org.joda.time.Interval;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import java.io.File;
import java.io.IOException;
@@ -65,9 +66,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-
public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
{
private static final String TEST_DATA_BASE_RELATIVE_PATH =
@@ -77,15 +75,15 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
private static final String TEST_DATA_RELATIVE_PATH_3 = TEST_DATA_BASE_RELATIVE_PATH + "2";
private static final String TEST_DATA_RELATIVE_PATH_4 = TEST_DATA_BASE_RELATIVE_PATH + "3";
- @Rule
- public final TemporaryFolder tmpFolder = new TemporaryFolder();
+ @RegisterExtension
+ public final TemporaryFolderExtension tmpFolder = new TemporaryFolderExtension();
private ObjectMapper jsonMapper;
private File segmentDeepStorageDir;
private File localSegmentCacheDir;
private SegmentLocalCacheManager manager;
- @Before
+ @BeforeEach
public void setUp() throws Exception
{
jsonMapper = TestHelper.makeJsonMapper();
@@ -111,7 +109,7 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
localSegmentCacheDir = tmpFolder.newFolder("segment_cache");
manager = makeDefaultManager(jsonMapper);
- Assert.assertTrue(manager.canHandleSegments());
+ Assertions.assertTrue(manager.canHandleSegments());
}
@Test
@@ -132,7 +130,7 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
TestIndex.INDEX_IO,
jsonMapper
);
- Assert.assertTrue(manager.canHandleSegments());
+ Assertions.assertTrue(manager.canHandleSegments());
}
@Test
@@ -150,7 +148,7 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
TestIndex.INDEX_IO,
jsonMapper
);
- Assert.assertTrue(manager.canHandleSegments());
+ Assertions.assertTrue(manager.canHandleSegments());
}
@Test
@@ -165,7 +163,7 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
TestIndex.INDEX_IO,
jsonMapper
);
- Assert.assertFalse(manager.canHandleSegments());
+ Assertions.assertFalse(manager.canHandleSegments());
}
@Test
@@ -181,7 +179,7 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
jsonMapper
);
DruidExceptionMatcher.assertThat(
- Assert.assertThrows(
+ Assertions.assertThrows(
DruidException.class,
() -> manager.getCachedSegments()
),
@@ -211,8 +209,11 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
writeSegmentFile(segment2);
manager.storeInfoFile(segment2);
- Assert.assertTrue(manager.canHandleSegments());
- assertThat(manager.getCachedSegments(), containsInAnyOrder(segment1, segment2));
+ Assertions.assertTrue(manager.canHandleSegments());
+ Assertions.assertEquals(
+ ImmutableSet.of(segment1, segment2),
+ ImmutableSet.copyOf(manager.getCachedSegments())
+ );
}
@Test
@@ -241,11 +242,14 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
);
manager.storeInfoFile(segment3);
final File segment3InfoFile = new File(baseInfoDir, segment3.getId().toString());
- Assert.assertTrue(segment3InfoFile.exists());
+ Assertions.assertTrue(segment3InfoFile.exists());
- Assert.assertTrue(manager.canHandleSegments());
- assertThat(manager.getCachedSegments(), containsInAnyOrder(segment1, segment2));
- Assert.assertFalse(segment3InfoFile.exists());
+ Assertions.assertTrue(manager.canHandleSegments());
+ Assertions.assertEquals(
+ ImmutableSet.of(segment1, segment2),
+ ImmutableSet.copyOf(manager.getCachedSegments())
+ );
+ Assertions.assertFalse(segment3InfoFile.exists());
}
@Test
@@ -260,12 +264,12 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
final File unsafeInfoFile = new File(infoDir, segment.getId().toString());
FileUtils.mkdirp(infoDir);
- Assert.assertThrows(IAE.class, () -> manager.storeInfoFile(segment));
- Assert.assertFalse(unsafeInfoFile.exists());
+ Assertions.assertThrows(IAE.class, () -> manager.storeInfoFile(segment));
+ Assertions.assertFalse(unsafeInfoFile.exists());
Files.write(unsafeInfoFile.toPath(), new byte[]{1});
manager.removeInfoFile(segment);
- Assert.assertTrue(unsafeInfoFile.exists());
+ Assertions.assertTrue(unsafeInfoFile.exists());
}
@Test
@@ -293,11 +297,11 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
}
// if bootstrapping a file that already exists it will be mounted by bootsrap
- Assert.assertNotNull(manager.getSegmentFiles(segmentToBootstrap));
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToBootstrap));
- Assert.assertFalse(unzippedSegmentPathInLocation.exists());
- Assert.assertFalse(new File(localSegmentCacheDir, segmentToBootstrap.getDataSource()).exists());
- Assert.assertTrue(new File(localSegmentCacheDir, segmentToBootstrap.getId().toString()).exists());
+ Assertions.assertFalse(unzippedSegmentPathInLocation.exists());
+ Assertions.assertFalse(new File(localSegmentCacheDir, segmentToBootstrap.getDataSource()).exists());
+ Assertions.assertTrue(new File(localSegmentCacheDir, segmentToBootstrap.getId().toString()).exists());
}
@Test
@@ -335,11 +339,11 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
}
// if bootstrapping a file that already exists it will be mounted by bootsrap
- Assert.assertNotNull(manager.getSegmentFiles(segmentToBootstrap));
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToBootstrap));
- Assert.assertFalse(unzippedSegmentPathInLocation.exists());
- Assert.assertFalse(new File(localSegmentCacheDir, segmentToBootstrap.getDataSource()).exists());
- Assert.assertTrue(new File(localSegmentCacheDir, segmentToBootstrap.getId().toString()).exists());
+ Assertions.assertFalse(unzippedSegmentPathInLocation.exists());
+ Assertions.assertFalse(new File(localSegmentCacheDir, segmentToBootstrap.getDataSource()).exists());
+ Assertions.assertTrue(new File(localSegmentCacheDir, segmentToBootstrap.getId().toString()).exists());
}
@Test
@@ -354,10 +358,10 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
);
FileUtils.mkdirp(cachedSegmentFile);
- Assert.assertTrue("Expect cache hit", manager.isSegmentCached(cachedSegment));
+ Assertions.assertTrue(manager.isSegmentCached(cachedSegment), "Expect cache hit");
final DataSegment uncachedSegment = dataSegmentWithInterval("2014-10-21T00:00:00Z/P1D");
- Assert.assertFalse("Expect cache miss", manager.isSegmentCached(uncachedSegment));
+ Assertions.assertFalse(manager.isSegmentCached(uncachedSegment), "Expect cache miss");
}
@Test
@@ -397,14 +401,14 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
new File(segmentDeepStorageDir.getCanonicalPath() + "/" + TEST_DATA_RELATIVE_PATH + "/index.zip")
);
- Assert.assertFalse("Expect cache miss before downloading segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload), "Expect cache miss before downloading segment");
manager.load(segmentToDownload);
manager.getSegmentFiles(segmentToDownload);
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload), "Expect cache hit after downloading segment");
manager.drop(segmentToDownload);
- Assert.assertFalse("Expect cache miss after dropping segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload), "Expect cache miss after dropping segment");
}
@Test
@@ -434,15 +438,15 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
final File localSegmentFile = new File(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH);
makeSegmentZip(localSegmentFile, new File(localSegmentFile, "index.zip"));
- Assert.assertFalse("Expect cache miss before downloading segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload), "Expect cache miss before downloading segment");
manager.load(segmentToDownload);
File segmentFile = manager.getSegmentFiles(segmentToDownload);
- Assert.assertTrue(segmentFile.getAbsolutePath().contains("/local_storage_folder/"));
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertTrue(segmentFile.getAbsolutePath().contains("/local_storage_folder/"));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload), "Expect cache hit after downloading segment");
manager.drop(segmentToDownload);
- Assert.assertFalse("Expect cache miss after dropping segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload), "Expect cache miss after dropping segment");
}
@Test
@@ -473,15 +477,15 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
makeSegmentZip(localSegmentFile, new File(localSegmentFile, "index.zip"));
- Assert.assertFalse("Expect cache miss before downloading segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload), "Expect cache miss before downloading segment");
manager.load(segmentToDownload);
File segmentFile = manager.getSegmentFiles(segmentToDownload);
- Assert.assertTrue(segmentFile.getAbsolutePath().contains("/local_storage_folder2/"));
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertTrue(segmentFile.getAbsolutePath().contains("/local_storage_folder2/"));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload), "Expect cache hit after downloading segment");
manager.drop(segmentToDownload);
- Assert.assertFalse("Expect cache miss after dropping segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload), "Expect cache miss after dropping segment");
}
@Test
@@ -518,11 +522,11 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
try {
// expect failure
manager.load(segmentToDownload);
- Assert.fail();
+ Assertions.fail();
}
catch (SegmentLoadingException e) {
}
- Assert.assertFalse("Expect cache miss after dropping segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload), "Expect cache miss after dropping segment");
manager.drop(segmentToDownload);
}
@@ -554,12 +558,12 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
final File localSegmentFile = new File(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH);
makeSegmentZip(localSegmentFile, new File(segmentDeepStorageDir + "/" + TEST_DATA_RELATIVE_PATH + "/index.zip"));
- Assert.assertFalse("Expect cache miss before downloading segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload), "Expect cache miss before downloading segment");
manager.load(segmentToDownload);
File segmentFile = manager.getSegmentFiles(segmentToDownload);
- Assert.assertTrue(segmentFile.getAbsolutePath().contains("/local_storage_folder/"));
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertTrue(segmentFile.getAbsolutePath().contains("/local_storage_folder/"));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload), "Expect cache hit after downloading segment");
final DataSegment segmentToDownload2 = makeTestDataSegment(segmentDeepStorageDir, 1, TEST_DATA_RELATIVE_PATH_2);
final File localSegmentFile2 = new File(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH_2);
@@ -567,11 +571,11 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
manager.load(segmentToDownload2);
File segmentFile2 = manager.getSegmentFiles(segmentToDownload2);
- Assert.assertTrue(segmentFile2.getAbsolutePath().contains("/local_storage_folder2/"));
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload2));
+ Assertions.assertTrue(segmentFile2.getAbsolutePath().contains("/local_storage_folder2/"));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload2), "Expect cache hit after downloading segment");
manager.drop(segmentToDownload2);
- Assert.assertFalse("Expect cache miss after dropping segment", manager.isSegmentCached(segmentToDownload2));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload2), "Expect cache miss after dropping segment");
}
@Test
@@ -610,29 +614,29 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
final DataSegment segmentToDownload1 = makeTestDataSegment(segmentDeepStorageDir);
createSegmentZipInLocation(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH);
- Assert.assertFalse("Expect cache miss before downloading segment", manager.isSegmentCached(segmentToDownload1));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload1), "Expect cache miss before downloading segment");
manager.load(segmentToDownload1);
File segmentFile = manager.getSegmentFiles(segmentToDownload1);
- Assert.assertTrue(segmentFile.getAbsolutePath().contains("/local_storage_folder/"));
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload1));
+ Assertions.assertTrue(segmentFile.getAbsolutePath().contains("/local_storage_folder/"));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload1), "Expect cache hit after downloading segment");
manager.drop(segmentToDownload1);
- Assert.assertFalse("Expect cache miss after dropping segment", manager.isSegmentCached(segmentToDownload1));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload1), "Expect cache miss after dropping segment");
// Segment 2 should be downloaded in local_storage_folder2
final DataSegment segmentToDownload2 = makeTestDataSegment(segmentDeepStorageDir, 1, TEST_DATA_RELATIVE_PATH_2);
createSegmentZipInLocation(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH_2);
- Assert.assertFalse("Expect cache miss before downloading segment", manager.isSegmentCached(segmentToDownload2));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload2), "Expect cache miss before downloading segment");
manager.load(segmentToDownload2);
File segmentFile2 = manager.getSegmentFiles(segmentToDownload2);
- Assert.assertTrue(segmentFile2.getAbsolutePath().contains("/local_storage_folder2/"));
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload2));
+ Assertions.assertTrue(segmentFile2.getAbsolutePath().contains("/local_storage_folder2/"));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload2), "Expect cache hit after downloading segment");
manager.drop(segmentToDownload2);
- Assert.assertFalse("Expect cache miss after dropping segment", manager.isSegmentCached(segmentToDownload2));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload2), "Expect cache miss after dropping segment");
// Segment 3 should be downloaded in local_storage_folder3
final DataSegment segmentToDownload3 = makeTestDataSegment(segmentDeepStorageDir, 2, TEST_DATA_RELATIVE_PATH_3);
@@ -640,24 +644,24 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
manager.load(segmentToDownload3);
File segmentFile3 = manager.getSegmentFiles(segmentToDownload3);
- Assert.assertTrue(segmentFile3.getAbsolutePath().contains("/local_storage_folder3/"));
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload3));
+ Assertions.assertTrue(segmentFile3.getAbsolutePath().contains("/local_storage_folder3/"));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload3), "Expect cache hit after downloading segment");
manager.drop(segmentToDownload3);
- Assert.assertFalse("Expect cache miss after dropping segment", manager.isSegmentCached(segmentToDownload3));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload3), "Expect cache miss after dropping segment");
// Segment 4 should be downloaded in local_storage_folder again, asserting round robin distribution of segments
final DataSegment segmentToDownload4 = makeTestDataSegment(segmentDeepStorageDir, 3, TEST_DATA_RELATIVE_PATH_4);
createSegmentZipInLocation(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH_4);
- Assert.assertFalse("Expect cache miss before downloading segment", manager.isSegmentCached(segmentToDownload4));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload4), "Expect cache miss before downloading segment");
manager.load(segmentToDownload4);
File segmentFile1 = manager.getSegmentFiles(segmentToDownload4);
- Assert.assertTrue(segmentFile1.getAbsolutePath().contains("/local_storage_folder/"));
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload4));
+ Assertions.assertTrue(segmentFile1.getAbsolutePath().contains("/local_storage_folder/"));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload4), "Expect cache hit after downloading segment");
manager.drop(segmentToDownload4);
- Assert.assertFalse("Expect cache miss after dropping segment", manager.isSegmentCached(segmentToDownload4));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload4), "Expect cache miss after dropping segment");
}
@Test
@@ -690,23 +694,23 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
createSegmentZipInLocation(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH);
- Assert.assertFalse("Expect cache miss before downloading segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload), "Expect cache miss before downloading segment");
manager.load(segmentToDownload);
File segmentFile = manager.getSegmentFiles(segmentToDownload);
- Assert.assertTrue(segmentFile.getAbsolutePath().contains("/local_storage_folder/"));
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertTrue(segmentFile.getAbsolutePath().contains("/local_storage_folder/"));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload), "Expect cache hit after downloading segment");
// Segment 2 should be downloaded in local_storage_folder2, segment2 size 5L
final DataSegment segmentToDownload2 = makeTestDataSegment(segmentDeepStorageDir, 5L, 1, TEST_DATA_RELATIVE_PATH_2);
createSegmentZipInLocation(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH_2);
- Assert.assertFalse("Expect cache miss before downloading segment", manager.isSegmentCached(segmentToDownload2));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload2), "Expect cache miss before downloading segment");
manager.load(segmentToDownload2);
File segmentFile2 = manager.getSegmentFiles(segmentToDownload2);
- Assert.assertTrue(segmentFile2.getAbsolutePath().contains("/local_storage_folder2/"));
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload2));
+ Assertions.assertTrue(segmentFile2.getAbsolutePath().contains("/local_storage_folder2/"));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload2), "Expect cache hit after downloading segment");
// Segment 3 should be downloaded in local_storage_folder3, segment3 size 20L
@@ -715,8 +719,8 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
manager.load(segmentToDownload3);
File segmentFile3 = manager.getSegmentFiles(segmentToDownload3);
- Assert.assertTrue(segmentFile3.getAbsolutePath().contains("/local_storage_folder3/"));
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload3));
+ Assertions.assertTrue(segmentFile3.getAbsolutePath().contains("/local_storage_folder3/"));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload3), "Expect cache hit after downloading segment");
// Now the storage locations local_storage_folder1, local_storage_folder2 and local_storage_folder3 have 10, 5 and
// 20 bytes occupied respectively. The default strategy should pick location2 (as it has least bytes used) for the
@@ -724,12 +728,12 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
final DataSegment segmentToDownload4 = makeTestDataSegment(segmentDeepStorageDir, 10L, 3, TEST_DATA_RELATIVE_PATH_4);
createSegmentZipInLocation(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH_4);
- Assert.assertFalse("Expect cache miss before downloading segment", manager.isSegmentCached(segmentToDownload4));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload4), "Expect cache miss before downloading segment");
manager.load(segmentToDownload4);
File segmentFile1 = manager.getSegmentFiles(segmentToDownload4);
- Assert.assertTrue(segmentFile1.getAbsolutePath().contains("/local_storage_folder2/"));
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload4));
+ Assertions.assertTrue(segmentFile1.getAbsolutePath().contains("/local_storage_folder2/"));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload4), "Expect cache hit after downloading segment");
}
@@ -773,23 +777,23 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
createSegmentZipInLocation(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH);
- Assert.assertFalse("Expect cache miss before downloading segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload), "Expect cache miss before downloading segment");
manager.load(segmentToDownload);
File segmentFile = manager.getSegmentFiles(segmentToDownload);
- Assert.assertTrue(segmentFile.getAbsolutePath().contains("/local_storage_folder/"));
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertTrue(segmentFile.getAbsolutePath().contains("/local_storage_folder/"));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload), "Expect cache hit after downloading segment");
// Segment 2 should be downloaded in local_storage_folder3, segment2 size 9L
final DataSegment segmentToDownload2 = makeTestDataSegment(segmentDeepStorageDir, 9L, 1, TEST_DATA_RELATIVE_PATH_2);
createSegmentZipInLocation(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH_2);
- Assert.assertFalse("Expect cache miss before downloading segment", manager.isSegmentCached(segmentToDownload2));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload2), "Expect cache miss before downloading segment");
manager.load(segmentToDownload2);
File segmentFile2 = manager.getSegmentFiles(segmentToDownload2);
- Assert.assertTrue(segmentFile2.getAbsolutePath().contains("/local_storage_folder3/"));
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload2));
+ Assertions.assertTrue(segmentFile2.getAbsolutePath().contains("/local_storage_folder3/"));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload2), "Expect cache hit after downloading segment");
// Segment 3 should not be downloaded, segment3 size 20L
@@ -799,11 +803,11 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
try {
// expect failure
manager.load(segmentToDownload3);
- Assert.fail();
+ Assertions.fail();
}
catch (SegmentLoadingException e) {
}
- Assert.assertFalse("Expect cache miss after dropping segment", manager.isSegmentCached(segmentToDownload3));
+ Assertions.assertFalse(manager.isSegmentCached(segmentToDownload3), "Expect cache miss after dropping segment");
}
@Test
@@ -816,23 +820,23 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
manager.load(segmentToDownload);
final File cachedSegmentDir = manager.getSegmentFiles(segmentToDownload);
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(segmentToDownload));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload), "Expect cache hit after downloading segment");
// Emulate a corrupted segment file
final File downloadMarker = new File(
new File(localSegmentCacheDir, segmentToDownload.getId().toString()),
SegmentLocalCacheManager.DOWNLOAD_START_MARKER_FILE_NAME
);
- Assert.assertTrue(downloadMarker.createNewFile());
+ Assertions.assertTrue(downloadMarker.createNewFile());
// create a new manager, expect corrupted segment to be cleaned out and freshly downloaded after startup
SegmentLocalCacheManager manager = makeDefaultManager(jsonMapper);
manager.load(segmentToDownload);
manager.getSegmentFiles(segmentToDownload);
// this is still true becuase
- Assert.assertTrue("Don't expect cache miss for corrupted segment file", manager.isSegmentCached(segmentToDownload));
- Assert.assertTrue(cachedSegmentDir.exists());
- Assert.assertFalse(downloadMarker.exists());
+ Assertions.assertTrue(manager.isSegmentCached(segmentToDownload), "Don't expect cache miss for corrupted segment file");
+ Assertions.assertTrue(cachedSegmentDir.exists());
+ Assertions.assertFalse(downloadMarker.exists());
}
@Test
@@ -854,9 +858,9 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
manager.bootstrap(dataSegment, SegmentLazyLoadFailCallback.NOOP);
Segment actualBootstrapSegment = manager.acquireCachedSegment(dataSegment.getId(), AcquireMode.FULL).orElse(null);
- Assert.assertNotNull(actualBootstrapSegment);
- Assert.assertEquals(dataSegment.getId(), actualBootstrapSegment.getId());
- Assert.assertEquals(dataSegment.getInterval(), actualBootstrapSegment.getDataInterval());
+ Assertions.assertNotNull(actualBootstrapSegment);
+ Assertions.assertEquals(dataSegment.getId(), actualBootstrapSegment.getId());
+ Assertions.assertEquals(dataSegment.getInterval(), actualBootstrapSegment.getDataInterval());
}
@@ -882,9 +886,9 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
manager.bootstrap(dataSegment, () -> {});
Segment actualBootstrapSegment = manager.acquireCachedSegment(dataSegment.getId(), AcquireMode.FULL).orElse(null);
- Assert.assertNotNull(actualBootstrapSegment);
- Assert.assertEquals(dataSegment.getId(), actualBootstrapSegment.getId());
- Assert.assertEquals(dataSegment.getInterval(), actualBootstrapSegment.getDataInterval());
+ Assertions.assertNotNull(actualBootstrapSegment);
+ Assertions.assertEquals(dataSegment.getId(), actualBootstrapSegment.getId());
+ Assertions.assertEquals(dataSegment.getInterval(), actualBootstrapSegment.getDataInterval());
}
@Test
@@ -910,30 +914,30 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
createSegmentZipInLocation(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH);
manager.load(segmentToLoad);
- Assert.assertNull(manager.getSegmentFiles(segmentToLoad));
- Assert.assertFalse(manager.acquireCachedSegment(segmentToLoad.getId(), AcquireMode.FULL).isPresent());
+ Assertions.assertNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertFalse(manager.acquireCachedSegment(segmentToLoad.getId(), AcquireMode.FULL).isPresent());
AcquireSegmentAction segmentAction = manager.acquireSegment(segmentToLoad, AcquireMode.FULL);
AcquireSegmentResult result = segmentAction.getSegmentFuture().get();
Optional<Segment> theSegment = result.getReferenceProvider().acquireReference();
- Assert.assertTrue(theSegment.isPresent());
- Assert.assertNotNull(manager.getSegmentFiles(segmentToLoad));
- Assert.assertEquals(segmentToLoad.getId(), theSegment.get().getId());
- Assert.assertEquals(segmentToLoad.getInterval(), theSegment.get().getDataInterval());
+ Assertions.assertTrue(theSegment.isPresent());
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertEquals(segmentToLoad.getId(), theSegment.get().getId());
+ Assertions.assertEquals(segmentToLoad.getInterval(), theSegment.get().getDataInterval());
theSegment.get().close();
segmentAction.close();
manager.drop(segmentToLoad);
// drop doesn't really drop, segments hang out until evicted
- Assert.assertNotNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToLoad));
// can actually load them again because load doesn't really do anything
AcquireSegmentAction segmentActionAfterDrop = manager.acquireSegment(segmentToLoad, AcquireMode.FULL);
AcquireSegmentResult resultAfterDrop = segmentActionAfterDrop.getSegmentFuture().get();
Optional<Segment> theSegmentAfterDrop = resultAfterDrop.getReferenceProvider().acquireReference();
- Assert.assertTrue(theSegmentAfterDrop.isPresent());
- Assert.assertNotNull(manager.getSegmentFiles(segmentToLoad));
- Assert.assertEquals(segmentToLoad.getId(), theSegmentAfterDrop.get().getId());
- Assert.assertEquals(segmentToLoad.getInterval(), theSegmentAfterDrop.get().getDataInterval());
+ Assertions.assertTrue(theSegmentAfterDrop.isPresent());
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertEquals(segmentToLoad.getId(), theSegmentAfterDrop.get().getId());
+ Assertions.assertEquals(segmentToLoad.getInterval(), theSegmentAfterDrop.get().getDataInterval());
theSegmentAfterDrop.get().close();
segmentActionAfterDrop.close();
@@ -950,7 +954,7 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
);
manager.load(segmentToLoad);
- Assert.assertTrue("segment should be cached (static, mounted) after load", manager.isSegmentCached(segmentToLoad));
+ Assertions.assertTrue(manager.isSegmentCached(segmentToLoad), "segment should be cached (static, mounted) after load");
// Take the already-loaded fast path, but do NOT invoke the supplier yet (getSegmentFuture() is what runs it).
final AcquireSegmentAction action = manager.acquireSegment(segmentToLoad, AcquireMode.FULL);
@@ -961,10 +965,10 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
// Invoking the supplier now must not NPE; the segment is reported absent (empty) instead.
final AcquireSegmentResult result = action.getSegmentFuture().get();
- Assert.assertNotNull("reference provider must never be null", result.getReferenceProvider());
- Assert.assertFalse(
- "a segment dropped before the supplier ran should be reported absent",
- result.getReferenceProvider().acquireReference().isPresent()
+ Assertions.assertNotNull(result.getReferenceProvider(), "reference provider must never be null");
+ Assertions.assertFalse(
+ result.getReferenceProvider().acquireReference().isPresent(),
+ "a segment dropped before the supplier ran should be reported absent"
);
action.close();
@@ -981,7 +985,7 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
.build();
final List<StorageLocation> storageLocations = loaderConfig.toStorageLocations();
DruidExceptionMatcher.assertThat(
- Assert.assertThrows(
+ Assertions.assertThrows(
DruidException.class,
() -> new SegmentLocalCacheManager(
storageLocations,
@@ -1022,32 +1026,32 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
createSegmentZipInLocation(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH);
manager.bootstrap(segmentToBootstrap, SegmentLazyLoadFailCallback.NOOP);
- Assert.assertNull(manager.getSegmentFiles(segmentToBootstrap));
- Assert.assertFalse(manager.acquireCachedSegment(segmentToBootstrap.getId(), AcquireMode.FULL).isPresent());
+ Assertions.assertNull(manager.getSegmentFiles(segmentToBootstrap));
+ Assertions.assertFalse(manager.acquireCachedSegment(segmentToBootstrap.getId(), AcquireMode.FULL).isPresent());
AcquireSegmentAction segmentAction = manager.acquireSegment(segmentToBootstrap, AcquireMode.FULL);
AcquireSegmentResult result = segmentAction.getSegmentFuture().get();
Optional<Segment> theSegment = result.getReferenceProvider().acquireReference();
- Assert.assertTrue(theSegment.isPresent());
- Assert.assertNotNull(manager.getSegmentFiles(segmentToBootstrap));
- Assert.assertEquals(segmentToBootstrap.getId(), theSegment.get().getId());
- Assert.assertEquals(segmentToBootstrap.getInterval(), theSegment.get().getDataInterval());
+ Assertions.assertTrue(theSegment.isPresent());
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToBootstrap));
+ Assertions.assertEquals(segmentToBootstrap.getId(), theSegment.get().getId());
+ Assertions.assertEquals(segmentToBootstrap.getInterval(), theSegment.get().getDataInterval());
theSegment.get().close();
segmentAction.close();
manager.drop(segmentToBootstrap);
// drop doesn't really drop, segments hang out until evicted
- Assert.assertNotNull(manager.getSegmentFiles(segmentToBootstrap));
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToBootstrap));
// can actually load them again because bootstrap doesn't really do anything unless the segment is already
// present in the cache
AcquireSegmentAction segmentActionAfterDrop = manager.acquireSegment(segmentToBootstrap, AcquireMode.FULL);
AcquireSegmentResult resultAfterDrop = segmentActionAfterDrop.getSegmentFuture().get();
Optional<Segment> theSegmentAfterDrop = resultAfterDrop.getReferenceProvider().acquireReference();
- Assert.assertTrue(theSegmentAfterDrop.isPresent());
- Assert.assertNotNull(manager.getSegmentFiles(segmentToBootstrap));
- Assert.assertEquals(segmentToBootstrap.getId(), theSegmentAfterDrop.get().getId());
- Assert.assertEquals(segmentToBootstrap.getInterval(), theSegmentAfterDrop.get().getDataInterval());
+ Assertions.assertTrue(theSegmentAfterDrop.isPresent());
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToBootstrap));
+ Assertions.assertEquals(segmentToBootstrap.getId(), theSegmentAfterDrop.get().getId());
+ Assertions.assertEquals(segmentToBootstrap.getInterval(), theSegmentAfterDrop.get().getDataInterval());
theSegmentAfterDrop.get().close();
segmentActionAfterDrop.close();
@@ -1093,7 +1097,7 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
}
// if bootstrapping a file that already exists it will be mounted by bootsrap
- Assert.assertNotNull(manager.getSegmentFiles(segmentToBootstrap));
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToBootstrap));
}
@Test
@@ -1105,9 +1109,9 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
createSegmentZipInLocation(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH);
manager.load(segmentToLoad);
- Assert.assertNotNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToLoad));
manager.drop(segmentToLoad);
- Assert.assertNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertNull(manager.getSegmentFiles(segmentToLoad));
// ensure that if virtual storage is not enabled, we do not download the segment (callers might have a DataSegment
// reference which was originally cached and then dropped before attempting to acquire a segment. if virtual storage
@@ -1115,10 +1119,10 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
AcquireSegmentAction segmentAction = manager.acquireSegment(segmentToLoad, AcquireMode.FULL);
AcquireSegmentResult result = segmentAction.getSegmentFuture().get();
Optional<Segment> theSegment = result.getReferenceProvider().acquireReference();
- Assert.assertFalse(theSegment.isPresent());
+ Assertions.assertFalse(theSegment.isPresent());
segmentAction.close();
- Assert.assertNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertNull(manager.getSegmentFiles(segmentToLoad));
}
@Test
@@ -1144,8 +1148,8 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
createSegmentZipInLocation(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH);
manager.load(segmentToLoad);
- Assert.assertNull(manager.getSegmentFiles(segmentToLoad));
- Assert.assertFalse(manager.acquireCachedSegment(segmentToLoad.getId(), AcquireMode.FULL).isPresent());
+ Assertions.assertNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertFalse(manager.acquireCachedSegment(segmentToLoad.getId(), AcquireMode.FULL).isPresent());
AcquireSegmentAction segmentAction = manager.acquireSegment(segmentToLoad, AcquireMode.FULL);
// now drop it before we actually load it, but dropping a weakly held reference does not remove the entry from the
@@ -1154,19 +1158,19 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
// however, we also have a hold, so it will not be evicted
final DataSegment cannotLoad = makeTestDataSegment(segmentDeepStorageDir, 1, TEST_DATA_RELATIVE_PATH_2);
- Assert.assertThrows(DruidException.class, () -> manager.acquireSegment(cannotLoad, AcquireMode.FULL));
+ Assertions.assertThrows(DruidException.class, () -> manager.acquireSegment(cannotLoad, AcquireMode.FULL));
// and we can still mount and use the segment we are holding
AcquireSegmentResult result = segmentAction.getSegmentFuture().get();
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
Optional<Segment> theSegment = result.getReferenceProvider().acquireReference();
- Assert.assertTrue(theSegment.isPresent());
- Assert.assertNotNull(manager.getSegmentFiles(segmentToLoad));
- Assert.assertEquals(segmentToLoad.getId(), theSegment.get().getId());
- Assert.assertEquals(segmentToLoad.getInterval(), theSegment.get().getDataInterval());
+ Assertions.assertTrue(theSegment.isPresent());
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertEquals(segmentToLoad.getId(), theSegment.get().getId());
+ Assertions.assertEquals(segmentToLoad.getInterval(), theSegment.get().getDataInterval());
theSegment.get().close();
segmentAction.close();
- Assert.assertNotNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToLoad));
// now that the hold has been released, we can load the other segment and evict the one that was held
createSegmentZipInLocation(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH_2);
@@ -1174,11 +1178,11 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
AcquireSegmentAction segmentActionAfterDrop = manager.acquireSegment(cannotLoad, AcquireMode.FULL);
AcquireSegmentResult resultDrop = segmentActionAfterDrop.getSegmentFuture().get();
Optional<Segment> theSegmentAfterDrop = resultDrop.getReferenceProvider().acquireReference();
- Assert.assertTrue(theSegmentAfterDrop.isPresent());
- Assert.assertNotNull(manager.getSegmentFiles(cannotLoad));
- Assert.assertEquals(cannotLoad.getId(), theSegmentAfterDrop.get().getId());
- Assert.assertEquals(cannotLoad.getInterval(), theSegmentAfterDrop.get().getDataInterval());
- Assert.assertNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertTrue(theSegmentAfterDrop.isPresent());
+ Assertions.assertNotNull(manager.getSegmentFiles(cannotLoad));
+ Assertions.assertEquals(cannotLoad.getId(), theSegmentAfterDrop.get().getId());
+ Assertions.assertEquals(cannotLoad.getInterval(), theSegmentAfterDrop.get().getDataInterval());
+ Assertions.assertNull(manager.getSegmentFiles(segmentToLoad));
theSegmentAfterDrop.get().close();
segmentActionAfterDrop.close();
@@ -1212,45 +1216,45 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
AcquireSegmentAction segmentAction = manager.acquireSegment(segmentToLoad, AcquireMode.FULL);
AcquireSegmentResult result = segmentAction.getSegmentFuture().get();
Optional<Segment> theSegment = result.getReferenceProvider().acquireReference();
- Assert.assertTrue(theSegment.isPresent());
- Assert.assertNotNull(manager.getSegmentFiles(segmentToLoad));
- Assert.assertEquals(segmentToLoad.getId(), theSegment.get().getId());
+ Assertions.assertTrue(theSegment.isPresent());
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertEquals(segmentToLoad.getId(), theSegment.get().getId());
// Info file should exist
final File infoFile = new File(infoDir, segmentToLoad.getId().toString());
- Assert.assertTrue(infoFile.exists());
+ Assertions.assertTrue(infoFile.exists());
// Drop the segment while still holding
manager.drop(segmentToLoad);
// Segment files and info file should still exist because we still have a hold
- Assert.assertNotNull(manager.getSegmentFiles(segmentToLoad));
- Assert.assertTrue(infoFile.exists());
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertTrue(infoFile.exists());
// Release the hold - with evictImmediately, the segment should be evicted immediately
theSegment.get().close();
segmentAction.close();
// Both segment files and info file should be deleted
- Assert.assertNull(manager.getSegmentFiles(segmentToLoad));
- Assert.assertFalse(infoFile.exists());
+ Assertions.assertNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertFalse(infoFile.exists());
// Verify the segment can be loaded again if needed
AcquireSegmentAction segmentActionAfterEvict = manager.acquireSegment(segmentToLoad, AcquireMode.FULL);
AcquireSegmentResult resultAfterEvict = segmentActionAfterEvict.getSegmentFuture().get();
Optional<Segment> theSegmentAfterEvict = resultAfterEvict.getReferenceProvider().acquireReference();
- Assert.assertTrue(theSegmentAfterEvict.isPresent());
- Assert.assertNotNull(manager.getSegmentFiles(segmentToLoad));
- Assert.assertEquals(segmentToLoad.getId(), theSegmentAfterEvict.get().getId());
+ Assertions.assertTrue(theSegmentAfterEvict.isPresent());
+ Assertions.assertNotNull(manager.getSegmentFiles(segmentToLoad));
+ Assertions.assertEquals(segmentToLoad.getId(), theSegmentAfterEvict.get().getId());
// Info file should exist again
- Assert.assertTrue(infoFile.exists());
+ Assertions.assertTrue(infoFile.exists());
theSegmentAfterEvict.get().close();
segmentActionAfterEvict.close();
// After final release, info file should be deleted again
- Assert.assertFalse(infoFile.exists());
+ Assertions.assertFalse(infoFile.exists());
}
@Test
@@ -1277,7 +1281,7 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
manager.load(tombstone);
manager.getSegmentFiles(tombstone);
- Assert.assertTrue("Expect cache hit after downloading segment", manager.isSegmentCached(tombstone));
+ Assertions.assertTrue(manager.isSegmentCached(tombstone), "Expect cache hit after downloading segment");
}
@Test
@@ -1296,22 +1300,22 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
manager.load(tombstone);
Segment segment = manager.acquireCachedSegment(tombstone.getId(), AcquireMode.FULL).orElse(null);
- Assert.assertEquals(tombstone.getId(), segment.getId());
- Assert.assertEquals(interval, segment.getDataInterval());
+ Assertions.assertEquals(tombstone.getId(), segment.getId());
+ Assertions.assertEquals(interval, segment.getDataInterval());
final CursorFactory cursorFactory = segment.as(CursorFactory.class);
- Assert.assertNotNull(cursorFactory);
- Assert.assertTrue(segment.isTombstone());
+ Assertions.assertNotNull(cursorFactory);
+ Assertions.assertTrue(segment.isTombstone());
final QueryableIndex queryableIndex = segment.as(QueryableIndex.class);
- Assert.assertNotNull(queryableIndex);
- Assert.assertEquals(interval, queryableIndex.getDataInterval());
- Assert.assertThrows(UnsupportedOperationException.class, queryableIndex::getMetadata);
- Assert.assertThrows(UnsupportedOperationException.class, queryableIndex::getNumRows);
- Assert.assertThrows(UnsupportedOperationException.class, queryableIndex::getAvailableDimensions);
- Assert.assertThrows(UnsupportedOperationException.class, queryableIndex::getBitmapFactoryForDimensions);
- Assert.assertThrows(UnsupportedOperationException.class, queryableIndex::getDimensionHandlers);
- Assert.assertThrows(UnsupportedOperationException.class, () -> queryableIndex.getColumnHolder("foo"));
+ Assertions.assertNotNull(queryableIndex);
+ Assertions.assertEquals(interval, queryableIndex.getDataInterval());
+ Assertions.assertThrows(UnsupportedOperationException.class, queryableIndex::getMetadata);
+ Assertions.assertThrows(UnsupportedOperationException.class, queryableIndex::getNumRows);
+ Assertions.assertThrows(UnsupportedOperationException.class, queryableIndex::getAvailableDimensions);
+ Assertions.assertThrows(UnsupportedOperationException.class, queryableIndex::getBitmapFactoryForDimensions);
+ Assertions.assertThrows(UnsupportedOperationException.class, queryableIndex::getDimensionHandlers);
+ Assertions.assertThrows(UnsupportedOperationException.class, () -> queryableIndex.getColumnHolder("foo"));
}
private SegmentLocalCacheManager makeDefaultManager(ObjectMapper jsonMapper)
diff --git a/server/src/test/java/org/apache/druid/segment/loading/StorageLocationSelectorStrategyTest.java b/server/src/test/java/org/apache/druid/segment/loading/StorageLocationSelectorStrategyTest.java
index 393c20f9d5b..86b5f54bd68 100644
--- a/server/src/test/java/org/apache/druid/segment/loading/StorageLocationSelectorStrategyTest.java
+++ b/server/src/test/java/org/apache/druid/segment/loading/StorageLocationSelectorStrategyTest.java
@@ -33,10 +33,10 @@ import org.apache.druid.guice.JsonConfigurator;
import org.apache.druid.guice.LazySingleton;
import org.apache.druid.guice.StorageNodeModule;
import org.apache.druid.jackson.DefaultObjectMapper;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.apache.druid.testing.TemporaryFolderExtension;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import java.io.File;
import java.util.ArrayList;
@@ -48,8 +48,8 @@ import java.util.Properties;
public class StorageLocationSelectorStrategyTest
{
- @Rule
- public final TemporaryFolder tmpFolder = new TemporaryFolder();
+ @RegisterExtension
+ public final TemporaryFolderExtension tmpFolder = new TemporaryFolderExtension();
@Test
public void testLeastBytesUsedLocationSelectorStrategy() throws Exception
@@ -75,16 +75,25 @@ public class StorageLocationSelectorStrategyTest
Iterator<StorageLocation> locations = leastBytesUsedStrategy.getLocations();
StorageLocation loc1 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_2",
- localStorageFolder2, loc1.getPath());
+ Assertions.assertEquals(
+ localStorageFolder2,
+ loc1.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_2"
+ );
StorageLocation loc2 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_3",
- localStorageFolder3, loc2.getPath());
+ Assertions.assertEquals(
+ localStorageFolder3,
+ loc2.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_3"
+ );
StorageLocation loc3 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_1",
- localStorageFolder1, loc3.getPath());
+ Assertions.assertEquals(
+ localStorageFolder1,
+ loc3.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_1"
+ );
}
@@ -100,14 +109,20 @@ public class StorageLocationSelectorStrategyTest
Iterator<StorageLocation> locations = roundRobinStrategy.getLocations();
StorageLocation loc1 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_1",
- localStorageFolder1, loc1.getPath());
+ Assertions.assertEquals(
+ localStorageFolder1,
+ loc1.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_1"
+ );
locations = roundRobinStrategy.getLocations();
StorageLocation loc2 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_1",
- localStorageFolder1, loc2.getPath());
+ Assertions.assertEquals(
+ localStorageFolder1,
+ loc2.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_1"
+ );
}
@@ -130,32 +145,50 @@ public class StorageLocationSelectorStrategyTest
Iterator<StorageLocation> locations = roundRobinStrategy.getLocations();
StorageLocation loc1 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_1",
- localStorageFolder1, loc1.getPath());
+ Assertions.assertEquals(
+ localStorageFolder1,
+ loc1.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_1"
+ );
StorageLocation loc2 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_2",
- localStorageFolder2, loc2.getPath());
+ Assertions.assertEquals(
+ localStorageFolder2,
+ loc2.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_2"
+ );
StorageLocation loc3 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_3",
- localStorageFolder3, loc3.getPath());
+ Assertions.assertEquals(
+ localStorageFolder3,
+ loc3.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_3"
+ );
// Second call to getLocations()
locations = roundRobinStrategy.getLocations();
loc2 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_2",
- localStorageFolder2, loc2.getPath());
+ Assertions.assertEquals(
+ localStorageFolder2,
+ loc2.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_2"
+ );
loc3 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_3",
- localStorageFolder3, loc3.getPath());
+ Assertions.assertEquals(
+ localStorageFolder3,
+ loc3.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_3"
+ );
loc1 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_1",
- localStorageFolder1, loc1.getPath());
+ Assertions.assertEquals(
+ localStorageFolder1,
+ loc1.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_1"
+ );
}
@Test
@@ -176,24 +209,36 @@ public class StorageLocationSelectorStrategyTest
Iterator<StorageLocation> locations = roundRobinStrategy.getLocations();
StorageLocation loc1 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_1",
- localStorageFolder1, loc1.getPath());
+ Assertions.assertEquals(
+ localStorageFolder1,
+ loc1.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_1"
+ );
locations = roundRobinStrategy.getLocations();
StorageLocation loc2 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_2",
- localStorageFolder2, loc2.getPath());
+ Assertions.assertEquals(
+ localStorageFolder2,
+ loc2.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_2"
+ );
locations = roundRobinStrategy.getLocations();
StorageLocation loc3 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_3",
- localStorageFolder3, loc3.getPath());
+ Assertions.assertEquals(
+ localStorageFolder3,
+ loc3.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_3"
+ );
loc1 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_1",
- localStorageFolder1, loc1.getPath());
+ Assertions.assertEquals(
+ localStorageFolder1,
+ loc1.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_1"
+ );
}
@Test
@@ -221,7 +266,7 @@ public class StorageLocationSelectorStrategyTest
File[] result = new File[]{loc1.getPath(), loc2.getPath(), loc3.getPath()};
Arrays.sort(result);
- Assert.assertArrayEquals(new File[]{localStorageFolder1, localStorageFolder2, localStorageFolder3}, result);
+ Assertions.assertArrayEquals(new File[]{localStorageFolder1, localStorageFolder2, localStorageFolder3}, result);
}
@Test
@@ -245,31 +290,49 @@ public class StorageLocationSelectorStrategyTest
Iterator<StorageLocation> locations = mostAvailableStrategy.getLocations();
StorageLocation loc1 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_2",
- localStorageFolder2, loc1.getPath());
+ Assertions.assertEquals(
+ localStorageFolder2,
+ loc1.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_2"
+ );
StorageLocation loc2 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_3",
- localStorageFolder3, loc2.getPath());
+ Assertions.assertEquals(
+ localStorageFolder3,
+ loc2.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_3"
+ );
StorageLocation loc3 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_1",
- localStorageFolder1, loc3.getPath());
+ Assertions.assertEquals(
+ localStorageFolder1,
+ loc3.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_1"
+ );
storageLocation2.reserve(makeCacheEntry("tmp_loc2", 6000000000L));
locations = mostAvailableStrategy.getLocations();
loc1 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_3",
- localStorageFolder3, loc1.getPath());
+ Assertions.assertEquals(
+ localStorageFolder3,
+ loc1.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_3"
+ );
loc2 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_2",
- localStorageFolder2, loc2.getPath());
+ Assertions.assertEquals(
+ localStorageFolder2,
+ loc2.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_2"
+ );
loc3 = locations.next();
- Assert.assertEquals("The next element of the iterator should point to path local_storage_folder_1",
- localStorageFolder1, loc3.getPath());
+ Assertions.assertEquals(
+ localStorageFolder1,
+ loc3.getPath(),
+ "The next element of the iterator should point to path local_storage_folder_1"
+ );
}
@Test
@@ -280,9 +343,9 @@ public class StorageLocationSelectorStrategyTest
props.setProperty("druid.segmentCache.locations", "[{\"path\": \"/tmp/druid/indexCache\"}]");
StorageLocationSelectorStrategy strategy = makeInjectorWithProperties(props).getInstance(StorageLocationSelectorStrategy.class);
- Assert.assertEquals(LeastBytesUsedStorageLocationSelectorStrategy.class,
+ Assertions.assertEquals(LeastBytesUsedStorageLocationSelectorStrategy.class,
strategy.getClass());
- Assert.assertEquals("/tmp/druid/indexCache", strategy.getLocations().next().getPath().getAbsolutePath());
+ Assertions.assertEquals("/tmp/druid/indexCache", strategy.getLocations().next().getPath().getAbsolutePath());
}
@Test
@@ -295,9 +358,9 @@ public class StorageLocationSelectorStrategyTest
Injector injector = makeInjectorWithProperties(props);
StorageLocationSelectorStrategy strategy = injector.getInstance(StorageLocationSelectorStrategy.class);
- Assert.assertEquals(RoundRobinStorageLocationSelectorStrategy.class,
+ Assertions.assertEquals(RoundRobinStorageLocationSelectorStrategy.class,
strategy.getClass());
- Assert.assertEquals("/tmp/druid/indexCache", strategy.getLocations().next().getPath().getAbsolutePath());
+ Assertions.assertEquals("/tmp/druid/indexCache", strategy.getLocations().next().getPath().getAbsolutePath());
}
@Test
@@ -310,9 +373,9 @@ public class StorageLocationSelectorStrategyTest
Injector injector = makeInjectorWithProperties(props);
StorageLocationSelectorStrategy strategy = injector.getInstance(StorageLocationSelectorStrategy.class);
- Assert.assertEquals(LeastBytesUsedStorageLocationSelectorStrategy.class,
+ Assertions.assertEquals(LeastBytesUsedStorageLocationSelectorStrategy.class,
strategy.getClass());
- Assert.assertEquals("/tmp/druid/indexCache", strategy.getLocations().next().getPath().getAbsolutePath());
+ Assertions.assertEquals("/tmp/druid/indexCache", strategy.getLocations().next().getPath().getAbsolutePath());
}
@Test
@@ -325,9 +388,9 @@ public class StorageLocationSelectorStrategyTest
Injector injector = makeInjectorWithProperties(props);
StorageLocationSelectorStrategy strategy = injector.getInstance(StorageLocationSelectorStrategy.class);
- Assert.assertEquals(RandomStorageLocationSelectorStrategy.class,
+ Assertions.assertEquals(RandomStorageLocationSelectorStrategy.class,
strategy.getClass());
- Assert.assertEquals("/tmp/druid/indexCache", strategy.getLocations().next().getPath().getAbsolutePath());
+ Assertions.assertEquals("/tmp/druid/indexCache", strategy.getLocations().next().getPath().getAbsolutePath());
}
@Test
@@ -340,9 +403,9 @@ public class StorageLocationSelectorStrategyTest
Injector injector = makeInjectorWithProperties(props);
StorageLocationSelectorStrategy strategy = injector.getInstance(StorageLocationSelectorStrategy.class);
- Assert.assertEquals(MostAvailableSizeStorageLocationSelectorStrategy.class,
+ Assertions.assertEquals(MostAvailableSizeStorageLocationSelectorStrategy.class,
strategy.getClass());
- Assert.assertEquals("/tmp/druid/indexCache", strategy.getLocations().next().getPath().getAbsolutePath());
+ Assertions.assertEquals("/tmp/druid/indexCache", strategy.getLocations().next().getPath().getAbsolutePath());
}
private Injector makeInjectorWithProperties(final Properties props)
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/ChatHandlerProviderTest.java b/server/src/test/java/org/apache/druid/segment/realtime/ChatHandlerProviderTest.java
index 2163a5c1948..0055fc79d3f 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/ChatHandlerProviderTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/ChatHandlerProviderTest.java
@@ -20,9 +20,9 @@
package org.apache.druid.segment.realtime;
import org.apache.druid.java.util.common.ISE;
-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;
public class ChatHandlerProviderTest
{
@@ -34,7 +34,7 @@ public class ChatHandlerProviderTest
private ChatHandlerProvider chatHandlerProvider;
- @Before
+ @BeforeEach
public void setUp()
{
chatHandlerProvider = new ChatHandlerProvider();
@@ -45,20 +45,20 @@ public class ChatHandlerProviderTest
{
ChatHandler testChatHandler = new TestChatHandler();
- Assert.assertFalse("bad initial state", chatHandlerProvider.get(TEST_SERVICE_NAME).isPresent());
+ Assertions.assertFalse(chatHandlerProvider.get(TEST_SERVICE_NAME).isPresent(), "bad initial state");
chatHandlerProvider.register(TEST_SERVICE_NAME, testChatHandler);
- Assert.assertTrue("chatHandler did not register", chatHandlerProvider.get(TEST_SERVICE_NAME).isPresent());
- Assert.assertEquals(testChatHandler, chatHandlerProvider.get(TEST_SERVICE_NAME).get());
+ Assertions.assertTrue(chatHandlerProvider.get(TEST_SERVICE_NAME).isPresent(), "chatHandler did not register");
+ Assertions.assertEquals(testChatHandler, chatHandlerProvider.get(TEST_SERVICE_NAME).get());
chatHandlerProvider.unregister(TEST_SERVICE_NAME);
- Assert.assertFalse("chatHandler did not deregister", chatHandlerProvider.get(TEST_SERVICE_NAME).isPresent());
+ Assertions.assertFalse(chatHandlerProvider.get(TEST_SERVICE_NAME).isPresent(), "chatHandler did not deregister");
}
@Test
public void testDuplicateRegistrationThrows()
{
chatHandlerProvider.register(TEST_SERVICE_NAME, new TestChatHandler());
- Assert.assertThrows(ISE.class, () -> chatHandlerProvider.register(TEST_SERVICE_NAME, new TestChatHandler()));
+ Assertions.assertThrows(ISE.class, () -> chatHandlerProvider.register(TEST_SERVICE_NAME, new TestChatHandler()));
}
}
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/ChatHandlerResourceTest.java b/server/src/test/java/org/apache/druid/segment/realtime/ChatHandlerResourceTest.java
index 4636e6523d8..3ff58eefe04 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/ChatHandlerResourceTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/ChatHandlerResourceTest.java
@@ -24,14 +24,14 @@ import com.google.common.base.Optional;
import org.apache.druid.java.util.metrics.TaskHolder;
import org.apache.druid.server.initialization.jetty.ServiceUnavailableException;
import org.easymock.EasyMock;
-import org.easymock.EasyMockRunner;
+import org.easymock.EasyMockExtension;
import org.easymock.EasyMockSupport;
import org.easymock.Mock;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
-@RunWith(EasyMockRunner.class)
+@ExtendWith(EasyMockExtension.class)
public class ChatHandlerResourceTest extends EasyMockSupport
{
@@ -50,7 +50,7 @@ public class ChatHandlerResourceTest extends EasyMockSupport
replayAll();
chatHandlerResource = new ChatHandlerResource(handlers, taskHolder);
- Assert.assertThrows(ServiceUnavailableException.class, () -> chatHandlerResource.doTaskChat(handlerId, null));
+ Assertions.assertThrows(ServiceUnavailableException.class, () -> chatHandlerResource.doTaskChat(handlerId, null));
verifyAll();
}
}
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/FireHydrantTest.java b/server/src/test/java/org/apache/druid/segment/realtime/FireHydrantTest.java
index a226934a4c4..c168753f531 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/FireHydrantTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/FireHydrantTest.java
@@ -28,9 +28,9 @@ import org.apache.druid.segment.SegmentMapFunction;
import org.apache.druid.segment.TestIndex;
import org.apache.druid.testing.InitializedNullHandlingTest;
import org.apache.druid.timeline.SegmentId;
-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.io.IOException;
import java.util.Optional;
@@ -41,7 +41,7 @@ public class FireHydrantTest extends InitializedNullHandlingTest
private QueryableIndexSegment queryableIndexSegment;
private FireHydrant hydrant;
- @Before
+ @BeforeEach
public void setup()
{
incrementalIndexSegment = new IncrementalIndexSegment(TestIndex.getIncrementalTestIndex(), SegmentId.dummy("test"));
@@ -54,50 +54,50 @@ public class FireHydrantTest extends InitializedNullHandlingTest
@Test
public void testAcquireSegmentNotSwapped()
{
- Assert.assertEquals(0, hydrant.getHydrantSegment().getNumReferences());
+ Assertions.assertEquals(0, hydrant.getHydrantSegment().getNumReferences());
Segment segment = hydrant.acquireSegment();
- Assert.assertNotNull(segment);
- Assert.assertSame(incrementalIndexSegment, ((ReferenceCountedSegmentProvider.ReferenceClosingSegment) segment).getProvider().getBaseSegment());
- Assert.assertEquals(1, hydrant.getHydrantSegment().getNumReferences());
+ Assertions.assertNotNull(segment);
+ Assertions.assertSame(incrementalIndexSegment, ((ReferenceCountedSegmentProvider.ReferenceClosingSegment) segment).getProvider().getBaseSegment());
+ Assertions.assertEquals(1, hydrant.getHydrantSegment().getNumReferences());
}
@Test
public void testAcquireSegmentSwapped()
{
ReferenceCountedSegmentProvider incrementalSegmentReference = hydrant.getHydrantSegment();
- Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
+ Assertions.assertEquals(0, incrementalSegmentReference.getNumReferences());
hydrant.swapSegment(queryableIndexSegment);
Segment segment = hydrant.acquireSegment();
- Assert.assertNotNull(segment);
- Assert.assertSame(queryableIndexSegment, ((ReferenceCountedSegmentProvider.ReferenceClosingSegment) segment).getProvider().getBaseSegment());
- Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
- Assert.assertEquals(1, hydrant.getHydrantSegment().getNumReferences());
+ Assertions.assertNotNull(segment);
+ Assertions.assertSame(queryableIndexSegment, ((ReferenceCountedSegmentProvider.ReferenceClosingSegment) segment).getProvider().getBaseSegment());
+ Assertions.assertEquals(0, incrementalSegmentReference.getNumReferences());
+ Assertions.assertEquals(1, hydrant.getHydrantSegment().getNumReferences());
}
@Test
public void testAcquireSegmentClosed()
{
hydrant.getHydrantSegment().close();
- Assert.assertEquals(0, hydrant.getHydrantSegment().getNumReferences());
- Throwable t = Assert.assertThrows(ISE.class, hydrant::acquireSegment);
- Assert.assertEquals("segment.close() is called somewhere outside FireHydrant.swapSegment()", t.getMessage());
+ Assertions.assertEquals(0, hydrant.getHydrantSegment().getNumReferences());
+ Throwable t = Assertions.assertThrows(ISE.class, hydrant::acquireSegment);
+ Assertions.assertEquals("segment.close() is called somewhere outside FireHydrant.swapSegment()", t.getMessage());
}
@Test
public void testGetSegmentForQuery() throws IOException
{
ReferenceCountedSegmentProvider incrementalSegmentReference = hydrant.getHydrantSegment();
- Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
+ Assertions.assertEquals(0, incrementalSegmentReference.getNumReferences());
Optional<Segment> maybeSegmentAndCloseable = hydrant.getSegmentForQuery(
SegmentMapFunction.IDENTITY
);
- Assert.assertTrue(maybeSegmentAndCloseable.isPresent());
- Assert.assertEquals(1, incrementalSegmentReference.getNumReferences());
+ Assertions.assertTrue(maybeSegmentAndCloseable.isPresent());
+ Assertions.assertEquals(1, incrementalSegmentReference.getNumReferences());
Segment segmentAndCloseable = maybeSegmentAndCloseable.get();
segmentAndCloseable.close();
- Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
+ Assertions.assertEquals(0, incrementalSegmentReference.getNumReferences());
}
@Test
@@ -106,20 +106,20 @@ public class FireHydrantTest extends InitializedNullHandlingTest
ReferenceCountedSegmentProvider incrementalSegmentReference = hydrant.getHydrantSegment();
hydrant.swapSegment(queryableIndexSegment);
ReferenceCountedSegmentProvider queryableSegmentReference = hydrant.getHydrantSegment();
- Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
- Assert.assertEquals(0, queryableSegmentReference.getNumReferences());
+ Assertions.assertEquals(0, incrementalSegmentReference.getNumReferences());
+ Assertions.assertEquals(0, queryableSegmentReference.getNumReferences());
Optional<Segment> maybeSegmentAndCloseable = hydrant.getSegmentForQuery(
SegmentMapFunction.IDENTITY
);
- Assert.assertTrue(maybeSegmentAndCloseable.isPresent());
- Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
- Assert.assertEquals(1, queryableSegmentReference.getNumReferences());
+ Assertions.assertTrue(maybeSegmentAndCloseable.isPresent());
+ Assertions.assertEquals(0, incrementalSegmentReference.getNumReferences());
+ Assertions.assertEquals(1, queryableSegmentReference.getNumReferences());
Segment segmentAndCloseable = maybeSegmentAndCloseable.get();
segmentAndCloseable.close();
- Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
- Assert.assertEquals(0, queryableSegmentReference.getNumReferences());
+ Assertions.assertEquals(0, incrementalSegmentReference.getNumReferences());
+ Assertions.assertEquals(0, queryableSegmentReference.getNumReferences());
}
@Test
@@ -128,28 +128,28 @@ public class FireHydrantTest extends InitializedNullHandlingTest
ReferenceCountedSegmentProvider incrementalSegmentReference = hydrant.getHydrantSegment();
hydrant.swapSegment(null);
ReferenceCountedSegmentProvider queryableSegmentReference = hydrant.getHydrantSegment();
- Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
- Assert.assertNull(queryableSegmentReference);
+ Assertions.assertEquals(0, incrementalSegmentReference.getNumReferences());
+ Assertions.assertNull(queryableSegmentReference);
Optional<Segment> maybeSegmentAndCloseable = hydrant.getSegmentForQuery(
SegmentMapFunction.IDENTITY
);
- Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
- Assert.assertFalse(maybeSegmentAndCloseable.isPresent());
+ Assertions.assertEquals(0, incrementalSegmentReference.getNumReferences());
+ Assertions.assertFalse(maybeSegmentAndCloseable.isPresent());
}
@Test
public void testGetSegmentForQueryButNotAbleToAcquireReferencesSegmentClosed()
{
ReferenceCountedSegmentProvider incrementalSegmentReference = hydrant.getHydrantSegment();
- Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
+ Assertions.assertEquals(0, incrementalSegmentReference.getNumReferences());
incrementalSegmentReference.close();
- Throwable t = Assert.assertThrows(
+ Throwable t = Assertions.assertThrows(
ISE.class,
() -> hydrant.getSegmentForQuery(SegmentMapFunction.IDENTITY)
);
- Assert.assertEquals("segment.close() is called somewhere outside FireHydrant.swapSegment()", t.getMessage());
+ Assertions.assertEquals("segment.close() is called somewhere outside FireHydrant.swapSegment()", t.getMessage());
}
@Test
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/SegmentGenerationMetricsTest.java b/server/src/test/java/org/apache/druid/segment/realtime/SegmentGenerationMetricsTest.java
index 16dacf32110..98e4b330eca 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/SegmentGenerationMetricsTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/SegmentGenerationMetricsTest.java
@@ -19,8 +19,8 @@
package org.apache.druid.segment.realtime;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class SegmentGenerationMetricsTest
{
@@ -32,7 +32,7 @@ public class SegmentGenerationMetricsTest
SegmentGenerationMetrics snapshot = metrics.snapshot();
assertMessageGapAggregateMetricsReset(metrics);
// invalid value
- Assert.assertTrue(0 > snapshot.maxSegmentHandoffTime());
+ Assertions.assertTrue(0 > snapshot.maxSegmentHandoffTime());
}
@Test
@@ -46,13 +46,13 @@ public class SegmentGenerationMetricsTest
SegmentGenerationMetrics snapshot = metrics.snapshot();
- Assert.assertTrue(snapshot.messageGap() >= 20L);
+ Assertions.assertTrue(snapshot.messageGap() >= 20L);
final SegmentGenerationMetrics.MessageGapStats messageGapStats = snapshot.getMessageGapStats();
- Assert.assertEquals(20L, messageGapStats.min());
- Assert.assertEquals(20L, messageGapStats.max());
- Assert.assertEquals(messageGapStats.min(), messageGapStats.max());
- Assert.assertEquals(20L, messageGapStats.avg(), 0);
- Assert.assertEquals(7, snapshot.maxSegmentHandoffTime());
+ Assertions.assertEquals(20L, messageGapStats.min());
+ Assertions.assertEquals(20L, messageGapStats.max());
+ Assertions.assertEquals(messageGapStats.min(), messageGapStats.max());
+ Assertions.assertEquals(20L, messageGapStats.avg(), 0);
+ Assertions.assertEquals(7, snapshot.maxSegmentHandoffTime());
}
@Test
@@ -69,15 +69,15 @@ public class SegmentGenerationMetricsTest
SegmentGenerationMetrics snapshot = metrics.snapshot();
// Latest message gap must be invalid after processing is done
- Assert.assertEquals(-1, snapshot.messageGap());
+ Assertions.assertEquals(-1, snapshot.messageGap());
final SegmentGenerationMetrics.MessageGapStats messageGapStats = snapshot.getMessageGapStats();
- Assert.assertEquals(0, messageGapStats.count());
- Assert.assertEquals(Long.MIN_VALUE, messageGapStats.max());
- Assert.assertEquals(Long.MAX_VALUE, messageGapStats.min());
- Assert.assertEquals(Double.NaN, messageGapStats.avg(), 0);
+ Assertions.assertEquals(0, messageGapStats.count());
+ Assertions.assertEquals(Long.MIN_VALUE, messageGapStats.max());
+ Assertions.assertEquals(Long.MAX_VALUE, messageGapStats.min());
+ Assertions.assertEquals(Double.NaN, messageGapStats.avg(), 0);
// value must be invalid
- Assert.assertTrue(0 > snapshot.maxSegmentHandoffTime());
+ Assertions.assertTrue(0 > snapshot.maxSegmentHandoffTime());
}
@Test
@@ -93,23 +93,23 @@ public class SegmentGenerationMetricsTest
metrics.markProcessingDone();
SegmentGenerationMetrics snapshot = metrics.snapshot();
// Latest message gap must be invalid after processing is done
- Assert.assertEquals(-1, snapshot.messageGap());
+ Assertions.assertEquals(-1, snapshot.messageGap());
final SegmentGenerationMetrics.MessageGapStats messageGapStats = snapshot.getMessageGapStats();
- Assert.assertEquals(5, messageGapStats.count());
- Assert.assertEquals(0, messageGapStats.min());
- Assert.assertEquals(120, messageGapStats.max());
- Assert.assertEquals(60.0, messageGapStats.avg(), 0);
+ Assertions.assertEquals(5, messageGapStats.count());
+ Assertions.assertEquals(0, messageGapStats.min());
+ Assertions.assertEquals(120, messageGapStats.max());
+ Assertions.assertEquals(60.0, messageGapStats.avg(), 0);
- Assert.assertEquals(7L, snapshot.maxSegmentHandoffTime());
+ Assertions.assertEquals(7L, snapshot.maxSegmentHandoffTime());
}
private static void assertMessageGapAggregateMetricsReset(final SegmentGenerationMetrics metrics)
{
final SegmentGenerationMetrics.MessageGapStats messageGapStats = metrics.getMessageGapStats();
- Assert.assertEquals(0, messageGapStats.count());
- Assert.assertEquals(Long.MIN_VALUE, messageGapStats.max());
- Assert.assertEquals(Long.MAX_VALUE, messageGapStats.min());
- Assert.assertEquals(Double.NaN, messageGapStats.avg(), 0);
+ Assertions.assertEquals(0, messageGapStats.count());
+ Assertions.assertEquals(Long.MIN_VALUE, messageGapStats.max());
+ Assertions.assertEquals(Long.MAX_VALUE, messageGapStats.min());
+ Assertions.assertEquals(Double.NaN, messageGapStats.avg(), 0);
}
}
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/BatchAppenderatorDriverTest.java b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/BatchAppenderatorDriverTest.java
index a071ff7af7d..5504f0b842a 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/BatchAppenderatorDriverTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/BatchAppenderatorDriverTest.java
@@ -38,10 +38,11 @@ import org.apache.druid.timeline.partition.NumberedShardSpec;
import org.easymock.EasyMock;
import org.easymock.EasyMockSupport;
import org.joda.time.DateTime;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import javax.annotation.Nullable;
import java.util.Arrays;
@@ -85,7 +86,7 @@ public class BatchAppenderatorDriverTest extends EasyMockSupport
private BatchAppenderatorDriver driver;
private DataSegmentKiller dataSegmentKiller;
- @Before
+ @BeforeEach
public void setup()
{
appenderatorTester = new BatchAppenderatorTester(MAX_ROWS_IN_MEMORY);
@@ -101,7 +102,7 @@ public class BatchAppenderatorDriverTest extends EasyMockSupport
EasyMock.replay(dataSegmentKiller);
}
- @After
+ @AfterEach
public void tearDown() throws Exception
{
EasyMock.verify(dataSegmentKiller);
@@ -113,10 +114,10 @@ public class BatchAppenderatorDriverTest extends EasyMockSupport
@Test
public void testSimple() throws Exception
{
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
for (InputRow row : ROWS) {
- Assert.assertTrue(driver.add(row, "dummy").isOk());
+ Assertions.assertTrue(driver.add(row, "dummy").isOk());
}
checkSegmentStates(2, SegmentState.APPENDING);
@@ -129,7 +130,7 @@ public class BatchAppenderatorDriverTest extends EasyMockSupport
driver.publishAll(null, Collections.emptySet(), makeOkPublisher(), Function.identity(), null)
.get(TIMEOUT, TimeUnit.MILLISECONDS);
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableSet.of(
new SegmentIdWithShardSpec(DATA_SOURCE, Intervals.of("2000/PT1H"), VERSION, new NumberedShardSpec(0, 0)),
new SegmentIdWithShardSpec(DATA_SOURCE, Intervals.of("2000T01/PT1H"), VERSION, new NumberedShardSpec(0, 0))
@@ -140,17 +141,18 @@ public class BatchAppenderatorDriverTest extends EasyMockSupport
.collect(Collectors.toSet())
);
- Assert.assertNull(published.getCommitMetadata());
+ Assertions.assertNull(published.getCommitMetadata());
}
- @Test(timeout = 5000L)
+ @Test
+ @Timeout(value = 5000L, unit = TimeUnit.MILLISECONDS)
public void testIncrementalPush() throws Exception
{
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
int i = 0;
for (InputRow row : ROWS) {
- Assert.assertTrue(driver.add(row, "dummy").isOk());
+ Assertions.assertTrue(driver.add(row, "dummy").isOk());
checkSegmentStates(1, SegmentState.APPENDING);
checkSegmentStates(i, SegmentState.PUSHED_AND_DROPPED);
@@ -164,7 +166,7 @@ public class BatchAppenderatorDriverTest extends EasyMockSupport
driver.publishAll(null, Collections.emptySet(), makeOkPublisher(), Function.identity(), null)
.get(TIMEOUT, TimeUnit.MILLISECONDS);
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableSet.of(
new SegmentIdWithShardSpec(DATA_SOURCE, Intervals.of("2000/PT1H"), VERSION, new NumberedShardSpec(0, 0)),
new SegmentIdWithShardSpec(DATA_SOURCE, Intervals.of("2000T01/PT1H"), VERSION, new NumberedShardSpec(0, 0)),
@@ -176,29 +178,29 @@ public class BatchAppenderatorDriverTest extends EasyMockSupport
.collect(Collectors.toSet())
);
- Assert.assertNull(published.getCommitMetadata());
+ Assertions.assertNull(published.getCommitMetadata());
}
@Test
public void testRestart()
{
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
driver.close();
appenderatorTester.getAppenderator().close();
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
}
private void checkSegmentStates(int expectedNumSegmentsInState, SegmentState expectedState)
{
final SegmentsForSequence segmentsForSequence = driver.getSegments().get("dummy");
- Assert.assertNotNull(segmentsForSequence);
+ Assertions.assertNotNull(segmentsForSequence);
final List<SegmentWithState> segmentWithStates = segmentsForSequence
.allSegmentStateStream()
.filter(segmentWithState -> segmentWithState.getState() == expectedState)
.collect(Collectors.toList());
- Assert.assertEquals(expectedNumSegmentsInState, segmentWithStates.size());
+ Assertions.assertEquals(expectedNumSegmentsInState, segmentWithStates.size());
}
static TransactionalSegmentPublisher makeOkPublisher()
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/BatchAppenderatorTest.java b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/BatchAppenderatorTest.java
index bcf722c3cf5..d66a5dfc18c 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/BatchAppenderatorTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/BatchAppenderatorTest.java
@@ -40,21 +40,19 @@ import org.apache.druid.testing.InitializedNullHandlingTest;
import org.apache.druid.timeline.ClusterGroupTuples;
import org.apache.druid.timeline.DataSegment;
import org.apache.druid.timeline.partition.LinearShardSpec;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.MatcherAssert;
import org.joda.time.DateTime;
import org.joda.time.Interval;
import org.joda.time.chrono.ISOChronology;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.internal.matchers.ThrowableCauseMatcher;
-import org.junit.internal.matchers.ThrowableMessageMatcher;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
public class BatchAppenderatorTest extends InitializedNullHandlingTest
@@ -72,33 +70,33 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
final Appenderator appenderator = tester.getAppenderator();
// startJob
- Assert.assertNull(appenderator.startJob());
+ Assertions.assertNull(appenderator.startJob());
// getDataSource
- Assert.assertEquals(BatchAppenderatorTester.DATASOURCE, appenderator.getDataSource());
+ Assertions.assertEquals(BatchAppenderatorTester.DATASOURCE, appenderator.getDataSource());
// add #1
- Assert.assertEquals(
+ Assertions.assertEquals(
1,
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null)
.getNumRowsInSegment()
);
// add #2
- Assert.assertEquals(
+ Assertions.assertEquals(
1,
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bar", 2), null)
.getNumRowsInSegment()
);
// getSegments
- Assert.assertEquals(
+ Assertions.assertEquals(
IDENTIFIERS.subList(0, 2),
appenderator.getSegments().stream().sorted().collect(Collectors.toList())
);
// add #3, this hits max rows in memory:
- Assert.assertEquals(
+ Assertions.assertEquals(
2,
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "sux", 1), null)
.getNumRowsInSegment()
@@ -106,13 +104,13 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
// since we just added three rows and the max rows in memory is three, all the segments (sinks etc.)
// above should be cleared now
- Assert.assertEquals(
+ Assertions.assertEquals(
Collections.emptyList(),
((BatchAppenderator) appenderator).getInMemorySegments().stream().sorted().collect(Collectors.toList())
);
// add #4, this will add one more temporary segment:
- Assert.assertEquals(
+ Assertions.assertEquals(
1,
appenderator.add(IDENTIFIERS.get(2), createInputRow("2001", "qux", 4), null)
.getNumRowsInSegment()
@@ -124,7 +122,7 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
null,
false
).get().getSegments().stream().sorted().map(DataSegment::toString).collect(Collectors.toList());
- Assert.assertEquals(
+ Assertions.assertEquals(
List.of(
DataSegment.builder(IDENTIFIERS.get(0).asSegmentId())
.shardSpec(IDENTIFIERS.get(0).getShardSpec())
@@ -149,7 +147,7 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
.toString()
), segments
);
- Assert.assertEquals(
+ Assertions.assertEquals(
tester.getPushedSegments()
.stream()
.sorted()
@@ -159,16 +157,16 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
);
SegmentGenerationMetrics segmentGenerationMetrics = tester.getMetrics();
- Assert.assertEquals(2, segmentGenerationMetrics.numPersists());
- Assert.assertEquals(4, segmentGenerationMetrics.rowOutput());
- Assert.assertTrue(segmentGenerationMetrics.persistTimeMillis() > 0);
- Assert.assertTrue(segmentGenerationMetrics.persistCpuTime() > 0);
+ Assertions.assertEquals(2, segmentGenerationMetrics.numPersists());
+ Assertions.assertEquals(4, segmentGenerationMetrics.rowOutput());
+ Assertions.assertTrue(segmentGenerationMetrics.persistTimeMillis() > 0);
+ Assertions.assertTrue(segmentGenerationMetrics.persistCpuTime() > 0);
- Assert.assertTrue(segmentGenerationMetrics.mergeTimeMillis() > 0);
- Assert.assertTrue(segmentGenerationMetrics.mergeCpuTime() > 0);
+ Assertions.assertTrue(segmentGenerationMetrics.mergeTimeMillis() > 0);
+ Assertions.assertTrue(segmentGenerationMetrics.mergeCpuTime() > 0);
appenderator.close();
- Assert.assertTrue(appenderator.getSegments().isEmpty());
+ Assertions.assertTrue(appenderator.getSegments().isEmpty());
}
}
@@ -201,18 +199,18 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
appenderator.push(appenderator.getSegments(), null, false).get();
final List<DataSegment> pushed = tester.getPushedSegments();
- Assert.assertEquals(1, pushed.size());
+ Assertions.assertEquals(1, pushed.size());
final DataSegment segment = pushed.get(0);
// Empty-dimensions follow-up: clustered segments source their published dimensions from the cluster summary
// (clustering + non-clustering, in summary column order), not the empty top-level columns.
- Assert.assertEquals(List.of("tenant", "region"), segment.getDimensions());
+ Assertions.assertEquals(List.of("tenant", "region"), segment.getDimensions());
// clusterGroups is populated at publish time from the merged segment's cluster summary.
final ClusterGroupTuples groups = segment.getClusterGroups();
- Assert.assertNotNull(groups);
- Assert.assertEquals(List.of("tenant"), groups.clusteringColumns().getColumnNames());
- Assert.assertEquals(
+ Assertions.assertNotNull(groups);
+ Assertions.assertEquals(List.of("tenant"), groups.clusteringColumns().getColumnNames());
+ Assertions.assertEquals(
List.of(
Collections.singletonList("acme"),
Collections.singletonList("globex")
@@ -230,33 +228,33 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
final Appenderator appenderator = tester.getAppenderator();
// startJob
- Assert.assertNull(appenderator.startJob());
+ Assertions.assertNull(appenderator.startJob());
// getDataSource
- Assert.assertEquals(BatchAppenderatorTester.DATASOURCE, appenderator.getDataSource());
+ Assertions.assertEquals(BatchAppenderatorTester.DATASOURCE, appenderator.getDataSource());
// add #1
- Assert.assertEquals(
+ Assertions.assertEquals(
1,
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null)
.getNumRowsInSegment()
);
// add #2
- Assert.assertEquals(
+ Assertions.assertEquals(
1,
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bar", 2), null)
.getNumRowsInSegment()
);
// getSegments
- Assert.assertEquals(
+ Assertions.assertEquals(
IDENTIFIERS.subList(0, 2),
appenderator.getSegments().stream().sorted().collect(Collectors.toList())
);
// add #3, this hits max rows in memory:
- Assert.assertEquals(
+ Assertions.assertEquals(
2,
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "sux", 1), null)
.getNumRowsInSegment()
@@ -264,13 +262,13 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
// since we just added three rows and the max rows in memory is three, all the segments (sinks etc.)
// above should be cleared now
- Assert.assertEquals(
+ Assertions.assertEquals(
Collections.emptyList(),
((BatchAppenderator) appenderator).getInMemorySegments().stream().sorted().collect(Collectors.toList())
);
// add #4, this will add one more temporary segment:
- Assert.assertEquals(
+ Assertions.assertEquals(
1,
appenderator.add(IDENTIFIERS.get(2), createInputRow("2001", "qux", 4), null)
.getNumRowsInSegment()
@@ -283,24 +281,17 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
false
);
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
segmentsAndCommitMetadata::get
);
- MatcherAssert.assertThat(
- e,
- ThrowableCauseMatcher.hasCause(ThrowableCauseMatcher.hasCause(CoreMatchers.instanceOf(IOException.class)))
- );
-
- MatcherAssert.assertThat(
- e,
- ThrowableCauseMatcher.hasCause(ThrowableCauseMatcher.hasCause(ThrowableMessageMatcher.hasMessage(
- CoreMatchers.startsWith("Push failure test"))))
- );
+ final Throwable nestedCause = e.getCause().getCause();
+ Assertions.assertTrue(nestedCause instanceof IOException);
+ Assertions.assertTrue(nestedCause.getMessage().startsWith("Push failure test"));
SegmentGenerationMetrics segmentGenerationMetrics = tester.getMetrics();
- Assert.assertEquals(1, segmentGenerationMetrics.failedHandoffs());
+ Assertions.assertEquals(1, segmentGenerationMetrics.failedHandoffs());
}
}
@@ -316,24 +307,24 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
final Appenderator appenderator = tester.getAppenderator();
// startJob
- Assert.assertNull(appenderator.startJob());
+ Assertions.assertNull(appenderator.startJob());
// getDataSource
- Assert.assertEquals(BatchAppenderatorTester.DATASOURCE, appenderator.getDataSource());
+ Assertions.assertEquals(BatchAppenderatorTester.DATASOURCE, appenderator.getDataSource());
// Create a segment identifier with a non-utc interval
SegmentIdWithShardSpec segmentIdWithNonUTCTime =
createNonUTCSegmentId("2021-06-27T00:00:00.000+09:00/2021-06-28T00:00:00.000+09:00",
"A", 0); // should be in seg_0
- Assert.assertEquals(
+ Assertions.assertEquals(
1,
appenderator.add(segmentIdWithNonUTCTime, createInputRow("2021-06-27T00:01:11.080Z", "foo", 1), null)
.getNumRowsInSegment()
);
// getSegments
- Assert.assertEquals(
+ Assertions.assertEquals(
Collections.singletonList(segmentIdWithNonUTCTime),
appenderator.getSegments().stream().sorted().collect(Collectors.toList())
);
@@ -341,7 +332,7 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
// since we just added one row and the max rows in memory is one, all the segments (sinks etc)
// above should be cleared now
- Assert.assertEquals(
+ Assertions.assertEquals(
Collections.emptyList(),
((BatchAppenderator) appenderator).getInMemorySegments().stream().sorted().collect(Collectors.toList())
);
@@ -353,7 +344,7 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
null,
false
).get().getSegments().stream().sorted().map(DataSegment::toString).collect(Collectors.toList());
- Assert.assertEquals(
+ Assertions.assertEquals(
List.of(DataSegment.builder(segmentIdWithNonUTCTime.asSegmentId())
.shardSpec(segmentIdWithNonUTCTime.getShardSpec())
.dimensions(List.of("dim"))
@@ -363,13 +354,13 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
.toString()),
segments
);
- Assert.assertEquals(
+ Assertions.assertEquals(
tester.getPushedSegments().stream().sorted().map(DataSegment::toString).collect(Collectors.toList()),
segments
);
appenderator.close();
- Assert.assertTrue(appenderator.getSegments().isEmpty());
+ Assertions.assertTrue(appenderator.getSegments().isEmpty());
}
}
@@ -394,17 +385,17 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
// 44(map overhead) + 28 (TimeAndDims overhead) + 56 (aggregator metrics) + 54 (dimsKeySize) =
// 182 + 1 byte when null handling is enabled
int nullHandlingOverhead = 1;
- Assert.assertEquals(
+ Assertions.assertEquals(
190 + nullHandlingOverhead,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bar", 1), null);
- Assert.assertEquals(
+ Assertions.assertEquals(
190 + nullHandlingOverhead,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(1))
);
appenderator.close();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
}
}
@@ -427,15 +418,15 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null);
//expectedSizeInBytes = 44(map overhead) + 28 (TimeAndDims overhead) + 56 (aggregator metrics) + 54 (dimsKeySize) = 182
int nullHandlingOverhead = 1;
- Assert.assertEquals(190 + nullHandlingOverhead, ((BatchAppenderator) appenderator).getBytesCurrentlyInMemory());
+ Assertions.assertEquals(190 + nullHandlingOverhead, ((BatchAppenderator) appenderator).getBytesCurrentlyInMemory());
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bar", 1), null);
- Assert.assertEquals(
+ Assertions.assertEquals(
380 + 2 * nullHandlingOverhead,
((BatchAppenderator) appenderator).getBytesCurrentlyInMemory()
);
- Assert.assertEquals(2, appenderator.getSegments().size());
+ Assertions.assertEquals(2, appenderator.getSegments().size());
appenderator.close();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
}
}
@@ -453,11 +444,11 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
int currentInMemoryIndexSize = 190 + nullHandlingOverhead;
int sinkSizeOverhead = BatchAppenderator.ROUGH_OVERHEAD_PER_SINK;
// currHydrant in the sink still has > 0 bytesInMemory since we do not persist yet
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize + sinkSizeOverhead,
((BatchAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -471,12 +462,12 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
currentInMemoryIndexSize = 0;
// We are now over maxSizeInBytes after the add. Hence, we do a persist.
// currHydrant in the sink has 0 bytesInMemory since we just did a persist
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
// no sinks no hydrants after a persist, so we should have zero bytes currently in memory
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -485,11 +476,11 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "bob", 1), null);
// currHydrant in the sink still has > 0 bytesInMemory since we do not persist yet
currentInMemoryIndexSize = 190 + nullHandlingOverhead;
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize + sinkSizeOverhead,
((BatchAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -503,29 +494,33 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
currentInMemoryIndexSize = 0;
// We are now over maxSizeInBytes after the add. Hence, we do a persist.
// so no sinks & hydrants should be in memory...
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesCurrentlyInMemory()
);
appenderator.persistAll(null).get();
appenderator.close();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getBytesCurrentlyInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getBytesCurrentlyInMemory());
}
}
- @Test(expected = RuntimeException.class, timeout = 5000L)
+ @Test
+ @Timeout(value = 5000L, unit = TimeUnit.MILLISECONDS)
public void testTaskFailAsPersistCannotFreeAnyMoreMemory() throws Exception
{
try (final BatchAppenderatorTester tester =
new BatchAppenderatorTester(100, 5180, true)) {
final Appenderator appenderator = tester.getAppenderator();
appenderator.startJob();
- appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null);
+ Assertions.assertThrows(
+ RuntimeException.class,
+ () -> appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null)
+ );
}
}
@@ -548,13 +543,13 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null);
// Expected 0 since we persisted after the add
- Assert.assertEquals(
+ Assertions.assertEquals(
0,
((BatchAppenderator) appenderator).getBytesCurrentlyInMemory()
);
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null);
- Assert.assertEquals(
+ Assertions.assertEquals(
0,
((BatchAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -575,7 +570,7 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
int nullHandlingOverhead = 1;
int currentInMemoryIndexSize = 190 + nullHandlingOverhead;
int sinkSizeOverhead = BatchAppenderator.ROUGH_OVERHEAD_PER_SINK;
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize + sinkSizeOverhead,
((BatchAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -583,8 +578,8 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
// Close with row still in memory (no persist)
appenderator.close();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getBytesCurrentlyInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getBytesCurrentlyInMemory());
}
}
@@ -606,15 +601,15 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
int currentInMemoryIndexSize = 190 + nullHandlingOverhead;
int sinkSizeOverhead = 2 * BatchAppenderator.ROUGH_OVERHEAD_PER_SINK;
// currHydrant in the sink still has > 0 bytesInMemory since we do not persist yet
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(1))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
(2 * currentInMemoryIndexSize) + sinkSizeOverhead,
((BatchAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -630,15 +625,15 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
currentInMemoryIndexSize = 0;
// We are now over maxSizeInBytes after the add. Hence, we do a persist.
// currHydrant and the sink has 0 bytesInMemory since we just did a persist
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(1))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -647,32 +642,32 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "bob", 1), null);
// currHydrant in the sink still has > 0 bytesInMemory since we do not persist yet
currentInMemoryIndexSize = 190 + nullHandlingOverhead;
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
0,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(1))
);
// only one sink so far:
sinkSizeOverhead = BatchAppenderator.ROUGH_OVERHEAD_PER_SINK;
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize + sinkSizeOverhead,
((BatchAppenderator) appenderator).getBytesCurrentlyInMemory()
);
// Now add a single row to sink 1
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bob", 1), null);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(1))
);
sinkSizeOverhead += BatchAppenderator.ROUGH_OVERHEAD_PER_SINK;
- Assert.assertEquals(
+ Assertions.assertEquals(
(2 * currentInMemoryIndexSize) + sinkSizeOverhead,
((BatchAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -688,24 +683,24 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
currentInMemoryIndexSize = 0;
// We are now over maxSizeInBytes after the add. Hence, we do a persist.
// currHydrant in the sink has 0 bytesInMemory since we just did a persist
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(1))
);
// Mapped index size is the memory still needed after we persisted indexes. Note that the segments have
// 1 dimension columns, 2 metric column, 1 time column. However, we have two indexes now from the two pervious
// persists.
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((BatchAppenderator) appenderator).getBytesCurrentlyInMemory()
);
appenderator.close();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getBytesCurrentlyInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getBytesCurrentlyInMemory());
}
}
@@ -716,29 +711,29 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
new BatchAppenderatorTester(100, -1, true)) {
final Appenderator appenderator = tester.getAppenderator();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.startJob();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null);
//we still calculate the size even when ignoring it to make persist decision
int nullHandlingOverhead = 1;
- Assert.assertEquals(
+ Assertions.assertEquals(
190 + nullHandlingOverhead,
((BatchAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bar", 1), null);
// we added two rows only, and we told that maxSizeInBytes should be ignored, so it should not have been
// persisted:
int sinkSizeOverhead = 2 * BatchAppenderator.ROUGH_OVERHEAD_PER_SINK;
- Assert.assertEquals(
+ Assertions.assertEquals(
(380 + 2 * nullHandlingOverhead) + sinkSizeOverhead,
((BatchAppenderator) appenderator).getBytesCurrentlyInMemory()
);
- Assert.assertEquals(2, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(2, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.close();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
}
}
@@ -748,29 +743,29 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
try (final BatchAppenderatorTester tester = new BatchAppenderatorTester(3, false)) {
final Appenderator appenderator = tester.getAppenderator();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.startJob();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null);
- Assert.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bar", 1), null);
- Assert.assertEquals(2, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(2, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bar", 1), null);
- Assert.assertEquals(2, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(2, ((BatchAppenderator) appenderator).getRowsInMemory());
// no persist since last add was for a dup record
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bat", 1), null);
// persist expected ^ (3) rows added
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "baz", 1), null);
- Assert.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "qux", 1), null);
- Assert.assertEquals(2, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(2, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "bob", 1), null);
// persist expected ^ (3) rows added
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.close();
}
}
@@ -781,9 +776,9 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
try (final BatchAppenderatorTester tester = new BatchAppenderatorTester(1, false)) {
final Appenderator appenderator = tester.getAppenderator();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.startJob();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null);
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo2", 1), null);
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo3", 1), null);
@@ -796,7 +791,7 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
null,
false
).get().getSegments().stream().sorted().map(DataSegment::toString).collect(Collectors.toList());
- Assert.assertEquals(
+ Assertions.assertEquals(
List.of(
DataSegment.builder(IDENTIFIERS.get(0).asSegmentId())
.shardSpec(IDENTIFIERS.get(0).getShardSpec())
@@ -808,16 +803,16 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
),
segments
);
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
SegmentGenerationMetrics segmentGenerationMetrics = tester.getMetrics();
- Assert.assertEquals(4, segmentGenerationMetrics.numPersists());
- Assert.assertEquals(3, segmentGenerationMetrics.rowOutput());
- Assert.assertTrue(segmentGenerationMetrics.persistTimeMillis() > 0);
- Assert.assertTrue(segmentGenerationMetrics.persistCpuTime() > 0);
+ Assertions.assertEquals(4, segmentGenerationMetrics.numPersists());
+ Assertions.assertEquals(3, segmentGenerationMetrics.rowOutput());
+ Assertions.assertTrue(segmentGenerationMetrics.persistTimeMillis() > 0);
+ Assertions.assertTrue(segmentGenerationMetrics.persistCpuTime() > 0);
- Assert.assertTrue(segmentGenerationMetrics.mergeTimeMillis() > 0);
- Assert.assertTrue(segmentGenerationMetrics.mergeCpuTime() > 0);
+ Assertions.assertTrue(segmentGenerationMetrics.mergeTimeMillis() > 0);
+ Assertions.assertTrue(segmentGenerationMetrics.mergeCpuTime() > 0);
appenderator.close();
}
}
@@ -828,56 +823,56 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
try (final BatchAppenderatorTester tester = new BatchAppenderatorTester(3, false)) {
final Appenderator appenderator = tester.getAppenderator();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.startJob();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
Appenderator.AppenderatorAddResult addResult0 =
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null);
- Assert.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(1, addResult0.getNumRowsInSegment());
+ Assertions.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(1, addResult0.getNumRowsInSegment());
Appenderator.AppenderatorAddResult addResult1 =
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bar", 1), null);
- Assert.assertEquals(2, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(1, addResult1.getNumRowsInSegment());
+ Assertions.assertEquals(2, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(1, addResult1.getNumRowsInSegment());
addResult1 = // dup!
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bar", 1), null);
- Assert.assertEquals(2, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(1, addResult1.getNumRowsInSegment()); // dup record does not count
+ Assertions.assertEquals(2, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(1, addResult1.getNumRowsInSegment()); // dup record does not count
// no persist since last add was for a dup record
addResult1 =
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bat", 1), null);
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(2, addResult1.getNumRowsInSegment());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(2, addResult1.getNumRowsInSegment());
// persist expected ^ (3) rows added
// total rows per segment ought to be preserved even when sinks are removed from memory:
addResult1 =
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bat", 1), null);
- Assert.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(3, addResult1.getNumRowsInSegment());
+ Assertions.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(3, addResult1.getNumRowsInSegment());
addResult0 =
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "baz", 1), null);
- Assert.assertEquals(2, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(2, addResult0.getNumRowsInSegment());
+ Assertions.assertEquals(2, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(2, addResult0.getNumRowsInSegment());
addResult1 =
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "qux", 1), null);
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(4, addResult1.getNumRowsInSegment());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(4, addResult1.getNumRowsInSegment());
// persist expected ^ (3) rows added
addResult0 =
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "bob", 1), null);
- Assert.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(3, addResult0.getNumRowsInSegment());
+ Assertions.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(3, addResult0.getNumRowsInSegment());
appenderator.close();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
}
}
@@ -893,29 +888,29 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null);
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "bar", 2), null);
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "baz", 3), null);
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "qux", 4), null);
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(2), createInputRow("2001", "bob", 5), null);
- Assert.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.persistAll(null).get();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
List<File> segmentPaths = ((BatchAppenderator) appenderator).getPersistedidentifierPaths();
- Assert.assertNotNull(segmentPaths);
- Assert.assertEquals(3, segmentPaths.size());
+ Assertions.assertNotNull(segmentPaths);
+ Assertions.assertEquals(3, segmentPaths.size());
appenderator.push(IDENTIFIERS, null, false).get();
segmentPaths = ((BatchAppenderator) appenderator).getPersistedidentifierPaths();
- Assert.assertNotNull(segmentPaths);
- Assert.assertEquals(0, segmentPaths.size());
+ Assertions.assertNotNull(segmentPaths);
+ Assertions.assertEquals(0, segmentPaths.size());
appenderator.close();
@@ -931,73 +926,74 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null);
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "bar", 2), null);
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(2, appenderator.getTotalRowCount());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(2, appenderator.getTotalRowCount());
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "baz", 3), null);
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "qux", 4), null);
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(4, appenderator.getTotalRowCount());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(4, appenderator.getTotalRowCount());
appenderator.add(IDENTIFIERS.get(2), createInputRow("2001", "bob", 5), null);
- Assert.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(1, ((BatchAppenderator) appenderator).getRowsInMemory());
appenderator.persistAll(null).get();
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(5, appenderator.getTotalRowCount());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(5, appenderator.getTotalRowCount());
List<File> segmentPaths = ((BatchAppenderator) appenderator).getPersistedidentifierPaths();
- Assert.assertNotNull(segmentPaths);
- Assert.assertEquals(3, segmentPaths.size());
+ Assertions.assertNotNull(segmentPaths);
+ Assertions.assertEquals(3, segmentPaths.size());
appenderator.close();
segmentPaths = ((BatchAppenderator) appenderator).getPersistedidentifierPaths();
- Assert.assertNotNull(segmentPaths);
- Assert.assertEquals(0, segmentPaths.size());
+ Assertions.assertNotNull(segmentPaths);
+ Assertions.assertEquals(0, segmentPaths.size());
- Assert.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(0, appenderator.getTotalRowCount());
+ Assertions.assertEquals(0, ((BatchAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, appenderator.getTotalRowCount());
}
- @Test(timeout = 5000L)
+ @Test
+ @Timeout(value = 5000L, unit = TimeUnit.MILLISECONDS)
public void testTotalRowCount() throws Exception
{
try (final BatchAppenderatorTester tester = new BatchAppenderatorTester(3, false)) {
final Appenderator appenderator = tester.getAppenderator();
- Assert.assertEquals(0, appenderator.getTotalRowCount());
+ Assertions.assertEquals(0, appenderator.getTotalRowCount());
appenderator.startJob();
- Assert.assertEquals(0, appenderator.getTotalRowCount());
+ Assertions.assertEquals(0, appenderator.getTotalRowCount());
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null);
- Assert.assertEquals(1, appenderator.getTotalRowCount());
+ Assertions.assertEquals(1, appenderator.getTotalRowCount());
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bar", 1), null);
- Assert.assertEquals(2, appenderator.getTotalRowCount());
+ Assertions.assertEquals(2, appenderator.getTotalRowCount());
appenderator.persistAll(null).get();
- Assert.assertEquals(2, appenderator.getTotalRowCount());
+ Assertions.assertEquals(2, appenderator.getTotalRowCount());
appenderator.drop(IDENTIFIERS.get(0)).get();
- Assert.assertEquals(1, appenderator.getTotalRowCount());
+ Assertions.assertEquals(1, appenderator.getTotalRowCount());
appenderator.drop(IDENTIFIERS.get(1)).get();
- Assert.assertEquals(0, appenderator.getTotalRowCount());
+ Assertions.assertEquals(0, appenderator.getTotalRowCount());
appenderator.add(IDENTIFIERS.get(2), createInputRow("2001", "bar", 1), null);
- Assert.assertEquals(1, appenderator.getTotalRowCount());
+ Assertions.assertEquals(1, appenderator.getTotalRowCount());
appenderator.add(IDENTIFIERS.get(2), createInputRow("2001", "baz", 1), null);
- Assert.assertEquals(2, appenderator.getTotalRowCount());
+ Assertions.assertEquals(2, appenderator.getTotalRowCount());
appenderator.add(IDENTIFIERS.get(2), createInputRow("2001", "qux", 1), null);
- Assert.assertEquals(3, appenderator.getTotalRowCount());
+ Assertions.assertEquals(3, appenderator.getTotalRowCount());
appenderator.add(IDENTIFIERS.get(2), createInputRow("2001", "bob", 1), null);
- Assert.assertEquals(4, appenderator.getTotalRowCount());
+ Assertions.assertEquals(4, appenderator.getTotalRowCount());
appenderator.persistAll(null).get();
- Assert.assertEquals(4, appenderator.getTotalRowCount());
+ Assertions.assertEquals(4, appenderator.getTotalRowCount());
appenderator.drop(IDENTIFIERS.get(2)).get();
- Assert.assertEquals(0, appenderator.getTotalRowCount());
+ Assertions.assertEquals(0, appenderator.getTotalRowCount());
appenderator.close();
- Assert.assertEquals(0, appenderator.getTotalRowCount());
+ Assertions.assertEquals(0, appenderator.getTotalRowCount());
}
}
@@ -1017,14 +1013,15 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
), null);
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "foo", 1), null);
- Assert.assertEquals(1, rowIngestionMeters.getProcessed());
- Assert.assertEquals(1, rowIngestionMeters.getProcessedWithError());
- Assert.assertEquals(0, rowIngestionMeters.getUnparseable());
- Assert.assertEquals(0, rowIngestionMeters.getThrownAway());
+ Assertions.assertEquals(1, rowIngestionMeters.getProcessed());
+ Assertions.assertEquals(1, rowIngestionMeters.getProcessedWithError());
+ Assertions.assertEquals(0, rowIngestionMeters.getUnparseable());
+ Assertions.assertEquals(0, rowIngestionMeters.getThrownAway());
}
}
- @Test(timeout = 10000L)
+ @Test
+ @Timeout(value = 10000L, unit = TimeUnit.MILLISECONDS)
public void testPushContract() throws Exception
{
final RowIngestionMeters rowIngestionMeters = new SimpleRowIngestionMeters();
@@ -1048,7 +1045,7 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
).get().getSegments().stream().sorted().map(DataSegment::toString).collect(Collectors.toList());
// only one segment must have been pushed:
- Assert.assertEquals(
+ Assertions.assertEquals(
List.of(
DataSegment.builder(IDENTIFIERS.get(0).asSegmentId())
.shardSpec(IDENTIFIERS.get(0).getShardSpec())
@@ -1061,7 +1058,7 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
segments
);
- Assert.assertEquals(
+ Assertions.assertEquals(
tester.getPushedSegments().stream().sorted().map(DataSegment::toString).collect(Collectors.toList()),
segments
);
@@ -1069,7 +1066,7 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
appenderator.drop(IDENTIFIERS.get(0));
// and the segment that was not pushed should still be active
- Assert.assertEquals(
+ Assertions.assertEquals(
Collections.singletonList(IDENTIFIERS.get(1)),
appenderator.getSegments()
);
@@ -1078,7 +1075,8 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
}
}
- @Test(timeout = 5000L)
+ @Test
+ @Timeout(value = 5000L, unit = TimeUnit.MILLISECONDS)
public void testCloseContract() throws Exception
{
final RowIngestionMeters rowIngestionMeters = new SimpleRowIngestionMeters();
@@ -1112,18 +1110,18 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
// close should wait for all pushes and persists to end:
appenderator.close();
- Assert.assertTrue(!firstFuture.isCancelled());
- Assert.assertTrue(!secondFuture.isCancelled());
+ Assertions.assertTrue(!firstFuture.isCancelled());
+ Assertions.assertTrue(!secondFuture.isCancelled());
- Assert.assertTrue(firstFuture.isDone());
- Assert.assertTrue(secondFuture.isDone());
+ Assertions.assertTrue(firstFuture.isDone());
+ Assertions.assertTrue(secondFuture.isDone());
final SegmentsAndCommitMetadata segmentsAndCommitMetadataForFirstFuture = firstFuture.get();
final SegmentsAndCommitMetadata segmentsAndCommitMetadataForSecondFuture = secondFuture.get();
// all segments must have been pushed:
- Assert.assertEquals(segmentsAndCommitMetadataForFirstFuture.getSegments().size(), 1);
- Assert.assertEquals(segmentsAndCommitMetadataForSecondFuture.getSegments().size(), 1);
+ Assertions.assertEquals(segmentsAndCommitMetadataForFirstFuture.getSegments().size(), 1);
+ Assertions.assertEquals(segmentsAndCommitMetadataForSecondFuture.getSegments().size(), 1);
}
}
@@ -1176,4 +1174,3 @@ public class BatchAppenderatorTest extends InitializedNullHandlingTest
}
}
-
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/CommittedTest.java b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/CommittedTest.java
index d95a74dcfbf..6803dfaa390 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/CommittedTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/CommittedTest.java
@@ -24,8 +24,8 @@ import com.google.common.collect.ImmutableMap;
import org.apache.druid.jackson.DefaultObjectMapper;
import org.apache.druid.java.util.common.Intervals;
import org.apache.druid.timeline.partition.LinearShardSpec;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
@@ -78,7 +78,7 @@ public class CommittedTest
),
ImmutableMap.of("metadata", "foo")
);
- Assert.assertEquals(committed, committed2);
+ Assertions.assertEquals(committed, committed2);
}
@Test
@@ -87,23 +87,23 @@ public class CommittedTest
final Committed committed = fixedInstance();
final byte[] bytes = OBJECT_MAPPER.writeValueAsBytes(committed);
final Committed committed2 = OBJECT_MAPPER.readValue(bytes, Committed.class);
- Assert.assertEquals("Round trip: overall", committed, committed2);
- Assert.assertEquals("Round trip: metadata", committed.getMetadata(), committed2.getMetadata());
- Assert.assertEquals("Round trip: identifiers", committed.getHydrants().keySet(), committed2.getHydrants().keySet());
+ Assertions.assertEquals(committed, committed2, "Round trip: overall");
+ Assertions.assertEquals(committed.getMetadata(), committed2.getMetadata(), "Round trip: metadata");
+ Assertions.assertEquals(committed.getHydrants().keySet(), committed2.getHydrants().keySet(), "Round trip: identifiers");
}
@Test
public void testGetCommittedHydrant()
{
- Assert.assertEquals(3, fixedInstance().getCommittedHydrants(IDENTIFIER1));
- Assert.assertEquals(2, fixedInstance().getCommittedHydrants(IDENTIFIER2));
- Assert.assertEquals(0, fixedInstance().getCommittedHydrants(IDENTIFIER3));
+ Assertions.assertEquals(3, fixedInstance().getCommittedHydrants(IDENTIFIER1));
+ Assertions.assertEquals(2, fixedInstance().getCommittedHydrants(IDENTIFIER2));
+ Assertions.assertEquals(0, fixedInstance().getCommittedHydrants(IDENTIFIER3));
}
@Test
public void testWithout()
{
- Assert.assertEquals(0, fixedInstance().without(IDENTIFIER1).getCommittedHydrants(IDENTIFIER1));
- Assert.assertEquals(2, fixedInstance().without(IDENTIFIER1).getCommittedHydrants(IDENTIFIER2));
+ Assertions.assertEquals(0, fixedInstance().without(IDENTIFIER1).getCommittedHydrants(IDENTIFIER1));
+ Assertions.assertEquals(2, fixedInstance().without(IDENTIFIER1).getCommittedHydrants(IDENTIFIER2));
}
}
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentIdWithShardSpecTest.java b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentIdWithShardSpecTest.java
index 8e6c1b9df81..1f20014ff1d 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentIdWithShardSpecTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentIdWithShardSpecTest.java
@@ -24,8 +24,8 @@ import org.apache.druid.jackson.DefaultObjectMapper;
import org.apache.druid.java.util.common.Intervals;
import org.apache.druid.timeline.partition.NumberedShardSpec;
import org.joda.time.Interval;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class SegmentIdWithShardSpecTest
{
@@ -48,18 +48,18 @@ public class SegmentIdWithShardSpecTest
SegmentIdWithShardSpec.class
);
- Assert.assertEquals(ID_1, id2);
- Assert.assertEquals(DATA_SOURCE, id2.getDataSource());
- Assert.assertEquals(INTERVAL, id2.getInterval());
- Assert.assertEquals(VERSION, id2.getVersion());
- Assert.assertEquals(SHARD_SPEC_1.getPartitionNum(), id2.getShardSpec().getPartitionNum());
- Assert.assertEquals(SHARD_SPEC_1.getNumCorePartitions(), id2.getShardSpec().getNumCorePartitions());
+ Assertions.assertEquals(ID_1, id2);
+ Assertions.assertEquals(DATA_SOURCE, id2.getDataSource());
+ Assertions.assertEquals(INTERVAL, id2.getInterval());
+ Assertions.assertEquals(VERSION, id2.getVersion());
+ Assertions.assertEquals(SHARD_SPEC_1.getPartitionNum(), id2.getShardSpec().getPartitionNum());
+ Assertions.assertEquals(SHARD_SPEC_1.getNumCorePartitions(), id2.getShardSpec().getNumCorePartitions());
}
@Test
public void testAsString()
{
- Assert.assertEquals("foo_2000-01-01T00:00:00.000Z_2000-01-01T01:00:00.000Z_v1", ID_0.toString());
- Assert.assertEquals("foo_2000-01-01T00:00:00.000Z_2000-01-01T01:00:00.000Z_v1_1", ID_1.toString());
+ Assertions.assertEquals("foo_2000-01-01T00:00:00.000Z_2000-01-01T01:00:00.000Z_v1", ID_0.toString());
+ Assertions.assertEquals("foo_2000-01-01T00:00:00.000Z_2000-01-01T01:00:00.000Z_v1_1", ID_1.toString());
}
}
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentPublisherHelperTest.java b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentPublisherHelperTest.java
index cef0dd424b1..a5e91a74ad7 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentPublisherHelperTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentPublisherHelperTest.java
@@ -40,10 +40,8 @@ import org.apache.druid.timeline.partition.NumberedShardSpec;
import org.apache.druid.timeline.partition.PartitionIds;
import org.apache.druid.timeline.partition.ShardSpec;
import org.apache.druid.timeline.partition.SingleDimensionShardSpec;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
@@ -51,9 +49,6 @@ import java.util.Set;
public class SegmentPublisherHelperTest
{
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
public void testAnnotateAtomicUpdateGroupSize()
{
@@ -85,9 +80,9 @@ public class SegmentPublisherHelperTest
);
final Set<DataSegment> annotated = SegmentPublisherHelper.annotateShardSpec(segments);
for (DataSegment segment : annotated) {
- Assert.assertSame(NumberedOverwriteShardSpec.class, segment.getShardSpec().getClass());
+ Assertions.assertSame(NumberedOverwriteShardSpec.class, segment.getShardSpec().getClass());
final NumberedOverwriteShardSpec shardSpec = (NumberedOverwriteShardSpec) segment.getShardSpec();
- Assert.assertEquals(3, shardSpec.getAtomicUpdateGroupSize());
+ Assertions.assertEquals(3, shardSpec.getAtomicUpdateGroupSize());
}
}
@@ -101,9 +96,9 @@ public class SegmentPublisherHelperTest
);
final Set<DataSegment> annotated = SegmentPublisherHelper.annotateShardSpec(segments);
for (DataSegment segment : annotated) {
- Assert.assertSame(NumberedShardSpec.class, segment.getShardSpec().getClass());
+ Assertions.assertSame(NumberedShardSpec.class, segment.getShardSpec().getClass());
final NumberedShardSpec shardSpec = (NumberedShardSpec) segment.getShardSpec();
- Assert.assertEquals(3, shardSpec.getNumCorePartitions());
+ Assertions.assertEquals(3, shardSpec.getNumCorePartitions());
}
}
@@ -144,9 +139,9 @@ public class SegmentPublisherHelperTest
);
final Set<DataSegment> annotated = SegmentPublisherHelper.annotateShardSpec(segments);
for (DataSegment segment : annotated) {
- Assert.assertSame(HashBasedNumberedShardSpec.class, segment.getShardSpec().getClass());
+ Assertions.assertSame(HashBasedNumberedShardSpec.class, segment.getShardSpec().getClass());
final HashBasedNumberedShardSpec shardSpec = (HashBasedNumberedShardSpec) segment.getShardSpec();
- Assert.assertEquals(3, shardSpec.getNumCorePartitions());
+ Assertions.assertEquals(3, shardSpec.getNumCorePartitions());
}
}
@@ -160,9 +155,9 @@ public class SegmentPublisherHelperTest
);
final Set<DataSegment> annotated = SegmentPublisherHelper.annotateShardSpec(segments);
for (DataSegment segment : annotated) {
- Assert.assertSame(SingleDimensionShardSpec.class, segment.getShardSpec().getClass());
+ Assertions.assertSame(SingleDimensionShardSpec.class, segment.getShardSpec().getClass());
final SingleDimensionShardSpec shardSpec = (SingleDimensionShardSpec) segment.getShardSpec();
- Assert.assertEquals(3, shardSpec.getNumCorePartitions());
+ Assertions.assertEquals(3, shardSpec.getNumCorePartitions());
}
}
@@ -194,9 +189,9 @@ public class SegmentPublisherHelperTest
);
final Set<DataSegment> annotated = SegmentPublisherHelper.annotateShardSpec(segments);
for (DataSegment segment : annotated) {
- Assert.assertSame(DimensionRangeShardSpec.class, segment.getShardSpec().getClass());
+ Assertions.assertSame(DimensionRangeShardSpec.class, segment.getShardSpec().getClass());
final DimensionRangeShardSpec shardSpec = (DimensionRangeShardSpec) segment.getShardSpec();
- Assert.assertEquals(3, shardSpec.getNumCorePartitions());
+ Assertions.assertEquals(3, shardSpec.getNumCorePartitions());
}
}
@@ -209,7 +204,7 @@ public class SegmentPublisherHelperTest
newSegment(new NumberedShardSpec(2, 0))
);
final Set<DataSegment> annotated = SegmentPublisherHelper.annotateShardSpec(segments);
- Assert.assertEquals(segments, annotated);
+ Assertions.assertEquals(segments, annotated);
}
@Test
@@ -222,9 +217,9 @@ public class SegmentPublisherHelperTest
newSegment(new DimensionValueSetShardSpec(1, 0, ImmutableMap.of("tenant", ImmutableList.of("tenant_a"))))
);
final Set<DataSegment> annotated = SegmentPublisherHelper.annotateShardSpec(segments);
- Assert.assertEquals(segments, annotated);
+ Assertions.assertEquals(segments, annotated);
for (DataSegment segment : annotated) {
- Assert.assertSame(DimensionValueSetShardSpec.class, segment.getShardSpec().getClass());
+ Assertions.assertSame(DimensionValueSetShardSpec.class, segment.getShardSpec().getClass());
}
}
@@ -236,9 +231,11 @@ public class SegmentPublisherHelperTest
newSegment(new HashBucketShardSpec(1, 3, null, HashPartitionFunction.MURMUR3_32_ABS, new ObjectMapper())),
newSegment(new HashBucketShardSpec(2, 3, null, HashPartitionFunction.MURMUR3_32_ABS, new ObjectMapper()))
);
- expectedException.expect(IllegalStateException.class);
- expectedException.expectMessage("Cannot publish segments with shardSpec");
- SegmentPublisherHelper.annotateShardSpec(segments);
+ final IllegalStateException exception = Assertions.assertThrows(
+ IllegalStateException.class,
+ () -> SegmentPublisherHelper.annotateShardSpec(segments)
+ );
+ Assertions.assertTrue(exception.getMessage().contains("Cannot publish segments with shardSpec"));
}
private static DataSegment newSegment(ShardSpec shardSpec)
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentWithStateTest.java b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentWithStateTest.java
index c19ec56b6d7..4b2bd1ea28c 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentWithStateTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentWithStateTest.java
@@ -21,8 +21,8 @@ package org.apache.druid.segment.realtime.appenderator;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.druid.jackson.DefaultObjectMapper;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
@@ -33,7 +33,7 @@ public class SegmentWithStateTest
{
final ObjectMapper objectMapper = new DefaultObjectMapper();
final byte[] bytes = objectMapper.writeValueAsBytes(SegmentWithState.SegmentState.APPEND_FINISHED);
- Assert.assertEquals(
+ Assertions.assertEquals(
SegmentWithState.SegmentState.APPEND_FINISHED,
objectMapper.readValue(bytes, SegmentWithState.SegmentState.class)
);
@@ -43,11 +43,11 @@ public class SegmentWithStateTest
public void testSerdeForBackwardCompatibility() throws IOException
{
final ObjectMapper objectMapper = new DefaultObjectMapper();
- Assert.assertEquals(
+ Assertions.assertEquals(
SegmentWithState.SegmentState.APPENDING,
objectMapper.readValue("\"ACTIVE\"", SegmentWithState.SegmentState.class)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
SegmentWithState.SegmentState.APPEND_FINISHED,
objectMapper.readValue("\"INACTIVE\"", SegmentWithState.SegmentState.class)
);
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentsAndCommitMetadataTest.java b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentsAndCommitMetadataTest.java
index 43df387598c..dc3f666e7c8 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentsAndCommitMetadataTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SegmentsAndCommitMetadataTest.java
@@ -20,7 +20,7 @@
package org.apache.druid.segment.realtime.appenderator;
import nl.jqno.equalsverifier.EqualsVerifier;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class SegmentsAndCommitMetadataTest
{
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SinkSchemaUtilTest.java b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SinkSchemaUtilTest.java
index 2d0da3a33bc..87904acfff0 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SinkSchemaUtilTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/SinkSchemaUtilTest.java
@@ -27,8 +27,8 @@ import org.apache.druid.segment.column.ColumnType;
import org.apache.druid.segment.column.RowSignature;
import org.apache.druid.segment.realtime.appenderator.SegmentSchemas.SegmentSchema;
import org.apache.druid.timeline.SegmentId;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.HashMap;
@@ -41,7 +41,7 @@ public class SinkSchemaUtilTest
@Test
public void testComputeAbsoluteSchemaEmpty()
{
- Assert.assertEquals(Optional.empty(), SinkSchemaUtil.computeAbsoluteSchema(new HashMap<>()));
+ Assertions.assertEquals(Optional.empty(), SinkSchemaUtil.computeAbsoluteSchema(new HashMap<>()));
}
@Test
@@ -79,30 +79,30 @@ public class SinkSchemaUtilTest
Optional<SegmentSchemas> segmentSchemas = SinkSchemaUtil.computeAbsoluteSchema(sinkSchemaMap);
- Assert.assertTrue(segmentSchemas.isPresent());
- Assert.assertEquals(2, segmentSchemas.get().getSegmentSchemaList().size());
+ Assertions.assertTrue(segmentSchemas.isPresent());
+ Assertions.assertEquals(2, segmentSchemas.get().getSegmentSchemaList().size());
Map<String, SegmentSchema> segmentSchemaMap = segmentSchemas.get().getSegmentSchemaList().stream().collect(
Collectors.toMap(SegmentSchema::getSegmentId, v -> v));
SegmentSchema segmentSchema1 = segmentSchemaMap.get(segment1.toString());
- Assert.assertEquals(20, segmentSchema1.getNumRows().intValue());
- Assert.assertEquals(segment1.toString(), segmentSchema1.getSegmentId());
- Assert.assertEquals("foo", segmentSchema1.getDataSource());
- Assert.assertFalse(segmentSchema1.isDelta());
- Assert.assertEquals(ImmutableList.of("dim1", "dim2", "dim3"), segmentSchema1.getNewColumns());
- Assert.assertEquals(columnTypeMap1, segmentSchema1.getColumnTypeMap());
- Assert.assertEquals(Collections.emptyList(), segmentSchema1.getUpdatedColumns());
+ Assertions.assertEquals(20, segmentSchema1.getNumRows().intValue());
+ Assertions.assertEquals(segment1.toString(), segmentSchema1.getSegmentId());
+ Assertions.assertEquals("foo", segmentSchema1.getDataSource());
+ Assertions.assertFalse(segmentSchema1.isDelta());
+ Assertions.assertEquals(ImmutableList.of("dim1", "dim2", "dim3"), segmentSchema1.getNewColumns());
+ Assertions.assertEquals(columnTypeMap1, segmentSchema1.getColumnTypeMap());
+ Assertions.assertEquals(Collections.emptyList(), segmentSchema1.getUpdatedColumns());
SegmentSchema segmentSchema2 = segmentSchemaMap.get(segment2.toString());
- Assert.assertEquals(40, segmentSchema2.getNumRows().intValue());
- Assert.assertEquals(segment2.toString(), segmentSchema2.getSegmentId());
- Assert.assertEquals("foo", segmentSchema2.getDataSource());
- Assert.assertFalse(segmentSchema2.isDelta());
- Assert.assertEquals(ImmutableList.of("dim1", "dim2", "dim3", "dim4"), segmentSchema2.getNewColumns());
- Assert.assertEquals(columnTypeMap2, segmentSchema2.getColumnTypeMap());
- Assert.assertEquals(Collections.emptyList(), segmentSchema2.getUpdatedColumns());
+ Assertions.assertEquals(40, segmentSchema2.getNumRows().intValue());
+ Assertions.assertEquals(segment2.toString(), segmentSchema2.getSegmentId());
+ Assertions.assertEquals("foo", segmentSchema2.getDataSource());
+ Assertions.assertFalse(segmentSchema2.isDelta());
+ Assertions.assertEquals(ImmutableList.of("dim1", "dim2", "dim3", "dim4"), segmentSchema2.getNewColumns());
+ Assertions.assertEquals(columnTypeMap2, segmentSchema2.getColumnTypeMap());
+ Assertions.assertEquals(Collections.emptyList(), segmentSchema2.getUpdatedColumns());
}
@Test
@@ -153,7 +153,7 @@ public class SinkSchemaUtilTest
Pair<RowSignature, Integer> schema3 = Pair.of(toRowSignature(columnTypeMap3), 80);
previousSinkSchemaMap.put(segment3, schema3);
- Assert.assertFalse(SinkSchemaUtil.computeSchemaChange(previousSinkSchemaMap, previousSinkSchemaMap).isPresent());
+ Assertions.assertFalse(SinkSchemaUtil.computeSchemaChange(previousSinkSchemaMap, previousSinkSchemaMap).isPresent());
}
@Test
@@ -239,37 +239,37 @@ public class SinkSchemaUtilTest
Optional<SegmentSchemas> segmentSchemasChange = SinkSchemaUtil.computeSchemaChange(previousSinkSchemaMap, currentSinkSchemaMap);
- Assert.assertTrue(segmentSchemasChange.isPresent());
- Assert.assertEquals(3, segmentSchemasChange.get().getSegmentSchemaList().size());
+ Assertions.assertTrue(segmentSchemasChange.isPresent());
+ Assertions.assertEquals(3, segmentSchemasChange.get().getSegmentSchemaList().size());
Map<String, SegmentSchema> segmentSchemaMap = segmentSchemasChange.get().getSegmentSchemaList().stream().collect(
Collectors.toMap(SegmentSchema::getSegmentId, v -> v));
SegmentSchema segmentSchema1 = segmentSchemaMap.get(segment1.toString());
- Assert.assertEquals(segment1.toString(), segmentSchema1.getSegmentId());
- Assert.assertEquals("foo", segmentSchema1.getDataSource());
- Assert.assertTrue(segmentSchema1.isDelta());
- Assert.assertEquals(50, segmentSchema1.getNumRows().intValue());
- Assert.assertEquals(ImmutableList.of("dim4", "dim5"), segmentSchema1.getNewColumns());
- Assert.assertEquals(ImmutableList.of("dim1", "dim2"), segmentSchema1.getUpdatedColumns());
- Assert.assertEquals(currColumnTypeMap1, segmentSchema1.getColumnTypeMap());
+ Assertions.assertEquals(segment1.toString(), segmentSchema1.getSegmentId());
+ Assertions.assertEquals("foo", segmentSchema1.getDataSource());
+ Assertions.assertTrue(segmentSchema1.isDelta());
+ Assertions.assertEquals(50, segmentSchema1.getNumRows().intValue());
+ Assertions.assertEquals(ImmutableList.of("dim4", "dim5"), segmentSchema1.getNewColumns());
+ Assertions.assertEquals(ImmutableList.of("dim1", "dim2"), segmentSchema1.getUpdatedColumns());
+ Assertions.assertEquals(currColumnTypeMap1, segmentSchema1.getColumnTypeMap());
SegmentSchema segmentSchema2 = segmentSchemaMap.get(segment3.toString());
- Assert.assertEquals(segment3.toString(), segmentSchema2.getSegmentId());
- Assert.assertEquals("foo", segmentSchema2.getDataSource());
- Assert.assertTrue(segmentSchema2.isDelta());
- Assert.assertEquals(100, segmentSchema2.getNumRows().intValue());
- Assert.assertEquals(Collections.emptyList(), segmentSchema2.getNewColumns());
- Assert.assertEquals(Collections.emptyList(), segmentSchema2.getUpdatedColumns());
- Assert.assertEquals(new HashMap<>(), segmentSchema2.getColumnTypeMap());
+ Assertions.assertEquals(segment3.toString(), segmentSchema2.getSegmentId());
+ Assertions.assertEquals("foo", segmentSchema2.getDataSource());
+ Assertions.assertTrue(segmentSchema2.isDelta());
+ Assertions.assertEquals(100, segmentSchema2.getNumRows().intValue());
+ Assertions.assertEquals(Collections.emptyList(), segmentSchema2.getNewColumns());
+ Assertions.assertEquals(Collections.emptyList(), segmentSchema2.getUpdatedColumns());
+ Assertions.assertEquals(new HashMap<>(), segmentSchema2.getColumnTypeMap());
SegmentSchema segmentSchema3 = segmentSchemaMap.get(segment4.toString());
- Assert.assertEquals(segment4.toString(), segmentSchema3.getSegmentId());
- Assert.assertEquals("foo", segmentSchema3.getDataSource());
- Assert.assertFalse(segmentSchema3.isDelta());
- Assert.assertEquals(40, segmentSchema3.getNumRows().intValue());
- Assert.assertEquals(ImmutableList.of("dim1", "dim2", "dim3", "dim4"), segmentSchema3.getNewColumns());
- Assert.assertEquals(Collections.emptyList(), segmentSchema3.getUpdatedColumns());
- Assert.assertEquals(columnTypeMap4, segmentSchema3.getColumnTypeMap());
+ Assertions.assertEquals(segment4.toString(), segmentSchema3.getSegmentId());
+ Assertions.assertEquals("foo", segmentSchema3.getDataSource());
+ Assertions.assertFalse(segmentSchema3.isDelta());
+ Assertions.assertEquals(40, segmentSchema3.getNumRows().intValue());
+ Assertions.assertEquals(ImmutableList.of("dim1", "dim2", "dim3", "dim4"), segmentSchema3.getNewColumns());
+ Assertions.assertEquals(Collections.emptyList(), segmentSchema3.getUpdatedColumns());
+ Assertions.assertEquals(columnTypeMap4, segmentSchema3.getColumnTypeMap());
}
private RowSignature toRowSignature(Map<String, ColumnType> columnTypeMap)
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderatorDriverFailTest.java b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderatorDriverFailTest.java
index a5b4709e919..2ecfaa9f39d 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderatorDriverFailTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderatorDriverFailTest.java
@@ -50,14 +50,11 @@ import org.apache.druid.timeline.SegmentId;
import org.apache.druid.timeline.partition.NumberedShardSpec;
import org.easymock.EasyMock;
import org.easymock.EasyMockSupport;
-import org.hamcrest.CoreMatchers;
import org.joda.time.Interval;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -100,10 +97,7 @@ public class StreamAppenderatorDriverFailTest extends EasyMockSupport
StreamAppenderatorDriver driver;
DataSegmentKiller dataSegmentKiller;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
+ @BeforeEach
public void setUp()
{
allocator = new TestSegmentAllocator(DATA_SOURCE, Granularities.HOUR);
@@ -111,7 +105,7 @@ public class StreamAppenderatorDriverFailTest extends EasyMockSupport
dataSegmentKiller = createStrictMock(DataSegmentKiller.class);
}
- @After
+ @AfterEach
public void tearDown() throws Exception
{
if (driver != null) {
@@ -123,12 +117,6 @@ public class StreamAppenderatorDriverFailTest extends EasyMockSupport
@Test
public void testFailDuringPersist() throws IOException, InterruptedException, TimeoutException, ExecutionException
{
- expectedException.expect(ExecutionException.class);
- expectedException.expectCause(CoreMatchers.instanceOf(ISE.class));
- expectedException.expectMessage("Fail test while persisting segments"
- + "[[foo_2000-01-01T00:00:00.000Z_2000-01-01T01:00:00.000Z_abc123, "
- + "foo_2000-01-01T01:00:00.000Z_2000-01-01T02:00:00.000Z_abc123]]");
-
driver = new StreamAppenderatorDriver(
createPersistFailAppenderator(),
allocator,
@@ -144,29 +132,34 @@ public class StreamAppenderatorDriverFailTest extends EasyMockSupport
final TestCommitterSupplier<Integer> committerSupplier = new TestCommitterSupplier<>();
segmentHandoffNotifierFactory.setHandoffDelay(100);
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
for (int i = 0; i < ROWS.size(); i++) {
committerSupplier.setMetadata(i + 1);
- Assert.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
+ Assertions.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
}
- driver.publish(
- StreamAppenderatorDriverTest.makeOkPublisher(),
- committerSupplier.get(),
- ImmutableList.of("dummy")
- ).get(PUBLISH_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+ final ExecutionException exception = Assertions.assertThrows(
+ ExecutionException.class,
+ () -> driver.publish(
+ StreamAppenderatorDriverTest.makeOkPublisher(),
+ committerSupplier.get(),
+ ImmutableList.of("dummy")
+ ).get(PUBLISH_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)
+ );
+ Assertions.assertTrue(exception.getCause() instanceof ISE);
+ Assertions.assertTrue(
+ exception.getMessage().contains(
+ "Fail test while persisting segments"
+ + "[[foo_2000-01-01T00:00:00.000Z_2000-01-01T01:00:00.000Z_abc123, "
+ + "foo_2000-01-01T01:00:00.000Z_2000-01-01T02:00:00.000Z_abc123]]"
+ )
+ );
}
@Test
public void testFailDuringPush() throws IOException, InterruptedException, TimeoutException, ExecutionException
{
- expectedException.expect(ExecutionException.class);
- expectedException.expectCause(CoreMatchers.instanceOf(ISE.class));
- expectedException.expectMessage("Fail test while pushing segments"
- + "[[foo_2000-01-01T00:00:00.000Z_2000-01-01T01:00:00.000Z_abc123, "
- + "foo_2000-01-01T01:00:00.000Z_2000-01-01T02:00:00.000Z_abc123]]");
-
driver = new StreamAppenderatorDriver(
createPushFailAppenderator(),
allocator,
@@ -182,29 +175,34 @@ public class StreamAppenderatorDriverFailTest extends EasyMockSupport
final TestCommitterSupplier<Integer> committerSupplier = new TestCommitterSupplier<>();
segmentHandoffNotifierFactory.setHandoffDelay(100);
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
for (int i = 0; i < ROWS.size(); i++) {
committerSupplier.setMetadata(i + 1);
- Assert.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
+ Assertions.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
}
- driver.publish(
- StreamAppenderatorDriverTest.makeOkPublisher(),
- committerSupplier.get(),
- ImmutableList.of("dummy")
- ).get(PUBLISH_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+ final ExecutionException exception = Assertions.assertThrows(
+ ExecutionException.class,
+ () -> driver.publish(
+ StreamAppenderatorDriverTest.makeOkPublisher(),
+ committerSupplier.get(),
+ ImmutableList.of("dummy")
+ ).get(PUBLISH_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)
+ );
+ Assertions.assertTrue(exception.getCause() instanceof ISE);
+ Assertions.assertTrue(
+ exception.getMessage().contains(
+ "Fail test while pushing segments"
+ + "[[foo_2000-01-01T00:00:00.000Z_2000-01-01T01:00:00.000Z_abc123, "
+ + "foo_2000-01-01T01:00:00.000Z_2000-01-01T02:00:00.000Z_abc123]]"
+ )
+ );
}
@Test
public void testFailDuringDrop() throws IOException, InterruptedException, TimeoutException, ExecutionException
{
- expectedException.expect(ExecutionException.class);
- expectedException.expectCause(CoreMatchers.instanceOf(ISE.class));
- expectedException.expectMessage(
- "Fail test while dropping segment"
- );
-
driver = new StreamAppenderatorDriver(
createDropFailAppenderator(),
allocator,
@@ -220,10 +218,10 @@ public class StreamAppenderatorDriverFailTest extends EasyMockSupport
final TestCommitterSupplier<Integer> committerSupplier = new TestCommitterSupplier<>();
segmentHandoffNotifierFactory.setHandoffDelay(100);
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
committerSupplier.setMetadata(1);
- Assert.assertTrue(driver.add(ROWS.get(0), "dummy", committerSupplier, false, true).isOk());
+ Assertions.assertTrue(driver.add(ROWS.get(0), "dummy", committerSupplier, false, true).isOk());
final SegmentsAndCommitMetadata published = driver.publish(
StreamAppenderatorDriverTest.makeOkPublisher(),
@@ -231,27 +229,34 @@ public class StreamAppenderatorDriverFailTest extends EasyMockSupport
ImmutableList.of("dummy")
).get(PUBLISH_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- driver.registerHandoff(published).get();
+ final ExecutionException exception = Assertions.assertThrows(
+ ExecutionException.class,
+ () -> driver.registerHandoff(published).get()
+ );
+ Assertions.assertTrue(exception.getCause() instanceof ISE);
+ Assertions.assertTrue(exception.getMessage().contains("Fail test while dropping segment"));
}
@Test
public void testFailDuringPublish() throws Exception
{
- expectedException.expect(ExecutionException.class);
- expectedException.expectCause(CoreMatchers.instanceOf(ISE.class));
- expectedException.expectMessage("Failed to publish segments because of [test]");
-
- testFailDuringPublishInternal(false);
+ final ExecutionException exception = Assertions.assertThrows(
+ ExecutionException.class,
+ () -> testFailDuringPublishInternal(false)
+ );
+ Assertions.assertTrue(exception.getCause() instanceof ISE);
+ Assertions.assertTrue(exception.getMessage().contains("Failed to publish segments because of [test]"));
}
@Test
public void testFailWithExceptionDuringPublish() throws Exception
{
- expectedException.expect(ExecutionException.class);
- expectedException.expectCause(CoreMatchers.instanceOf(RuntimeException.class));
- expectedException.expectMessage("test");
-
- testFailDuringPublishInternal(true);
+ final ExecutionException exception = Assertions.assertThrows(
+ ExecutionException.class,
+ () -> testFailDuringPublishInternal(true)
+ );
+ Assertions.assertTrue(exception.getCause() instanceof RuntimeException);
+ Assertions.assertTrue(exception.getMessage().contains("test"));
}
private void testFailDuringPublishInternal(boolean failWithException) throws Exception
@@ -271,11 +276,11 @@ public class StreamAppenderatorDriverFailTest extends EasyMockSupport
final TestCommitterSupplier<Integer> committerSupplier = new TestCommitterSupplier<>();
segmentHandoffNotifierFactory.setHandoffDelay(100);
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
for (int i = 0; i < ROWS.size(); i++) {
committerSupplier.setMetadata(i + 1);
- Assert.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
+ Assertions.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
}
if (!failWithException) {
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderatorDriverTest.java b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderatorDriverTest.java
index d5ba958a226..9d7baf19e93 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderatorDriverTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderatorDriverTest.java
@@ -42,18 +42,19 @@ import org.apache.druid.segment.handoff.SegmentHandoffNotifier;
import org.apache.druid.segment.handoff.SegmentHandoffNotifierFactory;
import org.apache.druid.segment.loading.DataSegmentKiller;
import org.apache.druid.segment.realtime.SegmentGenerationMetrics;
+import org.apache.druid.testing.TemporaryFolderExtension;
import org.apache.druid.timeline.DataSegment;
import org.apache.druid.timeline.partition.DimensionValueSetShardSpec;
import org.apache.druid.timeline.partition.NumberedShardSpec;
import org.easymock.EasyMock;
import org.easymock.EasyMockSupport;
import org.joda.time.DateTime;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.extension.RegisterExtension;
import javax.annotation.Nullable;
import java.io.IOException;
@@ -107,10 +108,10 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
private StreamAppenderatorDriver driver;
private DataSegmentKiller dataSegmentKiller;
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @RegisterExtension
+ public final TemporaryFolderExtension temporaryFolder = new TemporaryFolderExtension();
- @Before
+ @BeforeEach
public void setUp() throws Exception
{
streamAppenderatorTester =
@@ -134,7 +135,7 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
EasyMock.replay(dataSegmentKiller);
}
- @After
+ @AfterEach
public void tearDown() throws Exception
{
EasyMock.verify(dataSegmentKiller);
@@ -143,16 +144,17 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
driver.close();
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testSimple() throws Exception
{
final TestCommitterSupplier<Integer> committerSupplier = new TestCommitterSupplier<>();
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
for (int i = 0; i < ROWS.size(); i++) {
committerSupplier.setMetadata(i + 1);
- Assert.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
+ Assertions.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
}
final SegmentsAndCommitMetadata published = driver.publish(
@@ -168,7 +170,7 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
final SegmentsAndCommitMetadata segmentsAndCommitMetadata = driver.registerHandoff(published)
.get(HANDOFF_CONDITION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableSet.of(
new SegmentIdWithShardSpec(DATA_SOURCE, Intervals.of("2000/PT1H"), VERSION, new NumberedShardSpec(0, 0)),
new SegmentIdWithShardSpec(DATA_SOURCE, Intervals.of("2000T01/PT1H"), VERSION, new NumberedShardSpec(0, 0))
@@ -176,17 +178,18 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
asIdentifiers(segmentsAndCommitMetadata.getSegments())
);
- Assert.assertEquals(3, segmentsAndCommitMetadata.getCommitMetadata());
+ Assertions.assertEquals(3, segmentsAndCommitMetadata.getCommitMetadata());
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testPublishReturnsAnnotatedShardSpecs() throws Exception
{
final TestCommitterSupplier<Integer> committerSupplier = new TestCommitterSupplier<>();
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
for (int i = 0; i < ROWS.size(); i++) {
committerSupplier.setMetadata(i + 1);
- Assert.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
+ Assertions.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
}
// Annotate function that swaps every segment to a DimensionValueSetShardSpec. The publisher echoes the annotated segments
@@ -209,12 +212,12 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
toDimensionValueSet
).get(PUBLISH_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- Assert.assertFalse("Expected at least one published segment", published.getSegments().isEmpty());
+ Assertions.assertFalse(published.getSegments().isEmpty(), "Expected at least one published segment");
for (DataSegment segment : published.getSegments()) {
- Assert.assertTrue(
+ Assertions.assertTrue(
+ segment.getShardSpec() instanceof DimensionValueSetShardSpec,
"Returned segment should carry the published DimensionValueSetShardSpec, not the pre-publish NumberedShardSpec; "
- + "got " + segment.getShardSpec().getClass().getSimpleName(),
- segment.getShardSpec() instanceof DimensionValueSetShardSpec
+ + "got " + segment.getShardSpec().getClass().getSimpleName()
);
}
}
@@ -224,7 +227,7 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
{
final int numSegments = 3;
final TestCommitterSupplier<Integer> committerSupplier = new TestCommitterSupplier<>();
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
for (int i = 0; i < numSegments * MAX_ROWS_PER_SEGMENT; i++) {
committerSupplier.setMetadata(i + 1);
@@ -239,7 +242,7 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
)
);
final AppenderatorDriverAddResult addResult = driver.add(row, "dummy", committerSupplier, false, true);
- Assert.assertTrue(addResult.isOk());
+ Assertions.assertTrue(addResult.isOk());
if (addResult.getNumRowsInSegment() > MAX_ROWS_PER_SEGMENT) {
driver.moveSegmentOut("dummy", ImmutableList.of(addResult.getSegmentIdentifier()));
}
@@ -257,21 +260,22 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
final SegmentsAndCommitMetadata segmentsAndCommitMetadata = driver.registerHandoff(published)
.get(HANDOFF_CONDITION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- Assert.assertEquals(numSegments, segmentsAndCommitMetadata.getSegments().size());
- Assert.assertEquals(numSegments * MAX_ROWS_PER_SEGMENT, segmentsAndCommitMetadata.getCommitMetadata());
+ Assertions.assertEquals(numSegments, segmentsAndCommitMetadata.getSegments().size());
+ Assertions.assertEquals(numSegments * MAX_ROWS_PER_SEGMENT, segmentsAndCommitMetadata.getCommitMetadata());
}
- @Test(timeout = 60_000L, expected = TimeoutException.class)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testHandoffTimeout() throws Exception
{
final TestCommitterSupplier<Integer> committerSupplier = new TestCommitterSupplier<>();
segmentHandoffNotifierFactory.disableHandoff();
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
for (int i = 0; i < ROWS.size(); i++) {
committerSupplier.setMetadata(i + 1);
- Assert.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
+ Assertions.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
}
final SegmentsAndCommitMetadata published = driver.publish(
@@ -284,7 +288,10 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
Thread.sleep(100);
}
- driver.registerHandoff(published).get(HANDOFF_CONDITION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+ Assertions.assertThrows(
+ TimeoutException.class,
+ () -> driver.registerHandoff(published).get(HANDOFF_CONDITION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)
+ );
}
@Test
@@ -293,11 +300,11 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
{
final TestCommitterSupplier<Integer> committerSupplier = new TestCommitterSupplier<>();
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
for (int i = 0; i < ROWS.size(); i++) {
committerSupplier.setMetadata(i + 1);
- Assert.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
+ Assertions.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
}
driver.persist(committerSupplier.get());
@@ -309,8 +316,8 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
ImmutableList.of("dummy")
).get(PUBLISH_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- Assert.assertNotNull(segmentsAndCommitMetadata.getUpgradedSegments());
- Assert.assertEquals(
+ Assertions.assertNotNull(segmentsAndCommitMetadata.getUpgradedSegments());
+ Assertions.assertEquals(
segmentsAndCommitMetadata.getSegments().size(),
segmentsAndCommitMetadata.getUpgradedSegments().size()
);
@@ -322,7 +329,7 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
for (DataSegment segment : segmentsAndCommitMetadata.getUpgradedSegments()) {
expectedHandedOffSegments.add(segment.toDescriptor());
}
- Assert.assertEquals(expectedHandedOffSegments, segmentHandoffNotifierFactory.getHandedOffSegmentDescriptors());
+ Assertions.assertEquals(expectedHandedOffSegments, segmentHandoffNotifierFactory.getHandedOffSegmentDescriptors());
}
@Test
@@ -330,12 +337,12 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
{
final TestCommitterSupplier<Integer> committerSupplier = new TestCommitterSupplier<>();
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
// Add the first row and publish immediately
{
committerSupplier.setMetadata(1);
- Assert.assertTrue(driver.add(ROWS.get(0), "dummy", committerSupplier, false, true).isOk());
+ Assertions.assertTrue(driver.add(ROWS.get(0), "dummy", committerSupplier, false, true).isOk());
final SegmentsAndCommitMetadata segmentsAndCommitMetadata = driver.publishAndRegisterHandoff(
makeOkPublisher(),
@@ -343,20 +350,20 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
ImmutableList.of("dummy")
).get(PUBLISH_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableSet.of(
new SegmentIdWithShardSpec(DATA_SOURCE, Intervals.of("2000/PT1H"), VERSION, new NumberedShardSpec(0, 0))
),
asIdentifiers(segmentsAndCommitMetadata.getSegments())
);
- Assert.assertEquals(1, segmentsAndCommitMetadata.getCommitMetadata());
+ Assertions.assertEquals(1, segmentsAndCommitMetadata.getCommitMetadata());
}
// Add the second and third rows and publish immediately
for (int i = 1; i < ROWS.size(); i++) {
committerSupplier.setMetadata(i + 1);
- Assert.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
+ Assertions.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
final SegmentsAndCommitMetadata segmentsAndCommitMetadata = driver.publishAndRegisterHandoff(
makeOkPublisher(),
@@ -364,7 +371,7 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
ImmutableList.of("dummy")
).get(PUBLISH_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableSet.of(
// The second and third rows have the same dataSource, interval, and version, but different shardSpec of
// different partitionNum
@@ -373,7 +380,7 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
asIdentifiers(segmentsAndCommitMetadata.getSegments())
);
- Assert.assertEquals(i + 1, segmentsAndCommitMetadata.getCommitMetadata());
+ Assertions.assertEquals(i + 1, segmentsAndCommitMetadata.getCommitMetadata());
}
driver.persist(committerSupplier.get());
@@ -385,12 +392,12 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
ImmutableList.of("dummy")
).get(PUBLISH_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableSet.of(),
asIdentifiers(segmentsAndCommitMetadata.getSegments())
);
- Assert.assertEquals(3, segmentsAndCommitMetadata.getCommitMetadata());
+ Assertions.assertEquals(3, segmentsAndCommitMetadata.getCommitMetadata());
}
@Test
@@ -398,14 +405,14 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
{
final TestCommitterSupplier<Integer> committerSupplier = new TestCommitterSupplier<>();
- Assert.assertNull(driver.startJob(null));
+ Assertions.assertNull(driver.startJob(null));
committerSupplier.setMetadata(1);
- Assert.assertTrue(driver.add(ROWS.get(0), "sequence_0", committerSupplier, false, true).isOk());
+ Assertions.assertTrue(driver.add(ROWS.get(0), "sequence_0", committerSupplier, false, true).isOk());
for (int i = 1; i < ROWS.size(); i++) {
committerSupplier.setMetadata(i + 1);
- Assert.assertTrue(driver.add(ROWS.get(i), "sequence_1", committerSupplier, false, true).isOk());
+ Assertions.assertTrue(driver.add(ROWS.get(i), "sequence_1", committerSupplier, false, true).isOk());
}
final ListenableFuture<SegmentsAndCommitMetadata> futureForSequence0 = driver.publishAndRegisterHandoff(
@@ -429,22 +436,22 @@ public class StreamAppenderatorDriverTest extends EasyMockSupport
TimeUnit.MILLISECONDS
);
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableSet.of(
new SegmentIdWithShardSpec(DATA_SOURCE, Intervals.of("2000/PT1H"), VERSION, new NumberedShardSpec(0, 0))
),
asIdentifiers(handedoffFromSequence0.getSegments())
);
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableSet.of(
new SegmentIdWithShardSpec(DATA_SOURCE, Intervals.of("2000T01/PT1H"), VERSION, new NumberedShardSpec(0, 0))
),
asIdentifiers(handedoffFromSequence1.getSegments())
);
- Assert.assertEquals(3, handedoffFromSequence0.getCommitMetadata());
- Assert.assertEquals(3, handedoffFromSequence1.getCommitMetadata());
+ Assertions.assertEquals(3, handedoffFromSequence0.getCommitMetadata());
+ Assertions.assertEquals(3, handedoffFromSequence1.getCommitMetadata());
}
private Set<SegmentIdWithShardSpec> asIdentifiers(Iterable<DataSegment> segments)
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderatorTest.java b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderatorTest.java
index 4f4a0d39046..3bd6990503c 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderatorTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderatorTest.java
@@ -60,17 +60,14 @@ import org.apache.druid.segment.realtime.SegmentGenerationMetrics;
import org.apache.druid.segment.realtime.sink.Committers;
import org.apache.druid.server.coordination.DataSegmentAnnouncer;
import org.apache.druid.testing.InitializedNullHandlingTest;
+import org.apache.druid.testing.TemporaryFolderExtension;
import org.apache.druid.timeline.DataSegment;
import org.apache.druid.timeline.partition.LinearShardSpec;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.MatcherAssert;
import org.joda.time.Interval;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.internal.matchers.ThrowableCauseMatcher;
-import org.junit.internal.matchers.ThrowableMessageMatcher;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.extension.RegisterExtension;
import javax.annotation.Nullable;
import java.io.IOException;
@@ -97,8 +94,8 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
si("2001/2002", "A", 0)
);
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @RegisterExtension
+ public final TemporaryFolderExtension temporaryFolder = new TemporaryFolderExtension();
@Test
public void testSimpleIngestion() throws Exception
@@ -114,39 +111,39 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final Supplier<Committer> committerSupplier = committerSupplierFromConcurrentMap(commitMetadata);
// startJob
- Assert.assertEquals(null, appenderator.startJob());
+ Assertions.assertEquals(null, appenderator.startJob());
// getDataSource
- Assert.assertEquals(StreamAppenderatorTester.DATASOURCE, appenderator.getDataSource());
+ Assertions.assertEquals(StreamAppenderatorTester.DATASOURCE, appenderator.getDataSource());
// add
commitMetadata.put("x", "1");
- Assert.assertEquals(
+ Assertions.assertEquals(
1,
appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", 1), committerSupplier)
.getNumRowsInSegment()
);
commitMetadata.put("x", "2");
- Assert.assertEquals(
+ Assertions.assertEquals(
2,
appenderator.add(IDENTIFIERS.get(0), ir("2000", "bar", 2), committerSupplier)
.getNumRowsInSegment()
);
commitMetadata.put("x", "3");
- Assert.assertEquals(
+ Assertions.assertEquals(
1,
appenderator.add(IDENTIFIERS.get(1), ir("2000", "qux", 4), committerSupplier)
.getNumRowsInSegment()
);
// getSegments
- Assert.assertEquals(IDENTIFIERS.subList(0, 2), sorted(appenderator.getSegments()));
+ Assertions.assertEquals(IDENTIFIERS.subList(0, 2), sorted(appenderator.getSegments()));
// getRowCount
- Assert.assertEquals(2, appenderator.getRowCount(IDENTIFIERS.get(0)));
- Assert.assertEquals(1, appenderator.getRowCount(IDENTIFIERS.get(1)));
+ Assertions.assertEquals(2, appenderator.getRowCount(IDENTIFIERS.get(0)));
+ Assertions.assertEquals(1, appenderator.getRowCount(IDENTIFIERS.get(1)));
thrown = false;
try {
appenderator.getRowCount(IDENTIFIERS.get(2));
@@ -154,7 +151,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
catch (IllegalStateException e) {
thrown = true;
}
- Assert.assertTrue(thrown);
+ Assertions.assertTrue(thrown);
// push all
final SegmentsAndCommitMetadata segmentsAndCommitMetadata = appenderator.push(
@@ -162,7 +159,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
committerSupplier.get(),
false
).get();
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableMap.of("x", "3"),
segmentsAndCommitMetadata.getCommitMetadata()
);
@@ -170,7 +167,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
sorted(segmentsAndCommitMetadata.getSegments()),
DataSegment::toString
);
- Assert.assertEquals(
+ Assertions.assertEquals(
List.of(
DataSegment.builder(IDENTIFIERS.get(0).asSegmentId())
.shardSpec(IDENTIFIERS.get(0).getShardSpec())
@@ -187,20 +184,20 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
.build()
.toString()
), segments);
- Assert.assertEquals(Lists.transform(sorted(tester.getPushedSegments()), DataSegment::toString), segments);
+ Assertions.assertEquals(Lists.transform(sorted(tester.getPushedSegments()), DataSegment::toString), segments);
SegmentGenerationMetrics segmentGenerationMetrics = tester.getMetrics();
- Assert.assertEquals(2, segmentGenerationMetrics.numPersists());
- Assert.assertEquals(3, segmentGenerationMetrics.rowOutput());
- Assert.assertTrue(segmentGenerationMetrics.persistTimeMillis() > 0);
- Assert.assertTrue(segmentGenerationMetrics.persistCpuTime() > 0);
+ Assertions.assertEquals(2, segmentGenerationMetrics.numPersists());
+ Assertions.assertEquals(3, segmentGenerationMetrics.rowOutput());
+ Assertions.assertTrue(segmentGenerationMetrics.persistTimeMillis() > 0);
+ Assertions.assertTrue(segmentGenerationMetrics.persistCpuTime() > 0);
- Assert.assertTrue(segmentGenerationMetrics.mergeTimeMillis() > 0);
- Assert.assertTrue(segmentGenerationMetrics.mergeCpuTime() > 0);
+ Assertions.assertTrue(segmentGenerationMetrics.mergeTimeMillis() > 0);
+ Assertions.assertTrue(segmentGenerationMetrics.mergeCpuTime() > 0);
// clear
appenderator.clear();
- Assert.assertTrue(appenderator.getSegments().isEmpty());
+ Assertions.assertTrue(appenderator.getSegments().isEmpty());
}
}
@@ -219,39 +216,39 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final Supplier<Committer> committerSupplier = committerSupplierFromConcurrentMap(commitMetadata);
// startJob
- Assert.assertEquals(null, appenderator.startJob());
+ Assertions.assertEquals(null, appenderator.startJob());
// getDataSource
- Assert.assertEquals(StreamAppenderatorTester.DATASOURCE, appenderator.getDataSource());
+ Assertions.assertEquals(StreamAppenderatorTester.DATASOURCE, appenderator.getDataSource());
// add
commitMetadata.put("x", "1");
- Assert.assertEquals(
+ Assertions.assertEquals(
1,
appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", 1), committerSupplier)
.getNumRowsInSegment()
);
commitMetadata.put("x", "2");
- Assert.assertEquals(
+ Assertions.assertEquals(
2,
appenderator.add(IDENTIFIERS.get(0), ir("2000", "bar", 2), committerSupplier)
.getNumRowsInSegment()
);
commitMetadata.put("x", "3");
- Assert.assertEquals(
+ Assertions.assertEquals(
1,
appenderator.add(IDENTIFIERS.get(1), ir("2000", "qux", 4), committerSupplier)
.getNumRowsInSegment()
);
// getSegments
- Assert.assertEquals(IDENTIFIERS.subList(0, 2), sorted(appenderator.getSegments()));
+ Assertions.assertEquals(IDENTIFIERS.subList(0, 2), sorted(appenderator.getSegments()));
// getRowCount
- Assert.assertEquals(2, appenderator.getRowCount(IDENTIFIERS.get(0)));
- Assert.assertEquals(1, appenderator.getRowCount(IDENTIFIERS.get(1)));
+ Assertions.assertEquals(2, appenderator.getRowCount(IDENTIFIERS.get(0)));
+ Assertions.assertEquals(1, appenderator.getRowCount(IDENTIFIERS.get(1)));
thrown = false;
try {
appenderator.getRowCount(IDENTIFIERS.get(2));
@@ -259,7 +256,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
catch (IllegalStateException e) {
thrown = true;
}
- Assert.assertTrue(thrown);
+ Assertions.assertTrue(thrown);
// push all
final ListenableFuture<SegmentsAndCommitMetadata> segmentsAndCommitMetadata = appenderator.push(
@@ -268,23 +265,16 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
false
);
- final ExecutionException e = Assert.assertThrows(
+ final ExecutionException e = Assertions.assertThrows(
ExecutionException.class,
segmentsAndCommitMetadata::get
);
- MatcherAssert.assertThat(
- e,
- ThrowableCauseMatcher.hasCause(ThrowableCauseMatcher.hasCause(CoreMatchers.instanceOf(IOException.class)))
- );
-
- MatcherAssert.assertThat(
- e,
- ThrowableCauseMatcher.hasCause(ThrowableCauseMatcher.hasCause(ThrowableMessageMatcher.hasMessage(
- CoreMatchers.startsWith("Push failure test"))))
- );
+ final Throwable nestedCause = e.getCause().getCause();
+ Assertions.assertTrue(nestedCause instanceof IOException);
+ Assertions.assertTrue(nestedCause.getMessage().startsWith("Push failure test"));
SegmentGenerationMetrics segmentGenerationMetrics = tester.getMetrics();
- Assert.assertEquals(1, segmentGenerationMetrics.failedHandoffs());
+ Assertions.assertEquals(1, segmentGenerationMetrics.failedHandoffs());
}
}
@@ -322,17 +312,17 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
appenderator.startJob();
appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", 1), committerSupplier);
int nullHandlingOverhead = 1;
- Assert.assertEquals(
+ Assertions.assertEquals(
190 + nullHandlingOverhead,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
appenderator.add(IDENTIFIERS.get(1), ir("2000", "bar", 1), committerSupplier);
- Assert.assertEquals(
+ Assertions.assertEquals(
190 + nullHandlingOverhead,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(1))
);
appenderator.close();
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
}
}
@@ -371,14 +361,14 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", 1), committerSupplier);
//expectedSizeInBytes = 44(map overhead) + 28 (TimeAndDims overhead) + 56 (aggregator metrics) + 54 (dimsKeySize) = 190
int nullHandlingOverhead = 1;
- Assert.assertEquals(190 + nullHandlingOverhead, ((StreamAppenderator) appenderator).getBytesCurrentlyInMemory());
+ Assertions.assertEquals(190 + nullHandlingOverhead, ((StreamAppenderator) appenderator).getBytesCurrentlyInMemory());
appenderator.add(IDENTIFIERS.get(1), ir("2000", "bar", 1), committerSupplier);
- Assert.assertEquals(
+ Assertions.assertEquals(
380 + 2 * nullHandlingOverhead,
((StreamAppenderator) appenderator).getBytesCurrentlyInMemory()
);
appenderator.close();
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
}
}
@@ -420,11 +410,11 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
int currentInMemoryIndexSize = 190 + nullHandlingOverhead;
int sinkSizeOverhead = 1 * StreamAppenderator.ROUGH_OVERHEAD_PER_SINK;
// currHydrant in the sink still has > 0 bytesInMemory since we do not persist yet
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize + sinkSizeOverhead,
((StreamAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -438,7 +428,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
currentInMemoryIndexSize = 0;
// We are now over maxSizeInBytes after the add. Hence, we do a persist.
// currHydrant in the sink has 0 bytesInMemory since we just did a persist
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
@@ -447,7 +437,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
int mappedIndexSize = 1012 + (2 * StreamAppenderator.ROUGH_OVERHEAD_PER_METRIC_COLUMN_HOLDER) +
StreamAppenderator.ROUGH_OVERHEAD_PER_DIMENSION_COLUMN_HOLDER +
StreamAppenderator.ROUGH_OVERHEAD_PER_TIME_COLUMN_HOLDER;
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize + sinkSizeOverhead + mappedIndexSize,
((StreamAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -456,11 +446,11 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
appenderator.add(IDENTIFIERS.get(0), ir("2000", "bob", 1), committerSupplier);
// currHydrant in the sink still has > 0 bytesInMemory since we do not persist yet
currentInMemoryIndexSize = 190 + nullHandlingOverhead;
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize + sinkSizeOverhead + mappedIndexSize,
((StreamAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -473,7 +463,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
currentInMemoryIndexSize = 0;
// We are now over maxSizeInBytes after the add. Hence, we do a persist.
// currHydrant in the sink has 0 bytesInMemory since we just did a persist
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
@@ -483,13 +473,13 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
mappedIndexSize = 2 * (1012 + (2 * StreamAppenderator.ROUGH_OVERHEAD_PER_METRIC_COLUMN_HOLDER) +
StreamAppenderator.ROUGH_OVERHEAD_PER_DIMENSION_COLUMN_HOLDER +
StreamAppenderator.ROUGH_OVERHEAD_PER_TIME_COLUMN_HOLDER);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize + sinkSizeOverhead + mappedIndexSize,
((StreamAppenderator) appenderator).getBytesCurrentlyInMemory()
);
appenderator.close();
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getBytesCurrentlyInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getBytesCurrentlyInMemory());
}
}
@@ -524,7 +514,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
};
appenderator.startJob();
- Assert.assertThrows(
+ Assertions.assertThrows(
RuntimeException.class,
() -> appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", 1), committerSupplier)
);
@@ -565,13 +555,13 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
appenderator.startJob();
appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", 1), committerSupplier);
// Expected 0 since we persisted after the add
- Assert.assertEquals(
+ Assertions.assertEquals(
0,
((StreamAppenderator) appenderator).getBytesCurrentlyInMemory()
);
appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", 1), committerSupplier);
// Expected 0 since we persisted after the add
- Assert.assertEquals(
+ Assertions.assertEquals(
0,
((StreamAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -615,7 +605,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
int nullHandlingOverhead = 1;
int currentInMemoryIndexSize = 190 + nullHandlingOverhead;
int sinkSizeOverhead = 1 * StreamAppenderator.ROUGH_OVERHEAD_PER_SINK;
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize + sinkSizeOverhead,
((StreamAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -623,8 +613,8 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
// Close with row still in memory (no persist)
appenderator.close();
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getBytesCurrentlyInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getBytesCurrentlyInMemory());
}
}
@@ -668,15 +658,15 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
int currentInMemoryIndexSize = 190 + nullHandlingOverhead;
int sinkSizeOverhead = 2 * StreamAppenderator.ROUGH_OVERHEAD_PER_SINK;
// currHydrant in the sink still has > 0 bytesInMemory since we do not persist yet
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(1))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
(2 * currentInMemoryIndexSize) + sinkSizeOverhead,
((StreamAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -691,11 +681,11 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
currentInMemoryIndexSize = 0;
// We are now over maxSizeInBytes after the add. Hence, we do a persist.
// currHydrant in the sink has 0 bytesInMemory since we just did a persist
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(1))
);
@@ -704,7 +694,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
int mappedIndexSize = 2 * (1012 + (2 * StreamAppenderator.ROUGH_OVERHEAD_PER_METRIC_COLUMN_HOLDER) +
StreamAppenderator.ROUGH_OVERHEAD_PER_DIMENSION_COLUMN_HOLDER +
StreamAppenderator.ROUGH_OVERHEAD_PER_TIME_COLUMN_HOLDER);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize + sinkSizeOverhead + mappedIndexSize,
((StreamAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -713,29 +703,29 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
appenderator.add(IDENTIFIERS.get(0), ir("2000", "bob", 1), committerSupplier);
// currHydrant in the sink still has > 0 bytesInMemory since we do not persist yet
currentInMemoryIndexSize = 190 + nullHandlingOverhead;
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
0,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(1))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize + sinkSizeOverhead + mappedIndexSize,
((StreamAppenderator) appenderator).getBytesCurrentlyInMemory()
);
// Now add a single row to sink 1
appenderator.add(IDENTIFIERS.get(1), ir("2000", "bob", 1), committerSupplier);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(1))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
(2 * currentInMemoryIndexSize) + sinkSizeOverhead + mappedIndexSize,
((StreamAppenderator) appenderator).getBytesCurrentlyInMemory()
);
@@ -752,11 +742,11 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
currentInMemoryIndexSize = 0;
// We are now over maxSizeInBytes after the add. Hence, we do a persist.
// currHydrant in the sink has 0 bytesInMemory since we just did a persist
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(1))
);
@@ -766,13 +756,13 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
mappedIndexSize = 2 * (2 * (1012 + (2 * StreamAppenderator.ROUGH_OVERHEAD_PER_METRIC_COLUMN_HOLDER) +
StreamAppenderator.ROUGH_OVERHEAD_PER_DIMENSION_COLUMN_HOLDER +
StreamAppenderator.ROUGH_OVERHEAD_PER_TIME_COLUMN_HOLDER));
- Assert.assertEquals(
+ Assertions.assertEquals(
currentInMemoryIndexSize + sinkSizeOverhead + mappedIndexSize,
((StreamAppenderator) appenderator).getBytesCurrentlyInMemory()
);
appenderator.close();
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getBytesCurrentlyInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getBytesCurrentlyInMemory());
}
}
@@ -806,26 +796,26 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
};
};
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.startJob();
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", 1), committerSupplier);
//we still calculate the size even when ignoring it to make persist decision
int nullHandlingOverhead = 1;
- Assert.assertEquals(
+ Assertions.assertEquals(
190 + nullHandlingOverhead,
((StreamAppenderator) appenderator).getBytesInMemory(IDENTIFIERS.get(0))
);
- Assert.assertEquals(1, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(1, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(1), ir("2000", "bar", 1), committerSupplier);
int sinkSizeOverhead = 2 * StreamAppenderator.ROUGH_OVERHEAD_PER_SINK;
- Assert.assertEquals(
+ Assertions.assertEquals(
(380 + 2 * nullHandlingOverhead) + sinkSizeOverhead,
((StreamAppenderator) appenderator).getBytesCurrentlyInMemory()
);
- Assert.assertEquals(2, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(2, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.close();
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
}
}
@@ -863,23 +853,23 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
}
};
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.startJob();
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", 1), committerSupplier);
- Assert.assertEquals(1, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(1, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(1), ir("2000", "bar", 1), committerSupplier);
- Assert.assertEquals(2, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(2, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(1), ir("2000", "bar", 1), committerSupplier);
- Assert.assertEquals(2, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(2, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(0), ir("2000", "baz", 1), committerSupplier);
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(1), ir("2000", "qux", 1), committerSupplier);
- Assert.assertEquals(1, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(1, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(0), ir("2000", "bob", 1), committerSupplier);
- Assert.assertEquals(2, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(2, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.persistAll(committerSupplier.get());
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.close();
}
}
@@ -913,23 +903,23 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
};
};
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.startJob();
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", 1), committerSupplier, false);
- Assert.assertEquals(1, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(1, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(1), ir("2000", "bar", 1), committerSupplier, false);
- Assert.assertEquals(2, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(2, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(1), ir("2000", "bar", 1), committerSupplier, false);
- Assert.assertEquals(2, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(2, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(0), ir("2000", "baz", 1), committerSupplier, false);
- Assert.assertEquals(3, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(3, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(1), ir("2000", "qux", 1), committerSupplier, false);
- Assert.assertEquals(4, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(4, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.add(IDENTIFIERS.get(0), ir("2000", "bob", 1), committerSupplier, false);
- Assert.assertEquals(5, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(5, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.persistAll(committerSupplier.get());
- Assert.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
+ Assertions.assertEquals(0, ((StreamAppenderator) appenderator).getRowsInMemory());
appenderator.close();
}
}
@@ -990,14 +980,15 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
.basePersistDirectory(tuningConfig.getBasePersistDirectory())
.build()) {
final Appenderator appenderator2 = tester2.getAppenderator();
- Assert.assertEquals(ImmutableMap.of("eventCount", 4), appenderator2.startJob());
- Assert.assertEquals(ImmutableList.of(IDENTIFIERS.get(0)), appenderator2.getSegments());
- Assert.assertEquals(4, appenderator2.getRowCount(IDENTIFIERS.get(0)));
+ Assertions.assertEquals(ImmutableMap.of("eventCount", 4), appenderator2.startJob());
+ Assertions.assertEquals(ImmutableList.of(IDENTIFIERS.get(0)), appenderator2.getSegments());
+ Assertions.assertEquals(4, appenderator2.getRowCount(IDENTIFIERS.get(0)));
}
}
}
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testTotalRowCount() throws Exception
{
try (
@@ -1009,37 +1000,37 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final ConcurrentMap<String, String> commitMetadata = new ConcurrentHashMap<>();
final Supplier<Committer> committerSupplier = committerSupplierFromConcurrentMap(commitMetadata);
- Assert.assertEquals(0, appenderator.getTotalRowCount());
+ Assertions.assertEquals(0, appenderator.getTotalRowCount());
appenderator.startJob();
- Assert.assertEquals(0, appenderator.getTotalRowCount());
+ Assertions.assertEquals(0, appenderator.getTotalRowCount());
appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", 1), committerSupplier);
- Assert.assertEquals(1, appenderator.getTotalRowCount());
+ Assertions.assertEquals(1, appenderator.getTotalRowCount());
appenderator.add(IDENTIFIERS.get(1), ir("2000", "bar", 1), committerSupplier);
- Assert.assertEquals(2, appenderator.getTotalRowCount());
+ Assertions.assertEquals(2, appenderator.getTotalRowCount());
appenderator.persistAll(committerSupplier.get()).get();
- Assert.assertEquals(2, appenderator.getTotalRowCount());
+ Assertions.assertEquals(2, appenderator.getTotalRowCount());
appenderator.drop(IDENTIFIERS.get(0)).get();
- Assert.assertEquals(1, appenderator.getTotalRowCount());
+ Assertions.assertEquals(1, appenderator.getTotalRowCount());
appenderator.drop(IDENTIFIERS.get(1)).get();
- Assert.assertEquals(0, appenderator.getTotalRowCount());
+ Assertions.assertEquals(0, appenderator.getTotalRowCount());
appenderator.add(IDENTIFIERS.get(2), ir("2001", "bar", 1), committerSupplier);
- Assert.assertEquals(1, appenderator.getTotalRowCount());
+ Assertions.assertEquals(1, appenderator.getTotalRowCount());
appenderator.add(IDENTIFIERS.get(2), ir("2001", "baz", 1), committerSupplier);
- Assert.assertEquals(2, appenderator.getTotalRowCount());
+ Assertions.assertEquals(2, appenderator.getTotalRowCount());
appenderator.add(IDENTIFIERS.get(2), ir("2001", "qux", 1), committerSupplier);
- Assert.assertEquals(3, appenderator.getTotalRowCount());
+ Assertions.assertEquals(3, appenderator.getTotalRowCount());
appenderator.add(IDENTIFIERS.get(2), ir("2001", "bob", 1), committerSupplier);
- Assert.assertEquals(4, appenderator.getTotalRowCount());
+ Assertions.assertEquals(4, appenderator.getTotalRowCount());
appenderator.persistAll(committerSupplier.get()).get();
- Assert.assertEquals(4, appenderator.getTotalRowCount());
+ Assertions.assertEquals(4, appenderator.getTotalRowCount());
appenderator.drop(IDENTIFIERS.get(2)).get();
- Assert.assertEquals(0, appenderator.getTotalRowCount());
+ Assertions.assertEquals(0, appenderator.getTotalRowCount());
appenderator.close();
- Assert.assertEquals(0, appenderator.getTotalRowCount());
+ Assertions.assertEquals(0, appenderator.getTotalRowCount());
}
}
@@ -1059,10 +1050,10 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", "invalid_met"), Committers.nilSupplier());
appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", 1), Committers.nilSupplier());
- Assert.assertEquals(1, rowIngestionMeters.getProcessed());
- Assert.assertEquals(1, rowIngestionMeters.getProcessedWithError());
- Assert.assertEquals(0, rowIngestionMeters.getUnparseable());
- Assert.assertEquals(0, rowIngestionMeters.getThrownAway());
+ Assertions.assertEquals(1, rowIngestionMeters.getProcessed());
+ Assertions.assertEquals(1, rowIngestionMeters.getProcessedWithError());
+ Assertions.assertEquals(0, rowIngestionMeters.getUnparseable());
+ Assertions.assertEquals(0, rowIngestionMeters.getThrownAway());
}
}
@@ -1132,15 +1123,15 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
// segment 0 won't be dropped immediately
final List<Result<TimeseriesResultValue>> results1 =
QueryPlus.wrap(query1).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query1",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2000"),
new TimeseriesResultValue(ImmutableMap.of("count", 3L, "met", 7L))
)
),
- results1
+ results1,
+ "query1"
);
// segment 0 would eventually be dropped at some time after 1 secs drop delay
@@ -1156,7 +1147,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
new TimeseriesResultValue(ImmutableMap.of("count", 1L, "met", 4L))
)
);
- Assert.assertEquals("query after dropped", expectedResults, results);
+ Assertions.assertEquals(expectedResults, results, "query after dropped");
}
}
@@ -1183,7 +1174,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
)
);
- Assert.assertEquals(StreamAppenderator.PendingSegmentUpgradeResult.ANNOUNCED, outcome);
+ Assertions.assertEquals(StreamAppenderator.PendingSegmentUpgradeResult.ANNOUNCED, outcome);
}
}
@@ -1210,7 +1201,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
)
);
- Assert.assertEquals(StreamAppenderator.PendingSegmentUpgradeResult.SKIPPED_UNKNOWN_BASE, outcome);
+ Assertions.assertEquals(StreamAppenderator.PendingSegmentUpgradeResult.SKIPPED_UNKNOWN_BASE, outcome);
}
}
@@ -1335,39 +1326,39 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> results1 =
QueryPlus.wrap(query1).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query1",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2001"),
new TimeseriesResultValue(ImmutableMap.of("count", 4L, "met", 120L))
)
),
- results1
+ results1,
+ "query1"
);
final List<Result<TimeseriesResultValue>> results1_B =
QueryPlus.wrap(query1_B).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query1_B",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2001"),
new TimeseriesResultValue(ImmutableMap.of("count", 4L, "met", 120L))
)
),
- results1_B
+ results1_B,
+ "query1_B"
);
final List<Result<TimeseriesResultValue>> results1_C =
QueryPlus.wrap(query1_C).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query1_C",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2001"),
new TimeseriesResultValue(ImmutableMap.of("count", 4L, "met", 120L))
)
),
- results1_C
+ results1_C,
+ "query1_C"
);
// Query2: segment #2, partial
@@ -1437,39 +1428,39 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> results2 =
QueryPlus.wrap(query2).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query2",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2001"),
new TimeseriesResultValue(ImmutableMap.of("count", 1L, "met", 8L))
)
),
- results2
+ results2,
+ "query2"
);
final List<Result<TimeseriesResultValue>> results2_B =
QueryPlus.wrap(query2_B).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query2_B",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2001"),
new TimeseriesResultValue(ImmutableMap.of("count", 1L, "met", 8L))
)
),
- results2_B
+ results2_B,
+ "query2_B"
);
final List<Result<TimeseriesResultValue>> results2_C =
QueryPlus.wrap(query2_C).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query2_C",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2001"),
new TimeseriesResultValue(ImmutableMap.of("count", 1L, "met", 8L))
)
),
- results2_C
+ results2_C,
+ "query2_C"
);
// Query3: segment #2, two disjoint intervals
@@ -1554,39 +1545,39 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> results3 =
QueryPlus.wrap(query3).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query3",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2001"),
new TimeseriesResultValue(ImmutableMap.of("count", 2L, "met", 72L))
)
),
- results3
+ results3,
+ "query3"
);
final List<Result<TimeseriesResultValue>> results3_B =
QueryPlus.wrap(query3_B).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query3_B",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2001"),
new TimeseriesResultValue(ImmutableMap.of("count", 2L, "met", 72L))
)
),
- results3_B
+ results3_B,
+ "query3_B"
);
final List<Result<TimeseriesResultValue>> results3_C =
QueryPlus.wrap(query3_C).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query3_C",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2001"),
new TimeseriesResultValue(ImmutableMap.of("count", 2L, "met", 72L))
)
),
- results3_C
+ results3_C,
+ "query3_C"
);
final ScanQuery query4 = Druids.newScanQueryBuilder()
@@ -1657,40 +1648,40 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
.build();
final List<ScanResultValue> results4 =
QueryPlus.wrap(query4).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(2, results4.size()); // 2 segments, 1 row per segment
- Assert.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4.get(0).getColumns().toArray());
- Assert.assertArrayEquals(
+ Assertions.assertEquals(2, results4.size()); // 2 segments, 1 row per segment
+ Assertions.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4.get(0).getColumns().toArray());
+ Assertions.assertArrayEquals(
new Object[]{DateTimes.of("2001").getMillis(), "foo", 1L, 8L},
((List<Object>) ((List<Object>) results4.get(0).getEvents()).get(0)).toArray()
);
- Assert.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4.get(0).getColumns().toArray());
- Assert.assertArrayEquals(
+ Assertions.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4.get(0).getColumns().toArray());
+ Assertions.assertArrayEquals(
new Object[]{DateTimes.of("2001T03").getMillis(), "foo", 1L, 64L},
((List<Object>) ((List<Object>) results4.get(1).getEvents()).get(0)).toArray()
);
final List<ScanResultValue> results4_B =
QueryPlus.wrap(query4_B).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(2, results4_B.size()); // 2 segments, 1 row per segment
- Assert.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4_B.get(0).getColumns().toArray());
- Assert.assertArrayEquals(
+ Assertions.assertEquals(2, results4_B.size()); // 2 segments, 1 row per segment
+ Assertions.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4_B.get(0).getColumns().toArray());
+ Assertions.assertArrayEquals(
new Object[]{DateTimes.of("2001").getMillis(), "foo", 1L, 8L},
((List<Object>) ((List<Object>) results4_B.get(0).getEvents()).get(0)).toArray()
);
- Assert.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4_B.get(0).getColumns().toArray());
- Assert.assertArrayEquals(
+ Assertions.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4_B.get(0).getColumns().toArray());
+ Assertions.assertArrayEquals(
new Object[]{DateTimes.of("2001T03").getMillis(), "foo", 1L, 64L},
((List<Object>) ((List<Object>) results4_B.get(1).getEvents()).get(0)).toArray()
);
final List<ScanResultValue> results4_C =
QueryPlus.wrap(query4_C).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(2, results4_C.size()); // 2 segments, 1 row per segment
- Assert.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4_C.get(0).getColumns().toArray());
- Assert.assertArrayEquals(
+ Assertions.assertEquals(2, results4_C.size()); // 2 segments, 1 row per segment
+ Assertions.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4_C.get(0).getColumns().toArray());
+ Assertions.assertArrayEquals(
new Object[]{DateTimes.of("2001").getMillis(), "foo", 1L, 8L},
((List<Object>) ((List<Object>) results4_C.get(0).getEvents()).get(0)).toArray()
);
- Assert.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4_C.get(0).getColumns().toArray());
- Assert.assertArrayEquals(
+ Assertions.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4_C.get(0).getColumns().toArray());
+ Assertions.assertArrayEquals(
new Object[]{DateTimes.of("2001T03").getMillis(), "foo", 1L, 64L},
((List<Object>) ((List<Object>) results4_C.get(1).getEvents()).get(0)).toArray()
);
@@ -1765,15 +1756,15 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> results1 =
QueryPlus.wrap(query1).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query1",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2000"),
new TimeseriesResultValue(ImmutableMap.of("count", 3L, "met", 7L))
)
),
- results1
+ results1,
+ "query1"
);
// Query2: 2000/2002
@@ -1791,8 +1782,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> results2 =
QueryPlus.wrap(query2).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query2",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2000"),
@@ -1803,7 +1793,8 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
new TimeseriesResultValue(ImmutableMap.of("count", 4L, "met", 120L))
)
),
- results2
+ results2,
+ "query2"
);
// Query3: 2000/2001T01
@@ -1821,7 +1812,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> results3 =
QueryPlus.wrap(query3).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2000"),
@@ -1855,7 +1846,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> results4 =
QueryPlus.wrap(query4).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2000"),
@@ -1876,8 +1867,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> resultsAfterDrop1 =
QueryPlus.wrap(query1).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query1",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2000"),
@@ -1889,8 +1879,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> resultsAfterDrop2 =
QueryPlus.wrap(query2).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query2",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2000"),
@@ -1901,12 +1890,13 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
new TimeseriesResultValue(ImmutableMap.of("count", 4L, "met", 120L))
)
),
- resultsAfterDrop2
+ resultsAfterDrop2,
+ "query2"
);
final List<Result<TimeseriesResultValue>> resultsAfterDrop3 =
QueryPlus.wrap(query3).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2000"),
@@ -1922,7 +1912,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> resultsAfterDrop4 =
QueryPlus.wrap(query4).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2000"),
@@ -1960,15 +1950,15 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
.aggregators(ImmutableList.of(new LongSumAggregatorFactory("count", "count")))
.granularity(Granularities.DAY)
.build();
- DruidException e = Assert.assertThrows(
+ DruidException e = Assertions.assertThrows(
DruidException.class,
() -> QueryPlus.wrap(query1)
.run(appenderator, ResponseContext.createEmpty())
.toList()
);
- Assert.assertEquals(DruidException.Category.FORBIDDEN, e.getCategory());
- Assert.assertEquals(DruidException.Persona.OPERATOR, e.getTargetPersona());
- Assert.assertEquals(
+ Assertions.assertEquals(DruidException.Category.FORBIDDEN, e.getCategory());
+ Assertions.assertEquals(DruidException.Persona.OPERATOR, e.getTargetPersona());
+ Assertions.assertEquals(
"Failed security validation with segment [foo_2000-01-01T00:00:00.000Z_2001-01-01T00:00:00.000Z_A]",
e.getMessage()
);
@@ -2021,15 +2011,15 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> results1 =
QueryPlus.wrap(query1).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query1",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2000"),
new TimeseriesResultValue(ImmutableMap.of("count", 3L, "met", 7L))
)
),
- results1
+ results1,
+ "query1"
);
verifySinkMetrics(
@@ -2059,7 +2049,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> results3 =
QueryPlus.wrap(query3).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2000"),
@@ -2106,7 +2096,7 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> results4 =
QueryPlus.wrap(query4).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2000"),
@@ -2178,15 +2168,15 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> results1 =
QueryPlus.wrap(query1).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query1",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2001"),
new TimeseriesResultValue(ImmutableMap.of("count", 4L, "met", 120L))
)
),
- results1
+ results1,
+ "query1"
);
verifySinkMetrics(
@@ -2225,15 +2215,15 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> results2 =
QueryPlus.wrap(query2).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query2",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2001"),
new TimeseriesResultValue(ImmutableMap.of("count", 1L, "met", 8L))
)
),
- results2
+ results2,
+ "query2"
);
verifySinkMetrics(
@@ -2277,15 +2267,15 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final List<Result<TimeseriesResultValue>> results3 =
QueryPlus.wrap(query3).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(
- "query3",
+ Assertions.assertEquals(
ImmutableList.of(
new Result<>(
DateTimes.of("2001"),
new TimeseriesResultValue(ImmutableMap.of("count", 2L, "met", 72L))
)
),
- results3
+ results3,
+ "query3"
);
verifySinkMetrics(
@@ -2323,14 +2313,14 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
.build();
final List<ScanResultValue> results4 =
QueryPlus.wrap(query4).run(appenderator, ResponseContext.createEmpty()).toList();
- Assert.assertEquals(2, results4.size()); // 2 segments, 1 row per segment
- Assert.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4.get(0).getColumns().toArray());
- Assert.assertArrayEquals(
+ Assertions.assertEquals(2, results4.size()); // 2 segments, 1 row per segment
+ Assertions.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4.get(0).getColumns().toArray());
+ Assertions.assertArrayEquals(
new Object[]{DateTimes.of("2001").getMillis(), "foo", 1L, 8L},
((List<Object>) ((List<Object>) results4.get(0).getEvents()).get(0)).toArray()
);
- Assert.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4.get(0).getColumns().toArray());
- Assert.assertArrayEquals(
+ Assertions.assertArrayEquals(new String[]{"__time", "dim", "count", "met"}, results4.get(0).getColumns().toArray());
+ Assertions.assertArrayEquals(
new Object[]{DateTimes.of("2001T03").getMillis(), "foo", 1L, 64L},
((List<Object>) ((List<Object>) results4.get(1).getEvents()).get(0)).toArray()
);
@@ -2426,13 +2416,13 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
final int segments = segmentIds.size();
emitter.verifyEmitted(DefaultQueryMetrics.QUERY_CPU_TIME, 1);
emitter.verifyEmitted(DefaultQueryMetrics.QUERY_SEGMENTS_COUNT, 1);
- Assert.assertEquals(segments, emitter.getMetricEvents(DefaultQueryMetrics.QUERY_SEGMENT_TIME).size());
- Assert.assertEquals(segments, emitter.getMetricEvents(DefaultQueryMetrics.QUERY_SEGMENT_AND_CACHE_TIME).size());
- Assert.assertEquals(segments, emitter.getMetricEvents(DefaultQueryMetrics.QUERY_WAIT_TIME).size());
+ Assertions.assertEquals(segments, emitter.getMetricEvents(DefaultQueryMetrics.QUERY_SEGMENT_TIME).size());
+ Assertions.assertEquals(segments, emitter.getMetricEvents(DefaultQueryMetrics.QUERY_SEGMENT_AND_CACHE_TIME).size());
+ Assertions.assertEquals(segments, emitter.getMetricEvents(DefaultQueryMetrics.QUERY_WAIT_TIME).size());
for (String id : segmentIds) {
- Assert.assertTrue(emitter.getMetricEvents(DefaultQueryMetrics.QUERY_SEGMENT_TIME).stream().anyMatch(value -> value.getUserDims().containsValue(id)));
- Assert.assertTrue(emitter.getMetricEvents(DefaultQueryMetrics.QUERY_SEGMENT_AND_CACHE_TIME).stream().anyMatch(value -> value.getUserDims().containsValue(id)));
- Assert.assertTrue(emitter.getMetricEvents(DefaultQueryMetrics.QUERY_WAIT_TIME).stream().anyMatch(value -> value.getUserDims().containsValue(id)));
+ Assertions.assertTrue(emitter.getMetricEvents(DefaultQueryMetrics.QUERY_SEGMENT_TIME).stream().anyMatch(value -> value.getUserDims().containsValue(id)));
+ Assertions.assertTrue(emitter.getMetricEvents(DefaultQueryMetrics.QUERY_SEGMENT_AND_CACHE_TIME).stream().anyMatch(value -> value.getUserDims().containsValue(id)));
+ Assertions.assertTrue(emitter.getMetricEvents(DefaultQueryMetrics.QUERY_WAIT_TIME).stream().anyMatch(value -> value.getUserDims().containsValue(id)));
}
}
@@ -2452,10 +2442,10 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
StreamAppenderator.SinkSchemaAnnouncer sinkSchemaAnnouncer = appenderator.getSinkSchemaAnnouncer();
// startJob
- Assert.assertEquals(null, appenderator.startJob());
+ Assertions.assertEquals(null, appenderator.startJob());
// getDataSource
- Assert.assertEquals(StreamAppenderatorTester.DATASOURCE, appenderator.getDataSource());
+ Assertions.assertEquals(StreamAppenderatorTester.DATASOURCE, appenderator.getDataSource());
// add first row
commitMetadata.put("x", "1");
@@ -2468,35 +2458,35 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
List<Pair<String, SegmentSchemas>> announcedAbsoluteSchema = dataSegmentAnnouncer.getAnnouncedAbsoluteSchema();
List<Pair<String, SegmentSchemas>> announcedDeltaSchema = dataSegmentAnnouncer.getAnnouncedDeltaSchema();
- Assert.assertEquals(1, announcedAbsoluteSchema.size());
- Assert.assertEquals(1, announcedDeltaSchema.size());
+ Assertions.assertEquals(1, announcedAbsoluteSchema.size());
+ Assertions.assertEquals(1, announcedDeltaSchema.size());
// verify absolute schema
- Assert.assertEquals(appenderator.getId(), announcedAbsoluteSchema.get(0).lhs);
+ Assertions.assertEquals(appenderator.getId(), announcedAbsoluteSchema.get(0).lhs);
List<SegmentSchemas.SegmentSchema> segmentSchemas = announcedAbsoluteSchema.get(0).rhs.getSegmentSchemaList();
- Assert.assertEquals(1, segmentSchemas.size());
+ Assertions.assertEquals(1, segmentSchemas.size());
SegmentSchemas.SegmentSchema absoluteSchemaId1Row1 = segmentSchemas.get(0);
- Assert.assertEquals(IDENTIFIERS.get(0).asSegmentId().toString(), absoluteSchemaId1Row1.getSegmentId());
- Assert.assertEquals(1, absoluteSchemaId1Row1.getNumRows().intValue());
- Assert.assertFalse(absoluteSchemaId1Row1.isDelta());
- Assert.assertEquals(Collections.emptyList(), absoluteSchemaId1Row1.getUpdatedColumns());
- Assert.assertEquals(Lists.newArrayList("__time", "dim", "count", "met"), absoluteSchemaId1Row1.getNewColumns());
- Assert.assertEquals(
+ Assertions.assertEquals(IDENTIFIERS.get(0).asSegmentId().toString(), absoluteSchemaId1Row1.getSegmentId());
+ Assertions.assertEquals(1, absoluteSchemaId1Row1.getNumRows().intValue());
+ Assertions.assertFalse(absoluteSchemaId1Row1.isDelta());
+ Assertions.assertEquals(Collections.emptyList(), absoluteSchemaId1Row1.getUpdatedColumns());
+ Assertions.assertEquals(Lists.newArrayList("__time", "dim", "count", "met"), absoluteSchemaId1Row1.getNewColumns());
+ Assertions.assertEquals(
ImmutableMap.of("__time", ColumnType.LONG, "count", ColumnType.LONG, "dim", ColumnType.STRING, "met", ColumnType.LONG),
absoluteSchemaId1Row1.getColumnTypeMap());
// verify delta schema
- Assert.assertEquals(appenderator.getId(), announcedDeltaSchema.get(0).lhs);
+ Assertions.assertEquals(appenderator.getId(), announcedDeltaSchema.get(0).lhs);
segmentSchemas = announcedDeltaSchema.get(0).rhs.getSegmentSchemaList();
SegmentSchemas.SegmentSchema deltaSchemaId1Row1 = segmentSchemas.get(0);
- Assert.assertEquals(1, segmentSchemas.size());
- Assert.assertEquals(IDENTIFIERS.get(0).asSegmentId().toString(), deltaSchemaId1Row1.getSegmentId());
- Assert.assertEquals(1, deltaSchemaId1Row1.getNumRows().intValue());
+ Assertions.assertEquals(1, segmentSchemas.size());
+ Assertions.assertEquals(IDENTIFIERS.get(0).asSegmentId().toString(), deltaSchemaId1Row1.getSegmentId());
+ Assertions.assertEquals(1, deltaSchemaId1Row1.getNumRows().intValue());
// absolute schema is sent for a new sink
- Assert.assertFalse(deltaSchemaId1Row1.isDelta());
- Assert.assertEquals(Collections.emptyList(), deltaSchemaId1Row1.getUpdatedColumns());
- Assert.assertEquals(Lists.newArrayList("__time", "dim", "count", "met"), deltaSchemaId1Row1.getNewColumns());
- Assert.assertEquals(
+ Assertions.assertFalse(deltaSchemaId1Row1.isDelta());
+ Assertions.assertEquals(Collections.emptyList(), deltaSchemaId1Row1.getUpdatedColumns());
+ Assertions.assertEquals(Lists.newArrayList("__time", "dim", "count", "met"), deltaSchemaId1Row1.getNewColumns());
+ Assertions.assertEquals(
ImmutableMap.of("__time", ColumnType.LONG, "count", ColumnType.LONG, "dim", ColumnType.STRING, "met", ColumnType.LONG),
deltaSchemaId1Row1.getColumnTypeMap());
@@ -2513,34 +2503,34 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
announcedAbsoluteSchema = dataSegmentAnnouncer.getAnnouncedAbsoluteSchema();
announcedDeltaSchema = dataSegmentAnnouncer.getAnnouncedDeltaSchema();
- Assert.assertEquals(1, announcedAbsoluteSchema.size());
- Assert.assertEquals(1, announcedDeltaSchema.size());
+ Assertions.assertEquals(1, announcedAbsoluteSchema.size());
+ Assertions.assertEquals(1, announcedDeltaSchema.size());
// verify absolute schema
- Assert.assertEquals(appenderator.getId(), announcedAbsoluteSchema.get(0).lhs);
+ Assertions.assertEquals(appenderator.getId(), announcedAbsoluteSchema.get(0).lhs);
segmentSchemas = announcedAbsoluteSchema.get(0).rhs.getSegmentSchemaList();
- Assert.assertEquals(1, segmentSchemas.size());
+ Assertions.assertEquals(1, segmentSchemas.size());
SegmentSchemas.SegmentSchema absoluteSchemaId1Row2 = segmentSchemas.get(0);
- Assert.assertEquals(IDENTIFIERS.get(0).asSegmentId().toString(), absoluteSchemaId1Row2.getSegmentId());
- Assert.assertEquals(2, absoluteSchemaId1Row2.getNumRows().intValue());
- Assert.assertFalse(absoluteSchemaId1Row2.isDelta());
- Assert.assertEquals(Collections.emptyList(), absoluteSchemaId1Row2.getUpdatedColumns());
- Assert.assertEquals(Lists.newArrayList("__time", "dim", "count", "met"), absoluteSchemaId1Row2.getNewColumns());
- Assert.assertEquals(
+ Assertions.assertEquals(IDENTIFIERS.get(0).asSegmentId().toString(), absoluteSchemaId1Row2.getSegmentId());
+ Assertions.assertEquals(2, absoluteSchemaId1Row2.getNumRows().intValue());
+ Assertions.assertFalse(absoluteSchemaId1Row2.isDelta());
+ Assertions.assertEquals(Collections.emptyList(), absoluteSchemaId1Row2.getUpdatedColumns());
+ Assertions.assertEquals(Lists.newArrayList("__time", "dim", "count", "met"), absoluteSchemaId1Row2.getNewColumns());
+ Assertions.assertEquals(
ImmutableMap.of("__time", ColumnType.LONG, "count", ColumnType.LONG, "dim", ColumnType.STRING, "met", ColumnType.LONG),
absoluteSchemaId1Row2.getColumnTypeMap());
// verify delta
- Assert.assertEquals(appenderator.getId(), announcedDeltaSchema.get(0).lhs);
+ Assertions.assertEquals(appenderator.getId(), announcedDeltaSchema.get(0).lhs);
segmentSchemas = announcedDeltaSchema.get(0).rhs.getSegmentSchemaList();
SegmentSchemas.SegmentSchema deltaSchemaId1Row2 = segmentSchemas.get(0);
- Assert.assertEquals(1, segmentSchemas.size());
- Assert.assertEquals(IDENTIFIERS.get(0).asSegmentId().toString(), deltaSchemaId1Row2.getSegmentId());
- Assert.assertEquals(2, deltaSchemaId1Row2.getNumRows().intValue());
- Assert.assertTrue(deltaSchemaId1Row2.isDelta());
- Assert.assertEquals(Collections.emptyList(), deltaSchemaId1Row2.getUpdatedColumns());
- Assert.assertEquals(Collections.emptyList(), deltaSchemaId1Row2.getNewColumns());
- Assert.assertEquals(Collections.emptyMap(), deltaSchemaId1Row2.getColumnTypeMap());
+ Assertions.assertEquals(1, segmentSchemas.size());
+ Assertions.assertEquals(IDENTIFIERS.get(0).asSegmentId().toString(), deltaSchemaId1Row2.getSegmentId());
+ Assertions.assertEquals(2, deltaSchemaId1Row2.getNumRows().intValue());
+ Assertions.assertTrue(deltaSchemaId1Row2.isDelta());
+ Assertions.assertEquals(Collections.emptyList(), deltaSchemaId1Row2.getUpdatedColumns());
+ Assertions.assertEquals(Collections.emptyList(), deltaSchemaId1Row2.getNewColumns());
+ Assertions.assertEquals(Collections.emptyMap(), deltaSchemaId1Row2.getColumnTypeMap());
dataSegmentAnnouncer.clear();
@@ -2554,42 +2544,42 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
announcedAbsoluteSchema = dataSegmentAnnouncer.getAnnouncedAbsoluteSchema();
announcedDeltaSchema = dataSegmentAnnouncer.getAnnouncedDeltaSchema();
- Assert.assertEquals(1, announcedAbsoluteSchema.size());
- Assert.assertEquals(1, announcedDeltaSchema.size());
+ Assertions.assertEquals(1, announcedAbsoluteSchema.size());
+ Assertions.assertEquals(1, announcedDeltaSchema.size());
// verify absolute schema
- Assert.assertEquals(appenderator.getId(), announcedAbsoluteSchema.get(0).lhs);
+ Assertions.assertEquals(appenderator.getId(), announcedAbsoluteSchema.get(0).lhs);
segmentSchemas = announcedAbsoluteSchema.get(0).rhs.getSegmentSchemaList();
- Assert.assertEquals(2, segmentSchemas.size());
+ Assertions.assertEquals(2, segmentSchemas.size());
SegmentSchemas.SegmentSchema absoluteSchemaId2Row1 =
segmentSchemas.stream()
.filter(v -> v.getSegmentId().equals(IDENTIFIERS.get(1).asSegmentId().toString()))
.findFirst()
.get();
- Assert.assertEquals(IDENTIFIERS.get(1).asSegmentId().toString(), absoluteSchemaId2Row1.getSegmentId());
- Assert.assertEquals(1, absoluteSchemaId2Row1.getNumRows().intValue());
- Assert.assertFalse(absoluteSchemaId2Row1.isDelta());
- Assert.assertEquals(Collections.emptyList(), absoluteSchemaId2Row1.getUpdatedColumns());
- Assert.assertEquals(Lists.newArrayList("__time", "dim", "count", "met"), absoluteSchemaId2Row1.getNewColumns());
- Assert.assertEquals(
+ Assertions.assertEquals(IDENTIFIERS.get(1).asSegmentId().toString(), absoluteSchemaId2Row1.getSegmentId());
+ Assertions.assertEquals(1, absoluteSchemaId2Row1.getNumRows().intValue());
+ Assertions.assertFalse(absoluteSchemaId2Row1.isDelta());
+ Assertions.assertEquals(Collections.emptyList(), absoluteSchemaId2Row1.getUpdatedColumns());
+ Assertions.assertEquals(Lists.newArrayList("__time", "dim", "count", "met"), absoluteSchemaId2Row1.getNewColumns());
+ Assertions.assertEquals(
ImmutableMap.of("__time", ColumnType.LONG, "count", ColumnType.LONG, "dim", ColumnType.STRING, "met", ColumnType.LONG),
absoluteSchemaId2Row1.getColumnTypeMap());
// verify delta
- Assert.assertEquals(appenderator.getId(), announcedDeltaSchema.get(0).lhs);
+ Assertions.assertEquals(appenderator.getId(), announcedDeltaSchema.get(0).lhs);
segmentSchemas = announcedDeltaSchema.get(0).rhs.getSegmentSchemaList();
SegmentSchemas.SegmentSchema deltaSchemaId2Row1 =
segmentSchemas.stream()
.filter(v -> v.getSegmentId().equals(IDENTIFIERS.get(1).asSegmentId().toString()))
.findFirst()
.get();
- Assert.assertEquals(1, segmentSchemas.size());
- Assert.assertEquals(IDENTIFIERS.get(1).asSegmentId().toString(), deltaSchemaId2Row1.getSegmentId());
- Assert.assertEquals(1, deltaSchemaId2Row1.getNumRows().intValue());
- Assert.assertFalse(deltaSchemaId2Row1.isDelta());
- Assert.assertEquals(Collections.emptyList(), deltaSchemaId2Row1.getUpdatedColumns());
- Assert.assertEquals(Lists.newArrayList("__time", "dim", "count", "met"), deltaSchemaId2Row1.getNewColumns());
- Assert.assertEquals(
+ Assertions.assertEquals(1, segmentSchemas.size());
+ Assertions.assertEquals(IDENTIFIERS.get(1).asSegmentId().toString(), deltaSchemaId2Row1.getSegmentId());
+ Assertions.assertEquals(1, deltaSchemaId2Row1.getNumRows().intValue());
+ Assertions.assertFalse(deltaSchemaId2Row1.isDelta());
+ Assertions.assertEquals(Collections.emptyList(), deltaSchemaId2Row1.getUpdatedColumns());
+ Assertions.assertEquals(Lists.newArrayList("__time", "dim", "count", "met"), deltaSchemaId2Row1.getNewColumns());
+ Assertions.assertEquals(
ImmutableMap.of("__time", ColumnType.LONG, "count", ColumnType.LONG, "dim", ColumnType.STRING, "met", ColumnType.LONG),
deltaSchemaId2Row1.getColumnTypeMap());
}
@@ -2630,17 +2620,17 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
appenderator.add(segmentId1, row1, Suppliers.ofInstance(Committers.nil()), false);
appenderator.add(segmentId2, row2, Suppliers.ofInstance(Committers.nil()), false);
- Assert.assertEquals(2, appenderator.getSegments().size());
+ Assertions.assertEquals(2, appenderator.getSegments().size());
appenderator.drop(segmentId1).get();
synchronized (unlockedIntervals) {
- Assert.assertEquals(1, unlockedIntervals.size());
- Assert.assertEquals(segmentId1.getInterval(), unlockedIntervals.get(0));
+ Assertions.assertEquals(1, unlockedIntervals.size());
+ Assertions.assertEquals(segmentId1.getInterval(), unlockedIntervals.get(0));
}
- Assert.assertEquals(1, appenderator.getSegments().size());
- Assert.assertTrue(appenderator.getSegments().contains(segmentId2));
+ Assertions.assertEquals(1, appenderator.getSegments().size());
+ Assertions.assertTrue(appenderator.getSegments().contains(segmentId2));
}
}
@@ -2678,16 +2668,16 @@ public class StreamAppenderatorTest extends InitializedNullHandlingTest
appenderator.add(segmentId1, row1, Suppliers.ofInstance(Committers.nil()), false);
appenderator.add(segmentId2, row2, Suppliers.ofInstance(Committers.nil()), false);
- Assert.assertEquals(2, appenderator.getSegments().size());
+ Assertions.assertEquals(2, appenderator.getSegments().size());
appenderator.drop(segmentId1).get();
synchronized (unlockedIntervals) {
- Assert.assertEquals(0, unlockedIntervals.size());
+ Assertions.assertEquals(0, unlockedIntervals.size());
}
- Assert.assertEquals(1, appenderator.getSegments().size());
- Assert.assertTrue(appenderator.getSegments().contains(segmentId2));
+ Assertions.assertEquals(1, appenderator.getSegments().size());
+ Assertions.assertTrue(appenderator.getSegments().contains(segmentId2));
}
}
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/TransactionalSegmentPublisherTest.java b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/TransactionalSegmentPublisherTest.java
index c4eec7106a7..d0ea6bd0e30 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/TransactionalSegmentPublisherTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/TransactionalSegmentPublisherTest.java
@@ -22,18 +22,21 @@ package org.apache.druid.segment.realtime.appenderator;
import org.apache.druid.indexing.overlord.SegmentPublishResult;
import org.apache.druid.segment.SegmentSchemaMapping;
import org.apache.druid.timeline.DataSegment;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
public class TransactionalSegmentPublisherTest
{
- @Test(timeout = 60_000L)
+ @Test
+ @Timeout(value = 60_000L, unit = TimeUnit.MILLISECONDS)
public void testPublishSegments_retriesUpto5Times_ifFailureIsRetryable() throws IOException
{
final AtomicInteger attemptCount = new AtomicInteger(0);
@@ -42,11 +45,11 @@ public class TransactionalSegmentPublisherTest
attemptCount
);
- Assert.assertEquals(
+ Assertions.assertEquals(
SegmentPublishResult.retryableFailure("this error is retryable"),
publisher.publishSegments(null, Set.of(), Function.identity(), null, null)
);
- Assert.assertEquals(14, attemptCount.get());
+ Assertions.assertEquals(14, attemptCount.get());
}
@Test
@@ -58,11 +61,11 @@ public class TransactionalSegmentPublisherTest
attemptCount
);
- Assert.assertEquals(
+ Assertions.assertEquals(
SegmentPublishResult.fail("this error is not retryable"),
publisher.publishSegments(null, Set.of(), Function.identity(), null, null)
);
- Assert.assertEquals(1, attemptCount.get());
+ Assertions.assertEquals(1, attemptCount.get());
}
@Test
@@ -74,11 +77,11 @@ public class TransactionalSegmentPublisherTest
attemptCount
);
- Assert.assertEquals(
+ Assertions.assertEquals(
SegmentPublishResult.retryableFailure("this error is retryable"),
publisher.publishAnnotatedSegments(null, Set.of(), null, null)
);
- Assert.assertEquals(1, attemptCount.get());
+ Assertions.assertEquals(1, attemptCount.get());
}
private TransactionalSegmentPublisher createPublisher(
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/UnifiedIndexerAppenderatorsManagerTest.java b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/UnifiedIndexerAppenderatorsManagerTest.java
index 841507c6e50..2af7b4205c8 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/appenderator/UnifiedIndexerAppenderatorsManagerTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/appenderator/UnifiedIndexerAppenderatorsManagerTest.java
@@ -57,11 +57,9 @@ import org.apache.druid.testing.InitializedNullHandlingTest;
import org.apache.logging.log4j.ThreadContext;
import org.easymock.EasyMock;
import org.joda.time.Interval;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import javax.annotation.Nullable;
import java.io.File;
@@ -72,9 +70,6 @@ import java.util.Map;
public class UnifiedIndexerAppenderatorsManagerTest extends InitializedNullHandlingTest
{
- @Rule
- public final ExpectedException expectedException = ExpectedException.none();
-
private final WorkerConfig workerConfig = new WorkerConfig();
private final UnifiedIndexerAppenderatorsManager manager = new UnifiedIndexerAppenderatorsManager(
DirectQueryProcessingPool.INSTANCE,
@@ -91,7 +86,7 @@ public class UnifiedIndexerAppenderatorsManagerTest extends InitializedNullHandl
private AppenderatorConfig appenderatorConfig;
private Appenderator appenderator;
- @Before
+ @BeforeEach
public void setup()
{
appenderatorConfig = EasyMock.createMock(AppenderatorConfig.class);
@@ -133,7 +128,7 @@ public class UnifiedIndexerAppenderatorsManagerTest extends InitializedNullHandl
.build()
);
- Assert.assertEquals("myDataSource", bundle.getWalker().getDataSource());
+ Assertions.assertEquals("myDataSource", bundle.getWalker().getDataSource());
}
@Test
@@ -144,18 +139,19 @@ public class UnifiedIndexerAppenderatorsManagerTest extends InitializedNullHandl
.intervals(new MultipleIntervalSegmentSpec(Intervals.ONLY_ETERNITY))
.build();
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("Could not find segment walker for datasource");
-
- manager.getBundle(query);
+ final IllegalArgumentException exception = Assertions.assertThrows(
+ IllegalArgumentException.class,
+ () -> manager.getBundle(query)
+ );
+ Assertions.assertTrue(exception.getMessage().contains("Could not find segment walker for datasource"));
}
@Test
public void test_removeAppenderatorsForTask()
{
- Assert.assertEquals(ImmutableSet.of("myDataSource"), manager.getDatasourceBundles().keySet());
+ Assertions.assertEquals(ImmutableSet.of("myDataSource"), manager.getDatasourceBundles().keySet());
manager.removeAppenderatorsForTask("taskId", "myDataSource");
- Assert.assertTrue(manager.getDatasourceBundles().isEmpty());
+ Assertions.assertTrue(manager.getDatasourceBundles().isEmpty());
}
@Test
@@ -166,7 +162,7 @@ public class UnifiedIndexerAppenderatorsManagerTest extends InitializedNullHandl
manager.removeAppenderatorsForTask("someOtherTaskId", "myDataSource");
// Should be no change.
- Assert.assertEquals(ImmutableSet.of("myDataSource"), manager.getDatasourceBundles().keySet());
+ Assertions.assertEquals(ImmutableSet.of("myDataSource"), manager.getDatasourceBundles().keySet());
}
@Test
@@ -182,14 +178,14 @@ public class UnifiedIndexerAppenderatorsManagerTest extends InitializedNullHandl
// Three forms of persist.
- Assert.assertEquals(file, limitedPoolIndexMerger.persist(null, null, file, null, null, null));
- Assert.assertEquals(file, limitedPoolIndexMerger.persist(null, null, file, null, null));
+ Assertions.assertEquals(file, limitedPoolIndexMerger.persist(null, null, file, null, null, null));
+ Assertions.assertEquals(file, limitedPoolIndexMerger.persist(null, null, file, null, null));
// Need a mocked index for this test, since getInterval is called on it.
final IncrementalIndex index = EasyMock.createMock(IncrementalIndex.class);
EasyMock.expect(index.getInterval()).andReturn(null);
EasyMock.replay(index);
- Assert.assertEquals(file, limitedPoolIndexMerger.persist(index, file, null, null));
+ Assertions.assertEquals(file, limitedPoolIndexMerger.persist(index, file, null, null));
EasyMock.verify(index);
}
@@ -204,10 +200,10 @@ public class UnifiedIndexerAppenderatorsManagerTest extends InitializedNullHandl
final File file = new File("xyz");
- Assert.assertThrows(
- "failed",
+ Assertions.assertThrows(
RuntimeException.class, // Wrapped IOException
- () -> limitedPoolIndexMerger.persist(null, null, file, null, null, null)
+ () -> limitedPoolIndexMerger.persist(null, null, file, null, null, null),
+ "failed"
);
}
@@ -222,8 +218,7 @@ public class UnifiedIndexerAppenderatorsManagerTest extends InitializedNullHandl
final File file = new File("xyz");
- Assert.assertThrows(
- "failed",
+ Assertions.assertThrows(
RuntimeException.class, // Wrapped IOException
() -> limitedPoolIndexMerger.mergeQueryableIndex(
null,
@@ -236,7 +231,8 @@ public class UnifiedIndexerAppenderatorsManagerTest extends InitializedNullHandl
null,
null,
-1
- )
+ ),
+ "failed"
);
}
@@ -252,8 +248,8 @@ public class UnifiedIndexerAppenderatorsManagerTest extends InitializedNullHandl
final File file = new File("xyz");
// Two forms of mergeQueryableIndex
- Assert.assertEquals(file, limitedPoolIndexMerger.mergeQueryableIndex(null, false, null, file, null, null, -1));
- Assert.assertEquals(
+ Assertions.assertEquals(file, limitedPoolIndexMerger.mergeQueryableIndex(null, false, null, file, null, null, -1));
+ Assertions.assertEquals(
file,
limitedPoolIndexMerger.mergeQueryableIndex(
null,
@@ -282,14 +278,16 @@ public class UnifiedIndexerAppenderatorsManagerTest extends InitializedNullHandl
final File file = new File("xyz");
// "merge" is neither necessary nor implemented
- expectedException.expect(UnsupportedOperationException.class);
- Assert.assertEquals(file, limitedPoolIndexMerger.merge(null, false, null, file, null, null, -1));
+ Assertions.assertThrows(
+ UnsupportedOperationException.class,
+ () -> limitedPoolIndexMerger.merge(null, false, null, file, null, null, -1)
+ );
}
@Test
public void test_getWorkerConfig()
{
- Assert.assertSame(workerConfig, manager.getWorkerConfig());
+ Assertions.assertSame(workerConfig, manager.getWorkerConfig());
}
@Test
@@ -297,7 +295,7 @@ public class UnifiedIndexerAppenderatorsManagerTest extends InitializedNullHandl
{
appenderator.setTaskThreadContext();
final Map<String, String> threadContext = ThreadContext.getContext();
- Assert.assertEquals(
+ Assertions.assertEquals(
Map.of("task.log.id", "taskId", "task.log.file", "/mnt/var/taskId"),
threadContext
);
diff --git a/server/src/test/java/org/apache/druid/segment/realtime/sink/SinkTest.java b/server/src/test/java/org/apache/druid/segment/realtime/sink/SinkTest.java
index 4e12583b374..0646b27945f 100644
--- a/server/src/test/java/org/apache/druid/segment/realtime/sink/SinkTest.java
+++ b/server/src/test/java/org/apache/druid/segment/realtime/sink/SinkTest.java
@@ -55,8 +55,8 @@ import org.apache.druid.timeline.partition.ShardSpec;
import org.apache.druid.utils.CloseableUtils;
import org.easymock.EasyMock;
import org.joda.time.Interval;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.Arrays;
@@ -99,18 +99,18 @@ public class SinkTest extends InitializedNullHandlingTest
sink.add(new MapBasedInputRow(DateTimes.of("2013-01-01"), ImmutableList.of(), ImmutableMap.of()));
FireHydrant currHydrant = sink.getCurrHydrant();
- Assert.assertEquals(Intervals.of("2013-01-01/PT1M"), currHydrant.getIndex().getInterval());
+ Assertions.assertEquals(Intervals.of("2013-01-01/PT1M"), currHydrant.getIndex().getInterval());
FireHydrant swapHydrant = sink.swap();
sink.add(new MapBasedInputRow(DateTimes.of("2013-01-01"), ImmutableList.of(), ImmutableMap.of()));
- Assert.assertEquals(currHydrant, swapHydrant);
- Assert.assertNotSame(currHydrant, sink.getCurrHydrant());
- Assert.assertEquals(Intervals.of("2013-01-01/PT1M"), sink.getCurrHydrant().getIndex().getInterval());
+ Assertions.assertEquals(currHydrant, swapHydrant);
+ Assertions.assertNotSame(currHydrant, sink.getCurrHydrant());
+ Assertions.assertEquals(Intervals.of("2013-01-01/PT1M"), sink.getCurrHydrant().getIndex().getInterval());
- Assert.assertEquals(2, Iterators.size(sink.iterator()));
+ Assertions.assertEquals(2, Iterators.size(sink.iterator()));
}
@Test
@@ -133,7 +133,7 @@ public class SinkTest extends InitializedNullHandlingTest
.withSegmentGranularity(new SegmentGranularitySpec(Granularities.HOUR, null))
.withBaseTable(clusterSpec)
.build();
- Assert.assertNotNull(schema.getClusterSpec());
+ Assertions.assertNotNull(schema.getClusterSpec());
final long t0 = DateTimes.of("2013-01-01T00:00:00").getMillis();
final Sink sink = new Sink(
@@ -151,12 +151,12 @@ public class SinkTest extends InitializedNullHandlingTest
sink.add(clusterRow(t0 + 2, "globex", "eu-west-1"));
final IncrementalIndex index = sink.getCurrHydrant().getIndex();
- Assert.assertTrue(index instanceof OnheapIncrementalIndex);
+ Assertions.assertTrue(index instanceof OnheapIncrementalIndex);
final OnHeapClusteredBaseTable clusteredBaseTable = ((OnheapIncrementalIndex) index).getClusteredBaseTable();
- Assert.assertNotNull("expected clustered IncrementalIndex from clustered DataSchema", clusteredBaseTable);
- Assert.assertEquals(3, clusteredBaseTable.numRows());
- Assert.assertEquals(2, clusteredBaseTable.getGroups().size());
- Assert.assertEquals(List.of("acme", "globex"), clusteredBaseTable.getStringDictionary());
+ Assertions.assertNotNull(clusteredBaseTable, "expected clustered IncrementalIndex from clustered DataSchema");
+ Assertions.assertEquals(3, clusteredBaseTable.numRows());
+ Assertions.assertEquals(2, clusteredBaseTable.getGroups().size());
+ Assertions.assertEquals(List.of("acme", "globex"), clusteredBaseTable.getStringDictionary());
}
@Test
@@ -171,7 +171,7 @@ public class SinkTest extends InitializedNullHandlingTest
.withAggregators(new CountAggregatorFactory("count"))
.withGranularity(new UniformGranularitySpec(Granularities.HOUR, Granularities.NONE, null))
.build();
- Assert.assertNull(schema.getClusterSpec());
+ Assertions.assertNull(schema.getClusterSpec());
final Sink sink = new Sink(
Intervals.of("2013-01-01/2013-01-02"),
@@ -185,8 +185,8 @@ public class SinkTest extends InitializedNullHandlingTest
sink.add(clusterRow(DateTimes.of("2013-01-01").getMillis(), "acme", "us-east-1"));
final IncrementalIndex index = sink.getCurrHydrant().getIndex();
- Assert.assertTrue(index instanceof OnheapIncrementalIndex);
- Assert.assertNull(((OnheapIncrementalIndex) index).getClusteredBaseTable());
+ Assertions.assertTrue(index instanceof OnheapIncrementalIndex);
+ Assertions.assertNull(((OnheapIncrementalIndex) index).getClusteredBaseTable());
}
private static InputRow clusterRow(long ts, String tenant, String region)
@@ -201,7 +201,7 @@ public class SinkTest extends InitializedNullHandlingTest
@Test
public void testAcquireSegmentReferences_empty()
{
- Assert.assertEquals(
+ Assertions.assertEquals(
Collections.emptyList(),
Sink.acquireSegmentReferences(Collections.emptyList(), SegmentMapFunction.IDENTITY, false)
);
@@ -212,12 +212,12 @@ public class SinkTest extends InitializedNullHandlingTest
{
final List<FireHydrant> hydrants = twoHydrants();
final List<SinkSegmentReference> references = Sink.acquireSegmentReferences(hydrants, SegmentMapFunction.IDENTITY, false);
- Assert.assertNotNull(references);
- Assert.assertEquals(2, references.size());
- Assert.assertEquals(0, references.get(0).getHydrantNumber());
- Assert.assertFalse(references.get(0).isImmutable());
- Assert.assertEquals(1, references.get(1).getHydrantNumber());
- Assert.assertTrue(references.get(1).isImmutable());
+ Assertions.assertNotNull(references);
+ Assertions.assertEquals(2, references.size());
+ Assertions.assertEquals(0, references.get(0).getHydrantNumber());
+ Assertions.assertFalse(references.get(0).isImmutable());
+ Assertions.assertEquals(1, references.get(1).getHydrantNumber());
+ Assertions.assertTrue(references.get(1).isImmutable());
CloseableUtils.closeAll(references);
}
@@ -226,10 +226,10 @@ public class SinkTest extends InitializedNullHandlingTest
{
final List<FireHydrant> hydrants = twoHydrants();
final List<SinkSegmentReference> references = Sink.acquireSegmentReferences(hydrants, SegmentMapFunction.IDENTITY, true);
- Assert.assertNotNull(references);
- Assert.assertEquals(1, references.size());
- Assert.assertEquals(1, references.get(0).getHydrantNumber());
- Assert.assertTrue(references.get(0).isImmutable());
+ Assertions.assertNotNull(references);
+ Assertions.assertEquals(1, references.size());
+ Assertions.assertEquals(1, references.get(0).getHydrantNumber());
+ Assertions.assertTrue(references.get(0).isImmutable());
CloseableUtils.closeAll(references);
}
@@ -241,7 +241,7 @@ public class SinkTest extends InitializedNullHandlingTest
hydrants.get(1).swapSegment(null);
final List<SinkSegmentReference> references = Sink.acquireSegmentReferences(hydrants, SegmentMapFunction.IDENTITY, false);
- Assert.assertNull(references);
+ Assertions.assertNull(references);
}
@Test
@@ -286,7 +286,7 @@ public class SinkTest extends InitializedNullHandlingTest
expectedColumnTypeMap.put("rows", ColumnType.LONG);
RowSignature signature = sink.getSignature();
- Assert.assertEquals(toRowSignature(expectedColumnTypeMap), signature);
+ Assertions.assertEquals(toRowSignature(expectedColumnTypeMap), signature);
sink.add(
new MapBasedInputRow(
@@ -300,7 +300,7 @@ public class SinkTest extends InitializedNullHandlingTest
expectedColumnTypeMap.put("newCol1", ColumnType.STRING);
expectedColumnTypeMap.put("rows", ColumnType.LONG);
signature = sink.getSignature();
- Assert.assertEquals(toRowSignature(expectedColumnTypeMap), signature);
+ Assertions.assertEquals(toRowSignature(expectedColumnTypeMap), signature);
sink.swap();
@@ -314,7 +314,7 @@ public class SinkTest extends InitializedNullHandlingTest
expectedColumnTypeMap.put("newCol2", ColumnType.STRING);
signature = sink.getSignature();
- Assert.assertEquals(toRowSignature(expectedColumnTypeMap), signature);
+ Assertions.assertEquals(toRowSignature(expectedColumnTypeMap), signature);
sink.add(
new MapBasedInputRow(
@@ -326,7 +326,7 @@ public class SinkTest extends InitializedNullHandlingTest
expectedColumnTypeMap.put("newCol3", ColumnType.STRING);
signature = sink.getSignature();
- Assert.assertEquals(toRowSignature(expectedColumnTypeMap), signature);
+ Assertions.assertEquals(toRowSignature(expectedColumnTypeMap), signature);
sink.swap();
sink.add(
@@ -339,7 +339,7 @@ public class SinkTest extends InitializedNullHandlingTest
expectedColumnTypeMap.put("newCol4", ColumnType.STRING);
signature = sink.getSignature();
- Assert.assertEquals(toRowSignature(expectedColumnTypeMap), signature);
+ Assertions.assertEquals(toRowSignature(expectedColumnTypeMap), signature);
}
private RowSignature toRowSignature(Map<String, ColumnType> columnTypeMap)
diff --git a/server/src/test/java/org/apache/druid/server/lookup/cache/LookupNodeDiscoveryTest.java b/server/src/test/java/org/apache/druid/server/lookup/cache/LookupNodeDiscoveryTest.java
index 66c2493f2c8..141cd5032e6 100644
--- a/server/src/test/java/org/apache/druid/server/lookup/cache/LookupNodeDiscoveryTest.java
+++ b/server/src/test/java/org/apache/druid/server/lookup/cache/LookupNodeDiscoveryTest.java
@@ -30,9 +30,9 @@ import org.apache.druid.discovery.NodeRole;
import org.apache.druid.server.DruidNode;
import org.apache.druid.server.http.HostAndPortWithScheme;
import org.easymock.EasyMock;
-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;
/**
*/
@@ -42,7 +42,7 @@ public class LookupNodeDiscoveryTest
private DruidNodeDiscovery druidNodeDiscovery;
private LookupNodeDiscovery lookupNodeDiscovery;
- @Before
+ @BeforeEach
public void setup()
{
druidNodeDiscoveryProvider = EasyMock.createStrictMock(DruidNodeDiscoveryProvider.class);
@@ -85,7 +85,7 @@ public class LookupNodeDiscoveryTest
@Test
public void testGetNodesInTier()
{
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableList.of(
HostAndPortWithScheme.fromParts("http", "h1", 8080),
HostAndPortWithScheme.fromParts("http", "h2", 8080)
@@ -93,14 +93,14 @@ public class LookupNodeDiscoveryTest
ImmutableList.copyOf(lookupNodeDiscovery.getNodesInTier("tier1"))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableList.of(
HostAndPortWithScheme.fromParts("http", "h3", 8080)
),
ImmutableList.copyOf(lookupNodeDiscovery.getNodesInTier("tier2"))
);
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableList.of(),
ImmutableList.copyOf(lookupNodeDiscovery.getNodesInTier("tier3"))
);
@@ -111,7 +111,7 @@ public class LookupNodeDiscoveryTest
@Test
public void testGetAllTiers()
{
- Assert.assertEquals(
+ Assertions.assertEquals(
ImmutableSet.of("tier1", "tier2"),
lookupNodeDiscovery.getAllTiers()
);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org