@Test
public void testDoGetWithOAuth2() throws Exception {
Map<String, String> options = new HashMap<String, String>();
options.put("OAUTH_SERVICE_NAME", "example");
ProxyUriManager.ProxyUri proxyUri = new ProxyUri(-1, false, true, "default", "http://example.org/gadget.xml", REQUEST_URL);
proxyUri.setAuthType(AuthType.OAUTH2);
Uri uri = Uri.parse(BASIC_SYNTAX_URL + "&authz=oauth2&OAUTH_SERVICE_NAME=example&container=default&gadget=http://example.org/gadget.xml");
expect(proxyUriManager.process(uri)).andReturn(proxyUri);
expect(request.getScheme()).andReturn(uri.getScheme());
expect(request.getServerName()).andReturn(uri.getAuthority());
expect(request.getServerPort()).andReturn(80);
expect(request.getRequestURI()).andReturn(uri.getPath());
expect(request.getQueryString()).andReturn(uri.getQuery());
expect(request.getHeader("Host")).andReturn(uri.getAuthority());
expect(request.getParameter("OAUTH_SERVICE_NAME")).andReturn("example");
expect(request.getParameterNames()).andReturn(Collections.enumeration(options.keySet()));
expect(lockedDomainService.isSafeForOpenProxy(uri.getAuthority())).andReturn(true);
ProxyUriManager.ProxyUri pUri = new ProxyUri(-1, false, true, "default", "http://example.org/gadget.xml", REQUEST_URL);
pUri.setAuthType(AuthType.OAUTH2);
pUri.setOAuth2Arguments(new OAuth2Arguments(AuthType.OAUTH2, options));
expect(proxyHandler.fetch(pUri)).andReturn(new HttpResponse(RESPONSE_BODY));
replay();
servlet.doGet(request, recorder);
verify();