Repository: jclouds-labs-google Updated Branches: refs/heads/master 0a5719814 -> 4879d4fe9
Prefer Guava Files over FileInputStream This ensures proper resource handling. Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/commit/4879d4fe Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/4879d4fe Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/4879d4fe Branch: refs/heads/master Commit: 4879d4fe9b324c2180691a0e5062fba54e5dce56 Parents: 0a57198 Author: Andrew Gaul <[email protected]> Authored: Thu May 22 00:26:03 2014 -0700 Committer: Andrew Gaul <[email protected]> Committed: Thu May 22 00:26:03 2014 -0700 ---------------------------------------------------------------------- .../src/test/java/org/jclouds/oauth/v2/OAuthTestUtils.java | 6 ++---- .../oauth/v2/functions/OAuthCredentialsFromPKTest.java | 9 ++++++--- 2 files changed, 8 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4879d4fe/oauth/src/test/java/org/jclouds/oauth/v2/OAuthTestUtils.java ---------------------------------------------------------------------- diff --git a/oauth/src/test/java/org/jclouds/oauth/v2/OAuthTestUtils.java b/oauth/src/test/java/org/jclouds/oauth/v2/OAuthTestUtils.java index 611a60a..35eb9b1 100644 --- a/oauth/src/test/java/org/jclouds/oauth/v2/OAuthTestUtils.java +++ b/oauth/src/test/java/org/jclouds/oauth/v2/OAuthTestUtils.java @@ -19,10 +19,8 @@ package org.jclouds.oauth.v2; import com.google.common.base.Charsets; import com.google.common.base.Throwables; import com.google.common.io.Files; -import org.jclouds.util.Strings2; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; @@ -40,8 +38,8 @@ public class OAuthTestUtils { try { properties = properties == null ? new Properties() : properties; properties.put("oauth.identity", "foo"); - properties.put("oauth.credential", Strings2.toStringAndClose(new FileInputStream("src/test/resources/testpk" + - ".pem"))); + properties.put("oauth.credential", + Files.asCharSource(new File("src/test/resources/testpk.pem"), Charsets.UTF_8).read()); properties.put("oauth.endpoint", "http://localhost:5000/o/oauth2/token"); properties.put(AUDIENCE, "https://accounts.google.com/o/oauth2/token"); return properties; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4879d4fe/oauth/src/test/java/org/jclouds/oauth/v2/functions/OAuthCredentialsFromPKTest.java ---------------------------------------------------------------------- diff --git a/oauth/src/test/java/org/jclouds/oauth/v2/functions/OAuthCredentialsFromPKTest.java b/oauth/src/test/java/org/jclouds/oauth/v2/functions/OAuthCredentialsFromPKTest.java index 435cabc..e3794d6 100644 --- a/oauth/src/test/java/org/jclouds/oauth/v2/functions/OAuthCredentialsFromPKTest.java +++ b/oauth/src/test/java/org/jclouds/oauth/v2/functions/OAuthCredentialsFromPKTest.java @@ -17,11 +17,10 @@ package org.jclouds.oauth.v2.functions; import static com.google.common.base.Suppliers.ofInstance; -import static org.jclouds.util.Strings2.toStringAndClose; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import java.io.FileInputStream; +import java.io.File; import java.io.IOException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; @@ -29,6 +28,9 @@ import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.security.spec.InvalidKeySpecException; +import com.google.common.base.Charsets; +import com.google.common.io.Files; + import org.jclouds.domain.Credentials; import org.jclouds.oauth.v2.domain.OAuthCredentials; import org.jclouds.oauth.v2.functions.OAuthCredentialsSupplier.OAuthCredentialsForCredentials; @@ -43,7 +45,8 @@ public class OAuthCredentialsFromPKTest { public static OAuthCredentials loadOAuthCredentials() throws IOException, NoSuchAlgorithmException, CertificateException, InvalidKeySpecException { OAuthCredentialsSupplier loader = new OAuthCredentialsSupplier(ofInstance(new Credentials("foo", - toStringAndClose(new FileInputStream("src/test/resources/testpk.pem")))), new OAuthCredentialsForCredentials("RS256"), "RS256"); + Files.asCharSource(new File("src/test/resources/testpk.pem"), Charsets.UTF_8).read())), + new OAuthCredentialsForCredentials("RS256"), "RS256"); return loader.get(); }
