FrankChen021 commented on code in PR #20057:
URL: https://github.com/apache/druid/pull/20057#discussion_r3805188430
##########
server/src/test/java/org/apache/druid/guice/BrokerProcessingModuleTest.java:
##########
@@ -86,27 +93,29 @@
public void testCachePopulatorAsSingleton()
{
CachePopulator cachePopulator = injector.getInstance(CachePopulator.class);
- Assert.assertNotNull(cachePopulator);
+ Assertions.assertNotNull(cachePopulator);
}
- @Test(expected = ProvisionException.class)
+ @Test
public void testMemoryCheckThrowsException()
{
- // JDK 9 and above do not support checking for direct memory size
- // so this test only validates functionality for Java 8.
- try {
- JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
- }
- catch (UnsupportedOperationException e) {
- Assume.assumeNoException(e);
- }
- Properties props = new Properties();
- props.setProperty("druid.processing.buffer.sizeBytes", "3GiB");
- Injector injector1 = makeInjector(props);
-
- DruidProcessingConfig processingBufferConfig =
injector1.getInstance(DruidProcessingConfig.class);
- BrokerProcessingModule module = new BrokerProcessingModule();
- module.getMergeBufferPool(processingBufferConfig,
JvmUtils.getRuntimeInfo());
+ Assertions.assertThrows(ProvisionException.class, () -> {
+ // JDK 9 and above do not support checking for direct memory size
+ // so this test only validates functionality for Java 8.
+ try {
+ JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
+ }
+ catch (UnsupportedOperationException e) {
+ Assumptions.assumeTrue(false, e::getMessage);
+ }
+ Properties props = new Properties();
+ props.setProperty("druid.processing.buffer.sizeBytes", "3GiB");
+ Injector injector1 = makeInjector(props);
+
+ DruidProcessingConfig processingBufferConfig =
injector1.getInstance(DruidProcessingConfig.class);
+ BrokerProcessingModule module = new BrokerProcessingModule();
+ module.getMergeBufferPool(processingBufferConfig,
JvmUtils.getRuntimeInfo());
Review Comment:
Pre-existing on `offical/master`: the same `JvmUtils.getRuntimeInfo()`
passed to `getMergeBufferPool` was already present at base line 109. The
migration changed only JUnit structure and assumption handling; no deprecated
call was introduced.
##########
server/src/test/java/org/apache/druid/guice/DruidProcessingModuleTest.java:
##########
@@ -22,42 +22,46 @@
import com.google.inject.ProvisionException;
import org.apache.druid.query.DruidProcessingConfig;
import org.apache.druid.utils.JvmUtils;
-import org.junit.Assume;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Test;
+
public class DruidProcessingModuleTest
{
- @Test(expected = ProvisionException.class)
+ @Test
public void testMemoryCheckThrowsException()
{
- // JDK 9 and above do not support checking for direct memory size
- // so this test only validates functionality for Java 8.
- try {
- JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
- }
- catch (UnsupportedOperationException e) {
- Assume.assumeNoException(e);
- }
+ Assertions.assertThrows(ProvisionException.class, () -> {
+ // JDK 9 and above do not support checking for direct memory size
+ // so this test only validates functionality for Java 8.
+ try {
+ JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
Review Comment:
Pre-existing on `offical/master`: the same
`JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes()` probe is present at base
line 37. PR2 only migrated the JUnit assumption/assertion flow; no deprecated
API call was introduced.
##########
server/src/test/java/org/apache/druid/guice/DruidProcessingModuleTest.java:
##########
@@ -22,42 +22,46 @@
import com.google.inject.ProvisionException;
import org.apache.druid.query.DruidProcessingConfig;
import org.apache.druid.utils.JvmUtils;
-import org.junit.Assume;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Test;
+
public class DruidProcessingModuleTest
{
- @Test(expected = ProvisionException.class)
+ @Test
public void testMemoryCheckThrowsException()
{
- // JDK 9 and above do not support checking for direct memory size
- // so this test only validates functionality for Java 8.
- try {
- JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
- }
- catch (UnsupportedOperationException e) {
- Assume.assumeNoException(e);
- }
+ Assertions.assertThrows(ProvisionException.class, () -> {
+ // JDK 9 and above do not support checking for direct memory size
+ // so this test only validates functionality for Java 8.
+ try {
+ JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
+ }
+ catch (UnsupportedOperationException e) {
+ Assumptions.assumeTrue(false, e::getMessage);
+ }
- DruidProcessingModule module = new DruidProcessingModule();
- module.getIntermediateResultsPool(
- new DruidProcessingConfig()
- {
- @Override
- public String getFormatString()
+ DruidProcessingModule module = new DruidProcessingModule();
+ module.getIntermediateResultsPool(
+ new DruidProcessingConfig()
{
- return "test";
- }
+ @Override
+ public String getFormatString()
+ {
+ return "test";
+ }
- @Override
- public int intermediateComputeSizeBytes()
- {
- return Integer.MAX_VALUE;
- }
- },
- JvmUtils.getRuntimeInfo()
- );
+ @Override
+ public int intermediateComputeSizeBytes()
+ {
+ return Integer.MAX_VALUE;
+ }
+ },
+ JvmUtils.getRuntimeInfo()
Review Comment:
Pre-existing on `offical/master`: the same `JvmUtils.getRuntimeInfo()`
passed to `getIntermediateResultsPool` was already present at base line 59. The
migration changed only JUnit wrapping and assumption handling.
##########
server/src/test/java/org/apache/druid/metadata/SQLMetadataConnectorTest.java:
##########
@@ -265,8 +265,8 @@
CentralizedDatasourceSchemaConfig.create()
);
BasicDataSource dataSource = testSQLMetadataConnector.getDatasource();
- Assert.assertEquals(dataSource.getMaxConnLifetimeMillis(), 1200000);
- Assert.assertEquals(dataSource.getDefaultQueryTimeout().intValue(), 30000);
+ Assertions.assertEquals(dataSource.getMaxConnLifetimeMillis(), 1200000);
Review Comment:
Pre-existing on `offical/master`: the test already invoked
`dataSource.getMaxConnLifetimeMillis()` at base line 268. PR2 only changed the
JUnit assertion class from `Assert` to `Assertions`; no deprecated API change
was introduced.
##########
server/src/test/java/org/apache/druid/metadata/SQLMetadataConnectorTest.java:
##########
@@ -265,8 +265,8 @@
CentralizedDatasourceSchemaConfig.create()
);
BasicDataSource dataSource = testSQLMetadataConnector.getDatasource();
- Assert.assertEquals(dataSource.getMaxConnLifetimeMillis(), 1200000);
- Assert.assertEquals(dataSource.getDefaultQueryTimeout().intValue(), 30000);
+ Assertions.assertEquals(dataSource.getMaxConnLifetimeMillis(), 1200000);
+ Assertions.assertEquals(dataSource.getDefaultQueryTimeout().intValue(),
30000);
Review Comment:
Pre-existing on `offical/master`: the test already invoked
`dataSource.getDefaultQueryTimeout()` at base line 269. PR2 only changed the
JUnit assertion class from `Assert` to `Assertions`; no deprecated API change
was introduced.
##########
server/src/test/java/org/apache/druid/segment/metadata/CoordinatorSegmentMetadataCacheTest.java:
##########
@@ -571,20 +571,20 @@
};
serverView.addSegment(newSegment(datasource, 1), ServerType.HISTORICAL);
- Assert.assertTrue(addSegmentLatch.await(1, TimeUnit.SECONDS));
+ Assertions.assertTrue(addSegmentLatch.await(1, TimeUnit.SECONDS));
- Assert.assertEquals(7, schema.getTotalSegments());
+ Assertions.assertEquals(7, schema.getTotalSegments());
List<AvailableSegmentMetadata> metadatas = schema
.getSegmentMetadataSnapshot()
.values()
.stream()
.filter(metadata ->
datasource.equals(metadata.getSegment().getDataSource()))
.collect(Collectors.toList());
- Assert.assertEquals(1, metadatas.size());
+ Assertions.assertEquals(1, metadatas.size());
AvailableSegmentMetadata metadata = metadatas.get(0);
- Assert.assertEquals(0, metadata.isRealtime());
- Assert.assertEquals(0, metadata.getNumRows());
-
Assert.assertTrue(schema.getSegmentsNeedingRefresh().contains(metadata.getSegment().getId()));
+ Assertions.assertEquals(0, metadata.isRealtime());
+ Assertions.assertEquals(0, metadata.getNumRows());
Review Comment:
Pre-existing on `offical/master`: the same `metadata.getNumRows()`
invocation is present at base line 586. PR2 only changed the JUnit assertion
from `Assert.assertEquals` to `Assertions.assertEquals`.
##########
server/src/test/java/org/apache/druid/segment/metadata/CoordinatorSegmentMetadataCacheTest.java:
##########
@@ -624,22 +624,22 @@
DataSegment segment = newSegment(datasource, 1);
serverView.addSegment(segment, ServerType.INDEXER_EXECUTOR);
serverView.addSegment(segment, ServerType.HISTORICAL);
- Assert.assertTrue(addSegmentLatch.await(1, TimeUnit.SECONDS));
+ Assertions.assertTrue(addSegmentLatch.await(1, TimeUnit.SECONDS));
- Assert.assertEquals(7, schema.getTotalSegments());
+ Assertions.assertEquals(7, schema.getTotalSegments());
List<AvailableSegmentMetadata> metadatas = schema
.getSegmentMetadataSnapshot()
.values()
.stream()
.filter(metadata ->
datasource.equals(metadata.getSegment().getDataSource()))
.collect(Collectors.toList());
- Assert.assertEquals(1, metadatas.size());
+ Assertions.assertEquals(1, metadatas.size());
AvailableSegmentMetadata metadata = metadatas.get(0);
- Assert.assertEquals(0, metadata.isRealtime()); // realtime flag is unset
when there is any historical
- Assert.assertEquals(0, metadata.getNumRows());
- Assert.assertEquals(2, metadata.getNumReplicas());
-
Assert.assertTrue(schema.getSegmentsNeedingRefresh().contains(metadata.getSegment().getId()));
-
Assert.assertFalse(schema.getMutableSegments().contains(metadata.getSegment().getId()));
+ Assertions.assertEquals(0, metadata.isRealtime()); // realtime flag is
unset when there is any historical
+ Assertions.assertEquals(0, metadata.getNumRows());
Review Comment:
Pre-existing on `offical/master`: the same `metadata.getNumRows()`
invocation is present at base line 639. PR2 only changed the JUnit assertion
from `Assert.assertEquals` to `Assertions.assertEquals`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]