FrankChen021 commented on code in PR #19940:
URL: https://github.com/apache/druid/pull/19940#discussion_r3742745368
##########
processing/src/test/java/org/apache/druid/java/util/common/StringUtilsTest.java:
##########
@@ -150,165 +145,167 @@
final ByteBuffer bytes = bufferHolder.get();
bytes.put(new byte[]{'a', 'b', 'c', 'd'});
bytes.rewind();
- Assert.assertEquals("abcd", StringUtils.fromUtf8(bytes, 4));
+ Assertions.assertEquals("abcd", StringUtils.fromUtf8(bytes, 4));
bytes.rewind();
- Assert.assertEquals("abcd", StringUtils.fromUtf8(bytes));
+ Assertions.assertEquals("abcd", StringUtils.fromUtf8(bytes));
}
}
@SuppressWarnings("MalformedFormatString")
@Test
public void testNonStrictFormat()
{
- Assert.assertEquals("test%d; format",
StringUtils.nonStrictFormat("test%d", "format"));
- Assert.assertEquals("test%s%s; format",
StringUtils.nonStrictFormat("test%s%s", "format"));
+ Assertions.assertEquals("test%d; format",
StringUtils.nonStrictFormat("test%d", "format"));
+ Assertions.assertEquals("test%s%s; format",
StringUtils.nonStrictFormat("test%s%s", "format"));
Review Comment:
Addressed in commit 166af79795 with the repository CodeQL suppression marker
for this intentional nonStrictFormat test case; the test behavior is unchanged.
The focused processing tests and validation passed.
##########
processing/src/test/java/org/apache/druid/java/util/common/CompressionUtilsTest.java:
##########
@@ -610,49 +610,49 @@
);
}
catch (ISE ise) {
- Assert.assertTrue(ise.getMessage().contains("does not start with
outDir"));
- Assert.assertFalse("Zip exploit triggered, /tmp/evil.txt was written.",
evilResult.exists());
+ Assertions.assertTrue(ise.getMessage().contains("does not start with
outDir"));
+ Assertions.assertFalse(evilResult.exists(), "Zip exploit triggered,
/tmp/evil.txt was written.");
return;
}
- Assert.fail("Exception was not thrown for malicious zip file");
+ Assertions.fail("Exception was not thrown for malicious zip file");
}
@Test
// Sanity check to make sure the test class works as expected
public void testZeroRemainingInputStream() throws IOException
{
try (OutputStream outputStream = new FileOutputStream(testFile)) {
- Assert.assertEquals(
+ Assertions.assertEquals(
GZ_BYTES.length,
ByteStreams.copy(
new ZeroRemainingInputStream(new ByteArrayInputStream(GZ_BYTES)),
outputStream
)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
GZ_BYTES.length,
ByteStreams.copy(
new ZeroRemainingInputStream(new ByteArrayInputStream(GZ_BYTES)),
outputStream
)
);
- Assert.assertEquals(
+ Assertions.assertEquals(
GZ_BYTES.length,
ByteStreams.copy(
new ZeroRemainingInputStream(new ByteArrayInputStream(GZ_BYTES)),
outputStream
)
);
}
- Assert.assertEquals(GZ_BYTES.length * 3, testFile.length());
+ Assertions.assertEquals(GZ_BYTES.length * 3, testFile.length());
Review Comment:
Fixed in commit 166af79795 by casting GZ_BYTES.length to long before
multiplication. This preserves the test behavior and prevents the potential
integer overflow. The focused processing tests passed.
##########
processing/src/test/java/org/apache/druid/utils/CloseableUtilsTest.java:
##########
@@ -79,7 +80,7 @@
MatcherAssert.assertThat(e, CoreMatchers.instanceOf(IOException.class));
// Second exception
- Assert.assertEquals(1, e.getSuppressed().length);
+ Assertions.assertEquals(1, e.getSuppressed().length);
Review Comment:
Fixed in commit 166af79795 by capturing the expected exception with
Assertions.assertThrows instead of a nullable local and manual try/catch. The
focused processing tests passed.
##########
processing/src/test/java/org/apache/druid/utils/CloseableUtilsTest.java:
##########
@@ -108,7 +109,7 @@
MatcherAssert.assertThat(e, CoreMatchers.instanceOf(IOException.class));
// Second exception
- Assert.assertEquals(1, e.getSuppressed().length);
+ Assertions.assertEquals(1, e.getSuppressed().length);
Review Comment:
Fixed in commit 166af79795 by capturing the expected exception with
Assertions.assertThrows instead of a nullable local and manual try/catch. The
focused processing tests passed.
--
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]