moved cdn extension to an Optional

This commit is contained in:
Adrian Cole 2012-03-23 00:38:52 -07:00
parent 000ed4a393
commit 5dced71f42
10 changed files with 285 additions and 157 deletions

View File

@ -18,62 +18,55 @@
*/
package org.jclouds.hpcloud.objectstorage;
import java.net.URI;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import org.jclouds.blobstore.functions.ReturnNullOnContainerNotFound;
import org.jclouds.hpcloud.objectstorage.domain.ContainerCDNMetadata;
import org.jclouds.hpcloud.objectstorage.functions.ParseCDNUriFromHeaders;
import org.jclouds.hpcloud.objectstorage.functions.ParseContainerCDNMetadataFromHeaders;
import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNAsyncClient;
import org.jclouds.hpcloud.objectstorage.functions.ParseContainerMetadataFromHeaders;
import org.jclouds.hpcloud.objectstorage.options.CreateContainerOptions;
import org.jclouds.hpcloud.objectstorage.options.ListCDNContainerOptions;
import org.jclouds.hpcloud.objectstorage.reference.HPCloudObjectStorageHeaders;
import org.jclouds.hpcloud.services.HPExtensionCDN;
import org.jclouds.openstack.filters.AuthenticateRequest;
import org.jclouds.openstack.services.ObjectStore;
import org.jclouds.openstack.swift.CommonSwiftAsyncClient;
import org.jclouds.openstack.swift.Storage;
import org.jclouds.openstack.swift.domain.ContainerMetadata;
import org.jclouds.openstack.swift.functions.ReturnTrueOn404FalseOn409;
import org.jclouds.openstack.swift.options.ListContainerOptions;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.Headers;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides asynchronous access to HP Cloud Object Storage via the REST API.
*
* <p/>All commands return a ListenableFuture of the result. Any exceptions incurred
* during processing will be wrapped in an {@link java.util.concurrent.ExecutionException} as documented in
* <p/>
* All commands return a ListenableFuture of the result. Any exceptions incurred during processing
* will be wrapped in an {@link java.util.concurrent.ExecutionException} as documented in
* {@link ListenableFuture#get()}.
*
* @see HPCloudObjectStorageClient
* @see <a href="https://manage.hpcloud.com/pages/build/docs/objectstorage-lvs/api">HP Cloud Object Storage API</a>
* @see <a href="https://manage.hpcloud.com/pages/build/docs/objectstorage-lvs/api">HP Cloud Object
* Storage API</a>
* @author Jeremy Daggett
*/
@SkipEncoding('/')
@RequestFilters(AuthenticateRequest.class)
@Endpoint(ObjectStore.class)
@Endpoint(Storage.class)
public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient {
/**
@ -112,69 +105,9 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient
ListenableFuture<Boolean> deleteContainerIfEmpty(@PathParam("container") String container);
/**
* @see HPCloudObjectStorageClient#listCDNContainers(ListCDNContainerOptions...)
* Provides synchronous access to CDN features.
*/
@Beta
@GET
@Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "format", values = "json")
@Path("/")
@Endpoint(HPExtensionCDN.class)
ListenableFuture<? extends Set<ContainerCDNMetadata>> listCDNContainers(ListCDNContainerOptions... options);
/**
* @see HPCloudObjectStorageClient#getCDNMetadata(String)
*/
@Beta
@HEAD
@ResponseParser(ParseContainerCDNMetadataFromHeaders.class)
@ExceptionParser(ReturnNullOnContainerNotFound.class)
@Path("/{container}")
@Endpoint(HPExtensionCDN.class)
ListenableFuture<ContainerCDNMetadata> getCDNMetadata(@PathParam("container") String container);
/**
* @see HPCloudObjectStorageClient#enableCDN(String, long)
*/
@Beta
@PUT
@Path("/{container}")
@Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "True")
@ResponseParser(ParseCDNUriFromHeaders.class)
@Endpoint(HPExtensionCDN.class)
ListenableFuture<URI> enableCDN(@PathParam("container") String container,
@HeaderParam(HPCloudObjectStorageHeaders.CDN_TTL) long ttl);
/**
* @see HPCloudObjectStorageClient#enableCDN(String)
*/
@Beta
@PUT
@Path("/{container}")
@Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "True")
@ResponseParser(ParseCDNUriFromHeaders.class)
@Endpoint(HPExtensionCDN.class)
ListenableFuture<URI> enableCDN(@PathParam("container") String container);
/**
* @see HPCloudObjectStorageClient#updateCDN(String, long)
*/
@Beta
@POST
@Path("/{container}")
@ResponseParser(ParseCDNUriFromHeaders.class)
@Endpoint(HPExtensionCDN.class)
ListenableFuture<URI> updateCDN(@PathParam("container") String container,
@HeaderParam(HPCloudObjectStorageHeaders.CDN_TTL) long ttl);
/**
* @see HPCloudObjectStorageClient#disableCDN(String)
*/
@Beta
@PUT
@Path("/{container}")
@Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "False")
@Endpoint(HPExtensionCDN.class)
ListenableFuture<Boolean> disableCDN(@PathParam("container") String container);
@Delegate
Optional<HPCloudCDNAsyncClient> getCDNExtension();
}

