You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by de...@apache.org on 2016/02/03 13:11:06 UTC

[46/51] [abbrv] lens git commit: LENS-920 : Fix issues in producing and consuming json for all api

http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-server/src/test/java/org/apache/lens/server/query/QueryAPIErrorResponseTest.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/QueryAPIErrorResponseTest.java b/lens-server/src/test/java/org/apache/lens/server/query/QueryAPIErrorResponseTest.java
index 6f8886c..30f7aff 100644
--- a/lens-server/src/test/java/org/apache/lens/server/query/QueryAPIErrorResponseTest.java
+++ b/lens-server/src/test/java/org/apache/lens/server/query/QueryAPIErrorResponseTest.java
@@ -31,6 +31,7 @@ import static org.testng.Assert.assertTrue;
 
 import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.xml.datatype.DatatypeConfigurationException;
 
@@ -41,6 +42,7 @@ import org.apache.lens.api.metastore.*;
 import org.apache.lens.api.query.SupportedQuerySubmitOperations;
 import org.apache.lens.api.result.LensAPIResult;
 import org.apache.lens.api.result.LensErrorTO;
+import org.apache.lens.api.util.MoxyJsonConfigurationContextResolver;
 import org.apache.lens.cube.error.ColUnAvailableInTimeRange;
 import org.apache.lens.server.LensJerseyTest;
 import org.apache.lens.server.LensRequestContextInitFilter;
@@ -50,12 +52,10 @@ import org.apache.lens.server.error.LensJAXBValidationExceptionMapper;
 import org.apache.lens.server.metastore.MetastoreResource;
 import org.apache.lens.server.session.SessionResource;
 
-import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.media.multipart.MultiPartFeature;
+import org.glassfish.jersey.moxy.json.MoxyJsonFeature;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.TestProperties;
-import org.glassfish.jersey.test.inmemory.InMemoryTestContainerFactory;
-import org.glassfish.jersey.test.spi.TestContainerFactory;
 import org.joda.time.DateTime;
 import org.joda.time.DateTimeZone;
 import org.joda.time.format.DateTimeFormat;
@@ -91,24 +91,14 @@ public class QueryAPIErrorResponseTest extends LensJerseyTest {
 
     return new ResourceConfig(LensRequestContextInitFilter.class, SessionResource.class, MetastoreResource.class,
       QueryServiceResource.class, MultiPartFeature.class, LensExceptionMapper.class, LensJAXBContextResolver.class,
-      LensRequestContextInitFilter.class, LensJAXBValidationExceptionMapper.class);
+      LensRequestContextInitFilter.class, LensJAXBValidationExceptionMapper.class,
+      MoxyJsonConfigurationContextResolver.class, MoxyJsonFeature.class);
   }
 
