You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ab...@apache.org on 2013/05/12 16:42:58 UTC
[13/18] JCLOUDS-25. Removing sandbox-*.
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/xml/ContainerHandler.java
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/xml/ContainerHandler.java b/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/xml/ContainerHandler.java
deleted file mode 100644
index 1d4fa40..0000000
--- a/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/xml/ContainerHandler.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/**
- * 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.mezeo.pcs.xml;
-
-import java.net.URI;
-import java.util.Date;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.regex.Pattern;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-
-import org.jclouds.date.DateService;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.logging.Logger;
-import org.jclouds.mezeo.pcs.domain.ContainerList;
-import org.jclouds.mezeo.pcs.domain.ResourceInfo;
-import org.jclouds.mezeo.pcs.domain.internal.ContainerInfoImpl;
-import org.jclouds.mezeo.pcs.domain.internal.ContainerListImpl;
-import org.jclouds.mezeo.pcs.domain.internal.FileInfoImpl;
-import org.jclouds.util.Strings2;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-/**
- * @author Adrian Cole
- */
-public class ContainerHandler extends ParseSax.HandlerWithResult<ContainerList> {
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- private SortedSet<ResourceInfo> containerMetadata = Sets.newTreeSet();
- protected Map<String, URI> metadataItems = Maps.newHashMap();
-
- private URI rootUrl;
- private String rootName;
- private Date rootCreated;
- private boolean rootInproject;
- private Date rootModified;
- private String rootOwner;
- private int rootVersion;
- private boolean rootShared;
- private Date rootAccessed;
- private long rootBytes;
- private URI rootParent;
- private URI rootTags;
- private URI rootMetadata;
-
- private URI currentUrl;
- private String currentName;
- private Date currentCreated;
- private boolean currentInproject;
- private Date currentModified;
- private String currentOwner;
- private int currentVersion;
- private boolean currentShared;
- private Date currentAccessed;
- private long currentBytes;
- private URI currentParent;
- private URI currentTags;
- private URI currentMetadata;
- private URI currentContents;
-
- private boolean currentPublic;
- private String currentMimeType;
- private URI currentContent;
- private URI currentPermissions;
-
- private URI currentThumbnail;
-
- private StringBuilder currentText = new StringBuilder();
-
- private final DateService dateParser;
-
- boolean inContainer = false;
- boolean inContents = false;
-
- private ContainerListImpl rootContainer;
-
- @Inject
- public ContainerHandler(DateService dateParser) {
- this.dateParser = dateParser;
- }
-
- public ContainerList getResult() {
- return rootContainer;
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attributes)
- throws SAXException {
- if (qName.equals("contents") && attributes.getIndex("count") != -1) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- rootUrl = URI.create(attributes.getValue(index).replace("/contents", ""));
- }
- inContents = true;
- return;
- } else if (qName.equals("container")) {
- if (inContents)
- inContainer = true;
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentUrl = URI.create(attributes.getValue(index));
- }
- } else if (qName.equals("parent")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentParent = URI.create(attributes.getValue(index));
- if (!inContents)
- rootParent = currentParent;
- }
- } else if (qName.equals("file")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentUrl = URI.create(attributes.getValue(index));
- }
- } else if (qName.equals("content")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentContent = URI.create(attributes.getValue(index));
- }
- } else if (qName.equals("contents")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentContents = URI.create(attributes.getValue(index));
- }
- } else if (qName.equals("permissions")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentPermissions = URI.create(attributes.getValue(index));
- }
- } else if (qName.equals("tags")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentTags = URI.create(attributes.getValue(index));
- if (!inContents)
- rootTags = currentTags;
- }
- } else if (qName.equals("thumbnail")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentThumbnail = URI.create(attributes.getValue(index));
- }
- } else if (qName.equals("metadata")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentMetadata = URI.create(attributes.getValue(index));
- if (!inContents)
- rootMetadata = currentMetadata;
- }
- } else if (qName.equals("metadata-item")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- String key = Strings2.replaceAll(attributes.getValue(index), METADATA_PATTERN, "");
- metadataItems.put(key.toLowerCase(), URI.create(attributes.getValue(index)));
- }
- }
- }
-
- public final Pattern METADATA_PATTERN = Pattern.compile(".*/metadata/");
-
- @Override
- public void endElement(String uri, String name, String qName) {
- if (qName.equals("contents")) {
- if (!inContainer)
- inContents = false;
- currentText = new StringBuilder();
- return;
- }
- if (qName.equals("container") && !inContents) {
- rootContainer = new ContainerListImpl(rootUrl, rootName, rootCreated, rootInproject,
- rootModified, rootOwner, rootVersion, rootShared, rootAccessed, rootBytes,
- containerMetadata, rootTags, rootMetadata, metadataItems, rootParent);
- } else if (qName.equals("container") || qName.equals("file")) {
- if (qName.equals("container")) {
- inContainer = false;
- containerMetadata.add(new ContainerInfoImpl(currentUrl, currentName, currentCreated,
- currentInproject, currentModified, currentOwner, currentVersion,
- currentShared, currentAccessed, currentBytes, currentContents, currentTags,
- currentMetadata, currentParent));
- } else {
- containerMetadata.add(new FileInfoImpl(currentUrl, currentName, currentCreated,
- currentInproject, currentModified, currentOwner, currentVersion,
- currentShared, currentAccessed, currentPublic, currentMimeType, currentBytes,
- currentContent, currentParent, currentPermissions, currentTags,
- currentMetadata, currentThumbnail));
- }
- currentUrl = null;
- currentName = null;
- currentCreated = null;
- currentInproject = false;
- currentModified = null;
- currentOwner = null;
- currentVersion = 0;
- currentShared = false;
- currentAccessed = null;
- currentBytes = 0;
- currentPublic = false;
- currentMimeType = null;
- currentParent = null;
- currentContents = null;
- currentContent = null;
- currentPermissions = null;
- currentTags = null;
- currentMetadata = null;
- currentThumbnail = null;
-
- } else if (qName.equals("name")) {
- currentName = currentText.toString().trim();
- if (!inContents)
- rootName = currentName;
- } else if (qName.equals("created")) {
- currentCreated = dateParser.fromSeconds(Long.parseLong(currentText.toString().trim()));
- if (!inContents)
- rootCreated = currentCreated;
- } else if (qName.equals("inproject")) {
- currentInproject = Boolean.parseBoolean(currentText.toString().trim());
- if (!inContents)
- rootInproject = currentInproject;
- } else if (qName.equals("modified")) {
- currentModified = dateParser.fromSeconds(Long.parseLong(currentText.toString().trim()));
- if (!inContents)
- rootModified = currentModified;
- } else if (qName.equals("owner")) {
- currentOwner = currentText.toString().trim();
- if (!inContents)
- rootOwner = currentOwner;
- } else if (qName.equals("version")) {
- currentVersion = Integer.parseInt(currentText.toString().trim());
- if (!inContents)
- rootVersion = currentVersion;
- } else if (qName.equals("shared")) {
- currentShared = Boolean.parseBoolean(currentText.toString().trim());
- if (!inContents)
- rootShared = currentShared;
- } else if (qName.equals("accessed")) {
- currentAccessed = dateParser.fromSeconds(Long.parseLong(currentText.toString().trim()));
- if (!inContents)
- rootAccessed = currentAccessed;
- } else if (qName.equals("bytes")) {
- currentBytes = Long.parseLong(currentText.toString().trim());
- if (!inContents)
- rootBytes = currentBytes;
- } else if (qName.equals("public")) {
- currentPublic = Boolean.parseBoolean(currentText.toString().trim());
- } else if (qName.equals("mime_type")) {
- currentMimeType = currentText.toString().trim();
- }
- currentText = new StringBuilder();
- }
-
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/xml/FileHandler.java
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/xml/FileHandler.java b/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/xml/FileHandler.java
deleted file mode 100644
index cd765e7..0000000
--- a/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/xml/FileHandler.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/**
- * 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.mezeo.pcs.xml;
-
-import java.net.URI;
-import java.util.Date;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import javax.inject.Inject;
-
-import org.jclouds.date.DateService;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.mezeo.pcs.domain.FileInfoWithMetadata;
-import org.jclouds.mezeo.pcs.domain.internal.FileInfoWithMetadataImpl;
-import org.jclouds.util.Strings2;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.collect.Maps;
-
-/**
- * @author Adrian Cole
- */
-public class FileHandler extends ParseSax.HandlerWithResult<FileInfoWithMetadata> {
- private static final Pattern CONTENT_PATTERN = Pattern.compile("/content");
- private static final Pattern METADATA_PATTERN = Pattern.compile(".*/metadata/");
-
- protected Map<String, URI> metadataItems = Maps.newHashMap();
-
- protected URI currentUrl;
- private String currentName;
- private Date currentCreated;
- private boolean currentInproject;
- private Date currentModified;
- private String currentOwner;
- private int currentVersion;
- private boolean currentShared;
- private Date currentAccessed;
- private long currentBytes;
- private String currentMimeType;
- private boolean currentPublic;
-
- protected StringBuilder currentText = new StringBuilder();
-
- private final DateService dateParser;
-
- private FileInfoWithMetadata fileMetadataList;
-
- private URI currentPermissions;
-
- private URI currentTags;
-
- private URI currentThumbnail;
-
- private URI currentMetadata;
-
- private URI currentContent;
-
- private URI currentParent;
-
- @Inject
- public FileHandler(DateService dateParser) {
- this.dateParser = dateParser;
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attributes)
- throws SAXException {
- if (qName.equals("content")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentContent = URI.create(attributes.getValue(index));
- currentUrl = URI.create(Strings2.replaceAll(attributes.getValue(index), CONTENT_PATTERN,
- ""));
- }
- } else if (qName.equals("permissions")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentPermissions = URI.create(attributes.getValue(index));
- }
- } else if (qName.equals("tags")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentTags = URI.create(attributes.getValue(index));
-
- }
- } else if (qName.equals("parent")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentParent = URI.create(attributes.getValue(index));
- }
- } else if (qName.equals("thumbnail")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentThumbnail = URI.create(attributes.getValue(index));
- }
- } else if (qName.equals("metadata")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- currentMetadata = URI.create(attributes.getValue(index));
- }
- } else if (qName.equals("metadata-item")) {
- int index = attributes.getIndex("xlink:href");
- if (index != -1) {
- String key = Strings2.replaceAll(attributes.getValue(index), METADATA_PATTERN, "");
- metadataItems.put(key.toLowerCase(), URI.create(attributes.getValue(index)));
- }
- }
- }
-
- @Override
- public void endElement(String uri, String name, String qName) {
- if (qName.equals("name")) {
- currentName = currentText.toString().trim();
- } else if (qName.equals("created")) {
- currentCreated = dateParser.fromSeconds(Long.parseLong(currentText.toString().trim()));
- } else if (qName.equals("inproject")) {
- currentInproject = Boolean.parseBoolean(currentText.toString().trim());
- } else if (qName.equals("modified")) {
- currentModified = dateParser.fromSeconds(Long.parseLong(currentText.toString().trim()));
- } else if (qName.equals("owner")) {
- currentOwner = currentText.toString().trim();
- } else if (qName.equals("version")) {
- currentVersion = Integer.parseInt(currentText.toString().trim());
- } else if (qName.equals("shared")) {
- currentShared = Boolean.parseBoolean(currentText.toString().trim());
- } else if (qName.equals("accessed")) {
- currentAccessed = dateParser.fromSeconds(Long.parseLong(currentText.toString().trim()));
- } else if (qName.equals("bytes")) {
- currentBytes = Long.parseLong(currentText.toString().trim());
- } else if (qName.equals("mime_type")) {
- currentMimeType = currentText.toString().trim();
- } else if (qName.equals("public")) {
- currentPublic = Boolean.parseBoolean(currentText.toString().trim());
- } else if (qName.equals("file")) {
- fileMetadataList = new FileInfoWithMetadataImpl(currentUrl, currentName, currentCreated,
- currentInproject, currentModified, currentOwner, currentVersion, currentShared,
- currentAccessed, currentPublic, currentMimeType, currentBytes, currentContent,
- currentParent, currentPermissions, currentTags, currentMetadata, metadataItems,
- currentThumbnail);
- currentUrl = null;
- currentName = null;
- currentCreated = null;
- currentInproject = false;
- currentModified = null;
- currentOwner = null;
- currentVersion = 0;
- currentShared = false;
- currentAccessed = null;
- currentBytes = 0;
- currentMimeType = null;
- currentPublic = false;
- }
- currentText = new StringBuilder();
- }
-
- public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-
- @Override
- public FileInfoWithMetadata getResult() {
- return fileMetadataList;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSAsyncClientTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSAsyncClientTest.java
deleted file mode 100644
index b9f1968..0000000
--- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSAsyncClientTest.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/**
- * 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.mezeo.pcs;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.net.URI;
-import java.util.Map;
-import java.util.Properties;
-
-import org.jclouds.blobstore.binders.BindBlobToMultipartFormTest;
-import org.jclouds.blobstore.functions.ReturnNullOnKeyNotFound;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.RequiresHttp;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x;
-import org.jclouds.http.functions.ReleasePayloadAndReturn;
-import org.jclouds.http.functions.ReturnInputStream;
-import org.jclouds.mezeo.pcs.PCSAsyncClient;
-import org.jclouds.mezeo.pcs.PCSClient;
-import org.jclouds.mezeo.pcs.PCSCloudAsyncClient.Response;
-import org.jclouds.mezeo.pcs.blobstore.functions.BlobToPCSFile;
-import org.jclouds.mezeo.pcs.config.PCSRestClientModule;
-import org.jclouds.mezeo.pcs.domain.PCSFile;
-import org.jclouds.mezeo.pcs.functions.AddMetadataItemIntoMap;
-import org.jclouds.mezeo.pcs.options.PutBlockOptions;
-import org.jclouds.mezeo.pcs.xml.ContainerHandler;
-import org.jclouds.mezeo.pcs.xml.FileHandler;
-import org.jclouds.rest.AsyncClientFactory;
-import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.RestClientTest;
-import org.jclouds.rest.RestContextFactory;
-import org.jclouds.rest.RestContextSpec;
-import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
-import org.jclouds.rest.internal.RestAnnotationProcessor;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Module;
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code PCSClient}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "pcs2.PCSClientTest")
-public class PCSAsyncClientTest extends RestClientTest<PCSAsyncClient> {
-
- public void testList() throws SecurityException, NoSuchMethodException, IOException {
- Method method = PCSAsyncClient.class.getMethod("list");
- HttpRequest request = processor.createRequest(method);
-
- assertRequestLineEquals(request, "GET http://root HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "X-Cloud-Depth: 2\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, ContainerHandler.class);
- assertExceptionParserClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testCreateContainer() throws SecurityException, NoSuchMethodException, IOException {
- Method method = PCSAsyncClient.class.getMethod("createContainer", String.class);
- HttpRequest request = processor.createRequest(method, "container");
-
- assertRequestLineEquals(request, "POST http://root/contents HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "<container><name>container</name></container>",
- "application/vnd.csp.container-info+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseURIFromListOrLocationHeaderIf20x.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testDeleteContainer() throws SecurityException, NoSuchMethodException, IOException {
- Method method = PCSAsyncClient.class.getMethod("deleteContainer", URI.class);
- HttpRequest request = processor.createRequest(method, URI.create("http://localhost/container/1234"));
-
- assertRequestLineEquals(request, "DELETE http://localhost/container/1234 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListURI() throws SecurityException, NoSuchMethodException, IOException {
- Method method = PCSAsyncClient.class.getMethod("list", URI.class);
- HttpRequest request = processor.createRequest(method, URI.create("http://localhost/mycontainer"));
-
- assertRequestLineEquals(request, "GET http://localhost/mycontainer HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "X-Cloud-Depth: 2\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, ContainerHandler.class);
- assertExceptionParserClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testGetFileInfo() throws SecurityException, NoSuchMethodException, IOException {
- Method method = PCSAsyncClient.class.getMethod("getFileInfo", URI.class);
- HttpRequest request = processor.createRequest(method, URI.create("http://localhost/myfile"));
-
- assertRequestLineEquals(request, "GET http://localhost/myfile HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "X-Cloud-Depth: 2\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, FileHandler.class);
- assertExceptionParserClassEquals(method, ReturnNullOnKeyNotFound.class);
-
- checkFilters(request);
- }
-
- public void testUploadFile() throws SecurityException, NoSuchMethodException, IOException {
- Method method = PCSAsyncClient.class.getMethod("uploadFile", URI.class, PCSFile.class);
- HttpRequest request = processor.createRequest(method, URI.create("http://localhost/mycontainer"), blobToPCSFile
- .apply(BindBlobToMultipartFormTest.TEST_BLOB));
-
- assertRequestLineEquals(request, "POST http://localhost/mycontainer/contents HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, BindBlobToMultipartFormTest.EXPECTS, "multipart/form-data; boundary=--JCLOUDS--",
- false);
-
- assertResponseParserClassEquals(method, request, ParseURIFromListOrLocationHeaderIf20x.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testUploadBlock() throws SecurityException, NoSuchMethodException, IOException {
- Method method = PCSAsyncClient.class.getMethod("uploadBlock", URI.class, PCSFile.class, Array.newInstance(
- PutBlockOptions.class, 0).getClass());
- HttpRequest request = processor.createRequest(method, URI.create("http://localhost/mycontainer"), blobToPCSFile
- .apply(BindBlobToMultipartFormTest.TEST_BLOB));
-
- assertRequestLineEquals(request, "PUT http://localhost/mycontainer/content HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "hello", "text/plain", false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDownloadFile() throws SecurityException, NoSuchMethodException, IOException {
- Method method = PCSAsyncClient.class.getMethod("downloadFile", URI.class);
- HttpRequest request = processor.createRequest(method, URI.create("http://localhost/container"));
-
- assertRequestLineEquals(request, "GET http://localhost/container/content HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReturnInputStream.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, ReturnNullOnKeyNotFound.class);
-
- checkFilters(request);
-
- }
-
- public void testDeleteFile() throws SecurityException, NoSuchMethodException, IOException {
- Method method = PCSAsyncClient.class.getMethod("deleteFile", URI.class);
- HttpRequest request = processor.createRequest(method,
- new Object[] { URI.create("http://localhost/contents/file") });
-
- assertRequestLineEquals(request, "DELETE http://localhost/contents/file HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testPutMetadata() throws SecurityException, NoSuchMethodException, IOException {
- Method method = PCSAsyncClient.class.getMethod("putMetadataItem", URI.class, String.class, String.class);
- HttpRequest request = processor.createRequest(method, URI.create("http://localhost/contents/file"), "pow", "bar");
-
- assertRequestLineEquals(request, "PUT http://localhost/contents/file/metadata/pow HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "bar", "application/unknown", false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testAddEntryToMap() throws SecurityException, NoSuchMethodException, IOException {
- Method method = PCSAsyncClient.class.getMethod("addMetadataItemToMap", URI.class, String.class, Map.class);
- HttpRequest request = processor.createRequest(method, URI.create("http://localhost/pow"), "newkey", ImmutableMap
- .of("key", "value"));
-
- assertRequestLineEquals(request, "GET http://localhost/pow/metadata/newkey HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, AddMetadataItemIntoMap.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, null);
-
- checkFilters(request);
- }
-
- private BlobToPCSFile blobToPCSFile;
-
- @Override
- protected void checkFilters(HttpRequest request) {
- assertEquals(request.getFilters().size(), 1);
- assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
- }
-
- @Override
- protected TypeLiteral<RestAnnotationProcessor<PCSAsyncClient>> createTypeLiteral() {
- return new TypeLiteral<RestAnnotationProcessor<PCSAsyncClient>>() {
- };
- }
-
- @BeforeClass
- @Override
- protected void setupFactory() throws IOException {
- super.setupFactory();
- blobToPCSFile = injector.getInstance(BlobToPCSFile.class);
- }
-
- @Override
- protected Module createModule() {
- return new TestPCSRestClientModule();
- }
-
- @RequiresHttp
- @ConfiguresRestClient
- private static final class TestPCSRestClientModule extends PCSRestClientModule {
- @Override
- protected void configure() {
- super.configure();
- }
-
- @Override
- protected Response provideCloudResponse(AsyncClientFactory factory) {
- return null;
- }
-
- @Override
- protected URI provideRootContainerUrl(Response response) {
- return URI.create("http://root");
- }
- }
-
- @Override
- public RestContextSpec<PCSClient, PCSAsyncClient> createContextSpec() {
- Properties properties = new Properties();
- properties.setProperty("pcs.endpoint", "http://goo");
- return new RestContextFactory().createContextSpec("pcs", "identity", "credential", properties);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSClientLiveTest.java
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSClientLiveTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSClientLiveTest.java
deleted file mode 100644
index aa36dd1..0000000
--- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSClientLiveTest.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/**
- * 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.mezeo.pcs;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.mezeo.pcs.options.PutBlockOptions.Builder.range;
-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.io.InputStream;
-import java.net.URI;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-
-import javax.inject.Provider;
-import javax.ws.rs.core.UriBuilder;
-
-import org.jclouds.Constants;
-import org.jclouds.blobstore.KeyNotFoundException;
-import org.jclouds.blobstore.domain.StorageType;
-import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.logging.log4j.config.Log4JLoggingModule;
-import org.jclouds.mezeo.pcs.PCSAsyncClient;
-import org.jclouds.mezeo.pcs.PCSClient;
-import org.jclouds.mezeo.pcs.domain.ContainerList;
-import org.jclouds.mezeo.pcs.domain.FileInfoWithMetadata;
-import org.jclouds.mezeo.pcs.domain.PCSFile;
-import org.jclouds.mezeo.pcs.domain.ResourceInfo;
-import org.jclouds.rest.RestContext;
-import org.jclouds.rest.RestContextFactory;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.BeforeGroups;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Maps;
-import com.google.inject.Module;
-import com.sun.jersey.api.uri.UriBuilderImpl;
-
-/**
- * Tests behavior of {@code PCSDiscovery}
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", testName = "pcs2.PCSClientLiveTest")
-public class PCSClientLiveTest {
-
- Provider<UriBuilder> uriBuilderProvider = new Provider<UriBuilder>() {
-
- @Override
- public UriBuilder get() {
- return new UriBuilderImpl();
- }
-
- };
-
- private RestContext<PCSClient, PCSAsyncClient> context;
- private PCSClient connection;
-
- protected String provider = "pcs";
- protected String identity;
- protected String credential;
- protected String endpoint;
- protected String apiVersion;
-
- protected void setupCredentials() {
- identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
- credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
- + ".credential");
- endpoint = System.getProperty("test." + provider + ".endpoint");
- apiVersion = System.getProperty("test." + provider + ".api-version");
- }
-
- protected Properties setupProperties() {
- Properties overrides = new Properties();
- overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
- overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
- overrides.setProperty(provider + ".identity", identity);
- overrides.setProperty(provider + ".credential", credential);
- if (endpoint != null)
- overrides.setProperty(provider + ".endpoint", endpoint);
- if (apiVersion != null)
- overrides.setProperty(provider + ".api-version", apiVersion);
- return overrides;
- }
-
- @BeforeGroups(groups = { "live" })
- public void setupClient() {
- setupCredentials();
- Properties overrides = setupProperties();
-
- context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
- overrides);
-
- connection = context.getApi();
- ContainerList response = connection.list();
- for (ResourceInfo resource : response) {
- if (resource.getType() == StorageType.FOLDER && resource.getName().startsWith(containerPrefix)) {
- System.err.printf("*** deleting container %s...%n", resource.getName());
- connection.deleteContainer(resource.getUrl());
- }
- }
-
- }
-
- private String containerPrefix = BaseBlobStoreIntegrationTest.CONTAINER_PREFIX;
-
- @Test
- public void testListContainers() throws Exception {
- ContainerList response = connection.list();
- URI rootUrl = response.getUrl();
- String name = "/";
- validateContainerList(response, rootUrl, name);
-
- long initialContainerCount = response.size();
- assertTrue(initialContainerCount >= 0);
-
- // Create test containers
- for (String container : new String[] { containerPrefix + ".testListOwnedContainers1",
- containerPrefix + ".testListOwnedContainers2" }) {
- URI containerURI = connection.createContainer(container);
- connection.putMetadataItem(containerURI, "name", container);
- response = connection.list(containerURI);
- validateContainerList(response, rootUrl, container);
-
- assertEquals(response.getMetadataItems().get("name"),
- URI.create(containerURI.toASCIIString() + "/metadata/name"));
-
- validateMetadataItemNameEquals(containerURI, container);
-
- connection.deleteContainer(containerURI);
- }
- }
-
- private void validateMetadataItemNameEquals(URI resource, String name) throws InterruptedException,
- ExecutionException, TimeoutException {
- Map<String, String> metadata = Maps.newHashMap();
- connection.addMetadataItemToMap(resource, "name", metadata);
- assertEquals(metadata.get("name"), name);
- }
-
- private void validateContainerList(ContainerList response, URI parent, String name) {
- assertNotNull(response.getMetadataItems());
- validateResource(response, parent, name);
- }
-
- private void validateFileInfo(FileInfoWithMetadata response, URI parent, String name, Long size, String mimeType) {
- assertNotNull(response.getMetadataItems());
- assertFalse(response.isPublic());
- assertEquals(response.getBytes(), size);
- assertEquals(response.getMimeType(), mimeType);
- assertNotNull(response.getContent());
- assertNotNull(response.getPermissions());
- assertNotNull(response.getThumbnail());
- validateResource(response, parent, name);
- }
-
- private void validateResource(ResourceInfo response, URI parent, String name) {
- assertNotNull(response);
- assertNotNull(response.getAccessed());
- assertNotNull(response.getBytes());
- assertNotNull(response.getCreated());
- assertNotNull(response.getMetadata());
- assertNotNull(response.getModified());
- assertEquals(response.getName(), name);
- assertEquals(response.getOwner(), identity);
- assertEquals(response.getParent(), parent);
- assertNotNull(response.getTags());
- assertNotNull(response.getType());
- assertNotNull(response.getUrl());
- assertNotNull(response.getVersion());
- }
-
- @Test
- public void testObjectOperations() throws Exception {
- String containerName = containerPrefix + ".testObjectOperations";
- String data = "Here is my data";
-
- URI container = connection.createContainer(containerName);
-
- // Test PUT with string data, ETag hash, and a piece of metadata
- PCSFile object = connection.newFile();
- object.getMetadata().setName("object");
- object.getMetadata().setMimeType("text/plain");
- object.setPayload(data);
- URI objectURI = connection.uploadFile(container, object);
- connection.putMetadataItem(objectURI, "name", "object");
-
- try {
- connection.downloadFile(uriBuilderProvider.get().uri(objectURI).path("sad").build());
- assert false;
- } catch (KeyNotFoundException e) {
- }
- // Test GET of object (including updated metadata)
- InputStream file = connection.downloadFile(objectURI);
- assertEquals(Strings2.toStringAndClose(file), data);
- validateFileInfoAndNameIsInMetadata(container, objectURI, "object", Long.valueOf(data.length()));
-
- try {
- connection.uploadFile(container, object);
- } catch (Throwable e) {
- assertEquals(e.getCause().getClass(), HttpResponseException.class);
- assertEquals(((HttpResponseException) e.getCause()).getResponse().getStatusCode(), 422);
- }
-
- connection.deleteFile(objectURI);
- try {
- connection.getFileInfo(objectURI);
- } catch (Throwable e) {
- assertEquals(e.getClass(), KeyNotFoundException.class);
- }
-
- String name = "sad";
- // try sending it in 2 parts
- object.getMetadata().setName(name);
- objectURI = connection.createFile(container, object);
- validateFileInfoAndNameIsInMetadata(container, objectURI, name, Long.valueOf(0));
-
- object.setPayload(data.substring(0, 2));
- connection.uploadBlock(objectURI, object, range(0, 2));
- validateFileInfoAndNameIsInMetadata(container, objectURI, name, Long.valueOf(2));
-
- object.setPayload(data.substring(2));
- connection.uploadBlock(objectURI, object, range(2, data.getBytes().length));
- validateFileInfoAndNameIsInMetadata(container, objectURI, name, Long.valueOf(data.length()));
-
- file = connection.downloadFile(objectURI);
- assertEquals(Strings2.toStringAndClose(file), data);
-
- // change data in an existing file
- data = "Here is my datum";
- object.setPayload(data.substring(2));
- connection.uploadBlock(objectURI, object, range(2, data.getBytes().length));
- validateFileInfoAndNameIsInMetadata(container, objectURI, name, Long.valueOf(data.length()));
-
- file = connection.downloadFile(objectURI);
- assertEquals(Strings2.toStringAndClose(file), data);
-
- connection.deleteFile(objectURI);
- connection.deleteContainer(container);
- }
-
- private FileInfoWithMetadata validateFileInfoAndNameIsInMetadata(URI container, URI objectURI, String name, Long size)
- throws InterruptedException, ExecutionException, TimeoutException {
- FileInfoWithMetadata response;
- connection.putMetadataItem(objectURI, "name", name);
-
- response = connection.getFileInfo(objectURI);
- validateFileInfo(response, container, name, size, "text/plain");
-
- assertEquals(response.getMetadataItems().get("name"), URI.create(objectURI.toASCIIString() + "/metadata/name"));
-
- validateMetadataItemNameEquals(objectURI, name);
- return response;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSCloudAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSCloudAsyncClientTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSCloudAsyncClientTest.java
deleted file mode 100644
index 0a06eb9..0000000
--- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSCloudAsyncClientTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * 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.mezeo.pcs;
-
-import static org.jclouds.rest.RestContextFactory.contextSpec;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.concurrent.TimeUnit;
-
-import org.jclouds.concurrent.Timeout;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.mezeo.pcs.PCSCloudAsyncClient;
-import org.jclouds.mezeo.pcs.PCSCloudAsyncClient.Response;
-import org.jclouds.mezeo.pcs.xml.CloudXlinkHandler;
-import org.jclouds.rest.RestClientTest;
-import org.jclouds.rest.RestContextSpec;
-import org.jclouds.rest.internal.RestAnnotationProcessor;
-import org.testng.annotations.Test;
-
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code PCSCloudAsyncClient}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "pcs2.PCSCloudTest")
-public class PCSCloudAsyncClientTest extends RestClientTest<PCSCloudAsyncClient> {
-
- public void testAuthenticate() throws SecurityException, NoSuchMethodException, IOException {
- Method method = PCSCloudAsyncClient.class.getMethod("authenticate");
- HttpRequest request = processor.createRequest(method);
-
- assertRequestLineEquals(request, "GET http://localhost:8080/v3 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, CloudXlinkHandler.class);
- assertExceptionParserClassEquals(method, null);
-
- checkFilters(request);
- }
-
- @Override
- protected TypeLiteral<RestAnnotationProcessor<PCSCloudAsyncClient>> createTypeLiteral() {
- return new TypeLiteral<RestAnnotationProcessor<PCSCloudAsyncClient>>() {
- };
- }
-
- @Override
- public RestContextSpec<PCSCloudClient, PCSCloudAsyncClient> createContextSpec() {
- return contextSpec("test", "http://localhost:8080", "3", "", "identity", "credential", PCSCloudClient.class,
- PCSCloudAsyncClient.class);
- }
-
- @Override
- protected void checkFilters(HttpRequest request) {
-
- }
-
- @Timeout(duration = 10, timeUnit = TimeUnit.SECONDS)
- public interface PCSCloudClient {
-
- Response authenticate();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/binders/BindContainerNameToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/binders/BindContainerNameToXmlPayloadTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/binders/BindContainerNameToXmlPayloadTest.java
deleted file mode 100644
index 59583e6..0000000
--- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/binders/BindContainerNameToXmlPayloadTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * 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.mezeo.pcs.binders;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.mezeo.pcs.binders.BindContainerNameToXmlPayload;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code BindContainerNameToXmlPayload}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "pcs2.BindContainerNameToXmlPayloadTest")
-public class BindContainerNameToXmlPayloadTest {
-
- public void test() {
- BindContainerNameToXmlPayload binder = new BindContainerNameToXmlPayload();
- HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
- binder.bindToRequest(request, "foo");
-
- assertEquals(request.getPayload().getRawContent(), "<container><name>foo</name></container>");
- assertEquals(request.getPayload().getContentMetadata().getContentLength(), Long.valueOf(
- "<container><name>foo</name></container>".getBytes().length));
- assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/unknown");
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/binders/BindFileInfoToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/binders/BindFileInfoToXmlPayloadTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/binders/BindFileInfoToXmlPayloadTest.java
deleted file mode 100644
index 6dfc1bc..0000000
--- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/binders/BindFileInfoToXmlPayloadTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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.mezeo.pcs.binders;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-
-import javax.ws.rs.core.HttpHeaders;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.mezeo.pcs.binders.BindFileInfoToXmlPayload;
-import org.jclouds.mezeo.pcs.config.PCSObjectModule;
-import org.jclouds.mezeo.pcs.domain.PCSFile;
-import org.testng.annotations.Test;
-
-import com.google.inject.Guice;
-
-/**
- * Tests behavior of {@code BindFileInfoToXmlPayload}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "pcs2.BindFileInfoToXmlPayloadTest")
-public class BindFileInfoToXmlPayloadTest {
- PCSFile.Factory factory = Guice.createInjector(new PCSObjectModule()).getInstance(PCSFile.Factory.class);
-
- public void test() {
- BindFileInfoToXmlPayload binder = new BindFileInfoToXmlPayload();
- HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
- PCSFile file = factory.create(null);
- file.getMetadata().setName("foo");
- request = binder.bindToRequest(request, file);
- assertEquals(request.getPayload().getRawContent(),
- "<file><name>foo</name><mime_type>application/octet-stream</mime_type><public>false</public></file>");
- assertEquals(
- request.getFirstHeaderOrNull(HttpHeaders.CONTENT_LENGTH),
- "<file><name>foo</name><mime_type>application/octet-stream</mime_type><public>false</public></file>"
- .getBytes().length + "");
- assertEquals(request.getFirstHeaderOrNull(HttpHeaders.CONTENT_TYPE), "application/vnd.csp.file-info+xml");
-
- }
-
- public void testCompound() {
- BindFileInfoToXmlPayload binder = new BindFileInfoToXmlPayload();
- HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
-
- PCSFile file = factory.create(null);
- file.getMetadata().setName("subdir/foo");
- request = binder.bindToRequest(request, file);
- assertEquals(request.getPayload().getRawContent(),
- "<file><name>foo</name><mime_type>application/octet-stream</mime_type><public>false</public></file>");
- assertEquals(
- request.getFirstHeaderOrNull(HttpHeaders.CONTENT_LENGTH),
- "<file><name>foo</name><mime_type>application/octet-stream</mime_type><public>false</public></file>"
- .getBytes().length + "");
- assertEquals(request.getFirstHeaderOrNull(HttpHeaders.CONTENT_TYPE), "application/vnd.csp.file-info+xml");
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/functions/AddMetadataAndReturnIdTest.java
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/functions/AddMetadataAndReturnIdTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/functions/AddMetadataAndReturnIdTest.java
deleted file mode 100644
index 3ef8300..0000000
--- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/functions/AddMetadataAndReturnIdTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * 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.mezeo.pcs.functions;
-
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code UseResourceIdAsETag}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "pcs2.AddMetadataAndReturnIdTest")
-public class AddMetadataAndReturnIdTest {
-// static {
-// RuntimeDelegate.setInstance(new RuntimeDelegateImpl());
-// }
-// HttpResponse response = new HttpResponse();
-// ConcurrentMap<Key, String> fileCache;
-// private RestAnnotationProcessor<TestService> factory;
-// private Method method;
-//
-// private static interface TestService {
-// @POST
-// public void foo(String container, PCSFile file, @Endpoint URI endpoint);
-// }
-//
-// @BeforeClass
-// void setupMap() {
-// fileCache = new ConcurrentHashMap<Key, String>();
-// fileCache.put(new Key("container", "key"), "7F143552-AAF5-11DE-BBB0-0BC388ED913B");
-// }
-//
-// @SuppressWarnings("unchecked")
-// PCSUtil createPCSUtil() {
-// PCSUtil connection = createMock(PCSUtil.class);
-// final Future<Void> voidF = createMock(Future.class);
-// expect(
-// connection.putMetadata(eq("7F143552-AAF5-11DE-BBB0-0BC388ED913B"), eq("foo"),
-// eq("bar"))).andReturn(voidF);
-// expect(
-// connection.putMetadata(eq("7F143552-AAF5-11DE-BBB0-0BC388ED913B"), eq("biz"),
-// eq("baz"))).andReturn(voidF);
-// replay(connection);
-// return connection;
-// }
-//
-// @Test(expectedExceptions = IllegalStateException.class)
-// public void testNoArgs() {
-// AddMetadataAndReturnId function = new AddMetadataAndReturnId(fileCache, createPCSUtil());
-//
-// function.apply(response);
-// }
-//
-// @Test(expectedExceptions = IllegalStateException.class)
-// public void testNoRequest() {
-// AddMetadataAndReturnId function = new AddMetadataAndReturnId(fileCache, createPCSUtil());
-// function.apply(response);
-// }
-//
-// public void testGetEtag() {
-// PCSUtil connection = createPCSUtil();
-// AddMetadataAndReturnId function = new AddMetadataAndReturnId(fileCache, connection);
-// function.setContext(factory.createRequest(method, "container", new PCSFile("key"), URI
-// .create("http://localhost:8080")));
-// response.setContent(Utils
-// .toInputStream("http://localhost/contents/7F143552-AAF5-11DE-BBB0-0BC388ED913B"));
-// String eTag = function.apply(response);
-// assertEquals(eTag, "7F143552-AAF5-11DE-BBB0-0BC388ED913B");
-// }
-//
-// public void testMetadataGetEtag() {
-// PCSUtil connection = createPCSUtil();
-// AddMetadataAndReturnId function = new AddMetadataAndReturnId(fileCache, connection);
-// PCSFile pcsFile = new PCSFile("key");
-// pcsFile.getMetadata().getUserMetadata().put("foo", "bar");
-// pcsFile.getMetadata().getUserMetadata().put("biz", "baz");
-//
-// function.setContext(factory.createRequest(method, "container", pcsFile, URI
-// .create("http://localhost:8080")));
-// response.setContent(Utils
-// .toInputStream("http://localhost/contents/7F143552-AAF5-11DE-BBB0-0BC388ED913B"));
-// String eTag = function.apply(response);
-// assertEquals(eTag, "7F143552-AAF5-11DE-BBB0-0BC388ED913B");
-// verify(connection);
-// }
-//
-// /**
-// * before class, as we need to ensure that the filter is threadsafe.
-// *
-// * @throws NoSuchMethodException
-// * @throws SecurityException
-// *
-// */
-// @BeforeClass
-// protected void createFilter() throws SecurityException, NoSuchMethodException {
-// Injector injector = Guice.createInjector(new RestModule(), new ExecutorServiceModule(
-// Executors.sameThreadExecutor()), new JavaUrlHttpCommandExecutorServiceModule(),
-// new AbstractModule() {
-//
-// protected void configure() {
-// RuntimeDelegate.setInstance(new RuntimeDelegateImpl());
-// bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
-// public Logger getLogger(String category) {
-// return Logger.NULL;
-// }
-// });
-// }
-//
-// });
-// factory = injector.getInstance(com.google.inject.Key
-// .get(new TypeLiteral<RestAnnotationProcessor<TestService>>() {
-// }));
-//
-// method = TestService.class.getMethod("foo", String.class, PCSFile.class, URI.class);
-// }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/functions/AssembleBlobFromBlobMetadataCallTest.java
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/functions/AssembleBlobFromBlobMetadataCallTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/functions/AssembleBlobFromBlobMetadataCallTest.java
deleted file mode 100644
index 412a348..0000000
--- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/functions/AssembleBlobFromBlobMetadataCallTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * 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.mezeo.pcs.functions;
-
-
-/**
- * @author Adrian Cole
- */
-public class AssembleBlobFromBlobMetadataCallTest {
-
-// @SuppressWarnings("unchecked")
-// @Test(expectedExceptions = NullPointerException.class)
-// public void testCall() throws HttpException {
-// FileMetadata metadata = new FileMetadata("blob");
-// metadata.setSize(103);
-// ConcurrentMap<Key, FileMetadata> mdCache = createMock(ConcurrentMap.class);
-// InputStream data = createMock(InputStream.class);
-// AssembleBlobFromContentAndMetadataCache callable = new AssembleBlobFromContentAndMetadataCache(
-// mdCache);
-// HttpResponse response = createMock(HttpResponse.class);
-// expect(mdCache.get(new Key("container", "blob"))).andReturn(metadata);
-// expect(response.getContent()).andReturn(data);
-// replay(mdCache);
-// replay(response);
-// PCSFile file = callable.apply(response);
-// assertEquals(file.getMetadata(), metadata);
-// assertEquals(file.getName(), "blob");
-// assertEquals(file.getData(), data);
-// assertEquals(file.getContentLength(), metadata.getSize());
-// }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/internal/StubPCSAsyncClient.java
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/internal/StubPCSAsyncClient.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/internal/StubPCSAsyncClient.java
deleted file mode 100644
index 187441c..0000000
--- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/internal/StubPCSAsyncClient.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * 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.mezeo.pcs.internal;
-
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Map;
-
-import org.jclouds.mezeo.pcs.PCSAsyncClient;
-import org.jclouds.mezeo.pcs.domain.ContainerList;
-import org.jclouds.mezeo.pcs.domain.FileInfoWithMetadata;
-import org.jclouds.mezeo.pcs.domain.PCSFile;
-import org.jclouds.mezeo.pcs.options.PutBlockOptions;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Implementation of {@link PCSBlobStore} which keeps all data in a local Map object.
- *
- * @author Adrian Cole
- */
-public class StubPCSAsyncClient implements PCSAsyncClient {
- public ListenableFuture<? extends ContainerList> list() {
- throw new UnsupportedOperationException();
- }
-
- public ListenableFuture<? extends ContainerList> list(URI container) {
- throw new UnsupportedOperationException();
- }
-
- public ListenableFuture<URI> createContainer(String container) {
- throw new UnsupportedOperationException();
- }
-
- public ListenableFuture<URI> createContainer(URI parent, String container) {
- throw new UnsupportedOperationException();
- }
-
- public ListenableFuture<Void> deleteContainer(URI container) {
- throw new UnsupportedOperationException();
- }
-
- public ListenableFuture<Void> deleteFile(URI file) {
- throw new UnsupportedOperationException();
- }
-
- public ListenableFuture<InputStream> downloadFile(URI file) {
- throw new UnsupportedOperationException();
- }
-
- public ListenableFuture<URI> uploadFile(URI container, PCSFile object) {
- throw new UnsupportedOperationException();
- }
-
- public ListenableFuture<URI> createFile(URI container, PCSFile object) {
- throw new UnsupportedOperationException();
- }
-
- public ListenableFuture<Void> uploadBlock(URI file, PCSFile object, PutBlockOptions... options) {
- throw new UnsupportedOperationException();
- }
-
- public PCSFile newFile() {
- throw new UnsupportedOperationException();
- }
-
- public ListenableFuture<FileInfoWithMetadata> getFileInfo(URI file) {
- throw new UnsupportedOperationException();
- }
-
- public ListenableFuture<Void> addMetadataItemToMap(URI resource, String key,
- Map<String, String> map) {
- throw new UnsupportedOperationException();
- }
-
- public ListenableFuture<Void> putMetadataItem(URI resource, String key, String value) {
- throw new UnsupportedOperationException();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/options/PutBlockOptionsTest.java
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/options/PutBlockOptionsTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/options/PutBlockOptionsTest.java
deleted file mode 100644
index e8a51d2..0000000
--- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/options/PutBlockOptionsTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * 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.mezeo.pcs.options;
-
-import static org.jclouds.mezeo.pcs.options.PutBlockOptions.Builder.range;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-
-import org.jclouds.mezeo.pcs.options.PutBlockOptions;
-import org.testng.annotations.Test;
-
-/**
- * Tests possible uses of PutBlockOptions and PutBlockOptions.Builder.*
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "mezeo.PutBlockOptionsTest")
-public class PutBlockOptionsTest {
-
- @Test
- public void testRange() {
- PutBlockOptions options = new PutBlockOptions();
- options.range(0, 1024);
- bytes1to1024(options);
- }
-
- private void bytes1to1024(PutBlockOptions options) {
- assertEquals(options.getRange(), "bytes 0-1024/*");
- }
-
- @Test
- public void testRangeZeroToFive() {
- PutBlockOptions options = new PutBlockOptions();
- options.range(0, 5);
- assertEquals(options.getRange(), "bytes 0-5/*");
- }
-
- @Test
- public void testRangeOverride() {
- PutBlockOptions options = new PutBlockOptions();
- options.range(0, 5).range(10, 100);
- assertEquals(options.getRange(), "bytes 10-100/*");
- }
-
- @Test
- public void testNullRange() {
- PutBlockOptions options = new PutBlockOptions();
- assertNull(options.getRange());
- }
-
- @Test
- public void testRangeStatic() {
- PutBlockOptions options = range(0, 1024);
- bytes1to1024(options);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testRangeNegative1() {
- range(-1, 0);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testRangeNegative2() {
- range(0, -1);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testRangeNegative() {
- range(-1, -1);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/xml/CloudXlinkHanderTest.java
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/xml/CloudXlinkHanderTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/xml/CloudXlinkHanderTest.java
deleted file mode 100644
index 9642f18..0000000
--- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/xml/CloudXlinkHanderTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * 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.mezeo.pcs.xml;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Map;
-
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.jclouds.mezeo.pcs.PCSCloudAsyncClient;
-import org.jclouds.mezeo.pcs.xml.CloudXlinkHandler;
-import org.jclouds.mezeo.pcs.xml.CloudXlinkHandler.PCSCloudResponseImpl;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Tests behavior of {@code ParseFlavorListFromJsonResponseTest}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "pcs2.CloudXlinkHanderTest")
-public class CloudXlinkHanderTest extends BaseHandlerTest {
- Map<String, URI> map = ImmutableMap
- .<String, URI> builder()
- .put(
- "rootContainer",
- URI
- .create("https://pcsbeta.mezeo.net/v2/containers/0B5C8F50-8E72-11DE-A1D4-D73479DA6257"))
- .put("contacts", URI.create("https://pcsbeta.mezeo.net/v2/contacts")).put("shares",
- URI.create("https://pcsbeta.mezeo.net/v2/shares")).put("projects",
- URI.create("https://pcsbeta.mezeo.net/v2/projects")).put("metacontainers",
- URI.create("https://pcsbeta.mezeo.net/v2/metacontainers")).put("account",
- URI.create("https://pcsbeta.mezeo.net/v2/account")).put("tags",
- URI.create("https://pcsbeta.mezeo.net/v2/tags")).put("recyclebin",
- URI.create("https://pcsbeta.mezeo.net/v2/recyclebin")).build();
-
- public void testApplyInputStream() {
- InputStream is = getClass().getResourceAsStream("/discovery.xml");
- PCSCloudAsyncClient.Response list = new PCSCloudResponseImpl(map);
-
- PCSCloudAsyncClient.Response result = (PCSCloudAsyncClient.Response) factory.create(
- injector.getInstance(CloudXlinkHandler.class)).parse(is);
-
- assertEquals(result, list);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/xml/ContainerHandlerTest.java
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/xml/ContainerHandlerTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/xml/ContainerHandlerTest.java
deleted file mode 100644
index 0f78330..0000000
--- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/xml/ContainerHandlerTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * 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.mezeo.pcs.xml;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.net.URI;
-
-import org.jclouds.date.DateService;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.jclouds.mezeo.pcs.domain.ContainerList;
-import org.jclouds.mezeo.pcs.domain.ResourceInfo;
-import org.jclouds.mezeo.pcs.domain.internal.ContainerInfoImpl;
-import org.jclouds.mezeo.pcs.domain.internal.ContainerListImpl;
-import org.jclouds.mezeo.pcs.domain.internal.FileInfoImpl;
-import org.jclouds.mezeo.pcs.xml.ContainerHandler;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSortedSet;
-import com.google.common.collect.Maps;
-
-/**
- * Tests behavior of {@code ContainerHandler}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "pcs2.ContainerHandlerTest")
-public class ContainerHandlerTest extends BaseHandlerTest {
-
- private DateService dateService;
-
- @BeforeTest
- @Override
- protected void setUpInjector() {
- super.setUpInjector();
- dateService = injector.getInstance(DateService.class);
- assert dateService != null;
- }
-
- public void testApplyInputStream() {
- InputStream is = getClass().getResourceAsStream("/test_root_container.xml");
- ImmutableSortedSet<? extends ResourceInfo> list = ImmutableSortedSet
- .of(
- new ContainerInfoImpl(
- URI
- .create("https://pcsbeta.mezeo.net/v2/containers/7F143552-AAF5-11DE-BBB0-0BC388ED913B"),
- "test1",
- dateService.fromSeconds(1254008225),
- false,
- dateService.fromSeconds(1254008226),
- "adrian@jclouds.org",
- 1,
- true,
- dateService.fromSeconds(1254008227),
- 1024,
- URI
- .create("https://pcsbeta.mezeo.net/v2/containers/7F143552-AAF5-11DE-BBB0-0BC388ED913B/contents"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/containers/7F143552-AAF5-11DE-BBB0-0BC388ED913B/tags"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/containers/7F143552-AAF5-11DE-BBB0-0BC388ED913B/metadata"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/containers/C4DA95C2-B298-11DE-8D7C-2B1FE4F2B99C")),
- new FileInfoImpl(
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/5C81DADC-AAEE-11DE-9D55-B39340AEFF3A"),
- "more",
- dateService.fromSeconds(1254005157),
- false,
- dateService.fromSeconds(1254005158),
- "adrian@jclouds.org",
- 1,
- false,
- dateService.fromSeconds(1254005159),
- true,
- "application/octet-stream",
- 254288,
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/5C81DADC-AAEE-11DE-9D55-B39340AEFF3A/content"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/containers/C4DA95C2-B298-11DE-8D7C-2B1FE4F2B99C"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/5C81DADC-AAEE-11DE-9D55-B39340AEFF3A/permissions"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/5C81DADC-AAEE-11DE-9D55-B39340AEFF3A/tags"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/5C81DADC-AAEE-11DE-9D55-B39340AEFF3A/metadata"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/5C81DADC-AAEE-11DE-9D55-B39340AEFF3A/thumbnail")),
-
- new FileInfoImpl(
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/9E4C5AFA-A98B-11DE-8B4C-C3884B4A2DA3"),
- "testfile.txt",
- dateService.fromSeconds(1254000180),
- true,
- dateService.fromSeconds(1254000181),
- "adrian@jclouds.org",
- 3,
- false,
- dateService.fromSeconds(1254000182),
- false,
- "text/plain",
- 5,
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/9E4C5AFA-A98B-11DE-8B4C-C3884B4A2DA3/content"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/containers/C4DA95C2-B298-11DE-8D7C-2B1FE4F2B99C"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/9E4C5AFA-A98B-11DE-8B4C-C3884B4A2DA3/permissions"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/9E4C5AFA-A98B-11DE-8B4C-C3884B4A2DA3/tags"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/9E4C5AFA-A98B-11DE-8B4C-C3884B4A2DA3/metadata"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/9E4C5AFA-A98B-11DE-8B4C-C3884B4A2DA3/thumbnail"))
-
- );
-
- ContainerList expects = new ContainerListImpl(
- URI
- .create("https://pcsbeta.mezeo.net/v2/containers/C4DA95C2-B298-11DE-8D7C-2B1FE4F2B99C"),
- "/",
- dateService.fromSeconds(1254848007),
- false,
- dateService.fromSeconds(1255026455),
- "adrian@jclouds.org",
- 0,
- false,
- dateService.fromSeconds(1255026455),
- 0,
- list,
- URI
- .create("https://pcsbeta.mezeo.net/v2/containers/C4DA95C2-B298-11DE-8D7C-2B1FE4F2B99C/tags"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/containers/C4DA95C2-B298-11DE-8D7C-2B1FE4F2B99C/metadata"),
- Maps.<String, URI> newHashMap(),
- URI
- .create("https://pcsbeta.mezeo.net/v2/containers/C4DA95C2-B298-11DE-8D7C-2B1FE4F2B99C"));
-
- ContainerList result = (ContainerList) factory.create(
- injector.getInstance(ContainerHandler.class)).parse(is);
-
- assertEquals(result, expects);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/xml/FileMetadataHandlerTest.java
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/xml/FileMetadataHandlerTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/xml/FileMetadataHandlerTest.java
deleted file mode 100644
index 5cb2b0b..0000000
--- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/xml/FileMetadataHandlerTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * 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.mezeo.pcs.xml;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.net.URI;
-
-import org.jclouds.date.DateService;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.jclouds.mezeo.pcs.domain.FileInfoWithMetadata;
-import org.jclouds.mezeo.pcs.domain.internal.FileInfoWithMetadataImpl;
-import org.jclouds.mezeo.pcs.xml.FileHandler;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Tests behavior of {@code FileListToFileMetadataListHandler}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "pcs2.FileMetadataHandlerTest")
-public class FileMetadataHandlerTest extends BaseHandlerTest {
-
- private DateService dateService;
-
- @BeforeTest
- @Override
- protected void setUpInjector() {
- super.setUpInjector();
- dateService = injector.getInstance(DateService.class);
- assert dateService != null;
- }
-
- public void testFileMetadata() {
- InputStream is = getClass().getResourceAsStream("/test_file_metadata.xml");
-
- FileInfoWithMetadata expects = new FileInfoWithMetadataImpl(
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/9E4C5AFA-A98B-11DE-8B4C-C3884B4A2DA3"),
- "testfile.txt",
- dateService.fromSeconds(1254000180),
- true,
- dateService.fromSeconds(1254000181),
- "adrian@jclouds.org",
- 3,
- false,
- dateService.fromSeconds(1254000182),
- false,
- "text/plain",
- 5,
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/9E4C5AFA-A98B-11DE-8B4C-C3884B4A2DA3/content"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/containers/C4DA95C2-B298-11DE-8D7C-2B1FE4F2B99C"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/9E4C5AFA-A98B-11DE-8B4C-C3884B4A2DA3/permissions"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/9E4C5AFA-A98B-11DE-8B4C-C3884B4A2DA3/tags"),
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/9E4C5AFA-A98B-11DE-8B4C-C3884B4A2DA3/metadata"),
- // Note that we should convert uppercase to lowercase, since most clouds do anyway
-
- ImmutableMap
- .<String, URI> of(
- "foo",
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/9E4C5AFA-A98B-11DE-8B4C-C3884B4A2DA3/metadata/Foo")),
- URI
- .create("https://pcsbeta.mezeo.net/v2/files/9E4C5AFA-A98B-11DE-8B4C-C3884B4A2DA3/thumbnail"));
-
- FileInfoWithMetadata result = (FileInfoWithMetadata) factory.create(
- injector.getInstance(FileHandler.class)).parse(is);
-
- assertEquals(result, expects);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/46e2f006/sandbox-apis/pcs/src/test/resources/discovery.xml
----------------------------------------------------------------------
diff --git a/sandbox-apis/pcs/src/test/resources/discovery.xml b/sandbox-apis/pcs/src/test/resources/discovery.xml
deleted file mode 100644
index b772a48..0000000
--- a/sandbox-apis/pcs/src/test/resources/discovery.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<cloud xmlns:xlink="http://www.w3.org/1999/xlink">
- <rootContainer xlink:href="https://pcsbeta.mezeo.net/v2/containers/0B5C8F50-8E72-11DE-A1D4-D73479DA6257" xlink:type="simple"/>
- <contacts xlink:href="https://pcsbeta.mezeo.net/v2/contacts" xlink:type="simple"/>
- <shares xlink:href="https://pcsbeta.mezeo.net/v2/shares" xlink:type="simple"/>
- <projects xlink:href="https://pcsbeta.mezeo.net/v2/projects" xlink:type="simple"/>
- <metacontainers xlink:href="https://pcsbeta.mezeo.net/v2/metacontainers" xlink:type="simple"/>
- <account xlink:href="https://pcsbeta.mezeo.net/v2/account" xlink:type="simple"/>
- <tags xlink:href="https://pcsbeta.mezeo.net/v2/tags" xlink:type="simple"/>
- <recyclebin xlink:href="https://pcsbeta.mezeo.net/v2/recyclebin" xlink:type="simple"/>
-</cloud>