-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-42101: [Java] Create File for Output Validation in FileRoundtrip #42115
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,12 @@ | |
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 java.io.File; | ||
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; | ||
|
@@ -32,6 +34,7 @@ | |
public class TestFileRoundtrip { | ||
|
||
@Rule public TemporaryFolder testFolder = new TemporaryFolder(); | ||
@Rule public TemporaryFolder testAnotherFolder = new TemporaryFolder(); | ||
|
||
private BufferAllocator allocator; | ||
|
||
|
@@ -58,4 +61,36 @@ public void test() throws Exception { | |
|
||
validateOutput(testOutFile, allocator); | ||
} | ||
|
||
@Test | ||
public void testDiffFolder() throws Exception { | ||
File testInFile = testFolder.newFile("testIn.arrow"); | ||
File testOutFile = testAnotherFolder.newFile("testOut.arrow"); | ||
|
||
writeInput(testInFile, allocator); | ||
|
||
String[] args = {"-i", testInFile.getAbsolutePath(), "-o", testOutFile.getAbsolutePath()}; | ||
int result = new FileRoundtrip(System.err).run(args); | ||
assertEquals(0, result); | ||
|
||
validateOutput(testOutFile, allocator); | ||
} | ||
|
||
@Test | ||
public void testNotPreparedInput() throws Exception { | ||
File testInFile = testFolder.newFile("testIn.arrow"); | ||
File testOutFile = testFolder.newFile("testOut.arrow"); | ||
|
||
String[] args = {"-i", testInFile.getAbsolutePath(), "-o", testOutFile.getAbsolutePath()}; | ||
|
||
// In JUnit 5, since the file itself is not created, the exception and message will be | ||
// different. | ||
Exception exception = | ||
assertThrows( | ||
InvalidArrowFileException.class, | ||
() -> { | ||
new FileRoundtrip(System.err).run(args); | ||
}); | ||
assertEquals("file too small: 0", exception.getMessage()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is actually being tested here? A 0-length input file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. In JUnit 5, I want to check for The code I wrote still works with JUnit 4 logic, so the tests don't write the input ( |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this PR is merged, changes will be needed to make it compatible with JUnit 5.
When using JUnit 5's
@TempDir
annotation, it was found that the logic works with non-existent files, causingIllegalArgumentException
with the messageinput file not found
.This seems to be due to differences in behavior between JUnit 4's
@TemporaryFolder
and JUnit 5's@TempDir
annotations.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM! Let's check the CIs.