View File

@ -18,19 +18,16 @@
*/
package org.jclouds.hpcloud.objectstorage;
import java.net.URI;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.hpcloud.objectstorage.domain.ContainerCDNMetadata;
import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNClient;
import org.jclouds.hpcloud.objectstorage.options.CreateContainerOptions;
import org.jclouds.hpcloud.objectstorage.options.ListCDNContainerOptions;
import org.jclouds.openstack.swift.CommonSwiftClient;
import org.jclouds.openstack.swift.domain.ContainerMetadata;
import org.jclouds.rest.annotations.Delegate;
import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
/**
@ -38,7 +35,8 @@ import com.google.common.util.concurrent.ListenableFuture;
*
* <p/>
* All commands return a ListenableFuture of the result. Any exceptions incurred during processing
* will be wrapped in an {@link java.util.concurrent.ExecutionException} as documented in {@link ListenableFuture#get()}.
* will be wrapped in an {@link java.util.concurrent.ExecutionException} as documented in
* {@link ListenableFuture#get()}.
*
* @see org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageClient
* @see <a href="https://manage.hpcloud.com/pages/build/docs/objectstorage-lvs/api">HP Cloud Object
@ -52,22 +50,9 @@ public interface HPCloudObjectStorageClient extends CommonSwiftClient {
ContainerMetadata getContainerMetadata(String container);
@Beta
Set<ContainerCDNMetadata> listCDNContainers(ListCDNContainerOptions... options);
@Beta
ContainerCDNMetadata getCDNMetadata(String container);
@Beta
URI enableCDN(String container, long ttl);
@Beta
URI enableCDN(String container);
@Beta
URI updateCDN(String container, long ttl);
@Beta
boolean disableCDN(String container);
/**
* Provides synchronous access to CDN features.
*/
@Delegate
Optional<HPCloudCDNClient> getCDNExtension();
}

View File

@ -33,7 +33,6 @@ import org.jclouds.collect.Memoized;
import org.jclouds.domain.Location;
import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageClient;
import org.jclouds.hpcloud.objectstorage.blobstore.functions.EnableCDNAndCache;
import org.jclouds.openstack.swift.CommonSwiftClient;
import org.jclouds.openstack.swift.blobstore.SwiftBlobStore;
import org.jclouds.openstack.swift.blobstore.functions.BlobStoreListContainerOptionsToListContainerOptions;
import org.jclouds.openstack.swift.blobstore.functions.BlobToObject;

View File