-  @Override
-  protected void configureClient(ClientConfig config) {
-    config.register(MultiPartFeature.class);
-    config.register(LensJAXBContextResolver.class);
-  }
+  @Test(dataProvider = "mediaTypeData")
+  public void testErrorResponseWhenSessionIdIsAbsent(MediaType mt) {
 
-  @Override
-  protected TestContainerFactory getTestContainerFactory() {
-    return new InMemoryTestContainerFactory();
-  }
-
-  @Test
-  public void testErrorResponseWhenSessionIdIsAbsent() {
-
-    Response response = estimate(target(), Optional.<LensSessionHandle>absent(), Optional.of(MOCK_QUERY));
+    Response response = estimate(target(), Optional.<LensSessionHandle>absent(), Optional.of(MOCK_QUERY), mt);
 
     final String expectedErrMsg = "Session id not provided. Please provide a session id.";
     LensErrorTO expectedLensErrorTO = LensErrorTO.composedOf(
@@ -118,12 +108,12 @@ public class QueryAPIErrorResponseTest extends LensJerseyTest {
     expectedData.verify(response);
   }
 
-  @Test
-  public void testErrorResponseWhenQueryIsAbsent() {
+  @Test(dataProvider = "mediaTypeData")
+  public void testErrorResponseWhenQueryIsAbsent(MediaType mt) {
 
-    LensSessionHandle sessionId = openSession(target(), "foo", "bar", new LensConf());
+    LensSessionHandle sessionId = openSession(target(), "foo", "bar", new LensConf(), mt);
     Optional<String> testQuery = Optional.absent();
-    Response response = estimate(target(), Optional.of(sessionId), testQuery);
+    Response response = estimate(target(), Optional.of(sessionId), testQuery, mt);
 
     final String expectedErrMsg = "Query is not provided, or it is empty or blank. Please provide a valid query.";
     LensErrorTO expectedLensErrorTO = LensErrorTO.composedOf(
@@ -133,13 +123,13 @@ public class QueryAPIErrorResponseTest extends LensJerseyTest {
     expectedData.verify(response);
   }
 
-  @Test
-  public void testErrorResponseWhenInvalidOperationIsSubmitted() {
+  @Test(dataProvider = "mediaTypeData")
+  public void testErrorResponseWhenInvalidOperationIsSubmitted(MediaType mt) {
 
-    LensSessionHandle sessionId = openSession(target(), "foo", "bar", new LensConf());
+    LensSessionHandle sessionId = openSession(target(), "foo", "bar", new LensConf(), mt);
 
     Response response = postQuery(target(), Optional.of(sessionId), Optional.of(MOCK_QUERY),
-        Optional.of(INVALID_OPERATION));
+        Optional.of(INVALID_OPERATION), mt);
 
     final String expectedErrMsg = "Provided Operation is not supported. Supported Operations are: "
       + "[estimate, execute, explain, execute_with_timeout]";
@@ -152,17 +142,16 @@ public class QueryAPIErrorResponseTest extends LensJerseyTest {
     expectedData.verify(response);
   }
 
-  @Test
-  public void testErrorResponseWhenLensMultiCauseExceptionOccurs() {
+  @Test(dataProvider = "mediaTypeData")
+  public void testErrorResponseWhenLensMultiCauseExceptionOccurs(MediaType mt) {
 
-    LensSessionHandle sessionId = openSession(target(), "foo", "bar");
+    LensSessionHandle sessionId = openSession(target(), "foo", "bar", mt);
 
     final String testQuery = "select * from non_existing_table";
-    Response response = estimate(target(), Optional.of(sessionId), Optional.of(testQuery));
+    Response response = estimate(target(), Optional.of(sessionId), Optional.of(testQuery), mt);
 
     final String expectedErrMsg1 = "Semantic Error : Error while compiling statement: "
       + "FAILED: SemanticException [Error 10001]: Line 1:31 Table not found 'non_existing_table'";
-
     final String expectedErrMsg2 = "Semantic Error : user lacks privilege or object not found: NON_EXISTING_TABLE";
 
     LensErrorTO expectedLensErrorTO1 = LensErrorTO.composedOf(INTERNAL_SERVER_ERROR.getValue(),
@@ -174,15 +163,16 @@ public class QueryAPIErrorResponseTest extends LensJerseyTest {
     LensErrorTO responseLensErrorTO = response.readEntity(LensAPIResult.class).getLensErrorTO();
 
     assertTrue(expectedLensErrorTO1.getMessage().equals(responseLensErrorTO.getMessage())
-            || expectedLensErrorTO2.getMessage().equals(responseLensErrorTO.getMessage()));
+            || expectedLensErrorTO2.getMessage().equals(responseLensErrorTO.getMessage()),
+      "Message is " + responseLensErrorTO.getMessage());
   }
 
-  @Test
-  public void testErrorResponseWithSyntaxErrorInQuery() {
+  @Test(dataProvider = "mediaTypeData")
+  public void testErrorResponseWithSyntaxErrorInQuery(MediaType mt) {
 
-    LensSessionHandle sessionId = openSession(target(), "foo", "bar", new LensConf());
+    LensSessionHandle sessionId = openSession(target(), "foo", "bar", new LensConf(), mt);
 
-    Response response = estimate(target(), Optional.of(sessionId), Optional.of(MOCK_QUERY));
+    Response response = estimate(target(), Optional.of(sessionId), Optional.of(MOCK_QUERY), mt);
 
     final String expectedErrMsg = "Syntax Error: line 1:0 cannot recognize input near 'mock' '-' 'query'";
     LensErrorTO expectedLensErrorTO = LensErrorTO.composedOf(SYNTAX_ERROR.getLensErrorInfo().getErrorCode(),
@@ -192,8 +182,8 @@ public class QueryAPIErrorResponseTest extends LensJerseyTest {
     expectedData.verify(response);
   }
 
-  @Test
-  public void testQueryColumnWithBothStartDateAndEndDate() throws DatatypeConfigurationException {
+  @Test(dataProvider = "mediaTypeData")
+  public void testQueryColumnWithBothStartDateAndEndDate(MediaType mt) throws DatatypeConfigurationException {
 
     /* This test will have a col which has both start date and end date set */
     /* Col will be queried for a time range which does not fall in start date and end date */
@@ -208,11 +198,11 @@ public class QueryAPIErrorResponseTest extends LensJerseyTest {
       + "before Friday, January 30, 2015 11:00:00 PM UTC. Please adjust the selected time range accordingly.";
 
     testColUnAvailableInTimeRange(Optional.of(startDateOneJan2015),
-      Optional.of(endDateThirtyJan2015), queryFromOneJan2014, queryTillThreeJan2014, expectedErrMsgSuffix);
+      Optional.of(endDateThirtyJan2015), queryFromOneJan2014, queryTillThreeJan2014, expectedErrMsgSuffix, mt);
   }
 
-  @Test
-  public void testQueryColumnWithOnlyStartDate() throws DatatypeConfigurationException {
+  @Test(dataProvider = "mediaTypeData")
+  public void testQueryColumnWithOnlyStartDate(MediaType mt) throws DatatypeConfigurationException {
 
     /* This test will have a col which has only start date set */
     /* Col will be queried for a time range which is before start date */
@@ -226,11 +216,11 @@ public class QueryAPIErrorResponseTest extends LensJerseyTest {
       + "Please adjust the selected time range accordingly.";
 
     testColUnAvailableInTimeRange(Optional.of(startDateOneJan2015),
-      Optional.<DateTime>absent(), queryFromOneJan2014, queryTillThreeJan2014, expectedErrMsgSuffix);
+      Optional.<DateTime>absent(), queryFromOneJan2014, queryTillThreeJan2014, expectedErrMsgSuffix, mt);
   }
 
-  @Test
-  public void testQueryColumnWithOnlyEndDate() throws DatatypeConfigurationException {
+  @Test(dataProvider = "mediaTypeData")
+  public void testQueryColumnWithOnlyEndDate(MediaType mt) throws DatatypeConfigurationException {
 
     /* This test will have a col which has only end date set */
     /* Col will be queried for a time range which is after end date */
@@ -244,12 +234,12 @@ public class QueryAPIErrorResponseTest extends LensJerseyTest {
       + "Please adjust the selected time range accordingly.";
 
     testColUnAvailableInTimeRange(Optional.<DateTime>absent(),
-      Optional.of(endDateThirtyJan2015), queryFromOneJan2016, queryTillThreeJan2016, expectedErrMsgSuffix);
+      Optional.of(endDateThirtyJan2015), queryFromOneJan2016, queryTillThreeJan2016, expectedErrMsgSuffix, mt);
   }
 
   private void testColUnAvailableInTimeRange(@NonNull final Optional<DateTime> colStartDate,
     @NonNull final Optional<DateTime> colEndDate, @NonNull DateTime queryFrom, @NonNull DateTime queryTill,
-    @NonNull final String expectedErrorMsgSuffix) throws DatatypeConfigurationException {
+    @NonNull final String expectedErrorMsgSuffix, @NonNull final MediaType mt) throws DatatypeConfigurationException {
 
     final WebTarget target = target();
     final String testDb = getRandomDbName();
@@ -258,21 +248,21 @@ public class QueryAPIErrorResponseTest extends LensJerseyTest {
     final String testFact = getRandomFactName();
 
     /* Setup: Begin */
-    LensSessionHandle sessionId = openSession(target, "foo", "bar", new LensConf());
+    LensSessionHandle sessionId = openSession(target, "foo", "bar", new LensConf(), mt);
 
     try {
 
-      createAndSetCurrentDbFailFast(target, sessionId, testDb);
+      createAndSetCurrentDbFailFast(target, sessionId, testDb, mt);
 
       /* Create a test cube with test dimension field having a start Date and end Date */
       XDimAttribute testXDim = createXDimAttribute(testDimensionField, colStartDate, colEndDate);
       XCube xcube = createXCubeWithDummyMeasure(testCube, Optional.of("dt"), testXDim);
-      createCubeFailFast(target, sessionId, xcube);
+      createCubeFailFast(target, sessionId, xcube, mt);
 
       /* Create a fact with test dimension field */
       XColumn xColumn = createXColumn(testDimensionField);
       XFactTable xFactTable = createXFactTableWithColumns(testFact, testCube, xColumn);
-      createFactFailFast(target, sessionId, xFactTable);
+      createFactFailFast(target, sessionId, xFactTable, mt);
 
       /* Setup: End */
 
@@ -280,7 +270,7 @@ public class QueryAPIErrorResponseTest extends LensJerseyTest {
       final String testQuery = "cube select " + testDimensionField + " from " + testCube + " where TIME_RANGE_IN(dt, "
         + "\"" + dtf.print(queryFrom) + "\",\"" + dtf.print(queryTill) + "\")";
 
-      Response response = estimate(target, Optional.of(sessionId), Optional.of(testQuery));
+      Response response = estimate(target, Optional.of(sessionId), Optional.of(testQuery), mt);
 
       final String expectedErrMsg = testDimensionField + expectedErrorMsgSuffix;
 
@@ -297,8 +287,8 @@ public class QueryAPIErrorResponseTest extends LensJerseyTest {
 
       expectedData.verify(response);
     } finally {
-      dropDatabaseFailFast(target, sessionId, testDb);
-      closeSessionFailFast(target, sessionId);
+      dropDatabaseFailFast(target, sessionId, testDb, mt);
+      closeSessionFailFast(target, sessionId, mt);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-server/src/test/java/org/apache/lens/server/query/TestLensDAO.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/TestLensDAO.java b/lens-server/src/test/java/org/apache/lens/server/query/TestLensDAO.java
index 01e846a..4597f9d 100644
--- a/lens-server/src/test/java/org/apache/lens/server/query/TestLensDAO.java
+++ b/lens-server/src/test/java/org/apache/lens/server/query/TestLensDAO.java
@@ -25,15 +25,12 @@ import java.sql.Statement;
 import java.util.HashMap;
 import java.util.List;
 
-import javax.ws.rs.core.Application;
-
 import org.apache.lens.api.LensConf;
 import org.apache.lens.api.LensSessionHandle;
 import org.apache.lens.api.query.LensQuery;
 import org.apache.lens.api.query.QueryHandle;
 import org.apache.lens.api.query.QueryStatus;
 import org.apache.lens.driver.jdbc.JDBCResultSet;
-import org.apache.lens.server.LensJerseyTest;
 import org.apache.lens.server.LensServices;
 import org.apache.lens.server.api.driver.MockDriver;
 import org.apache.lens.server.api.query.FinishedLensQuery;
@@ -53,7 +50,7 @@ import lombok.extern.slf4j.Slf4j;
  */
 @Test(groups = "unit-test")
 @Slf4j
-public class TestLensDAO extends LensJerseyTest {
+public class TestLensDAO {
 
   /**
    * Test lens server dao.
@@ -146,14 +143,4 @@ public class TestLensDAO extends LensJerseyTest {
     Assert.assertEquals(daoTestQueryHandles.size(), 1);
     Assert.assertEquals(daoTestQueryHandles.get(0).getHandleId().toString(), finishedHandle);
   }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.glassfish.jersey.test.JerseyTest#configure()
-   */
-  @Override
-  protected Application configure() {
-    return new QueryApp();
-  }
 }

http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-server/src/test/java/org/apache/lens/server/query/TestQueryConstraints.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/TestQueryConstraints.java b/lens-server/src/test/java/org/apache/lens/server/query/TestQueryConstraints.java
index ab42a3d..8493d85 100644
--- a/lens-server/src/test/java/org/apache/lens/server/query/TestQueryConstraints.java
+++ b/lens-server/src/test/java/org/apache/lens/server/query/TestQueryConstraints.java
@@ -25,9 +25,9 @@ import static org.testng.Assert.*;
 import java.util.*;
 
 import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
 
 import org.apache.lens.api.LensSessionHandle;
-import org.apache.lens.api.jaxb.LensJAXBContextResolver;
 import org.apache.lens.api.query.QueryHandle;
 import org.apache.lens.driver.hive.HiveDriver;
 import org.apache.lens.server.LensJerseyTest;
@@ -47,8 +47,6 @@ import org.apache.lens.server.common.TestResourceFile;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.conf.HiveConf;
 
-import org.glassfish.jersey.client.ClientConfig;
-import org.glassfish.jersey.media.multipart.MultiPartFeature;
 import org.glassfish.jersey.test.TestProperties;
 
 import org.testng.annotations.AfterMethod;
@@ -150,17 +148,6 @@ public class TestQueryConstraints extends LensJerseyTest {
     return new TestQueryService.QueryServiceTestApp();
   }
 
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.glassfish.jersey.test.JerseyTest#configureClient(org.glassfish.jersey.client.ClientConfig)
-   */
-  @Override
-  protected void configureClient(ClientConfig config) {
-    config.register(MultiPartFeature.class);
-    config.register(LensJAXBContextResolver.class);
-  }
-
   /** The test table. */
   public static final String TEST_TABLE = "TEST_TABLE";
 
@@ -171,7 +158,7 @@ public class TestQueryConstraints extends LensJerseyTest {
    * @throws InterruptedException the interrupted exception
    */
   private void createTable(String tblName) throws InterruptedException {
-    LensServerTestUtil.createTable(tblName, target(), lensSessionId);
+    LensServerTestUtil.createTable(tblName, target(), lensSessionId, defaultMT);
   }
 
   /**
@@ -182,7 +169,7 @@ public class TestQueryConstraints extends LensJerseyTest {
    * @throws InterruptedException the interrupted exception
    */
   private void loadData(String tblName, final String testDataFile) throws InterruptedException {
-    LensServerTestUtil.loadDataFromClasspath(tblName, testDataFile, target(), lensSessionId);
+    LensServerTestUtil.loadDataFromClasspath(tblName, testDataFile, target(), lensSessionId, defaultMT);
   }
 
   /**
@@ -192,26 +179,26 @@ public class TestQueryConstraints extends LensJerseyTest {
    * @throws InterruptedException the interrupted exception
    */
   private void dropTable(String tblName) throws InterruptedException {
-    LensServerTestUtil.dropTable(tblName, target(), lensSessionId);
+    LensServerTestUtil.dropTable(tblName, target(), lensSessionId, defaultMT);
   }
 
-  @Test
-  public void testThrottling() throws InterruptedException {
+  @Test(dataProvider = "mediaTypeData")
+  public void testThrottling(MediaType mt) throws InterruptedException {
     List<QueryHandle> handles = Lists.newArrayList();
     for (int j = 0; j < 5; j++) {
       for (int i = 0; i < 10; i++) {
-        handles.add(launchQuery());
+        handles.add(launchQuery(mt));
         assertValidity();
       }
       // No harm in sleeping, the queries will anyway take time.
       Thread.sleep(1000);
     }
     for (QueryHandle handle : handles) {
-      RestAPITestUtil.waitForQueryToFinish(target(), lensSessionId, handle);
+      RestAPITestUtil.waitForQueryToFinish(target(), lensSessionId, handle, mt);
       assertValidity();
     }
     for (QueryHandle handle : handles) {
-      RestAPITestUtil.getLensQueryResult(target(), lensSessionId, handle);
+      RestAPITestUtil.getLensQueryResultAsString(target(), lensSessionId, handle, mt);
       assertValidity();
     }
   }
@@ -222,10 +209,10 @@ public class TestQueryConstraints extends LensJerseyTest {
       + queryService.getLaunchedQueries());
   }
 
-  private QueryHandle launchQuery() {
+  private QueryHandle launchQuery(MediaType mt) {
     return RestAPITestUtil.executeAndGetHandle(target(), Optional.of(lensSessionId),
       Optional.of("select ID from " + TEST_TABLE),
-      Optional.of(LensServerAPITestUtil.getLensConf(QUERY_METRIC_UNIQUE_ID_CONF_KEY, UUID.randomUUID())));
+      Optional.of(LensServerAPITestUtil.getLensConf(QUERY_METRIC_UNIQUE_ID_CONF_KEY, UUID.randomUUID())), mt);
   }
 
   @AfterMethod

http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-server/src/test/java/org/apache/lens/server/query/TestQueryEndEmailNotifier.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/TestQueryEndEmailNotifier.java b/lens-server/src/test/java/org/apache/lens/server/query/TestQueryEndEmailNotifier.java
index 4ac42b2..e97a5a3 100644
--- a/lens-server/src/test/java/org/apache/lens/server/query/TestQueryEndEmailNotifier.java
+++ b/lens-server/src/test/java/org/apache/lens/server/query/TestQueryEndEmailNotifier.java
@@ -31,6 +31,7 @@ import java.util.Map;
 
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
 import org.apache.lens.api.LensConf;
@@ -49,8 +50,7 @@ import org.apache.lens.server.common.TestResourceFile;
 
 import org.apache.hadoop.hive.conf.HiveConf;
 
-import org.glassfish.jersey.client.ClientConfig;
-import org.glassfish.jersey.media.multipart.MultiPartFeature;
+import org.glassfish.jersey.test.TestProperties;
 import org.subethamail.wiser.Wiser;
 import org.subethamail.wiser.WiserMessage;
 import org.testng.annotations.*;
@@ -64,6 +64,7 @@ import com.google.common.base.Optional;
 public class TestQueryEndEmailNotifier extends LensJerseyTest {
 
   private static final int NUM_ITERS = 30;
+
   /** The query service. */
   QueryExecutionServiceImpl queryService;
 
@@ -121,19 +122,11 @@ public class TestQueryEndEmailNotifier extends LensJerseyTest {
    */
   @Override
   protected Application configure() {
+    enable(TestProperties.LOG_TRAFFIC);
+    enable(TestProperties.DUMP_ENTITY);
     return new QueryApp();
   }
 
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.glassfish.jersey.test.JerseyTest#configureClient(org.glassfish.jersey.client.ClientConfig)
-   */
-  @Override
-  protected void configureClient(ClientConfig config) {
-    config.register(MultiPartFeature.class);
-  }
-
   /** The test table. */
   public static final String TEST_TABLE = "EMAIL_NOTIFIER_TEST_TABLE";
 
@@ -144,7 +137,7 @@ public class TestQueryEndEmailNotifier extends LensJerseyTest {
    * @throws InterruptedException the interrupted exception
    */
   private void createTable(String tblName) throws InterruptedException {
-    LensServerTestUtil.createTable(tblName, target(), lensSessionId);
+    LensServerTestUtil.createTable(tblName, target(), lensSessionId, defaultMT);
   }
 
   /**
@@ -155,7 +148,7 @@ public class TestQueryEndEmailNotifier extends LensJerseyTest {
    * @throws InterruptedException the interrupted exception
    */
   private void loadData(String tblName, final String testDataFile) throws InterruptedException {
-    LensServerTestUtil.loadDataFromClasspath(tblName, testDataFile, target(), lensSessionId);
+    LensServerTestUtil.loadDataFromClasspath(tblName, testDataFile, target(), lensSessionId, defaultMT);
   }
 
   /**
@@ -165,13 +158,13 @@ public class TestQueryEndEmailNotifier extends LensJerseyTest {
    * @throws InterruptedException the interrupted exception
    */
   private void dropTable(String tblName) throws InterruptedException {
-    LensServerTestUtil.dropTable(tblName, target(), lensSessionId);
+    LensServerTestUtil.dropTable(tblName, target(), lensSessionId, defaultMT);
   }
 
-  private QueryHandle launchAndWaitForQuery(LensConf conf, String query, Status expectedStatus)
+  private QueryHandle launchAndWaitForQuery(LensConf conf, String query, Status expectedStatus, MediaType mt)
     throws InterruptedException {
     return executeAndWaitForQueryToFinish(target(), lensSessionId, query, Optional.of(conf),
-      Optional.of(expectedStatus)).getQueryHandle();
+      Optional.of(expectedStatus), mt).getQueryHandle();
   }
 
   private WiserMessage getMessage() throws InterruptedException {
@@ -200,58 +193,64 @@ public class TestQueryEndEmailNotifier extends LensJerseyTest {
    *
    * @throws InterruptedException the interrupted exception
    */
-  @Test
-  public void testLaunchFailure() throws InterruptedException {
+  @Test(dataProvider = "mediaTypeData")
+  public void testLaunchFailure(MediaType mt) throws InterruptedException {
     // launch failure
-    final Response response = execute(target(), Optional.of(lensSessionId), Optional.of("select fail from non_exist"));
+    final Response response = execute(target(), Optional.of(lensSessionId), Optional.of("select fail from non_exist"),
+      mt);
     assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
     QueryHandle handle = response.readEntity(new GenericType<LensAPIResult<QueryHandle>>() {}).getData();
     assertKeywordsContains(getMessage(), handle, "Launching query failed", "Reason");
   }
 
-  @Test
-  public void testFormattingFailure() throws InterruptedException {
+  @Test(dataProvider = "mediaTypeData")
+  public void testFormattingFailure(MediaType mt) throws InterruptedException {
     // formatting failure
     LensConf conf = getLensConf(
       LensConfConstants.QUERY_PERSISTENT_RESULT_SET, "true",
       LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false",
       LensConfConstants.QUERY_OUTPUT_SERDE, "NonexistentSerde.class");
-    QueryHandle handle = launchAndWaitForQuery(conf, "select ID, IDSTR from " + TEST_TABLE, Status.FAILED);
+    QueryHandle handle = launchAndWaitForQuery(conf, "select ID, IDSTR from " + TEST_TABLE, Status.FAILED, mt);
     assertKeywordsContains(getMessage(), handle, "Result formatting failed!", "Reason");
   }
 
-  @Test
-  public void testExecutionFailure() throws InterruptedException {
+  @Test(dataProvider = "mediaTypeData")
+  public void testExecutionFailure(MediaType mt) throws InterruptedException {
     // execution failure
     LensConf conf = getLensConf(
       LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "true",
       HiveConf.ConfVars.COMPRESSRESULT.name(), "true",
       "mapred.compress.map.output", "true",
       "mapred.map.output.compression.codec", "nonexisting");
-    QueryHandle handle = launchAndWaitForQuery(conf, "select count(ID) from " + TEST_TABLE, Status.FAILED);
+    QueryHandle handle = launchAndWaitForQuery(conf, "select count(ID) from " + TEST_TABLE, Status.FAILED, mt);
     assertKeywordsContains(getMessage(), handle, "Query execution failed!", "Reason");
   }
 
   @DataProvider(name = "success-tests")
   public Object[][] persistenceConfigDataProvider() {
     return new Object[][]{
-      {false, false, },
-      {true, false, },
-      {false, true, },
-      {true, true, },
+      {false, false, MediaType.APPLICATION_XML_TYPE},
+      {true, false, MediaType.APPLICATION_XML_TYPE},
+      {false, true, MediaType.APPLICATION_XML_TYPE},
+      {true, true, MediaType.APPLICATION_XML_TYPE},
+      {false, false, MediaType.APPLICATION_JSON_TYPE},
+      {true, false, MediaType.APPLICATION_JSON_TYPE},
+      {false, true, MediaType.APPLICATION_JSON_TYPE},
+      {true, true, MediaType.APPLICATION_JSON_TYPE},
     };
   }
 
   @Test(dataProvider = "success-tests")
-  public void testSuccessfulQuery(Boolean lensPersistence, Boolean driverPersistence) throws InterruptedException {
+  public void testSuccessfulQuery(Boolean lensPersistence, Boolean driverPersistence, MediaType mt)
+    throws InterruptedException {
     // successful query
     LensConf conf = getLensConf(
       LensConfConstants.QUERY_PERSISTENT_RESULT_SET, lensPersistence,
       LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, driverPersistence);
-    QueryHandle handle = launchAndWaitForQuery(conf, "select ID, IDSTR from " + TEST_TABLE, Status.SUCCESSFUL);
+    QueryHandle handle = launchAndWaitForQuery(conf, "select ID, IDSTR from " + TEST_TABLE, Status.SUCCESSFUL, mt);
     String expectedKeywords;
     if (lensPersistence || driverPersistence) {
-      QueryResult result = getLensQueryResult(target(), lensSessionId, handle);
+      QueryResult result = getLensQueryResult(target(), lensSessionId, handle, mt);
       expectedKeywords = result.toPrettyString();
     } else {
       expectedKeywords = InMemoryQueryResult.DECLARATION;