You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by an...@apache.org on 2014/05/31 07:02:44 UTC

git commit: Adding a test for 278

Repository: jclouds
Updated Branches:
  refs/heads/test-for-jclouds-278 [created] f0c434f1e


Adding a test for 278

Contributed by Bill Branan


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/f0c434f1
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/f0c434f1
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/f0c434f1

Branch: refs/heads/test-for-jclouds-278
Commit: f0c434f1e7c9d4fc580009d2d2385e279d064cb1
Parents: 5239e0f
Author: Andrew Phillips <an...@apache.org>
Authored: Fri May 30 21:46:47 2014 -0400
Committer: Andrew Phillips <an...@apache.org>
Committed: Fri May 30 21:46:47 2014 -0400

----------------------------------------------------------------------
 ...ParseObjectInfoListFromJsonResponseTest.java | 73 ++++++++++++++++++++
 1 file changed, 73 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/f0c434f1/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoListFromJsonResponseTest.java
----------------------------------------------------------------------
diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoListFromJsonResponseTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoListFromJsonResponseTest.java
new file mode 100644
index 0000000..6fa6ffd
--- /dev/null
+++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/functions/ParseObjectInfoListFromJsonResponseTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.swift.functions;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+import com.google.gson.Gson;
+import org.jclouds.blobstore.domain.PageSet;
+import org.jclouds.json.internal.GsonWrapper;
+import org.jclouds.openstack.swift.domain.ObjectInfo;
+import org.jclouds.openstack.swift.options.ListContainerOptions;
+import org.jclouds.reflect.Invocation;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.util.Strings2;
+import org.testng.annotations.Test;
+
+import javax.ws.rs.core.NewCookie;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+/**
+ * @author Bill Branan
+ */
+@Test(groups = "unit")
+public class ParseObjectInfoListFromJsonResponseTest {
+
+   @Test
+   public void testNoUrlDecodingOfResponse() throws Exception {
+       String contentName = "swift-test-content-%20-1401395399020";
+
+       String jsonObjectList =
+          "[{\"last_modified\": \"2014-05-29T20:30:03.845660\", " +
+            "\"bytes\": 19, " +
+            "\"name\": \"" + contentName + "\", " +
+            "\"content_type\": \"application/unknown\"}]";
+
+      InputStream stream = Strings2.toInputStream(jsonObjectList);
+
+      ParseObjectInfoListFromJsonResponse parser =
+          new ParseObjectInfoListFromJsonResponse(new GsonWrapper(new Gson()));
+
+      GeneratedHttpRequest.Builder builder = new GeneratedHttpRequest.Builder();
+      builder.method("method")
+             .endpoint("http://test.org/test")
+             .invocation(Invocation.create(Invokable.from(Object.class.getMethod("toString", null)),
+                                           ImmutableList.<Object>of("container-name", new ListContainerOptions[0])))
+             .caller(null);
+
+      parser.setContext(builder.build());
+
+      ObjectInfo objectInfo = parser.apply(stream).iterator().next();
+      assertEquals(objectInfo.getName(), contentName);
+   }
+
+}
\ No newline at end of file