You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by am...@apache.org on 2016/02/02 14:21:23 UTC

[5/7] 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/LensServerTestUtil.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/LensServerTestUtil.java b/lens-server/src/test/java/org/apache/lens/server/LensServerTestUtil.java
index 94dd394..ddca12f 100644
--- a/lens-server/src/test/java/org/apache/lens/server/LensServerTestUtil.java
+++ b/lens-server/src/test/java/org/apache/lens/server/LensServerTestUtil.java
@@ -75,7 +75,8 @@ public final class LensServerTestUtil {
    * @param schemaStr     the schema string, with surrounding parenthesis.
    * @throws InterruptedException the interrupted exception
    */
-  public static void createTable(String tblName, WebTarget parent, LensSessionHandle lensSessionId, String schemaStr)
+  public static void createTable(String tblName, WebTarget parent, LensSessionHandle lensSessionId, String schemaStr,
+    MediaType mt)
     throws InterruptedException {
     LensConf conf = new LensConf();
     conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false");
@@ -85,21 +86,21 @@ public final class LensServerTestUtil {
     String createTable = "CREATE TABLE IF NOT EXISTS " + tblName + schemaStr;
 
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
-      MediaType.APPLICATION_XML_TYPE));
+      mt));
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), createTable));
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
-      MediaType.APPLICATION_XML_TYPE));
+      mt));
 
-    final QueryHandle handle = target.request()
+    final QueryHandle handle = target.request(mt)
         .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
             new GenericType<LensAPIResult<QueryHandle>>() {}).getData();
     // wait till the query finishes
-    LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
+    LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(mt)
       .get(LensQuery.class);
     QueryStatus stat = ctx.getStatus();
     while (!stat.finished()) {
-      ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request().get(LensQuery.class);
+      ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(mt).get(LensQuery.class);
       stat = ctx.getStatus();
       Thread.sleep(1000);
     }
@@ -112,13 +113,13 @@ public final class LensServerTestUtil {
     assertTrue(ctx.getFinishTime() > 0, debugHelpMsg);
   }
 
-  public static void createTable(String tblName, WebTarget parent, LensSessionHandle lensSessionId)
+  public static void createTable(String tblName, WebTarget parent, LensSessionHandle lensSessionId, MediaType mt)
     throws InterruptedException {
-    createTable(tblName, parent, lensSessionId, "(ID INT, IDSTR STRING)");
+    createTable(tblName, parent, lensSessionId, "(ID INT, IDSTR STRING)", mt);
   }
 
   public static void loadData(String tblName, final String testDataFile, WebTarget parent,
-      LensSessionHandle lensSessionId) throws InterruptedException {
+      LensSessionHandle lensSessionId, MediaType mt) throws InterruptedException {
     LensConf conf = new LensConf();
     conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false");
     final WebTarget target = parent.path("queryapi/queries");
@@ -127,21 +128,21 @@ public final class LensServerTestUtil {
     String dataLoad = "LOAD DATA LOCAL INPATH '" + testDataFile + "' OVERWRITE INTO TABLE " + tblName;
 
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
-        MediaType.APPLICATION_XML_TYPE));
+        mt));
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), dataLoad));
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
-        MediaType.APPLICATION_XML_TYPE));
+        mt));
 
-    final QueryHandle handle = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
+    final QueryHandle handle = target.request(mt).post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
         new GenericType<LensAPIResult<QueryHandle>>() {}).getData();
 
     // wait till the query finishes
-    LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
+    LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(mt)
         .get(LensQuery.class);
     QueryStatus stat = ctx.getStatus();
     while (!stat.finished()) {
-      ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request().get(LensQuery.class);
+      ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(mt).get(LensQuery.class);
       stat = ctx.getStatus();
       Thread.sleep(1000);
     }
@@ -157,10 +158,10 @@ public final class LensServerTestUtil {
    * @throws InterruptedException the interrupted exception
    */
   public static void loadDataFromClasspath(String tblName, final String testDataFile, WebTarget parent,
-      LensSessionHandle lensSessionId) throws InterruptedException {
+      LensSessionHandle lensSessionId, MediaType mt) throws InterruptedException {
 
     String absolutePath = LensServerTestUtil.class.getClassLoader().getResource(testDataFile).getPath();
-    loadData(tblName, absolutePath, parent, lensSessionId);
+    loadData(tblName, absolutePath, parent, lensSessionId, mt);
   }
 
   /**
@@ -171,11 +172,11 @@ public final class LensServerTestUtil {
    * @param lensSessionId the lens session id
    * @throws InterruptedException the interrupted exception
    */
-  public static void dropTable(String tblName, WebTarget parent, LensSessionHandle lensSessionId)
+  public static void dropTable(String tblName, WebTarget parent, LensSessionHandle lensSessionId, MediaType mt)
     throws InterruptedException {
     LensConf conf = new LensConf();
     conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false");
-    dropTableWithConf(tblName, parent, lensSessionId, conf);
+    dropTableWithConf(tblName, parent, lensSessionId, conf, mt);
   }
 
   /**
@@ -189,28 +190,28 @@ public final class LensServerTestUtil {
    * @throws InterruptedException
    */
   public static void dropTableWithConf(String tblName, WebTarget parent, LensSessionHandle lensSessionId,
-    LensConf conf) throws InterruptedException {
+    LensConf conf, MediaType mt) throws InterruptedException {
     final WebTarget target = parent.path("queryapi/queries");
 
     final FormDataMultiPart mp = new FormDataMultiPart();
     String createTable = "DROP TABLE IF EXISTS " + tblName;
 
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
-      MediaType.APPLICATION_XML_TYPE));
+      mt));
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), createTable));
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
-      MediaType.APPLICATION_XML_TYPE));
+      mt));
 
