Fixed bug / refined GraphApiErrorResponseErrorHandler
[facebook-errors] / src / test / java / de / juplo / facebook / errors / GraphApiErrorResponseErrorHandlerIntegrationTest.java
index 6593375..55025e7 100644 (file)
@@ -10,6 +10,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.http.HttpStatus;
 import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.HttpServerErrorException;
 import org.springframework.web.client.RestTemplate;
 
 
@@ -32,13 +33,7 @@ public class GraphApiErrorResponseErrorHandlerIntegrationTest
   {
     LOG.info("testNoError");
 
-    requestFactory.setBody("{\n" +
-        "  \"error\": {\n" +
-        "    \"message\": \"(#200) The user hasn't authorized the application to perform this action\",\n" +
-        "    \"type\": \"OAuthException\",\n" +
-        "    \"code\": 200\n" +
-        "  }\n" +
-        "}");
+    requestFactory.setBody("{ \"message\": \"Hello World!\" }");
 
 
     requestFactory.setStatus(HttpStatus.CONTINUE);
@@ -74,10 +69,31 @@ public class GraphApiErrorResponseErrorHandlerIntegrationTest
       fail("Unexpected error: " + e);
     }
 
+    requestFactory.setStatus(HttpStatus.BAD_REQUEST);
+    try
+    {
+      clientTemplate.getForObject("ANY", SOME.class);
+      fail("The parent handler should have raised an exception!");
+    }
+    catch(HttpClientErrorException e)
+    {
+      LOG.debug("Expexted error: {}", e.toString());
+    }
+    catch(Exception e)
+    {
+      LOG.debug("{}", e.toString());
+      fail("Unexpected error: " + e);
+    }
+
     requestFactory.setStatus(HttpStatus.INTERNAL_SERVER_ERROR);
     try
     {
       clientTemplate.getForObject("ANY", SOME.class);
+      fail("The parent handler should have raised an exception!");
+    }
+    catch(HttpServerErrorException e)
+    {
+      LOG.debug("Expexted error: {}", e.toString());
     }
     catch(Exception e)
     {