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 [7/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/handler/BearerTokenHandlerTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/BearerTokenHandlerTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/BearerTokenHandlerTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/BearerTokenHandlerTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,111 @@
+/*
+ * 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.handler;
+
+import java.net.URI;
+
+import org.apache.shindig.common.uri.Uri;
+import org.apache.shindig.gadgets.http.HttpRequest;
+import org.apache.shindig.gadgets.oauth2.MockUtils;
+import org.apache.shindig.gadgets.oauth2.OAuth2Accessor;
+import org.apache.shindig.gadgets.oauth2.OAuth2Error;
+import org.apache.shindig.gadgets.oauth2.OAuth2Message;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class BearerTokenHandlerTest extends MockUtils {
+  @Test
+  public void testBearerTokenHandler_1() throws Exception {
+
+    final BearerTokenHandler result = new BearerTokenHandler();
+
+    Assert.assertNotNull(result);
+    Assert.assertTrue(ResourceRequestHandler.class.isInstance(result));
+    Assert.assertEquals(OAuth2Message.BEARER_TOKEN_TYPE, result.getTokenType());
+  }
+
+  @Test
+  public void testAddOAuth2Params_1() throws Exception {
+    final BearerTokenHandler fixture = new BearerTokenHandler();
+    final OAuth2Accessor accessor = null;
+    final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI("")));
+
+    final OAuth2HandlerError result = fixture.addOAuth2Params(accessor, request);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertNotNull(result.getError());
+    Assert.assertEquals(OAuth2Error.BEARER_TOKEN_PROBLEM, result.getError());
+    Assert.assertNotNull(result.getContextMessage());
+    Assert.assertTrue(result.getContextMessage().startsWith(""));
+  }
+
+  @Test
+  public void testAddOAuth2Params_2() throws Exception {
+    final BearerTokenHandler fixture = new BearerTokenHandler();
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error();
+    final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI("")));
+
+    final OAuth2HandlerError result = fixture.addOAuth2Params(accessor, request);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertNotNull(result.getError());
+    Assert.assertEquals(OAuth2Error.BEARER_TOKEN_PROBLEM, result.getError());
+    Assert.assertNotNull(result.getContextMessage());
+    Assert.assertTrue(result.getContextMessage().startsWith("accessor is invalid"));
+  }
+
+  @Test
+  public void testAddOAuth2Params_5() throws Exception {
+    final BearerTokenHandler fixture = new BearerTokenHandler();
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final HttpRequest request = new HttpRequest((Uri) null);
+    final OAuth2HandlerError result = fixture.addOAuth2Params(accessor, request);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertNotNull(result.getError());
+    Assert.assertEquals(OAuth2Error.BEARER_TOKEN_PROBLEM, result.getError());
+    Assert.assertNotNull(result.getContextMessage());
+    Assert.assertTrue(result.getContextMessage().startsWith("unAuthorizedRequestUri"));
+  }
+
+  @Test
+  public void testAddOAuth2Params_6() throws Exception {
+    final BearerTokenHandler fixture = new BearerTokenHandler();
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final HttpRequest request = new HttpRequest(Uri.parse(MockUtils.GADGET_URI1));
+    final OAuth2HandlerError result = fixture.addOAuth2Params(accessor, request);
+
+    Assert.assertNull(result);
+    final String authHeader = request.getHeader("Authorization");
+    Assert.assertNotNull(authHeader);
+    Assert.assertEquals("Bearer accessSecret", authHeader);
+  }
+
+  @Test
+  public void testGetTokenType_1() throws Exception {
+    final BearerTokenHandler fixture = new BearerTokenHandler();
+
+    final String result = fixture.getTokenType();
+
+    Assert.assertEquals("Bearer", result);
+  }
+}
\ No newline at end of file

Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/ClientCredentialsGrantTypeHandlerTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/ClientCredentialsGrantTypeHandlerTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/ClientCredentialsGrantTypeHandlerTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/ClientCredentialsGrantTypeHandlerTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,176 @@
+/*
+ * 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.handler;
+
+import org.apache.shindig.gadgets.http.HttpRequest;
+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.OAuth2RequestException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ClientCredentialsGrantTypeHandlerTest extends MockUtils {
+  private static ClientCredentialsGrantTypeHandler ccgth;
+
+  @Before
+  public void setUp() throws Exception {
+    ClientCredentialsGrantTypeHandlerTest.ccgth = new ClientCredentialsGrantTypeHandler(
+        MockUtils.getDummyClientAuthHandlers());
+  }
+
+  @Test
+  public void testClientCredentialsGrantTypeHandler_1() throws Exception {
+    final ClientCredentialsGrantTypeHandler result = ClientCredentialsGrantTypeHandlerTest.ccgth;
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals("client_credentials", result.getGrantType());
+    Assert.assertTrue(GrantRequestHandler.class.isInstance(result));
+    Assert.assertEquals(false, result.isAuthorizationEndpointResponse());
+    Assert.assertEquals(false, result.isRedirectRequired());
+    Assert.assertEquals(true, result.isTokenEndpointResponse());
+  }
+
+  @Test(expected = OAuth2RequestException.class)
+  public void testGetAuthorizationRequest_1() throws Exception {
+    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
+    final OAuth2Accessor accessor = null;
+
+    final String completeAuthorizationUrl = "xxx";
+
+    fixture.getAuthorizationRequest(accessor, completeAuthorizationUrl);
+  }
+
+  @Test(expected = OAuth2RequestException.class)
+  public void testGetAuthorizationRequest_2() throws Exception {
+    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+
+    final String completeAuthorizationUrl = null;
+
+    fixture.getAuthorizationRequest(accessor, completeAuthorizationUrl);
+  }
+
+  @Test(expected = OAuth2RequestException.class)
+  public void testGetAuthorizationRequest_3() throws Exception {
+    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error();
+
+    final String completeAuthorizationUrl = "xxx";
+
+    fixture.getAuthorizationRequest(accessor, completeAuthorizationUrl);
+  }
+
+  @Test(expected = OAuth2RequestException.class)
+  public void testGetAuthorizationRequest_4() throws Exception {
+    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final String completeAuthorizationUrl = "xxx";
+
+    fixture.getAuthorizationRequest(accessor, completeAuthorizationUrl);
+  }
+
+  @Test
+  public void testGetAuthorizationRequest_5() throws Exception {
+    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_ClientCredentials();
+    final String completeAuthorizationUrl = "xxx";
+
+    final HttpRequest result = fixture.getAuthorizationRequest(accessor, completeAuthorizationUrl);
+
+    Assert.assertNotNull(result);
+    final String postBody = result.getPostBodyAsString();
+    Assert.assertNotNull(postBody);
+    Assert.assertEquals(
+        "client_id=clientId1&client_secret=clientSecret1&grant_type=client_credentials", postBody);
+  }
+
+  @Test(expected = OAuth2RequestException.class)
+  public void testGetCompleteUrl_1() throws Exception {
+    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
+    final OAuth2Accessor accessor = null;
+    fixture.getCompleteUrl(accessor);
+  }
+
+  @Test(expected = OAuth2RequestException.class)
+  public void testGetCompleteUrl_2() throws Exception {
+    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error();
+    fixture.getCompleteUrl(accessor);
+  }
+
+  @Test(expected = OAuth2RequestException.class)
+  public void testGetCompleteUrl_3() throws Exception {
+    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+
+    fixture.getCompleteUrl(accessor);
+  }
+
+  @Test
+  public void testGetCompleteUrl_4() throws Exception {
+    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_ClientCredentials();
+
+    final String result = fixture.getCompleteUrl(accessor);
+
+    Assert.assertNotNull(result);
+    Assert
+        .assertEquals(
+            "http://www.example.com/token?client_id=clientId1&client_secret=clientSecret1&grant_type=client_credentials&scope=testScope",
+            result);
+  }
+
+  @Test
+  public void testGetGrantType_1() throws Exception {
+    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
+
+    final String result = fixture.getGrantType();
+
+    Assert.assertEquals(OAuth2Message.CLIENT_CREDENTIALS, result);
+  }
+
+  @Test
+  public void testIsAuthorizationEndpointResponse_1() throws Exception {
+    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
+
+    final boolean result = fixture.isAuthorizationEndpointResponse();
+
+    Assert.assertEquals(false, result);
+  }
+
+  @Test
+  public void testIsRedirectRequired_1() throws Exception {
+    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
+
+    final boolean result = fixture.isRedirectRequired();
+
+    Assert.assertEquals(false, result);
+  }
+
+  @Test
+  public void testIsTokenEndpointResponse_1() throws Exception {
+    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
+
+    final boolean result = fixture.isTokenEndpointResponse();
+
+    Assert.assertEquals(true, result);
+  }
+}
\ No newline at end of file

Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/CodeAuthorizationResponseHandlerTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/CodeAuthorizationResponseHandlerTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/CodeAuthorizationResponseHandlerTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/CodeAuthorizationResponseHandlerTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,466 @@
+/*
+ * 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.handler;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.shindig.gadgets.http.HttpFetcher;
+import org.apache.shindig.gadgets.http.HttpResponse;
+import org.apache.shindig.gadgets.oauth2.MockUtils;
+import org.apache.shindig.gadgets.oauth2.OAuth2Accessor;
+import org.apache.shindig.gadgets.oauth2.OAuth2Error;
+import org.apache.shindig.gadgets.oauth2.OAuth2Message;
+import org.apache.shindig.gadgets.oauth2.OAuth2Store;
+import org.apache.shindig.gadgets.oauth2.OAuth2Token;
+import org.easymock.EasyMock;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.inject.Provider;
+
+public class CodeAuthorizationResponseHandlerTest extends MockUtils {
+
+  private static CodeAuthorizationResponseHandler carh;
+  private static OAuth2Store store;
+
+  @Before
+  public void setUp() throws Exception {
+    CodeAuthorizationResponseHandlerTest.store = MockUtils.getDummyStore();
+    CodeAuthorizationResponseHandlerTest.carh = new CodeAuthorizationResponseHandler(
+        MockUtils.getDummyMessageProvider(), MockUtils.getDummyClientAuthHandlers(),
+        MockUtils.getDummyTokenEndpointResponseHandlers(), MockUtils.getDummyFecther());
+  }
+
+  @Test
+  @SuppressWarnings("unchecked")
+  public void testCodeAuthorizationResponseHandler_1() throws Exception {
+    final Provider<OAuth2Message> oauth2MessageProvider = EasyMock.createMock(Provider.class);
+    final List<ClientAuthenticationHandler> clientAuthenticationHandlers = EasyMock
+        .createMock(List.class);
+    final List<TokenEndpointResponseHandler> tokenEndpointResponseHandlers = EasyMock
+        .createMock(List.class);
+    final HttpFetcher fetcher = EasyMock.createMock(HttpFetcher.class);
+
+    EasyMock.replay(oauth2MessageProvider);
+    EasyMock.replay(clientAuthenticationHandlers);
+    EasyMock.replay(tokenEndpointResponseHandlers);
+    EasyMock.replay(fetcher);
+
+    final CodeAuthorizationResponseHandler result = new CodeAuthorizationResponseHandler(
+        oauth2MessageProvider, clientAuthenticationHandlers, tokenEndpointResponseHandlers, fetcher);
+
+    EasyMock.verify(oauth2MessageProvider);
+    EasyMock.verify(clientAuthenticationHandlers);
+    EasyMock.verify(tokenEndpointResponseHandlers);
+    EasyMock.verify(fetcher);
+    Assert.assertNotNull(result);
+    Assert.assertTrue(AuthorizationEndpointResponseHandler.class.isInstance(result));
+  }
+
+  @Test
+  public void testHandleRequest_1() throws Exception {
+    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Redirecting();
+    final HttpServletRequest request = null;
+
+    final OAuth2HandlerError result = fixture.handleRequest(accessor, request);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(OAuth2Error.AUTHORIZATION_CODE_PROBLEM, result.getError());
+    Assert.assertEquals("request is null", result.getContextMessage());
+  }
+
+  @Test
+  public void testHandleRequest_2() throws Exception {
+    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
+    final OAuth2Accessor accessor = null;
+    final HttpServletRequest request = new DummyHttpServletRequest();
+
+    final OAuth2HandlerError result = fixture.handleRequest(accessor, request);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(OAuth2Error.AUTHORIZATION_CODE_PROBLEM, result.getError());
+    Assert.assertEquals("accessor is null", result.getContextMessage());
+  }
+
+  @Test
+  public void testHandleRequest_3() throws Exception {
+    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error();
+    final HttpServletRequest request = new DummyHttpServletRequest();
+
+    final OAuth2HandlerError result = fixture.handleRequest(accessor, request);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(OAuth2Error.AUTHORIZATION_CODE_PROBLEM, result.getError());
+    Assert.assertEquals("accessor is invalid", result.getContextMessage());
+  }
+
+  @Test
+  public void testHandleRequest_4() throws Exception {
+    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_ClientCredentialsRedirecting();
+    final HttpServletRequest request = new DummyHttpServletRequest();
+
+    final OAuth2HandlerError result = fixture.handleRequest(accessor, request);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(OAuth2Error.AUTHORIZATION_CODE_PROBLEM, result.getError());
+    Assert.assertEquals("grant_type is not code", result.getContextMessage());
+  }
+
+  @Test
+  public void testHandleRequest_5() throws Exception {
+    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Redirecting();
+    final HttpServletRequest request = new DummyHttpServletRequest();
+
+    final OAuth2HandlerError result = fixture.handleRequest(accessor, request);
+
+    Assert.assertNull(result);
+
+    final OAuth2Token accessToken = CodeAuthorizationResponseHandlerTest.store.getToken(
+        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
+        accessor.getScope(), OAuth2Token.Type.ACCESS);
+    Assert.assertNotNull(accessToken);
+    Assert.assertEquals("xxx", new String(accessToken.getSecret(), "UTF-8"));
+    Assert.assertEquals(OAuth2Message.BEARER_TOKEN_TYPE, accessToken.getTokenType());
+    Assert.assertTrue(accessToken.getExpiresAt() > 1000);
+
+    final OAuth2Token refreshToken = CodeAuthorizationResponseHandlerTest.store.getToken(
+        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
+        accessor.getScope(), OAuth2Token.Type.REFRESH);
+    Assert.assertNotNull(refreshToken);
+    Assert.assertEquals("yyy", new String(refreshToken.getSecret(), "UTF-8"));
+  }
+
+  @Test
+  public void testHandleResponse_1() throws Exception {
+    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_ClientCredentials();
+    final HttpResponse response = new HttpResponse();
+    final OAuth2HandlerError result = fixture.handleResponse(accessor, response);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertEquals("doesn't handle responses", result.getContextMessage());
+  }
+
+  @Test
+  public void testHandlesRequest_1() throws Exception {
+    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final HttpServletRequest request = null;
+
+    final boolean result = fixture.handlesRequest(accessor, request);
+
+    Assert.assertEquals(false, result);
+  }
+
+  @Test
+  public void testHandlesRequest_2() throws Exception {
+    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Redirecting();
+    final HttpServletRequest request = new DummyHttpServletRequest();
+
+    final boolean result = fixture.handlesRequest(accessor, request);
+
+    Assert.assertTrue(result);
+  }
+
+  @Test
+  public void testHandlesRequest_3() throws Exception {
+    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
+    final OAuth2Accessor accessor = null;
+    final HttpServletRequest request = new DummyHttpServletRequest();
+
+    final boolean result = fixture.handlesRequest(accessor, request);
+
+    Assert.assertEquals(false, result);
+  }
+
+  @Test
+  public void testHandlesRequest_4() throws Exception {
+    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final HttpServletRequest request = new DummyHttpServletRequest();
+
+    final boolean result = fixture.handlesRequest(accessor, request);
+
+    Assert.assertEquals(false, result);
+  }
+
+  @Test
+  public void testHandlesResponse_1() throws Exception {
+    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final HttpResponse response = new HttpResponse();
+
+    final boolean result = fixture.handlesResponse(accessor, response);
+
+    Assert.assertEquals(false, result);
+  }
+
+  static class DummyHttpServletRequest implements HttpServletRequest {
+    private final Map<String, String> parameters;
+
+    DummyHttpServletRequest() {
+      this.parameters = new HashMap<String, String>(1);
+      this.parameters.put(OAuth2Message.AUTHORIZATION, "1234");
+    }
+
+    public Object getAttribute(final String arg0) {
+      return null;
+    }
+
+    @SuppressWarnings("rawtypes")
+    public Enumeration getAttributeNames() {
+      return null;
+    }
+
+    public String getCharacterEncoding() {
+      return null;
+    }
+
+    public int getContentLength() {
+      return 0;
+    }
+
+    public String getContentType() {
+      return null;
+    }
+
+    public ServletInputStream getInputStream() throws IOException {
+      return null;
+    }
+
+    public String getLocalAddr() {
+      return null;
+    }
+
+    public String getLocalName() {
+      return null;
+    }
+
+    public int getLocalPort() {
+      return 0;
+    }
+
+    public Locale getLocale() {
+      return null;
+    }
+
+    @SuppressWarnings("rawtypes")
+    public Enumeration getLocales() {
+      return null;
+    }
+
+    public String getParameter(final String arg0) {
+      return this.parameters.get(arg0);
+    }
+
+    @SuppressWarnings("rawtypes")
+    public Map getParameterMap() {
+      return this.parameters;
+    }
+
+    @SuppressWarnings("rawtypes")
+    public Enumeration getParameterNames() {
+      return Collections.enumeration(this.parameters.keySet());
+    }
+
+    public String[] getParameterValues(final String arg0) {
+      return null;
+    }
+
+    public String getProtocol() {
+      return null;
+    }
+
+    public BufferedReader getReader() throws IOException {
+      return null;
+    }
+
+    public String getRealPath(final String arg0) {
+      return null;
+    }
+
+    public String getRemoteAddr() {
+      return null;
+    }
+
+    public String getRemoteHost() {
+      return null;
+    }
+
+    public int getRemotePort() {
+      return 0;
+    }
+
+    public RequestDispatcher getRequestDispatcher(final String arg0) {
+      return null;
+    }
+
+    public String getScheme() {
+      return null;
+    }
+
+    public String getServerName() {
+      return null;
+    }
+
+    public int getServerPort() {
+      return 0;
+    }
+
+    public boolean isSecure() {
+      return false;
+    }
+
+    public void removeAttribute(final String arg0) {
+      // does nothing
+    }
+
+    public void setAttribute(final String arg0, final Object arg1) {
+      // does nothing
+    }
+
+    public void setCharacterEncoding(final String arg0) throws UnsupportedEncodingException {
+      // does nothing
+    }
+
+    public String getAuthType() {
+      return null;
+    }
+
+    public String getContextPath() {
+      return null;
+    }
+
+    public Cookie[] getCookies() {
+      return null;
+    }
+
+    public long getDateHeader(final String arg0) {
+      return 0;
+    }
+
+    public String getHeader(final String arg0) {
+      return null;
+    }
+
+    @SuppressWarnings("rawtypes")
+    public Enumeration getHeaderNames() {
+      return null;
+    }
+
+    @SuppressWarnings("rawtypes")
+    public Enumeration getHeaders(final String arg0) {
+      return null;
+    }
+
+    public int getIntHeader(final String arg0) {
+      return 0;
+    }
+
+    public String getMethod() {
+      return null;
+    }
+
+    public String getPathInfo() {
+      return null;
+    }
+
+    public String getPathTranslated() {
+      return null;
+    }
+
+    public String getQueryString() {
+      return null;
+    }
+
+    public String getRemoteUser() {
+      return null;
+    }
+
+    public String getRequestURI() {
+      return null;
+    }
+
+    public StringBuffer getRequestURL() {
+      return null;
+    }
+
+    public String getRequestedSessionId() {
+      return null;
+    }
+
+    public String getServletPath() {
+      return null;
+    }
+
+    public HttpSession getSession() {
+      return null;
+    }
+
+    public HttpSession getSession(final boolean arg0) {
+      return null;
+    }
+
+    public Principal getUserPrincipal() {
+      return null;
+    }
+
+    public boolean isRequestedSessionIdFromCookie() {
+      return false;
+    }
+
+    public boolean isRequestedSessionIdFromURL() {
+      return false;
+    }
+
+    public boolean isRequestedSessionIdFromUrl() {
+      return false;
+    }
+
+    public boolean isRequestedSessionIdValid() {
+      return false;
+    }
+
+    public boolean isUserInRole(final String arg0) {
+      return false;
+    }
+  }
+}
\ No newline at end of file

Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/CodeGrantTypeHandlerTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/CodeGrantTypeHandlerTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/CodeGrantTypeHandlerTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/CodeGrantTypeHandlerTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,135 @@
+/*
+ * 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.handler;
+
+import org.apache.shindig.gadgets.oauth2.MockUtils;
+import org.apache.shindig.gadgets.oauth2.OAuth2Accessor;
+import org.apache.shindig.gadgets.oauth2.OAuth2RequestException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CodeGrantTypeHandlerTest extends MockUtils {
+
+  private static CodeGrantTypeHandler cgth;
+
+  @Before
+  public void setUp() throws Exception {
+    CodeGrantTypeHandlerTest.cgth = new CodeGrantTypeHandler();
+  }
+
+  @Test
+  public void testCodeGrantTypeHandler_1() throws Exception {
+    final CodeGrantTypeHandler result = new CodeGrantTypeHandler();
+
+    Assert.assertNotNull(result);
+    Assert.assertTrue(GrantRequestHandler.class.isInstance(result));
+    Assert.assertEquals("code", result.getGrantType());
+    Assert.assertEquals("authorization_code", CodeGrantTypeHandler.getResponseType());
+    Assert.assertEquals(true, result.isAuthorizationEndpointResponse());
+    Assert.assertEquals(true, result.isRedirectRequired());
+    Assert.assertEquals(false, result.isTokenEndpointResponse());
+  }
+
+  @Test(expected = OAuth2RequestException.class)
+  public void testGetAuthorizationRequest_1() throws Exception {
+    final CodeGrantTypeHandler fixture = CodeGrantTypeHandlerTest.cgth;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final String completeAuthorizationUrl = "xxx";
+
+    fixture.getAuthorizationRequest(accessor, completeAuthorizationUrl);
+  }
+
+  @Test(expected = OAuth2RequestException.class)
+  public void testGetCompleteUrl_1() throws Exception {
+    final CodeGrantTypeHandler fixture = CodeGrantTypeHandlerTest.cgth;
+    final OAuth2Accessor accessor = null;
+    fixture.getCompleteUrl(accessor);
+  }
+
+  @Test(expected = OAuth2RequestException.class)
+  public void testGetCompleteUrl_2() throws Exception {
+    final CodeGrantTypeHandler fixture = CodeGrantTypeHandlerTest.cgth;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error();
+    fixture.getCompleteUrl(accessor);
+  }
+
+  @Test(expected = OAuth2RequestException.class)
+  public void testGetCompleteUrl_3() throws Exception {
+    final CodeGrantTypeHandler fixture = CodeGrantTypeHandlerTest.cgth;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_ClientCredentialsRedirecting();
+    fixture.getCompleteUrl(accessor);
+  }
+
+  @Test
+  public void testGetCompleteUrl_4() throws Exception {
+    final CodeGrantTypeHandler fixture = CodeGrantTypeHandlerTest.cgth;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final String result = fixture.getCompleteUrl(accessor);
+
+    Assert.assertNotNull(result);
+    Assert
+        .assertEquals(
+            "http://www.example.com/authorize?client_id=clientId1&redirect_uri=https%3A%2F%2Fwww.example.com%2Fgadgets%2Foauth2callback&response_type=code&scope=testScope&state=574006657",
+            result);
+  }
+
+  @Test
+  public void testGetGrantType_1() throws Exception {
+    final CodeGrantTypeHandler fixture = CodeGrantTypeHandlerTest.cgth;
+
+    final String result = fixture.getGrantType();
+
+    Assert.assertEquals("code", result);
+  }
+
+  @Test
+  public void testGetResponseType_1() throws Exception {
+    final String result = CodeGrantTypeHandler.getResponseType();
+
+    Assert.assertEquals("authorization_code", result);
+  }
+
+  @Test
+  public void testIsAuthorizationEndpointResponse_1() throws Exception {
+    final CodeGrantTypeHandler fixture = CodeGrantTypeHandlerTest.cgth;
+
+    final boolean result = fixture.isAuthorizationEndpointResponse();
+
+    Assert.assertEquals(true, result);
+  }
+
+  @Test
+  public void testIsRedirectRequired_1() throws Exception {
+    final CodeGrantTypeHandler fixture = CodeGrantTypeHandlerTest.cgth;
+
+    final boolean result = fixture.isRedirectRequired();
+
+    Assert.assertEquals(true, result);
+  }
+
+  @Test
+  public void testIsTokenEndpointResponse_1() throws Exception {
+    final CodeGrantTypeHandler fixture = CodeGrantTypeHandlerTest.cgth;
+
+    final boolean result = fixture.isTokenEndpointResponse();
+
+    Assert.assertEquals(false, result);
+  }
+}
\ No newline at end of file

Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/MacTokenHandlerTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/MacTokenHandlerTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/MacTokenHandlerTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/MacTokenHandlerTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,125 @@
+/*
+ * 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.handler;
+
+import java.net.URI;
+
+import org.apache.shindig.common.uri.Uri;
+import org.apache.shindig.gadgets.http.HttpRequest;
+import org.apache.shindig.gadgets.oauth2.MockUtils;
+import org.apache.shindig.gadgets.oauth2.OAuth2Accessor;
+import org.apache.shindig.gadgets.oauth2.OAuth2Error;
+import org.apache.shindig.gadgets.oauth2.OAuth2Message;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MacTokenHandlerTest extends MockUtils {
+  @Test
+  public void testMacTokenHandler_1() throws Exception {
+
+    final MacTokenHandler result = new MacTokenHandler();
+
+    Assert.assertNotNull(result);
+    Assert.assertTrue(ResourceRequestHandler.class.isInstance(result));
+    Assert.assertEquals(OAuth2Message.MAC_TOKEN_TYPE, result.getTokenType());
+  }
+
+  @Test
+  public void testAddOAuth2Params_1() throws Exception {
+    final MacTokenHandler fixture = new MacTokenHandler();
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI("")));
+
+    final OAuth2HandlerError result = fixture.addOAuth2Params(accessor, request);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertEquals(OAuth2Error.MAC_TOKEN_PROBLEM, result.getError());
+    Assert.assertEquals("token type mismatch expected mac but got Bearer",
+        result.getContextMessage());
+  }
+
+  @Test
+  public void testAddOAuth2Params_2() throws Exception {
+    final MacTokenHandler fixture = new MacTokenHandler();
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_MacToken();
+    final HttpRequest request = null;
+
+    final OAuth2HandlerError result = fixture.addOAuth2Params(accessor, request);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertEquals(OAuth2Error.MAC_TOKEN_PROBLEM, result.getError());
+    Assert.assertEquals("request is null", result.getContextMessage());
+  }
+
+  @Test
+  public void testAddOAuth2Params_3() throws Exception {
+    final MacTokenHandler fixture = new MacTokenHandler();
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error();
+    final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI("")));
+
+    final OAuth2HandlerError result = fixture.addOAuth2Params(accessor, request);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertEquals(OAuth2Error.MAC_TOKEN_PROBLEM, result.getError());
+    Assert.assertTrue(result.getContextMessage().startsWith("accessor is invalid"));
+  }
+
+  @Test
+  public void testAddOAuth2Params_4() throws Exception {
+    final MacTokenHandler fixture = new MacTokenHandler();
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_BadMacToken();
+    final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI("a")));
+    request.setMethod("");
+
+    final OAuth2HandlerError result = fixture.addOAuth2Params(accessor, request);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertEquals(OAuth2Error.MAC_TOKEN_PROBLEM, result.getError());
+    Assert.assertEquals("unsupported algorithm hmac-sha-256", result.getContextMessage());
+  }
+
+  @Test
+  public void testAddOAuth2Params_5() throws Exception {
+    final MacTokenHandler fixture = new MacTokenHandler();
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_MacToken();
+    final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI(
+        "http://www.example.com:9080/xxx")));
+    request.setMethod("");
+
+    final OAuth2HandlerError result = fixture.addOAuth2Params(accessor, request);
+
+    Assert.assertNull(result);
+    final String authHeader = request.getHeader("Authorization");
+    Assert.assertNotNull(authHeader);
+    Assert.assertTrue(authHeader.startsWith("MAC id = \"accessSecret\",nonce="));
+  }
+
+  @Test
+  public void testGetTokenType_1() throws Exception {
+    final MacTokenHandler fixture = new MacTokenHandler();
+
+    final String result = fixture.getTokenType();
+
+    Assert.assertEquals(OAuth2Message.MAC_TOKEN_TYPE, result);
+  }
+}
\ No newline at end of file

Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/OAuth2HandlerErrorTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/OAuth2HandlerErrorTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/OAuth2HandlerErrorTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/OAuth2HandlerErrorTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,94 @@
+/*
+ * 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.handler;
+
+import org.apache.shindig.gadgets.oauth2.OAuth2Error;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class OAuth2HandlerErrorTest {
+  @Test
+  public void testOAuth2HandlerError_1() throws Exception {
+    final OAuth2Error error = OAuth2Error.AUTHENTICATION_PROBLEM;
+    final String contextMessage = "";
+    final Exception cause = new Exception();
+
+    final OAuth2HandlerError result = new OAuth2HandlerError(error, contextMessage, cause);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals("", result.getContextMessage());
+    Assert
+        .assertEquals(
+            "org.apache.shindig.gadgets.oauth2.handler.OAuth2HandlerError : AUTHENTICATION_PROBLEM :  : java.lang.Exception",
+            result.toString());
+  }
+
+  @Test
+  public void testGetCause_1() throws Exception {
+    final OAuth2HandlerError fixture = new OAuth2HandlerError(OAuth2Error.AUTHENTICATION_PROBLEM,
+        "", new Exception());
+
+    final Exception result = fixture.getCause();
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(null, result.getMessage());
+    Assert.assertEquals(null, result.getLocalizedMessage());
+    Assert.assertEquals("java.lang.Exception", result.toString());
+    Assert.assertEquals(null, result.getCause());
+  }
+
+  @Test
+  public void testGetContextMessage_1() throws Exception {
+    final OAuth2HandlerError fixture = new OAuth2HandlerError(OAuth2Error.AUTHENTICATION_PROBLEM,
+        "", new Exception());
+
+    final String result = fixture.getContextMessage();
+
+    Assert.assertEquals("", result);
+  }
+
+  @Test
+  public void testGetError_1() throws Exception {
+    final OAuth2HandlerError fixture = new OAuth2HandlerError(OAuth2Error.AUTHENTICATION_PROBLEM,
+        "", new Exception());
+
+    final OAuth2Error result = fixture.getError();
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals("authentication_problem", result.getErrorCode());
+    Assert.assertEquals("Could not add authentication headers to the request.",
+        result.getErrorExplanation());
+    Assert.assertEquals("AUTHENTICATION_PROBLEM", result.name());
+    Assert.assertEquals(2, result.ordinal());
+    Assert.assertEquals("AUTHENTICATION_PROBLEM", result.toString());
+  }
+
+  @Test
+  public void testToString_1() throws Exception {
+    final OAuth2HandlerError fixture = new OAuth2HandlerError(OAuth2Error.AUTHENTICATION_PROBLEM,
+        "", new Exception());
+
+    final String result = fixture.toString();
+
+    Assert
+        .assertEquals(
+            "org.apache.shindig.gadgets.oauth2.handler.OAuth2HandlerError : AUTHENTICATION_PROBLEM :  : java.lang.Exception",
+            result);
+  }
+}
\ No newline at end of file

Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/OAuth2HandlerModuleTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/OAuth2HandlerModuleTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/OAuth2HandlerModuleTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/OAuth2HandlerModuleTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,114 @@
+/*
+ * 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.handler;
+
+import java.util.List;
+
+import org.apache.shindig.gadgets.http.HttpFetcher;
+import org.apache.shindig.gadgets.oauth2.OAuth2Store;
+import org.easymock.EasyMock;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provider;
+
+public class OAuth2HandlerModuleTest {
+  @Test
+  public void testConfigure_1() throws Exception {
+    final OAuth2HandlerModule fixture = new OAuth2HandlerModule();
+
+    Assert.assertTrue(AbstractModule.class.isInstance(fixture));
+  }
+
+  @Test
+  @SuppressWarnings({ "unchecked", "unused" })
+  public void testProvideAuthorizationEndpointResponseHandlers_1() throws Exception {
+    final OAuth2HandlerModule fixture = new OAuth2HandlerModule();
+    final CodeAuthorizationResponseHandler codeAuthorizationResponseHandler = new CodeAuthorizationResponseHandler(
+        EasyMock.createNiceMock(Provider.class), EasyMock.createNiceMock(List.class),
+        EasyMock.createNiceMock(List.class), EasyMock.createNiceMock(HttpFetcher.class));
+    final TokenAuthorizationResponseHandler tokenAuthorizationResponseHandler = new TokenAuthorizationResponseHandler(
+        EasyMock.createNiceMock(Provider.class), EasyMock.createNiceMock(OAuth2Store.class));
+
+    final List<AuthorizationEndpointResponseHandler> result = OAuth2HandlerModule
+        .provideAuthorizationEndpointResponseHandlers(codeAuthorizationResponseHandler);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(1, result.size());
+  }
+
+  @SuppressWarnings("unused")
+  @Test
+  public void testProvideClientAuthenticationHandlers_1() throws Exception {
+    final OAuth2HandlerModule fixture = new OAuth2HandlerModule();
+    final BasicAuthenticationHandler basicAuthenticationHandler = new BasicAuthenticationHandler();
+    final StandardAuthenticationHandler standardAuthenticationHandler = new StandardAuthenticationHandler();
+
+    final List<ClientAuthenticationHandler> result = OAuth2HandlerModule
+        .provideClientAuthenticationHandlers(basicAuthenticationHandler,
+            standardAuthenticationHandler);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(2, result.size());
+  }
+
+  @Test
+  @SuppressWarnings({ "unchecked", "unused" })
+  public void testProvideGrantRequestHandlers_1() throws Exception {
+    final OAuth2HandlerModule fixture = new OAuth2HandlerModule();
+    final ClientCredentialsGrantTypeHandler clientCredentialsGrantTypeHandler = new ClientCredentialsGrantTypeHandler(
+        EasyMock.createNiceMock(List.class));
+    final CodeGrantTypeHandler codeGrantTypeHandler = new CodeGrantTypeHandler();
+
+    final List<GrantRequestHandler> result = OAuth2HandlerModule.provideGrantRequestHandlers(
+        clientCredentialsGrantTypeHandler, codeGrantTypeHandler);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(2, result.size());
+  }
+
+  @Test
+  @SuppressWarnings({ "unchecked", "unused" })
+  public void testProvideTokenEndpointResponseHandlers_1() throws Exception {
+    final OAuth2HandlerModule fixture = new OAuth2HandlerModule();
+    final TokenAuthorizationResponseHandler tokenAuthorizationResponseHandler = new TokenAuthorizationResponseHandler(
+        EasyMock.createNiceMock(Provider.class), EasyMock.createNiceMock(OAuth2Store.class));
+
+    final List<TokenEndpointResponseHandler> result = OAuth2HandlerModule
+        .provideTokenEndpointResponseHandlers(tokenAuthorizationResponseHandler);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(1, result.size());
+  }
+
+  @SuppressWarnings("unused")
+  @Test
+  public void testProvideTokenHandlers_1() throws Exception {
+    final OAuth2HandlerModule fixture = new OAuth2HandlerModule();
+    final BearerTokenHandler bearerTokenHandler = new BearerTokenHandler();
+    final MacTokenHandler macTokenHandler = new MacTokenHandler();
+
+    final List<ResourceRequestHandler> result = OAuth2HandlerModule.provideTokenHandlers(
+        bearerTokenHandler, macTokenHandler);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(2, result.size());
+  }
+}
\ No newline at end of file

Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/StandardAuthenticationHandlerTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/StandardAuthenticationHandlerTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/StandardAuthenticationHandlerTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/StandardAuthenticationHandlerTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,123 @@
+/*
+ * 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.handler;
+
+import java.net.URI;
+
+import org.apache.shindig.common.uri.Uri;
+import org.apache.shindig.gadgets.http.HttpRequest;
+import org.apache.shindig.gadgets.oauth2.MockUtils;
+import org.apache.shindig.gadgets.oauth2.OAuth2Accessor;
+import org.apache.shindig.gadgets.oauth2.OAuth2Error;
+import org.apache.shindig.gadgets.oauth2.OAuth2Message;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class StandardAuthenticationHandlerTest extends MockUtils {
+  @Test
+  public void testStandardAuthenticationHandler_1() throws Exception {
+    final StandardAuthenticationHandler result = new StandardAuthenticationHandler();
+
+    Assert.assertNotNull(result);
+    Assert.assertTrue(ClientAuthenticationHandler.class.isInstance(result));
+    Assert.assertEquals(OAuth2Message.STANDARD_AUTH_TYPE, result.geClientAuthenticationType());
+
+  }
+
+  @Test
+  public void testAddOAuth2Authentication_1() throws Exception {
+    final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler();
+    final HttpRequest request = null;
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_StandardAuth();
+
+    final OAuth2HandlerError result = fixture.addOAuth2Authentication(request, accessor);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertEquals(OAuth2Error.AUTHENTICATION_PROBLEM, result.getError());
+    Assert.assertEquals("request is null", result.getContextMessage());
+  }
+
+  @Test
+  public void testAddOAuth2Authentication_2() throws Exception {
+    final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler();
+    final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI("")));
+    final OAuth2Accessor accessor = null;
+
+    final OAuth2HandlerError result = fixture.addOAuth2Authentication(request, accessor);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(OAuth2Error.AUTHENTICATION_PROBLEM, result.getError());
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertEquals("accessor is null", result.getContextMessage());
+  }
+
+  @Test
+  public void testAddOAuth2Authentication_3() throws Exception {
+    final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler();
+    final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI("")));
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error();
+
+    final OAuth2HandlerError result = fixture.addOAuth2Authentication(request, accessor);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(OAuth2Error.AUTHENTICATION_PROBLEM, result.getError());
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertEquals("accessor is invalid", result.getContextMessage());
+  }
+
+  @Test
+  public void testAddOAuth2Authentication_4() throws Exception {
+    final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler();
+    final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI("")));
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_StandardAuth();
+
+    final OAuth2HandlerError result = fixture.addOAuth2Authentication(request, accessor);
+
+    Assert.assertNull(result);
+    final String header1 = request.getHeader(OAuth2Message.CLIENT_ID);
+    Assert.assertNotNull(header1);
+    Assert.assertEquals(MockUtils.CLIENT_ID1, header1);
+
+    final String header2 = request.getHeader(OAuth2Message.CLIENT_SECRET);
+    Assert.assertNotNull(header2);
+    Assert.assertEquals(MockUtils.CLIENT_SECRET1, header2);
+
+    final String requestUri = request.getUri().toString();
+    Assert.assertNotNull(requestUri);
+    Assert.assertEquals("", requestUri);
+
+    final String param1 = request.getParam(OAuth2Message.CLIENT_ID);
+    Assert.assertNotNull(param1);
+    Assert.assertEquals(MockUtils.CLIENT_ID1, param1);
+
+    final String param2 = request.getHeader(OAuth2Message.CLIENT_SECRET);
+    Assert.assertNotNull(param2);
+    Assert.assertEquals(MockUtils.CLIENT_SECRET1, param2);
+  }
+
+  @Test
+  public void testGeClientAuthenticationType_1() throws Exception {
+    final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler();
+
+    final String result = fixture.geClientAuthenticationType();
+
+    Assert.assertEquals("STANDARD", result);
+  }
+}
\ No newline at end of file

Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/TokenAuthorizationResponseHandlerTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/TokenAuthorizationResponseHandlerTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/TokenAuthorizationResponseHandlerTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/handler/TokenAuthorizationResponseHandlerTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,203 @@
+/*
+ * 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.handler;
+
+import org.apache.shindig.gadgets.http.HttpResponse;
+import org.apache.shindig.gadgets.http.HttpResponseBuilder;
+import org.apache.shindig.gadgets.oauth2.MockUtils;
+import org.apache.shindig.gadgets.oauth2.OAuth2Accessor;
+import org.apache.shindig.gadgets.oauth2.OAuth2Error;
+import org.apache.shindig.gadgets.oauth2.OAuth2Message;
+import org.apache.shindig.gadgets.oauth2.OAuth2Store;
+import org.apache.shindig.gadgets.oauth2.OAuth2Token;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.inject.Provider;
+
+public class TokenAuthorizationResponseHandlerTest extends MockUtils {
+  private static TokenAuthorizationResponseHandler tarh;
+  private static OAuth2Store store;
+
+  @Before
+  public void setUp() throws Exception {
+    final Provider<OAuth2Message> oauth2MessageProvider = MockUtils.getDummyMessageProvider();
+    TokenAuthorizationResponseHandlerTest.store = MockUtils.getDummyStore();
+
+    TokenAuthorizationResponseHandlerTest.tarh = new TokenAuthorizationResponseHandler(
+        oauth2MessageProvider, TokenAuthorizationResponseHandlerTest.store);
+  }
+
+  @Test
+  public void testTokenAuthorizationResponseHandler_1() throws Exception {
+    Assert.assertNotNull(TokenAuthorizationResponseHandlerTest.tarh);
+    Assert.assertTrue(TokenEndpointResponseHandler.class
+        .isInstance(TokenAuthorizationResponseHandlerTest.tarh));
+  }
+
+  @Test
+  public void testHandlesResponse_1() throws Exception {
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error();
+    final HttpResponse response = new HttpResponse();
+
+    final boolean result = TokenAuthorizationResponseHandlerTest.tarh.handlesResponse(accessor,
+        response);
+    Assert.assertFalse(result);
+  }
+
+  @Test
+  public void testHandlesResponse_2() throws Exception {
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final HttpResponse response = null;
+
+    final boolean result = TokenAuthorizationResponseHandlerTest.tarh.handlesResponse(accessor,
+        response);
+    Assert.assertFalse(result);
+  }
+
+  @Test
+  public void testHandlesResponse_3() throws Exception {
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final HttpResponse response = new HttpResponse();
+
+    final boolean result = TokenAuthorizationResponseHandlerTest.tarh.handlesResponse(accessor,
+        response);
+    Assert.assertTrue(result);
+  }
+
+  @Test
+  public void testHandleResponse_1() throws Exception {
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error();
+    final HttpResponse response = new HttpResponse();
+
+    final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
+        accessor, response);
+    Assert.assertNotNull(result);
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertEquals(OAuth2Error.TOKEN_RESPONSE_PROBLEM, result.getError());
+    Assert.assertTrue(result.getContextMessage().startsWith("accessor is invalid"));
+  }
+
+  @Test
+  public void testHandleResponse_2() throws Exception {
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final HttpResponse response = null;
+
+    final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
+        accessor, response);
+    Assert.assertNotNull(result);
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertEquals(OAuth2Error.TOKEN_RESPONSE_PROBLEM, result.getError());
+    Assert.assertEquals("response is null", result.getContextMessage());
+  }
+
+  @Test
+  public void testHandleResponse_3() throws Exception {
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final HttpResponseBuilder builder = new HttpResponseBuilder().setStrictNoCache();
+    builder.setHttpStatusCode(HttpResponse.SC_FORBIDDEN);
+    final HttpResponse response = builder.create();
+
+    final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
+        accessor, response);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertEquals(OAuth2Error.TOKEN_RESPONSE_PROBLEM, result.getError());
+    Assert.assertTrue(result.getContextMessage().startsWith("can't handle error response"));
+  }
+
+  @Test
+  public void testHandleResponse_4() throws Exception {
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final HttpResponseBuilder builder = new HttpResponseBuilder().setStrictNoCache();
+    builder.setHttpStatusCode(HttpResponse.SC_OK);
+    builder.setHeader("Content-Type", "text/plain");
+    builder
+        .setContent("access_token=xxx&token_type=Bearer&expires=1&refresh_token=yyy&example_parameter=example_value");
+    final HttpResponse response = builder.create();
+
+    final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
+        accessor, response);
+
+    Assert.assertNull(result);
+
+    final OAuth2Token accessToken = TokenAuthorizationResponseHandlerTest.store.getToken(
+        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
+        accessor.getScope(), OAuth2Token.Type.ACCESS);
+    Assert.assertNotNull(accessToken);
+    Assert.assertEquals("xxx", new String(accessToken.getSecret(), "UTF-8"));
+    Assert.assertEquals(OAuth2Message.BEARER_TOKEN_TYPE, accessToken.getTokenType());
+    Assert.assertTrue(accessToken.getExpiresAt() > 1000);
+
+    final OAuth2Token refreshToken = TokenAuthorizationResponseHandlerTest.store.getToken(
+        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
+        accessor.getScope(), OAuth2Token.Type.REFRESH);
+    Assert.assertNotNull(refreshToken);
+    Assert.assertEquals("yyy", new String(refreshToken.getSecret(), "UTF-8"));
+  }
+
+  @Test
+  public void testHandleResponse_5() throws Exception {
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final HttpResponseBuilder builder = new HttpResponseBuilder().setStrictNoCache();
+    builder.setHttpStatusCode(HttpResponse.SC_OK);
+    builder.setHeader("Content-Type", "application/json");
+    builder
+        .setContent("{\"access_token\"=\"xxx\",\"token_type\"=\"Bearer\",\"expires_in\"=\"1\",\"refresh_token\"=\"yyy\",\"example_parameter\"=\"example_value\"}");
+    final HttpResponse response = builder.create();
+
+    final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
+        accessor, response);
+
+    Assert.assertNull(result);
+
+    final OAuth2Token accessToken = TokenAuthorizationResponseHandlerTest.store.getToken(
+        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
+        accessor.getScope(), OAuth2Token.Type.ACCESS);
+    Assert.assertNotNull(accessToken);
+    Assert.assertEquals("xxx", new String(accessToken.getSecret(), "UTF-8"));
+    Assert.assertEquals(OAuth2Message.BEARER_TOKEN_TYPE, accessToken.getTokenType());
+    Assert.assertTrue(accessToken.getExpiresAt() > 1000);
+
+    final OAuth2Token refreshToken = TokenAuthorizationResponseHandlerTest.store.getToken(
+        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
+        accessor.getScope(), OAuth2Token.Type.REFRESH);
+    Assert.assertNotNull(refreshToken);
+    Assert.assertEquals("yyy", new String(refreshToken.getSecret(), "UTF-8"));
+  }
+
+  @Test
+  public void testHandleResponse_6() throws Exception {
+    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
+    final HttpResponseBuilder builder = new HttpResponseBuilder().setStrictNoCache();
+    builder.setHttpStatusCode(HttpResponse.SC_OK);
+    builder.setHeader("Content-Type", "BAD");
+    final HttpResponse response = builder.create();
+
+    final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
+        accessor, response);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(null, result.getCause());
+    Assert.assertEquals(OAuth2Error.TOKEN_RESPONSE_PROBLEM, result.getError());
+    Assert.assertTrue(result.getContextMessage().startsWith("Unhandled Content-Type"));
+  }
+}
\ No newline at end of file

Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/logger/FilteredLoggerTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/logger/FilteredLoggerTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/logger/FilteredLoggerTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/logger/FilteredLoggerTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,243 @@
+/*
+ * 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.logger;
+
+import java.util.ResourceBundle;
+import java.util.logging.Level;
+
+import org.apache.shindig.gadgets.oauth2.OAuth2Error;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FilteredLoggerTest {
+  @Test
+  public void testFilteredLogger_1() throws Exception {
+    final String className = "";
+
+    final FilteredLogger result = new FilteredLogger(className);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(false, result.isLoggable());
+  }
+
+  @Test
+  public void testEntering_1() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+    final String sourceClass = "";
+    final String sourceMethod = "";
+
+    fixture.entering(sourceClass, sourceMethod);
+  }
+
+  @Test
+  public void testEntering_2() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+    final String sourceClass = "";
+    final String sourceMethod = "";
+    final Object param = new Object();
+
+    fixture.entering(sourceClass, sourceMethod, param);
+  }
+
+  @Test
+  public void testEntering_3() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+    final String sourceClass = "";
+    final String sourceMethod = "";
+    final Object[] params = new Object[] {};
+
+    fixture.entering(sourceClass, sourceMethod, params);
+  }
+
+  @Test
+  public void testExiting_1() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+    final String sourceClass = "";
+    final String sourceMethod = "";
+
+    fixture.exiting(sourceClass, sourceMethod);
+  }
+
+  @Test
+  public void testExiting_2() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+    final String sourceClass = "";
+    final String sourceMethod = "";
+    final Object result = new Object();
+
+    fixture.exiting(sourceClass, sourceMethod, result);
+  }
+
+  @Test
+  public void testFilterSecrets_1() throws Exception {
+    final String in = "a";
+
+    final String result = FilteredLogger.filterSecrets(in);
+
+    Assert.assertEquals("a", result);
+  }
+
+  @Test
+  public void testFilterSecrets_2() throws Exception {
+    final String in = null;
+
+    final String result = FilteredLogger.filterSecrets(in);
+
+    Assert.assertEquals("", result);
+  }
+
+  @Test
+  public void testFilterSecrets_3() throws Exception {
+    final String in = "";
+
+    final String result = FilteredLogger.filterSecrets(in);
+
+    Assert.assertEquals("", result);
+  }
+
+  @Test
+  public void testFilterSecrets_4() throws Exception {
+    final String in = "?access_token=XXX";
+
+    final String result = FilteredLogger.filterSecrets(in);
+
+    Assert.assertEquals("?access_token=REMOVED", result);
+  }
+
+  @Test
+  public void testFilterSecrets_5() throws Exception {
+    final String in = "Authorization: XXX";
+
+    final String result = FilteredLogger.filterSecrets(in);
+
+    Assert.assertEquals("REMOVED", result);
+  }
+
+  @Test
+  public void testGetFilteredLogger_1() throws Exception {
+    final String className = "";
+
+    final FilteredLogger result = FilteredLogger.getFilteredLogger(className);
+
+    Assert.assertNotNull(result);
+    Assert.assertEquals(false, result.isLoggable());
+  }
+
+  @Test
+  public void testGetResourceBundle_1() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+
+    final ResourceBundle result = fixture.getResourceBundle();
+
+    Assert.assertNotNull(result);
+    final String description = result.getString(OAuth2Error.FETCH_PROBLEM.getErrorCode());
+    Assert.assertEquals("executing OAuth2Request.fetch() : {0}", description);
+
+    Assert.assertNotNull(result);
+    final String explanation = result.getString(OAuth2Error.FETCH_PROBLEM.getErrorCode()
+        + ".explanation");
+    Assert.assertEquals("An error occurred issuing the OAuth2 request.", explanation);
+  }
+
+  @Test
+  public void testIsLoggable_1() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+
+    final boolean result = fixture.isLoggable();
+
+    Assert.assertEquals(false, result);
+  }
+
+  @Test
+  public void testIsLoggable_2() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+
+    final boolean result = fixture.isLoggable();
+
+    Assert.assertEquals(false, result);
+  }
+
+  @Test
+  public void testIsLoggable_3() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+    final Level logLevel = Level.FINE;
+
+    final boolean result = fixture.isLoggable(logLevel);
+
+    Assert.assertFalse(result);
+  }
+
+  @Test
+  public void testLog_1() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+    final String msg = "";
+    final Object param = new Object();
+
+    fixture.log(msg, param);
+  }
+
+  @Test
+  public void testLog_2() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+    final String msg = "";
+    final Throwable thrown = new Throwable();
+
+    fixture.log(msg, thrown);
+
+  }
+
+  @Test
+  public void testLog_3() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+    final String msg = "";
+    final Object[] params = new Object[] {};
+
+    fixture.log(msg, params);
+  }
+
+  @Test
+  public void testLog_4() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+    final Level logLevel = Level.FINE;
+    final String msg = "";
+    final Object param = new Object();
+
+    fixture.log(logLevel, msg, param);
+  }
+
+  @Test
+  public void testLog_5() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+    final Level logLevel = Level.FINE;
+    final String msg = "";
+    final Throwable thrown = new Throwable();
+
+    fixture.log(logLevel, msg, thrown);
+  }
+
+  @Test
+  public void testLog_6() throws Exception {
+    final FilteredLogger fixture = FilteredLogger.getFilteredLogger("");
+    final Level logLevel = Level.FINE;
+    final String msg = "";
+    final Object[] params = new Object[] {};
+
+    fixture.log(logLevel, msg, params);
+  }
+}
\ No newline at end of file

Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2CacheExceptionTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2CacheExceptionTest.java?rev=1182565&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2CacheExceptionTest.java (added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/persistence/OAuth2CacheExceptionTest.java Wed Oct 12 20:10:39 2011
@@ -0,0 +1,38 @@
+/*
+ * 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 OAuth2CacheExceptionTest {
+  @Test
+  public void testOAuth2CacheException_1() throws Exception {
+    final Exception cause = new Exception();
+
+    final OAuth2CacheException result = new OAuth2CacheException(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.OAuth2CacheException: java.lang.Exception",
+        result.toString());
+  }
+}
\ No newline at end of file