Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ public Response get(
@PathParam("path") String keyPath,
@QueryParam("uploadId") String uploadId,
@QueryParam("max-parts") @DefaultValue("1000") int maxParts,
@QueryParam("part-number-marker") String partNumberMarker,
InputStream body) throws IOException, OS3Exception {
@QueryParam("part-number-marker") String partNumberMarker)
throws IOException, OS3Exception {

S3GAction s3GAction = S3GAction.GET_KEY;
boolean auditSuccess = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static void setUp() throws Exception {
@Test
public void testListParts() throws Exception {
Response response = REST.get(OzoneConsts.S3_BUCKET, OzoneConsts.KEY,
uploadID, 3, "0", null);
uploadID, 3, "0");

ListPartsResponse listPartsResponse =
(ListPartsResponse) response.getEntity();
Expand All @@ -107,7 +107,7 @@ public void testListParts() throws Exception {
@Test
public void testListPartsContinuation() throws Exception {
Response response = REST.get(OzoneConsts.S3_BUCKET, OzoneConsts.KEY,
uploadID, 2, "0", null);
uploadID, 2, "0");
ListPartsResponse listPartsResponse =
(ListPartsResponse) response.getEntity();

Expand All @@ -116,7 +116,7 @@ public void testListPartsContinuation() throws Exception {

// Continue
response = REST.get(OzoneConsts.S3_BUCKET, OzoneConsts.KEY, uploadID, 2,
Integer.toString(listPartsResponse.getNextPartNumberMarker()), null);
Integer.toString(listPartsResponse.getNextPartNumberMarker()));
listPartsResponse = (ListPartsResponse) response.getEntity();

Assert.assertFalse(listPartsResponse.getTruncated());
Expand All @@ -128,7 +128,7 @@ public void testListPartsContinuation() throws Exception {
public void testListPartsWithUnknownUploadID() throws Exception {
try {
REST.get(OzoneConsts.S3_BUCKET, OzoneConsts.KEY,
uploadID, 2, "0", null);
uploadID, 2, "0");
} catch (OS3Exception ex) {
Assert.assertEquals(S3ErrorTable.NO_SUCH_UPLOAD.getErrorMessage(),
ex.getErrorMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.time.format.DateTimeFormatter;

Expand Down Expand Up @@ -70,7 +69,6 @@ public class TestObjectGet {
private HttpHeaders headers;
private ObjectEndpoint rest;
private OzoneClient client;
private ByteArrayInputStream body;
private ContainerRequestContext context;

@Before
Expand All @@ -89,7 +87,6 @@ public void init() throws IOException {
rest.setOzoneConfiguration(new OzoneConfiguration());
headers = Mockito.mock(HttpHeaders.class);
rest.setHeaders(headers);
body = new ByteArrayInputStream(CONTENT.getBytes(UTF_8));

context = Mockito.mock(ContainerRequestContext.class);
Mockito.when(context.getUriInfo()).thenReturn(Mockito.mock(UriInfo.class));
Expand All @@ -101,7 +98,7 @@ public void init() throws IOException {
@Test
public void get() throws IOException, OS3Exception {
//WHEN
Response response = rest.get("b1", "key1", null, 0, null, body);
Response response = rest.get("b1", "key1", null, 0, null);

//THEN
OzoneInputStream ozoneInputStream =
Expand All @@ -123,7 +120,7 @@ public void get() throws IOException, OS3Exception {
public void inheritRequestHeader() throws IOException, OS3Exception {
setDefaultHeader();

Response response = rest.get("b1", "key1", null, 0, null, body);
Response response = rest.get("b1", "key1", null, 0, null);

Assert.assertEquals(CONTENT_TYPE1,
response.getHeaderString("Content-Type"));
Expand Down Expand Up @@ -156,8 +153,7 @@ public void overrideResponseHeader() throws IOException, OS3Exception {

Mockito.when(context.getUriInfo().getQueryParameters())
.thenReturn(queryParameter);
body = new ByteArrayInputStream(CONTENT.getBytes(UTF_8));
Response response = rest.get("b1", "key1", null, 0, null, body);
Response response = rest.get("b1", "key1", null, 0, null);

Assert.assertEquals(CONTENT_TYPE2,
response.getHeaderString("Content-Type"));
Expand All @@ -177,15 +173,14 @@ public void overrideResponseHeader() throws IOException, OS3Exception {
public void getRangeHeader() throws IOException, OS3Exception {
Response response;
Mockito.when(headers.getHeaderString(RANGE_HEADER)).thenReturn("bytes=0-0");
body = new ByteArrayInputStream(CONTENT.getBytes(UTF_8));

response = rest.get("b1", "key1", null, 0, null, body);
response = rest.get("b1", "key1", null, 0, null);
Assert.assertEquals("1", response.getHeaderString("Content-Length"));
Assert.assertEquals(String.format("bytes 0-0/%s", CONTENT.length()),
response.getHeaderString("Content-Range"));

Mockito.when(headers.getHeaderString(RANGE_HEADER)).thenReturn("bytes=0-");
response = rest.get("b1", "key1", null, 0, null, body);
response = rest.get("b1", "key1", null, 0, null);
Assert.assertEquals(String.valueOf(CONTENT.length()),
response.getHeaderString("Content-Length"));
Assert.assertEquals(
Expand All @@ -196,16 +191,15 @@ public void getRangeHeader() throws IOException, OS3Exception {
@Test
public void getStatusCode() throws IOException, OS3Exception {
Response response;
body = new ByteArrayInputStream(CONTENT.getBytes(UTF_8));
response = rest.get("b1", "key1", null, 0, null, body);
response = rest.get("b1", "key1", null, 0, null);
Assert.assertEquals(response.getStatus(),
Response.Status.OK.getStatusCode());

// https://www.rfc-editor.org/rfc/rfc7233#section-4.1
// The 206 (Partial Content) status code indicates that the server is
// successfully fulfilling a range request for the target resource
Mockito.when(headers.getHeaderString(RANGE_HEADER)).thenReturn("bytes=0-1");
response = rest.get("b1", "key1", null, 0, null, body);
response = rest.get("b1", "key1", null, 0, null);
Assert.assertEquals(response.getStatus(),
Response.Status.PARTIAL_CONTENT.getStatusCode());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ public void testGetKey() throws IOException {
objectEndpoint.setOzoneConfiguration(conf);

try {
objectEndpoint.get("bucketName", "keyPath", null, 1000, "marker",
null);
objectEndpoint.get("bucketName", "keyPath", null, 1000, "marker");
Assert.fail("Should fail");
} catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public void testGetKeySuccess() throws Exception {
.length(), 1, null, body);
// GET the key from the bucket
keyEndpoint.get(bucketName, keyName, null, 0,
null, body);
null);
long curMetric = metrics.getGetKeySuccess();
assertEquals(1L, curMetric - oriMetric);
}
Expand All @@ -388,7 +388,7 @@ public void testGetKeyFailure() throws Exception {
// Fetching a non-existent key
try {
keyEndpoint.get(bucketName, "unknownKey", null, 0,
null, null);
null);
fail();
} catch (OS3Exception ex) {
assertEquals(S3ErrorTable.NO_SUCH_KEY.getCode(), ex.getCode());
Expand Down Expand Up @@ -520,7 +520,7 @@ public void testListPartsSuccess() throws Exception {

// Listing out the parts by providing the uploadID
keyEndpoint.get(bucketName, keyName,
uploadID, 3, null, null);
uploadID, 3, null);
long curMetric = metrics.getListPartsSuccess();
assertEquals(1L, curMetric - oriMetric);
}
Expand All @@ -532,7 +532,7 @@ public void testListPartsFailure() throws Exception {
try {
// Listing out the parts by providing the uploadID after aborting
keyEndpoint.get(bucketName, keyName,
"wrong_id", 3, null, null);
"wrong_id", 3, null);
fail();
} catch (OS3Exception ex) {
assertEquals(S3ErrorTable.NO_SUCH_UPLOAD.getCode(), ex.getCode());
Expand Down