-    final QueryHandle handle = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
+    final QueryHandle handle = target.request(mt).post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
         new GenericType<LensAPIResult<QueryHandle>>() {}).getData();
 
     // wait till the query finishes
-    LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
+    LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(mt)
       .get(LensQuery.class);
     QueryStatus stat = ctx.getStatus();
     while (!stat.finished()) {
-      ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request().get(LensQuery.class);
+      ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(mt).get(LensQuery.class);
       stat = ctx.getStatus();
       Thread.sleep(1000);
     }

http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-server/src/test/java/org/apache/lens/server/TestLensApplication.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/TestLensApplication.java b/lens-server/src/test/java/org/apache/lens/server/TestLensApplication.java
index 4f9f4d2..6636346 100644
--- a/lens-server/src/test/java/org/apache/lens/server/TestLensApplication.java
+++ b/lens-server/src/test/java/org/apache/lens/server/TestLensApplication.java
@@ -23,7 +23,6 @@ import static org.testng.Assert.assertEquals;
 import java.util.List;
 
 import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.Application;
 import javax.ws.rs.core.Response;
 
 import org.apache.lens.server.api.metrics.MetricsService;
@@ -39,17 +38,7 @@ import com.codahale.metrics.ScheduledReporter;
  * The Class TestLensApplication.
  */
 @Test(alwaysRun = true, groups = "unit-test")
