diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/BaseCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/BaseCommandTest.java index 731f799e1c..ee42d3332e 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/BaseCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/BaseCommandTest.java @@ -26,7 +26,6 @@ import java.util.List; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; -import org.junit.Assert; import org.junit.Assume; import org.junit.Before; import org.junit.Test; @@ -50,19 +49,19 @@ public void setUp() { @Test public void qualifiedPathTest() throws IOException { Path path = this.command.qualifiedPath(FILE_PATH); - Assert.assertEquals("test.parquet", path.getName()); + assertThat(path.getName()).isEqualTo("test.parquet"); } @Test public void qualifiedURITest() throws IOException { URI uri = this.command.qualifiedURI(FILE_PATH); - Assert.assertEquals("/var/tmp/test.parquet", uri.getPath()); + assertThat(uri.getPath()).isEqualTo("/var/tmp/test.parquet"); } @Test public void qualifiedURIResourceURITest() throws IOException { URI uri = this.command.qualifiedURI("resource:/a"); - Assert.assertEquals("/a", uri.getPath()); + assertThat(uri.getPath()).isEqualTo("/a"); } @Test @@ -93,14 +92,14 @@ public void hexToBytesRejectsInvalidHexString() { public void qualifiedPathTestForWindows() throws IOException { Assume.assumeTrue(System.getProperty("os.name").toLowerCase().startsWith("win")); Path path = this.command.qualifiedPath(WIN_FILE_PATH); - Assert.assertEquals("test.parquet", path.getName()); + assertThat(path.getName()).isEqualTo("test.parquet"); } @Test public void qualifiedURITestForWindows() throws IOException { Assume.assumeTrue(System.getProperty("os.name").toLowerCase().startsWith("win")); URI uri = this.command.qualifiedURI(WIN_FILE_PATH); - Assert.assertEquals("/C:/Test/Downloads/test.parquet", uri.getPath()); + assertThat(uri.getPath()).isEqualTo("/C:/Test/Downloads/test.parquet"); } class TestCommand extends BaseCommand { diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/MainTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/MainTest.java index 6bf54bdf05..26efb9317e 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/MainTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/MainTest.java @@ -18,11 +18,12 @@ */ package org.apache.parquet.cli; +import static org.assertj.core.api.Assertions.assertThatCode; + import java.io.File; import java.io.FileWriter; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.ToolRunner; -import org.junit.Assert; import org.junit.Test; import org.slf4j.LoggerFactory; @@ -30,8 +31,9 @@ public class MainTest { @Test public void mainTest() throws Exception { - ToolRunner.run(new Configuration(), new Main(LoggerFactory.getLogger(MainTest.class)), new String[] {}); - Assert.assertTrue("we simply verify there are no errors here", true); + assertThatCode(() -> ToolRunner.run( + new Configuration(), new Main(LoggerFactory.getLogger(MainTest.class)), new String[] {})) + .doesNotThrowAnyException(); } @Test @@ -43,28 +45,28 @@ public void testConfigFileLoading() throws Exception { writer.write("test.key=test.value\n"); } - try { - new Main(LoggerFactory.getLogger(MainTest.class)) - .run(new String[] {"--config-file", configFile.getAbsolutePath(), "help"}); - Assert.assertTrue("Config file loading should not throw exception", true); - } catch (IllegalArgumentException e) { - Assert.fail("Config file loading failed: " + e.getMessage()); - } + assertThatCode(() -> new Main(LoggerFactory.getLogger(MainTest.class)) + .run(new String[] {"--config-file", configFile.getAbsolutePath(), "help"})) + .doesNotThrowAnyException(); } @Test public void testLocalPropertiesFile() throws Exception { String configFile = getClass().getResource("/test-config.properties").getPath(); - ToolRunner.run(new Configuration(), new Main(LoggerFactory.getLogger(MainTest.class)), new String[] { - "--config-file", configFile, "version" - }); + assertThatCode(() -> ToolRunner.run( + new Configuration(), + new Main(LoggerFactory.getLogger(MainTest.class)), + new String[] {"--config-file", configFile, "version"})) + .doesNotThrowAnyException(); } @Test public void testLocalXmlFile() throws Exception { String configFile = getClass().getResource("/test-config.xml").getPath(); - ToolRunner.run(new Configuration(), new Main(LoggerFactory.getLogger(MainTest.class)), new String[] { - "--config-file", configFile, "version" - }); + assertThatCode(() -> ToolRunner.run( + new Configuration(), + new Main(LoggerFactory.getLogger(MainTest.class)), + new String[] {"--config-file", configFile, "version"})) + .doesNotThrowAnyException(); } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/AvroFileTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/AvroFileTest.java index 5278d7a323..2a68bb7f14 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/AvroFileTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/AvroFileTest.java @@ -18,6 +18,8 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.File; import java.io.IOException; import java.util.Arrays; @@ -47,7 +49,7 @@ protected File toAvro(File inputFile, File outputFile, boolean overwrite, String command.overwrite = overwrite; command.setConf(new Configuration()); int exitCode = command.run(); - assert (exitCode == 0); + assertThat(exitCode).isZero(); return outputFile; } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/CSVSchemaCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/CSVSchemaCommandTest.java index eeadb26d79..4cb8d7da61 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/CSVSchemaCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/CSVSchemaCommandTest.java @@ -18,11 +18,12 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.File; import java.io.IOException; import java.util.Arrays; import org.apache.hadoop.conf.Configuration; -import org.junit.Assert; import org.junit.Test; public class CSVSchemaCommandTest extends CSVFileTest { @@ -33,6 +34,6 @@ public void testCSVSchemaCommand() throws IOException { command.samplePaths = Arrays.asList(file.getAbsolutePath()); command.recordName = "Test"; command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/CatCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/CatCommandTest.java index ff71e75524..cf2f45030e 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/CatCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/CatCommandTest.java @@ -18,6 +18,7 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import com.google.protobuf.Message; @@ -35,7 +36,6 @@ import org.apache.parquet.schema.MessageType; import org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName; import org.apache.parquet.schema.Types; -import org.junit.Assert; import org.junit.Test; public class CatCommandTest extends ParquetFileTest { @@ -45,7 +45,7 @@ public void testCatCommand() throws IOException { CatCommand command = new CatCommand(createLogger(), 0); command.sourceFiles = Arrays.asList(file.getAbsolutePath()); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } @Test @@ -54,7 +54,7 @@ public void testCatCommandWithMultipleInput() throws IOException { CatCommand command = new CatCommand(createLogger(), 0); command.sourceFiles = Arrays.asList(file.getAbsolutePath(), file.getAbsolutePath()); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } @Test @@ -64,7 +64,7 @@ public void testCatCommandWithSpecificColumns() throws IOException { command.sourceFiles = Arrays.asList(file.getAbsolutePath()); command.columns = Arrays.asList(INT32_FIELD, INT64_FIELD); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } @Test @@ -89,7 +89,7 @@ public void testCatCommandProtoParquetAutoDetected() throws Exception { cmd.setConf(new Configuration()); int result = cmd.run(); - Assert.assertEquals(0, result); + assertThat(result).isZero(); } @Test @@ -104,7 +104,7 @@ public void testCatCommandWithSimpleReaderConfig() throws Exception { cmd.setConf(conf); int result = cmd.run(); - Assert.assertEquals(0, result); + assertThat(result).isZero(); } @Test @@ -117,7 +117,7 @@ public void testCatCommandWithHyphenatedFieldNames() throws Exception { cmd.setConf(new Configuration()); int result = cmd.run(); - Assert.assertEquals(0, result); + assertThat(result).isZero(); } private static void writeParquetWithHyphenatedFields(File file) throws IOException { diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/CheckParquet251CommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/CheckParquet251CommandTest.java index 6e83d49e6f..c1ebb68244 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/CheckParquet251CommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/CheckParquet251CommandTest.java @@ -18,11 +18,12 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.File; import java.io.IOException; import java.util.Arrays; import org.apache.hadoop.conf.Configuration; -import org.junit.Assert; import org.junit.Test; public class CheckParquet251CommandTest extends ParquetFileTest { @@ -32,6 +33,6 @@ public void testCheckParquet251Command() throws IOException { CheckParquet251Command command = new CheckParquet251Command(createLogger()); command.files = Arrays.asList(file.getAbsolutePath()); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ColumnSizeCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ColumnSizeCommandTest.java index efd0d2234b..4b9a7231d5 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ColumnSizeCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ColumnSizeCommandTest.java @@ -21,8 +21,7 @@ import static org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.INT32; import static org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.INT64; import static org.apache.parquet.schema.Type.Repetition.REQUIRED; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import java.io.File; import java.io.IOException; @@ -36,7 +35,6 @@ import org.apache.parquet.hadoop.example.GroupWriteSupport; import org.apache.parquet.schema.MessageType; import org.apache.parquet.schema.PrimitiveType; -import org.junit.Assert; import org.junit.Test; public class ColumnSizeCommandTest extends ParquetFileTest { @@ -51,17 +49,17 @@ public void testColumnSizeCommand() throws IOException { ColumnSizeCommand command = new ColumnSizeCommand(createLogger()); command.target = file.getAbsolutePath(); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } @Test public void testColumnSize() throws Exception { String inputFile = createParquetFile(); Map columnSizeInBytes = command.getColumnSizeInBytes(new Path(inputFile)); - assertEquals(columnSizeInBytes.size(), 2); - assertTrue(columnSizeInBytes.get("DocId") > columnSizeInBytes.get("Num")); + assertThat(columnSizeInBytes).hasSize(2); + assertThat(columnSizeInBytes.get("DocId")).isGreaterThan(columnSizeInBytes.get("Num")); Map columnRatio = command.getColumnRatio(columnSizeInBytes); - assertTrue(columnRatio.get("DocId") > columnRatio.get("Num")); + assertThat(columnRatio.get("DocId")).isGreaterThan(columnRatio.get("Num")); } private String createParquetFile() throws IOException { diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ConvertCSVCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ConvertCSVCommandTest.java index b8bbe45497..031ca959f3 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ConvertCSVCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ConvertCSVCommandTest.java @@ -18,13 +18,13 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.io.File; import java.io.IOException; import java.util.Arrays; import org.apache.hadoop.conf.Configuration; -import org.junit.Assert; import org.junit.Test; public class ConvertCSVCommandTest extends CSVFileTest { @@ -36,8 +36,8 @@ public void testConvertCSVCommand() throws IOException { File output = new File(getTempFolder(), getClass().getSimpleName() + ".parquet"); command.outputPath = output.getAbsolutePath(); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); - Assert.assertTrue(output.exists()); + assertThat(command.run()).isZero(); + assertThat(output).exists(); } @Test @@ -48,8 +48,8 @@ public void testConvertCSVCommandWithMultipleInput() throws IOException { File output = new File(getTempFolder(), getClass().getSimpleName() + ".parquet"); command.outputPath = output.getAbsolutePath(); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); - Assert.assertTrue(output.exists()); + assertThat(command.run()).isZero(); + assertThat(output).exists(); } @Test @@ -77,7 +77,7 @@ public void testConvertCSVCommandWithGenericConf() throws IOException { conf.set("parquet.avro.write-parquet-uuid", "true"); conf.set("parquet.avro.write-old-list-structure", "false"); command.setConf(conf); - Assert.assertEquals(0, command.run()); - Assert.assertTrue(output.exists()); + assertThat(command.run()).isZero(); + assertThat(output).exists(); } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ConvertCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ConvertCommandTest.java index c38a5b25bf..23dd62c281 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ConvertCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ConvertCommandTest.java @@ -18,11 +18,12 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.File; import java.io.IOException; import java.util.Arrays; import org.apache.hadoop.conf.Configuration; -import org.junit.Assert; import org.junit.Test; public class ConvertCommandTest extends AvroFileTest { @@ -34,8 +35,8 @@ public void testConvertCommand() throws IOException { File output = new File(getTempFolder(), "converted.avro"); command.outputPath = output.getAbsolutePath(); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); - Assert.assertTrue(output.exists()); + assertThat(command.run()).isZero(); + assertThat(output).exists(); } @Test @@ -51,8 +52,8 @@ public void testConvertCommandWithGenericConf() throws IOException { conf.set("test.property", "test.value"); command.setConf(conf); - Assert.assertEquals(0, command.run()); - Assert.assertTrue(output.exists()); + assertThat(command.run()).isZero(); + assertThat(output).exists(); } @Test @@ -68,8 +69,8 @@ public void testConvertCommandConfigurationValidation() throws IOException { conf.set("parquet.avro.write-old-list-structure", "false"); command.setConf(conf); - Assert.assertEquals(0, command.run()); - Assert.assertTrue(output.exists()); + assertThat(command.run()).isZero(); + assertThat(output).exists(); File output2 = new File(getTempFolder(), "converted_with_config_validation2.parquet"); command.outputPath = output2.getAbsolutePath(); @@ -78,7 +79,7 @@ public void testConvertCommandConfigurationValidation() throws IOException { conf2.set("parquet.avro.write-old-list-structure", "true"); command.setConf(conf2); - Assert.assertEquals(0, command.run()); - Assert.assertTrue(output2.exists()); + assertThat(command.run()).isZero(); + assertThat(output2).exists(); } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ParquetMetadataCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ParquetMetadataCommandTest.java index b6a9943191..7702e753f5 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ParquetMetadataCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ParquetMetadataCommandTest.java @@ -18,11 +18,12 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.File; import java.io.IOException; import java.util.Arrays; import org.apache.hadoop.conf.Configuration; -import org.junit.Assert; import org.junit.Test; public class ParquetMetadataCommandTest extends ParquetFileTest { @@ -32,6 +33,6 @@ public void testParquetMetadataCommand() throws IOException { ParquetMetadataCommand command = new ParquetMetadataCommand(createLogger()); command.targets = Arrays.asList(file.getAbsolutePath()); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/RewriteCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/RewriteCommandTest.java index 5ad5dd96a5..da0630b118 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/RewriteCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/RewriteCommandTest.java @@ -18,6 +18,7 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.io.File; @@ -26,7 +27,6 @@ import java.util.Arrays; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileAlreadyExistsException; -import org.junit.Assert; import org.junit.Test; public class RewriteCommandTest extends ParquetFileTest { @@ -38,8 +38,8 @@ public void testRewriteCommand() throws IOException { File output = new File(getTempFolder(), "converted.parquet"); command.output = output.getAbsolutePath(); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); - Assert.assertTrue(output.exists()); + assertThat(command.run()).isZero(); + assertThat(output).exists(); } @Test @@ -68,8 +68,8 @@ public void testRewriteCommandWithOverwrite() throws IOException { command.setConf(new Configuration()); Files.createFile(output.toPath()); - Assert.assertEquals(0, command.run()); - Assert.assertTrue(output.exists()); + assertThat(command.run()).isZero(); + assertThat(output).exists(); } @Test @@ -82,8 +82,8 @@ public void testRewriteCommandWithCompression_GZIP() throws IOException { command.codec = "GZIP"; command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); - Assert.assertTrue(output.exists()); + assertThat(command.run()).isZero(); + assertThat(output).exists(); } @Test @@ -96,7 +96,7 @@ public void testRewriteCommandWithCompression_gzip() throws IOException { command.codec = "gzip"; command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); - Assert.assertTrue(output.exists()); + assertThat(command.run()).isZero(); + assertThat(output).exists(); } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ScanCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ScanCommandTest.java index 12f705b7d2..ab1788da3d 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ScanCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ScanCommandTest.java @@ -18,13 +18,13 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.io.File; import java.io.IOException; import java.util.Arrays; import org.apache.hadoop.conf.Configuration; -import org.junit.Assert; import org.junit.Test; public class ScanCommandTest extends ParquetFileTest { @@ -34,7 +34,7 @@ public void testScanCommand() throws IOException { ScanCommand command = new ScanCommand(createLogger()); command.sourceFiles = Arrays.asList(file.getAbsolutePath()); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } @Test @@ -43,7 +43,7 @@ public void testScanCommandWithMultipleSourceFiles() throws IOException { ScanCommand command = new ScanCommand(createLogger()); command.sourceFiles = Arrays.asList(file.getAbsolutePath(), file.getAbsolutePath()); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } @Test diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/SchemaCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/SchemaCommandTest.java index b8d2a1ddc0..a35992f732 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/SchemaCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/SchemaCommandTest.java @@ -18,6 +18,7 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.io.File; @@ -26,7 +27,6 @@ import org.apache.commons.io.FileUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileAlreadyExistsException; -import org.junit.Assert; import org.junit.Test; public class SchemaCommandTest extends ParquetFileTest { @@ -36,7 +36,7 @@ public void testSchemaCommand() throws IOException { SchemaCommand command = new SchemaCommand(createLogger()); command.targets = Arrays.asList(file.getAbsolutePath()); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } @Test @@ -44,14 +44,14 @@ public void testSchemaCommandOverwriteExistentFile() throws IOException { File inputFile = parquetFile(); File outputFile = new File(getTempFolder(), getClass().getSimpleName() + ".avsc"); FileUtils.touch(outputFile); - Assert.assertEquals(0, outputFile.length()); + assertThat(outputFile.length()).isZero(); SchemaCommand command = new SchemaCommand(createLogger()); command.targets = Arrays.asList(inputFile.getAbsolutePath()); command.outputPath = outputFile.getAbsolutePath(); command.overwrite = true; command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); - Assert.assertTrue(0 < outputFile.length()); + assertThat(command.run()).isZero(); + assertThat(outputFile.length()).isPositive(); } @Test diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowBloomFilterCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowBloomFilterCommandTest.java index 7e6c1063ca..f7edf4b5bb 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowBloomFilterCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowBloomFilterCommandTest.java @@ -21,6 +21,7 @@ import static org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.BINARY; import static org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.INT32; +import static org.assertj.core.api.Assertions.assertThat; import java.io.File; import java.io.IOException; @@ -44,7 +45,6 @@ import org.apache.parquet.io.api.Binary; import org.apache.parquet.schema.MessageType; import org.apache.parquet.schema.Types; -import org.junit.Assert; import org.junit.Test; public class ShowBloomFilterCommandTest extends ParquetFileTest { @@ -56,7 +56,7 @@ public void testShowBloomFilterCommand() throws IOException { command.columnPath = INT32_FIELD; command.testValues = Arrays.asList(new String[] {"1"}); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } @Test @@ -75,7 +75,7 @@ public void testEncryptedFileWithBloomFilter() throws IOException { "02030405060708090a0b0c0d0e0f1011:name,email;0405060708090a0b0c0d0e0f10111213:phone"); command.setConf(conf); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); ShowBloomFilterCommand emailCommand = new ShowBloomFilterCommand(createLogger()); emailCommand.file = encryptedFile.getAbsolutePath(); @@ -83,7 +83,7 @@ public void testEncryptedFileWithBloomFilter() throws IOException { emailCommand.testValues = Arrays.asList(new String[] {"user1@test.com", "missing@test.com"}); emailCommand.setConf(conf); - Assert.assertEquals(0, emailCommand.run()); + assertThat(emailCommand.run()).isZero(); ShowBloomFilterCommand phoneCommand = new ShowBloomFilterCommand(createLogger()); phoneCommand.file = encryptedFile.getAbsolutePath(); @@ -91,7 +91,7 @@ public void testEncryptedFileWithBloomFilter() throws IOException { phoneCommand.testValues = Arrays.asList(new String[] {"555-0001", "555-9999"}); phoneCommand.setConf(conf); - Assert.assertEquals(0, phoneCommand.run()); + assertThat(phoneCommand.run()).isZero(); encryptedFile.delete(); } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowColumnIndexTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowColumnIndexTest.java index 9a02618173..fb530024e9 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowColumnIndexTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowColumnIndexTest.java @@ -18,11 +18,12 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.File; import java.io.IOException; import java.util.Arrays; import org.apache.hadoop.conf.Configuration; -import org.junit.Assert; import org.junit.Test; public class ShowColumnIndexTest extends ParquetFileTest { @@ -32,6 +33,6 @@ public void testShowColumnIndexCommand() throws IOException { ShowColumnIndexCommand command = new ShowColumnIndexCommand(createLogger()); command.files = Arrays.asList(file.getAbsolutePath()); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowDictionaryCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowDictionaryCommandTest.java index 30e26bc6ba..449db6ac8b 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowDictionaryCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowDictionaryCommandTest.java @@ -18,11 +18,12 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.File; import java.io.IOException; import java.util.Arrays; import org.apache.hadoop.conf.Configuration; -import org.junit.Assert; import org.junit.Test; public class ShowDictionaryCommandTest extends ParquetFileTest { @@ -33,7 +34,7 @@ public void testShowDirectoryCommand() throws IOException { command.targets = Arrays.asList(file.getAbsolutePath()); command.column = BINARY_FIELD; command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } @Test @@ -44,7 +45,7 @@ public void testShowDirectoryCommandWithoutDictionaryEncoding() throws IOExcepti // the 'double_field' column does not have dictionary encoding command.column = DOUBLE_FIELD; command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } @Test @@ -54,6 +55,6 @@ public void testShowDirectoryCommandForFixedLengthByteArray() throws IOException command.targets = Arrays.asList(file.getAbsolutePath()); command.column = FIXED_LEN_BYTE_ARRAY_FIELD; command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowFooterCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowFooterCommandTest.java index 6c6028848b..f0f4326af8 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowFooterCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowFooterCommandTest.java @@ -19,7 +19,7 @@ package org.apache.parquet.cli.commands; -import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import java.io.File; import java.io.IOException; @@ -34,9 +34,9 @@ public void testShowDirectoryCommand() throws IOException { command.target = file.getAbsolutePath(); command.raw = false; command.setConf(new Configuration()); - assertEquals(0, command.run()); + assertThat(command.run()).isZero(); command.raw = true; - assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowGeospatialStatisticsCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowGeospatialStatisticsCommandTest.java index 1a4f3f73ce..e00f8ca33d 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowGeospatialStatisticsCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowGeospatialStatisticsCommandTest.java @@ -18,11 +18,12 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.File; import java.io.IOException; import java.util.Arrays; import org.apache.hadoop.conf.Configuration; -import org.junit.Assert; import org.junit.Test; public class ShowGeospatialStatisticsCommandTest extends ParquetFileTest { @@ -32,6 +33,6 @@ public void testShowGeospatialStatisticsCommand() throws IOException { ShowGeospatialStatisticsCommand command = new ShowGeospatialStatisticsCommand(createLogger()); command.targets = Arrays.asList(file.getAbsolutePath()); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowPagesCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowPagesCommandTest.java index 73b1953c62..30c043b42e 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowPagesCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowPagesCommandTest.java @@ -18,11 +18,12 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.File; import java.io.IOException; import java.util.Arrays; import org.apache.hadoop.conf.Configuration; -import org.junit.Assert; import org.junit.Test; public class ShowPagesCommandTest extends ParquetFileTest { @@ -32,6 +33,6 @@ public void testShowPagesCommand() throws IOException { ShowPagesCommand command = new ShowPagesCommand(createLogger()); command.targets = Arrays.asList(file.getAbsolutePath()); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowSizeStatisticsCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowSizeStatisticsCommandTest.java index ff1733e906..2af5b497c8 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowSizeStatisticsCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowSizeStatisticsCommandTest.java @@ -18,11 +18,12 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.File; import java.io.IOException; import java.util.Arrays; import org.apache.hadoop.conf.Configuration; -import org.junit.Assert; import org.junit.Test; public class ShowSizeStatisticsCommandTest extends ParquetFileTest { @@ -32,7 +33,7 @@ public void testShowSizeStatisticsCommand() throws IOException { ShowSizeStatisticsCommand command = new ShowSizeStatisticsCommand(createLogger()); command.targets = Arrays.asList(file.getAbsolutePath()); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } @Test @@ -42,7 +43,7 @@ public void testShowSizeStatisticsWithColumnFilter() throws IOException { command.targets = Arrays.asList(file.getAbsolutePath()); command.columns = Arrays.asList(INT32_FIELD, INT64_FIELD); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } @Test @@ -52,6 +53,6 @@ public void testShowSizeStatisticsWithRowGroupFilter() throws IOException { command.targets = Arrays.asList(file.getAbsolutePath()); command.rowGroups = Arrays.asList(0); command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); + assertThat(command.run()).isZero(); } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowVersionCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowVersionCommandTest.java index 7eff9ad744..50f9b23b8e 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowVersionCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ShowVersionCommandTest.java @@ -18,9 +18,10 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; + import java.util.Queue; import org.apache.parquet.Version; -import org.junit.Assert; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.event.LoggingEvent; @@ -34,10 +35,10 @@ public void testVersionCommand() { private void testVersionCommand0(Logger console, Queue loggingEvents) { ShowVersionCommand command = new ShowVersionCommand(console); - Assert.assertEquals(0, command.run()); - Assert.assertEquals(1, loggingEvents.size()); + assertThat(command.run()).isZero(); + assertThat(loggingEvents).hasSize(1); LoggingEvent loggingEvent = loggingEvents.remove(); - Assert.assertEquals(Version.FULL_VERSION, loggingEvent.getMessage()); + assertThat(loggingEvent.getMessage()).isEqualTo(Version.FULL_VERSION); loggingEvents.clear(); } } diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ToAvroCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ToAvroCommandTest.java index 7efe217e64..7ac1d5b1a2 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ToAvroCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/ToAvroCommandTest.java @@ -19,6 +19,7 @@ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import com.beust.jcommander.JCommander; @@ -28,7 +29,6 @@ import java.io.IOException; import org.apache.commons.io.FileUtils; import org.apache.hadoop.fs.FileAlreadyExistsException; -import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -40,7 +40,7 @@ public class ToAvroCommandTest extends AvroFileTest { @Test public void testToAvroCommandFromParquet() throws IOException { File avroFile = toAvro(parquetFile()); - Assert.assertTrue(avroFile.exists()); + assertThat(avroFile).exists(); } @Test @@ -64,37 +64,37 @@ public void testToAvroCommandFromJson() throws IOException { .build() .parse("--overwrite", jsonInputFile.getAbsolutePath(), "--output", avroOutputFile.getAbsolutePath()); - assert (cmd.run() == 0); + assertThat(cmd.run()).isZero(); } @Test public void testToAvroCommandWithGzipCompression() throws IOException { File avroFile = toAvro(parquetFile(), "GZIP"); - Assert.assertTrue(avroFile.exists()); + assertThat(avroFile).exists(); } @Test public void testToAvroCommandWithSnappyCompression() throws IOException { File avroFile = toAvro(parquetFile(), "SNAPPY"); - Assert.assertTrue(avroFile.exists()); + assertThat(avroFile).exists(); } @Test public void testToAvroCommandWithZstdCompression() throws IOException { File avroFile = toAvro(parquetFile(), "ZSTD"); - Assert.assertTrue(avroFile.exists()); + assertThat(avroFile).exists(); } @Test public void testToAvroCommandWithBzip2Compression() throws IOException { File avroFile = toAvro(parquetFile(), "bzip2"); - Assert.assertTrue(avroFile.exists()); + assertThat(avroFile).exists(); } @Test public void testToAvroCommandWithXzCompression() throws IOException { File avroFile = toAvro(parquetFile(), "xz"); - Assert.assertTrue(avroFile.exists()); + assertThat(avroFile).exists(); } @Test @@ -109,9 +109,9 @@ public void testToAvroCommandWithInvalidCompression() throws IOException { public void testToAvroCommandOverwriteExistentFile() throws IOException { File outputFile = new File(getTempFolder(), getClass().getSimpleName() + ".avro"); FileUtils.touch(outputFile); - Assert.assertEquals(0, outputFile.length()); + assertThat(outputFile.length()).isZero(); File avroFile = toAvro(parquetFile(), outputFile, true); - Assert.assertTrue(0 < avroFile.length()); + assertThat(avroFile.length()).isPositive(); } @Test diff --git a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/TransCompressionCommandTest.java b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/TransCompressionCommandTest.java index 07b2f6ec34..7725e4b75c 100644 --- a/parquet-cli/src/test/java/org/apache/parquet/cli/commands/TransCompressionCommandTest.java +++ b/parquet-cli/src/test/java/org/apache/parquet/cli/commands/TransCompressionCommandTest.java @@ -18,10 +18,11 @@ */ package org.apache.parquet.cli.commands; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.File; import java.io.IOException; import org.apache.hadoop.conf.Configuration; -import org.junit.Assert; import org.junit.Test; public class TransCompressionCommandTest extends ParquetFileTest { @@ -37,8 +38,8 @@ public void testTransCompressionCommand_ZSTD() throws IOException { command.codec = "ZSTD"; command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); - Assert.assertTrue(output.exists()); + assertThat(command.run()).isZero(); + assertThat(output).exists(); } @Test @@ -52,7 +53,7 @@ public void testTransCompressionCommand_zstd() throws IOException { command.codec = "zstd"; command.setConf(new Configuration()); - Assert.assertEquals(0, command.run()); - Assert.assertTrue(output.exists()); + assertThat(command.run()).isZero(); + assertThat(output).exists(); } } diff --git a/parquet-plugins/parquet-encoding-vector/src/test/java/org/apache/parquet/column/values/bitpacking/TestByteBitPacking512VectorLE.java b/parquet-plugins/parquet-encoding-vector/src/test/java/org/apache/parquet/column/values/bitpacking/TestByteBitPacking512VectorLE.java index 8122cbeb4d..eb19890be9 100644 --- a/parquet-plugins/parquet-encoding-vector/src/test/java/org/apache/parquet/column/values/bitpacking/TestByteBitPacking512VectorLE.java +++ b/parquet-plugins/parquet-encoding-vector/src/test/java/org/apache/parquet/column/values/bitpacking/TestByteBitPacking512VectorLE.java @@ -110,7 +110,7 @@ private void unpackValuesUsingVectorBitWidthDirect(int bitWidth) { directBuffer.put(byteOutput); directBuffer.flip(); unpackValuesUsingVectorByteBuffer(bitWidth, directBuffer, output); - assertArrayEquals(expected, output); + assertThat(output).isEqualTo(expected); Arrays.fill(output, 0); }); } @@ -138,7 +138,7 @@ private void unpackValuesUsingVectorBitWidthReadOnly(int bitWidth) { // Read-only heap ByteBuffer (hasArray() returns false) ByteBuffer readOnlyBuffer = ByteBuffer.wrap(byteOutput).asReadOnlyBuffer(); unpackValuesUsingVectorByteBuffer(bitWidth, readOnlyBuffer, output); - assertArrayEquals(expected, output); + assertThat(output).isEqualTo(expected); Arrays.fill(output, 0); }); }