You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2015/10/26 04:40:27 UTC
[2/9] jclouds git commit: JCLOUDS-786: Remove legacy swift provider
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobLiveTest.java
deleted file mode 100644
index 11b424d..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobLiveTest.java
+++ /dev/null
@@ -1,37 +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.jclouds.openstack.swift.blobstore.integration;
-
-import java.util.Properties;
-
-import org.jclouds.blobstore.integration.internal.BaseBlobLiveTest;
-import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
-import org.testng.annotations.Test;
-
-@Test(groups = { "live" })
-public class SwiftBlobLiveTest extends BaseBlobLiveTest {
- @Override
- protected Properties setupProperties() {
- Properties props = super.setupProperties();
- setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
- return props;
- }
-
- public SwiftBlobLiveTest() {
- provider = System.getProperty("test.swift.provider", "swift");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobSignerLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobSignerLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobSignerLiveTest.java
deleted file mode 100644
index 9c681ba..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobSignerLiveTest.java
+++ /dev/null
@@ -1,38 +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.jclouds.openstack.swift.blobstore.integration;
-
-import org.jclouds.blobstore.integration.internal.BaseBlobSignerLiveTest;
-import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
-import org.testng.annotations.Test;
-
-import java.util.Properties;
-
-@Test(groups = {"live"})
-public class SwiftBlobSignerLiveTest extends BaseBlobSignerLiveTest {
-
- @Override
- protected Properties setupProperties() {
- Properties props = super.setupProperties();
- setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
- return props;
- }
-
- public SwiftBlobSignerLiveTest() {
- provider = System.getProperty("test.swift.provider", "swift");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerIntegrationLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerIntegrationLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerIntegrationLiveTest.java
deleted file mode 100644
index b557d8c..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerIntegrationLiveTest.java
+++ /dev/null
@@ -1,109 +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.jclouds.openstack.swift.blobstore.integration;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.util.Properties;
-
-import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
-import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
-import org.jclouds.openstack.swift.CommonSwiftClient;
-import org.jclouds.openstack.swift.domain.ContainerMetadata;
-import org.jclouds.openstack.swift.options.CreateContainerOptions;
-import org.testng.SkipException;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-@Test(groups = "live")
-public class SwiftContainerIntegrationLiveTest extends BaseContainerIntegrationTest {
- @Override
- protected Properties setupProperties() {
- Properties props = super.setupProperties();
- setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
- return props;
- }
-
- public SwiftContainerIntegrationLiveTest() {
- provider = System.getProperty("test.swift.provider", "swift");
- }
-
- @Test(groups = "live")
- public void testSetGetContainerMetadata() throws InterruptedException {
- CommonSwiftClient swift = view.utils().injector().getInstance(CommonSwiftClient.class);
-
- String containerName = getContainerName();
-
- ImmutableMap<String, String> metadata = ImmutableMap.<String, String> of(
- "key1", "value1",
- "key2", "value2");
-
- assertTrue(swift.setContainerMetadata(containerName, metadata));
-
- ContainerMetadata containerMetadata = swift.getContainerMetadata(containerName);
-
- assertEquals(containerMetadata.getMetadata().get("key1"), "value1");
- assertEquals(containerMetadata.getMetadata().get("key2"), "value2");
- }
-
- @Test(groups = "live")
- public void testCreateDeleteContainerMetadata() throws InterruptedException {
- CommonSwiftClient swift = view.utils().injector().getInstance(CommonSwiftClient.class);
-
- CreateContainerOptions options = CreateContainerOptions.Builder
- .withPublicAccess()
- .withMetadata(ImmutableMap.<String, String> of(
- "key1", "value1",
- "key2", "value2",
- "key3", "value3"));
-
- String containerName = getScratchContainerName();
- assertTrue(swift.createContainer(containerName, options));
-
- try {
- ContainerMetadata containerMetadata = swift.getContainerMetadata(containerName);
-
- assertEquals(containerMetadata.getMetadata().size(), 3);
- assertEquals(containerMetadata.getMetadata().get("key1"), "value1");
- assertEquals(containerMetadata.getMetadata().get("key2"), "value2");
- assertEquals(containerMetadata.getMetadata().get("key3"), "value3");
-
- assertTrue(swift.deleteContainerMetadata(containerName, ImmutableList.<String> of("key2", "key3")));
-
- containerMetadata = swift.getContainerMetadata(containerName);
-
- assertEquals(containerMetadata.getMetadata().size(), 1);
- assertEquals(containerMetadata.getMetadata().get("key1"), "value1");
- } finally {
- returnContainer(containerName);
- }
- }
-
- @Test(groups = { "integration", "live" })
- public void testListContainerGetBlobSize() throws Exception {
- // use new Swift provider instead
- throw new SkipException("Intentionally not implemented for the legacy Swift provider");
- }
-
- @Override
- public void testSetContainerAccess() throws Exception {
- throw new SkipException("Intentionally not implemented for the legacy Swift provider");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java
deleted file mode 100644
index 7291e5a..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java
+++ /dev/null
@@ -1,55 +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.jclouds.openstack.swift.blobstore.integration;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.Properties;
-
-import org.jclouds.blobstore.integration.internal.BaseContainerLiveTest;
-import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
-import org.testng.annotations.Test;
-
-@Test(groups = "live", testName = "SwiftContainerLiveTest" )
-public class SwiftContainerLiveTest extends BaseContainerLiveTest {
- @Override
- protected Properties setupProperties() {
- Properties props = super.setupProperties();
- setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
- return props;
- }
-
- public SwiftContainerLiveTest() {
- provider = System.getProperty("test.swift.provider", "swift");
- }
-
- @Test(expectedExceptions = UnsupportedOperationException.class)
- public void testPublicAccess() throws MalformedURLException, InterruptedException, IOException {
- super.testPublicAccess();
- }
-
- @Test(dependsOnMethods = "testPublicAccess")
- public void testPublicAccessInNonDefaultLocation() throws InterruptedException, MalformedURLException, IOException {
- super.testPublicAccessInNonDefaultLocation();
- }
-
- @Test(dependsOnMethods = "testPublicAccess")
- public void testPublicAccessInNonDefaultLocationWithBigBlob() throws InterruptedException, MalformedURLException,
- IOException {
- super.testPublicAccessInNonDefaultLocationWithBigBlob();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftServiceIntegrationLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftServiceIntegrationLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftServiceIntegrationLiveTest.java
deleted file mode 100644
index 1057eff..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftServiceIntegrationLiveTest.java
+++ /dev/null
@@ -1,37 +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.jclouds.openstack.swift.blobstore.integration;
-
-import java.util.Properties;
-
-import org.jclouds.blobstore.integration.internal.BaseServiceIntegrationTest;
-import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
-import org.testng.annotations.Test;
-
-@Test(groups = "live")
-public class SwiftServiceIntegrationLiveTest extends BaseServiceIntegrationTest {
- @Override
- protected Properties setupProperties() {
- Properties props = super.setupProperties();
- setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
- return props;
- }
-
- public SwiftServiceIntegrationLiveTest() {
- provider = System.getProperty("test.swift.provider", "swift");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/strategy/internal/MultipartNamingStrategyTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/strategy/internal/MultipartNamingStrategyTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/strategy/internal/MultipartNamingStrategyTest.java
deleted file mode 100644
index 364c410..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/strategy/internal/MultipartNamingStrategyTest.java
+++ /dev/null
@@ -1,71 +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.jclouds.openstack.swift.blobstore.strategy.internal;
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-@Test(testName = "MultipartNamingStrategyTest")
-public class MultipartNamingStrategyTest {
-
- @Test
- public void testGetPartNameFirstOneHundred() {
- final MultipartNamingStrategy strategy = new MultipartNamingStrategy();
- final String key = "file.txt";
- final int numberParts = 100;
-
- // check the first 100
- for (int i = 0; i < numberParts; i++) {
- String partName = strategy.getPartName(key, i + 1, numberParts);
- assertEquals(String.format("file.txt/%03d", i + 1), partName);
- }
- }
-
- @Test
- public void testGetPartNameChoices() {
- final MultipartNamingStrategy strategy = new MultipartNamingStrategy();
- final String key = "file.txt";
-
- // check less than 10 parts
- assertEquals(strategy.getPartName(key, 1, 5), "file.txt/1");
- assertEquals(strategy.getPartName(key, 2, 5), "file.txt/2");
- assertEquals(strategy.getPartName(key, 5, 5), "file.txt/5");
-
- // check <= 10 parts
- assertEquals(strategy.getPartName(key, 1, 10), "file.txt/01");
- assertEquals(strategy.getPartName(key, 2, 10), "file.txt/02");
- assertEquals(strategy.getPartName(key, 10, 10), "file.txt/10");
-
- // check <= 100 parts
- assertEquals(strategy.getPartName(key, 1, 100), "file.txt/001");
- assertEquals(strategy.getPartName(key, 9, 100), "file.txt/009");
- assertEquals(strategy.getPartName(key, 10, 100), "file.txt/010");
- assertEquals(strategy.getPartName(key, 99, 100), "file.txt/099");
- assertEquals(strategy.getPartName(key, 100, 100), "file.txt/100");
-
- // check <= 5000 parts
- assertEquals(strategy.getPartName(key, 1, 5000), "file.txt/0001");
- assertEquals(strategy.getPartName(key, 10, 5000), "file.txt/0010");
- assertEquals(strategy.getPartName(key, 99, 5000), "file.txt/0099");
- assertEquals(strategy.getPartName(key, 100, 5000), "file.txt/0100");
- assertEquals(strategy.getPartName(key, 999, 5000), "file.txt/0999");
- assertEquals(strategy.getPartName(key, 4999, 5000), "file.txt/4999");
- assertEquals(strategy.getPartName(key, 5000, 500), "file.txt/5000");
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/strategy/internal/SequentialMultipartUploadStrategyMockTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/strategy/internal/SequentialMultipartUploadStrategyMockTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/strategy/internal/SequentialMultipartUploadStrategyMockTest.java
deleted file mode 100644
index 2ad3186..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/strategy/internal/SequentialMultipartUploadStrategyMockTest.java
+++ /dev/null
@@ -1,144 +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.jclouds.openstack.swift.blobstore.strategy.internal;
-
-import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
-import static org.jclouds.Constants.PROPERTY_MAX_RETRIES;
-import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.jclouds.ContextBuilder;
-import org.jclouds.blobstore.domain.internal.BlobBuilderImpl;
-import org.jclouds.concurrent.config.ExecutorServiceModule;
-import org.jclouds.openstack.keystone.v2_0.internal.KeystoneFixture;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Charsets;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.Atomics;
-import com.google.inject.Module;
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-import com.squareup.okhttp.mockwebserver.QueueDispatcher;
-import com.squareup.okhttp.mockwebserver.RecordedRequest;
-
-@Test(singleThreaded = true)
-public class SequentialMultipartUploadStrategyMockTest {
-
- String authRequestBody = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPassword("user", "password")
- .getPayload().getRawContent().toString();
- String authResponse = KeystoneFixture.INSTANCE.responseWithAccess().getPayload().getRawContent().toString()
- .replace("https://objects.jclouds.org/v1.0/40806637803162", "URL");
- String token = "Auth_4f173437e4b013bee56d1007";
-
- @Test
- public void testMPUDoesMultipart() throws IOException, InterruptedException {
- MockWebServer server = new MockWebServer();
- AtomicReference<URL> url = setURLReplacingDispatcher(server);
- server.enqueue(new MockResponse().setResponseCode(200).setBody(authResponse));
- server.enqueue(new MockResponse().setResponseCode(200).addHeader("ETag", "a00"));
- server.enqueue(new MockResponse().setResponseCode(200).addHeader("ETag", "b00"));
- server.enqueue(new MockResponse().setResponseCode(200).addHeader("ETag", "fff"));
- server.play();
- url.set(server.getUrl("/"));
-
- byte[] bytes = "0123456789abcdef".getBytes(Charsets.US_ASCII);
- int partSize = bytes.length / 2;
- SequentialMultipartUploadStrategy api = mockSequentialMultipartUploadStrategy(url.get().toString(), partSize);
-
- try {
- assertEquals(api.execute("container", new BlobBuilderImpl().name("foo").payload(bytes).build()), "fff");
- } finally {
- RecordedRequest authRequest = server.takeRequest();
- assertEquals(authRequest.getRequestLine(), "POST /tokens HTTP/1.1");
- assertEquals(new String(authRequest.getBody()), authRequestBody);
- assertEquals(authRequest.getHeader("Content-Length"), String.valueOf(authRequestBody.length()));
-
- RecordedRequest part1 = server.takeRequest();
- assertEquals(part1.getRequestLine(), "PUT /container/foo/1 HTTP/1.1");
- assertEquals(part1.getHeader("X-Auth-Token"), token);
- assertEquals(part1.getHeader("Content-Length"), String.valueOf(partSize));
- assertEquals(new String(part1.getBody()), "01234567");
-
- RecordedRequest part2 = server.takeRequest();
- assertEquals(part2.getRequestLine(), "PUT /container/foo/2 HTTP/1.1");
- assertEquals(part2.getHeader("X-Auth-Token"), token);
- assertEquals(part2.getHeader("Content-Length"), String.valueOf(partSize));
- assertEquals(new String(part2.getBody()), "89abcdef");
-
- RecordedRequest manifest = server.takeRequest();
- assertEquals(manifest.getRequestLine(), "PUT /container/foo HTTP/1.1");
- assertEquals(manifest.getHeader("X-Auth-Token"), token);
- assertEquals(manifest.getHeader("Content-Length"), "0");
-
- server.shutdown();
- }
- }
-
- private static final Set<Module> modules = ImmutableSet.<Module> of(
- new ExecutorServiceModule(sameThreadExecutor()));
-
- static SequentialMultipartUploadStrategy mockSequentialMultipartUploadStrategy(String uri, int partSize) {
- Properties overrides = new Properties();
- // prevent expect-100 bug http://code.google.com/p/mockwebserver/issues/detail?id=6
- overrides.setProperty(PROPERTY_SO_TIMEOUT, "0");
- overrides.setProperty(PROPERTY_MAX_RETRIES, "1");
- overrides.setProperty("jclouds.mpu.parts.size", String.valueOf(partSize));
- return ContextBuilder.newBuilder("swift-keystone")
- .credentials("user", "password").endpoint(uri)
- .overrides(overrides)
- .modules(modules)
- .buildInjector().getInstance(SequentialMultipartUploadStrategy.class);
- }
-
- /**
- * there's no built-in way to defer evaluation of a response header, hence
- * this method, which allows us to send back links to the mock server.
- */
- private AtomicReference<URL> setURLReplacingDispatcher(MockWebServer server) {
- final AtomicReference<URL> url = Atomics.newReference();
-
- final QueueDispatcher dispatcher = new QueueDispatcher() {
- protected final BlockingQueue<MockResponse> responseQueue = new LinkedBlockingQueue<MockResponse>();
-
- @Override
- public MockResponse dispatch(RecordedRequest request) throws InterruptedException {
- MockResponse response = responseQueue.take();
- if (response.getBody() != null) {
- String newBody = new String(response.getBody().readByteArray()).replace("URL", url.get().toString());
- response = response.setBody(newBody);
- }
- return response;
- }
-
- @Override
- public void enqueueResponse(MockResponse response) {
- responseQueue.add(response);
- }
- };
- server.setDispatcher(dispatcher);
- return url;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/config/KeystoneStorageEndpointModuleTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/config/KeystoneStorageEndpointModuleTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/config/KeystoneStorageEndpointModuleTest.java
deleted file mode 100644
index 3ca670f..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/config/KeystoneStorageEndpointModuleTest.java
+++ /dev/null
@@ -1,131 +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.jclouds.openstack.swift.config;
-
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.expect;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Map;
-
-import org.jclouds.location.suppliers.RegionIdToURISupplier;
-import org.jclouds.openstack.services.ServiceType;
-import org.jclouds.openstack.swift.config.SwiftHttpApiModule.KeystoneStorageEndpointModule;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
-import com.google.common.collect.Maps;
-
-@Test(groups = "unit")
-public class KeystoneStorageEndpointModuleTest {
-
- private final String apiVersion = "9.8.7";
- private final RegionIdToURISupplier.Factory mockFactory = createStrictMock(RegionIdToURISupplier.Factory.class);
- private final RegionIdToURISupplier mockSupplier = createStrictMock(RegionIdToURISupplier.class);
-
- /**
- * Setup the expectations for our mock factory to return 3 region urls keyed
- * by test region names
- */
- @BeforeTest
- public void setup() {
- Map<String, Supplier<URI>> endpoints = Maps.newHashMap();
-
- try {
- endpoints.put("region1", Suppliers.ofInstance(new URI("http://region1.example.org/")));
- endpoints.put("region2", Suppliers.ofInstance(new URI("http://region2.example.org/")));
- endpoints.put("region3", Suppliers.ofInstance(new URI("http://region3.example.org/")));
- } catch (URISyntaxException ex) {
- fail("static test Strings do not parse to URI: " + ex.getMessage());
- }
-
- expect(mockSupplier.get())
- .andReturn(endpoints)
- .anyTimes();
- expect(mockFactory.createForApiTypeAndVersion(ServiceType.OBJECT_STORE, apiVersion))
- .andReturn(mockSupplier)
- .anyTimes();
-
- replay(mockSupplier);
- replay(mockFactory);
- }
-
- /**
- * Test that specifying an empty region will return an arbitrary URL
- */
- @Test
- public void testEmptyRegion() {
- final KeystoneStorageEndpointModule moduleToTest = new KeystoneStorageEndpointModule();
-
- // Test with an empty Region - just ensure we get either a region 1, 2 or 3
- // URI
- Supplier<URI> resultingSupplier = moduleToTest.provideStorageUrl(mockFactory, apiVersion, "");
- assertNotNull(resultingSupplier);
- URI resultingUri = resultingSupplier.get();
- assertNotNull(resultingUri);
-
- // Without a region our choice is arbitrary. We can't enforce an ordering
- // on the map
- // as that varies from JVM to JVM - easier to just assume its one of the
- // possible values
- assertTrue(resultingUri.toString().equals("http://region1.example.org/")
- || resultingUri.toString().equals("http://region2.example.org/")
- || resultingUri.toString().equals("http://region3.example.org/"));
- }
-
- /**
- * Test that specifying a region will return the correct URL
- */
- @Test
- public void testSpecificRegion() {
- final KeystoneStorageEndpointModule moduleToTest = new KeystoneStorageEndpointModule();
-
- // Iterate through our region names
- for (int i = 1; i <= 3; i++) {
- Supplier<URI> resultingSupplier = moduleToTest.provideStorageUrl(mockFactory, apiVersion, String.format("region%1$s", i));
- assertNotNull(resultingSupplier);
- URI resultingUri = resultingSupplier.get();
- assertNotNull(resultingUri);
-
- assertEquals(resultingUri.toString(),
- String.format("http://region%1$s.example.org/", i));
- }
- }
-
- /**
- * Test that specifying an undefined region will return null
- */
- @Test
- public void testUndefinedRegion() {
- final KeystoneStorageEndpointModule moduleToTest = new KeystoneStorageEndpointModule();
-
- Supplier<URI> resultingSupplier = moduleToTest.provideStorageUrl(mockFactory, apiVersion, "region-that-dne");
- assertNotNull(resultingSupplier);
- URI resultingUri = resultingSupplier.get();
- assertNull(resultingUri);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/domain/internal/ParseObjectInfoListFromJsonResponseTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/domain/internal/ParseObjectInfoListFromJsonResponseTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/domain/internal/ParseObjectInfoListFromJsonResponseTest.java
deleted file mode 100644
index 6178f4d..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/domain/internal/ParseObjectInfoListFromJsonResponseTest.java
+++ /dev/null
@@ -1,65 +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.jclouds.openstack.swift.domain.internal;
-
-import static com.google.common.io.BaseEncoding.base16;
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Set;
-
-import org.jclouds.date.internal.SimpleDateFormatDateService;
-import org.jclouds.openstack.swift.domain.ObjectInfo;
-import org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse;
-import org.jclouds.openstack.swift.internal.BasePayloadTest;
-import org.jclouds.openstack.swift.options.ListContainerOptions;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Tests behavior of {@code ParseObjectInfoListFromJsonResponse}
- */
-@Test(groups = "unit")
-public class ParseObjectInfoListFromJsonResponseTest extends BasePayloadTest {
-
- public void testApplyInputStream() {
- InputStream is = getClass().getResourceAsStream("/test_list_container.json");
- Set<ObjectInfo> expects = ImmutableSet
- .<ObjectInfo> of(
- ObjectInfoImpl.builder().container("container").name("test_obj_1")
- .uri(URI.create("http://localhost/key/test_obj_1"))
- .hash(base16().lowerCase().decode("4281c348eaf83e70ddce0e07221c3d28")).bytes(14l)
- .contentType("application/octet-stream")
- .lastModified(new SimpleDateFormatDateService().iso8601DateParse("2009-02-03T05:26:32.612Z"))
- .build(),
- ObjectInfoImpl.builder().container("container").name("test_obj_2")
- .uri(URI.create("http://localhost/key/test_obj_2"))
- .hash(base16().lowerCase().decode("b039efe731ad111bc1b0ef221c3849d0")).bytes(64l)
- .contentType("application/octet-stream")
- .lastModified(new SimpleDateFormatDateService().iso8601DateParse("2009-02-03T05:26:32.612Z"))
- .build());
- GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of("container",
- new ListContainerOptions[] { new ListContainerOptions() }));
- ParseObjectInfoListFromJsonResponse parser = i.getInstance(ParseObjectInfoListFromJsonResponse.class);
- parser.setContext(request);
- assertEquals(parser.apply(is).toString(), expects.toString());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseContainerListFromJsonResponseTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseContainerListFromJsonResponseTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseContainerListFromJsonResponseTest.java
deleted file mode 100644
index 98025df..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseContainerListFromJsonResponseTest.java
+++ /dev/null
@@ -1,56 +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.jclouds.openstack.swift.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseJson;
-import org.jclouds.openstack.swift.domain.ContainerMetadata;
-import org.jclouds.openstack.swift.internal.BasePayloadTest;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Maps;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code ParseContainerListFromJsonResponse}
- */
-@Test(groups = "unit")
-public class ParseContainerListFromJsonResponseTest extends BasePayloadTest {
-
- @Test
- public void testApplyInputStream() {
- InputStream is = Strings2
- .toInputStream("[ {\"name\":\"test_container_1\",\"count\":2,\"bytes\":78}, {\"name\":\"test_container_2\",\"count\":1,\"bytes\":17} ] ");
- Map<String, String> meta = Maps.newHashMap();
-
- List<ContainerMetadata> expects = ImmutableList.of(ContainerMetadata.builder().name("test_container_1").count( 2).bytes(78).metadata(meta).build(),
- ContainerMetadata.builder().name("test_container_2").count(1).bytes(17).metadata(meta).build());
- ParseJson<List<ContainerMetadata>> parser = i.getInstance(Key
- .get(new TypeLiteral<ParseJson<List<ContainerMetadata>>>() {
- }));
- assertEquals(parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build()), expects);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseContainerMetadataFromHeadersTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseContainerMetadataFromHeadersTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseContainerMetadataFromHeadersTest.java
deleted file mode 100644
index 4dfc5b3..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseContainerMetadataFromHeadersTest.java
+++ /dev/null
@@ -1,54 +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.jclouds.openstack.swift.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.http.HttpResponse;
-import org.jclouds.openstack.swift.domain.ContainerMetadata;
-import org.jclouds.openstack.swift.internal.BasePayloadTest;
-import org.jclouds.openstack.swift.reference.SwiftHeaders;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Tests behavior of {@code ParseContainerMetadataFromHeaders}
- */
-@Test(groups = "unit")
-public class ParseContainerMetadataFromHeadersTest extends BasePayloadTest {
-
- public void testParseContainerMetadataHeaders() {
- ParseContainerMetadataFromHeaders parser = i.getInstance(ParseContainerMetadataFromHeaders.class);
-
- parser.setContext(requestForArgs(ImmutableList.<Object> of("container", "key")));
-
- HttpResponse response = HttpResponse.builder().statusCode(204).message("No Content").payload("")
- .addHeader(SwiftHeaders.CONTAINER_BYTES_USED, "42")
- .addHeader(SwiftHeaders.CONTAINER_OBJECT_COUNT, "1")
- .addHeader(SwiftHeaders.CONTAINER_METADATA_PREFIX + "label1", "test1")
- .addHeader(SwiftHeaders.CONTAINER_METADATA_PREFIX + "label2", "test2").build();
-
- response.getPayload().getContentMetadata().setContentType("text/plain");
- ContainerMetadata containerMetadata = parser.apply(response);
-
- assertEquals(containerMetadata.getBytes(), 42);
- assertEquals(containerMetadata.getCount(), 1);
- assertEquals(containerMetadata.getMetadata().get("label1"), "test1");
- assertEquals(containerMetadata.getMetadata().get("label2"), "test2");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoFromHeadersTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoFromHeadersTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoFromHeadersTest.java
deleted file mode 100644
index 31e9d91..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoFromHeadersTest.java
+++ /dev/null
@@ -1,62 +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.jclouds.openstack.swift.functions;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import org.jclouds.http.HttpResponse;
-import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata;
-import org.jclouds.openstack.swift.internal.BasePayloadTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Tests behavior of {@code ParseObjectInfoFromHeaders}
- */
-@Test(groups = "unit")
-public class ParseObjectInfoFromHeadersTest extends BasePayloadTest {
-
- public void testEtagCaseIssue() {
- assertETagCanBeParsed("feb1",
- new byte[] { (byte) 0xfe, (byte) 0xb1 }
- );
- }
-
- public void testParseEtagWithQuotes() {
- assertETagCanBeParsed("\"feb1\"",
- new byte[] { (byte) 0xfe, (byte) 0xb1 }
- );
- }
-
- private void assertETagCanBeParsed(String etag, byte[] expectedHash) {
- ParseObjectInfoFromHeaders parser = i.getInstance(ParseObjectInfoFromHeaders.class);
-
- parser.setContext(requestForArgs(ImmutableList.<Object> of("container", "key")));
-
- HttpResponse response = HttpResponse.builder().statusCode(200).message("ok").payload("")
- .addHeader("Last-Modified", "Fri, 12 Jun 2007 13:40:18 GMT")
- .addHeader("Content-Length", "0")
- .addHeader("Etag", etag).build();
-
- response.getPayload().getContentMetadata().setContentType("text/plain");
- MutableObjectInfoWithMetadata md = parser.apply(response);
- assertNotNull(md.getHash());
- assertEquals(md.getHash(), expectedHash);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoListFromJsonResponseTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoListFromJsonResponseTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoListFromJsonResponseTest.java
deleted file mode 100644
index 3e8d685..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoListFromJsonResponseTest.java
+++ /dev/null
@@ -1,65 +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.jclouds.openstack.swift.functions;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.Invokable;
-import com.google.gson.Gson;
-import org.jclouds.json.internal.GsonWrapper;
-import org.jclouds.openstack.swift.domain.ObjectInfo;
-import org.jclouds.openstack.swift.options.ListContainerOptions;
-import org.jclouds.reflect.Invocation;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.Test;
-
-import java.io.InputStream;
-
-import static org.testng.Assert.assertEquals;
-
-@Test(groups = "unit")
-public class ParseObjectInfoListFromJsonResponseTest {
-
- @Test
- public void testNoUrlDecodingOfResponse() throws Exception {
- // '%x' is not a valid URL encoding
- String contentName = "swift-test-content-%x-1401395399020";
-
- String jsonObjectList =
- "[{\"last_modified\": \"2014-05-29T20:30:03.845660\", " +
- "\"bytes\": 19, " +
- "\"name\": \"" + contentName + "\", " +
- "\"content_type\": \"application/unknown\"}]";
-
- InputStream stream = Strings2.toInputStream(jsonObjectList);
-
- ParseObjectInfoListFromJsonResponse parser =
- new ParseObjectInfoListFromJsonResponse(new GsonWrapper(new Gson()));
-
- GeneratedHttpRequest.Builder builder = new GeneratedHttpRequest.Builder();
- builder.method("method")
- .endpoint("http://test.org/test")
- .invocation(Invocation.create(Invokable.from(Object.class.getMethod("toString", null)),
- ImmutableList.<Object>of("container-name", new ListContainerOptions[0])))
- .caller(null);
-
- parser.setContext(builder.build());
-
- ObjectInfo objectInfo = parser.apply(stream).iterator().next();
- assertEquals(objectInfo.getName(), contentName);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/handlers/ParseSwiftErrorFromHttpResponseTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/handlers/ParseSwiftErrorFromHttpResponseTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/handlers/ParseSwiftErrorFromHttpResponseTest.java
deleted file mode 100644
index 83f7f83..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/handlers/ParseSwiftErrorFromHttpResponseTest.java
+++ /dev/null
@@ -1,132 +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.jclouds.openstack.swift.handlers;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reportMatcher;
-import static org.easymock.EasyMock.verify;
-
-import java.net.URI;
-
-import org.easymock.IArgumentMatcher;
-import org.jclouds.blobstore.ContainerNotFoundException;
-import org.jclouds.blobstore.KeyNotFoundException;
-import org.jclouds.http.HttpCommand;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpRequest.Builder;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.openstack.swift.CopyObjectException;
-import org.jclouds.openstack.swift.reference.SwiftHeaders;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Strings;
-
-@Test(groups = { "unit" })
-public class ParseSwiftErrorFromHttpResponseTest {
-
- @Test
- public void test404SetsCopyObjectException() {
- assertCodeMakes("HEAD",
- URI.create("http://host/v1/MossoCloudFS_7064cdb1d49d4dcba3c899ac33e8409d/adriancole-blobstore1/key"), 404,
- "Not Found", "text/plain", "", "/bad/source/path", CopyObjectException.class);
- }
-
- @Test
- public void test404SetsKeyNotFoundExceptionMosso() {
- assertCodeMakes("HEAD",
- URI.create("http://host/v1/MossoCloudFS_7064cdb1d49d4dcba3c899ac33e8409d/adriancole-blobstore1/key"), 404,
- "Not Found", "", KeyNotFoundException.class);
- }
-
- @Test
- public void test404SetsKeyNotFoundExceptionSwift() {
- assertCodeMakes("HEAD",
- URI.create("http://67.202.39.175:8080/v1/AUTH_7064cdb1d49d4dcba3c899ac33e8409d/adriancole-blobstore1/key"),
- 404, "Not Found", "", KeyNotFoundException.class);
- }
-
- @Test
- public void test404SetsContainerNotFoundExceptionMosso() {
- assertCodeMakes("HEAD",
- URI.create("http://host/v1/MossoCloudFS_7064cdb1d49d4dcba3c899ac33e8409d/adriancole-blobstore1"), 404,
- "Not Found", "", ContainerNotFoundException.class);
- }
-
- @Test
- public void test404SetsContainerNotFoundExceptionSwift() {
- assertCodeMakes("HEAD",
- URI.create("http://67.202.39.175:8080/v1/AUTH_7064cdb1d49d4dcba3c899ac33e8409d/adriancole-blobstore1"),
- 404, "Not Found", "", ContainerNotFoundException.class);
- }
-
- private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content,
- Class<? extends Exception> expected) {
- assertCodeMakes(method, uri, statusCode, message, "text/plain", content, expected);
- }
-
- private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType,
- String content, Class<? extends Exception> expected) {
- assertCodeMakes(method, uri, statusCode, message, contentType, content, "", expected);
- }
-
- private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType,
- String content, String copyObjectSourcePath, Class<? extends Exception> expected) {
- ParseSwiftErrorFromHttpResponse function = new ParseSwiftErrorFromHttpResponse();
-
- HttpCommand command = createMock(HttpCommand.class);
- Builder<?> requestBuilder = HttpRequest.builder().method(method).endpoint(uri);
-
- if (!Strings.isNullOrEmpty(copyObjectSourcePath)) {
- requestBuilder.addHeader(SwiftHeaders.OBJECT_COPY_FROM, copyObjectSourcePath);
- }
-
- HttpRequest request = requestBuilder.build();
- HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build();
- response.getPayload().getContentMetadata().setContentType(contentType);
-
- expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
- command.setException(classEq(expected));
-
- replay(command);
-
- function.handleError(command, response);
-
- verify(command);
- }
-
- public static Exception classEq(final Class<? extends Exception> in) {
- reportMatcher(new IArgumentMatcher() {
-
- @Override
- public void appendTo(StringBuffer buffer) {
- buffer.append("classEq(");
- buffer.append(in);
- buffer.append(")");
- }
-
- @Override
- public boolean matches(Object arg) {
- return arg.getClass() == in;
- }
-
- });
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BasePayloadTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BasePayloadTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BasePayloadTest.java
deleted file mode 100644
index 8142397..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BasePayloadTest.java
+++ /dev/null
@@ -1,58 +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.jclouds.openstack.swift.internal;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Properties;
-
-import org.jclouds.functions.ExpandProperties;
-import org.jclouds.json.config.GsonModule;
-import org.jclouds.json.config.GsonModule.DateAdapter;
-import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
-import org.jclouds.openstack.swift.SwiftApiMetadata;
-import org.jclouds.reflect.Invocation;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-
-import com.google.common.base.Throwables;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.name.Names;
-
-public class BasePayloadTest {
- protected Injector i = Guice.createInjector(new AbstractModule() {
- @Override
- protected void configure() {
- Properties expanded = new ExpandProperties().apply(new SwiftApiMetadata().getDefaultProperties());
- Names.bindProperties(binder(), expanded);
- bind(DateAdapter.class).to(Iso8601DateAdapter.class);
- }
- }, new GsonModule());
-
- protected GeneratedHttpRequest requestForArgs(List<Object> args) {
- try {
- Invocation invocation = Invocation.create(method(String.class, "toString"), args);
- return GeneratedHttpRequest.builder().method("POST").endpoint(URI.create("http://localhost/key"))
- .invocation(invocation).build();
- } catch (SecurityException e) {
- throw Throwables.propagate(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BaseSwiftExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BaseSwiftExpectTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BaseSwiftExpectTest.java
deleted file mode 100644
index 96438a1..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BaseSwiftExpectTest.java
+++ /dev/null
@@ -1,66 +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.jclouds.openstack.swift.internal;
-
-import java.util.Properties;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.rest.internal.BaseRestApiExpectTest;
-
-/**
- * Base class for writing Swift Expect tests
- */
-public class BaseSwiftExpectTest<T> extends BaseRestApiExpectTest<T> {
-
- protected String endpoint = "http://myhost:8080/auth";
- protected HttpRequest authRequest;
- public BaseSwiftExpectTest() {
- provider = "swift";
- identity = "test:tester";
- credential = "testing";
- authRequest = HttpRequest.builder()
- .method("GET")
- .endpoint(endpoint + "/v1.0")
- .addHeader("X-Auth-User", identity)
- .addHeader("X-Auth-Key", credential)
- .addHeader("Accept", "*/*")
- .addHeader("Host", "myhost:8080").build();
- }
-
- protected String authToken = "AUTH_tk36dabe83ca744cc296a98ec46089ec35";
-
- protected String swiftEndpoint = "http://127.0.0.1:8080/v1/AUTH_test";
-
- /**
- * often swift returns the localhost url when requested via a dns name. this
- * test ensures that replacement works.
- */
- protected String swiftEndpointWithHostReplaced = swiftEndpoint.replace("127.0.0.1", "myhost");
-
- protected HttpResponse authResponse = HttpResponse.builder()
- .statusCode(200)
- .message("HTTP/1.1 200 OK")
- .addHeader("X-Storage-Url", swiftEndpoint)
- .addHeader("X-Auth-Token", authToken).build();
-
- protected Properties setupProperties() {
- Properties props = super.setupProperties();
- props.put(provider + ".endpoint", endpoint);
- return props;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BaseSwiftKeystoneExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BaseSwiftKeystoneExpectTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BaseSwiftKeystoneExpectTest.java
deleted file mode 100644
index 844b5a8..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BaseSwiftKeystoneExpectTest.java
+++ /dev/null
@@ -1,77 +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.jclouds.openstack.swift.internal;
-
-import java.util.Properties;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.openstack.keystone.v2_0.internal.KeystoneFixture;
-import org.jclouds.rest.internal.BaseRestApiExpectTest;
-
-/**
- * Base class for writing Swift Keystone Expect tests
- */
-public class BaseSwiftKeystoneExpectTest<T> extends BaseRestApiExpectTest<T> {
- protected HttpRequest keystoneAuthWithUsernameAndPassword;
- protected HttpRequest keystoneAuthWithUsernameAndPasswordAndTenantName;
- protected HttpRequest keystoneAuthWithAccessKeyAndSecretKeyAndTenantName;
- protected String authToken;
- protected HttpResponse responseWithKeystoneAccess;
- protected HttpRequest keystoneAuthWithAccessKeyAndSecretKeyAndTenantId;
- protected String identityWithTenantId;
-
- public BaseSwiftKeystoneExpectTest() {
- provider = "swift-keystone";
- keystoneAuthWithUsernameAndPassword = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPassword(identity,
- credential);
- keystoneAuthWithUsernameAndPasswordAndTenantName = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPasswordAndTenantName(identity,
- credential);
- keystoneAuthWithAccessKeyAndSecretKeyAndTenantName = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKeyAndTenantName(identity,
- credential);
- keystoneAuthWithAccessKeyAndSecretKeyAndTenantId = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKeyAndTenantId(identity,
- credential);
-
- authToken = KeystoneFixture.INSTANCE.getAuthToken();
- responseWithKeystoneAccess = KeystoneFixture.INSTANCE.responseWithAccess();
- // now, createContext arg will need tenant prefix
- identityWithTenantId = KeystoneFixture.INSTANCE.getTenantId() + ":" + identity;
- identity = KeystoneFixture.INSTANCE.getTenantName() + ":" + identity;
- }
-
- @Override
- protected Properties setupProperties() {
- Properties overrides = super.setupProperties();
- // hpcloud or openstack
- overrides.setProperty("jclouds.regions", "region-a.geo-1,RegionOne");
- return overrides;
- }
-
- protected HttpRequest.Builder<?> authenticatedGET() {
- return HttpRequest.builder()
- .method("GET")
- .addHeader("Accept", MediaType.APPLICATION_JSON)
- .addHeader("X-Auth-Token", authToken);
- }
-
- @Override
- protected HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) {
- return HttpRequestComparisonType.JSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java
deleted file mode 100644
index 4ddf183..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java
+++ /dev/null
@@ -1,69 +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.jclouds.openstack.swift.keystone;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Properties;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.openstack.keystone.v2_0.internal.KeystoneFixture;
-import org.jclouds.openstack.swift.SwiftKeystoneClient;
-import org.jclouds.openstack.swift.internal.BaseSwiftKeystoneExpectTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @see KeystoneProperties#CREDENTIAL_TYPE
- */
-@Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest")
-public class AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest extends BaseSwiftKeystoneExpectTest<SwiftKeystoneClient> {
- public AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest() {
- identity = identityWithTenantId;
- }
-
- /**
- * this reflects the properties that a user would pass to createContext
- */
- @Override
- protected Properties setupProperties() {
- Properties contextProperties = super.setupProperties();
- contextProperties.setProperty("jclouds.keystone.credential-type", "apiAccessKeyCredentials");
- contextProperties.setProperty("jclouds.keystone.tenant-id", KeystoneFixture.INSTANCE.getTenantId());
- return contextProperties;
- }
-
- public void testContainerExistsWhenResponseIs2xx() throws Exception {
- HttpRequest containerExists = HttpRequest.builder()
- .method("HEAD")
- .endpoint("https://objects.jclouds.org/v1.0/40806637803162/container")
- .addHeader("Accept", MediaType.WILDCARD)
- .addHeader("X-Auth-Token", authToken).build();
-
- HttpResponse containerExistsResponse = HttpResponse.builder().statusCode(200).build();
-
- SwiftKeystoneClient clientWhenContainerExists = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantId,
- responseWithKeystoneAccess, containerExists, containerExistsResponse);
-
- assertEquals(clientWhenContainerExists.containerExists("container"), true);
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java
deleted file mode 100644
index 7fda986..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java
+++ /dev/null
@@ -1,70 +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.jclouds.openstack.swift.keystone;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Properties;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.openstack.keystone.v2_0.internal.KeystoneFixture;
-import org.jclouds.openstack.swift.SwiftKeystoneClient;
-import org.jclouds.openstack.swift.internal.BaseSwiftKeystoneExpectTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @see KeystoneProperties#CREDENTIAL_TYPE
- */
-@Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest")
-public class AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest extends BaseSwiftKeystoneExpectTest<SwiftKeystoneClient> {
- public AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest() {
- identity = "identity";
- }
-
- /**
- * this reflects the properties that a user would pass to createContext
- */
- @Override
- protected Properties setupProperties() {
- Properties contextProperties = super.setupProperties();
- contextProperties.setProperty("jclouds.keystone.credential-type", "apiAccessKeyCredentials");
- contextProperties.setProperty("jclouds.keystone.tenant-name", KeystoneFixture.INSTANCE.getTenantName());
- return contextProperties;
- }
-
- public void testContainerExistsWhenResponseIs2xx() throws Exception {
- HttpRequest containerExists = HttpRequest.builder()
- .method("HEAD")
- .endpoint("https://objects.jclouds.org/v1.0/40806637803162/container")
- .addHeader("Accept", MediaType.WILDCARD)
- .addHeader("X-Auth-Token", authToken).build();
-
- HttpResponse containerExistsResponse = HttpResponse.builder().statusCode(200).build();
-
- SwiftKeystoneClient clientWhenContainerExists = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName,
- responseWithKeystoneAccess, containerExists, containerExistsResponse);
-
- assertEquals(clientWhenContainerExists.containerExists("container"), true);
- }
-
-
-}
-
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/AccessKeyAndSecretKeyAuthenticationExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/AccessKeyAndSecretKeyAuthenticationExpectTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/AccessKeyAndSecretKeyAuthenticationExpectTest.java
deleted file mode 100644
index d6a2d97..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/AccessKeyAndSecretKeyAuthenticationExpectTest.java
+++ /dev/null
@@ -1,64 +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.jclouds.openstack.swift.keystone;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Properties;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.openstack.swift.SwiftKeystoneClient;
-import org.jclouds.openstack.swift.internal.BaseSwiftKeystoneExpectTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @see KeystoneProperties#CREDENTIAL_TYPE
- */
-@Test(groups = "unit", testName = "AccessKeyAndSecretKeyAuthenticationExpectTest")
-public class AccessKeyAndSecretKeyAuthenticationExpectTest extends BaseSwiftKeystoneExpectTest<SwiftKeystoneClient> {
-
- /**
- * this reflects the properties that a user would pass to createContext
- */
- @Override
- protected Properties setupProperties() {
- Properties contextProperties = super.setupProperties();
- contextProperties.setProperty("jclouds.keystone.credential-type", "apiAccessKeyCredentials");
- return contextProperties;
- }
-
- public void testContainerExistsWhenResponseIs2xx() throws Exception {
- HttpRequest containerExists = HttpRequest.builder()
- .method("HEAD")
- .endpoint("https://objects.jclouds.org/v1.0/40806637803162/container")
- .addHeader("Accept", MediaType.WILDCARD)
- .addHeader("X-Auth-Token", authToken).build();
-
- HttpResponse containerExistsResponse = HttpResponse.builder().statusCode(200).build();
-
- SwiftKeystoneClient clientWhenContainerExists = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName,
- responseWithKeystoneAccess, containerExists, containerExistsResponse);
-
- assertEquals(clientWhenContainerExists.containerExists("container"), true);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/PasswordAuthenticationExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/PasswordAuthenticationExpectTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/PasswordAuthenticationExpectTest.java
deleted file mode 100644
index 841ed47..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/PasswordAuthenticationExpectTest.java
+++ /dev/null
@@ -1,67 +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.jclouds.openstack.swift.keystone;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Properties;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.openstack.swift.SwiftKeystoneClient;
-import org.jclouds.openstack.swift.internal.BaseSwiftKeystoneExpectTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @see KeystoneProperties#CREDENTIAL_TYPE
- */
-@Test(groups = "unit", testName = "PasswordAuthenticationExpectTest")
-public class PasswordAuthenticationExpectTest extends BaseSwiftKeystoneExpectTest<SwiftKeystoneClient> {
- public PasswordAuthenticationExpectTest() {
- identity = "identity";
- }
-
- /**
- * this reflects the properties that a user would pass to createContext
- */
- @Override
- protected Properties setupProperties() {
- Properties contextProperties = super.setupProperties();
- contextProperties.setProperty("jclouds.keystone.credential-type", "passwordCredentials");
- return contextProperties;
- }
-
- public void testContainerExistsWhenResponseIs2xx() throws Exception {
- HttpRequest containerExists = HttpRequest.builder()
- .method("HEAD")
- .endpoint("https://objects.jclouds.org/v1.0/40806637803162/container")
- .addHeader("Accept", MediaType.WILDCARD)
- .addHeader("X-Auth-Token", authToken).build();
-
- HttpResponse containerExistsResponse = HttpResponse.builder().statusCode(200).build();
-
- SwiftKeystoneClient clientWhenContainerExists = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
- responseWithKeystoneAccess, containerExists, containerExistsResponse);
-
- assertEquals(clientWhenContainerExists.containerExists("container"), true);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/PasswordAuthenticationWithTenantNameExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/PasswordAuthenticationWithTenantNameExpectTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/PasswordAuthenticationWithTenantNameExpectTest.java
deleted file mode 100644
index 10064d4..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/keystone/PasswordAuthenticationWithTenantNameExpectTest.java
+++ /dev/null
@@ -1,64 +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.jclouds.openstack.swift.keystone;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Properties;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.openstack.swift.SwiftKeystoneClient;
-import org.jclouds.openstack.swift.internal.BaseSwiftKeystoneExpectTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @see KeystoneProperties#CREDENTIAL_TYPE
- */
-@Test(groups = "unit", testName = "PasswordAuthenticationWithTenantNameExpectTest")
-public class PasswordAuthenticationWithTenantNameExpectTest extends BaseSwiftKeystoneExpectTest<SwiftKeystoneClient> {
-
- /**
- * this reflects the properties that a user would pass to createContext
- */
- @Override
- protected Properties setupProperties() {
- Properties contextProperties = super.setupProperties();
- contextProperties.setProperty("jclouds.keystone.credential-type", "passwordCredentials");
- return contextProperties;
- }
-
- public void testContainerExistsWhenResponseIs2xx() throws Exception {
- HttpRequest containerExists = HttpRequest.builder()
- .method("HEAD")
- .endpoint("https://objects.jclouds.org/v1.0/40806637803162/container")
- .addHeader("Accept", MediaType.WILDCARD)
- .addHeader("X-Auth-Token", authToken).build();
-
- HttpResponse containerExistsResponse = HttpResponse.builder().statusCode(200).build();
-
- SwiftKeystoneClient clientWhenContainerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
- responseWithKeystoneAccess, containerExists, containerExistsResponse);
-
- assertEquals(clientWhenContainerExists.containerExists("container"), true);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/592a4e7c/apis/swift/src/test/java/org/jclouds/openstack/swift/options/CreateContainerOptionsTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/options/CreateContainerOptionsTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/options/CreateContainerOptionsTest.java
deleted file mode 100644
index 333560e..0000000
--- a/apis/swift/src/test/java/org/jclouds/openstack/swift/options/CreateContainerOptionsTest.java
+++ /dev/null
@@ -1,66 +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.jclouds.openstack.swift.options;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.openstack.swift.reference.SwiftHeaders;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Tests behavior of {@code CreateContainerOptions}
- */
-@Test(groups = "unit")
-public class CreateContainerOptionsTest {
-
- public void testPublicAccess() {
- CreateContainerOptions options = new CreateContainerOptions().withPublicAccess();
- assertEquals(ImmutableList.of(".r:*,.rlistings"),
- options.buildRequestHeaders().get("X-Container-Read"));
- }
-
- public void testPublicAccessStatic() {
- CreateContainerOptions options = CreateContainerOptions.Builder.withPublicAccess();
- assertEquals(ImmutableList.of(".r:*,.rlistings"),
- options.buildRequestHeaders().get("X-Container-Read"));
- }
-
- public void testMetadata() {
- CreateContainerOptions options = new CreateContainerOptions().withMetadata(ImmutableMap
- .of("test", "foo"));
- assertEquals(ImmutableList.of("foo"), options.buildRequestHeaders().get(
- SwiftHeaders.CONTAINER_METADATA_PREFIX + "test"));
- }
-
- public void testMetadataAlreadyPrefixed() {
- CreateContainerOptions options = new CreateContainerOptions().withMetadata(ImmutableMap
- .of(SwiftHeaders.CONTAINER_METADATA_PREFIX + "test", "foo"));
- assertEquals(ImmutableList.of("foo"), options.buildRequestHeaders().get(
- SwiftHeaders.CONTAINER_METADATA_PREFIX + "test"));
- }
-
- public void testMetadataStatic() {
- CreateContainerOptions options = CreateContainerOptions.Builder
- .withMetadata(ImmutableMap.of("test", "foo"));
- assertEquals(ImmutableList.of("foo"), options.buildRequestHeaders().get(
- SwiftHeaders.CONTAINER_METADATA_PREFIX + "test"));
- }
-
-}