cnauroth commented on code in PR #7291:
URL: https://github.com/apache/hadoop/pull/7291#discussion_r1920474642
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestTextCommand.java:
##########
@@ -67,39 +75,194 @@ public void testDisplayForAvroFiles() throws Exception {
assertEquals(expectedOutput, output);
}
+ @Test
+ public void testEmptyAvroFile() throws Exception {
+ String output = readUsingTextCommand(AVRO_FILENAME,
+ generateEmptyAvroBinaryData());
+ assertTrue(output.isEmpty());
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAvroFileInputStreamNullBuffer() throws Exception {
+ createFile(AVRO_FILENAME, generateWeatherAvroBinaryData());
+ URI uri = new URI(AVRO_FILENAME);
+ Configuration conf = new Configuration();
+ try (InputStream is = getInputStream(uri, conf)) {
+ is.read(null, 0, 10);
+ }
+ }
+
+ @Test(expected = IndexOutOfBoundsException.class)
+ public void testAvroFileInputStreamNegativePosition() throws Exception {
+ createFile(AVRO_FILENAME, generateWeatherAvroBinaryData());
+ URI uri = new URI(AVRO_FILENAME);
+ Configuration conf = new Configuration();
+ try (InputStream is = getInputStream(uri, conf)) {
+ is.read(new byte[10], -1, 10);
+ }
+ }
+
+ @Test(expected = IndexOutOfBoundsException.class)
+ public void testAvroFileInputStreamTooLong() throws Exception {
+ createFile(AVRO_FILENAME, generateWeatherAvroBinaryData());
+ URI uri = new URI(AVRO_FILENAME);
+ Configuration conf = new Configuration();
+ try (InputStream is = getInputStream(uri, conf)) {
+ is.read(new byte[10], 0, 11);
+ }
+ }
+
+ @Test
+ public void testAvroFileInputStreamZeroLengthRead() throws Exception {
+ createFile(AVRO_FILENAME, generateWeatherAvroBinaryData());
+ URI uri = new URI(AVRO_FILENAME);
Review Comment:
It sounds like you would like to see something here lifted to a `@Before`.
The `uri` gets initialized to different values though in different tests, so
I'm not sure I can make that comm in a `@Before`.
--
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]