Repository: jclouds
Updated Branches:
  refs/heads/master bb3c9d265 -> b1c163636


Adding a test to check for JCLOUDS-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/b1c16363
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/b1c16363
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/b1c16363

Branch: refs/heads/master
Commit: b1c163636dbf07b360f85f2ca8a3e570e9c494bd
Parents: bb3c9d2
Author: Andrew Phillips <[email protected]>
Authored: Fri May 30 21:46:47 2014 -0400
Committer: Andrew Phillips <[email protected]>
Committed: Mon Jun 9 15:15:17 2014 -0400

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


http://git-wip-us.apache.org/repos/asf/jclouds/blob/b1c16363/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..ad9688b
--- /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 {
+      // '%x' is not a valid URL encoding
+      String contentName = "swift-test-content-%x-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

Reply via email to