amogh-jahagirdar commented on code in PR #17965:
URL: https://github.com/apache/iceberg/pull/17965#discussion_r4732259029
##########
aliyun/src/test/java/org/apache/iceberg/aliyun/oss/TestOSSInputStream.java:
##########
@@ -92,6 +94,40 @@ private void readAndCheck(
.isEqualTo(Arrays.copyOfRange(original, (int) rangeStart, (int)
rangeEnd));
}
+ @Test
+ public void testReadSingleEOF() throws Exception {
+ OSSURI uri = new OSSURI(location("read-single-eof.dat"));
+ byte[] data = new byte[] {1, 2};
+
+ writeOSSData(uri, data);
+
+ try (SeekableInputStream in = new OSSInputStream(ossClient().get(), uri)) {
+ assertThat(in.read()).isEqualTo(1);
+ assertThat(in.read()).isEqualTo(2);
+ assertThat(in.read()).isEqualTo(EOF);
+ assertThat(in.getPos()).isEqualTo(data.length);
+ }
+ }
+
+ @Test
+ public void testReadBufferedEOF() throws Exception {
+ OSSURI uri = new OSSURI(location("read-buffered-eof.dat"));
+ int dataSize = 8;
+ byte[] expected = randomData(dataSize);
+ byte[] actual = new byte[dataSize + 1];
+
+ writeOSSData(uri, expected);
+
+ try (SeekableInputStream in = new OSSInputStream(ossClient().get(), uri)) {
+ int bytesRead = in.read(actual, 0, dataSize + 1);
+ assertThat(bytesRead).isEqualTo(dataSize);
+ assertThat(Arrays.copyOfRange(actual, 0, bytesRead)).isEqualTo(expected);
+
+ assertThat(in.read(actual, 0, 10)).isEqualTo(EOF);
Review Comment:
could we just pass in actual.length() here instead of 10 , actual only has 9
bytes; this passes regardless of that but it makes the test harder to parse
since it reads like invalid input
--
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]