From d34ccaf6137e9a865c1598f818a954bedf476848 Mon Sep 17 00:00:00 2001 From: Kousuke Saruta Date: Thu, 21 Sep 2023 01:05:15 +0900 Subject: [PATCH 1/3] AVRO-3863: [Java] Delete temporary test data after tests finish --- .../src/test/java/org/apache/avro/TestDataFileReader.java | 5 +++++ .../avro/src/test/java/org/apache/avro/io/TestEncoders.java | 1 + .../java/org/apache/avro/tool/TestCreateRandomFileTool.java | 6 ++++++ .../test/java/org/apache/avro/tool/TestToTrevniTool.java | 6 ++++++ 4 files changed, 18 insertions(+) diff --git a/lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java b/lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java index a85b966409b..37f3a456e85 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java +++ b/lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java @@ -91,6 +91,7 @@ void throttledInputStream() throws IOException { .parse("{\"type\": \"record\", \"name\": \"TestSchema\", \"fields\": " + "[ {\"name\": \"id\", \"type\": [\"long\", \"null\"], \"default\": null}]}"); File f = Files.createTempFile("testThrottledInputStream", ".avro").toFile(); + f.deleteOnExit(); try (DataFileWriter w = new DataFileWriter<>(new GenericDatumWriter<>())) { w.create(legacySchema, f); w.flush(); @@ -150,6 +151,7 @@ void inputStreamEOF() throws IOException { .parse("{\"type\": \"record\", \"name\": \"TestSchema\", \"fields\": " + "[ {\"name\": \"id\", \"type\": [\"long\", \"null\"], \"default\": null}]}"); File f = Files.createTempFile("testInputStreamEOF", ".avro").toFile(); + f.deleteOnExit(); try (DataFileWriter w = new DataFileWriter<>(new GenericDatumWriter<>())) { w.create(legacySchema, f); w.flush(); @@ -201,6 +203,7 @@ void ignoreSchemaValidationOnRead() throws IOException { // Create a file with the legacy schema. File f = Files.createTempFile("testIgnoreSchemaValidationOnRead", ".avro").toFile(); + f.deleteOnExit(); try (DataFileWriter w = new DataFileWriter<>(new GenericDatumWriter<>())) { w.create(legacySchema, f); w.flush(); @@ -215,6 +218,7 @@ void ignoreSchemaValidationOnRead() throws IOException { @Test void invalidMagicLength() throws IOException { File f = Files.createTempFile("testInvalidMagicLength", ".avro").toFile(); + f.deleteOnExit(); try (FileWriter w = new FileWriter(f)) { w.write("-"); } @@ -227,6 +231,7 @@ void invalidMagicLength() throws IOException { @Test void invalidMagicBytes() throws IOException { File f = Files.createTempFile("testInvalidMagicBytes", ".avro").toFile(); + f.deleteOnExit(); try (FileWriter w = new FileWriter(f)) { w.write("invalid"); } diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java b/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java index dbed64d6a18..dcc37415b49 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java +++ b/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java @@ -262,6 +262,7 @@ void arrayBackedByteBuffer() throws IOException { @Test void mappedByteBuffer() throws IOException { Path file = Paths.get(DIR.getPath() + "testMappedByteBuffer.avro"); + file.toFile().deleteOnExit(); Files.write(file, someBytes(EXAMPLE_DATA_SIZE)); MappedByteBuffer buffer = FileChannel.open(file, StandardOpenOption.READ).map(FileChannel.MapMode.READ_ONLY, 0, EXAMPLE_DATA_SIZE); diff --git a/lang/java/tools/src/test/java/org/apache/avro/tool/TestCreateRandomFileTool.java b/lang/java/tools/src/test/java/org/apache/avro/tool/TestCreateRandomFileTool.java index 838fec3ce30..ce4f79c5616 100644 --- a/lang/java/tools/src/test/java/org/apache/avro/tool/TestCreateRandomFileTool.java +++ b/lang/java/tools/src/test/java/org/apache/avro/tool/TestCreateRandomFileTool.java @@ -34,6 +34,7 @@ import org.apache.avro.util.RandomData; import org.apache.trevni.TestUtil; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -66,6 +67,11 @@ public void after() throws Exception { err.close(); } + @AfterAll + public static void afterAll() throws Exception { + OUT_FILE.delete(); + } + private int run(List args) throws Exception { PrintStream output = new PrintStream(out); PrintStream saveOut = System.out; diff --git a/lang/java/tools/src/test/java/org/apache/avro/tool/TestToTrevniTool.java b/lang/java/tools/src/test/java/org/apache/avro/tool/TestToTrevniTool.java index 4fd0f718911..e8e6f3383fa 100644 --- a/lang/java/tools/src/test/java/org/apache/avro/tool/TestToTrevniTool.java +++ b/lang/java/tools/src/test/java/org/apache/avro/tool/TestToTrevniTool.java @@ -30,6 +30,7 @@ import org.apache.avro.generic.GenericDatumWriter; import org.apache.avro.util.RandomData; import org.apache.trevni.avro.AvroColumnReader; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; public class TestToTrevniTool { @@ -41,6 +42,11 @@ public class TestToTrevniTool { private static final File TREVNI_FILE = new File(DIR, "random.trv"); private static final File SCHEMA_FILE = new File("../../../share/test/schemas/weather.avsc"); + @AfterAll + public static void afterAll() throws Exception { + AVRO_FILE.delete(); + } + private String run(String... args) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream p = new PrintStream(baos); From c7a0749b0e163a5d6c83fdd30917a9ddf68f44a1 Mon Sep 17 00:00:00 2001 From: Kousuke Saruta Date: Thu, 21 Sep 2023 04:58:06 +0900 Subject: [PATCH 2/3] Use @TempDir --- .../org/apache/avro/TestDataFileReader.java | 18 +++++++-------- .../java/org/apache/avro/io/TestEncoders.java | 5 ++--- .../avro/tool/TestCreateRandomFileTool.java | 21 +++++++++--------- .../apache/avro/tool/TestToTrevniTool.java | 22 +++++++++---------- 4 files changed, 30 insertions(+), 36 deletions(-) diff --git a/lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java b/lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java index 37f3a456e85..91e4a41d273 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java +++ b/lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java @@ -38,9 +38,12 @@ import org.apache.avro.generic.GenericDatumReader; import org.apache.avro.generic.GenericDatumWriter; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; @SuppressWarnings("restriction") public class TestDataFileReader { + @TempDir + public Path DATA_DIR; // regression test for bug AVRO-2286 @Test @@ -90,8 +93,7 @@ void throttledInputStream() throws IOException { Schema legacySchema = new Schema.Parser(Schema.NameValidator.NO_VALIDATION).setValidateDefaults(false) .parse("{\"type\": \"record\", \"name\": \"TestSchema\", \"fields\": " + "[ {\"name\": \"id\", \"type\": [\"long\", \"null\"], \"default\": null}]}"); - File f = Files.createTempFile("testThrottledInputStream", ".avro").toFile(); - f.deleteOnExit(); + File f = DATA_DIR.resolve("testThrottledInputStream.avro").toFile(); try (DataFileWriter w = new DataFileWriter<>(new GenericDatumWriter<>())) { w.create(legacySchema, f); w.flush(); @@ -150,8 +152,7 @@ void inputStreamEOF() throws IOException { Schema legacySchema = new Schema.Parser(Schema.NameValidator.NO_VALIDATION).setValidateDefaults(false) .parse("{\"type\": \"record\", \"name\": \"TestSchema\", \"fields\": " + "[ {\"name\": \"id\", \"type\": [\"long\", \"null\"], \"default\": null}]}"); - File f = Files.createTempFile("testInputStreamEOF", ".avro").toFile(); - f.deleteOnExit(); + File f = DATA_DIR.resolve("testInputStreamEOF.avro").toFile(); try (DataFileWriter w = new DataFileWriter<>(new GenericDatumWriter<>())) { w.create(legacySchema, f); w.flush(); @@ -202,8 +203,7 @@ void ignoreSchemaValidationOnRead() throws IOException { + "[ {\"name\": \"id\", \"type\": [\"long\", \"null\"], \"default\": null}]}"); // Create a file with the legacy schema. - File f = Files.createTempFile("testIgnoreSchemaValidationOnRead", ".avro").toFile(); - f.deleteOnExit(); + File f = DATA_DIR.resolve("testIgnoreSchemaValidationOnRead.avro").toFile(); try (DataFileWriter w = new DataFileWriter<>(new GenericDatumWriter<>())) { w.create(legacySchema, f); w.flush(); @@ -217,8 +217,7 @@ void ignoreSchemaValidationOnRead() throws IOException { @Test void invalidMagicLength() throws IOException { - File f = Files.createTempFile("testInvalidMagicLength", ".avro").toFile(); - f.deleteOnExit(); + File f = DATA_DIR.resolve("testInvalidMagicLength.avro").toFile(); try (FileWriter w = new FileWriter(f)) { w.write("-"); } @@ -230,8 +229,7 @@ void invalidMagicLength() throws IOException { @Test void invalidMagicBytes() throws IOException { - File f = Files.createTempFile("testInvalidMagicBytes", ".avro").toFile(); - f.deleteOnExit(); + File f = DATA_DIR.resolve("testInvalidMagicBytes.avro").toFile(); try (FileWriter w = new FileWriter(f)) { w.write("invalid"); } diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java b/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java index dcc37415b49..ebd6659a42f 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java +++ b/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java @@ -57,7 +57,7 @@ public class TestEncoders { private static EncoderFactory factory = EncoderFactory.get(); @TempDir - public File DIR; + public Path DIR; @Test void binaryEncoderInit() throws IOException { @@ -261,8 +261,7 @@ void arrayBackedByteBuffer() throws IOException { @Test void mappedByteBuffer() throws IOException { - Path file = Paths.get(DIR.getPath() + "testMappedByteBuffer.avro"); - file.toFile().deleteOnExit(); + Path file = DIR.resolve("testMappedByteBuffer.avro"); Files.write(file, someBytes(EXAMPLE_DATA_SIZE)); MappedByteBuffer buffer = FileChannel.open(file, StandardOpenOption.READ).map(FileChannel.MapMode.READ_ONLY, 0, EXAMPLE_DATA_SIZE); diff --git a/lang/java/tools/src/test/java/org/apache/avro/tool/TestCreateRandomFileTool.java b/lang/java/tools/src/test/java/org/apache/avro/tool/TestCreateRandomFileTool.java index ce4f79c5616..c28d8983324 100644 --- a/lang/java/tools/src/test/java/org/apache/avro/tool/TestCreateRandomFileTool.java +++ b/lang/java/tools/src/test/java/org/apache/avro/tool/TestCreateRandomFileTool.java @@ -21,6 +21,7 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.PrintStream; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -34,18 +35,19 @@ import org.apache.avro.util.RandomData; import org.apache.trevni.TestUtil; -import org.junit.jupiter.api.AfterAll; 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; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; public class TestCreateRandomFileTool { private static final String COUNT = System.getProperty("test.count", "200"); - private static final File DIR = new File("/tmp"); - private static final File OUT_FILE = new File(DIR, "random.avro"); + + @TempDir + private Path DIR; private static final File SCHEMA_FILE = new File("../../../share/test/schemas/weather.avsc"); private final Schema.Parser schemaParser = new Schema.Parser(); @@ -67,11 +69,6 @@ public void after() throws Exception { err.close(); } - @AfterAll - public static void afterAll() throws Exception { - OUT_FILE.delete(); - } - private int run(List args) throws Exception { PrintStream output = new PrintStream(out); PrintStream saveOut = System.out; @@ -89,12 +86,13 @@ private int run(List args) throws Exception { private void check(String... extraArgs) throws Exception { ArrayList args = new ArrayList<>(); - args.addAll(Arrays.asList(OUT_FILE.toString(), "--count", COUNT, "--schema-file", SCHEMA_FILE.toString(), "--seed", + File outFile = DIR.resolve("random.avro").toFile(); + args.addAll(Arrays.asList(outFile.toString(), "--count", COUNT, "--schema-file", SCHEMA_FILE.toString(), "--seed", Long.toString(SEED))); args.addAll(Arrays.asList(extraArgs)); run(args); - DataFileReader reader = new DataFileReader<>(OUT_FILE, new GenericDatumReader<>()); + DataFileReader reader = new DataFileReader<>(outFile, new GenericDatumReader<>()); Iterator found = reader.iterator(); for (Object expected : new RandomData(schemaParser.parse(SCHEMA_FILE), Integer.parseInt(COUNT), SEED)) @@ -105,8 +103,9 @@ private void check(String... extraArgs) throws Exception { private void checkMissingCount(String... extraArgs) throws Exception { ArrayList args = new ArrayList<>(); + File outFile = DIR.resolve("random.avro").toFile(); args.addAll( - Arrays.asList(OUT_FILE.toString(), "--schema-file", SCHEMA_FILE.toString(), "--seed", Long.toString(SEED))); + Arrays.asList(outFile.toString(), "--schema-file", SCHEMA_FILE.toString(), "--seed", Long.toString(SEED))); args.addAll(Arrays.asList(extraArgs)); run(args); assertTrue(err.toString().contains("Need count (--count)")); diff --git a/lang/java/tools/src/test/java/org/apache/avro/tool/TestToTrevniTool.java b/lang/java/tools/src/test/java/org/apache/avro/tool/TestToTrevniTool.java index e8e6f3383fa..136aeb36592 100644 --- a/lang/java/tools/src/test/java/org/apache/avro/tool/TestToTrevniTool.java +++ b/lang/java/tools/src/test/java/org/apache/avro/tool/TestToTrevniTool.java @@ -22,6 +22,7 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.PrintStream; +import java.nio.file.Path; import java.util.Arrays; import java.util.Iterator; @@ -30,22 +31,17 @@ import org.apache.avro.generic.GenericDatumWriter; import org.apache.avro.util.RandomData; import org.apache.trevni.avro.AvroColumnReader; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class TestToTrevniTool { private static final long SEED = System.currentTimeMillis(); private static final int COUNT = Integer.parseInt(System.getProperty("test.count", "200")); - private static final File DIR = new File("/tmp"); - private static final File AVRO_FILE = new File(DIR, "random.avro"); - private static final File TREVNI_FILE = new File(DIR, "random.trv"); - private static final File SCHEMA_FILE = new File("../../../share/test/schemas/weather.avsc"); - @AfterAll - public static void afterAll() throws Exception { - AVRO_FILE.delete(); - } + @TempDir + private Path DIR; + private static final File SCHEMA_FILE = new File("../../../share/test/schemas/weather.avsc"); private String run(String... args) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -59,14 +55,16 @@ void test() throws Exception { Schema schema = new Schema.Parser().parse(SCHEMA_FILE); DataFileWriter writer = new DataFileWriter<>(new GenericDatumWriter<>()); - writer.create(schema, Util.createFromFS(AVRO_FILE.toString())); + File avroFile = DIR.resolve("random.avro").toFile(); + writer.create(schema, avroFile); for (Object datum : new RandomData(schema, COUNT, SEED)) writer.append(datum); writer.close(); - run(AVRO_FILE.toString(), TREVNI_FILE.toString()); + File trevniFile = DIR.resolve("random.trv").toFile(); + run(avroFile.toString(), trevniFile.toString()); - AvroColumnReader reader = new AvroColumnReader<>(new AvroColumnReader.Params(TREVNI_FILE)); + AvroColumnReader reader = new AvroColumnReader<>(new AvroColumnReader.Params(trevniFile)); Iterator found = reader.iterator(); for (Object expected : new RandomData(schema, COUNT, SEED)) assertEquals(expected, found.next()); From 37e22d1a59b7226bdc74202293f5414ea3e05658 Mon Sep 17 00:00:00 2001 From: Kousuke Saruta Date: Mon, 25 Sep 2023 01:50:35 +0900 Subject: [PATCH 3/3] Align Java naming convention --- .../java/org/apache/avro/TestDataFileReader.java | 12 ++++++------ .../test/java/org/apache/avro/io/TestEncoders.java | 4 ++-- .../apache/avro/tool/TestCreateRandomFileTool.java | 6 +++--- .../java/org/apache/avro/tool/TestToTrevniTool.java | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java b/lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java index 91e4a41d273..4b4f1c2d35a 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java +++ b/lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java @@ -43,7 +43,7 @@ @SuppressWarnings("restriction") public class TestDataFileReader { @TempDir - public Path DATA_DIR; + public Path dataDir; // regression test for bug AVRO-2286 @Test @@ -93,7 +93,7 @@ void throttledInputStream() throws IOException { Schema legacySchema = new Schema.Parser(Schema.NameValidator.NO_VALIDATION).setValidateDefaults(false) .parse("{\"type\": \"record\", \"name\": \"TestSchema\", \"fields\": " + "[ {\"name\": \"id\", \"type\": [\"long\", \"null\"], \"default\": null}]}"); - File f = DATA_DIR.resolve("testThrottledInputStream.avro").toFile(); + File f = dataDir.resolve("testThrottledInputStream.avro").toFile(); try (DataFileWriter w = new DataFileWriter<>(new GenericDatumWriter<>())) { w.create(legacySchema, f); w.flush(); @@ -152,7 +152,7 @@ void inputStreamEOF() throws IOException { Schema legacySchema = new Schema.Parser(Schema.NameValidator.NO_VALIDATION).setValidateDefaults(false) .parse("{\"type\": \"record\", \"name\": \"TestSchema\", \"fields\": " + "[ {\"name\": \"id\", \"type\": [\"long\", \"null\"], \"default\": null}]}"); - File f = DATA_DIR.resolve("testInputStreamEOF.avro").toFile(); + File f = dataDir.resolve("testInputStreamEOF.avro").toFile(); try (DataFileWriter w = new DataFileWriter<>(new GenericDatumWriter<>())) { w.create(legacySchema, f); w.flush(); @@ -203,7 +203,7 @@ void ignoreSchemaValidationOnRead() throws IOException { + "[ {\"name\": \"id\", \"type\": [\"long\", \"null\"], \"default\": null}]}"); // Create a file with the legacy schema. - File f = DATA_DIR.resolve("testIgnoreSchemaValidationOnRead.avro").toFile(); + File f = dataDir.resolve("testIgnoreSchemaValidationOnRead.avro").toFile(); try (DataFileWriter w = new DataFileWriter<>(new GenericDatumWriter<>())) { w.create(legacySchema, f); w.flush(); @@ -217,7 +217,7 @@ void ignoreSchemaValidationOnRead() throws IOException { @Test void invalidMagicLength() throws IOException { - File f = DATA_DIR.resolve("testInvalidMagicLength.avro").toFile(); + File f = dataDir.resolve("testInvalidMagicLength.avro").toFile(); try (FileWriter w = new FileWriter(f)) { w.write("-"); } @@ -229,7 +229,7 @@ void invalidMagicLength() throws IOException { @Test void invalidMagicBytes() throws IOException { - File f = DATA_DIR.resolve("testInvalidMagicBytes.avro").toFile(); + File f = dataDir.resolve("testInvalidMagicBytes.avro").toFile(); try (FileWriter w = new FileWriter(f)) { w.write("invalid"); } diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java b/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java index ebd6659a42f..2995bf56709 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java +++ b/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java @@ -57,7 +57,7 @@ public class TestEncoders { private static EncoderFactory factory = EncoderFactory.get(); @TempDir - public Path DIR; + public Path dataDir; @Test void binaryEncoderInit() throws IOException { @@ -261,7 +261,7 @@ void arrayBackedByteBuffer() throws IOException { @Test void mappedByteBuffer() throws IOException { - Path file = DIR.resolve("testMappedByteBuffer.avro"); + Path file = dataDir.resolve("testMappedByteBuffer.avro"); Files.write(file, someBytes(EXAMPLE_DATA_SIZE)); MappedByteBuffer buffer = FileChannel.open(file, StandardOpenOption.READ).map(FileChannel.MapMode.READ_ONLY, 0, EXAMPLE_DATA_SIZE); diff --git a/lang/java/tools/src/test/java/org/apache/avro/tool/TestCreateRandomFileTool.java b/lang/java/tools/src/test/java/org/apache/avro/tool/TestCreateRandomFileTool.java index c28d8983324..c0503862b38 100644 --- a/lang/java/tools/src/test/java/org/apache/avro/tool/TestCreateRandomFileTool.java +++ b/lang/java/tools/src/test/java/org/apache/avro/tool/TestCreateRandomFileTool.java @@ -47,7 +47,7 @@ public class TestCreateRandomFileTool { private static final String COUNT = System.getProperty("test.count", "200"); @TempDir - private Path DIR; + private Path dataDir; private static final File SCHEMA_FILE = new File("../../../share/test/schemas/weather.avsc"); private final Schema.Parser schemaParser = new Schema.Parser(); @@ -86,7 +86,7 @@ private int run(List args) throws Exception { private void check(String... extraArgs) throws Exception { ArrayList args = new ArrayList<>(); - File outFile = DIR.resolve("random.avro").toFile(); + File outFile = dataDir.resolve("random.avro").toFile(); args.addAll(Arrays.asList(outFile.toString(), "--count", COUNT, "--schema-file", SCHEMA_FILE.toString(), "--seed", Long.toString(SEED))); args.addAll(Arrays.asList(extraArgs)); @@ -103,7 +103,7 @@ private void check(String... extraArgs) throws Exception { private void checkMissingCount(String... extraArgs) throws Exception { ArrayList args = new ArrayList<>(); - File outFile = DIR.resolve("random.avro").toFile(); + File outFile = dataDir.resolve("random.avro").toFile(); args.addAll( Arrays.asList(outFile.toString(), "--schema-file", SCHEMA_FILE.toString(), "--seed", Long.toString(SEED))); args.addAll(Arrays.asList(extraArgs)); diff --git a/lang/java/tools/src/test/java/org/apache/avro/tool/TestToTrevniTool.java b/lang/java/tools/src/test/java/org/apache/avro/tool/TestToTrevniTool.java index 136aeb36592..2bd690d25a3 100644 --- a/lang/java/tools/src/test/java/org/apache/avro/tool/TestToTrevniTool.java +++ b/lang/java/tools/src/test/java/org/apache/avro/tool/TestToTrevniTool.java @@ -40,7 +40,7 @@ public class TestToTrevniTool { private static final int COUNT = Integer.parseInt(System.getProperty("test.count", "200")); @TempDir - private Path DIR; + private Path dataDir; private static final File SCHEMA_FILE = new File("../../../share/test/schemas/weather.avsc"); private String run(String... args) throws Exception { @@ -55,13 +55,13 @@ void test() throws Exception { Schema schema = new Schema.Parser().parse(SCHEMA_FILE); DataFileWriter writer = new DataFileWriter<>(new GenericDatumWriter<>()); - File avroFile = DIR.resolve("random.avro").toFile(); + File avroFile = dataDir.resolve("random.avro").toFile(); writer.create(schema, avroFile); for (Object datum : new RandomData(schema, COUNT, SEED)) writer.append(datum); writer.close(); - File trevniFile = DIR.resolve("random.trv").toFile(); + File trevniFile = dataDir.resolve("random.trv").toFile(); run(avroFile.toString(), trevniFile.toString()); AvroColumnReader reader = new AvroColumnReader<>(new AvroColumnReader.Params(trevniFile));