@ -18,6 +18,8 @@
*/
package org.jclouds.hpcloud.objectstorage.blobstore.config;
import static com.google.common.base.Preconditions.checkArgument;
import java.net.URI;
import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;
@ -31,6 +33,7 @@ import org.jclouds.hpcloud.objectstorage.blobstore.HPCloudObjectStorageAsyncBlob
import org.jclouds.hpcloud.objectstorage.blobstore.HPCloudObjectStorageBlobStore;
import org.jclouds.hpcloud.objectstorage.blobstore.functions.HPCloudObjectStorageObjectToBlobMetadata;
import org.jclouds.hpcloud.objectstorage.domain.ContainerCDNMetadata;
import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNClient;
import org.jclouds.http.HttpResponseException;
import org.jclouds.openstack.swift.blobstore.SwiftAsyncBlobStore;
import org.jclouds.openstack.swift.blobstore.SwiftBlobStore;
@ -38,6 +41,7 @@ import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule;
import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata;
import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@ -66,8 +70,10 @@ public class HPCloudObjectStorageBlobStoreContextModule extends SwiftBlobStoreCo
@Override
public URI load(String container) {
Optional<HPCloudCDNClient> cdnExension = client.getCDNExtension();
checkArgument(cdnExension.isPresent(), "CDN is required, but the extension is not available!");
try {
ContainerCDNMetadata md = client.getCDNMetadata(container);
ContainerCDNMetadata md = cdnExension.get().getCDNMetadata(container);
return md != null ? md.getCDNUri() : null;
} catch (HttpResponseException e) {
// TODO: this is due to beta status

View File

@ -18,14 +18,18 @@
*/
package org.jclouds.hpcloud.objectstorage.blobstore.functions;
import static com.google.common.base.Preconditions.checkArgument;
import java.net.URI;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageClient;
import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNClient;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.cache.LoadingCache;
/**
@ -45,7 +49,9 @@ public class EnableCDNAndCache implements Function<String, URI> {
@Override
public URI apply(String input) {
URI uri = sync.enableCDN(input);
Optional<HPCloudCDNClient> cdnExension = sync.getCDNExtension();
checkArgument(cdnExension.isPresent(), "CDN is required, but the extension is not available!");
URI uri = cdnExension.get().enableCDN(input);
cdnContainer.put(input, uri);
return uri;
}

View File

@ -21,12 +21,14 @@ package org.jclouds.hpcloud.objectstorage.config;
import static org.jclouds.util.Suppliers2.getLastValueInMap;
import java.net.URI;
import java.util.Map;
import javax.inject.Singleton;
import com.google.inject.Scopes;
import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageAsyncClient;
import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageClient;
import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNAsyncClient;
import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNClient;
import org.jclouds.hpcloud.services.HPExtensionCDN;
import org.jclouds.hpcloud.services.HPExtensionServiceType;
import org.jclouds.http.HttpErrorHandler;
@ -40,10 +42,10 @@ import org.jclouds.location.suppliers.ImplicitLocationSupplier;
import org.jclouds.location.suppliers.RegionIdToURISupplier;
import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
import org.jclouds.openstack.services.ObjectStore;
import org.jclouds.openstack.services.ServiceType;
import org.jclouds.openstack.swift.CommonSwiftAsyncClient;
import org.jclouds.openstack.swift.CommonSwiftClient;
import org.jclouds.openstack.swift.Storage;
import org.jclouds.openstack.swift.config.SwiftObjectModule;
import org.jclouds.openstack.swift.handlers.ParseSwiftErrorFromHttpResponse;
import org.jclouds.rest.ConfiguresRestClient;
@ -51,7 +53,9 @@ import org.jclouds.rest.annotations.ApiVersion;
import org.jclouds.rest.config.RestClientModule;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Provides;
import com.google.inject.Scopes;
/**
*
@ -61,9 +65,11 @@ import com.google.inject.Provides;
@RequiresHttp
public class HPCloudObjectStorageRestClientModule extends
RestClientModule<HPCloudObjectStorageClient, HPCloudObjectStorageAsyncClient> {
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder().put(
HPCloudCDNClient.class, HPCloudCDNAsyncClient.class).build();
public HPCloudObjectStorageRestClientModule() {
super(HPCloudObjectStorageClient.class, HPCloudObjectStorageAsyncClient.class);
super(HPCloudObjectStorageClient.class, HPCloudObjectStorageAsyncClient.class, DELEGATE_MAP);
}
protected void configure() {
@ -108,7 +114,7 @@ public class HPCloudObjectStorageRestClientModule extends
@Provides
@Singleton
@ObjectStore
@Storage
protected Supplier<URI> provideStorageUrl(RegionIdToURISupplier.Factory factory, @ApiVersion String apiVersion) {
return getLastValueInMap(factory.createForApiTypeAndVersion(ServiceType.OBJECT_STORE, apiVersion));
}

View File

@ -0,0 +1,130 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.hpcloud.objectstorage.extensions;
import java.net.URI;
import java.util.Set;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import org.jclouds.blobstore.functions.ReturnNullOnContainerNotFound;
import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageClient;
import org.jclouds.hpcloud.objectstorage.domain.ContainerCDNMetadata;
import org.jclouds.hpcloud.objectstorage.functions.ParseCDNUriFromHeaders;
import org.jclouds.hpcloud.objectstorage.functions.ParseContainerCDNMetadataFromHeaders;
import org.jclouds.hpcloud.objectstorage.options.ListCDNContainerOptions;
import org.jclouds.hpcloud.objectstorage.reference.HPCloudObjectStorageHeaders;
import org.jclouds.hpcloud.services.HPExtensionCDN;
import org.jclouds.openstack.filters.AuthenticateRequest;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.Headers;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import com.google.common.annotations.Beta;
import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides asynchronous access to HP Cloud Object Storage via the REST API.
*
* <p/>All commands return a ListenableFuture of the result. Any exceptions incurred
* during processing will be wrapped in an {@link java.util.concurrent.ExecutionException} as documented in
* {@link ListenableFuture#get()}.
*
* @see HPCloudObjectStorageClient
* @see <a href="https://manage.hpcloud.com/pages/build/docs/objectstorage-lvs/api">HP Cloud Object Storage API</a>
* @author Jeremy Daggett
*/
@SkipEncoding('/')
@RequestFilters(AuthenticateRequest.class)
@Endpoint(HPExtensionCDN.class)
public interface HPCloudCDNAsyncClient {
/**
* @see HPCloudObjectStorageClient#listCDNContainers(ListCDNContainerOptions...)
*/
@Beta
@GET
@Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "format", values = "json")
@Path("/")
ListenableFuture<? extends Set<ContainerCDNMetadata>> listCDNContainers(ListCDNContainerOptions... options);
/**
* @see HPCloudObjectStorageClient#getCDNMetadata(String)
*/
@Beta
@HEAD
@ResponseParser(ParseContainerCDNMetadataFromHeaders.class)
@ExceptionParser(ReturnNullOnContainerNotFound.class)
@Path("/{container}")
ListenableFuture<ContainerCDNMetadata> getCDNMetadata(@PathParam("container") String container);
/**
* @see HPCloudObjectStorageClient#enableCDN(String, long)
*/
@Beta
@PUT
@Path("/{container}")
@Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "True")
@ResponseParser(ParseCDNUriFromHeaders.class)
ListenableFuture<URI> enableCDN(@PathParam("container") String container,
@HeaderParam(HPCloudObjectStorageHeaders.CDN_TTL) long ttl);
/**
* @see HPCloudObjectStorageClient#enableCDN(String)
*/
@Beta
@PUT
@Path("/{container}")
@Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "True")
@ResponseParser(ParseCDNUriFromHeaders.class)
ListenableFuture<URI> enableCDN(@PathParam("container") String container);
/**
* @see HPCloudObjectStorageClient#updateCDN(String, long)
*/
@Beta
@POST
@Path("/{container}")
@ResponseParser(ParseCDNUriFromHeaders.class)
ListenableFuture<URI> updateCDN(@PathParam("container") String container,
@HeaderParam(HPCloudObjectStorageHeaders.CDN_TTL) long ttl);
/**
* @see HPCloudObjectStorageClient#disableCDN(String)
*/
@Beta
@PUT
@Path("/{container}")
@Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "False")
ListenableFuture<Boolean> disableCDN(@PathParam("container") String container);
}

