Repository: hadoop Updated Branches: refs/heads/trunk 0bf8a110a -> 0c2914e58
http://git-wip-us.apache.org/repos/asf/hadoop/blob/0c2914e5/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/object/TestHeadObject.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/object/TestHeadObject.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/object/TestHeadObject.java deleted file mode 100644 index 5b65dac..0000000 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/object/TestHeadObject.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.hadoop.ozone.s3.object; - -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.hadoop.hdds.client.ReplicationFactor; -import org.apache.hadoop.hdds.client.ReplicationType; -import org.apache.hadoop.ozone.client.*; -import org.apache.hadoop.ozone.client.io.OzoneOutputStream; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import javax.ws.rs.core.Response; -import org.apache.hadoop.ozone.s3.exception.OS3Exception; -import java.io.IOException; - -import static java.net.HttpURLConnection.HTTP_NOT_FOUND; - -/** - * Test head object. - */ -public class TestHeadObject { - private String volName = "vol1"; - private String bucketName = "b1"; - private OzoneClientStub clientStub; - private ObjectStore objectStoreStub; - private HeadObject headObject; - private OzoneBucket bucket; - - @Before - public void setup() throws IOException { - //Create client stub and object store stub. - clientStub = new OzoneClientStub(); - objectStoreStub = clientStub.getObjectStore(); - - // Create volume and bucket - objectStoreStub.createVolume(volName); - OzoneVolume volumeStub = objectStoreStub.getVolume(volName); - volumeStub.createBucket(bucketName); - bucket = objectStoreStub.getVolume(volName).getBucket(bucketName); - - // Create HeadBucket and setClient to OzoneClientStub - headObject = new HeadObject(); - headObject.setClient(clientStub); - } - - @Test - public void testHeadObject() throws Exception { - //GIVEN - String value = RandomStringUtils.randomAlphanumeric(32); - OzoneOutputStream out = bucket.createKey("key1", - value.getBytes().length, ReplicationType.STAND_ALONE, - ReplicationFactor.ONE); - out.write(value.getBytes()); - out.close(); - - //WHEN - Response response = headObject.head(volName, bucketName, "key1"); - - //THEN - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(value.getBytes().length, - Long.parseLong(response.getHeaderString("Content-Length"))); - } - - @Test - public void testHeadFailByBadName() throws Exception { - //Head an object that doesn't exist. - try { - headObject.head(volName, bucketName, "badKeyName"); - } catch (OS3Exception ex) { - Assert.assertTrue(ex.getCode().contains("NoSuchObject")); - Assert.assertTrue(ex.getErrorMessage().contains("object does not exist")); - Assert.assertEquals(HTTP_NOT_FOUND, ex.getHttpCode()); - } - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/0c2914e5/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/object/TestPutObject.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/object/TestPutObject.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/object/TestPutObject.java deleted file mode 100644 index a8f0648..0000000 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/object/TestPutObject.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.hadoop.ozone.s3.object; - -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.Response; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.nio.charset.Charset; - -import org.apache.hadoop.ozone.client.ObjectStore; -import org.apache.hadoop.ozone.client.OzoneClientStub; -import org.apache.hadoop.ozone.client.io.OzoneInputStream; -import org.apache.hadoop.hdds.client.ReplicationFactor; -import org.apache.hadoop.hdds.client.ReplicationType; - -import org.apache.commons.io.IOUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; - -/** - * Test put object. - */ -public class TestPutObject { - public static final String CONTENT = "0123456789"; - private String userName = "ozone"; - private String bucketName = "b1"; - private String keyName = "key1"; - private OzoneClientStub clientStub; - private ObjectStore objectStoreStub; - private PutObject putObject; - - @Before - public void setup() throws IOException { - //Create client stub and object store stub. - clientStub = new OzoneClientStub(); - objectStoreStub = clientStub.getObjectStore(); - - // Create bucket - objectStoreStub.createS3Bucket(userName, bucketName); - - // Create PutObject and setClient to OzoneClientStub - putObject = new PutObject(); - putObject.setClient(clientStub); - } - - @Test - public void testPutObject() throws IOException { - //GIVEN - HttpHeaders headers = Mockito.mock(HttpHeaders.class); - ByteArrayInputStream body = new ByteArrayInputStream(CONTENT.getBytes()); - - //WHEN - Response response = putObject.put(headers, bucketName, keyName, - ReplicationType.STAND_ALONE, ReplicationFactor.ONE, "32 * 1024 * 1024", - CONTENT.length(), body); - - //THEN - String volumeName = clientStub.getObjectStore().getOzoneVolumeName(bucketName); - OzoneInputStream ozoneInputStream = - clientStub.getObjectStore().getVolume(volumeName).getBucket(bucketName) - .readKey(keyName); - String keyContent = - IOUtils.toString(ozoneInputStream, Charset.forName("UTF-8")); - - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(CONTENT, keyContent); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hadoop/blob/0c2914e5/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/object/package-info.java ---------------------------------------------------------------------- diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/object/package-info.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/object/package-info.java deleted file mode 100644 index 897e209..0000000 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/object/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Unit tests for the object related rest endpoints. - */ -package org.apache.hadoop.ozone.s3.object; \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
