You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by wo...@apache.org on 2011/10/12 22:10:42 UTC
svn commit: r1182565 [8/9] - in /shindig/trunk: config/
content/samplecontainer/examples/commoncontainer/
content/samplecontainer/examples/oauth2/
features/src/main/javascript/features/core.io/
features/src/main/javascript/features/shindig.xhrwrapper/ ...
Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2ClientTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2ClientTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2ClientTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2ClientTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,665 @@
+/*
+ * 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.apache.shindig.gadgets.oauth2.persistence;
+
+import org.apache.shindig.gadgets.oauth2.MockUtils;
+import org.apache.shindig.gadgets.oauth2.OAuth2Accessor;
+import org.apache.shindig.gadgets.oauth2.OAuth2Message;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class OAuth2ClientTest extends MockUtils {
+ private static OAuth2Client client1;
+ private static OAuth2Client client2;
+
+ @Before
+ public void setUp() throws Exception {
+ OAuth2ClientTest.client1 = MockUtils.getClient_Code_Confidential();
+ OAuth2ClientTest.client2 = MockUtils.getClient_Code_Public();
+ }
+
+ @Test
+ public void testOAuth2Client_1() throws Exception {
+ final OAuth2Client result = new OAuth2Client(MockUtils.getDummyEncrypter());
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(null, result.getAuthorizationUrl());
+ Assert.assertEquals(null, result.getClientAuthenticationType());
+ Assert.assertEquals(null, result.getClientId());
+ Assert.assertEquals(null, result.getClientSecret());
+ Assert.assertEquals(null, result.getEncryptedSecret());
+ Assert.assertEquals(null, result.getGadgetUri());
+ Assert.assertEquals("NONE", result.getGrantType());
+ Assert.assertEquals(null, result.getRedirectUri());
+ Assert.assertEquals(null, result.getServiceName());
+ Assert.assertEquals(null, result.getTokenUrl());
+ Assert.assertEquals(false, result.isAllowModuleOverride());
+ Assert.assertEquals(false, result.isAuthorizationHeader());
+ Assert.assertEquals(false, result.isUrlParameter());
+ Assert
+ .assertEquals(
+ "org.apache.shindig.gadgets.oauth2.persistence.sample.OAuth2ClientImpl: serviceName = null , redirectUri = null , gadgetUri = null , clientId = null , grantType = NONE , type = UNKNOWN , grantType = NONE , tokenUrl = null , authorizationUrl = null , this.clientAuthenticationType = null",
+ result.toString());
+ }
+
+ @Test
+ public void testEquals_1() throws Exception {
+
+ final OAuth2Client obj = new OAuth2Client(MockUtils.getDummyEncrypter());
+ obj.setAuthorizationUrl(MockUtils.AUTHORIZE_URL);
+ obj.setClientAuthenticationType(OAuth2Message.BASIC_AUTH_TYPE);
+ obj.setServiceName(MockUtils.SERVICE_NAME);
+ obj.setRedirectUri(MockUtils.REDIRECT_URI);
+ obj.setGrantType(OAuth2Message.AUTHORIZATION);
+ obj.setAllowModuleOverride(true);
+ obj.setAuthorizationHeader(true);
+ obj.setTokenUrl(MockUtils.TOKEN_URL);
+ obj.setGadgetUri(MockUtils.GADGET_URI1);
+ obj.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ obj.setUrlParameter(false);
+ obj.setClientSecret(MockUtils.CLIENT_SECRET1.getBytes("UTF-8"));
+ obj.setClientId(MockUtils.CLIENT_ID1);
+
+ final boolean result = OAuth2ClientTest.client1.equals(obj);
+
+ Assert.assertTrue(result);
+ }
+
+ @Test
+ public void testEquals_2() throws Exception {
+ final Object obj = new Object();
+
+ boolean result = OAuth2ClientTest.client1.equals(obj);
+
+ Assert.assertFalse(result);
+
+ result = OAuth2ClientTest.client1.equals(OAuth2ClientTest.client2);
+
+ Assert.assertFalse(result);
+ }
+
+ @Test
+ public void testEquals_3() throws Exception {
+ final boolean result = OAuth2ClientTest.client1.equals(null);
+
+ Assert.assertFalse(result);
+ }
+
+ @Test
+ public void testGetAuthorizationUrl_1() throws Exception {
+ final String result = OAuth2ClientTest.client1.getAuthorizationUrl();
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(MockUtils.AUTHORIZE_URL, result);
+ }
+
+ @Test
+ public void testGetClientAuthenticationType_1() throws Exception {
+ final String result = OAuth2ClientTest.client1.getClientAuthenticationType();
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(OAuth2Message.BASIC_AUTH_TYPE, result);
+ }
+
+ @Test
+ public void testGetClientId_1() throws Exception {
+ final String result = OAuth2ClientTest.client1.getClientId();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(MockUtils.CLIENT_ID1, result);
+ }
+
+ @Test
+ public void testGetClientSecret_1() throws Exception {
+ final byte[] result = OAuth2ClientTest.client1.getClientSecret();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(MockUtils.CLIENT_SECRET1, new String(result, "UTF-8"));
+ }
+
+ @Test
+ public void testGetEncryptedSecret_1() throws Exception {
+ final byte[] result = OAuth2ClientTest.client1.getEncryptedSecret();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals("dmjfouTfdsfu2", new String(result, "UTF-8"));
+ }
+
+ @Test
+ public void testGetEncrypter_1() throws Exception {
+ final OAuth2Encrypter result = OAuth2ClientTest.client1.getEncrypter();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(MockUtils.getDummyEncrypter(), result);
+ }
+
+ @Test
+ public void testGetGadgetUri_1() throws Exception {
+ final String result = OAuth2ClientTest.client1.getGadgetUri();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(MockUtils.GADGET_URI1, result);
+ }
+
+ @Test
+ public void testGetGrantType_1() throws Exception {
+ final String result = OAuth2ClientTest.client1.getGrantType();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(OAuth2Message.AUTHORIZATION_CODE, result);
+ }
+
+ @Test
+ public void testGetRedirectUri_1() throws Exception {
+ final String result = OAuth2ClientTest.client1.getRedirectUri();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(MockUtils.REDIRECT_URI, result);
+ }
+
+ @Test
+ public void testGetServiceName_1() throws Exception {
+ final String result = OAuth2ClientTest.client1.getServiceName();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(MockUtils.SERVICE_NAME, result);
+ }
+
+ @Test
+ public void testGetTokenUrl_1() throws Exception {
+ final String result = OAuth2ClientTest.client1.getTokenUrl();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(MockUtils.TOKEN_URL, result);
+ }
+
+ @Test
+ public void testGetType_1() throws Exception {
+ final org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type result = OAuth2ClientTest.client1
+ .getType();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(OAuth2Accessor.Type.CONFIDENTIAL, result);
+ }
+
+ @Test
+ public void testHashCode_1() throws Exception {
+ final int result = OAuth2ClientTest.client1.hashCode();
+
+ Assert.assertEquals(-1410040560, result);
+ }
+
+ @Test
+ public void testHashCode_2() throws Exception {
+ final int result = OAuth2ClientTest.client2.hashCode();
+
+ Assert.assertEquals(-1410040559, result);
+ }
+
+ @Test
+ public void testHashCode_3() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri((String) null);
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+
+ final int result = fixture.hashCode();
+
+ Assert.assertEquals(0, result);
+ }
+
+ @Test
+ public void testIsAllowModuleOverride_1() throws Exception {
+ final boolean result = OAuth2ClientTest.client1.isAllowModuleOverride();
+
+ Assert.assertTrue(result);
+ }
+
+ @Test
+ public void testIsAllowModuleOverride_2() throws Exception {
+ final boolean result = OAuth2ClientTest.client2.isAllowModuleOverride();
+
+ Assert.assertFalse(result);
+ }
+
+ @Test
+ public void testIsAuthorizationHeader_1() throws Exception {
+ final boolean result = OAuth2ClientTest.client1.isAuthorizationHeader();
+
+ Assert.assertTrue(result);
+ }
+
+ @Test
+ public void testIsAuthorizationHeader_2() throws Exception {
+ final boolean result = OAuth2ClientTest.client2.isAuthorizationHeader();
+
+ Assert.assertFalse(result);
+ }
+
+ @Test
+ public void testIsUrlParameter_1() throws Exception {
+ final boolean result = OAuth2ClientTest.client1.isUrlParameter();
+
+ Assert.assertFalse(result);
+ }
+
+ @Test
+ public void testIsUrlParameter_2() throws Exception {
+ final boolean result = OAuth2ClientTest.client2.isUrlParameter();
+
+ Assert.assertTrue(result);
+ }
+
+ @Test
+ public void testSetAllowModuleOverride_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final boolean alllowModuleOverride = true;
+
+ fixture.setAllowModuleOverride(alllowModuleOverride);
+ }
+
+ @Test
+ public void testSetAuthorizationHeader_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final boolean authorizationHeader = true;
+
+ fixture.setAuthorizationHeader(authorizationHeader);
+ }
+
+ @Test
+ public void testSetAuthorizationUrl_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final String authorizationUrl = "";
+
+ fixture.setAuthorizationUrl(authorizationUrl);
+ }
+
+ @Test
+ public void testSetClientAuthenticationType_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final String clientAuthenticationType = "";
+
+ fixture.setClientAuthenticationType(clientAuthenticationType);
+ }
+
+ @Test
+ public void testSetClientId_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final String clientId = "";
+
+ fixture.setClientId(clientId);
+ }
+
+ @Test
+ public void testSetClientSecret_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final byte[] secret = new byte[] {};
+
+ fixture.setClientSecret(secret);
+ }
+
+ @Test
+ public void testSetClientSecret_2() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final byte[] secret = new byte[] {};
+
+ fixture.setClientSecret(secret);
+ }
+
+ @Test
+ public void testSetEncryptedSecret_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final byte[] encryptedSecret = new byte[] {};
+
+ fixture.setEncryptedSecret(encryptedSecret);
+ }
+
+ @Test
+ public void testSetEncryptedSecret_2() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final byte[] encryptedSecret = new byte[] {};
+
+ fixture.setEncryptedSecret(encryptedSecret);
+ }
+
+ @Test
+ public void testSetGadgetUri_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final String gadgetUri = "";
+
+ fixture.setGadgetUri(gadgetUri);
+ }
+
+ @Test
+ public void testSetGrantType_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final String grantType = "";
+
+ fixture.setGrantType(grantType);
+ }
+
+ @Test
+ public void testSetRedirectUri_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final String redirectUri = "";
+
+ fixture.setRedirectUri(redirectUri);
+ }
+
+ @Test
+ public void testSetServiceName_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final String serviceName = "";
+
+ fixture.setServiceName(serviceName);
+ }
+
+ @Test
+ public void testSetTokenUrl_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final String tokenUrl = "";
+
+ fixture.setTokenUrl(tokenUrl);
+ }
+
+ @Test
+ public void testSetType_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type type = org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL;
+
+ fixture.setType(type);
+ }
+
+ @Test
+ public void testSetUrlParameter_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+ final boolean urlParameter = true;
+
+ fixture.setUrlParameter(urlParameter);
+ }
+
+ @Test
+ public void testToString_1() throws Exception {
+ final OAuth2Client fixture = new OAuth2Client(MockUtils.getDummyEncrypter());
+ fixture.setAuthorizationUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setServiceName("");
+ fixture.setRedirectUri("");
+ fixture.setGrantType("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setAllowModuleOverride(true);
+ fixture.setAuthorizationHeader(true);
+ fixture.setTokenUrl("");
+ fixture.setGadgetUri("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Accessor.Type.CONFIDENTIAL);
+ fixture.setUrlParameter(true);
+ fixture.setClientSecret(new byte[] {});
+ fixture.setClientId("");
+
+ final String result = fixture.toString();
+
+ Assert.assertNotNull(result);
+ }
+}
\ No newline at end of file
Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2EncryptionExceptionTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2EncryptionExceptionTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2EncryptionExceptionTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2EncryptionExceptionTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.apache.shindig.gadgets.oauth2.persistence;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class OAuth2EncryptionExceptionTest {
+ @Test
+ public void testOAuth2EncryptionException_1() throws Exception {
+ final Exception cause = new Exception();
+
+ final OAuth2EncryptionException result = new OAuth2EncryptionException(cause);
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(500, result.getHttpStatusCode());
+ Assert.assertEquals("java.lang.Exception", result.getMessage());
+ Assert.assertEquals("java.lang.Exception", result.getLocalizedMessage());
+ Assert
+ .assertEquals(
+ "org.apache.shindig.gadgets.oauth2.persistence.OAuth2EncryptionException: java.lang.Exception",
+ result.toString());
+ }
+}
\ No newline at end of file
Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2PersistenceExceptionTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2PersistenceExceptionTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2PersistenceExceptionTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2PersistenceExceptionTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,39 @@
+/*
+ * 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.apache.shindig.gadgets.oauth2.persistence;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class OAuth2PersistenceExceptionTest {
+ @Test
+ public void testOAuth2PersistenceException_1() throws Exception {
+ final Exception cause = new Exception();
+
+ final OAuth2PersistenceException result = new OAuth2PersistenceException(cause);
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals("java.lang.Exception", result.getMessage());
+ Assert.assertEquals("java.lang.Exception", result.getLocalizedMessage());
+ Assert
+ .assertEquals(
+ "org.apache.shindig.gadgets.oauth2.persistence.OAuth2PersistenceException: java.lang.Exception",
+ result.toString());
+ }
+}
\ No newline at end of file
Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2TokenPersistenceTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2TokenPersistenceTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2TokenPersistenceTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2TokenPersistenceTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,687 @@
+/*
+ * 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.apache.shindig.gadgets.oauth2.persistence;
+
+import java.util.Map;
+
+import org.apache.shindig.gadgets.oauth2.MockUtils;
+import org.apache.shindig.gadgets.oauth2.OAuth2Message;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class OAuth2TokenPersistenceTest extends MockUtils {
+ private static OAuth2TokenPersistence accessToken;
+ private static OAuth2TokenPersistence refreshToken;
+
+ @Before
+ public void setUp() throws Exception {
+ OAuth2TokenPersistenceTest.accessToken = MockUtils.getAccessToken();
+ OAuth2TokenPersistenceTest.refreshToken = MockUtils.getRefreshToken();
+ }
+
+ @Test
+ public void testOAuth2TokenPersistence_1() throws Exception {
+ final OAuth2TokenPersistence result = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(null, result.getEncryptedMacSecret());
+ Assert.assertEquals(null, result.getEncryptedSecret());
+ Assert.assertEquals(0L, result.getExpiresAt());
+ Assert.assertEquals(null, result.getGadgetUri());
+ Assert.assertEquals(0L, result.getIssuedAt());
+ Assert.assertEquals(null, result.getMacAlgorithm());
+ Assert.assertEquals(null, result.getMacExt());
+ Assert.assertEquals(null, result.getMacSecret());
+ Assert.assertEquals(null, result.getScope());
+ Assert.assertEquals(null, result.getSecret());
+ Assert.assertEquals(null, result.getServiceName());
+ Assert.assertEquals("Bearer", result.getTokenType());
+ Assert.assertEquals(null, result.getType());
+ Assert.assertEquals(null, result.getUser());
+ Assert
+ .assertEquals(
+ "org.apache.shindig.gadgets.oauth2.persistence.sample.OAuth2TokenImpl: serviceName = null , user = null , gadgetUri = null , scope = null , tokenType = Bearer , issuedAt = 0 , expiresAt = 0 , type = null",
+ result.toString());
+ }
+
+ @Test
+ public void testEquals_1() throws Exception {
+ final OAuth2TokenPersistence obj = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ obj.setServiceName(MockUtils.SERVICE_NAME);
+ obj.setUser(MockUtils.USER);
+ obj.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ obj.setIssuedAt(0L);
+ obj.setEncryptedMacSecret(new byte[] {});
+ obj.setMacAlgorithm("");
+ obj.setScope(MockUtils.SCOPE);
+ obj.setExpiresAt(1L);
+ obj.setMacSecret(new byte[] {});
+ obj.setSecret(new byte[] {});
+ obj.setGadgetUri(MockUtils.GADGET_URI1);
+ obj.setMacExt("");
+ obj.setTokenType(OAuth2Message.BEARER_TOKEN_TYPE);
+
+ final boolean result = OAuth2TokenPersistenceTest.accessToken.equals(obj);
+
+ Assert.assertTrue(result);
+ }
+
+ @Test
+ public void testEquals_2() throws Exception {
+ final boolean result = OAuth2TokenPersistenceTest.accessToken
+ .equals(OAuth2TokenPersistenceTest.refreshToken);
+
+ Assert.assertFalse(result);
+ }
+
+ @Test
+ public void testEquals_3() throws Exception {
+ Assert.assertFalse(OAuth2TokenPersistenceTest.accessToken.equals(new Object()));
+ }
+
+ @Test
+ public void testEquals_4() throws Exception {
+ Assert.assertFalse(OAuth2TokenPersistenceTest.accessToken.equals(null));
+ }
+
+ @Test
+ public void testGetEncryptedMacSecret_1() throws Exception {
+ final byte[] result = OAuth2TokenPersistenceTest.accessToken.getEncryptedMacSecret();
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals("", new String(result, "UTF-8"));
+ }
+
+ @Test
+ public void testGetEncryptedSecret_1() throws Exception {
+ final byte[] result = OAuth2TokenPersistenceTest.accessToken.getEncryptedSecret();
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals("bddfttTfdsfu", new String(result, "UTF-8"));
+ }
+
+ @Test
+ public void testGetExpiresAt_1() throws Exception {
+ final long result = OAuth2TokenPersistenceTest.accessToken.getExpiresAt();
+
+ Assert.assertEquals(1L, result);
+ }
+
+ @Test
+ public void testGetGadgetUri_1() throws Exception {
+ final String result = OAuth2TokenPersistenceTest.accessToken.getGadgetUri();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(MockUtils.GADGET_URI1, result);
+ }
+
+ @Test
+ public void testGetIssuedAt_1() throws Exception {
+ final long result = OAuth2TokenPersistenceTest.accessToken.getIssuedAt();
+
+ Assert.assertEquals(0L, result);
+ }
+
+ @Test
+ public void testGetMacAlgorithm_1() throws Exception {
+ final String result = OAuth2TokenPersistenceTest.accessToken.getMacAlgorithm();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals("", result);
+ }
+
+ @Test
+ public void testGetMacExt_1() throws Exception {
+ final String result = OAuth2TokenPersistenceTest.accessToken.getMacExt();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals("", result);
+ }
+
+ @Test
+ public void testGetMacSecret_1() throws Exception {
+ final byte[] result = OAuth2TokenPersistenceTest.accessToken.getMacSecret();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals("", new String(result, "UTF-8"));
+ }
+
+ @Test
+ public void testGetProperties_1() throws Exception {
+ final Map<String, String> result = OAuth2TokenPersistenceTest.accessToken.getProperties();
+
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testGetScope_1() throws Exception {
+ final String result = OAuth2TokenPersistenceTest.accessToken.getScope();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(MockUtils.SCOPE, result);
+ }
+
+ @Test
+ public void testGetSecret_1() throws Exception {
+ final byte[] result = OAuth2TokenPersistenceTest.accessToken.getSecret();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(MockUtils.ACCESS_SECRET, new String(result, "UTF-8"));
+ }
+
+ @Test
+ public void testGetServiceName_1() throws Exception {
+ final String result = OAuth2TokenPersistenceTest.accessToken.getServiceName();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(MockUtils.SERVICE_NAME, result);
+ }
+
+ @Test
+ public void testGetTokenType_1() throws Exception {
+ final String result = OAuth2TokenPersistenceTest.accessToken.getTokenType();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(OAuth2Message.BEARER_TOKEN_TYPE, result);
+ }
+
+ @Test
+ public void testGetType_1() throws Exception {
+ final org.apache.shindig.gadgets.oauth2.OAuth2Token.Type result = OAuth2TokenPersistenceTest.accessToken
+ .getType();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS, result);
+ }
+
+ @Test
+ public void testGetType_2() throws Exception {
+ final org.apache.shindig.gadgets.oauth2.OAuth2Token.Type result = OAuth2TokenPersistenceTest.refreshToken
+ .getType();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.REFRESH, result);
+ }
+
+ @Test
+ public void testGetUser_1() throws Exception {
+ final String result = OAuth2TokenPersistenceTest.accessToken.getUser();
+
+ Assert.assertNotNull(result);
+
+ Assert.assertEquals(MockUtils.USER, result);
+ }
+
+ @Test
+ public void testHashCode_1() throws Exception {
+ final int result = OAuth2TokenPersistenceTest.accessToken.hashCode();
+
+ Assert.assertEquals(-1087355025, result);
+ }
+
+ @Test
+ public void testHashCode_2() throws Exception {
+ final int result = OAuth2TokenPersistenceTest.refreshToken.hashCode();
+
+ Assert.assertEquals(-1380171248, result);
+ }
+
+ @Test
+ public void testHashCode_3() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri((String) null);
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+
+ final int result = fixture.hashCode();
+
+ Assert.assertEquals(0, result);
+ }
+
+ @Test
+ public void testSetEncryptedMacSecret_1() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final byte[] encryptedSecret = new byte[] {};
+
+ fixture.setEncryptedMacSecret(encryptedSecret);
+ }
+
+ @Test
+ public void testSetEncryptedMaxSecret_2() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final byte[] encryptedSecret = new byte[] {};
+
+ fixture.setEncryptedMacSecret(encryptedSecret);
+ }
+
+ @Test
+ public void testSetEncryptedSecret_1() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final byte[] encryptedSecret = new byte[] {};
+
+ fixture.setEncryptedSecret(encryptedSecret);
+ }
+
+ @Test
+ public void testSetEncryptedSecret_2() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final byte[] encryptedSecret = new byte[] {};
+
+ fixture.setEncryptedSecret(encryptedSecret);
+ }
+
+ @Test
+ public void testSetExpiresAt_1() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final long expiresAt = 1L;
+
+ fixture.setExpiresAt(expiresAt);
+ }
+
+ @Test
+ public void testSetGadgetUri_1() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final String gadgetUri = "";
+
+ fixture.setGadgetUri(gadgetUri);
+ }
+
+ @Test
+ public void testSetIssuedAt_1() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final long issuedAt = 1L;
+
+ fixture.setIssuedAt(issuedAt);
+ }
+
+ @Test
+ public void testSetMacAlgorithm_1() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final String algorithm = "";
+
+ fixture.setMacAlgorithm(algorithm);
+ }
+
+ @Test
+ public void testSetMacExt_1() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final String macExt = "";
+
+ fixture.setMacExt(macExt);
+ }
+
+ @Test
+ public void testSetMacSecret_1() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final byte[] secret = new byte[] {};
+
+ fixture.setMacSecret(secret);
+ }
+
+ @Test
+ public void testSetMacSecret_2() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final byte[] secret = new byte[] {};
+
+ fixture.setMacSecret(secret);
+ }
+
+ @Test
+ public void testSetScope_1() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final String scope = "";
+
+ fixture.setScope(scope);
+ }
+
+ @Test
+ public void testSetSecret_1() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final byte[] secret = new byte[] {};
+
+ fixture.setSecret(secret);
+ }
+
+ @Test
+ public void testSetSecret_2() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final byte[] secret = new byte[] {};
+
+ fixture.setSecret(secret);
+ }
+
+ @Test
+ public void testSetServiceName_1() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final String serviceName = "";
+
+ fixture.setServiceName(serviceName);
+ }
+
+ @Test
+ public void testSetTokenType_1() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final String tokenType = "";
+
+ fixture.setTokenType(tokenType);
+ }
+
+ @Test
+ public void testSetType_1() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final org.apache.shindig.gadgets.oauth2.OAuth2Token.Type type = org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS;
+
+ fixture.setType(type);
+ }
+
+ @Test
+ public void testSetUser_1() throws Exception {
+ final OAuth2TokenPersistence fixture = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ fixture.setServiceName("");
+ fixture.setEncryptedSecret(new byte[] {});
+ fixture.setUser("");
+ fixture.setType(org.apache.shindig.gadgets.oauth2.OAuth2Token.Type.ACCESS);
+ fixture.setIssuedAt(1L);
+ fixture.setEncryptedMacSecret(new byte[] {});
+ fixture.setMacAlgorithm("");
+ fixture.setScope("");
+ fixture.setExpiresAt(1L);
+ fixture.setMacSecret(new byte[] {});
+ fixture.setSecret(new byte[] {});
+ fixture.setGadgetUri("");
+ fixture.setMacExt("");
+ fixture.setTokenType("");
+ final String user = "";
+
+ fixture.setUser(user);
+
+ }
+
+ @Test
+ public void testToString_1() throws Exception {
+ final String result = OAuth2TokenPersistenceTest.accessToken.toString();
+
+ Assert.assertNotNull(result);
+
+ Assert
+ .assertEquals(
+ "org.apache.shindig.gadgets.oauth2.persistence.sample.OAuth2TokenImpl: serviceName = serviceName , user = testUser , gadgetUri = http://www.example.com/1 , scope = testScope , tokenType = Bearer , issuedAt = 0 , expiresAt = 1 , type = ACCESS",
+ result);
+ }
+}
\ No newline at end of file
Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/InMemoryCacheTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/InMemoryCacheTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/InMemoryCacheTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/InMemoryCacheTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,334 @@
+/*
+ * 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.apache.shindig.gadgets.oauth2.persistence.sample;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.apache.shindig.gadgets.oauth2.BasicOAuth2Accessor;
+import org.apache.shindig.gadgets.oauth2.MockUtils;
+import org.apache.shindig.gadgets.oauth2.OAuth2Accessor;
+import org.apache.shindig.gadgets.oauth2.OAuth2Message;
+import org.apache.shindig.gadgets.oauth2.OAuth2Store;
+import org.apache.shindig.gadgets.oauth2.OAuth2Token;
+import org.apache.shindig.gadgets.oauth2.persistence.OAuth2Cache;
+import org.apache.shindig.gadgets.oauth2.persistence.OAuth2Client;
+import org.apache.shindig.gadgets.oauth2.persistence.OAuth2TokenPersistence;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class InMemoryCacheTest extends MockUtils {
+
+ private InMemoryCache cache;
+
+ @Before
+ public void setUp() throws Exception {
+ this.cache = new InMemoryCache();
+ Assert.assertNotNull(this.cache);
+ Assert.assertTrue(OAuth2Cache.class.isInstance(this.cache));
+
+ this.cache.storeClient(MockUtils.getClient_Code_Confidential());
+ this.cache.storeClient(MockUtils.getClient_Code_Public());
+
+ this.cache.storeToken(MockUtils.getAccessToken());
+ this.cache.storeToken(MockUtils.getRefreshToken());
+
+ this.cache.storeOAuth2Accessor(MockUtils.getOAuth2Accessor_Code());
+ this.cache.storeOAuth2Accessor(MockUtils.getOAuth2Accessor_Error());
+ }
+
+ @Test
+ public void testClearClients_1() throws Exception {
+ Assert.assertNotNull(this.cache.getClient(MockUtils.CLIENT_INDEX1));
+
+ this.cache.clearClients();
+
+ Assert.assertNull(this.cache.getClient(MockUtils.CLIENT_INDEX1));
+ }
+
+ @Test
+ public void testClearTokens_1() throws Exception {
+ Assert.assertNotNull(this.cache.getToken(MockUtils.ACCESS_TOKEN_INDEX));
+
+ this.cache.clearTokens();
+
+ Assert.assertNull(this.cache.getToken(MockUtils.ACCESS_TOKEN_INDEX));
+ }
+
+ @Test
+ public void testGetClient_1() throws Exception {
+ final OAuth2Client result = this.cache.getClient(MockUtils.CLIENT_INDEX1);
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(MockUtils.CLIENT_ID1, result.getClientId());
+ }
+
+ @Test
+ public void testGetClientIndex_1() throws Exception {
+
+ final Integer result = this.cache.getClientIndex(MockUtils.GADGET_URI1, MockUtils.SERVICE_NAME);
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(MockUtils.CLIENT_INDEX1, result);
+ }
+
+ @Test
+ public void testGetOAuth2Accessor_1() throws Exception {
+ final OAuth2Accessor result = this.cache.getOAuth2Accessor(MockUtils.ACCESSOR_INDEX1);
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(MockUtils.CLIENT_ID1, result.getClientId());
+ }
+
+ @Test
+ public void testGetOAuth2Accessor_2() throws Exception {
+ final OAuth2Accessor result = this.cache.getOAuth2Accessor(null);
+
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void testGetOAuth2Accessor_3() throws Exception {
+ final OAuth2Accessor result = this.cache.getOAuth2Accessor(MockUtils.BAD_INDEX);
+
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void testGetOAuth2AccessorIndex_1() throws Exception {
+
+ final Integer result = this.cache.getOAuth2AccessorIndex(MockUtils.GADGET_URI1,
+ MockUtils.SERVICE_NAME, MockUtils.USER, MockUtils.SCOPE);
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(MockUtils.ACCESSOR_INDEX1, result);
+ }
+
+ @Test
+ public void testGetToken_1() throws Exception {
+ final OAuth2Token result = this.cache.getToken(MockUtils.ACCESS_TOKEN_INDEX);
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(MockUtils.ACCESS_SECRET, new String(result.getSecret(), "UTF-8"));
+ }
+
+ @Test
+ public void testGetTokenMockUtilsIndex_1() throws Exception {
+ final Integer result = this.cache.getTokenIndex(MockUtils.getAccessToken());
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(MockUtils.ACCESS_TOKEN_INDEX, result);
+ }
+
+ @Test
+ public void testGetTokenIndex_2() throws Exception {
+
+ final OAuth2Token token = null;
+
+ final Integer result = this.cache.getTokenIndex(token);
+
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void testGetTokenIndex_3() throws Exception {
+
+ final Integer result = this.cache.getTokenIndex(MockUtils.GADGET_URI1, MockUtils.SERVICE_NAME,
+ MockUtils.USER, MockUtils.SCOPE, OAuth2Token.Type.ACCESS);
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(MockUtils.ACCESS_TOKEN_INDEX, result);
+ }
+
+ @Test
+ public void testRemoveClient_1() throws Exception {
+
+ OAuth2Client result = this.cache.getClient(MockUtils.CLIENT_INDEX1);
+
+ Assert.assertNotNull(result);
+
+ result = this.cache.removeClient(MockUtils.CLIENT_INDEX1);
+
+ Assert.assertNotNull(result);
+
+ result = this.cache.removeClient(MockUtils.CLIENT_INDEX1);
+
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void testRemoveOAuth2Accessor_1() throws Exception {
+
+ final OAuth2Accessor result = this.cache.removeOAuth2Accessor(MockUtils.BAD_INDEX);
+
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void testRemoveToken_1() throws Exception {
+
+ OAuth2Token result = this.cache.getToken(MockUtils.ACCESS_TOKEN_INDEX);
+
+ Assert.assertNotNull(result);
+
+ result = this.cache.removeToken(MockUtils.ACCESS_TOKEN_INDEX);
+
+ Assert.assertNotNull(result);
+
+ result = this.cache.removeToken(MockUtils.ACCESS_TOKEN_INDEX);
+
+ Assert.assertNull(result);
+
+ }
+
+ @Test
+ public void testStoreClient_1() throws Exception {
+
+ OAuth2Client client = new OAuth2Client(MockUtils.getDummyEncrypter());
+ client.setGadgetUri("xxx");
+ client.setServiceName("yyy");
+
+ final Integer result = this.cache.storeClient(client);
+
+ Assert.assertEquals(909248813, result.intValue());
+
+ client = this.cache.getClient(result);
+
+ Assert.assertNotNull(client);
+ Assert.assertEquals("xxx", client.getGadgetUri());
+ Assert.assertEquals("yyy", client.getServiceName());
+ }
+
+ @Test
+ public void testStoreClient_2() throws Exception {
+
+ final OAuth2Client client = null;
+
+ final Integer result = this.cache.storeClient(client);
+
+ Assert.assertNull(result);
+ }
+
+ @Test
+ public void testStoreClients_1() throws Exception {
+
+ this.cache.clearClients();
+
+ final Collection<OAuth2Client> clients = new HashSet<OAuth2Client>();
+ clients.add(MockUtils.getClient_Code_Confidential());
+ clients.add(MockUtils.getClient_Code_Public());
+
+ this.cache.storeClients(clients);
+
+ Assert.assertNotNull(this.cache.getClient(MockUtils.CLIENT_INDEX1));
+ Assert.assertNotNull(this.cache.getClient(MockUtils.CLIENT_INDEX2));
+ }
+
+ @Test
+ public void testStoreOAuth2Accessor_1() throws Exception {
+ final OAuth2Store store = MockUtils.getDummyStore(this.cache, null, null);
+ OAuth2Accessor accessor = new BasicOAuth2Accessor("XXX", "YYY", "ZZZ", "", false, store, "AAA");
+
+ final Integer result = this.cache.storeOAuth2Accessor(accessor);
+
+ Assert.assertEquals(-1664180105, result.intValue());
+
+ accessor = this.cache.getOAuth2Accessor(result);
+
+ Assert.assertNotNull(accessor);
+ Assert.assertEquals("XXX", accessor.getGadgetUri());
+ Assert.assertEquals("YYY", accessor.getServiceName());
+ Assert.assertEquals("ZZZ", accessor.getUser());
+ Assert.assertEquals("", accessor.getScope());
+ Assert.assertEquals(false, accessor.isAllowModuleOverrides());
+ Assert.assertEquals("AAA", accessor.getRedirectUri());
+ Assert.assertEquals("-1664180105", accessor.getState());
+ }
+
+ @Test
+ public void testStoreOAuth2Accessor_2() throws Exception {
+
+ final OAuth2Accessor accessor = null;
+
+ final Integer result = this.cache.storeOAuth2Accessor(accessor);
+
+ Assert.assertEquals(null, result);
+ }
+
+ @Test
+ public void testStoreToken_1() throws Exception {
+ OAuth2Token token = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
+ token.setGadgetUri("xxx");
+ token.setServiceName("yyy");
+ token.setExpiresAt(2);
+ token.setIssuedAt(1);
+ token.setMacAlgorithm(OAuth2Message.HMAC_SHA_1);
+ token.setMacSecret("shh, it's a secret".getBytes("UTF-8"));
+ token.setScope("mac_scope");
+ token.setSecret("i'll never tell".getBytes("UTF-8"));
+ token.setTokenType(OAuth2Message.MAC_TOKEN_TYPE);
+ token.setType(OAuth2Token.Type.ACCESS);
+ token.setUser("zzz");
+
+ final Integer result = this.cache.storeToken(token);
+
+ Assert.assertEquals(460203885, result.intValue());
+
+ token = this.cache.getToken(result);
+
+ Assert.assertNotNull(token);
+ Assert.assertEquals("xxx", token.getGadgetUri());
+ Assert.assertEquals("yyy", token.getServiceName());
+
+ Assert.assertEquals(2, token.getExpiresAt());
+ Assert.assertEquals(1, token.getIssuedAt());
+ Assert.assertEquals(OAuth2Message.HMAC_SHA_1, token.getMacAlgorithm());
+ Assert.assertEquals("shh, it's a secret", new String(token.getMacSecret(), "UTF-8"));
+ Assert.assertEquals("mac_scope", token.getScope());
+ Assert.assertEquals("i'll never tell", new String(token.getSecret(), "UTF-8"));
+ Assert.assertEquals(OAuth2Message.MAC_TOKEN_TYPE, token.getTokenType());
+ Assert.assertEquals(OAuth2Token.Type.ACCESS, token.getType());
+ Assert.assertEquals("zzz", token.getUser());
+ }
+
+ @Test
+ public void testStoreToken_2() throws Exception {
+
+ final OAuth2Token token = null;
+
+ final Integer result = this.cache.storeToken(token);
+
+ Assert.assertEquals(null, result);
+ }
+
+ @Test
+ public void testStoreTokens_1() throws Exception {
+ this.cache.clearTokens();
+
+ final Collection<OAuth2Token> tokens = new HashSet<OAuth2Token>(2);
+ tokens.add(MockUtils.getAccessToken());
+ tokens.add(MockUtils.getRefreshToken());
+
+ this.cache.storeTokens(tokens);
+
+ Assert.assertNotNull(this.cache.getToken(MockUtils.ACCESS_TOKEN_INDEX));
+ Assert.assertNotNull(this.cache.getToken(MockUtils.REFRESH_TOKEN_INDEX));
+ }
+}
\ No newline at end of file
Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/JSONOAuth2PersisterTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/JSONOAuth2PersisterTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/JSONOAuth2PersisterTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/JSONOAuth2PersisterTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,78 @@
+package org.apache.shindig.gadgets.oauth2.persistence.sample;
+
+import java.util.Set;
+
+import org.apache.shindig.gadgets.oauth2.MockUtils;
+import org.apache.shindig.gadgets.oauth2.OAuth2Accessor;
+import org.apache.shindig.gadgets.oauth2.OAuth2Message;
+import org.apache.shindig.gadgets.oauth2.OAuth2Token;
+import org.apache.shindig.gadgets.oauth2.persistence.OAuth2Client;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JSONOAuth2PersisterTest extends MockUtils {
+ private JSONOAuth2Persister persister;
+
+ @Before
+ public void setUp() throws Exception {
+ this.persister = MockUtils.getDummyPersister();
+ }
+
+ @Test
+ public void testCreateToken_1() throws Exception {
+ final OAuth2Token result = this.persister.createToken();
+
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testLoadClients_1() throws Exception {
+
+ final Set<OAuth2Client> result = this.persister.loadClients();
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(2, result.size());
+
+ for (final OAuth2Client client : result) {
+ final String gadgetUri = client.getGadgetUri();
+ Assert.assertNotNull(gadgetUri);
+ final boolean goodClient = (gadgetUri.equals(MockUtils.GADGET_URI1) || gadgetUri
+ .equals(MockUtils.GADGET_URI2));
+ Assert.assertTrue(goodClient);
+ if (gadgetUri.equals(MockUtils.GADGET_URI1)) {
+ Assert.assertEquals(MockUtils.AUTHORIZE_URL, client.getAuthorizationUrl());
+ Assert.assertEquals(OAuth2Message.BASIC_AUTH_TYPE, client.getClientAuthenticationType());
+ Assert.assertEquals(MockUtils.CLIENT_ID1, client.getClientId());
+ Assert
+ .assertEquals(MockUtils.CLIENT_SECRET1, new String(client.getClientSecret(), "UTF-8"));
+ Assert.assertEquals(MockUtils.getDummyEncrypter(), client.getEncrypter());
+ Assert.assertEquals(OAuth2Message.AUTHORIZATION, client.getGrantType());
+ Assert.assertEquals(MockUtils.REDIRECT_URI, client.getRedirectUri());
+ Assert.assertEquals(MockUtils.SERVICE_NAME, client.getServiceName());
+ Assert.assertEquals(MockUtils.TOKEN_URL, client.getTokenUrl());
+ Assert.assertEquals(OAuth2Accessor.Type.CONFIDENTIAL, client.getType());
+ Assert.assertEquals(true, client.isAllowModuleOverride());
+ Assert.assertEquals(true, client.isAuthorizationHeader());
+ Assert.assertEquals(false, client.isUrlParameter());
+ } else if (gadgetUri.equals(MockUtils.GADGET_URI2)) {
+ Assert.assertEquals(MockUtils.AUTHORIZE_URL, client.getAuthorizationUrl());
+ Assert.assertEquals(OAuth2Message.STANDARD_AUTH_TYPE, client.getClientAuthenticationType());
+ Assert.assertEquals(MockUtils.CLIENT_ID2, client.getClientId());
+ Assert
+ .assertEquals(MockUtils.CLIENT_SECRET2, new String(client.getClientSecret(), "UTF-8"));
+ Assert.assertEquals(MockUtils.getDummyEncrypter(), client.getEncrypter());
+ Assert.assertEquals(OAuth2Message.CLIENT_CREDENTIALS, client.getGrantType());
+ Assert.assertEquals(MockUtils.REDIRECT_URI, client.getRedirectUri());
+ Assert.assertEquals(MockUtils.SERVICE_NAME, client.getServiceName());
+ Assert.assertEquals(MockUtils.TOKEN_URL, client.getTokenUrl());
+ Assert.assertEquals(OAuth2Accessor.Type.PUBLIC, client.getType());
+ Assert.assertEquals(false, client.isAllowModuleOverride());
+ Assert.assertEquals(false, client.isAuthorizationHeader());
+ Assert.assertEquals(true, client.isUrlParameter());
+ } else {
+ throw new RuntimeException("Bad client found " + gadgetUri);
+ }
+ }
+ }
+}
\ No newline at end of file
Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/NoOpEncrypterTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/NoOpEncrypterTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/NoOpEncrypterTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/NoOpEncrypterTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,100 @@
+/*
+ * 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.apache.shindig.gadgets.oauth2.persistence.sample;
+
+import org.apache.shindig.gadgets.oauth2.persistence.OAuth2Encrypter;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class NoOpEncrypterTest {
+ @Test
+ public void testNoOpEncrypter_1() throws Exception {
+
+ final NoOpEncrypter result = new NoOpEncrypter();
+
+ Assert.assertNotNull(result);
+ Assert.assertTrue(OAuth2Encrypter.class.isInstance(result));
+ }
+
+ @Test
+ public void testDecrypt_1() throws Exception {
+ final NoOpEncrypter fixture = new NoOpEncrypter();
+ final String encryptedSecret = "secretin";
+
+ final byte[] bytes = fixture.decrypt(encryptedSecret.getBytes("UTF-8"));
+
+ final String result = new String(bytes, "UTF-8");
+
+ Assert.assertEquals("secretin", result);
+ }
+
+ @Test
+ public void testDecrypt_2() throws Exception {
+ final NoOpEncrypter fixture = new NoOpEncrypter();
+
+ final byte[] result = fixture.decrypt(null);
+
+ Assert.assertEquals(null, result);
+ }
+
+ @Test
+ public void testDecrypt_3() throws Exception {
+ final NoOpEncrypter fixture = new NoOpEncrypter();
+ final String encryptedSecret = "";
+
+ final byte[] bytes = fixture.decrypt(encryptedSecret.getBytes("UTF-8"));
+
+ final String result = new String(bytes, "UTF-8");
+
+ Assert.assertEquals("", result);
+ }
+
+ @Test
+ public void testEncrypt_1() throws Exception {
+ final NoOpEncrypter fixture = new NoOpEncrypter();
+ final String plainSecret = "secretin";
+
+ final byte[] bytes = fixture.encrypt(plainSecret.getBytes("UTF-8"));
+
+ final String result = new String(bytes, "UTF-8");
+
+ Assert.assertEquals("secretin", result);
+ }
+
+ @Test
+ public void testEncrypt_2() throws Exception {
+ final NoOpEncrypter fixture = new NoOpEncrypter();
+
+ final byte[] result = fixture.encrypt(null);
+
+ Assert.assertEquals(null, result);
+ }
+
+ @Test
+ public void testEncrypt_3() throws Exception {
+ final NoOpEncrypter fixture = new NoOpEncrypter();
+ final String plainSecret = "";
+
+ final byte[] bytes = fixture.encrypt(plainSecret.getBytes("UTF-8"));
+
+ final String result = new String(bytes, "UTF-8");
+
+ Assert.assertEquals("", result);
+ }
+}
\ No newline at end of file
Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/OAuth2GadgetBindingTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/OAuth2GadgetBindingTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/OAuth2GadgetBindingTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/OAuth2GadgetBindingTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,117 @@
+/*
+ * 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.apache.shindig.gadgets.oauth2.persistence.sample;
+
+import org.apache.shindig.gadgets.oauth2.MockUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class OAuth2GadgetBindingTest extends MockUtils {
+ private static final OAuth2GadgetBinding FIXTURE = new OAuth2GadgetBinding(MockUtils.GADGET_URI1,
+ MockUtils.SERVICE_NAME, "xxx", true);
+
+ @Test
+ public void testOAuth2GadgetBinding_1() throws Exception {
+ final OAuth2GadgetBinding result = new OAuth2GadgetBinding("xxx", "yyy", "zzz", false);
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals("zzz", result.getClientName());
+ Assert.assertEquals("yyy", result.getGadgetServiceName());
+ Assert.assertEquals("xxx", result.getGadgetUri());
+ Assert.assertEquals(false, result.isAllowOverride());
+ }
+
+ @Test
+ public void testEquals_1() throws Exception {
+ final Object obj = new OAuth2GadgetBinding(MockUtils.GADGET_URI1, MockUtils.SERVICE_NAME,
+ "xxx", true);
+
+ final boolean result = OAuth2GadgetBindingTest.FIXTURE.equals(obj);
+
+ Assert.assertEquals(true, result);
+ }
+
+ @Test
+ public void testEquals_2() throws Exception {
+ final Object obj = new Object();
+
+ final boolean result = OAuth2GadgetBindingTest.FIXTURE.equals(obj);
+
+ Assert.assertEquals(false, result);
+ }
+
+ @Test
+ public void testEquals_3() throws Exception {
+ final boolean result = OAuth2GadgetBindingTest.FIXTURE.equals(null);
+
+ Assert.assertEquals(false, result);
+ }
+
+ @Test
+ public void testGetClientName_1() throws Exception {
+ final String result = OAuth2GadgetBindingTest.FIXTURE.getClientName();
+
+ Assert.assertEquals("xxx", result);
+ }
+
+ @Test
+ public void testGetGadgetServiceName_1() throws Exception {
+ final String result = OAuth2GadgetBindingTest.FIXTURE.getGadgetServiceName();
+
+ Assert.assertEquals(MockUtils.SERVICE_NAME, result);
+ }
+
+ @Test
+ public void testGetGadgetUri_1() throws Exception {
+ final String result = OAuth2GadgetBindingTest.FIXTURE.getGadgetUri();
+
+ Assert.assertEquals(MockUtils.GADGET_URI1, result);
+ }
+
+ @Test
+ public void testHashCode_1() throws Exception {
+ final int result = OAuth2GadgetBindingTest.FIXTURE.hashCode();
+
+ Assert.assertEquals(-1901114596, result);
+ }
+
+ @Test
+ public void testIsAllowOverride_1() throws Exception {
+ final boolean result = OAuth2GadgetBindingTest.FIXTURE.isAllowOverride();
+
+ Assert.assertEquals(true, result);
+ }
+
+ @Test
+ public void testIsAllowOverride_2() throws Exception {
+ final boolean result = OAuth2GadgetBindingTest.FIXTURE.isAllowOverride();
+
+ Assert.assertEquals(true, result);
+ }
+
+ @Test
+ public void testToString_1() throws Exception {
+ final String result = OAuth2GadgetBindingTest.FIXTURE.toString();
+
+ Assert.assertEquals(
+ "org.apache.shindig.gadgets.oauth2.persistence.sample.OAuth2GadgetBinding: gadgetUri = "
+ + MockUtils.GADGET_URI1 + " , gadgetServiceName = " + MockUtils.SERVICE_NAME
+ + " , allowOverride = true", result);
+ }
+}
\ No newline at end of file
Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/OAuth2PersistenceModuleTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/OAuth2PersistenceModuleTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/OAuth2PersistenceModuleTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/OAuth2PersistenceModuleTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,33 @@
+/*
+ * 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.apache.shindig.gadgets.oauth2.persistence.sample;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.google.inject.AbstractModule;
+
+public class OAuth2PersistenceModuleTest {
+ @Test
+ public void testConfigure_1() throws Exception {
+ final OAuth2PersistenceModule fixture = new OAuth2PersistenceModule();
+ Assert.assertNotNull(fixture);
+ Assert.assertTrue(AbstractModule.class.isInstance(fixture));
+ }
+}
\ No newline at end of file
Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/OAuth2ProviderTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/OAuth2ProviderTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/OAuth2ProviderTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/sample/OAuth2ProviderTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,175 @@
+/*
+ * 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.apache.shindig.gadgets.oauth2.persistence.sample;
+
+import org.apache.shindig.gadgets.oauth2.OAuth2Message;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class OAuth2ProviderTest {
+ private OAuth2Provider PROVIDER;
+
+ @Before
+ public void setUp() {
+ this.PROVIDER = new OAuth2Provider();
+ this.PROVIDER.setAuthorizationHeader(true);
+ this.PROVIDER.setAuthorizationUrl("xxx");
+ this.PROVIDER.setClientAuthenticationType(OAuth2Message.BASIC_AUTH_TYPE);
+ this.PROVIDER.setName("yyy");
+ this.PROVIDER.setTokenUrl("zzz");
+ this.PROVIDER.setUrlParameter(false);
+
+ }
+
+ @Test
+ public void testOAuth2Provider_1() throws Exception {
+ final OAuth2Provider result = new OAuth2Provider();
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testEquals_1() throws Exception {
+ final OAuth2Provider obj = new OAuth2Provider();
+ obj.setTokenUrl("zzz");
+ obj.setClientAuthenticationType(OAuth2Message.BASIC_AUTH_TYPE);
+ obj.setAuthorizationUrl("xxx");
+ obj.setAuthorizationHeader(true);
+ obj.setName("yyy");
+ obj.setUrlParameter(false);
+
+ final boolean result = this.PROVIDER.equals(obj);
+
+ Assert.assertEquals(true, result);
+ }
+
+ @Test
+ public void testEquals_2() throws Exception {
+
+ final Object obj = new Object();
+
+ final boolean result = this.PROVIDER.equals(obj);
+
+ Assert.assertEquals(false, result);
+ }
+
+ @Test
+ public void testGetAuthorizationUrl_1() throws Exception {
+ final String result = this.PROVIDER.getAuthorizationUrl();
+
+ Assert.assertEquals("xxx", result);
+ }
+
+ @Test
+ public void testGetClientAuthenticationType_1() throws Exception {
+ final String result = this.PROVIDER.getClientAuthenticationType();
+
+ Assert.assertEquals(OAuth2Message.BASIC_AUTH_TYPE, result);
+ }
+
+ @Test
+ public void testGetName_1() throws Exception {
+ final String result = this.PROVIDER.getName();
+
+ Assert.assertEquals("yyy", result);
+ }
+
+ @Test
+ public void testGetTokenUrl_1() throws Exception {
+ final String result = this.PROVIDER.getTokenUrl();
+
+ Assert.assertEquals("zzz", result);
+ }
+
+ @Test
+ public void testHashCode_1() throws Exception {
+ final int result = this.PROVIDER.hashCode();
+
+ Assert.assertEquals(120153, result);
+ }
+
+ @Test
+ public void testHashCode_2() throws Exception {
+ final OAuth2Provider fixture = new OAuth2Provider();
+ fixture.setTokenUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setAuthorizationUrl("");
+ fixture.setAuthorizationHeader(true);
+ fixture.setName((String) null);
+ fixture.setUrlParameter(true);
+
+ final int result = fixture.hashCode();
+
+ Assert.assertEquals(0, result);
+ }
+
+ @Test
+ public void testIsAuthorizationHeader_1() throws Exception {
+ final boolean result = this.PROVIDER.isAuthorizationHeader();
+
+ Assert.assertEquals(true, result);
+ }
+
+ @Test
+ public void testIsAuthorizationHeader_2() throws Exception {
+ final OAuth2Provider fixture = new OAuth2Provider();
+ fixture.setTokenUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setAuthorizationUrl("");
+ fixture.setAuthorizationHeader(false);
+ fixture.setName("");
+ fixture.setUrlParameter(true);
+
+ final boolean result = fixture.isAuthorizationHeader();
+
+ Assert.assertEquals(false, result);
+ }
+
+ @Test
+ public void testIsUrlParameter_1() throws Exception {
+ final boolean result = this.PROVIDER.isUrlParameter();
+
+ Assert.assertEquals(false, result);
+ }
+
+ @Test
+ public void testIsUrlParameter_2() throws Exception {
+ final OAuth2Provider fixture = new OAuth2Provider();
+ fixture.setTokenUrl("");
+ fixture.setClientAuthenticationType("");
+ fixture.setAuthorizationUrl("");
+ fixture.setAuthorizationHeader(true);
+ fixture.setName("");
+ fixture.setUrlParameter(false);
+
+ final boolean result = fixture.isUrlParameter();
+
+ Assert.assertEquals(false, result);
+ }
+
+ @Test
+ public void testToString_1() throws Exception {
+ final String result = this.PROVIDER.toString();
+
+ Assert
+ .assertEquals(
+ "org.apache.shindig.gadgets.oauth2.persistence.sample.OAuth2Provider: name = yyy , authorizationUrl = xxx , tokenUrl = zzz , clientAuthenticationType = Basic",
+ result);
+ }
+}
\ No newline at end of file
Modified: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/RewriteModuleTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/RewriteModuleTest.java?rev=1182565&r1=1182564&r2=1182565&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/RewriteModuleTest.java (original)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/RewriteModuleTest.java Wed Oct 12 20:10:39 2011
@@ -28,6 +28,10 @@ import org.apache.shindig.config.Contain
import org.apache.shindig.gadgets.DefaultGuiceModule;
import org.apache.shindig.gadgets.admin.GadgetAdminModule;
import org.apache.shindig.gadgets.oauth.OAuthModule;
+import org.apache.shindig.gadgets.oauth2.OAuth2Module;
+import org.apache.shindig.gadgets.oauth2.handler.OAuth2HandlerModule;
+import org.apache.shindig.gadgets.oauth2.persistence.sample.OAuth2PersistenceModule;
+import org.apache.shindig.gadgets.oauth2.OAuth2MessageModule;
import org.apache.shindig.gadgets.render.CajaResponseRewriter;
import org.apache.shindig.gadgets.render.SanitizingResponseRewriter;
import org.apache.shindig.gadgets.rewrite.ResponseRewriterList.RewriteFlow;
@@ -69,7 +73,7 @@ public class RewriteModuleTest {
injector = Guice.createInjector(
new PropertiesModule(),
new GadgetAdminModule(),
- new DefaultGuiceModule(), new OAuthModule());
+ new DefaultGuiceModule(), new OAuthModule(), new OAuth2Module(), new OAuth2PersistenceModule(), new OAuth2MessageModule(), new OAuth2HandlerModule());
}
@Test
Modified: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/StyleTagProxyEmbeddedUrlsVisitorTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/StyleTagProxyEmbeddedUrlsVisitorTest.java?rev=1182565&r1=1182564&r2=1182565&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/StyleTagProxyEmbeddedUrlsVisitorTest.java (original)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/StyleTagProxyEmbeddedUrlsVisitorTest.java Wed Oct 12 20:10:39 2011
@@ -29,6 +29,10 @@ import org.apache.shindig.gadgets.Gadget
import org.apache.shindig.gadgets.admin.GadgetAdminModule;
import org.apache.shindig.gadgets.http.HttpRequest;
import org.apache.shindig.gadgets.oauth.OAuthModule;
+import org.apache.shindig.gadgets.oauth2.OAuth2Module;
+import org.apache.shindig.gadgets.oauth2.handler.OAuth2HandlerModule;
+import org.apache.shindig.gadgets.oauth2.persistence.sample.OAuth2PersistenceModule;
+import org.apache.shindig.gadgets.oauth2.OAuth2MessageModule;
import org.apache.shindig.gadgets.parse.ParseModule;
import org.apache.shindig.gadgets.parse.caja.CajaHtmlParser;
import org.apache.shindig.gadgets.parse.caja.CajaHtmlSerializer;
@@ -67,7 +71,7 @@ public class StyleTagProxyEmbeddedUrlsVi
super.setUp();
injector = Guice.createInjector(
new PropertiesModule(), new GadgetAdminModule(), new DefaultGuiceModule(),
- new OAuthModule());
+ new OAuthModule(), new OAuth2Module(), new OAuth2PersistenceModule(), new OAuth2MessageModule(), new OAuth2HandlerModule());
ParseModule.DOMImplementationProvider domImpl =
new ParseModule.DOMImplementationProvider();
htmlParser = new CajaHtmlParser(domImpl.get());