Updated Branches:
  refs/heads/fix-jclouds-155 b86371236 -> ea2feb67c

Incorporating review comments


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

Branch: refs/heads/fix-jclouds-155
Commit: ea2feb67ca3d0807f2156143188fd6adbf69287f
Parents: b863712
Author: Andrew Phillips <[email protected]>
Authored: Mon Jul 29 22:59:07 2013 -0400
Committer: Andrew Phillips <[email protected]>
Committed: Mon Jul 29 22:59:07 2013 -0400

----------------------------------------------------------------------
 ...seAuthenticationResponseFromHeadersTest.java | 20 +++++++++++---------
 common/openstack/pom.xml                        |  5 -----
 .../ParseAuthenticationResponseFromHeaders.java | 12 ++++++------
 3 files changed, 17 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ea2feb67/apis/swift/src/test/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeadersTest.java
----------------------------------------------------------------------
diff --git 
a/apis/swift/src/test/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeadersTest.java
 
b/apis/swift/src/test/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeadersTest.java
index 200cdfe..91987a9 100644
--- 
a/apis/swift/src/test/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeadersTest.java
+++ 
b/apis/swift/src/test/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeadersTest.java
@@ -60,18 +60,20 @@ public class ParseAuthenticationResponseFromHeadersTest {
                                           .addHeader("X-Storage-Url", 
"http://127.0.0.1:8080/v1/token";).build();
 
       AuthenticationResponse md = parser.apply(response);
-      assertEquals(md, new AuthenticationResponse("token", 
ImmutableMap.<String, URI> of("X-Storage-Url".toLowerCase(), URI
+      assertEquals(md, new AuthenticationResponse("token", 
ImmutableMap.<String, URI> of("X-Storage-Url", URI
                .create("http://fooman:8080/v1/token";))));
+   }
 
+   public void testHandleHeadersCaseInsensitively() {
+      ParseAuthenticationResponseFromHeaders parser = 
i.getInstance(ParseAuthenticationResponseFromHeaders.class);
+      parser = parser.setHostToReplace("fooman");
 
-      // Additional test that verifies that the case insensitive header 
"X-Storage-Url" is actually replaced
-      //       https://issues.apache.org/jira/browse/JCLOUDS-155
-      response = HttpResponse.builder().statusCode(204).message("No Content")
-              .addHeader("X-Auth-Token".toLowerCase(), "token")
-              .addHeader("X-Storage-Token".toLowerCase(), "token")
-              .addHeader("X-Storage-Url".toLowerCase(), 
"http://127.0.0.1:8080/v1/token";).build();
-      md = parser.apply(response);
-      assertEquals(md, new AuthenticationResponse("token", 
ImmutableMap.<String, URI> of("X-Storage-Url".toLowerCase(), URI
+      HttpResponse response = 
HttpResponse.builder().statusCode(204).message("No Content")
+              .addHeader("x-auth-token", "token")
+              .addHeader("x-storage-token", "token")
+              .addHeader("x-storage-url", 
"http://127.0.0.1:8080/v1/token";).build();
+      AuthenticationResponse md = parser.apply(response);
+      assertEquals(md, new AuthenticationResponse("token", 
ImmutableMap.<String, URI> of("x-storage-url".toLowerCase(), URI
               .create("http://fooman:8080/v1/token";))));
    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ea2feb67/common/openstack/pom.xml
----------------------------------------------------------------------
diff --git a/common/openstack/pom.xml b/common/openstack/pom.xml
index 52bd657..dce8613 100644
--- a/common/openstack/pom.xml
+++ b/common/openstack/pom.xml
@@ -50,11 +50,6 @@
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>commons-collections</groupId>
-      <artifactId>commons-collections</artifactId>
-      <version>3.2.1</version>
-    </dependency>
   </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ea2feb67/common/openstack/src/main/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeaders.java
----------------------------------------------------------------------
diff --git 
a/common/openstack/src/main/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeaders.java
 
b/common/openstack/src/main/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeaders.java
index c1f94ed..ed033f0 100644
--- 
a/common/openstack/src/main/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeaders.java
+++ 
b/common/openstack/src/main/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeaders.java
@@ -35,7 +35,8 @@ import org.jclouds.rest.InvocationContext;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Function;
-import org.apache.commons.collections.map.CaseInsensitiveMap;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
 
 /**
  * This parses {@link AuthenticationResponse} from HTTP headers.
@@ -58,14 +59,13 @@ public class ParseAuthenticationResponseFromHeaders 
implements Function<HttpResp
       releasePayload(from);
 
       // HTTP headers are case in-sensitive (RFC 2616) so we must allow for 
that when looking an header names for the URL keyword
-      //FIXME When Apache commons-collections 4 is out of Snapshot it will 
provide generics for CaseInsensitiveMap 
-      final CaseInsensitiveMap services = new CaseInsensitiveMap();
-      for (final Entry<String, String> entry : from.getHeaders().entries()) {
+      Builder<String, URI> builder = ImmutableMap.builder();
+      for (Entry<String, String> entry : from.getHeaders().entries()) {
          if (entry.getKey().toLowerCase().endsWith(URL_SUFFIX.toLowerCase()))
-            services.put(entry.getKey(), getURI(entry.getValue()));
+            builder.put(entry.getKey(), getURI(entry.getValue()));
       }
       AuthenticationResponse response = new 
AuthenticationResponse(checkNotNull(from.getFirstHeaderOrNull(AUTH_TOKEN),
-               AUTH_TOKEN), services);
+               AUTH_TOKEN), builder.build());
       logger.debug("will connect to: ", response);
       return response;
    }

Reply via email to