You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by za...@apache.org on 2014/03/03 22:38:46 UTC
[4/5] JCLOUDS-423 - Adds support for Rackspace Cloud Files API - Added support for CloudFilesApi/CDNApi - Added mock/live tests - Refactored listFirstPage() and listAt() API methods to list() and listWithOptions(…) - General Swift API cleanup: docs and t
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApi.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApi.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApi.java
index 8b6637f..b884f30 100644
--- a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApi.java
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApi.java
@@ -32,6 +32,7 @@ import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.openstack.swift.v1.binders.BindMetadataToHeaders.BindObjectMetadataToHeaders;
import org.jclouds.openstack.swift.v1.domain.Segment;
+import org.jclouds.openstack.swift.v1.domain.SwiftObject;
import org.jclouds.openstack.swift.v1.functions.ETagHeader;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
@@ -41,9 +42,10 @@ import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.binders.BindToJsonPayload;
/**
- * @see <a
- * href="http://docs.openstack.org/api/openstack-object-storage/1.0/content/static-large-objects.html">
- * Static Large Objects API</a>
+ * Provides access to the Swift Static Large Object API features.
+ *
+ * @author Adrian Cole
+ * @author Jeremy Daggett
*/
@RequestFilters(AuthenticateRequest.class)
@Consumes(APPLICATION_JSON)
@@ -53,16 +55,16 @@ public interface StaticLargeObjectApi {
* Creates or updates a static large object's manifest.
*
* @param objectName
- * corresponds to {@link SwiftObject#name()}.
+ * corresponds to {@link SwiftObject#getName()}.
* @param segments
* ordered parts which will be concatenated upon download.
* @param metadata
- * corresponds to {@link SwiftObject#metadata()}.
+ * corresponds to {@link SwiftObject#getMetadata()}.
*
- * @return {@link SwiftObject#etag()} of the object, which is the MD5
+ * @return {@link SwiftObject#getEtag()} of the object, which is the MD5
* checksum of the concatenated ETag values of the {@code segments}.
*/
- @Named("CreateOrUpdateStaticLargeObjectManifest")
+ @Named("staticLargeObject:replaceManifest")
@PUT
@ResponseParser(ETagHeader.class)
@Path("/{objectName}")
@@ -75,9 +77,9 @@ public interface StaticLargeObjectApi {
* Deletes a static large object, if present, including all of its segments.
*
* @param objectName
- * corresponds to {@link SwiftObject#name()}.
+ * corresponds to {@link SwiftObject#getName()}.
*/
- @Named("DeleteStaticLargeObject")
+ @Named("staticLargeObject:delete")
@DELETE
@Fallback(VoidOnNotFoundOr404.class)
@Path("/{objectName}")
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/EntriesWithoutMetaPrefix.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/EntriesWithoutMetaPrefix.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/EntriesWithoutMetaPrefix.java
index 06f0eaf..27e3741 100644
--- a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/EntriesWithoutMetaPrefix.java
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/EntriesWithoutMetaPrefix.java
@@ -29,9 +29,7 @@ import com.google.common.collect.Multimap;
* @param from
* a {@link Multimap} containing the prefixed headers.
*
- * @return the extracted {@code Metadata} without the prefixed keys.
- *
- * @see {@link SwiftResource#metadata()}
+ * @return the extracted metadata without the prefixed keys.
*/
enum EntriesWithoutMetaPrefix implements Function<Multimap<String, String>, Map<String, String>> {
INSTANCE;
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseAccountFromHeaders.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseAccountFromHeaders.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseAccountFromHeaders.java
index f31cbac..9debe67 100644
--- a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseAccountFromHeaders.java
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseAccountFromHeaders.java
@@ -16,6 +16,10 @@
*/
package org.jclouds.openstack.swift.v1.functions;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.ACCOUNT_BYTES_USED;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.ACCOUNT_CONTAINER_COUNT;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.ACCOUNT_OBJECT_COUNT;
+
import org.jclouds.http.HttpResponse;
import org.jclouds.openstack.swift.v1.domain.Account;
@@ -25,10 +29,10 @@ public class ParseAccountFromHeaders implements Function<HttpResponse, Account>
@Override
public Account apply(HttpResponse from) {
- return Account.builder() //
- .bytesUsed(Long.parseLong(from.getFirstHeaderOrNull("X-Account-Bytes-Used"))) //
- .containerCount(Long.parseLong(from.getFirstHeaderOrNull("X-Account-Container-Count"))) //
- .objectCount(Long.parseLong(from.getFirstHeaderOrNull("X-Account-Object-Count"))) //
+ return Account.builder()
+ .bytesUsed(Long.parseLong(from.getFirstHeaderOrNull(ACCOUNT_BYTES_USED)))
+ .containerCount(Long.parseLong(from.getFirstHeaderOrNull(ACCOUNT_CONTAINER_COUNT)))
+ .objectCount(Long.parseLong(from.getFirstHeaderOrNull(ACCOUNT_OBJECT_COUNT)))
.metadata(EntriesWithoutMetaPrefix.INSTANCE.apply(from.getHeaders())).build();
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseContainerFromHeaders.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseContainerFromHeaders.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseContainerFromHeaders.java
index 5fb3c9f..d616351 100644
--- a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseContainerFromHeaders.java
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseContainerFromHeaders.java
@@ -16,6 +16,11 @@
*/
package org.jclouds.openstack.swift.v1.functions;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.CONTAINER_ACL_ANYBODY_READ;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.CONTAINER_BYTES_USED;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.CONTAINER_OBJECT_COUNT;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.CONTAINER_READ;
+
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.openstack.swift.v1.domain.Container;
@@ -31,12 +36,14 @@ public class ParseContainerFromHeaders implements Function<HttpResponse, Contain
@Override
public Container apply(HttpResponse from) {
- return Container.builder() //
- .name(name) //
- .bytesUsed(Long.parseLong(from.getFirstHeaderOrNull("X-Container-Bytes-Used"))) //
- .objectCount(Long.parseLong(from.getFirstHeaderOrNull("X-Container-Object-Count"))) //
- .anybodyRead(".r:*,.rlistings".equals(from.getFirstHeaderOrNull("X-Container-Read"))) //
+ Container c =
+ Container.builder()
+ .name(name)
+ .bytesUsed(Long.parseLong(from.getFirstHeaderOrNull(CONTAINER_BYTES_USED)))
+ .objectCount(Long.parseLong(from.getFirstHeaderOrNull(CONTAINER_OBJECT_COUNT)))
+ .anybodyRead(CONTAINER_ACL_ANYBODY_READ.equals(from.getFirstHeaderOrNull(CONTAINER_READ)))
.metadata(EntriesWithoutMetaPrefix.INSTANCE.apply(from.getHeaders())).build();
+ return c;
}
@Override
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectFromResponse.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectFromResponse.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectFromResponse.java
index 158aa6d..6c1ac9e 100644
--- a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectFromResponse.java
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectFromResponse.java
@@ -46,12 +46,12 @@ public class ParseObjectFromResponse implements Function<HttpResponse, SwiftObje
@Override
public SwiftObject apply(HttpResponse from) {
- return SwiftObject.builder() //
- .uri(URI.create(uri)) //
- .name(name) //
- .etag(from.getFirstHeaderOrNull(ETAG)) //
- .payload(from.getPayload()) //
- .lastModified(dates.rfc822DateParse(from.getFirstHeaderOrNull(LAST_MODIFIED))) //
+ return SwiftObject.builder()
+ .uri(URI.create(uri))
+ .name(name)
+ .etag(from.getFirstHeaderOrNull(ETAG))
+ .payload(from.getPayload())
+ .lastModified(dates.rfc822DateParse(from.getFirstHeaderOrNull(LAST_MODIFIED)))
.headers(from.getHeaders())
.metadata(EntriesWithoutMetaPrefix.INSTANCE.apply(from.getHeaders())).build();
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectListFromResponse.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectListFromResponse.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectListFromResponse.java
index 5cfa562..0b58e8b 100644
--- a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectListFromResponse.java
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectListFromResponse.java
@@ -74,11 +74,11 @@ public class ParseObjectListFromResponse implements Function<HttpResponse, Objec
@Override
public SwiftObject apply(InternalObject input) {
- return SwiftObject.builder() //
- .uri(URI.create(String.format("%s%s", containerUri, input.name))) //
- .name(input.name) //
- .etag(input.hash) //
- .payload(payload(input.bytes, input.content_type)) //
+ return SwiftObject.builder()
+ .uri(URI.create(String.format("%s%s", containerUri, input.name)))
+ .name(input.name)
+ .etag(input.hash)
+ .payload(payload(input.bytes, input.content_type))
.lastModified(input.last_modified).build();
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/handlers/SwiftErrorHandler.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/handlers/SwiftErrorHandler.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/handlers/SwiftErrorHandler.java
index 2fe469e..2bde41c 100644
--- a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/handlers/SwiftErrorHandler.java
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/handlers/SwiftErrorHandler.java
@@ -30,6 +30,7 @@ import org.jclouds.http.HttpResponseException;
import org.jclouds.openstack.swift.v1.CopyObjectException;
import org.jclouds.openstack.swift.v1.reference.SwiftHeaders;
import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.InsufficientResourcesException;
// TODO: is there error spec someplace? let's type errors, etc.
public class SwiftErrorHandler implements HttpErrorHandler {
@@ -81,6 +82,9 @@ public class SwiftErrorHandler implements HttpErrorHandler {
case 409:
exception = new IllegalStateException(exception.getMessage(), exception);
break;
+ case 413:
+ exception = new InsufficientResourcesException(exception.getMessage(), exception);
+ break;
}
command.setException(exception);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/CreateContainerOptions.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/CreateContainerOptions.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/CreateContainerOptions.java
index fc8f9c8..cef386a 100644
--- a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/CreateContainerOptions.java
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/CreateContainerOptions.java
@@ -16,22 +16,29 @@
*/
package org.jclouds.openstack.swift.v1.options;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.CONTAINER_ACL_ANYBODY_READ;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.CONTAINER_METADATA_PREFIX;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.CONTAINER_READ;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.CONTAINER_VERSIONS_LOCATION;
+
import java.util.Map;
import org.jclouds.http.options.BaseHttpRequestOptions;
import org.jclouds.openstack.swift.v1.binders.BindMetadataToHeaders;
+import org.jclouds.openstack.swift.v1.domain.Container;
+import org.jclouds.openstack.swift.v1.features.ContainerApi;
/**
- * Options available to <a href=
- * "http://docs.openstack.org/api/openstack-object-storage/1.0/content/create-container.html"
- * >create a container</a>.
+ * Options for creating a {@link Container}.
*
- * @see ContainerApi#createIfAbsent
+ * @see ContainerApi#createIfAbsent(String, CreateContainerOptions)
*/
public class CreateContainerOptions extends BaseHttpRequestOptions {
public static final CreateContainerOptions NONE = new CreateContainerOptions();
- /** corresponds to {@link Container#metadata()} */
+ /**
+ * Sets the metadata on a container at creation.
+ */
public CreateContainerOptions metadata(Map<String, String> metadata) {
if (!metadata.isEmpty()) {
this.headers.putAll(bindMetadataToHeaders.toHeaders(metadata));
@@ -39,26 +46,48 @@ public class CreateContainerOptions extends BaseHttpRequestOptions {
return this;
}
- /** Sets the ACL the container so that anybody can read it. */
+ /**
+ * Sets the public ACL on the container so that anybody can read it.
+ */
public CreateContainerOptions anybodyRead() {
- this.headers.put("x-container-read", ".r:*,.rlistings");
+ this.headers.put(CONTAINER_READ, CONTAINER_ACL_ANYBODY_READ);
+ return this;
+ }
+
+ /**
+ * Sets the container that will contain object versions.
+ */
+ public CreateContainerOptions versionsLocation(String containerName) {
+ this.headers.put(CONTAINER_VERSIONS_LOCATION, containerName);
return this;
}
public static class Builder {
- /** @see CreateContainerOptions#anybodyRead */
+ /**
+ * @see CreateContainerOptions#anybodyRead
+ */
public static CreateContainerOptions anybodyRead() {
CreateContainerOptions options = new CreateContainerOptions();
return options.anybodyRead();
}
- /** @see CreateContainerOptions#metadata */
+ /**
+ * @see CreateContainerOptions#metadata
+ */
public static CreateContainerOptions metadata(Map<String, String> metadata) {
CreateContainerOptions options = new CreateContainerOptions();
return options.metadata(metadata);
}
+
+ /**
+ * @see CreateContainerOptions#versionsLocation
+ */
+ public static CreateContainerOptions versionsLocation(String containerName) {
+ CreateContainerOptions options = new CreateContainerOptions();
+ return options.versionsLocation(containerName);
+ }
}
- private static final BindMetadataToHeaders bindMetadataToHeaders = new BindMetadataToHeaders("x-container-meta-");
+ private static final BindMetadataToHeaders bindMetadataToHeaders = new BindMetadataToHeaders(CONTAINER_METADATA_PREFIX);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/ListContainerOptions.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/ListContainerOptions.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/ListContainerOptions.java
index 3373455..e1003e4 100644
--- a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/ListContainerOptions.java
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/ListContainerOptions.java
@@ -20,18 +20,19 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import org.jclouds.http.options.BaseHttpRequestOptions;
+import org.jclouds.openstack.swift.v1.features.ContainerApi;
/**
- * Options available for <a href=
- * "http://docs.openstack.org/api/openstack-object-storage/1.0/content/list-objects.html"
- * >listing objects</a>.
+ * Options for listing containers.
*
- * @see ObjectApi#list
+ * @see ContainerApi#list(ListContainerOptions)
*/
public class ListContainerOptions extends BaseHttpRequestOptions {
public static final ListContainerOptions NONE = new ListContainerOptions();
- /** list operation returns no more than this amount. */
+ /**
+ * list operation returns no more than this amount.
+ */
public ListContainerOptions limit(int limit) {
checkState(limit >= 0, "limit must be >= 0");
checkState(limit <= 10000, "limit must be <= 10000");
@@ -39,31 +40,41 @@ public class ListContainerOptions extends BaseHttpRequestOptions {
return this;
}
- /** object names greater in value than the specified marker are returned. */
+ /**
+ * object names greater in value than the specified marker are returned.
+ */
public ListContainerOptions marker(String marker) {
queryParameters.put("marker", checkNotNull(marker, "marker"));
return this;
}
- /** object names less in value than the specified marker are returned. */
+ /**
+ * object names less in value than the specified marker are returned.
+ */
public ListContainerOptions endMarker(String endMarker) {
queryParameters.put("end_marker", checkNotNull(endMarker, "endMarker"));
return this;
}
- /** object names beginning with this substring are returned. */
+ /**
+ * object names beginning with this substring are returned.
+ */
public ListContainerOptions prefix(String prefix) {
queryParameters.put("prefix", checkNotNull(prefix, "prefix"));
return this;
}
- /** object names nested in the container are returned. */
+ /**
+ * object names nested in the container are returned.
+ */
public ListContainerOptions delimiter(char delimiter) {
queryParameters.put("delimiter", Character.toString(delimiter));
return this;
}
- /** object names nested in the pseudo path are returned. */
+ /**
+ * object names nested in the pseudo path are returned.
+ */
public ListContainerOptions path(String path) {
queryParameters.put("path", checkNotNull(path, "path"));
return this;
@@ -71,37 +82,49 @@ public class ListContainerOptions extends BaseHttpRequestOptions {
public static class Builder {
- /** @see ListContainerOptions#limit */
+ /**
+ * @see ListContainerOptions#limit
+ */
public static ListContainerOptions limit(int limit) {
ListContainerOptions options = new ListContainerOptions();
return options.limit(limit);
}
- /** @see ListContainerOptions#marker */
+ /**
+ * @see ListContainerOptions#marker
+ */
public static ListContainerOptions marker(String marker) {
ListContainerOptions options = new ListContainerOptions();
return options.marker(marker);
}
- /** @see ListContainerOptions#endMarker */
+ /**
+ * @see ListContainerOptions#endMarker
+ */
public static ListContainerOptions endMarker(String endMarker) {
ListContainerOptions options = new ListContainerOptions();
return options.endMarker(endMarker);
}
- /** @see ListContainerOptions#prefix */
+ /**
+ * @see ListContainerOptions#prefix
+ */
public static ListContainerOptions prefix(String prefix) {
ListContainerOptions options = new ListContainerOptions();
return options.prefix(prefix);
}
- /** @see ListContainerOptions#delimiter */
+ /**
+ * @see ListContainerOptions#delimiter
+ */
public static ListContainerOptions delimiter(char delimiter) {
ListContainerOptions options = new ListContainerOptions();
return options.delimiter(delimiter);
}
- /** @see ListContainerOptions#path */
+ /**
+ * @see ListContainerOptions#path
+ */
public static ListContainerOptions path(String path) {
ListContainerOptions options = new ListContainerOptions();
return options.path(path);
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/reference/SwiftHeaders.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/reference/SwiftHeaders.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/reference/SwiftHeaders.java
index e0c9348..d8bcd5c 100644
--- a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/reference/SwiftHeaders.java
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/reference/SwiftHeaders.java
@@ -22,30 +22,62 @@ package org.jclouds.openstack.swift.v1.reference;
* @author Jeremy Daggett
*/
public interface SwiftHeaders {
+
+ // Common Metadata Prefixes
+ String ACCOUNT_METADATA_PREFIX = "X-Account-Meta-";
+ String CONTAINER_METADATA_PREFIX = "X-Container-Meta-";
+ String OBJECT_METADATA_PREFIX = "X-Object-Meta-";
+ String USER_METADATA_PREFIX = OBJECT_METADATA_PREFIX;
+
+ // Metadata Removal Prefixes
+ String ACCOUNT_REMOVE_METADATA_PREFIX = "X-Remove-Account-Meta-";
+ String CONTAINER_REMOVE_METADATA_PREFIX = "X-Remove-Container-Meta-";
+ String OBJECT_REMOVE_METADATA_PREFIX = "X-Remove-Object-Meta-";
+
+ // TempURL
+ String ACCOUNT_TEMPORARY_URL_KEY = ACCOUNT_METADATA_PREFIX + "Temp-Url-Key";
+ String ACCOUNT_TEMPORARY_URL_KEY_2 = ACCOUNT_TEMPORARY_URL_KEY + "-2";
- String USER_METADATA_PREFIX = "X-Object-Meta-";
-
- String ACCOUNT_TEMPORARY_URL_KEY = "X-Account-Meta-Temp-Url-Key";
+ // Account Headers
String ACCOUNT_BYTES_USED = "X-Account-Bytes-Used";
String ACCOUNT_CONTAINER_COUNT = "X-Account-Container-Count";
+ String ACCOUNT_OBJECT_COUNT = "X-Account-Object-Count";
+ // Container Headers
String CONTAINER_BYTES_USED = "X-Container-Bytes-Used";
String CONTAINER_OBJECT_COUNT = "X-Container-Object-Count";
- String CONTAINER_METADATA_PREFIX = "X-Container-Meta-";
- String CONTAINER_DELETE_METADATA_PREFIX = "X-Remove-Container-Meta-";
+ // Public access - not supported in all Swift Impls
String CONTAINER_READ = "X-Container-Read";
String CONTAINER_WRITE = "X-Container-Write";
+ String CONTAINER_ACL_ANYBODY_READ = ".r:*,.rlistings";
- String CONTAINER_WEB_INDEX = "X-Container-Meta-Web-Index";
- String CONTAINER_WEB_ERROR = "X-Container-Meta-Web-Error";
- String CONTAINER_WEB_LISTINGS = "X-Container-Meta-Web-Listings";
- String CONTAINER_WEB_LISTINGS_CSS = "X-Container-Meta-Web-Listings-CSS";
-
+ // CORS
+ String CONTAINER_ACCESS_CONTROL_ALLOW_ORIGIN = CONTAINER_METADATA_PREFIX + "Access-Control-Allow-Origin";
+ String CONTAINER_ACCESS_CONTROL_MAX_AGE = CONTAINER_METADATA_PREFIX + "Access-Control-Max-Age";
+ String CONTAINER_ACCESS_CONTROL_EXPOSE_HEADERS = CONTAINER_METADATA_PREFIX + "Access-Control-Expose-Headers";
+
+ // Container Quota
+ String CONTAINER_QUOTA_BYTES = CONTAINER_METADATA_PREFIX + "Quota-Bytes";
+ String CONTAINER_QUOTA_COUNT = CONTAINER_METADATA_PREFIX + "Quota-Count";
+
+ // Container Sync
+ String CONTAINER_SYNC_KEY = "X-Container-Sync-Key";
+ String CONTAINER_SYNC_TO = "X-Container-Sync-To";
+
+ // Versioning
+ String CONTAINER_VERSIONS_LOCATION = "X-Versions-Location";
+
+ // Misc functionality
+ String CONTAINER_WEB_MODE = "X-Web-Mode";
+
String OBJECT_COPY_FROM = "X-Copy-From";
String OBJECT_DELETE_AFTER = "X-Delete-After";
String OBJECT_DELETE_AT = "X-Delete-At";
+ String OBJECT_MANIFEST = "X-Object-Manifest";
/** Get the newest version of the object for GET and HEAD requests */
String OBJECT_NEWEST = "X-Newest";
- String OBJECT_VERSIONS_LOCATION = "X-Versions-Location";
+
+ // Static Large Object
+ String STATIC_LARGE_OBJECT = "X-Static-Large-Object";
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerLiveTest.java
index 733563c..9a00c14 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerLiveTest.java
@@ -38,7 +38,7 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
@Test(groups = "live", testName = "TemporaryUrlSignerLiveTest")
-public class TemporaryUrlSignerLiveTest extends BaseSwiftApiLiveTest {
+public class TemporaryUrlSignerLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
private String name = getClass().getSimpleName();
private String containerName = getClass().getSimpleName() + "Container";
@@ -48,10 +48,10 @@ public class TemporaryUrlSignerLiveTest extends BaseSwiftApiLiveTest {
SwiftObject object = api.objectApiInRegionForContainer(regionId, containerName).head(name);
long expires = System.currentTimeMillis() / 1000 + 5;
- String signature = TemporaryUrlSigner.checkApiEvery(api.accountApiInRegion(regionId), 5) //
- .sign("GET", object.uri().getPath(), expires);
+ String signature = TemporaryUrlSigner.checkApiEvery(api.accountApiInRegion(regionId), 5)
+ .sign("GET", object.getUri().getPath(), expires);
- URI signed = URI.create(format("%s?temp_url_sig=%s&temp_url_expires=%s", object.uri(), signature, expires));
+ URI signed = URI.create(format("%s?temp_url_sig=%s&temp_url_expires=%s", object.getUri(), signature, expires));
InputStream publicStream = signed.toURL().openStream();
assertEquals(Strings2.toStringAndClose(publicStream), "swifty");
@@ -74,7 +74,7 @@ public class TemporaryUrlSignerLiveTest extends BaseSwiftApiLiveTest {
for (String regionId : api.configuredRegions()) {
api.accountApiInRegion(regionId).updateTemporaryUrlKey(key);
api.containerApiInRegion(regionId).createIfAbsent(containerName, CreateContainerOptions.NONE);
- api.objectApiInRegionForContainer(regionId, containerName) //
+ api.objectApiInRegionForContainer(regionId, containerName)
.replace(name, newStringPayload("swifty"), ImmutableMap.<String, String> of());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerMockTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerMockTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerMockTest.java
index 0f856ba..6744fb6 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerMockTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerMockTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.openstack.swift.v1;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.ACCOUNT_TEMPORARY_URL_KEY;
import static org.jclouds.openstack.swift.v1.features.AccountApiMockTest.accountResponse;
import static org.testng.Assert.assertEquals;
@@ -25,7 +26,7 @@ import org.testng.annotations.Test;
import com.squareup.okhttp.mockwebserver.MockResponse;
import com.squareup.okhttp.mockwebserver.MockWebServer;
-@Test
+@Test(groups = "unit", testName = "TemporaryUrlSignerMockTest")
public class TemporaryUrlSignerMockTest extends BaseOpenStackMockTest<SwiftApi> {
@Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "accountApi")
@@ -36,7 +37,7 @@ public class TemporaryUrlSignerMockTest extends BaseOpenStackMockTest<SwiftApi>
public void whenAccountApiHasKey() throws Exception {
MockWebServer server = mockOpenStackServer();
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
- server.enqueue(addCommonHeaders(accountResponse().addHeader("X-Account-Meta-Temp-URL-Key", "mykey")));
+ server.enqueue(addCommonHeaders(accountResponse().addHeader(ACCOUNT_TEMPORARY_URL_KEY, "mykey")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobIntegrationLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobIntegrationLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobIntegrationLiveTest.java
index 39f0a0f..6d26100 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobIntegrationLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobIntegrationLiveTest.java
@@ -26,8 +26,9 @@ import org.testng.SkipException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-@Test(groups = "live")
+@Test(groups = "live", testName = "SwiftBlobIntegrationLiveTest")
public class SwiftBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
+
public SwiftBlobIntegrationLiveTest() {
provider = "openstack-swift";
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobLiveTest.java
index f7b6b00..d9996bf 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobLiveTest.java
@@ -23,8 +23,9 @@ import java.util.Properties;
import org.jclouds.blobstore.integration.internal.BaseBlobLiveTest;
import org.testng.annotations.Test;
-@Test(groups = "live")
+@Test(groups = "live", testName = "SwiftBlobLiveTest")
public class SwiftBlobLiveTest extends BaseBlobLiveTest {
+
public SwiftBlobLiveTest() {
provider = "openstack-swift";
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobSignerLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobSignerLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobSignerLiveTest.java
index 36fc024..9dd603f 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobSignerLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobSignerLiveTest.java
@@ -23,8 +23,9 @@ import java.util.Properties;
import org.jclouds.blobstore.integration.internal.BaseBlobSignerLiveTest;
import org.testng.annotations.Test;
-@Test(groups = "live")
+@Test(groups = "live", testName = "SwiftBlobSignerLiveTest")
public class SwiftBlobSignerLiveTest extends BaseBlobSignerLiveTest {
+
public SwiftBlobSignerLiveTest() {
provider = "openstack-swift";
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerIntegrationLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerIntegrationLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerIntegrationLiveTest.java
index 4e682f8..d954867 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerIntegrationLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerIntegrationLiveTest.java
@@ -24,8 +24,9 @@ import java.util.Properties;
import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
import org.testng.annotations.Test;
-@Test(groups = "live")
+@Test(groups = "live", testName = "SwiftContainerIntegrationLiveTest")
public class SwiftContainerIntegrationLiveTest extends BaseContainerIntegrationTest {
+
public SwiftContainerIntegrationLiveTest() {
provider = "openstack-swift";
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerLiveTest.java
index 8f5ab6c..9bd85d6 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerLiveTest.java
@@ -23,8 +23,9 @@ import java.util.Properties;
import org.jclouds.blobstore.integration.internal.BaseContainerLiveTest;
import org.testng.annotations.Test;
-@Test(groups = "live")
+@Test(groups = "live", testName = "SwiftContainerLiveTest")
public class SwiftContainerLiveTest extends BaseContainerLiveTest {
+
public SwiftContainerLiveTest() {
provider = "openstack-swift";
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftServiceIntegrationLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftServiceIntegrationLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftServiceIntegrationLiveTest.java
index fa9a734..1da1a68 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftServiceIntegrationLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftServiceIntegrationLiveTest.java
@@ -23,8 +23,9 @@ import java.util.Properties;
import org.jclouds.blobstore.integration.internal.BaseServiceIntegrationTest;
import org.testng.annotations.Test;
-@Test(groups = "live")
+@Test(groups = "live", testName = "SwiftServiceIntegrationLiveTest")
public class SwiftServiceIntegrationLiveTest extends BaseServiceIntegrationTest {
+
public SwiftServiceIntegrationLiveTest() {
provider = "openstack-swift";
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/config/SwiftTypeAdaptersTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/config/SwiftTypeAdaptersTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/config/SwiftTypeAdaptersTest.java
index 30edc8f..e4225fc 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/config/SwiftTypeAdaptersTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/config/SwiftTypeAdaptersTest.java
@@ -30,32 +30,32 @@ import com.google.gson.GsonBuilder;
@Test
public class SwiftTypeAdaptersTest {
- Gson gson = new GsonBuilder() //
- .registerTypeAdapter(ExtractArchiveResponse.class, new ExtractArchiveResponseAdapter()) //
- .registerTypeAdapter(BulkDeleteResponse.class, new BulkDeleteResponseAdapter()) //
+ Gson gson = new GsonBuilder()
+ .registerTypeAdapter(ExtractArchiveResponse.class, new ExtractArchiveResponseAdapter())
+ .registerTypeAdapter(BulkDeleteResponse.class, new BulkDeleteResponseAdapter())
.create();
public void extractArchiveWithoutErrors() {
- assertEquals(gson.fromJson("" //
- + "{\n" //
- + " \"Response Status\": \"201 Created\",\n" //
- + " \"Response Body\": \"\",\n" //
- + " \"Errors\": [],\n" //
- + " \"Number Files Created\": 10\n" //
+ assertEquals(gson.fromJson(""
+ + "{\n"
+ + " \"Response Status\": \"201 Created\",\n"
+ + " \"Response Body\": \"\",\n"
+ + " \"Errors\": [],\n"
+ + " \"Number Files Created\": 10\n"
+ "}", ExtractArchiveResponse.class), ExtractArchiveResponse.create(10, ImmutableMap.<String, String> of()));
}
public void extractArchiveWithErrorsAndDecodesPaths() {
assertEquals(
- gson.fromJson("" //
- + "{\n" //
- + " \"Response Status\": \"201 Created\",\n" //
- + " \"Response Body\": \"\",\n" //
- + " \"Errors\": [\n" //
- + " [\"/v1/12345678912345/mycontainer/home/xx%3Cyy\", \"400 Bad Request\"],\n" //
- + " [\"/v1/12345678912345/mycontainer/../image.gif\", \"400 Bad Request\"]\n" //
- + " ],\n" //
- + " \"Number Files Created\": 8\n" //
+ gson.fromJson(""
+ + "{\n"
+ + " \"Response Status\": \"201 Created\",\n"
+ + " \"Response Body\": \"\",\n"
+ + " \"Errors\": [\n"
+ + " [\"/v1/12345678912345/mycontainer/home/xx%3Cyy\", \"400 Bad Request\"],\n"
+ + " [\"/v1/12345678912345/mycontainer/../image.gif\", \"400 Bad Request\"]\n"
+ + " ],\n"
+ + " \"Number Files Created\": 8\n"
+ "}", ExtractArchiveResponse.class),
ExtractArchiveResponse.create(
8,
@@ -65,25 +65,25 @@ public class SwiftTypeAdaptersTest {
}
public void bulkDeleteWithoutErrors() {
- assertEquals(gson.fromJson("" //
- + "{\n" //
- + " \"Response Status\": \"200 OK\",\n" //
- + " \"Response Body\": \"\",\n" //
- + " \"Errors\": [],\n" //
- + " \"Number Not Found\": 1,\n" //
- + " \"Number Deleted\": 9\n" //
+ assertEquals(gson.fromJson(""
+ + "{\n"
+ + " \"Response Status\": \"200 OK\",\n"
+ + " \"Response Body\": \"\",\n"
+ + " \"Errors\": [],\n"
+ + " \"Number Not Found\": 1,\n"
+ + " \"Number Deleted\": 9\n"
+ "}", BulkDeleteResponse.class), BulkDeleteResponse.create(9, 1, ImmutableMap.<String, String> of()));
}
public void bulkDeleteWithErrorsAndDecodesPaths() {
- assertEquals(gson.fromJson("" //
- + "{\n" //
- + " \"Response Status\": \"400 Bad Request\",\n" //
- + " \"Response Body\": \"\",\n" //
- + " \"Errors\": [\n" //
- + " [\"/v1/12345678912345/Not%20Empty\", \"409 Conflict\"]" //
- + " ],\n" //
- + " \"Number Deleted\": 0\n" //
+ assertEquals(gson.fromJson(""
+ + "{\n"
+ + " \"Response Status\": \"400 Bad Request\",\n"
+ + " \"Response Body\": \"\",\n"
+ + " \"Errors\": [\n"
+ + " [\"/v1/12345678912345/Not%20Empty\", \"409 Conflict\"]"
+ + " ],\n"
+ + " \"Number Deleted\": 0\n"
+ "}", BulkDeleteResponse.class),
BulkDeleteResponse.create(0, 0, ImmutableMap.of("/v1/12345678912345/Not Empty", "409 Conflict")));
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiLiveTest.java
index 31eff6e..4359a71 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiLiveTest.java
@@ -24,6 +24,7 @@ import static org.testng.Assert.assertTrue;
import java.util.Map;
import java.util.Map.Entry;
+import org.jclouds.openstack.swift.v1.SwiftApi;
import org.jclouds.openstack.swift.v1.domain.Account;
import org.jclouds.openstack.swift.v1.internal.BaseSwiftApiLiveTest;
import org.testng.annotations.Test;
@@ -31,21 +32,21 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
@Test(groups = "live", testName = "AccountApiLiveTest")
-public class AccountApiLiveTest extends BaseSwiftApiLiveTest {
+public class AccountApiLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
- public void get() throws Exception {
+ public void testGet() throws Exception {
for (String regionId : regions) {
AccountApi accountApi = api.accountApiInRegion(regionId);
Account account = accountApi.get();
assertNotNull(account);
- assertTrue(account.containerCount() >= 0);
- assertTrue(account.objectCount() >= 0);
- assertTrue(account.bytesUsed() >= 0);
+ assertTrue(account.getContainerCount() >= 0);
+ assertTrue(account.getObjectCount() >= 0);
+ assertTrue(account.getBytesUsed() >= 0);
}
}
- public void updateMetadata() throws Exception {
+ public void testUpdateMetadata() throws Exception {
for (String regionId : regions) {
AccountApi accountApi = api.accountApiInRegion(regionId);
@@ -57,7 +58,7 @@ public class AccountApiLiveTest extends BaseSwiftApiLiveTest {
}
}
- public void deleteMetadata() throws Exception {
+ public void testDeleteMetadata() throws Exception {
for (String regionId : regions) {
AccountApi accountApi = api.accountApiInRegion(regionId);
@@ -70,7 +71,7 @@ public class AccountApiLiveTest extends BaseSwiftApiLiveTest {
Account account = accountApi.get();
for (Entry<String, String> entry : meta.entrySet()) {
// note keys are returned in lower-case!
- assertFalse(account.metadata().containsKey(entry.getKey().toLowerCase()));
+ assertFalse(account.getMetadata().containsKey(entry.getKey().toLowerCase()));
}
}
}
@@ -79,7 +80,7 @@ public class AccountApiLiveTest extends BaseSwiftApiLiveTest {
Account account = accountApi.get();
for (Entry<String, String> entry : meta.entrySet()) {
// note keys are returned in lower-case!
- assertEquals(account.metadata().get(entry.getKey().toLowerCase()), entry.getValue(), //
+ assertEquals(account.getMetadata().get(entry.getKey().toLowerCase()), entry.getValue(),
account + " didn't have metadata: " + entry);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiMockTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiMockTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiMockTest.java
index 2c5a9b2..f7e9125 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiMockTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiMockTest.java
@@ -16,6 +16,12 @@
*/
package org.jclouds.openstack.swift.v1.features;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.ACCOUNT_BYTES_USED;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.ACCOUNT_CONTAINER_COUNT;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.ACCOUNT_METADATA_PREFIX;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.ACCOUNT_OBJECT_COUNT;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.ACCOUNT_REMOVE_METADATA_PREFIX;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.ACCOUNT_TEMPORARY_URL_KEY;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@@ -35,32 +41,31 @@ import com.squareup.okhttp.mockwebserver.RecordedRequest;
/**
* @author Jeremy Daggett
*/
-@Test
+@Test(groups = "unit", testName = "AccountApiMockTest")
public class AccountApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
/** upper-cases first char, and lower-cases rest!! **/
public void getKnowingServerMessesWithMetadataKeyCaseFormat() throws Exception {
MockWebServer server = mockOpenStackServer();
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
- server.enqueue(addCommonHeaders(accountResponse() //
+ server.enqueue(addCommonHeaders(accountResponse()
// note silly casing
- .addHeader("X-Account-Meta-Apiname", "swift") //
- .addHeader("X-Account-Meta-Apiversion", "v1.1")));
+ .addHeader(ACCOUNT_METADATA_PREFIX + "Apiname", "swift")
+ .addHeader(ACCOUNT_METADATA_PREFIX + "Apiversion", "v1.1")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
Account account = api.accountApiInRegion("DFW").get();
- assertEquals(account.containerCount(), 3l);
- assertEquals(account.objectCount(), 42l);
- assertEquals(account.bytesUsed(), 323479l);
+ assertEquals(account.getContainerCount(), 3l);
+ assertEquals(account.getObjectCount(), 42l);
+ assertEquals(account.getBytesUsed(), 323479l);
for (Entry<String, String> entry : metadata.entrySet()) {
- assertEquals(account.metadata().get(entry.getKey().toLowerCase()), entry.getValue());
+ assertEquals(account.getMetadata().get(entry.getKey().toLowerCase()), entry.getValue());
}
assertEquals(server.getRequestCount(), 2);
- assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
- assertEquals(server.takeRequest().getRequestLine(),
- "HEAD /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/ HTTP/1.1");
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "HEAD", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/");
} finally {
server.shutdown();
}
@@ -69,21 +74,21 @@ public class AccountApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void updateMetadata() throws Exception {
MockWebServer server = mockOpenStackServer();
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
- server.enqueue(addCommonHeaders(accountResponse() //
- .addHeader("X-Account-Meta-ApiName", "swift") //
- .addHeader("X-Account-Meta-ApiVersion", "v1.1")));
+ server.enqueue(addCommonHeaders(accountResponse()
+ .addHeader(ACCOUNT_METADATA_PREFIX + "ApiName", "swift")
+ .addHeader(ACCOUNT_METADATA_PREFIX + "ApiVersion", "v1.1")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
assertTrue(api.accountApiInRegion("DFW").updateMetadata(metadata));
assertEquals(server.getRequestCount(), 2);
- assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
+ assertAuthentication(server);
+
RecordedRequest replaceRequest = server.takeRequest();
- assertEquals(replaceRequest.getRequestLine(),
- "POST /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/ HTTP/1.1");
+ assertRequest(replaceRequest,"POST", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/");
for (Entry<String, String> entry : metadata.entrySet()) {
- assertEquals(replaceRequest.getHeader("x-account-meta-" + entry.getKey().toLowerCase()), entry.getValue());
+ assertEquals(replaceRequest.getHeader(ACCOUNT_METADATA_PREFIX + entry.getKey().toLowerCase()), entry.getValue());
}
} finally {
server.shutdown();
@@ -100,11 +105,11 @@ public class AccountApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
assertTrue(api.accountApiInRegion("DFW").updateTemporaryUrlKey("foobar"));
assertEquals(server.getRequestCount(), 2);
- assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
+ assertAuthentication(server);
+
RecordedRequest replaceRequest = server.takeRequest();
- assertEquals(replaceRequest.getRequestLine(),
- "POST /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/ HTTP/1.1");
- assertEquals(replaceRequest.getHeader("X-Account-Meta-Temp-URL-Key"), "foobar");
+ assertRequest(replaceRequest, "POST", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/");
+ assertEquals(replaceRequest.getHeader(ACCOUNT_TEMPORARY_URL_KEY), "foobar");
} finally {
server.shutdown();
}
@@ -125,7 +130,7 @@ public class AccountApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
assertEquals(deleteRequest.getRequestLine(),
"POST /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/ HTTP/1.1");
for (String key : metadata.keySet()) {
- assertEquals(deleteRequest.getHeader("x-remove-account-meta-" + key.toLowerCase()), "ignored");
+ assertEquals(deleteRequest.getHeader(ACCOUNT_REMOVE_METADATA_PREFIX + key.toLowerCase()), "ignored");
}
} finally {
server.shutdown();
@@ -135,9 +140,9 @@ public class AccountApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
private static final Map<String, String> metadata = ImmutableMap.of("ApiName", "swift", "ApiVersion", "v1.1");
public static MockResponse accountResponse() {
- return new MockResponse() //
- .addHeader("X-Account-Container-Count", "3") //
- .addHeader("X-Account-Object-Count", "42") //
- .addHeader("X-Account-Bytes-Used", "323479");
+ return new MockResponse()
+ .addHeader(ACCOUNT_CONTAINER_COUNT, "3")
+ .addHeader(ACCOUNT_OBJECT_COUNT, "42")
+ .addHeader(ACCOUNT_BYTES_USED, "323479");
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiLiveTest.java
index 39341fd..fa8e6b6 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiLiveTest.java
@@ -28,6 +28,7 @@ import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.exporter.TarGzExporter;
import org.jclouds.io.Payloads;
+import org.jclouds.openstack.swift.v1.SwiftApi;
import org.jclouds.openstack.swift.v1.domain.BulkDeleteResponse;
import org.jclouds.openstack.swift.v1.domain.ExtractArchiveResponse;
import org.jclouds.openstack.swift.v1.internal.BaseSwiftApiLiveTest;
@@ -42,46 +43,46 @@ import com.google.common.collect.Lists;
import com.google.common.io.ByteStreams;
@Test(groups = "live", testName = "BulkApiLiveTest")
-public class BulkApiLiveTest extends BaseSwiftApiLiveTest {
+public class BulkApiLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
static final int OBJECT_COUNT = 10;
private String containerName = getClass().getSimpleName();
- public void notPresentWhenDeleting() throws Exception {
+ public void testNotPresentWhenDeleting() throws Exception {
for (String regionId : regions) {
BulkDeleteResponse deleteResponse = api.bulkApiInRegion(regionId).bulkDelete(
ImmutableList.of(UUID.randomUUID().toString()));
- assertEquals(deleteResponse.deleted(), 0);
- assertEquals(deleteResponse.notFound(), 1);
- assertTrue(deleteResponse.errors().isEmpty());
+ assertEquals(deleteResponse.getDeleted(), 0);
+ assertEquals(deleteResponse.getNotFound(), 1);
+ assertTrue(deleteResponse.getErrors().isEmpty());
}
}
- public void extractArchive() throws Exception {
+ public void testExtractArchive() throws Exception {
for (String regionId : regions) {
ExtractArchiveResponse extractResponse = api.bulkApiInRegion(regionId).extractArchive(containerName,
Payloads.newPayload(tarGz), "tar.gz");
- assertEquals(extractResponse.created(), OBJECT_COUNT);
- assertTrue(extractResponse.errors().isEmpty());
- assertEquals(api.containerApiInRegion(regionId).get(containerName).objectCount(), OBJECT_COUNT);
+ assertEquals(extractResponse.getCreated(), OBJECT_COUNT);
+ assertTrue(extractResponse.getErrors().isEmpty());
+ assertEquals(api.containerApiInRegion(regionId).get(containerName).getObjectCount(), OBJECT_COUNT);
// repeat the command
extractResponse = api.bulkApiInRegion(regionId).extractArchive(containerName, Payloads.newPayload(tarGz),
"tar.gz");
- assertEquals(extractResponse.created(), OBJECT_COUNT);
- assertTrue(extractResponse.errors().isEmpty());
+ assertEquals(extractResponse.getCreated(), OBJECT_COUNT);
+ assertTrue(extractResponse.getErrors().isEmpty());
}
}
- @Test(dependsOnMethods = "extractArchive")
- public void bulkDelete() throws Exception {
+ @Test(dependsOnMethods = "testExtractArchive")
+ public void testBulkDelete() throws Exception {
for (String regionId : regions) {
BulkDeleteResponse deleteResponse = api.bulkApiInRegion(regionId).bulkDelete(paths);
- assertEquals(deleteResponse.deleted(), OBJECT_COUNT);
- assertEquals(deleteResponse.notFound(), 0);
- assertTrue(deleteResponse.errors().isEmpty());
- assertEquals(api.containerApiInRegion(regionId).get(containerName).objectCount(), 0);
+ assertEquals(deleteResponse.getDeleted(), OBJECT_COUNT);
+ assertEquals(deleteResponse.getNotFound(), 0);
+ assertTrue(deleteResponse.getErrors().isEmpty());
+ assertEquals(api.containerApiInRegion(regionId).get(containerName).getObjectCount(), 0);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiMockTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiMockTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiMockTest.java
index 69ce5a1..5b4c200 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiMockTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiMockTest.java
@@ -34,11 +34,10 @@ import com.squareup.okhttp.mockwebserver.MockResponse;
import com.squareup.okhttp.mockwebserver.MockWebServer;
import com.squareup.okhttp.mockwebserver.RecordedRequest;
-// TODO: cannot yet test bulk delete offline
-@Test
+@Test(groups = "unit", testName = "BulkApiMockTest")
public class BulkApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
- public void extractArchive() throws Exception {
+ public void testExtractArchive() throws Exception {
GenericArchive files = ShrinkWrap.create(GenericArchive.class, "files.tar.gz");
StringAsset content = new StringAsset("foo");
for (int i = 0; i < 10; i++) {
@@ -54,14 +53,13 @@ public class BulkApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
ExtractArchiveResponse response = api.bulkApiInRegion("DFW").extractArchive("myContainer",
newByteArrayPayload(tarGz), "tar.gz");
- assertEquals(response.created(), 10);
- assertTrue(response.errors().isEmpty());
+ assertEquals(response.getCreated(), 10);
+ assertTrue(response.getErrors().isEmpty());
assertEquals(server.getRequestCount(), 2);
- assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
+ assertAuthentication(server);
RecordedRequest extractRequest = server.takeRequest();
- assertEquals(extractRequest.getRequestLine(),
- "PUT /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer?extract-archive=tar.gz HTTP/1.1");
+ assertRequest(extractRequest, "PUT", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer?extract-archive=tar.gz");
assertEquals(extractRequest.getBody(), tarGz);
} finally {
server.shutdown();
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiLiveTest.java
index e28ca8e..31ff231 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiLiveTest.java
@@ -24,9 +24,11 @@ import static org.testng.Assert.assertTrue;
import java.util.Map;
import java.util.Map.Entry;
+import org.jclouds.openstack.swift.v1.SwiftApi;
import org.jclouds.openstack.swift.v1.domain.Container;
import org.jclouds.openstack.swift.v1.internal.BaseSwiftApiLiveTest;
import org.jclouds.openstack.swift.v1.options.CreateContainerOptions;
+import org.jclouds.openstack.swift.v1.options.ListContainerOptions;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -36,71 +38,70 @@ import com.google.common.collect.ImmutableMap;
/**
* @author Adrian Cole
+ * @author Jeremy Daggett
*/
@Test(groups = "live", testName = "ContainerApiLiveTest")
-public class ContainerApiLiveTest extends BaseSwiftApiLiveTest {
+public class ContainerApiLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
private String name = getClass().getSimpleName();
- @Test
- public void list() throws Exception {
+ public void testList() throws Exception {
for (String regionId : regions) {
ContainerApi containerApi = api.containerApiInRegion(regionId);
- FluentIterable<Container> response = containerApi.listFirstPage();
+ FluentIterable<Container> response = containerApi.list();
assertNotNull(response);
for (Container container : response) {
- assertNotNull(container.name());
- assertTrue(container.objectCount() >= 0);
- assertTrue(container.bytesUsed() >= 0);
+ assertNotNull(container.getName());
+ assertTrue(container.getObjectCount() >= 0);
+ assertTrue(container.getBytesUsed() >= 0);
}
}
}
- public void get() throws Exception {
+ public void testListWithOptions() throws Exception {
+ String lexicographicallyBeforeName = name.substring(0, name.length() - 1);
for (String regionId : regions) {
- Container container = api.containerApiInRegion(regionId).get(name);
- assertEquals(container.name(), name);
- assertTrue(container.objectCount() == 0);
- assertTrue(container.bytesUsed() == 0);
+ ListContainerOptions options = ListContainerOptions.Builder.marker(lexicographicallyBeforeName);
+ Container container = api.containerApiInRegion(regionId).list(options).get(0);
+ assertEquals(container.getName(), name);
+ assertTrue(container.getObjectCount() == 0);
+ assertTrue(container.getBytesUsed() == 0);
}
}
-
- public void listAt() throws Exception {
- String lexicographicallyBeforeName = name.substring(0, name.length() - 1);
+
+ public void testGet() throws Exception {
for (String regionId : regions) {
- Container container = api.containerApiInRegion(regionId).listAt(lexicographicallyBeforeName).get(0);
- assertEquals(container.name(), name);
- assertTrue(container.objectCount() == 0);
- assertTrue(container.bytesUsed() == 0);
+ Container container = api.containerApiInRegion(regionId).get(name);
+ assertEquals(container.getName(), name);
+ assertTrue(container.getObjectCount() == 0);
+ assertTrue(container.getBytesUsed() == 0);
}
}
- public void updateMetadata() throws Exception {
+ public void testUpdateMetadata() throws Exception {
+ Map<String, String> meta = ImmutableMap.of("MyAdd1", "foo", "MyAdd2", "bar");
+
for (String regionId : regions) {
ContainerApi containerApi = api.containerApiInRegion(regionId);
-
- Map<String, String> meta = ImmutableMap.of("MyAdd1", "foo", "MyAdd2", "bar");
-
assertTrue(containerApi.updateMetadata(name, meta));
-
containerHasMetadata(containerApi, name, meta);
}
}
- public void deleteMetadata() throws Exception {
+ public void testDeleteMetadata() throws Exception {
+ Map<String, String> meta = ImmutableMap.of("MyDelete1", "foo", "MyDelete2", "bar");
+
for (String regionId : regions) {
ContainerApi containerApi = api.containerApiInRegion(regionId);
-
- Map<String, String> meta = ImmutableMap.of("MyDelete1", "foo", "MyDelete2", "bar");
-
+ // update
assertTrue(containerApi.updateMetadata(name, meta));
containerHasMetadata(containerApi, name, meta);
-
+ // delete
assertTrue(containerApi.deleteMetadata(name, meta));
Container container = containerApi.get(name);
for (Entry<String, String> entry : meta.entrySet()) {
// note keys are returned in lower-case!
- assertFalse(container.metadata().containsKey(entry.getKey().toLowerCase()));
+ assertFalse(container.getMetadata().containsKey(entry.getKey().toLowerCase()));
}
}
}
@@ -109,7 +110,7 @@ public class ContainerApiLiveTest extends BaseSwiftApiLiveTest {
Container container = containerApi.get(name);
for (Entry<String, String> entry : meta.entrySet()) {
// note keys are returned in lower-case!
- assertEquals(container.metadata().get(entry.getKey().toLowerCase()), entry.getValue(), //
+ assertEquals(container.getMetadata().get(entry.getKey().toLowerCase()), entry.getValue(),
container + " didn't have metadata: " + entry);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiMockTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiMockTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiMockTest.java
index b52122d..752b4b7 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiMockTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiMockTest.java
@@ -17,8 +17,15 @@
package org.jclouds.openstack.swift.v1.features;
import static org.jclouds.openstack.swift.v1.options.CreateContainerOptions.Builder.anybodyRead;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.CONTAINER_ACL_ANYBODY_READ;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.CONTAINER_BYTES_USED;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.CONTAINER_METADATA_PREFIX;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.CONTAINER_OBJECT_COUNT;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.CONTAINER_READ;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.CONTAINER_REMOVE_METADATA_PREFIX;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import java.util.Map;
@@ -26,8 +33,9 @@ import java.util.Map.Entry;
import org.jclouds.openstack.swift.v1.SwiftApi;
import org.jclouds.openstack.swift.v1.domain.Container;
-import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest;
import org.jclouds.openstack.swift.v1.options.CreateContainerOptions;
+import org.jclouds.openstack.swift.v1.options.ListContainerOptions;
+import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
@@ -36,70 +44,65 @@ import com.squareup.okhttp.mockwebserver.MockResponse;
import com.squareup.okhttp.mockwebserver.MockWebServer;
import com.squareup.okhttp.mockwebserver.RecordedRequest;
-@Test
+@Test(groups = "unit", testName = "ContainerApiMockTest")
public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
-
- String containerList = "" //
- + "[\n" //
- + " {\"name\":\"test_container_1\", \"count\":2, \"bytes\":78},\n" //
- + " {\"name\":\"test_container_2\", \"count\":1, \"bytes\":17}\n" //
- + "]";
-
- public void listFirstPage() throws Exception {
+
+ public void testList() throws Exception {
MockWebServer server = mockOpenStackServer();
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
- server.enqueue(addCommonHeaders(new MockResponse().setBody(containerList)));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/container_list.json"))));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
- ImmutableList<Container> containers = api.containerApiInRegion("DFW").listFirstPage().toList();
- assertEquals(containers, ImmutableList.of(//
- Container.builder() //
- .name("test_container_1") //
- .objectCount(2) //
- .bytesUsed(78).build(), //
- Container.builder() //
- .name("test_container_2") //
- .objectCount(1) //
+ ImmutableList<Container> containers = api.containerApiInRegion("DFW").list().toList();
+ assertEquals(containers, ImmutableList.of(
+ Container.builder()
+ .name("test_container_1")
+ .objectCount(2)
+ .bytesUsed(78).build(),
+ Container.builder()
+ .name("test_container_2")
+ .objectCount(1)
.bytesUsed(17).build()));
assertEquals(server.getRequestCount(), 2);
- assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
- assertEquals(server.takeRequest().getRequestLine(),
- "GET /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/?format=json HTTP/1.1");
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/?format=json");
} finally {
server.shutdown();
}
}
- public void listAt() throws Exception {
+ public void testListWithOptions() throws Exception {
MockWebServer server = mockOpenStackServer();
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
- server.enqueue(addCommonHeaders(new MockResponse().setBody(containerList)));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/container_list.json"))));
+ ListContainerOptions options = ListContainerOptions.Builder.marker("test");
+ assertNotNull(options);
+
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
- ImmutableList<Container> containers = api.containerApiInRegion("DFW").listAt("test").toList();
- assertEquals(containers, ImmutableList.of(//
- Container.builder() //
- .name("test_container_1") //
- .objectCount(2) //
- .bytesUsed(78).build(), //
- Container.builder() //
- .name("test_container_2") //
- .objectCount(1) //
+ ImmutableList<Container> containers = api.containerApiInRegion("DFW").list(options).toList();
+ assertEquals(containers, ImmutableList.of(
+ Container.builder()
+ .name("test_container_1")
+ .objectCount(2)
+ .bytesUsed(78).build(),
+ Container.builder()
+ .name("test_container_2")
+ .objectCount(1)
.bytesUsed(17).build()));
assertEquals(server.getRequestCount(), 2);
- assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
- assertEquals(server.takeRequest().getRequestLine(),
- "GET /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/?format=json&marker=test HTTP/1.1");
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/?format=json&marker=test");
} finally {
server.shutdown();
}
}
- public void createIfAbsent() throws Exception {
+ public void testCreateIfAbsent() throws Exception {
MockWebServer server = mockOpenStackServer();
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201)));
@@ -109,16 +112,14 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
assertTrue(api.containerApiInRegion("DFW").createIfAbsent("myContainer", CreateContainerOptions.NONE));
assertEquals(server.getRequestCount(), 2);
- assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
- RecordedRequest createRequest = server.takeRequest();
- assertEquals(createRequest.getRequestLine(),
- "PUT /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer HTTP/1.1");
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer");
} finally {
server.shutdown();
}
}
- public void createWithOptions() throws Exception {
+ public void testCreateWithOptions() throws Exception {
MockWebServer server = mockOpenStackServer();
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201)));
@@ -128,20 +129,22 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
assertTrue(api.containerApiInRegion("DFW").createIfAbsent("myContainer", anybodyRead().metadata(metadata)));
assertEquals(server.getRequestCount(), 2);
- assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
+ assertAuthentication(server);
+
RecordedRequest createRequest = server.takeRequest();
- assertEquals(createRequest.getRequestLine(),
- "PUT /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer HTTP/1.1");
- assertEquals(createRequest.getHeader("x-container-read"), ".r:*,.rlistings");
+ assertRequest(createRequest, "PUT", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer");
+
+ assertEquals(createRequest.getHeader(CONTAINER_READ), CONTAINER_ACL_ANYBODY_READ);
+
for (Entry<String, String> entry : metadata.entrySet()) {
- assertEquals(createRequest.getHeader("x-container-meta-" + entry.getKey().toLowerCase()), entry.getValue());
+ assertEquals(createRequest.getHeader(CONTAINER_METADATA_PREFIX + entry.getKey().toLowerCase()), entry.getValue());
}
} finally {
server.shutdown();
}
}
- public void alreadyCreated() throws Exception {
+ public void testAlreadyCreated() throws Exception {
MockWebServer server = mockOpenStackServer();
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(202)));
@@ -151,38 +154,35 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
assertFalse(api.containerApiInRegion("DFW").createIfAbsent("myContainer", CreateContainerOptions.NONE));
assertEquals(server.getRequestCount(), 2);
- assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
- RecordedRequest createRequest = server.takeRequest();
- assertEquals(createRequest.getRequestLine(),
- "PUT /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer HTTP/1.1");
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer");
} finally {
server.shutdown();
}
}
/** upper-cases first char, and lower-cases rest!! **/
- public void getKnowingServerMessesWithMetadataKeyCaseFormat() throws Exception {
+ public void testGetKnowingServerMessesWithMetadataKeyCaseFormat() throws Exception {
MockWebServer server = mockOpenStackServer();
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
- server.enqueue(addCommonHeaders(containerResponse() //
+ server.enqueue(addCommonHeaders(containerResponse()
// note silly casing
- .addHeader("X-Container-Meta-Apiname", "swift") //
- .addHeader("X-Container-Meta-Apiversion", "v1.1")));
+ .addHeader(CONTAINER_METADATA_PREFIX + "Apiname", "swift")
+ .addHeader(CONTAINER_METADATA_PREFIX + "Apiversion", "v1.1")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
Container container = api.containerApiInRegion("DFW").get("myContainer");
- assertEquals(container.name(), "myContainer");
- assertEquals(container.objectCount(), 42l);
- assertEquals(container.bytesUsed(), 323479l);
- for (Entry<String, String> entry : container.metadata().entrySet()) {
- assertEquals(container.metadata().get(entry.getKey().toLowerCase()), entry.getValue());
+ assertEquals(container.getName(), "myContainer");
+ assertEquals(container.getObjectCount(), 42l);
+ assertEquals(container.getBytesUsed(), 323479l);
+ for (Entry<String, String> entry : container.getMetadata().entrySet()) {
+ assertEquals(container.getMetadata().get(entry.getKey().toLowerCase()), entry.getValue());
}
assertEquals(server.getRequestCount(), 2);
- assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
- assertEquals(server.takeRequest().getRequestLine(),
- "HEAD /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer HTTP/1.1");
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "HEAD", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer");
} finally {
server.shutdown();
}
@@ -191,9 +191,9 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void updateMetadata() throws Exception {
MockWebServer server = mockOpenStackServer();
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
- server.enqueue(addCommonHeaders(containerResponse() //
- .addHeader("X-Container-Meta-ApiName", "swift") //
- .addHeader("X-Container-Meta-ApiVersion", "v1.1")));
+ server.enqueue(addCommonHeaders(containerResponse()
+ .addHeader(CONTAINER_METADATA_PREFIX + "ApiName", "swift")
+ .addHeader(CONTAINER_METADATA_PREFIX + "ApiVersion", "v1.1")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -205,7 +205,7 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
assertEquals(replaceRequest.getRequestLine(),
"POST /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer HTTP/1.1");
for (Entry<String, String> entry : metadata.entrySet()) {
- assertEquals(replaceRequest.getHeader("x-container-meta-" + entry.getKey().toLowerCase()), entry.getValue());
+ assertEquals(replaceRequest.getHeader(CONTAINER_METADATA_PREFIX + entry.getKey().toLowerCase()), entry.getValue());
}
} finally {
server.shutdown();
@@ -227,7 +227,7 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
assertEquals(deleteRequest.getRequestLine(),
"POST /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer HTTP/1.1");
for (String key : metadata.keySet()) {
- assertEquals(deleteRequest.getHeader("x-remove-container-meta-" + key.toLowerCase()), "ignored");
+ assertEquals(deleteRequest.getHeader(CONTAINER_REMOVE_METADATA_PREFIX + key.toLowerCase()), "ignored");
}
} finally {
server.shutdown();
@@ -295,8 +295,8 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
private static final Map<String, String> metadata = ImmutableMap.of("ApiName", "swift", "ApiVersion", "v1.1");
public static MockResponse containerResponse() {
- return new MockResponse() //
- .addHeader("X-Container-Object-Count", "42") //
- .addHeader("X-Container-Bytes-Used", "323479");
+ return new MockResponse()
+ .addHeader(CONTAINER_OBJECT_COUNT, "42")
+ .addHeader(CONTAINER_BYTES_USED, "323479");
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/43aa5b3a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/CreatePublicContainerLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/CreatePublicContainerLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/CreatePublicContainerLiveTest.java
index f6251d0..6f921ef 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/CreatePublicContainerLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/CreatePublicContainerLiveTest.java
@@ -19,19 +19,20 @@ package org.jclouds.openstack.swift.v1.features;
import static org.jclouds.openstack.swift.v1.options.CreateContainerOptions.Builder.anybodyRead;
import static org.testng.Assert.assertTrue;
+import org.jclouds.openstack.swift.v1.SwiftApi;
import org.jclouds.openstack.swift.v1.internal.BaseSwiftApiLiveTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
@Test(groups = "live", testName = "CreatePublicContainerLiveTest")
-public class CreatePublicContainerLiveTest extends BaseSwiftApiLiveTest {
+public class CreatePublicContainerLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
private String name = getClass().getSimpleName();
- public void anybodyReadUpdatesMetadata() throws Exception {
+ public void testAnybodyReadUpdatesMetadata() throws Exception {
for (String regionId : api.configuredRegions()) {
api.containerApiInRegion(regionId).createIfAbsent(name, anybodyRead());
- assertTrue(api.containerApiInRegion(regionId).get(name).anybodyRead().get());
+ assertTrue(api.containerApiInRegion(regionId).get(name).getAnybodyRead().get());
}
}