This is an automated email from the ASF dual-hosted git repository.

lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new fef86d21ad GH-42092: [Java] Update Unit Tests for Tools Module (#42093)
fef86d21ad is described below

commit fef86d21ad9d6959607120a712b818a1738925bc
Author: Hyunseok Seo <hsseo0...@gmail.com>
AuthorDate: Tue Jun 18 08:56:03 2024 +0900

    GH-42092: [Java] Update Unit Tests for Tools Module (#42093)
    
    
    
    ### Rationale for this change
    
    Update package from JUnit 4(`org.junit`) to JUnit 5(`org.junit.jupiter`).
    
    ### What changes are included in this PR?
    
    - [x] Replacing org.junit with org.junit.jupiter.api.
    - [x] Updating Assertions.assertXXX to assertXXX using static imports.
    - [x] Updating annotations such as `@ Before`, `@ BeforeClass`, `@ After`, 
`@ AfterClass`, `@ Test`, `@ Rule`, `@ TemporaryFolder`
      - `@ Before` -> `@ BeforeEach`
      - `@ BeforeClass` -> `@ BeforeAll`
      - `@ After` -> `@ AfterEach`
      - `@ AfterClass` -> `@ AfterAll`
      - `@ Test` -> `@ Test` with `org.junit.jupiter`
      - `@ Rule`, `@ TemporaryFolder` -> `@ TempDir`
    - [x] Doing self review
    
    ### Are these changes tested?
    
    Yes, existing tests have passed.
    
    ### Are there any user-facing changes?
    
    No.
    
    * GitHub Issue: #42092
    
    Authored-by: Hyunseok Seo <hsseo0...@gmail.com>
    Signed-off-by: David Li <li.david...@gmail.com>
---
 .../apache/arrow/tools/ArrowFileTestFixtures.java  | 18 ++---
 .../org/apache/arrow/tools/EchoServerTest.java     | 86 +++++++++++-----------
 .../org/apache/arrow/tools/TestFileRoundtrip.java  | 58 ++++++++++-----
 .../org/apache/arrow/tools/TestIntegration.java    | 73 +++++++++---------
 4 files changed, 126 insertions(+), 109 deletions(-)

diff --git 
a/java/tools/src/test/java/org/apache/arrow/tools/ArrowFileTestFixtures.java 
b/java/tools/src/test/java/org/apache/arrow/tools/ArrowFileTestFixtures.java
index e9dd225dbd..03c1af3022 100644
--- a/java/tools/src/test/java/org/apache/arrow/tools/ArrowFileTestFixtures.java
+++ b/java/tools/src/test/java/org/apache/arrow/tools/ArrowFileTestFixtures.java
@@ -16,9 +16,10 @@
  */
 package org.apache.arrow.tools;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import org.apache.arrow.memory.BufferAllocator;
@@ -33,7 +34,6 @@ import org.apache.arrow.vector.complex.writer.IntWriter;
 import org.apache.arrow.vector.ipc.ArrowFileReader;
 import org.apache.arrow.vector.ipc.ArrowFileWriter;
 import org.apache.arrow.vector.ipc.message.ArrowBlock;
-import org.junit.Assert;
 
 public class ArrowFileTestFixtures {
   static final int COUNT = 10;
@@ -70,14 +70,14 @@ public class ArrowFileTestFixtures {
   }
 
   static void validateContent(int count, VectorSchemaRoot root) {
-    Assert.assertEquals(count, root.getRowCount());
+    assertEquals(count, root.getRowCount());
     for (int i = 0; i < count; i++) {
-      Assert.assertEquals(i, root.getVector("int").getObject(i));
-      Assert.assertEquals(Long.valueOf(i), 
root.getVector("bigInt").getObject(i));
+      assertEquals(i, root.getVector("int").getObject(i));
+      assertEquals(Long.valueOf(i), root.getVector("bigInt").getObject(i));
     }
   }
 
-  static void write(FieldVector parent, File file) throws 
FileNotFoundException, IOException {
+  static void write(FieldVector parent, File file) throws IOException {
     VectorSchemaRoot root = new VectorSchemaRoot(parent);
     try (FileOutputStream fileOutputStream = new FileOutputStream(file);
         ArrowFileWriter arrowWriter =
@@ -86,13 +86,11 @@ public class ArrowFileTestFixtures {
     }
   }
 
-  static void writeInput(File testInFile, BufferAllocator allocator)
-      throws FileNotFoundException, IOException {
-    int count = ArrowFileTestFixtures.COUNT;
+  static void writeInput(File testInFile, BufferAllocator allocator) throws 
IOException {
     try (BufferAllocator vectorAllocator =
             allocator.newChildAllocator("original vectors", 0, 
Integer.MAX_VALUE);
         NonNullableStructVector parent = 
NonNullableStructVector.empty("parent", vectorAllocator)) {
-      writeData(count, parent);
+      writeData(COUNT, parent);
       write(parent.getChild("root"), testInFile);
     }
   }
diff --git 
a/java/tools/src/test/java/org/apache/arrow/tools/EchoServerTest.java 
b/java/tools/src/test/java/org/apache/arrow/tools/EchoServerTest.java
index a38b12c5ae..239913ca4e 100644
--- a/java/tools/src/test/java/org/apache/arrow/tools/EchoServerTest.java
+++ b/java/tools/src/test/java/org/apache/arrow/tools/EchoServerTest.java
@@ -19,8 +19,11 @@ package org.apache.arrow.tools;
 import static java.util.Arrays.asList;
 import static org.apache.arrow.vector.types.Types.MinorType.TINYINT;
 import static org.apache.arrow.vector.types.Types.MinorType.VARCHAR;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import com.google.common.collect.ImmutableList;
 import java.io.IOException;
@@ -53,10 +56,9 @@ import org.apache.arrow.vector.types.pojo.Field;
 import org.apache.arrow.vector.types.pojo.FieldType;
 import org.apache.arrow.vector.types.pojo.Schema;
 import org.apache.arrow.vector.util.Text;
-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.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 public class EchoServerTest {
 
@@ -64,7 +66,7 @@ public class EchoServerTest {
   private static int serverPort;
   private static Thread serverThread;
 
-  @BeforeClass
+  @BeforeAll
   public static void startEchoServer() throws IOException {
     server = new EchoServer(0);
     serverPort = server.port();
@@ -82,7 +84,7 @@ public class EchoServerTest {
     serverThread.start();
   }
 
-  @AfterClass
+  @AfterAll
   public static void stopEchoServer() throws IOException, InterruptedException 
{
     server.close();
     serverThread.join();
@@ -113,7 +115,7 @@ public class EchoServerTest {
       TinyIntVector readVector =
           (TinyIntVector) 
reader.getVectorSchemaRoot().getFieldVectors().get(0);
       for (int i = 0; i < batches; i++) {
-        Assert.assertTrue(reader.loadNextBatch());
+        assertTrue(reader.loadNextBatch());
         assertEquals(16, reader.getVectorSchemaRoot().getRowCount());
         assertEquals(16, readVector.getValueCount());
         for (int j = 0; j < 8; j++) {
@@ -121,7 +123,7 @@ public class EchoServerTest {
           assertTrue(readVector.isNull(j + 8));
         }
       }
-      Assert.assertFalse(reader.loadNextBatch());
+      assertFalse(reader.loadNextBatch());
       assertEquals(0, reader.getVectorSchemaRoot().getRowCount());
       assertEquals(reader.bytesRead(), writer.bytesWritten());
     }
@@ -185,30 +187,30 @@ public class EchoServerTest {
 
         reader.loadNextBatch();
         VectorSchemaRoot readerRoot = reader.getVectorSchemaRoot();
-        Assert.assertEquals(6, readerRoot.getRowCount());
+        assertEquals(6, readerRoot.getRowCount());
 
         FieldVector readVector = readerRoot.getFieldVectors().get(0);
-        Assert.assertNotNull(readVector);
+        assertNotNull(readVector);
 
         DictionaryEncoding readEncoding = 
readVector.getField().getDictionary();
-        Assert.assertNotNull(readEncoding);
-        Assert.assertEquals(1L, readEncoding.getId());
+        assertNotNull(readEncoding);
+        assertEquals(1L, readEncoding.getId());
 
-        Assert.assertEquals(6, readVector.getValueCount());
-        Assert.assertEquals(0, readVector.getObject(0));
-        Assert.assertEquals(1, readVector.getObject(1));
-        Assert.assertEquals(null, readVector.getObject(2));
-        Assert.assertEquals(2, readVector.getObject(3));
-        Assert.assertEquals(1, readVector.getObject(4));
-        Assert.assertEquals(2, readVector.getObject(5));
+        assertEquals(6, readVector.getValueCount());
+        assertEquals(0, readVector.getObject(0));
+        assertEquals(1, readVector.getObject(1));
+        assertEquals(null, readVector.getObject(2));
+        assertEquals(2, readVector.getObject(3));
+        assertEquals(1, readVector.getObject(4));
+        assertEquals(2, readVector.getObject(5));
 
         Dictionary dictionary = reader.lookup(1L);
-        Assert.assertNotNull(dictionary);
+        assertNotNull(dictionary);
         VarCharVector dictionaryVector = ((VarCharVector) 
dictionary.getVector());
-        Assert.assertEquals(3, dictionaryVector.getValueCount());
-        Assert.assertEquals(new Text("foo"), dictionaryVector.getObject(0));
-        Assert.assertEquals(new Text("bar"), dictionaryVector.getObject(1));
-        Assert.assertEquals(new Text("baz"), dictionaryVector.getObject(2));
+        assertEquals(3, dictionaryVector.getValueCount());
+        assertEquals(new Text("foo"), dictionaryVector.getObject(0));
+        assertEquals(new Text("bar"), dictionaryVector.getObject(1));
+        assertEquals(new Text("baz"), dictionaryVector.getObject(2));
       }
     }
   }
@@ -261,35 +263,35 @@ public class EchoServerTest {
 
         reader.loadNextBatch();
         VectorSchemaRoot readerRoot = reader.getVectorSchemaRoot();
-        Assert.assertEquals(3, readerRoot.getRowCount());
+        assertEquals(3, readerRoot.getRowCount());
 
         ListVector readVector = (ListVector) 
readerRoot.getFieldVectors().get(0);
-        Assert.assertNotNull(readVector);
+        assertNotNull(readVector);
 
-        Assert.assertNull(readVector.getField().getDictionary());
+        assertNull(readVector.getField().getDictionary());
         DictionaryEncoding readEncoding =
             readVector.getField().getChildren().get(0).getDictionary();
-        Assert.assertNotNull(readEncoding);
-        Assert.assertEquals(2L, readEncoding.getId());
+        assertNotNull(readEncoding);
+        assertEquals(2L, readEncoding.getId());
 
         Field nestedField = readVector.getField().getChildren().get(0);
 
         DictionaryEncoding encoding = nestedField.getDictionary();
-        Assert.assertNotNull(encoding);
-        Assert.assertEquals(2L, encoding.getId());
-        Assert.assertEquals(new Int(32, true), encoding.getIndexType());
+        assertNotNull(encoding);
+        assertEquals(2L, encoding.getId());
+        assertEquals(new Int(32, true), encoding.getIndexType());
 
-        Assert.assertEquals(3, readVector.getValueCount());
-        Assert.assertEquals(Arrays.asList(0, 1), readVector.getObject(0));
-        Assert.assertEquals(Arrays.asList(0), readVector.getObject(1));
-        Assert.assertEquals(Arrays.asList(1), readVector.getObject(2));
+        assertEquals(3, readVector.getValueCount());
+        assertEquals(Arrays.asList(0, 1), readVector.getObject(0));
+        assertEquals(Arrays.asList(0), readVector.getObject(1));
+        assertEquals(Arrays.asList(1), readVector.getObject(2));
 
         Dictionary readDictionary = reader.lookup(2L);
-        Assert.assertNotNull(readDictionary);
+        assertNotNull(readDictionary);
         VarCharVector dictionaryVector = ((VarCharVector) 
readDictionary.getVector());
-        Assert.assertEquals(2, dictionaryVector.getValueCount());
-        Assert.assertEquals(new Text("foo"), dictionaryVector.getObject(0));
-        Assert.assertEquals(new Text("bar"), dictionaryVector.getObject(1));
+        assertEquals(2, dictionaryVector.getValueCount());
+        assertEquals(new Text("foo"), dictionaryVector.getObject(0));
+        assertEquals(new Text("bar"), dictionaryVector.getObject(1));
       }
     }
   }
diff --git 
a/java/tools/src/test/java/org/apache/arrow/tools/TestFileRoundtrip.java 
b/java/tools/src/test/java/org/apache/arrow/tools/TestFileRoundtrip.java
index a98fefeea7..5839f50383 100644
--- a/java/tools/src/test/java/org/apache/arrow/tools/TestFileRoundtrip.java
+++ b/java/tools/src/test/java/org/apache/arrow/tools/TestFileRoundtrip.java
@@ -18,40 +18,41 @@ package org.apache.arrow.tools;
 
 import static org.apache.arrow.tools.ArrowFileTestFixtures.validateOutput;
 import static org.apache.arrow.tools.ArrowFileTestFixtures.writeInput;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.File;
+import java.io.FileOutputStream;
 import org.apache.arrow.memory.BufferAllocator;
 import org.apache.arrow.memory.RootAllocator;
 import org.apache.arrow.vector.ipc.InvalidArrowFileException;
-import org.junit.After;
-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.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 public class TestFileRoundtrip {
 
-  @Rule public TemporaryFolder testFolder = new TemporaryFolder();
-  @Rule public TemporaryFolder testAnotherFolder = new TemporaryFolder();
+  @TempDir public File testFolder;
+  @TempDir public File testAnotherFolder;
 
   private BufferAllocator allocator;
 
-  @Before
+  @BeforeEach
   public void init() {
     allocator = new RootAllocator(Integer.MAX_VALUE);
   }
 
-  @After
+  @AfterEach
   public void tearDown() {
     allocator.close();
   }
 
   @Test
   public void test() throws Exception {
-    File testInFile = testFolder.newFile("testIn.arrow");
-    File testOutFile = testFolder.newFile("testOut.arrow");
+    File testInFile = new File(testFolder, "testIn.arrow");
+    File testOutFile = new File(testFolder, "testOut.arrow");
 
     writeInput(testInFile, allocator);
 
@@ -64,8 +65,8 @@ public class TestFileRoundtrip {
 
   @Test
   public void testDiffFolder() throws Exception {
-    File testInFile = testFolder.newFile("testIn.arrow");
-    File testOutFile = testAnotherFolder.newFile("testOut.arrow");
+    File testInFile = new File(testFolder, "testIn.arrow");
+    File testOutFile = new File(testAnotherFolder, "testOut.arrow");
 
     writeInput(testInFile, allocator);
 
@@ -77,20 +78,37 @@ public class TestFileRoundtrip {
   }
 
   @Test
-  public void testNotPreparedInput() throws Exception {
-    File testInFile = testFolder.newFile("testIn.arrow");
-    File testOutFile = testFolder.newFile("testOut.arrow");
+  public void testNotFoundInput() {
+    File testInFile = new File(testFolder, "testIn.arrow");
+    File testOutFile = new File(testFolder, "testOut.arrow");
 
     String[] args = {"-i", testInFile.getAbsolutePath(), "-o", 
testOutFile.getAbsolutePath()};
+    Exception exception =
+        assertThrows(
+            IllegalArgumentException.class,
+            () -> {
+              new FileRoundtrip(System.err).run(args);
+            });
+
+    assertTrue(exception.getMessage().contains("input file not found"));
+  }
+
+  @Test
+  public void testSmallSizeInput() throws Exception {
+    File testInFile = new File(testFolder, "testIn.arrow");
+    File testOutFile = new File(testFolder, "testOut.arrow");
 
-    // In JUnit 5, since the file itself is not created, the exception and 
message will be
-    // different.
+    // create an empty file
+    new FileOutputStream(testInFile).close();
+
+    String[] args = {"-i", testInFile.getAbsolutePath(), "-o", 
testOutFile.getAbsolutePath()};
     Exception exception =
         assertThrows(
             InvalidArrowFileException.class,
             () -> {
               new FileRoundtrip(System.err).run(args);
             });
+
     assertEquals("file too small: 0", exception.getMessage());
   }
 }
diff --git 
a/java/tools/src/test/java/org/apache/arrow/tools/TestIntegration.java 
b/java/tools/src/test/java/org/apache/arrow/tools/TestIntegration.java
index db74739480..e7f59b628b 100644
--- a/java/tools/src/test/java/org/apache/arrow/tools/TestIntegration.java
+++ b/java/tools/src/test/java/org/apache/arrow/tools/TestIntegration.java
@@ -20,9 +20,9 @@ import static 
org.apache.arrow.tools.ArrowFileTestFixtures.validateOutput;
 import static org.apache.arrow.tools.ArrowFileTestFixtures.write;
 import static org.apache.arrow.tools.ArrowFileTestFixtures.writeData;
 import static org.apache.arrow.tools.ArrowFileTestFixtures.writeInput;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
 import com.fasterxml.jackson.core.util.DefaultPrettyPrinter.NopIndenter;
@@ -30,7 +30,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.StringReader;
 import java.util.Map;
@@ -44,15 +43,14 @@ import 
org.apache.arrow.vector.complex.writer.BaseWriter.StructWriter;
 import org.apache.arrow.vector.complex.writer.BigIntWriter;
 import org.apache.arrow.vector.complex.writer.Float8Writer;
 import org.apache.arrow.vector.complex.writer.IntWriter;
-import org.junit.After;
-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.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 public class TestIntegration {
 
-  @Rule public TemporaryFolder testFolder = new TemporaryFolder();
+  @TempDir public File testFolder;
 
   private BufferAllocator allocator;
   private ObjectMapper om = new ObjectMapper();
@@ -66,7 +64,7 @@ public class TestIntegration {
   }
 
   static void writeInputFloat(File testInFile, BufferAllocator allocator, 
double... f)
-      throws FileNotFoundException, IOException {
+      throws IOException {
     try (BufferAllocator vectorAllocator =
             allocator.newChildAllocator("original vectors", 0, 
Integer.MAX_VALUE);
         NonNullableStructVector parent = 
NonNullableStructVector.empty("parent", vectorAllocator)) {
@@ -82,8 +80,7 @@ public class TestIntegration {
     }
   }
 
-  static void writeInput2(File testInFile, BufferAllocator allocator)
-      throws FileNotFoundException, IOException {
+  static void writeInput2(File testInFile, BufferAllocator allocator) throws 
IOException {
     int count = ArrowFileTestFixtures.COUNT;
     try (BufferAllocator vectorAllocator =
             allocator.newChildAllocator("original vectors", 0, 
Integer.MAX_VALUE);
@@ -102,22 +99,22 @@ public class TestIntegration {
     }
   }
 
-  @Before
+  @BeforeEach
   public void init() {
     allocator = new RootAllocator(Integer.MAX_VALUE);
   }
 
-  @After
+  @AfterEach
   public void tearDown() {
     allocator.close();
   }
 
   @Test
   public void testValid() throws Exception {
-    File testInFile = testFolder.newFile("testIn.arrow");
-    File testJSONFile = testFolder.newFile("testOut.json");
+    File testInFile = new File(testFolder, "testIn.arrow");
+    File testJSONFile = new File(testFolder, "testOut.json");
     testJSONFile.delete();
-    File testOutFile = testFolder.newFile("testOut.arrow");
+    File testOutFile = new File(testFolder, "testOut.arrow");
     testOutFile.delete();
 
     // generate an arrow file
@@ -170,8 +167,8 @@ public class TestIntegration {
     if (!testJSONFile.exists()) {
       testJSONFile = new 
File("../docs/source/format/integration_json_examples/simple.json");
     }
-    File testOutFile = testFolder.newFile("testOut.arrow");
-    File testRoundTripJSONFile = testFolder.newFile("testOut.json");
+    File testOutFile = new File(testFolder, "testOut.arrow");
+    File testRoundTripJSONFile = new File(testFolder, "testOut.json");
     testOutFile.delete();
     testRoundTripJSONFile.delete();
 
@@ -205,7 +202,7 @@ public class TestIntegration {
     String o;
     int j = 0;
     while ((i = orig.readLine()) != null && (o = rt.readLine()) != null) {
-      assertEquals("line: " + j, i, o);
+      assertEquals(i, o, "line: " + j);
       ++j;
     }
   }
@@ -218,8 +215,8 @@ public class TestIntegration {
     if (!testJSONFile.exists()) {
       testJSONFile = new 
File("../docs/source/format/integration_json_examples/struct.json");
     }
-    File testOutFile = testFolder.newFile("testOutStruct.arrow");
-    File testRoundTripJSONFile = testFolder.newFile("testOutStruct.json");
+    File testOutFile = new File(testFolder, "testOutStruct.arrow");
+    File testRoundTripJSONFile = new File(testFolder, "testOutStruct.json");
     testOutFile.delete();
     testRoundTripJSONFile.delete();
 
@@ -253,7 +250,7 @@ public class TestIntegration {
     String o;
     int j = 0;
     while ((i = orig.readLine()) != null && (o = rt.readLine()) != null) {
-      assertEquals("line: " + j, i, o);
+      assertEquals(i, o, "line: " + j);
       ++j;
     }
   }
@@ -267,9 +264,9 @@ public class TestIntegration {
   /** The test should not be sensitive to small variations in float 
representation. */
   @Test
   public void testFloat() throws Exception {
-    File testValidInFile = testFolder.newFile("testValidFloatIn.arrow");
-    File testInvalidInFile = testFolder.newFile("testAlsoValidFloatIn.arrow");
-    File testJSONFile = testFolder.newFile("testValidOut.json");
+    File testValidInFile = new File(testFolder, "testValidFloatIn.arrow");
+    File testInvalidInFile = new File(testFolder, 
"testAlsoValidFloatIn.arrow");
+    File testJSONFile = new File(testFolder, "testValidOut.json");
     testJSONFile.delete();
 
     // generate an arrow file
@@ -305,9 +302,9 @@ public class TestIntegration {
 
   @Test
   public void testInvalid() throws Exception {
-    File testValidInFile = testFolder.newFile("testValidIn.arrow");
-    File testInvalidInFile = testFolder.newFile("testInvalidIn.arrow");
-    File testJSONFile = testFolder.newFile("testInvalidOut.json");
+    File testValidInFile = new File(testFolder, "testValidIn.arrow");
+    File testInvalidInFile = new File(testFolder, "testInvalidIn.arrow");
+    File testJSONFile = new File(testFolder, "testInvalidOut.json");
     testJSONFile.delete();
 
     // generate an arrow file
@@ -338,12 +335,14 @@ public class TestIntegration {
       Command.VALIDATE.name()
     };
     // this should fail
-    try {
-      integration.run(args3);
-      fail("should have failed");
-    } catch (IllegalArgumentException e) {
-      assertTrue(e.getMessage(), e.getMessage().contains("Different values in 
column"));
-      assertTrue(e.getMessage(), e.getMessage().contains("999"));
-    }
+    IllegalArgumentException e =
+        assertThrows(
+            IllegalArgumentException.class,
+            () -> {
+              integration.run(args3);
+            });
+
+    assertTrue(e.getMessage().contains("Different values in column"), 
e.getMessage());
+    assertTrue(e.getMessage().contains("999"), e.getMessage());
   }
 }

Reply via email to