@Test public void testNextFetchThrowsRuntimeException() throws Exception { serviceProvider.setThrow(new RuntimeException("very, very wrong")); MakeRequestClient client = makeNonSocialClient("owner", "owner", GADGET_URL); try { client.sendGet(FakeOAuthServiceProvider.ACCESS_TOKEN_URL); fail("Should have thrown"); } catch (RuntimeException e) { // good } //checkLogContains("OAuth fetch unexpected fatal erro"); checkLogContains("GET /request?param=foo&opensocial_owner_id=owner"); checkLogContains("OAuth error [very, very wrong] for " + "application http://www.example.com/gadget.xml"); checkLogContains("RuntimeException"); checkLogContains("very, very wrong"); }
@Test public void testNextFetchThrowsRuntimeException() throws Exception { serviceProvider.setThrow(new RuntimeException("very, very wrong")); MakeRequestClient client = makeNonSocialClient("owner", "owner", GADGET_URL); try { client.sendGet(FakeOAuthServiceProvider.ACCESS_TOKEN_URL); fail("Should have thrown"); } catch (RuntimeException e) { // good } //checkLogContains("OAuth fetch unexpected fatal erro"); checkLogContains("GET /request?param=foo&opensocial_owner_id=owner"); checkLogContains("OAuth error [very, very wrong] for " + "application http://www.example.com/gadget.xml"); checkLogContains("RuntimeException"); checkLogContains("very, very wrong"); }
@Test public void testNextFetchThrowsRuntimeException() throws Exception { serviceProvider.setThrow(new RuntimeException("very, very wrong")); MakeRequestClient client = makeNonSocialClient("owner", "owner", GADGET_URL); try { client.sendGet(FakeOAuthServiceProvider.ACCESS_TOKEN_URL); fail("Should have thrown"); } catch (RuntimeException e) { // good } checkLogContains("OAuth fetch unexpected fatal erro"); checkLogContains("GET /request?param=foo&opensocial_owner_id=owner"); checkLogContains("OAuth error [very, very wrong] for " + "application http://www.example.com/gadget.xml"); checkLogContains("RuntimeException"); checkLogContains("very, very wrong"); }
@Test public void testNextFetchThrowsGadgetException() throws Exception { serviceProvider.setThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, "mildly wrong")); MakeRequestClient client = makeNonSocialClient("owner", "owner", GADGET_URL); HttpResponse response = client.sendGet(FakeOAuthServiceProvider.ACCESS_TOKEN_URL); assertEquals("MISSING_SERVER_RESPONSE", response.getMetadata().get("oauthError")); assertEquals("", response.getResponseAsString()); String oauthErrorText = response.getMetadata().get("oauthErrorText"); checkStringContains("should say no response", oauthErrorText, "No response from server"); checkStringContains("should show request", oauthErrorText, "GET /request?param=foo&opensocial_owner_id=owner"); checkStringContains("should log empty response", oauthErrorText, "Received response 1:\n\n"); checkLogContains("No response from server"); checkLogContains("GET /request?param=foo&opensocial_owner_id=owner"); checkLogContains("OAuth error [MISSING_SERVER_RESPONSE, No response from server] for " + "application http://www.example.com/gadget.xml"); checkLogContains("GadgetException"); checkLogContains("mildly wrong"); }
@Test public void testNextFetchThrowsGadgetException() throws Exception { serviceProvider.setThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, "mildly wrong")); MakeRequestClient client = makeNonSocialClient("owner", "owner", GADGET_URL); HttpResponse response = client.sendGet(FakeOAuthServiceProvider.ACCESS_TOKEN_URL); assertEquals("MISSING_SERVER_RESPONSE", response.getMetadata().get("oauthError")); assertEquals("", response.getResponseAsString()); String oauthErrorText = response.getMetadata().get("oauthErrorText"); checkStringContains("should say no response", oauthErrorText, "No response from server"); checkStringContains("should show request", oauthErrorText, "GET /request?param=foo&opensocial_owner_id=owner"); checkStringContains("should log empty response", oauthErrorText, "Received response 1:\n\n"); checkLogContains("No response from server"); checkLogContains("GET /request?param=foo&opensocial_owner_id=owner"); checkLogContains("OAuth error [MISSING_SERVER_RESPONSE, No response from server] for " + "application http://www.example.com/gadget.xml"); checkLogContains("GadgetException"); checkLogContains("mildly wrong"); }
@Test public void testNextFetchThrowsGadgetException() throws Exception { serviceProvider.setThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, "mildly wrong")); MakeRequestClient client = makeNonSocialClient("owner", "owner", GADGET_URL); HttpResponse response = client.sendGet(FakeOAuthServiceProvider.ACCESS_TOKEN_URL); assertEquals("MISSING_SERVER_RESPONSE", response.getMetadata().get("oauthError")); assertEquals("", response.getResponseAsString()); String oauthErrorText = response.getMetadata().get("oauthErrorText"); checkStringContains("should say no response", oauthErrorText, "No response from server"); checkStringContains("should show request", oauthErrorText, "GET /request?param=foo&opensocial_owner_id=owner"); checkStringContains("should log empty response", oauthErrorText, "Received response 1:\n\n"); checkLogContains("No response from server"); checkLogContains("GET /request?param=foo&opensocial_owner_id=owner"); checkLogContains("OAuth error [MISSING_SERVER_RESPONSE, No response from server] for " + "application http://www.example.com/gadget.xml"); checkLogContains("GadgetException"); checkLogContains("mildly wrong"); }