Skip to content

Commit a2bd162

Browse files
committed
HADOOP-19027. Update TestS3AExceptionTranslation for the 416 change
1 parent 3b82019 commit a2bd162

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/TestS3AExceptionTranslation.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static org.apache.hadoop.fs.s3a.S3ATestUtils.*;
2323
import static org.apache.hadoop.fs.s3a.S3AUtils.*;
2424
import static org.apache.hadoop.fs.s3a.impl.InternalConstants.SC_404;
25+
import static org.apache.hadoop.fs.s3a.impl.InternalConstants.SC_416_RANGE_NOT_SATISFIABLE;
2526
import static org.junit.Assert.*;
2627

2728
import java.io.EOFException;
@@ -38,6 +39,7 @@
3839
import com.amazonaws.AmazonServiceException;
3940
import com.amazonaws.services.s3.model.AmazonS3Exception;
4041

42+
import org.assertj.core.api.Assertions;
4143
import org.junit.Test;
4244

4345
import org.apache.hadoop.fs.s3a.impl.ErrorTranslation;
@@ -80,10 +82,10 @@ protected void assertContained(String text, String contained) {
8082
text != null && text.contains(contained));
8183
}
8284

83-
protected <E extends Throwable> void verifyTranslated(
85+
protected <E extends Throwable> E verifyTranslated(
8486
int status,
8587
Class<E> expected) throws Exception {
86-
verifyTranslated(expected, createS3Exception(status));
88+
return verifyTranslated(expected, createS3Exception(status));
8789
}
8890

8991
@Test
@@ -128,7 +130,12 @@ public void test410isNotFound() throws Exception {
128130

129131
@Test
130132
public void test416isEOF() throws Exception {
131-
verifyTranslated(416, EOFException.class);
133+
134+
// 416 maps the the subclass of EOFException
135+
final IOException ex = verifyTranslated(SC_416_RANGE_NOT_SATISFIABLE,
136+
RangeNotSatisfiableEOFException.class);
137+
Assertions.assertThat(ex)
138+
.isInstanceOf(EOFException.class);
132139
}
133140

134141
@Test

0 commit comments

Comments
 (0)