View File

@ -0,0 +1,65 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.hpcloud.objectstorage.extensions;
import java.net.URI;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.hpcloud.objectstorage.domain.ContainerCDNMetadata;
import org.jclouds.hpcloud.objectstorage.options.ListCDNContainerOptions;
import com.google.common.annotations.Beta;
import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides synchronous access to HP Cloud Object Storage via the REST API.
*
* <p/>
* All commands return a ListenableFuture of the result. Any exceptions incurred during processing
* will be wrapped in an {@link java.util.concurrent.ExecutionException} as documented in {@link ListenableFuture#get()}.
*
* @see org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageClient
* @see <a href="https://manage.hpcloud.com/pages/build/docs/objectstorage-lvs/api">HP Cloud Object
* Storage API</a>
* @author Jeremy Daggett
*/
@Timeout(duration = 120, timeUnit = TimeUnit.SECONDS)
public interface HPCloudCDNClient {
@Beta
Set<ContainerCDNMetadata> listCDNContainers(ListCDNContainerOptions... options);
@Beta
ContainerCDNMetadata getCDNMetadata(String container);
@Beta
URI enableCDN(String container, long ttl);
@Beta
URI enableCDN(String container);
@Beta
URI updateCDN(String container, long ttl);
@Beta
boolean disableCDN(String container);
}

View File

@ -57,34 +57,34 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
final String containerNameWithoutCDN = getContainerName();
try {
try {
getApi().disableCDN(containerNameWithCDN);
getApi().disableCDN(containerNameWithoutCDN);
getApi().getCDNExtension().get().disableCDN(containerNameWithCDN);
getApi().getCDNExtension().get().disableCDN(containerNameWithoutCDN);
} catch (Exception e) {
e.printStackTrace();
}
ContainerCDNMetadata cdnMetadata = null;
// Enable CDN with PUT for one container
final URI cdnUri = getApi().enableCDN(containerNameWithCDN);
final URI cdnUri = getApi().getCDNExtension().get().enableCDN(containerNameWithCDN);
assertTrue(cdnUri != null);
// Confirm CDN is enabled via HEAD request and has default TTL
cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
cdnMetadata = getApi().getCDNExtension().get().getCDNMetadata(containerNameWithCDN);
assertTrue(cdnMetadata.isCDNEnabled());
assertEquals(cdnMetadata.getCDNUri(), cdnUri);
cdnMetadata = getApi().getCDNMetadata(containerNameWithoutCDN);
cdnMetadata = getApi().getCDNExtension().get().getCDNMetadata(containerNameWithoutCDN);
assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
+ " should not have metadata";
assert getApi().getCDNMetadata("DoesNotExist") == null;
assert getApi().getCDNExtension().get().getCDNMetadata("DoesNotExist") == null;
// List CDN metadata for containers, and ensure all CDN info is
// available for enabled
// container
Set<ContainerCDNMetadata> cdnMetadataList = getApi().listCDNContainers();
Set<ContainerCDNMetadata> cdnMetadataList = getApi().getCDNExtension().get().listCDNContainers();
assertTrue(cdnMetadataList.size() >= 1);
final long initialTTL = cdnMetadata.getTTL();
@ -98,7 +98,7 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
* }));
*/
cdnMetadataList = getApi().listCDNContainers(
cdnMetadataList = getApi().getCDNExtension().get().listCDNContainers(
ListCDNContainerOptions.Builder.afterMarker(
containerNameWithCDN.substring(0, containerNameWithCDN.length() - 1)).maxResults(1));
assertEquals(cdnMetadataList.size(), 1);
@ -106,9 +106,9 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
// Enable CDN with PUT for the same container, this time with a custom
// TTL
long ttl = 4000;
getApi().enableCDN(containerNameWithCDN, ttl);
getApi().getCDNExtension().get().enableCDN(containerNameWithCDN, ttl);
cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
cdnMetadata = getApi().getCDNExtension().get().getCDNMetadata(containerNameWithCDN);
assertTrue(cdnMetadata.isCDNEnabled());
@ -116,23 +116,23 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
// Check POST by updating TTL settings
ttl = minimumTTL;
getApi().updateCDN(containerNameWithCDN, minimumTTL);
getApi().getCDNExtension().get().updateCDN(containerNameWithCDN, minimumTTL);
cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
cdnMetadata = getApi().getCDNExtension().get().getCDNMetadata(containerNameWithCDN);
assertTrue(cdnMetadata.isCDNEnabled());
assertEquals(cdnMetadata.getTTL(), minimumTTL);
// Confirm that minimum allowed value for TTL is 3600, lower values are
// ignored.
getApi().updateCDN(containerNameWithCDN, 3599L);
cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
getApi().getCDNExtension().get().updateCDN(containerNameWithCDN, 3599L);
cdnMetadata = getApi().getCDNExtension().get().getCDNMetadata(containerNameWithCDN);
assertEquals(cdnMetadata.getTTL(), 3599L);
// Disable CDN with POST
assertTrue(getApi().disableCDN(containerNameWithCDN));
assertTrue(getApi().getCDNExtension().get().disableCDN(containerNameWithCDN));
cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
cdnMetadata = getApi().getCDNExtension().get().getCDNMetadata(containerNameWithCDN);
assertEquals(cdnMetadata.isCDNEnabled(), false);
} catch (Exception e) {
e.printStackTrace();

View File

@ -1,12 +1,13 @@
package org.jclouds.hpcloud.objectstorage.internal;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextFactory;
import org.jclouds.domain.Location;
import org.jclouds.http.HttpRequest;
@ -15,13 +16,10 @@ import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.BaseRestClientExpectTest;
import org.testng.annotations.Test;
import java.net.URI;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
@Test(groups = "unit", testName = "HPCloudObjectStorageExpectTest")
public class HPCloudObjectStorageExpectTest extends BaseRestClientExpectTest<BlobStore> {