-public class TestLensApplication extends LensJerseyTest {
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.glassfish.jersey.test.JerseyTest#configure()
-   */
-  @Override
-  protected Application configure() {
-    return new LensApplication();
-  }
+public class TestLensApplication extends LensAllApplicationJerseyTest {
 
   /**
    * Setup.

http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-server/src/test/java/org/apache/lens/server/TestServerMode.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/TestServerMode.java b/lens-server/src/test/java/org/apache/lens/server/TestServerMode.java
index 75f21e1..caf968a 100644
--- a/lens-server/src/test/java/org/apache/lens/server/TestServerMode.java
+++ b/lens-server/src/test/java/org/apache/lens/server/TestServerMode.java
@@ -61,7 +61,8 @@ public class TestServerMode extends LensAllApplicationJerseyTest {
   @BeforeTest
   public void setUp() throws Exception {
     super.setUp();
-    LensServerTestUtil.createTable("test_table", target(), RestAPITestUtil.openFooBarSession(target()));
+    LensServerTestUtil.createTable("test_table", target(), RestAPITestUtil.openFooBarSession(target(), defaultMT),
+      defaultMT);
   }
 
   /*

http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-server/src/test/java/org/apache/lens/server/TestServerRestart.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/TestServerRestart.java b/lens-server/src/test/java/org/apache/lens/server/TestServerRestart.java
index 877200f..0f55d9e 100644
--- a/lens-server/src/test/java/org/apache/lens/server/TestServerRestart.java
+++ b/lens-server/src/test/java/org/apache/lens/server/TestServerRestart.java
@@ -142,14 +142,14 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
     createRestartTestDataFile();
 
     // Create a test table
-    createTable("test_server_restart", target(), lensSessionId);
-    loadData("test_server_restart", TestResourceFile.TEST_DATA_FILE.getValue(), target(), lensSessionId);
+    createTable("test_server_restart", target(), lensSessionId, defaultMT);
+    loadData("test_server_restart", TestResourceFile.TEST_DATA_FILE.getValue(), target(), lensSessionId, defaultMT);
     log.info("Loaded data");
 
     // test post execute op
     final WebTarget target = target().path("queryapi/queries");
 
-    List<QueryHandle> launchedQueries = new ArrayList<QueryHandle>();
+    List<QueryHandle> launchedQueries = new ArrayList<>();
     final int NUM_QUERIES = 10;
 
     boolean killed = false;
@@ -168,19 +168,18 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
 
       final FormDataMultiPart mp = new FormDataMultiPart();
       mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
-        MediaType.APPLICATION_XML_TYPE));
+        defaultMT));
       mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(),
         "select COUNT(ID) from test_server_restart"));
       mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
       mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(),
-        new LensConf(), MediaType.APPLICATION_XML_TYPE));
-      final QueryHandle handle = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
+        new LensConf(), defaultMT));
+      final QueryHandle handle = target.request(defaultMT).post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
         new GenericType<LensAPIResult<QueryHandle>>() {}).getData();
 
       Assert.assertNotNull(handle);
-      LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
+      LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(defaultMT)
         .get(LensQuery.class);
-      QueryStatus stat = ctx.getStatus();
       log.info("{} submitted query {} state: {}", i, handle, ctx.getStatus().getStatus());
       launchedQueries.add(handle);
     }
@@ -196,18 +195,19 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
     for (QueryHandle handle : launchedQueries) {
       log.info("Polling query {}", handle);
       try {
-        LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
+        LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(defaultMT)
           .get(LensQuery.class);
         QueryStatus stat = ctx.getStatus();
         while (!stat.finished()) {
           log.info("Polling query {} Status:{}", handle, stat);
-          ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request().get(LensQuery.class);
+          ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(defaultMT)
+            .get(LensQuery.class);
           stat = ctx.getStatus();
           Thread.sleep(1000);
         }
         assertEquals(ctx.getStatus().getStatus(), QueryStatus.Status.SUCCESSFUL, "Expected to be successful " + handle);
         PersistentQueryResult resultset = target.path(handle.toString()).path("resultset")
-          .queryParam("sessionid", lensSessionId).request().get(PersistentQueryResult.class);
+          .queryParam("sessionid", lensSessionId).request(defaultMT).get(PersistentQueryResult.class);
         List<String> rows = TestQueryService.readResultSet(resultset, handle, true);
         assertEquals(rows.size(), 1);
         assertEquals(rows.get(0), "" + NROWS);
@@ -218,7 +218,7 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
       }
     }
     log.info("End server restart test");
-    LensServerTestUtil.dropTable("test_server_restart", target(), lensSessionId);
+    LensServerTestUtil.dropTable("test_server_restart", target(), lensSessionId, defaultMT);
     queryService.closeSession(lensSessionId);
   }
 
@@ -249,9 +249,9 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
     log.info("@@ Added resource {}", dataFile.toURI());
 
     // Create a test table
-    createTable("test_hive_server_restart", target(), lensSessionId);
+    createTable("test_hive_server_restart", target(), lensSessionId, defaultMT);
     loadData("test_hive_server_restart", TestResourceFile.TEST_DATA_FILE.getValue(), target(),
-      lensSessionId);
+      lensSessionId, defaultMT);
     log.info("Loaded data");
 
     log.info("Hive Server restart test");
@@ -261,24 +261,25 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
     // Submit query, restart HS2, submit another query
     FormDataMultiPart mp = new FormDataMultiPart();
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
-      MediaType.APPLICATION_XML_TYPE));
+      defaultMT));
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(),
       "select COUNT(ID) from test_hive_server_restart"));
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
     mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(),
-      MediaType.APPLICATION_XML_TYPE));
-    QueryHandle handle = target.request()
+      defaultMT));
+    QueryHandle handle = target.request(defaultMT)
       .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
         new GenericType<LensAPIResult<QueryHandle>>() {}).getData();
 
     Assert.assertNotNull(handle);
 
     // wait for query to move out of QUEUED state
-    LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
+    LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(defaultMT)
         .get(LensQuery.class);
     QueryStatus stat = ctx.getStatus();
     while (stat.queued()) {
-      ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request().get(LensQuery.class);
+      ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(defaultMT)
+        .get(LensQuery.class);
       stat = ctx.getStatus();
       Thread.sleep(1000);
     }
@@ -312,12 +313,13 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
     verifyParamOnRestart(lensSessionId);
 
     // Poll for first query, we should not get any exception
-    ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
+    ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(defaultMT)
       .get(LensQuery.class);
     stat = ctx.getStatus();
     while (!stat.finished()) {
       log.info("Polling query {} Status:{}", handle, stat);
-      ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request().get(LensQuery.class);
+      ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(defaultMT)
+        .get(LensQuery.class);
       stat = ctx.getStatus();
       Thread.sleep(1000);
     }
@@ -332,18 +334,19 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
     final String query = "select COUNT(ID) from test_hive_server_restart";
     Response response = null;
     while (response == null || response.getStatus() == Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()) {
-      response = execute(target(), Optional.of(lensSessionId), Optional.of(query));
+      response = execute(target(), Optional.of(lensSessionId), Optional.of(query), defaultMT);
       Thread.sleep(1000);
     }
 
     handle = response.readEntity(new GenericType<LensAPIResult<QueryHandle>>() {}).getData();
 
     // Poll for second query, this should finish successfully
-    ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request().get(LensQuery.class);
+    ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(defaultMT).get(LensQuery.class);
     stat = ctx.getStatus();
     while (!stat.finished()) {
       log.info("Post restart polling query {} Status:{}", handle, stat);
-      ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request().get(LensQuery.class);
+      ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request(defaultMT)
+        .get(LensQuery.class);
       stat = ctx.getStatus();
       Thread.sleep(1000);
     }
@@ -364,7 +367,7 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
     // "Expected to be successful " + handle);
 
     log.info("End hive server restart test");
-    LensServerTestUtil.dropTable("test_hive_server_restart", target(), lensSessionId);
+    LensServerTestUtil.dropTable("test_hive_server_restart", target(), lensSessionId, defaultMT);
     queryService.closeSession(lensSessionId);
   }
 
@@ -383,9 +386,9 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
     sessionForm.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("username").build(), "foo"));
     sessionForm.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("password").build(), "bar"));
     sessionForm.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionconf").fileName("sessionconf")
-      .build(), new LensConf(), MediaType.APPLICATION_XML_TYPE));
+      .build(), new LensConf(), defaultMT));
 
-    final LensSessionHandle restartTestSession = sessionTarget.request().post(
+    final LensSessionHandle restartTestSession = sessionTarget.request(defaultMT).post(
       Entity.entity(sessionForm, MediaType.MULTIPART_FORM_DATA_TYPE), LensSessionHandle.class);
     Assert.assertNotNull(restartTestSession);
 
@@ -396,11 +399,11 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
     final WebTarget resourcetarget = target().path("session/resources");
     final FormDataMultiPart mp1 = new FormDataMultiPart();
     mp1.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), restartTestSession,
-      MediaType.APPLICATION_XML_TYPE));
+      defaultMT));
     mp1.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("type").build(), "file"));
     mp1.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("path").build(),
       "target/test-classes/lens-site.xml"));
-    APIResult result = resourcetarget.path("add").request()
+    APIResult result = resourcetarget.path("add").request(defaultMT)
       .put(Entity.entity(mp1, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class);
     assertEquals(result.getStatus(), Status.SUCCEEDED);
 
@@ -420,18 +423,18 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
     Assert.assertTrue(resourceEntry.getLocation().contains("target/test-classes/lens-site.xml"));
 
     // close session
-    result = sessionTarget.queryParam("sessionid", restartTestSession).request().delete(APIResult.class);
+    result = sessionTarget.queryParam("sessionid", restartTestSession).request(defaultMT).delete(APIResult.class);
     assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
   }
 
   private void setParams(LensSessionHandle lensSessionHandle) {
     FormDataMultiPart setpart = new FormDataMultiPart();
     setpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionHandle,
-      MediaType.APPLICATION_XML_TYPE));
+      defaultMT));
     setpart
       .bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("key").build(), "lens.session.testRestartKey"));
     setpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("value").build(), "myvalue"));
-    APIResult result = target().path("session").path("params").request()
+    APIResult result = target().path("session").path("params").request(defaultMT)
       .put(Entity.entity(setpart, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class);
     assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
   }
@@ -439,10 +442,10 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
   private void verifyParamOnRestart(LensSessionHandle lensSessionHandle) {
 
     StringList sessionParams = target().path("session").path("params").queryParam("sessionid", lensSessionHandle)
-      .queryParam("verbose", true).queryParam("key", "lens.session.testRestartKey").request().get(StringList.class);
+      .queryParam("verbose", true).queryParam("key", "lens.session.testRestartKey").request(defaultMT)
+      .get(StringList.class);
     System.out.println("Session params:" + sessionParams.getElements());
     assertEquals(sessionParams.getElements().size(), 1);
     Assert.assertTrue(sessionParams.getElements().contains("lens.session.testRestartKey=myvalue"));
-
   }
 }

http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-server/src/test/java/org/apache/lens/server/common/FormDataMultiPartFactory.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/common/FormDataMultiPartFactory.java b/lens-server/src/test/java/org/apache/lens/server/common/FormDataMultiPartFactory.java
index 5301162..9a1d79d 100644
--- a/lens-server/src/test/java/org/apache/lens/server/common/FormDataMultiPartFactory.java
+++ b/lens-server/src/test/java/org/apache/lens/server/common/FormDataMultiPartFactory.java
@@ -41,83 +41,76 @@ public class FormDataMultiPartFactory {
   }
 
   public static FormDataMultiPart createFormDataMultiPartForQuery(final Optional<LensSessionHandle> sessionId,
-      final Optional<String> query, final Optional<String> operation, final LensConf lensConf) {
+      final Optional<String> query, final Optional<String> operation, final LensConf lensConf, MediaType mt) {
 
     final FormDataMultiPart mp = new FormDataMultiPart();
 
     if (sessionId.isPresent()) {
-      mp.bodyPart(getSessionIdFormDataBodyPart(sessionId.get()));
+      mp.bodyPart(getSessionIdFormDataBodyPart(sessionId.get(), mt));
     }
 
     if (query.isPresent()) {
-      mp.bodyPart(getFormDataBodyPart("query", query.get()));
+      mp.bodyPart(getFormDataBodyPart("query", query.get(), mt));
     }
 
     if (operation.isPresent()) {
-      mp.bodyPart(getFormDataBodyPart("operation", operation.get()));
+      mp.bodyPart(getFormDataBodyPart("operation", operation.get(), mt));
     }
 
-    mp.bodyPart(getFormDataBodyPart("conf", "conf", lensConf));
+    mp.bodyPart(getFormDataBodyPart("conf", "conf", lensConf, mt));
     return mp;
   }
 
-  public static FormDataMultiPart createFormDataMultiPartForSession(final Optional<LensSessionHandle> sessionId,
-      final Optional<String> username, final Optional<String> password, final Optional<LensConf> lensConf) {
+  public static FormDataMultiPart createFormDataMultiPartForSession(
+    final Optional<String> username, final Optional<String> password, final Optional<LensConf> lensConf,
+    final MediaType mt) {
 
     final FormDataMultiPart mp = new FormDataMultiPart();
 
-    if (sessionId.isPresent()) {
-      mp.bodyPart(getSessionIdFormDataBodyPart(sessionId.get()));
-    }
-
     if (username.isPresent()) {
-      mp.bodyPart(getFormDataBodyPart("username", username.get()));
+      mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("username").build(), username.get()));
     }
 
     if (password.isPresent()) {
-      mp.bodyPart(getFormDataBodyPart("password", password.get()));
+      mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("password").build(), password.get()));
     }
 
     if (lensConf.isPresent()) {
-      mp.bodyPart(getFormDataBodyPart("sessionconf", "sessionconf", lensConf.get()));
+      mp.bodyPart(getFormDataBodyPart("sessionconf", "sessionconf", lensConf.get(), mt));
     }
 
     return mp;
   }
 
   public static FormDataMultiPart createFormDataMultiPartForFact(final LensSessionHandle sessionId,
-      final XFactTable xFactTable) {
+      final XFactTable xFactTable, MediaType mt) {
 
     final FormDataMultiPart mp = new FormDataMultiPart();
-    mp.bodyPart(getSessionIdFormDataBodyPart(sessionId));
-    mp.bodyPart(getFormDataBodyPart("fact", "fact", cubeObjectFactory.createXFactTable(xFactTable)));
+    mp.bodyPart(getSessionIdFormDataBodyPart(sessionId, mt));
+    mp.bodyPart(getFormDataBodyPart("fact", "fact", cubeObjectFactory.createXFactTable(xFactTable), mt));
 
     return mp;
   }
 
-  private static FormDataBodyPart getFormDataBodyPart(final String fdContentDispName, final String value) {
+  private static FormDataBodyPart getFormDataBodyPart(final String fdContentDispName, final String value,
+    final MediaType mt) {
     return new FormDataBodyPart(FormDataContentDisposition.name(fdContentDispName).build(), value,
-        MediaType.APPLICATION_XML_TYPE);
+        mt);
   }
 
-  private static FormDataBodyPart getFormDataBodyPart(final String fdContentDispName, final Object entity) {
+  private static FormDataBodyPart getFormDataBodyPart(final String fdContentDispName, final Object entity,
+    final MediaType mt) {
     return new FormDataBodyPart(FormDataContentDisposition.name(fdContentDispName).build(), entity,
-        MediaType.APPLICATION_XML_TYPE);
+        mt);
   }
 
   private static FormDataBodyPart getFormDataBodyPart(final String fdContentDispName, final String fileName,
-      final Object entity) {
+      final Object entity, final MediaType mt) {
     return new FormDataBodyPart(FormDataContentDisposition.name(fdContentDispName).fileName(fileName).build(), entity,
-        MediaType.APPLICATION_XML_TYPE);
-  }
-
-  private static FormDataBodyPart getFormDataBodyPartWithOutEntity(final String fdContentDispName,
-      final String fileName) {
-    return new FormDataBodyPart(FormDataContentDisposition.name(fdContentDispName).fileName(fileName).build(),
-        MediaType.APPLICATION_XML_TYPE);
+        mt);
   }
 
-  private static FormDataBodyPart getSessionIdFormDataBodyPart(final LensSessionHandle sessionId) {
-    return getFormDataBodyPart("sessionid", sessionId);
+  private static FormDataBodyPart getSessionIdFormDataBodyPart(final LensSessionHandle sessionId, MediaType mt) {
+    return getFormDataBodyPart("sessionid", sessionId, mt);
   }
 }

http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-server/src/test/java/org/apache/lens/server/common/RestAPITestUtil.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/common/RestAPITestUtil.java b/lens-server/src/test/java/org/apache/lens/server/common/RestAPITestUtil.java
index 4b25fd0..0e39b52 100644
--- a/lens-server/src/test/java/org/apache/lens/server/common/RestAPITestUtil.java
+++ b/lens-server/src/test/java/org/apache/lens/server/common/RestAPITestUtil.java
@@ -19,7 +19,6 @@
 
 package org.apache.lens.server.common;
 
-import static org.apache.lens.server.common.FormDataMultiPartFactory.createFormDataMultiPartForFact;
 import static org.apache.lens.server.common.FormDataMultiPartFactory.createFormDataMultiPartForSession;
 
 import static org.testng.Assert.assertEquals;
@@ -28,9 +27,11 @@ import static org.testng.Assert.assertNotNull;
 import javax.ws.rs.client.Entity;
 import javax.ws.rs.client.Invocation;
 import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.GenericEntity;
 import javax.ws.rs.core.GenericType;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import javax.xml.bind.JAXBElement;
 
 import org.apache.lens.api.APIResult;
 import org.apache.lens.api.LensConf;
@@ -38,10 +39,7 @@ import org.apache.lens.api.LensSessionHandle;
 import org.apache.lens.api.metastore.ObjectFactory;
 import org.apache.lens.api.metastore.XCube;
 import org.apache.lens.api.metastore.XFactTable;
-import org.apache.lens.api.query.LensQuery;
-import org.apache.lens.api.query.QueryHandle;
-import org.apache.lens.api.query.QueryResult;
-import org.apache.lens.api.query.QueryStatus;
+import org.apache.lens.api.query.*;
 import org.apache.lens.api.result.LensAPIResult;
 
 import org.glassfish.jersey.media.multipart.FormDataMultiPart;
@@ -56,43 +54,43 @@ public class RestAPITestUtil {
     throw new UnsupportedOperationException();
   }
 
-  public static LensSessionHandle openFooBarSession(final WebTarget target) {
-    return openSession(target, "foo", "bar");
+  public static LensSessionHandle openFooBarSession(final WebTarget target, MediaType mt) {
+    return openSession(target, "foo", "bar", mt);
   }
 
-  public static LensSessionHandle openSession(final WebTarget target, final String userName, final String passwd) {
-    return openSession(target, userName, passwd, new LensConf());
+  public static LensSessionHandle openSession(final WebTarget target, final String userName, final String passwd,
+    MediaType mt) {
+    return openSession(target, userName, passwd, new LensConf(), mt);
   }
 
   public static LensSessionHandle openSession(final WebTarget target, final String userName, final String passwd,
-    final LensConf conf) {
+    final LensConf conf, MediaType mt) {
 
-    final FormDataMultiPart mp = createFormDataMultiPartForSession(Optional.<LensSessionHandle>absent(),
-      Optional.of(userName), Optional.of(passwd), Optional.of(conf));
+    final FormDataMultiPart mp = createFormDataMultiPartForSession(Optional.of(userName), Optional.of(passwd),
+      Optional.of(conf), mt);
 
-    return target.path("session").request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
+    return target.path("session").request(mt).post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
       LensSessionHandle.class);
   }
 
   public static Response estimate(final WebTarget target, final Optional<LensSessionHandle> sessionId,
-    final Optional<String> query) {
-
-    return postQuery(target, sessionId, query, Optional.of("estimate"), Optional.<LensConf>absent());
+    final Optional<String> query, MediaType mt) {
+    return postQuery(target, sessionId, query, Optional.of("estimate"), Optional.<LensConf>absent(), mt);
   }
 
   public static Response execute(final WebTarget target, final Optional<LensSessionHandle> sessionId,
-    final Optional<String> query) {
-    return execute(target, sessionId, query, Optional.<LensConf>absent());
+    final Optional<String> query, MediaType mt) {
+    return execute(target, sessionId, query, Optional.<LensConf>absent(), mt);
   }
 
   public static Response execute(final WebTarget target, final Optional<LensSessionHandle> sessionId,
-    final Optional<String> query, final Optional<LensConf> lensConf) {
-    return postQuery(target, sessionId, query, Optional.of("execute"), lensConf);
+    final Optional<String> query, final Optional<LensConf> lensConf, MediaType mt) {
+    return postQuery(target, sessionId, query, Optional.of("execute"), lensConf, mt);
   }
 
   public static <T> T executeAndGetHandle(final WebTarget target, final Optional<LensSessionHandle> sessionId,
-    final Optional<String> query, final Optional<LensConf> lensConf) {
-    Response resp = postQuery(target, sessionId, query, Optional.of("execute"), lensConf);
+    final Optional<String> query, final Optional<LensConf> lensConf, MediaType mt) {
+    Response resp = postQuery(target, sessionId, query, Optional.of("execute"), lensConf, mt);
     assertEquals(resp.getStatus(), Response.Status.OK.getStatusCode());
     T handle = resp.readEntity(new GenericType<LensAPIResult<T>>() {}).getData();
     assertNotNull(handle);
@@ -100,116 +98,115 @@ public class RestAPITestUtil {
   }
 
   public static Response postQuery(final WebTarget target, final Optional<LensSessionHandle> sessionId,
-    final Optional<String> query, final Optional<String> operation) {
-    return postQuery(target, sessionId, query, operation, Optional.<LensConf>absent());
+                                   final Optional<String> query, final Optional<String> operation, MediaType mt) {
+    return postQuery(target, sessionId, query, operation, Optional.<LensConf>absent(), mt);
   }
 
   public static Response postQuery(final WebTarget target, final Optional<LensSessionHandle> sessionId,
-    final Optional<String> query, final Optional<String> operation, Optional<LensConf> lensConfOptional) {
+    final Optional<String> query, final Optional<String> operation, Optional<LensConf> lensConfOptional, MediaType mt) {
 
     FormDataMultiPart mp = FormDataMultiPartFactory
-      .createFormDataMultiPartForQuery(sessionId, query, operation, lensConfOptional.or(new LensConf()));
+      .createFormDataMultiPartForQuery(sessionId, query, operation, lensConfOptional.or(new LensConf()), mt);
 
-    return target.path("queryapi/queries").request(MediaType.APPLICATION_XML).post(
+    return target.path("queryapi/queries").request(mt).post(
       Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE));
   }
 
   public static LensQuery executeAndWaitForQueryToFinish(WebTarget target, LensSessionHandle lensSessionId,
-    String query, Optional<LensConf> conf, Optional<QueryStatus.Status> statusOptional) throws InterruptedException {
-    QueryHandle handle = executeAndGetHandle(target, Optional.of(lensSessionId), Optional.of(query), conf);
+    String query, Optional<LensConf> conf, Optional<QueryStatus.Status> statusOptional, MediaType mt)
+    throws InterruptedException {
+    QueryHandle handle = executeAndGetHandle(target, Optional.of(lensSessionId), Optional.of(query), conf, mt);
     if (statusOptional.isPresent()) {
-      return waitForQueryToFinish(target, lensSessionId, handle, statusOptional.get());
+      return waitForQueryToFinish(target, lensSessionId, handle, statusOptional.get(), mt);
     } else {
-      return waitForQueryToFinish(target, lensSessionId, handle);
+      return waitForQueryToFinish(target, lensSessionId, handle, mt);
     }
   }
 
-  public static void closeSessionFailFast(final WebTarget target, final LensSessionHandle sessionId) {
-    APIResult result = closeSession(target, sessionId);
+  public static void closeSessionFailFast(final WebTarget target, final LensSessionHandle sessionId, MediaType mt) {
+    APIResult result = closeSession(target, sessionId, mt);
     checkResponse(result);
   }
 
-  public static APIResult closeSession(final WebTarget target, final LensSessionHandle sessionId) {
-    return target.path("session").queryParam("sessionid", sessionId).request().delete(APIResult.class);
+  public static APIResult closeSession(final WebTarget target, final LensSessionHandle sessionId, MediaType mt) {
+    return target.path("session").queryParam("sessionid", sessionId).request(mt).delete(APIResult.class);
   }
 
-  public static String getCurrentDatabase(final WebTarget target, final LensSessionHandle sessionId) {
+  public static String getCurrentDatabase(final WebTarget target, final LensSessionHandle sessionId, MediaType mt) {
     WebTarget dbTarget = target.path("metastore").path("databases/current");
-    Invocation.Builder builder = dbTarget.queryParam("sessionid", sessionId).request(MediaType.APPLICATION_XML);
+    Invocation.Builder builder = dbTarget.queryParam("sessionid", sessionId).request(mt);
     String response = builder.get(String.class);
     return response;
   }
 
-  public static APIResult createCube(final WebTarget target, final LensSessionHandle sessionId, final XCube cube) {
-
-    return target.path("metastore").path("cubes").queryParam("sessionid", sessionId).request(MediaType.APPLICATION_XML)
-      .post(Entity.xml(cubeObjectFactory.createXCube(cube)), APIResult.class);
+  public static APIResult createCube(final WebTarget target, final LensSessionHandle sessionId, final XCube cube,
+    MediaType mt) {
+    return target.path("metastore").path("cubes").queryParam("sessionid", sessionId).request(mt)
+      .post(Entity.entity(
+        new GenericEntity<JAXBElement<XCube>>(cubeObjectFactory.createXCube(cube)){}, mt), APIResult.class);
   }
 
-  public static void createCubeFailFast(final WebTarget target, final LensSessionHandle sessionId, final XCube cube) {
-    APIResult result = createCube(target, sessionId, cube);
+  public static void createCubeFailFast(final WebTarget target, final LensSessionHandle sessionId, final XCube cube,
+    MediaType mt) {
+    APIResult result = createCube(target, sessionId, cube, mt);
     checkResponse(result);
   }
 
-  public static APIResult createFact(final WebTarget target, final LensSessionHandle sessionId,
-    final XFactTable factTable) {
-
-    FormDataMultiPart mp = createFormDataMultiPartForFact(sessionId, factTable);
-    return target.path("metastore").path("facts").queryParam("sessionid", sessionId).request(MediaType.APPLICATION_XML)
-      .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class);
-  }
-
   public static void createFactFailFast(final WebTarget target, final LensSessionHandle sessionId,
-    final XFactTable factTable) {
+    final XFactTable factTable, MediaType mt) {
 
-    APIResult result = createFact(target, sessionId, factTable);
+    APIResult result = target.path("metastore").path("facts").queryParam("sessionid", sessionId)
+      .request(mt).post(Entity.entity(
+          new GenericEntity<JAXBElement<XFactTable>>(cubeObjectFactory.createXFactTable(factTable)) {
+          }, mt),
+        APIResult.class);
     checkResponse(result);
   }
 
   public static APIResult setCurrentDatabase(final WebTarget target, final LensSessionHandle sessionId,
-    final String dbName) {
+    final String dbName, MediaType mt) {
 
     WebTarget dbTarget = target.path("metastore").path("databases/current");
-    return dbTarget.queryParam("sessionid", sessionId).request(MediaType.APPLICATION_XML)
+    return dbTarget.queryParam("sessionid", sessionId).request(mt)
       .put(Entity.xml(dbName),
         APIResult.class);
   }
 
   public static void setCurrentDatabaseFailFast(final WebTarget target, final LensSessionHandle sessionId,
-    final String dbName) {
+    final String dbName, MediaType mt) {
 
-    APIResult result = setCurrentDatabase(target, sessionId, dbName);
+    APIResult result = setCurrentDatabase(target, sessionId, dbName, mt);
     checkResponse(result);
   }
 
   public static APIResult createDatabase(final WebTarget target, final LensSessionHandle sessionId,
-    final String dbName) {
+    final String dbName, MediaType mt) {
 
     WebTarget dbTarget = target.path("metastore").path("databases");
-    return dbTarget.queryParam("sessionid", sessionId).request(MediaType.APPLICATION_XML)
+    return dbTarget.queryParam("sessionid", sessionId).request(mt)
       .post(Entity.xml(dbName), APIResult.class);
   }
 
   public static void createDatabaseFailFast(final WebTarget target, final LensSessionHandle sessionId,
-    final String dbName) {
+    final String dbName, MediaType mt) {
 
-    APIResult result = createDatabase(target, sessionId, dbName);
+    APIResult result = createDatabase(target, sessionId, dbName, mt);
     checkResponse(result);
   }
 
   public static void createAndSetCurrentDbFailFast(final WebTarget target, final LensSessionHandle sessionId,
-    final String dbName) {
+    final String dbName, MediaType mt) {
 
-    createDatabaseFailFast(target, sessionId, dbName);
-    setCurrentDatabaseFailFast(target, sessionId, dbName);
+    createDatabaseFailFast(target, sessionId, dbName, mt);
+    setCurrentDatabaseFailFast(target, sessionId, dbName, mt);
   }
 
   public static APIResult dropDatabaseFailFast(final WebTarget target, final LensSessionHandle sessionId,
-    String dbName) {
+    String dbName, MediaType mt) {
 
     WebTarget dbTarget = target.path("metastore").path("databases").path(dbName);
     return dbTarget.queryParam("cascade", "true")
-      .queryParam("sessionid", sessionId).request(MediaType.APPLICATION_XML).delete(APIResult.class);
+      .queryParam("sessionid", sessionId).request(mt).delete(APIResult.class);
   }
 
   private static void checkResponse(final APIResult result) {
@@ -219,32 +216,38 @@ public class RestAPITestUtil {
   }
 
   public static LensQuery waitForQueryToFinish(final WebTarget target, final LensSessionHandle lensSessionHandle,
-    final QueryHandle handle) throws InterruptedException {
-    LensQuery ctx = getLensQuery(target, lensSessionHandle, handle);
+    final QueryHandle handle, MediaType mt) throws InterruptedException {
+    LensQuery ctx = getLensQuery(target, lensSessionHandle, handle, mt);
     while (!ctx.getStatus().finished()) {
-      ctx = getLensQuery(target, lensSessionHandle, handle);
+      ctx = getLensQuery(target, lensSessionHandle, handle, mt);
       Thread.sleep(1000);
     }
     return ctx;
   }
 
   public static LensQuery waitForQueryToFinish(final WebTarget target, final LensSessionHandle lensSessionHandle,
-    final QueryHandle handle, QueryStatus.Status status) throws InterruptedException {
-    LensQuery lensQuery = waitForQueryToFinish(target, lensSessionHandle, handle);
+    final QueryHandle handle, QueryStatus.Status status, MediaType mt) throws InterruptedException {
+    LensQuery lensQuery = waitForQueryToFinish(target, lensSessionHandle, handle, mt);
     assertEquals(lensQuery.getStatus().getStatus(), status);
     return lensQuery;
   }
 
   public static LensQuery getLensQuery(final WebTarget target, final LensSessionHandle lensSessionHandle,
-    final QueryHandle handle) {
-    return target.path("queryapi/queries").path(handle.toString()).queryParam("sessionid", lensSessionHandle).request()
-      .get(LensQuery.class);
+    final QueryHandle handle, MediaType mt) {
+    return target.path("queryapi/queries").path(handle.toString()).queryParam("sessionid", lensSessionHandle)
+      .request(mt).get(LensQuery.class);
   }
 
-  public static QueryResult getLensQueryResult(final WebTarget target, final LensSessionHandle lensSessionHandle,
-    final QueryHandle handle) {
+  public static String getLensQueryResultAsString(final WebTarget target, final LensSessionHandle lensSessionHandle,
+    final QueryHandle handle, MediaType mt) {
+    return target.path("queryapi/queries").path(handle.toString()).path("resultset")
+      .queryParam("sessionid", lensSessionHandle).request(mt).get(String.class);
+  }
+
+  public static PersistentQueryResult getLensQueryResult(final WebTarget target,
+    final LensSessionHandle lensSessionHandle, final QueryHandle handle, MediaType mt) {
     return target.path("queryapi/queries").path(handle.toString()).path("resultset")
-      .queryParam("sessionid", lensSessionHandle).request().get(QueryResult.class);
+      .queryParam("sessionid", lensSessionHandle).request(mt).get(PersistentQueryResult.class);
   }
 
   public static Response getLensQueryHttpResult(final WebTarget target, final LensSessionHandle lensSessionHandle,

http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-server/src/test/java/org/apache/lens/server/healthcheck/TestHealthChecks.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/healthcheck/TestHealthChecks.java b/lens-server/src/test/java/org/apache/lens/server/healthcheck/TestHealthChecks.java
index 8e22c7a..56c67fb 100644
--- a/lens-server/src/test/java/org/apache/lens/server/healthcheck/TestHealthChecks.java
+++ b/lens-server/src/test/java/org/apache/lens/server/healthcheck/TestHealthChecks.java
@@ -20,24 +20,18 @@ package org.apache.lens.server.healthcheck;
 
 import static org.testng.Assert.*;
 
-import javax.ws.rs.core.Application;
-
 import org.apache.lens.server.EventServiceImpl;
-import org.apache.lens.server.LensJerseyTest;
+import org.apache.lens.server.LensAllApplicationJerseyTest;
 import org.apache.lens.server.LensServices;
 import org.apache.lens.server.api.LensService;
 import org.apache.lens.server.api.health.HealthStatus;
 import org.apache.lens.server.api.query.QueryExecutionService;
 import org.apache.lens.server.metastore.CubeMetastoreServiceImpl;
-import org.apache.lens.server.metastore.MetastoreApp;
 import org.apache.lens.server.metrics.MetricsServiceImpl;
 import org.apache.lens.server.quota.QuotaServiceImpl;
 import org.apache.lens.server.scheduler.SchedulerServiceImpl;
 import org.apache.lens.server.session.HiveSessionService;
 
-import org.glassfish.jersey.client.ClientConfig;
-import org.glassfish.jersey.media.multipart.MultiPartFeature;
-
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -45,7 +39,7 @@ import org.testng.annotations.Test;
 import com.codahale.metrics.health.HealthCheck;
 
 @Test(groups = "unit-test")
-public class TestHealthChecks extends LensJerseyTest {
+public class TestHealthChecks extends LensAllApplicationJerseyTest {
   @BeforeTest
   public void setUp() throws Exception {
     super.setUp();
@@ -56,16 +50,6 @@ public class TestHealthChecks extends LensJerseyTest {
     super.tearDown();
   }
 
-  @Override
-  protected Application configure() {
-    return new MetastoreApp();
-  }
-
-  @Override
-  protected void configureClient(ClientConfig config) {
-    config.register(MultiPartFeature.class);
-  }
-
   @Test
   public void testCubeMetastoreServiceHealth() throws Exception {
     checkHealth(CubeMetastoreServiceImpl.NAME);