[NO ISSUE][TEST] On unexpected non-JSON result, throw exception with content (if any)

Change-Id: Iaa2be7b877cb6ea1230c4d084438ca44ee51d86f
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/10685
Reviewed-by: Michael Blow <mblow@apache.org>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Tested-by: Michael Blow <mblow@apache.org>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/ResultExtractor.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/ResultExtractor.java
index 3895ec8..5ab5b01 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/ResultExtractor.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/ResultExtractor.java
@@ -28,9 +28,11 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.asterix.common.config.GlobalConfig;
 import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.testframework.context.TestCaseContext.OutputFormat;
 import org.apache.commons.io.IOUtils;
+import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -203,7 +205,15 @@
 
         LOGGER.debug("+++++++\n" + resultStr + "\n+++++++\n");
 
-        final ObjectNode result = OBJECT_READER.readValue(resultStr);
+        final ObjectNode result;
+        try {
+            result = OBJECT_READER.readValue(resultStr);
+        } catch (Exception e) {
+            // whoops, not JSON (e.g. 404) - just include the body
+            GlobalConfig.ASTERIX_LOGGER.log(Level.ERROR, resultStr);
+            throw new Exception(resultStr);
+        }
+
         final boolean isJsonFormat = isJsonFormat(fmt);
 
         // if we have errors field in the results, we will always return it