Repository: jclouds-labs-openstack Updated Branches: refs/heads/master b84b0898c -> 43aa5b3a0
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java ---------------------------------------------------------------------- diff --git a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java new file mode 100644 index 0000000..66b4b64 --- /dev/null +++ b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java @@ -0,0 +1,39 @@ +/* + * 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.rackspace.cloudfiles.v1.blobstore.integration; + +import static org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes.API_KEY_CREDENTIALS; + +import java.util.Properties; + +import org.jclouds.openstack.swift.v1.blobstore.integration.SwiftServiceIntegrationLiveTest; +import org.testng.annotations.Test; + +@Test(groups = "live", testName = "CloudFilesServiceIntegrationLiveTest") +public class CloudFilesServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest { + + public CloudFilesServiceIntegrationLiveTest() { + provider = "rackspace-cloudfiles"; + } + + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + setIfTestSystemPropertyPresent(props, API_KEY_CREDENTIALS); + return props; + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesAccountApiLiveTest.java ---------------------------------------------------------------------- diff --git a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesAccountApiLiveTest.java b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesAccountApiLiveTest.java new file mode 100644 index 0000000..297ae7d --- /dev/null +++ b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesAccountApiLiveTest.java @@ -0,0 +1,38 @@ +/* + * 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.rackspace.cloudfiles.v1.features; + +import static org.testng.Assert.assertTrue; + +import org.jclouds.openstack.swift.v1.domain.Account; +import org.jclouds.openstack.swift.v1.features.AccountApiLiveTest; +import org.testng.annotations.Test; + +@Test(groups = "live", testName = "CloudFilesAccountApiLiveTest") +public class CloudFilesAccountApiLiveTest extends AccountApiLiveTest { + + public CloudFilesAccountApiLiveTest() { + provider = "rackspace-cloudfiles"; + } + + public void testUrlKeyExists() throws Exception { + for (String regionId : regions) { + Account account = api.accountApiInRegion(regionId).get(); + assertTrue(account.getTemporaryUrlKey().isPresent()); + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesBulkApiLiveTest.java ---------------------------------------------------------------------- diff --git a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesBulkApiLiveTest.java b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesBulkApiLiveTest.java new file mode 100644 index 0000000..331ab85 --- /dev/null +++ b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesBulkApiLiveTest.java @@ -0,0 +1,28 @@ +/* + * 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.rackspace.cloudfiles.v1.features; + +import org.jclouds.openstack.swift.v1.features.BulkApiLiveTest; +import org.testng.annotations.Test; + +@Test(groups = "live", testName = "CloudFilesBulkApiLiveTest") +public class CloudFilesBulkApiLiveTest extends BulkApiLiveTest { + + public CloudFilesBulkApiLiveTest() { + provider = "rackspace-cloudfiles"; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiLiveTest.java ---------------------------------------------------------------------- diff --git a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiLiveTest.java b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiLiveTest.java new file mode 100644 index 0000000..fe299ba --- /dev/null +++ b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiLiveTest.java @@ -0,0 +1,105 @@ +/* + * 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.rackspace.cloudfiles.v1.features; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.util.List; + +import org.jclouds.openstack.swift.v1.options.CreateContainerOptions; +import org.jclouds.openstack.swift.v1.options.ListContainerOptions; +import org.jclouds.rackspace.cloudfiles.v1.domain.CDNContainer; +import org.jclouds.rackspace.cloudfiles.v1.internal.BaseCloudFilesApiLiveTest; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author Jeremy Daggett + */ +@Test(groups = "live", testName = "CloudFilesCDNApiLiveTest") +public class CloudFilesCDNApiLiveTest extends BaseCloudFilesApiLiveTest { + + private String name = getClass().getSimpleName(); + + public CloudFilesCDNApiLiveTest() { + super(); + } + + public void testList() throws Exception { + for (String regionId : regions) { + CDNApi cdnApi = api.cdnApiInRegion(regionId); + + List<CDNContainer> cdnResponse = cdnApi.list().toList(); + assertNotNull(cdnResponse); + for (CDNContainer cdnContainer : cdnResponse) { + assertNotNull(cdnContainer.getName()); + assertTrue(cdnContainer.isEnabled()); + assertNotNull(cdnContainer.isLogRetentionEnabled()); + assertNotNull(cdnContainer.getTtl()); + assertNotNull(cdnContainer.getUri()); + assertNotNull(cdnContainer.getSslUri()); + assertNotNull(cdnContainer.getStreamingUri()); + assertNotNull(cdnContainer.getIosUri()); + } + } + } + + public void testListWithOptions() throws Exception { + String lexicographicallyBeforeName = name.substring(0, name.length() - 1); + for (String regionId : regions) { + ListContainerOptions options = ListContainerOptions.Builder.marker(lexicographicallyBeforeName); + CDNContainer cdnContainer = api.cdnApiInRegion(regionId).list(options).get(0); + + assertNotNull(cdnContainer.getName()); + assertTrue(cdnContainer.isEnabled()); + assertNotNull(cdnContainer.isLogRetentionEnabled()); + assertNotNull(cdnContainer.getTtl()); + assertNotNull(cdnContainer.getUri()); + assertNotNull(cdnContainer.getSslUri()); + assertNotNull(cdnContainer.getStreamingUri()); + assertNotNull(cdnContainer.getIosUri()); + } + } + + public void testGet() throws Exception { + for (String regionId : regions) { + CDNContainer cdnContainer = api.cdnApiInRegion(regionId).get(name); + assertNotNull(cdnContainer); + } + } + + @BeforeClass(groups = "live") + public void setup() { + super.setup(); + for (String regionId : regions) { + api.containerApiInRegion(regionId).createIfAbsent(name, CreateContainerOptions.NONE); + api.cdnApiInRegion(regionId).enable(name); + } + } + + @Override + @AfterClass(groups = "live") + public void tearDown() { + for (String regionId : regions) { + api.cdnApiInRegion(regionId).disable(name); + api.containerApiInRegion(regionId).deleteIfEmpty(name); + } + super.tearDown(); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiMockTest.java ---------------------------------------------------------------------- diff --git a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiMockTest.java b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiMockTest.java new file mode 100644 index 0000000..916496e --- /dev/null +++ b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiMockTest.java @@ -0,0 +1,381 @@ +/* + * 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.rackspace.cloudfiles.v1.features; + +import static com.google.common.base.Charsets.US_ASCII; +import static javax.ws.rs.core.HttpHeaders.CONTENT_LENGTH; +import static javax.ws.rs.core.HttpHeaders.CONTENT_TYPE; +import static javax.ws.rs.core.HttpHeaders.ETAG; +import static javax.ws.rs.core.HttpHeaders.LAST_MODIFIED; +import static org.jclouds.rackspace.cloudfiles.v1.options.UpdateCDNContainerOptions.Builder.enabled; +import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_ENABLED; +import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_IOS_URI; +import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_LOG_RETENTION; +import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_SSL_URI; +import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_STREAMING_URI; +import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_TTL; +import static org.jclouds.rackspace.cloudfiles.v1.reference.CloudFilesHeaders.CDN_URI; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import java.net.URI; +import java.util.List; + +import org.jclouds.io.Payload; +import org.jclouds.io.Payloads; +import org.jclouds.openstack.swift.v1.options.ListContainerOptions; +import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest; +import org.jclouds.rackspace.cloudfiles.v1.CloudFilesApi; +import org.jclouds.rackspace.cloudfiles.v1.domain.CDNContainer; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; + +@Test(groups = "unit", testName = "CloudFilesCDNApiMockTest") +public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesApi> { + + List<String> emails = ImmutableList.of("[email protected]", "[email protected]"); + + public void testList() throws Exception { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/cdn_container_list.json")))); + + try { + CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles"); + CDNApi cdnApi = api.cdnApiInRegion("DFW"); + + ImmutableList<CDNContainer> cdnContainers = cdnApi.list().toList(); + + assertEquals(cdnContainers, mockContainers); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertRequest(server.takeRequest(), "GET", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/?format=json&enabled_only=true"); + } finally { + server.shutdown(); + } + } + + public void testListWithOptions() throws Exception { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/cdn_container_list_at.json")))); + + try { + CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles"); + ListContainerOptions options = ListContainerOptions.Builder.marker("cdn-container-3"); + ImmutableList<CDNContainer> containers = api.cdnApiInRegion("DFW").list(options).toList(); + + for(CDNContainer container : containers) { + checkCDNContainer(container); + } + + assertEquals(containers, mockContainers.subList(2, mockContainers.size())); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertRequest(server.takeRequest(), "GET", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/?format=json&enabled_only=true&marker=cdn-container-3"); + } finally { + server.shutdown(); + } + } + + public void testEnableAndDisable() throws Exception { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(enabledResponse().setResponseCode(201))); + server.enqueue(addCommonHeaders(enabledResponse().setResponseCode(201))); + server.enqueue(addCommonHeaders(disabledResponse().setResponseCode(201))); + + try { + CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles"); + CDNApi cdnApi = api.cdnApiInRegion("DFW"); + + // enable a CDN Container + URI enabledContainer = cdnApi.enable("container-1"); + assertNotNull(enabledContainer); + + // ensure that it is disabled + assertTrue(cdnApi.disable("container-1")); + + // get the container from the CDN and ensure that it is disabled + CDNContainer disabledContainer = cdnApi.get("container-1"); + checkCDNContainer(disabledContainer); + assertFalse(disabledContainer.isEnabled()); + + assertEquals(server.getRequestCount(), 4); + assertAuthentication(server); + assertRequest(server.takeRequest(), "PUT", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/container-1"); + assertRequest(server.takeRequest(), "PUT", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/container-1"); + assertRequest(server.takeRequest(), "HEAD", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/container-1"); + } finally { + server.shutdown(); + } + } + + public void testEnableWithTTL() throws Exception { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(enabledResponse().setResponseCode(201))); + + try { + CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles"); + CDNApi cdnApi = api.cdnApiInRegion("DFW"); + + // enable a CDN Container with a TTL + URI enabledContainer = cdnApi.enable("container-1", 777777); + assertNotNull(enabledContainer); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertRequest(server.takeRequest(), "PUT", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/container-1"); + } finally { + server.shutdown(); + } + } + + public void testGet() throws Exception { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(enabledResponse().setResponseCode(201))); + + try { + CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles"); + CDNApi cdnApi = api.cdnApiInRegion("DFW"); + + CDNContainer cdnContainer = cdnApi.get("container-1"); + checkCDNContainer(cdnContainer); + assertEquals(mockCDNContainer, cdnContainer); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertRequest(server.takeRequest(), "HEAD", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/container-1"); + } finally { + server.shutdown(); + } + } + + public void testGetFail() throws Exception { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404))); + + try { + CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles"); + CDNApi cdnApi = api.cdnApiInRegion("DFW"); + + CDNContainer cdnContainer = cdnApi.get("container-1"); + + assertAuthentication(server); + assertRequest(server.takeRequest(), "HEAD", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/container-1"); + assertNull(cdnContainer); + } finally { + server.shutdown(); + } + } + + public void testPurgeObject() throws Exception { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201))); + + try { + CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles"); + CDNApi cdnApi = api.cdnApiInRegion("DFW"); + + // purge the object + assertTrue(cdnApi.purgeObject("myContainer", "myObject", emails)); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertRequest(server.takeRequest(), "DELETE", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer/myObject"); + } finally { + server.shutdown(); + } + } + + public void testUpdate() throws Exception { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")).setResponseCode(200))); //POST + server.enqueue(addCommonHeaders(enabledResponse().setResponseCode(200))); + server.enqueue(addCommonHeaders(updatedResponse().setResponseCode(204))); + server.enqueue(addCommonHeaders(updatedResponse().setResponseCode(200))); + + try { + CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles"); + CDNApi cdnApi = api.cdnApiInRegion("DFW"); + + CDNContainer cdnContainer = cdnApi.get("container-1"); + checkCDNContainer(cdnContainer); + + // update the CDN Container + assertTrue(cdnApi.update("container-1", enabled(false).logRetention(true).ttl(7654321))); + + cdnContainer = cdnApi.get("container-1"); + checkCDNContainer(cdnContainer); + + CDNContainer updatedContainer = CDNContainer.builder() + .name("container-1") + .enabled(false) + .logRetention(true) + .ttl(7654321) + .uri(URI.create("http://id-1.cdn.rackspace.com")) + .sslUri(URI.create("https://ssl-id-1.ssl.rackspace.com")) + .streamingUri(URI.create("http://streaming-id-1.stream.rackspace.com")) + .iosUri(URI.create("http://ios-id-1.iosr.rackspace.com")) + .build(); + + assertEquals(updatedContainer, cdnContainer); + + assertEquals(server.getRequestCount(), 4); + assertAuthentication(server); + assertRequest(server.takeRequest(), "HEAD", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/container-1"); + assertRequest(server.takeRequest(), "POST", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/container-1"); + assertRequest(server.takeRequest(), "HEAD", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/container-1"); + } finally { + server.shutdown(); + } + } + + private static final void checkCDNContainer(CDNContainer cdnContainer) { + assertNotNull(cdnContainer.getName()); + assertNotNull(cdnContainer.isEnabled()); + assertNotNull(cdnContainer.isLogRetentionEnabled()); + assertNotNull(cdnContainer.getTtl()); + assertNotNull(cdnContainer.getUri()); + assertNotNull(cdnContainer.getSslUri()); + assertNotNull(cdnContainer.getStreamingUri()); + assertNotNull(cdnContainer.getIosUri()); + } + + private static final CDNContainer mockCDNContainer = CDNContainer.builder() + .name("container-1") + .enabled(true) + .logRetention(false) + .ttl(777777) + .uri(URI.create("http://id-1.cdn.rackspace.com")) + .sslUri(URI.create("https://ssl-id-1.ssl.rackspace.com")) + .streamingUri(URI.create("http://streaming-id-1.stream.rackspace.com")) + .iosUri(URI.create("http://ios-id-1.iosr.rackspace.com")) + .build(); + + private static MockResponse enabledResponse() { + return new MockResponse() + .addHeader(CDN_ENABLED, "true") + .addHeader(CDN_LOG_RETENTION, "false") + .addHeader(CDN_TTL, "777777") + .addHeader(CDN_URI,"http://id-1.cdn.rackspace.com") + .addHeader(CDN_SSL_URI, "https://ssl-id-1.ssl.rackspace.com") + .addHeader(CDN_STREAMING_URI, "http://streaming-id-1.stream.rackspace.com") + .addHeader(CDN_IOS_URI, "http://ios-id-1.iosr.rackspace.com") + .addHeader(CONTENT_LENGTH, "0") + .addHeader(CONTENT_TYPE, "text/plain; charset=UTF-8"); + } + + private static MockResponse disabledResponse() { + return new MockResponse() + .addHeader(CDN_ENABLED, "false") + .addHeader(CDN_LOG_RETENTION, "false") + .addHeader(CDN_TTL, "777777") + .addHeader(CDN_URI,"http://id-1.cdn.rackspace.com") + .addHeader(CDN_SSL_URI, "https://ssl-id-1.ssl.rackspace.com") + .addHeader(CDN_STREAMING_URI, "http://streaming-id-1.stream.rackspace.com") + .addHeader(CDN_IOS_URI, "http://ios-id-1.iosr.rackspace.com") + .addHeader(CONTENT_LENGTH, "0") + .addHeader(CONTENT_TYPE, "text/plain; charset=UTF-8"); + } + + private static MockResponse updatedResponse() { + return new MockResponse() + .addHeader(CDN_ENABLED, "false") + .addHeader(CDN_LOG_RETENTION, "true") + .addHeader(CDN_TTL, "7654321") + .addHeader(CDN_URI,"http://id-1.cdn.rackspace.com") + .addHeader(CDN_SSL_URI, "https://ssl-id-1.ssl.rackspace.com") + .addHeader(CDN_STREAMING_URI, "http://streaming-id-1.stream.rackspace.com") + .addHeader(CDN_IOS_URI, "http://ios-id-1.iosr.rackspace.com") + .addHeader(CONTENT_LENGTH, "0") + .addHeader(CONTENT_TYPE, "text/plain; charset=UTF-8"); + } + + private static final ImmutableList<CDNContainer> mockContainers = ImmutableList.of( + CDNContainer.builder() + .name("cdn-container-1") + .enabled(true) + .logRetention(false) + .ttl(259200) + .uri(URI.create("http://id-1.cdn.rackspace.com")) + .sslUri(URI.create("https://ssl-id-1.ssl.rackspace.com")) + .streamingUri(URI.create("http://streaming-id-1.stream.rackspace.com")) + .iosUri(URI.create("http://ios-id-1.iosr.rackspace.com")) + .build(), + CDNContainer.builder() + .name("cdn-container-2") + .enabled(true) + .logRetention(true) + .ttl(259200) + .uri(URI.create("http://id-2.cdn.rackspace.com")) + .sslUri(URI.create("https://ssl-id-2.ssl.rackspace.com")) + .streamingUri(URI.create("http://streaming-id-2.stream.rackspace.com")) + .iosUri(URI.create("http://ios-id-2.iosr.rackspace.com")) + .build(), + CDNContainer.builder() + .name("cdn-container-3") + .enabled(true) + .logRetention(false) + .ttl(259200) + .uri(URI.create("http://id-3.cdn.rackspace.com")) + .sslUri(URI.create("https://ssl-id-3.ssl.rackspace.com")) + .streamingUri(URI.create("http://streaming-id-3.stream.rackspace.com")) + .iosUri(URI.create("http://ios-id-3.iosr.rackspace.com")) + .build(), + CDNContainer.builder() + .name("cdn-container-4") + .enabled(true) + .logRetention(true) + .ttl(777777) + .uri(URI.create("http://id-4.cdn.rackspace.com")) + .sslUri(URI.create("https://ssl-id-4.ssl.rackspace.com")) + .streamingUri(URI.create("http://streaming-id-4.stream.rackspace.com")) + .iosUri(URI.create("http://ios-id-4.iosr.rackspace.com")) + .build()); + + private static MockResponse objectResponse() { + return new MockResponse() + .addHeader(LAST_MODIFIED, "Fri, 12 Jun 2010 13:40:18 GMT") + .addHeader(ETAG, "8a964ee2a5e88be344f36c22562a6486") + // TODO: MWS doesn't allow you to return content length w/o content + // on HEAD! + .setBody("ABCD".getBytes(US_ASCII)) + .addHeader(CONTENT_LENGTH, "4").addHeader(CONTENT_TYPE, "text/plain; charset=UTF-8"); + } + + private static final byte[] NO_CONTENT = new byte[] {}; + + private static Payload payload(long bytes, String contentType) { + Payload payload = Payloads.newByteArrayPayload(NO_CONTENT); + payload.getContentMetadata().setContentLength(bytes); + payload.getContentMetadata().setContentType(contentType); + return payload; + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesContainerApiLiveTest.java ---------------------------------------------------------------------- diff --git a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesContainerApiLiveTest.java b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesContainerApiLiveTest.java new file mode 100644 index 0000000..4db4e5a --- /dev/null +++ b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesContainerApiLiveTest.java @@ -0,0 +1,27 @@ +/* + * 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.rackspace.cloudfiles.v1.features; + +import org.jclouds.openstack.swift.v1.features.ContainerApiLiveTest; +import org.testng.annotations.Test; + +@Test(groups = "live", testName = "CloudFilesContainerApiLiveTest") +public class CloudFilesContainerApiLiveTest extends ContainerApiLiveTest { + public CloudFilesContainerApiLiveTest() { + provider = "rackspace-cloudfiles"; + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesObjectApiLiveTest.java ---------------------------------------------------------------------- diff --git a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesObjectApiLiveTest.java b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesObjectApiLiveTest.java new file mode 100644 index 0000000..a0ffa31 --- /dev/null +++ b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesObjectApiLiveTest.java @@ -0,0 +1,27 @@ +/* + * 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.rackspace.cloudfiles.v1.features; + +import org.jclouds.openstack.swift.v1.features.ObjectApiLiveTest; +import org.testng.annotations.Test; + +@Test(groups = "live", testName = "CloudFilesObjectApiLiveTest") +public class CloudFilesObjectApiLiveTest extends ObjectApiLiveTest { + public CloudFilesObjectApiLiveTest() { + provider = "rackspace-cloudfiles"; + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/internal/BaseCloudFilesApiLiveTest.java ---------------------------------------------------------------------- diff --git a/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/internal/BaseCloudFilesApiLiveTest.java b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/internal/BaseCloudFilesApiLiveTest.java new file mode 100644 index 0000000..6586cd1 --- /dev/null +++ b/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/internal/BaseCloudFilesApiLiveTest.java @@ -0,0 +1,37 @@ +/* + * 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.rackspace.cloudfiles.v1.internal; + +import static org.testng.Assert.assertNotNull; + +import org.jclouds.openstack.swift.v1.domain.Container; +import org.jclouds.openstack.swift.v1.internal.BaseSwiftApiLiveTest; +import org.jclouds.rackspace.cloudfiles.v1.CloudFilesApi; +import org.testng.annotations.Test; + +/** + * Base class for all Cloud Files API Live tests. + * + * @author Jeremy Daggett + */ +@Test(groups = "live", testName = "BaseCloudFilesApiLiveTest") +public abstract class BaseCloudFilesApiLiveTest extends BaseSwiftApiLiveTest<CloudFilesApi> { + + protected BaseCloudFilesApiLiveTest() { + provider = "rackspace-cloudfiles"; + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/rackspace-cloudfiles/src/test/resources/cdn_container_list.json ---------------------------------------------------------------------- diff --git a/rackspace-cloudfiles/src/test/resources/cdn_container_list.json b/rackspace-cloudfiles/src/test/resources/cdn_container_list.json new file mode 100644 index 0000000..4dce8db --- /dev/null +++ b/rackspace-cloudfiles/src/test/resources/cdn_container_list.json @@ -0,0 +1,42 @@ +[ + { + "cdn_streaming_uri": "http://streaming-id-1.stream.rackspace.com", + "name": "cdn-container-1", + "cdn_ios_uri": "http://ios-id-1.iosr.rackspace.com", + "cdn_ssl_uri": "https://ssl-id-1.ssl.rackspace.com", + "cdn_enabled": true, + "ttl": 259200, + "log_retention": false, + "cdn_uri": "http://id-1.cdn.rackspace.com" + }, + { + "cdn_streaming_uri": "http://streaming-id-2.stream.rackspace.com", + "name": "cdn-container-2", + "cdn_ios_uri": "http://ios-id-2.iosr.rackspace.com", + "cdn_ssl_uri": "https://ssl-id-2.ssl.rackspace.com", + "cdn_enabled": true, + "ttl": 259200, + "log_retention": true, + "cdn_uri": "http://id-2.cdn.rackspace.com" + }, + { + "cdn_streaming_uri": "http://streaming-id-3.stream.rackspace.com", + "name": "cdn-container-3", + "cdn_ios_uri": "http://ios-id-3.iosr.rackspace.com", + "cdn_ssl_uri": "https://ssl-id-3.ssl.rackspace.com", + "cdn_enabled": true, + "ttl": 259200, + "log_retention": false, + "cdn_uri": "http://id-3.cdn.rackspace.com" + }, + { + "cdn_streaming_uri": "http://streaming-id-4.stream.rackspace.com", + "name": "cdn-container-4", + "cdn_ios_uri": "http://ios-id-4.iosr.rackspace.com", + "cdn_ssl_uri": "https://ssl-id-4.ssl.rackspace.com", + "cdn_enabled": true, + "ttl": 777777, + "log_retention": true, + "cdn_uri": "http://id-4.cdn.rackspace.com" + } +] http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/rackspace-cloudfiles/src/test/resources/cdn_container_list_at.json ---------------------------------------------------------------------- diff --git a/rackspace-cloudfiles/src/test/resources/cdn_container_list_at.json b/rackspace-cloudfiles/src/test/resources/cdn_container_list_at.json new file mode 100644 index 0000000..f1fa9ee --- /dev/null +++ b/rackspace-cloudfiles/src/test/resources/cdn_container_list_at.json @@ -0,0 +1,22 @@ +[ + { + "cdn_streaming_uri": "http://streaming-id-3.stream.rackspace.com", + "name": "cdn-container-3", + "cdn_ios_uri": "http://ios-id-3.iosr.rackspace.com", + "cdn_ssl_uri": "https://ssl-id-3.ssl.rackspace.com", + "cdn_enabled": true, + "ttl": 259200, + "log_retention": false, + "cdn_uri": "http://id-3.cdn.rackspace.com" + }, + { + "cdn_streaming_uri": "http://streaming-id-4.stream.rackspace.com", + "name": "cdn-container-4", + "cdn_ios_uri": "http://ios-id-4.iosr.rackspace.com", + "cdn_ssl_uri": "https://ssl-id-4.ssl.rackspace.com", + "cdn_enabled": true, + "ttl": 777777, + "log_retention": true, + "cdn_uri": "http://id-4.cdn.rackspace.com" + } +] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/rackspace-cloudfiles/src/test/resources/logback.xml ---------------------------------------------------------------------- diff --git a/rackspace-cloudfiles/src/test/resources/logback.xml b/rackspace-cloudfiles/src/test/resources/logback.xml new file mode 100644 index 0000000..ce891f1 --- /dev/null +++ b/rackspace-cloudfiles/src/test/resources/logback.xml @@ -0,0 +1,71 @@ +<?xml version="1.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. + +--> +<configuration scan="false"> + <appender name="FILE" class="ch.qos.logback.core.FileAppender"> + <file>target/test-data/jclouds.log</file> + + <encoder> + <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern> + </encoder> + </appender> + + <appender name="WIREFILE" class="ch.qos.logback.core.FileAppender"> + <file>target/test-data/jclouds-wire.log</file> + + <encoder> + <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern> + </encoder> + </appender> + + <appender name="BLOBSTOREFILE" class="ch.qos.logback.core.FileAppender"> + <file>target/test-data/jclouds-blobstore.log</file> + + <encoder> + <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern> + </encoder> + </appender> + + <root> + <level value="warn" /> + </root> + + <logger name="org.jclouds"> + <level value="DEBUG" /> + <appender-ref ref="FILE" /> + </logger> + +<!-- + <logger name="jclouds.wire"> + <level value="DEBUG" /> + <appender-ref ref="WIREFILE" /> + </logger> +--> + + <logger name="jclouds.headers"> + <level value="DEBUG" /> + <appender-ref ref="WIREFILE" /> + </logger> + + <logger name="jclouds.blobstore"> + <level value="DEBUG" /> + <appender-ref ref="BLOBSTOREFILE" /> + </logger> + +</configuration>
