LENS-1003: Add list query tests to regression

Project: http://git-wip-us.apache.org/repos/asf/lens/repo
Commit: http://git-wip-us.apache.org/repos/asf/lens/commit/44bb7edb
Tree: http://git-wip-us.apache.org/repos/asf/lens/tree/44bb7edb
Diff: http://git-wip-us.apache.org/repos/asf/lens/diff/44bb7edb

Branch: refs/heads/master
Commit: 44bb7edb63e24c972621e7d700f82a25a55ad4f0
Parents: 33dfee1
Author: Archana H <archana.h...@gmail.com>
Authored: Wed Apr 13 19:09:32 2016 +0530
Committer: Rajat Khandelwal <rajatgupt...@gmail.com>
Committed: Wed Apr 13 19:09:32 2016 +0530

----------------------------------------------------------------------
 .../src/additional/java/SampleUdf.java          |  22 +-
 .../core/constants/QueryInventory.java          |  30 +-
 .../core/helpers/LensServerHelper.java          |   8 +-
 .../regression/core/helpers/QueryHelper.java    | 254 +++++----
 .../core/helpers/ServiceManagerHelper.java      |  48 +-
 .../regression/core/helpers/SessionHelper.java  | 108 ++--
 .../org/apache/lens/regression/util/Util.java   |  34 +-
 .../lens/regression/client/ITListQueryTest.java | 515 +++++++++++++++++++
 .../regression/client/SessionResourceTests.java |  33 +-
 9 files changed, 836 insertions(+), 216 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lens/blob/44bb7edb/lens-regression/src/additional/java/SampleUdf.java
----------------------------------------------------------------------
diff --git a/lens-regression/src/additional/java/SampleUdf.java 
b/lens-regression/src/additional/java/SampleUdf.java
index e340ffd..0c4e089 100644
--- a/lens-regression/src/additional/java/SampleUdf.java
+++ b/lens-regression/src/additional/java/SampleUdf.java
@@ -21,16 +21,20 @@ import org.apache.hadoop.hive.ql.exec.UDF;
 import org.apache.hadoop.io.Text;
 
 public final class SampleUdf extends UDF {
-    public Text evaluate(final Text s, Text sleepTime) throws 
InterruptedException {
+  public Text evaluate(final Text s, Text sleepTime) throws 
InterruptedException {
 
-        if(sleepTime!=null){
-            Thread.sleep(Long.parseLong(sleepTime.toString()));
-        }else{
-            Thread.sleep(180000);
-        }
+    Long time = 180*1000L;
 
-        if (s == null) { return null; }
-
-        return new Text(s.toString().toLowerCase());
+    if(sleepTime != null){
+      time = Long.parseLong(sleepTime.toString()) * 1000L;
     }
+
+    System.out.println("Sleep Time : " + time);
+
+    Thread.sleep(time);
+
+    if (s == null) { return null; }
+
+    return new Text(s.toString().toLowerCase());
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lens/blob/44bb7edb/lens-regression/src/main/java/org/apache/lens/regression/core/constants/QueryInventory.java
----------------------------------------------------------------------
diff --git 
a/lens-regression/src/main/java/org/apache/lens/regression/core/constants/QueryInventory.java
 
b/lens-regression/src/main/java/org/apache/lens/regression/core/constants/QueryInventory.java
index e41ca86..eb889c4 100644
--- 
a/lens-regression/src/main/java/org/apache/lens/regression/core/constants/QueryInventory.java
+++ 
b/lens-regression/src/main/java/org/apache/lens/regression/core/constants/QueryInventory.java
@@ -19,8 +19,25 @@
 
 package org.apache.lens.regression.core.constants;
 
+import java.util.Properties;
+
+import org.apache.lens.regression.util.Util;
+
+
 public class QueryInventory {
 
+  static final String QUERIES_PROPERTIES = "queries.properties";
+  static Properties queryMap = null;
+
+  static {
+    queryMap = Util.getPropertiesObj(QUERIES_PROPERTIES);
+  }
+
+  public static String getQueryFromInventory(String queryName){
+    return queryMap.get(queryName).toString();
+  }
+
+
   private QueryInventory() {
 
   }
@@ -29,12 +46,12 @@ public class QueryInventory {
   public static final String WRONG_QUERY = "cube select NO_ID from sample_dim 
where name != 'first'";
 
   public static final String DIM_QUERY = "cube select id,name from sample_dim 
where name != 'first'";
-  public static final String CUBE_QUERY = "cube select sample_dim.name, 
measure4 from sample_cube where "
+  public static final String CUBE_QUERY = "cube select sample_dim_chain.name, 
measure4 from sample_cube where "
     + "time_range_in(dt, '2014-06-24-23', '2014-06-25-00')";
   public static final String WRONG_DIM_QUERY = "cube select NO_ID from 
sample_dim where name != 'first'";
 
   public static final String HIVE_DIM_QUERY = "cube select id,name from 
sample_dim2 where name != 'first'";
-  public static final String HIVE_CUBE_QUERY = "cube select sample_dim.name, 
measure4 from sample_cube where "
+  public static final String HIVE_CUBE_QUERY = "cube select 
sample_dim_chain.name, measure4 from sample_cube where "
     + "time_range_in(dt, '2014-06-24-23', '2014-06-25-00')";
 
   public static final String JDBC_CUBE_QUERY = "cube select product_id from 
sales where "
@@ -43,7 +60,7 @@ public class QueryInventory {
     + "time_range_in(delivery_time,'2015-04-12','2015-04-14')";
 
   public static final String WRONG_HIVE_DIM_QUERY = "cube select NO_ID from 
sample_dim2 where name != 'first'";
-  public static final String WRONG_HIVE_CUBE_QUERY="cube select 
sample_dim.name, measure4 from sample_cube where "
+  public static final String WRONG_HIVE_CUBE_QUERY="cube select 
sample_dim_chain.name, measure4 from sample_cube where "
     + "time_range_in(dt, '2014-07-01-00', '2014-07-25-05')";
 
   public static final String WRONG_SYNTAX_QUERY="cube select id,name from 
sample_dim2 name != 'first'";
@@ -54,4 +71,11 @@ public class QueryInventory {
   public static final String SLEEP_FUNCTION = "CREATE TEMPORARY FUNCTION sleep 
AS 'hive.udf.SampleUdf'";
   public static final String SLEEP_QUERY = "cube select sleep(name) from 
sample_dim where name != 'first'";
 
+  //  public static final String SLEEP_QUERY = "cube select sleep(name,20000) 
from sample_dim where name != 'first'";
+
+  public static final String NO_CUBE_KEYWORD_QUERY = "select 
sample_dim_chain.name, measure4 from sample_cube where "
+      + "time_range_in(dt, '2014-06-24-23', '2014-06-25-00')";
+
+  public static final String QUOTE_QUERY = "cube select id,name from 
sample_dim2 where name != 'first\'s'";
+
 }

http://git-wip-us.apache.org/repos/asf/lens/blob/44bb7edb/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/LensServerHelper.java
----------------------------------------------------------------------
diff --git 
a/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/LensServerHelper.java
 
b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/LensServerHelper.java
index 760c088..2f8b9c0 100644
--- 
a/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/LensServerHelper.java
+++ 
b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/LensServerHelper.java
@@ -21,8 +21,8 @@ package org.apache.lens.regression.core.helpers;
 
 import java.io.IOException;
 
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-import javax.xml.bind.JAXBException;
 
 import org.apache.lens.regression.util.AssertUtil;
 import org.apache.lens.regression.util.Util;
@@ -46,15 +46,15 @@ public class LensServerHelper extends ServiceManagerHelper {
    * Restart Lens server
    */
 
-  public void restart() throws JSchException, IOException, 
InterruptedException, JAXBException, LensException {
+  public void restart() throws JSchException, IOException, 
InterruptedException, LensException {
     int counter = 0;
     Util.runRemoteCommand("bash /usr/local/lens/server/bin/lens-ctl stop");
     Util.runRemoteCommand("bash /usr/local/lens/server/bin/lens-ctl start");
-    Response response = this.exec("get", "", servLens, null, null);
+    Response response = this.exec("get", "", servLens, null, null, 
MediaType.TEXT_PLAIN_TYPE, MediaType.TEXT_PLAIN);
     while (response == null && counter < 40) {
       Thread.sleep(5000);
       log.info("Waiting for Lens server to come up ");
-      response = this.exec("get", "", servLens, null, null);
+      response = this.exec("get", "", servLens, null, null, 
MediaType.TEXT_PLAIN_TYPE, MediaType.TEXT_PLAIN);
       log.info("Response:{}", response);
       counter++;
     }

http://git-wip-us.apache.org/repos/asf/lens/blob/44bb7edb/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/QueryHelper.java
----------------------------------------------------------------------
diff --git 
a/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/QueryHelper.java
 
b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/QueryHelper.java
index e72eb34..5035ce8 100644
--- 
a/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/QueryHelper.java
+++ 
b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/QueryHelper.java
@@ -24,7 +24,6 @@ import java.util.List;
 import javax.ws.rs.core.GenericType;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-import javax.xml.bind.JAXBException;
 
 import org.apache.lens.api.LensConf;
 import org.apache.lens.api.query.*;
@@ -63,7 +62,7 @@ public class QueryHelper extends ServiceManagerHelper {
    * @return the query Handle
    */
   public LensAPIResult executeQuery(String queryString, String queryName, 
String sessionHandleString,
-      String conf) throws InstantiationException, IllegalAccessException, 
JAXBException, LensException {
+        String conf, String outputMediaType) throws LensException {
     FormBuilder formData = new FormBuilder();
     formData.add("sessionid", sessionHandleString);
     formData.add("query", queryString);
@@ -73,24 +72,28 @@ public class QueryHelper extends ServiceManagerHelper {
       formData.add("queryName", queryName);
     }
     Response response = this.exec("post", QueryURL.QUERY_URL, servLens, null, 
null, MediaType.MULTIPART_FORM_DATA_TYPE,
-            MediaType.APPLICATION_XML, formData.getForm());
+        outputMediaType, formData.getForm());
     LensAPIResult result = response.readEntity(new 
GenericType<LensAPIResult>(){});
     return result;
   }
 
-  public LensAPIResult executeQuery(String queryString, String queryName, 
String sessionHandleString) throws
-      InstantiationException, IllegalAccessException, JAXBException, 
LensException {
+  public LensAPIResult executeQuery(String queryString, String queryName, 
String sessionHandleString, String conf)
+    throws LensException {
+    return executeQuery(queryString, queryName, sessionHandleString, conf, 
MediaType.APPLICATION_XML);
+  }
+
+  public LensAPIResult executeQuery(String queryString, String queryName, 
String sessionHandleString)
+    throws LensException {
     return executeQuery(queryString, queryName, sessionHandleString,
         "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><conf 
/>");
   }
 
-  public LensAPIResult executeQuery(String queryString, String queryName) 
throws
-      InstantiationException, IllegalAccessException, JAXBException, 
LensException {
+  public LensAPIResult executeQuery(String queryString, String queryName) 
throws LensException {
     return executeQuery(queryString, queryName, sessionHandleString);
   }
 
   public LensAPIResult executeQuery(String queryString) throws
-      InstantiationException, IllegalAccessException, JAXBException, 
LensException {
+       LensException {
     return executeQuery(queryString, null);
   }
 
@@ -106,8 +109,7 @@ public class QueryHelper extends ServiceManagerHelper {
    */
 
   public LensAPIResult executeQueryTimeout(String queryString, String timeout, 
String queryName,
-      String sessionHandleString, String conf) throws InstantiationException, 
IllegalAccessException, JAXBException,
-      LensException {
+      String sessionHandleString, String conf) throws LensException {
     FormBuilder formData = new FormBuilder();
     formData.add("sessionid", sessionHandleString);
     formData.add("query", queryString);
@@ -126,23 +128,20 @@ public class QueryHelper extends ServiceManagerHelper {
   }
 
   public LensAPIResult executeQueryTimeout(String queryString, String timeout, 
String queryName,
-      String sessionHandleString) throws InstantiationException, 
IllegalAccessException, JAXBException, LensException {
+        String sessionHandleString) throws LensException {
     return executeQueryTimeout(queryString, timeout, queryName, 
sessionHandleString,
         "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><conf 
/>");
   }
 
-  public LensAPIResult executeQueryTimeout(String queryString, String timeout, 
String queryName) throws
-      InstantiationException, IllegalAccessException, JAXBException, 
LensException {
+  public LensAPIResult executeQueryTimeout(String queryString, String timeout, 
String queryName) throws LensException {
     return executeQueryTimeout(queryString, timeout, queryName, 
sessionHandleString);
   }
 
-  public LensAPIResult executeQueryTimeout(String queryString, String timeout) 
throws
-      InstantiationException, IllegalAccessException, JAXBException, 
LensException {
+  public LensAPIResult executeQueryTimeout(String queryString, String timeout) 
throws LensException {
     return executeQueryTimeout(queryString, timeout, null);
   }
 
-  public LensAPIResult executeQueryTimeout(String queryString) throws
-      InstantiationException, IllegalAccessException, JAXBException, 
LensException {
+  public LensAPIResult executeQueryTimeout(String queryString) throws 
LensException {
     return executeQueryTimeout(queryString, null);
   }
 
@@ -158,7 +157,7 @@ public class QueryHelper extends ServiceManagerHelper {
    */
 
   public LensAPIResult executeQuery(String queryString, String queryName, 
String user, String sessionHandleString,
-      LensConf conf) throws JAXBException, InstantiationException, 
IllegalAccessException, LensException {
+      LensConf conf) throws  LensException {
 
     FormBuilder formData = new FormBuilder();
     formData.add("sessionid", sessionHandleString);
@@ -174,7 +173,7 @@ public class QueryHelper extends ServiceManagerHelper {
         new 
FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(),
 conf,
             MediaType.APPLICATION_XML_TYPE));
     Response response = this.exec("post", "/queryapi/queries", servLens, null, 
null, MediaType.MULTIPART_FORM_DATA_TYPE,
-            MediaType.APPLICATION_XML, formData.getForm());
+        MediaType.APPLICATION_XML, formData.getForm());
     LensAPIResult result = response.readEntity(new 
GenericType<LensAPIResult>(){});
     log.info("QueryHandle String:{}", result);
     return result;
@@ -190,7 +189,7 @@ public class QueryHelper extends ServiceManagerHelper {
    */
 
   public LensAPIResult<QueryPlan> explainQuery(String queryString, String 
sessionHandleString, String conf) throws
-      JAXBException, InstantiationException, IllegalAccessException, 
LensException {
+       LensException {
     FormBuilder formData = new FormBuilder();
     formData.add("sessionid", sessionHandleString);
     formData.add("query", queryString);
@@ -199,20 +198,20 @@ public class QueryHelper extends ServiceManagerHelper {
         new 
FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(),
 conf,
             MediaType.APPLICATION_XML_TYPE));
     Response response = this.exec("post", "/queryapi/queries", servLens, null, 
null, MediaType.MULTIPART_FORM_DATA_TYPE,
-            MediaType.APPLICATION_XML, formData.getForm());
+        MediaType.APPLICATION_XML, formData.getForm());
     LensAPIResult<QueryPlan> result = response.readEntity(new 
GenericType<LensAPIResult<QueryPlan>>(){});
     log.info("QueryPlan String:{}", result);
     return result;
   }
 
   public LensAPIResult<QueryPlan> explainQuery(String queryString, String 
sessionHandleString) throws
-      JAXBException, InstantiationException, IllegalAccessException, 
LensException {
+       LensException {
     return explainQuery(queryString, sessionHandleString,
         "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><conf 
/>");
   }
 
   public LensAPIResult<QueryPlan> explainQuery(String queryString) throws
-      JAXBException, InstantiationException, IllegalAccessException, 
LensException {
+       LensException {
     return explainQuery(queryString, sessionHandleString);
   }
 
@@ -226,7 +225,7 @@ public class QueryHelper extends ServiceManagerHelper {
    */
 
   public LensAPIResult<QueryCostTO> estimateQuery(String queryString, String 
sessionHandleString, String conf) throws
-      InstantiationException, IllegalAccessException, JAXBException, 
LensException {
+       LensException {
     FormBuilder formData = new FormBuilder();
     formData.add("sessionid", sessionHandleString);
     formData.add("query", queryString);
@@ -240,13 +239,13 @@ public class QueryHelper extends ServiceManagerHelper {
   }
 
   public LensAPIResult<QueryCostTO> estimateQuery(String queryString, String 
sessionHandleString) throws
-      InstantiationException, IllegalAccessException, JAXBException, 
LensException {
+       LensException {
     return estimateQuery(queryString, sessionHandleString,
         "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><conf 
/>");
   }
 
   public LensAPIResult<QueryCostTO> estimateQuery(String queryString) throws
-      InstantiationException, IllegalAccessException, JAXBException, 
LensException {
+       LensException {
     return estimateQuery(queryString, sessionHandleString);
   }
 
@@ -260,7 +259,7 @@ public class QueryHelper extends ServiceManagerHelper {
    */
 
   public QueryPlan explainAndPrepareQuery(String queryString, String 
sessionHandleString, String conf) throws
-      InstantiationException, IllegalAccessException, JAXBException, 
LensException {
+      LensException {
 
     FormBuilder formData = new FormBuilder();
     formData.add("sessionid", sessionHandleString);
@@ -276,13 +275,13 @@ public class QueryHelper extends ServiceManagerHelper {
   }
 
   public QueryPlan explainAndPrepareQuery(String queryString, String 
sessionHandleString) throws
-      JAXBException, InstantiationException, IllegalAccessException, 
LensException {
+      LensException {
     return explainAndPrepareQuery(queryString, sessionHandleString,
         "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><conf 
/>");
   }
 
   public QueryPlan explainAndPrepareQuery(String queryString) throws
-      JAXBException, InstantiationException, IllegalAccessException, 
LensException {
+       LensException {
     return explainAndPrepareQuery(queryString, sessionHandleString);
   }
 
@@ -296,14 +295,14 @@ public class QueryHelper extends ServiceManagerHelper {
    * @return the query Result
    */
   public QueryResult getResultSet(QueryHandle queryHandle, String fromIndex, 
String fetchSize,
-      String sessionHandleString) throws JAXBException, 
InstantiationException, IllegalAccessException, LensException {
+      String sessionHandleString) throws  LensException {
 
     MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
     query.put("fromindex", fromIndex);
     query.put("fetchsize", fetchSize);
 
-    Response response = this
-        .exec("get", QueryURL.QUERY_URL + "/" + queryHandle.toString() + 
"/resultset", servLens, null, query);
+    Response response = this.exec("get", QueryURL.QUERY_URL + "/" + 
queryHandle.toString() + "/resultset", servLens,
+        null, query, MediaType.APPLICATION_XML_TYPE, 
MediaType.APPLICATION_XML, null);
     AssertUtil.assertSucceededResponse(response);
     QueryResult result = response.readEntity(new GenericType<QueryResult>(){});
     log.info("QueryResult String:{}", result);
@@ -311,15 +310,64 @@ public class QueryHelper extends ServiceManagerHelper {
   }
 
   public QueryResult getResultSet(QueryHandle queryHandle, String fromIndex, 
String fetchSize) throws
-      JAXBException, InstantiationException, IllegalAccessException, 
LensException {
+       LensException {
     return getResultSet(queryHandle, fromIndex, fetchSize, 
sessionHandleString);
   }
 
   public QueryResult getResultSet(QueryHandle queryHandle) throws
-      JAXBException, InstantiationException, IllegalAccessException, 
LensException {
+       LensException {
     return getResultSet(queryHandle, "0", "100", sessionHandleString);
   }
 
+
+  /**
+   * Get the Result set for json
+   *
+   * @param queryHandle
+   * @param fromIndex
+   * @param fetchSize
+   * @param sessionHandleString
+   * @return the query Result
+   */
+  public String getPersistentResultSetJson(QueryHandle queryHandle, String 
fromIndex, String fetchSize,
+      String sessionHandleString) throws LensException {
+
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    query.put("fromindex", fromIndex);
+    query.put("fetchsize", fetchSize);
+
+    Response response = this.exec("get", QueryURL.QUERY_URL + "/" + 
queryHandle.toString() + "/resultset", servLens,
+         null, query, MediaType.APPLICATION_XML_TYPE, 
MediaType.APPLICATION_JSON, null);
+    AssertUtil.assertSucceededResponse(response);
+    String result = response.readEntity(String.class);
+    log.info("QueryResult String:{}", result);
+    return result;
+  }
+
+  public String getInmemoryResultSetJson(QueryHandle queryHandle, String 
fromIndex, String fetchSize,
+      String sessionHandleString) throws LensException {
+
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    query.put("fromindex", fromIndex);
+    query.put("fetchsize", fetchSize);
+
+    Response response = this.exec("get", QueryURL.QUERY_URL + "/" + 
queryHandle.toString() + "/resultset", servLens,
+         null, query, MediaType.APPLICATION_XML_TYPE, 
MediaType.APPLICATION_JSON, null);
+    AssertUtil.assertSucceededResponse(response);
+    String result = response.readEntity(String.class);
+    log.info("QueryResult String:{}", result);
+    return result;
+  }
+
+  public String getPersistentResultSetJson(QueryHandle queryHandle, String 
fromIndex, String fetchSize)
+    throws LensException{
+    return getPersistentResultSetJson(queryHandle, fromIndex, fetchSize, 
sessionHandleString);
+  }
+
+  public String getPersistentResultSetJson(QueryHandle queryHandle) throws 
LensException {
+    return getPersistentResultSetJson(queryHandle, "0", "100", 
sessionHandleString);
+  }
+
   /**
    * Get the HTTP result set
    *
@@ -327,10 +375,9 @@ public class QueryHelper extends ServiceManagerHelper {
    * @return the query Result
    */
 
-  public QueryResult getHttpResultSet(QueryHandle queryHandle) throws
-      JAXBException, InstantiationException, IllegalAccessException, 
LensException {
-    Response response = this
-        .exec("get", QueryURL.QUERY_URL + "/" + queryHandle.toString() + 
"/httpresultset", servLens, null, null);
+  public QueryResult getHttpResultSet(QueryHandle queryHandle) throws 
LensException {
+    Response response = this.exec("get", QueryURL.QUERY_URL + "/" + 
queryHandle.toString() + "/httpresultset",
+      servLens, null, null);
     AssertUtil.assertSucceededResponse(response);
     QueryResult result = response.readEntity(new GenericType<QueryResult>(){});
     return result;
@@ -346,14 +393,14 @@ public class QueryHelper extends ServiceManagerHelper {
    */
 
   public QueryHandle executePreparedQuery(QueryPrepareHandle queryHandle, 
String sessionHandleString,
-      String conf) throws InstantiationException, IllegalAccessException, 
JAXBException, LensException {
+      String conf) throws  LensException {
     FormBuilder formData = new FormBuilder();
     formData.add("sessionid", sessionHandleString);
     formData.add("prepareHandle", queryHandle.toString());
     formData.add("operation", "EXECUTE");
     formData.add("conf", conf);
-    Response response = this.exec("post", "/queryapi/preparedqueries/" + 
queryHandle.toString(), servLens, null, null,
-        MediaType.MULTIPART_FORM_DATA_TYPE, MediaType.APPLICATION_XML, 
formData.getForm());
+    Response response = this.exec("post", QueryURL.PREPAREDQUERY_URL + "/" + 
queryHandle.toString(), servLens, null,
+        null, MediaType.MULTIPART_FORM_DATA_TYPE, MediaType.APPLICATION_XML, 
formData.getForm());
     AssertUtil.assertSucceededResponse(response);
     QueryHandle result = response.readEntity(new GenericType<QueryHandle>(){});
     log.info("QueryHandle String:{}", result);
@@ -361,13 +408,12 @@ public class QueryHelper extends ServiceManagerHelper {
   }
 
   public QueryHandle executePreparedQuery(QueryPrepareHandle queryHandle, 
String sessionHandleString) throws
-      InstantiationException, IllegalAccessException, JAXBException, 
LensException {
+       LensException {
     return executePreparedQuery(queryHandle, sessionHandleString,
         "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><conf 
/>");
   }
 
-  public QueryHandle executePreparedQuery(QueryPrepareHandle queryHandle) 
throws
-      InstantiationException, IllegalAccessException, JAXBException, 
LensException {
+  public QueryHandle executePreparedQuery(QueryPrepareHandle queryHandle) 
throws LensException {
     return executePreparedQuery(queryHandle, sessionHandleString);
   }
 
@@ -382,8 +428,7 @@ public class QueryHelper extends ServiceManagerHelper {
    */
 
   public QueryHandleWithResultSet 
executePreparedQueryTimeout(QueryPrepareHandle queryHandle, String timeout,
-      String sessionHandleString, String conf) throws InstantiationException, 
IllegalAccessException,
-      JAXBException, LensException {
+      String sessionHandleString, String conf) throws LensException {
     FormBuilder formData = new FormBuilder();
     formData.add("sessionid", sessionHandleString);
     formData.add("prepareHandle", queryHandle.toString());
@@ -392,25 +437,25 @@ public class QueryHelper extends ServiceManagerHelper {
     if (timeout != null) {
       formData.add("timeoutmillis", timeout);
     }
-    Response response = this.exec("post", "/queryapi/preparedqueries/" + 
queryHandle.toString(), servLens, null, null,
+    Response response = this.exec("post", QueryURL.PREPAREDQUERY_URL + 
queryHandle.toString(), servLens, null, null,
         MediaType.MULTIPART_FORM_DATA_TYPE, MediaType.APPLICATION_XML, 
formData.getForm());
     QueryHandleWithResultSet result = response.readEntity(new 
GenericType<QueryHandleWithResultSet>(){});
     return result;
   }
 
   public QueryHandleWithResultSet 
executePreparedQueryTimeout(QueryPrepareHandle queryHandle, String timeout,
-      String sessionHandleString) throws InstantiationException, 
IllegalAccessException, JAXBException, LensException {
+      String sessionHandleString) throws  LensException {
     return executePreparedQueryTimeout(queryHandle, timeout, 
sessionHandleString,
         "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><conf 
/>");
   }
 
   public QueryHandleWithResultSet 
executePreparedQueryTimeout(QueryPrepareHandle queryHandle, String timeout) 
throws
-      InstantiationException, IllegalAccessException, JAXBException, 
LensException {
+       LensException {
     return executePreparedQueryTimeout(queryHandle, timeout, 
sessionHandleString);
   }
 
   public QueryHandleWithResultSet 
executePreparedQueryTimeout(QueryPrepareHandle queryHandle) throws
-      InstantiationException, IllegalAccessException, JAXBException, 
LensException {
+       LensException {
     return executePreparedQueryTimeout(queryHandle, null);
   }
 
@@ -424,7 +469,7 @@ public class QueryHelper extends ServiceManagerHelper {
    */
 
   public QueryPrepareHandle submitPreparedQuery(String queryString, String 
queryName, String sessionHandleString,
-      String conf) throws JAXBException, InstantiationException, 
IllegalAccessException, LensException {
+      String conf) throws  LensException {
     FormBuilder formData = new FormBuilder();
     formData.add("sessionid", sessionHandleString);
     formData.add("query", queryString);
@@ -434,7 +479,7 @@ public class QueryHelper extends ServiceManagerHelper {
       formData.add("queryName", queryName);
     }
     Response response = this
-        .exec("post", "/queryapi/preparedqueries", servLens, null, null, 
MediaType.MULTIPART_FORM_DATA_TYPE,
+        .exec("post", QueryURL.PREPAREDQUERY_URL, servLens, null, null, 
MediaType.MULTIPART_FORM_DATA_TYPE,
             MediaType.APPLICATION_XML, formData.getForm());
     AssertUtil.assertSucceededResponse(response);
     LensAPIResult<QueryPrepareHandle> result = response.readEntity(
@@ -442,19 +487,19 @@ public class QueryHelper extends ServiceManagerHelper {
     return result.getData();
   }
 
-  public QueryPrepareHandle submitPreparedQuery(String queryString, String 
queryName, String sessionHandleString) throws
-      JAXBException, InstantiationException, IllegalAccessException, 
LensException {
+  public QueryPrepareHandle submitPreparedQuery(String queryString, String 
queryName, String sessionHandleString)
+    throws LensException {
     return submitPreparedQuery(queryString, queryName, sessionHandleString,
         "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><conf 
/>");
   }
 
   public QueryPrepareHandle submitPreparedQuery(String queryString, String 
queryName) throws
-      JAXBException, InstantiationException, IllegalAccessException, 
LensException {
+       LensException {
     return submitPreparedQuery(queryString, queryName, sessionHandleString);
   }
 
   public QueryPrepareHandle submitPreparedQuery(String queryString) throws
-      JAXBException, InstantiationException, IllegalAccessException, 
LensException {
+       LensException {
     return submitPreparedQuery(queryString, null);
   }
 
@@ -465,8 +510,8 @@ public class QueryHelper extends ServiceManagerHelper {
    * @param sessionHandleString
    */
 
-  public void destoryPreparedQueryByHandle(QueryPrepareHandle 
queryPreparedHandle, String sessionHandleString) throws
-      JAXBException, LensException {
+  public void destoryPreparedQueryByHandle(QueryPrepareHandle 
queryPreparedHandle, String sessionHandleString)
+    throws LensException {
     MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
     Response response = this
         .exec("delete", QueryURL.PREPAREDQUERY_URL + "/" + 
queryPreparedHandle.toString(), servLens, null, query);
@@ -474,7 +519,7 @@ public class QueryHelper extends ServiceManagerHelper {
     AssertUtil.assertSucceededResponse(response);
   }
 
-  public void destoryPreparedQueryByHandle(QueryPrepareHandle 
queryPreparedHandle) throws JAXBException, LensException {
+  public void destoryPreparedQueryByHandle(QueryPrepareHandle 
queryPreparedHandle) throws LensException {
     destoryPreparedQueryByHandle(queryPreparedHandle, sessionHandleString);
   }
 
@@ -490,7 +535,7 @@ public class QueryHelper extends ServiceManagerHelper {
    */
 
   public List<QueryPrepareHandle> getPreparedQueryHandleList(String queryName, 
String user, String sessionHandleString,
-      String fromDate, String toDate) throws InstantiationException, 
IllegalAccessException {
+      String fromDate, String toDate) {
     MapBuilder queryList = new MapBuilder("sessionid", sessionHandleString);
     if (queryName != null) {
       queryList.put("queryName", queryName);
@@ -511,21 +556,19 @@ public class QueryHelper extends ServiceManagerHelper {
   }
 
   public List<QueryPrepareHandle> getPreparedQueryHandleList(String queryName, 
String user,
-      String sessionHandleString) throws InstantiationException, 
IllegalAccessException {
+      String sessionHandleString) {
     return getPreparedQueryHandleList(queryName, user, sessionHandleString, 
null, null);
   }
 
-  public List<QueryPrepareHandle> getPreparedQueryHandleList(String queryName, 
String user) throws
-      InstantiationException, IllegalAccessException {
+  public List<QueryPrepareHandle> getPreparedQueryHandleList(String queryName, 
String user) {
     return getPreparedQueryHandleList(queryName, user, sessionHandleString);
   }
 
-  public List<QueryPrepareHandle> getPreparedQueryHandleList(String queryName) 
throws
-      InstantiationException, IllegalAccessException {
+  public List<QueryPrepareHandle> getPreparedQueryHandleList(String queryName) 
{
     return getPreparedQueryHandleList(queryName, null);
   }
 
-  public List<QueryPrepareHandle> getPreparedQueryHandleList() throws 
InstantiationException, IllegalAccessException {
+  public List<QueryPrepareHandle> getPreparedQueryHandleList() {
     return getPreparedQueryHandleList(null);
   }
 
@@ -539,7 +582,7 @@ public class QueryHelper extends ServiceManagerHelper {
    */
 
   public void destroyPreparedQuery(String queryName, String user, String 
sessionHandleString, String fromDate,
-      String toDate) throws JAXBException, LensException {
+      String toDate) throws LensException {
 
     MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
     if (queryName != null) {
@@ -560,20 +603,19 @@ public class QueryHelper extends ServiceManagerHelper {
     AssertUtil.assertSucceededResponse(response);
   }
 
-  public void destroyPreparedQuery(String queryName, String user, String 
sessionHandleString) throws
-      JAXBException, LensException {
+  public void destroyPreparedQuery(String queryName, String user, String 
sessionHandleString) throws LensException {
     destroyPreparedQuery(queryName, user, sessionHandleString, null, null);
   }
 
-  public void destroyPreparedQuery(String queryName, String user) throws 
JAXBException, LensException {
+  public void destroyPreparedQuery(String queryName, String user) throws 
LensException {
     destroyPreparedQuery(queryName, user, sessionHandleString);
   }
 
-  public void destroyPreparedQuery(String queryName) throws JAXBException, 
LensException {
+  public void destroyPreparedQuery(String queryName) throws  LensException {
     destroyPreparedQuery(queryName, null);
   }
 
-  public void destroyPreparedQuery() throws JAXBException, LensException {
+  public void destroyPreparedQuery() throws  LensException {
     destroyPreparedQuery(null);
   }
 
@@ -609,7 +651,7 @@ public class QueryHelper extends ServiceManagerHelper {
    * @return the query Handle list
    */
   public List<QueryHandle> getQueryHandleList(String queryName, String state, 
String user, String sessionHandleString,
-      String fromDate, String toDate, String driver) throws 
InstantiationException, IllegalAccessException {
+      String fromDate, String toDate, String driver) {
     MapBuilder queryList = new MapBuilder("sessionid", sessionHandleString);
     if (queryName != null) {
       queryList.put("queryName", queryName);
@@ -630,38 +672,34 @@ public class QueryHelper extends ServiceManagerHelper {
       queryList.put("driver", driver);
     }
     Response response = this.sendQuery("get", QueryURL.QUERY_URL, queryList);
-    log.info("Response : {}", response);
     List<QueryHandle> list = response.readEntity(new 
GenericType<List<QueryHandle>>(){});
     return list;
   }
 
   public List<QueryHandle> getQueryHandleList(String queryName, String state, 
String user,
-      String sessionHandleString, String fromDate, String toDate) throws 
InstantiationException,
-          IllegalAccessException {
+    String sessionHandleString, String fromDate, String toDate) {
     return getQueryHandleList(queryName, state, user, sessionHandleString, 
fromDate, toDate, null);
   }
 
 
   public List<QueryHandle> getQueryHandleList(String queryName, String state, 
String user,
-      String sessionHandleString) throws InstantiationException, 
IllegalAccessException {
+      String sessionHandleString) {
     return getQueryHandleList(queryName, state, user, sessionHandleString, 
null, null);
   }
 
-  public List<QueryHandle> getQueryHandleList(String queryName, String state, 
String user) throws
-      InstantiationException, IllegalAccessException {
+  public List<QueryHandle> getQueryHandleList(String queryName, String state, 
String user) {
     return getQueryHandleList(queryName, state, user, sessionHandleString);
   }
 
-  public List<QueryHandle> getQueryHandleList(String queryName, String state) 
throws
-      InstantiationException, IllegalAccessException {
+  public List<QueryHandle> getQueryHandleList(String queryName, String state) {
     return getQueryHandleList(queryName, state, null);
   }
 
-  public List<QueryHandle> getQueryHandleList(String queryName) throws 
InstantiationException, IllegalAccessException {
+  public List<QueryHandle> getQueryHandleList(String queryName) {
     return getQueryHandleList(queryName, null);
   }
 
-  public List<QueryHandle> getQueryHandleList() throws InstantiationException, 
IllegalAccessException {
+  public List<QueryHandle> getQueryHandleList() {
     return getQueryHandleList(null);
   }
 
@@ -673,25 +711,32 @@ public class QueryHelper extends ServiceManagerHelper {
    * @return the lens query
    */
 
-  public LensQuery waitForCompletion(String sessionHandleString, QueryHandle 
queryHandle) throws
-      JAXBException, InterruptedException, InstantiationException, 
IllegalAccessException, LensException {
+  public LensQuery waitForCompletion(String sessionHandleString, QueryHandle 
queryHandle, MediaType inputMediaType,
+      String outputMediaType) throws InterruptedException, LensException {
+
     MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
-    Response response = this.exec("get", QueryURL.QUERY_URL + "/" + 
queryHandle.toString(), servLens, null, query);
+    Response response = this.exec("get", QueryURL.QUERY_URL + "/" + 
queryHandle.toString(), servLens, null, query,
+        inputMediaType, outputMediaType);
     AssertUtil.assertSucceededResponse(response);
     LensQuery lensQuery = response.readEntity(new GenericType<LensQuery>(){});
 
     while (!lensQuery.getStatus().finished()) {
       log.info("Waiting...");
       Thread.sleep(1000);
-      response = this.exec("get", QueryURL.QUERY_URL + "/" + 
queryHandle.toString(), servLens, null, query);
+      response = this.exec("get", QueryURL.QUERY_URL + "/" + 
queryHandle.toString(), servLens, null, query,
+          inputMediaType, outputMediaType);
       lensQuery = response.readEntity(new GenericType<LensQuery>(){});
     }
     log.info("QueryStatus message:{}", 
lensQuery.getStatus().getStatusMessage());
     return lensQuery;
   }
 
-  public LensQuery waitForCompletion(QueryHandle queryHandle) throws
-      JAXBException, InterruptedException, InstantiationException, 
IllegalAccessException, LensException {
+  public LensQuery waitForCompletion(String sessionHandleString, QueryHandle 
queryHandle) throws
+       InterruptedException, LensException {
+    return waitForCompletion(sessionHandleString, queryHandle, null, null);
+  }
+
+  public LensQuery waitForCompletion(QueryHandle queryHandle) throws 
InterruptedException, LensException {
     return waitForCompletion(sessionHandleString, queryHandle);
   }
 
@@ -704,7 +749,7 @@ public class QueryHelper extends ServiceManagerHelper {
    */
 
   public QueryStatus waitForQueryToRun(QueryHandle queryHandle, String 
sessionHandleString) throws
-      JAXBException, InterruptedException, InstantiationException, 
IllegalAccessException, LensException {
+      InterruptedException, LensException {
     QueryStatus queryStatus = getQueryStatus(sessionHandleString, queryHandle);
     while (queryStatus.getStatus() == QueryStatus.Status.QUEUED) {
       log.info("Waiting for Query to be in Running Phase");
@@ -714,8 +759,7 @@ public class QueryHelper extends ServiceManagerHelper {
     return queryStatus;
   }
 
-  public QueryStatus waitForQueryToRun(QueryHandle queryHandle) throws
-      JAXBException, InterruptedException, InstantiationException, 
IllegalAccessException, LensException {
+  public QueryStatus waitForQueryToRun(QueryHandle queryHandle) throws 
InterruptedException, LensException {
     return waitForQueryToRun(queryHandle, sessionHandleString);
   }
 
@@ -727,8 +771,7 @@ public class QueryHelper extends ServiceManagerHelper {
    * @return the query Status
    */
 
-  public QueryStatus getQueryStatus(String sessionHandleString, QueryHandle 
queryHandle) throws
-      JAXBException, InstantiationException, IllegalAccessException, 
LensException {
+  public QueryStatus getQueryStatus(String sessionHandleString, QueryHandle 
queryHandle) throws  LensException {
     MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
     Response response = this.exec("get", QueryURL.QUERY_URL + "/" + 
queryHandle.toString(), servLens, null, query);
     log.info("Response : {}", response);
@@ -739,8 +782,7 @@ public class QueryHelper extends ServiceManagerHelper {
     return qStatus;
   }
 
-  public LensQuery getLensQuery(String sessionHandleString, QueryHandle 
queryHandle) throws
-      JAXBException, InstantiationException, IllegalAccessException, 
LensException {
+  public LensQuery getLensQuery(String sessionHandleString, QueryHandle 
queryHandle) throws LensException {
     MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
     Response response = this.exec("get", QueryURL.QUERY_URL + "/" + 
queryHandle.toString(), servLens, null, query);
     log.info("Response : {}", response);
@@ -749,8 +791,7 @@ public class QueryHelper extends ServiceManagerHelper {
     return lensQuery;
   }
 
-  public QueryStatus getQueryStatus(QueryHandle queryHandle) throws
-      JAXBException, InstantiationException, IllegalAccessException, 
LensException {
+  public QueryStatus getQueryStatus(QueryHandle queryHandle) throws 
LensException {
     return getQueryStatus(sessionHandleString, queryHandle);
   }
 
@@ -761,15 +802,14 @@ public class QueryHelper extends ServiceManagerHelper {
    * @param queryHandle
    */
 
-  public void killQueryByQueryHandle(String sessionHandleString, QueryHandle 
queryHandle) throws
-      JAXBException, LensException {
+  public void killQueryByQueryHandle(String sessionHandleString, QueryHandle 
queryHandle) throws LensException {
     MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
     Response response = this.exec("delete", QueryURL.QUERY_URL + "/" + 
queryHandle.toString(), servLens, null, query);
     log.info("Response : {}", response);
     AssertUtil.assertSucceededResponse(response);
   }
 
-  public void killQueryByQueryHandle(QueryHandle queryHandle) throws 
JAXBException, LensException {
+  public void killQueryByQueryHandle(QueryHandle queryHandle) throws 
LensException {
     killQueryByQueryHandle(sessionHandleString, queryHandle);
   }
 
@@ -785,7 +825,7 @@ public class QueryHelper extends ServiceManagerHelper {
    */
 
   public void killQuery(String queryName, String state, String user, String 
sessionHandleString, String fromDate,
-      String toDate) throws JAXBException, LensException {
+      String toDate) throws  LensException {
 
     MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
     if (queryName != null) {
@@ -814,23 +854,23 @@ public class QueryHelper extends ServiceManagerHelper {
   }
 
   public void killQuery(String queryName, String state, String user, String 
sessionHandleString) throws
-      JAXBException, LensException {
+       LensException {
     killQuery(queryName, state, user, sessionHandleString, null, null);
   }
 
-  public void killQuery(String queryName, String state, String user) throws 
JAXBException, LensException {
+  public void killQuery(String queryName, String state, String user) throws 
LensException {
     killQuery(queryName, state, user, sessionHandleString);
   }
 
-  public void killQuery(String queryName, String state) throws JAXBException, 
LensException {
+  public void killQuery(String queryName, String state) throws  LensException {
     killQuery(queryName, state, null);
   }
 
-  public void killQuery(String queryName) throws JAXBException, LensException {
+  public void killQuery(String queryName) throws  LensException {
     killQuery(queryName, null);
   }
 
-  public void killQuery() throws JAXBException, LensException {
+  public void killQuery() throws  LensException {
     killQuery(null);
   }
 

http://git-wip-us.apache.org/repos/asf/lens/blob/44bb7edb/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/ServiceManagerHelper.java
----------------------------------------------------------------------
diff --git 
a/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/ServiceManagerHelper.java
 
b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/ServiceManagerHelper.java
index feddb0f..a1d75ea 100644
--- 
a/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/ServiceManagerHelper.java
+++ 
b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/ServiceManagerHelper.java
@@ -19,7 +19,6 @@
 
 package org.apache.lens.regression.core.helpers;
 
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.URI;
 import java.util.Map;
@@ -33,6 +32,7 @@ import javax.ws.rs.core.UriBuilder;
 import javax.xml.bind.JAXBException;
 
 import org.apache.lens.api.APIResult;
+import org.apache.lens.api.LensConf;
 import org.apache.lens.regression.core.constants.SessionURL;
 import org.apache.lens.regression.core.type.FormBuilder;
 import org.apache.lens.regression.core.type.MapBuilder;
@@ -40,6 +40,8 @@ import org.apache.lens.regression.util.AssertUtil;
 import org.apache.lens.regression.util.Util;
 import org.apache.lens.server.api.error.LensException;
 
+import org.glassfish.jersey.media.multipart.FormDataBodyPart;
+import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
 import org.glassfish.jersey.media.multipart.FormDataMultiPart;
 import org.glassfish.jersey.media.multipart.MultiPartFeature;
 
@@ -56,6 +58,9 @@ public abstract class ServiceManagerHelper {
   private static final String LENS_CLIENT_DIR = "lens.client.dir";
   private static final String LENS_SERVER_HDFS_URL = "lens.server.hdfsurl";
   private static final String LENS_CURRENT_DB = "lens.server.currentDB";
+  private static final String JOB_CONF_URL = "job.conf.url";
+  private static final String START_DATE = "query.start.date";
+
 
   protected static String sessionHandleString;
   protected static WebTarget servLens;
@@ -68,6 +73,9 @@ public abstract class ServiceManagerHelper {
   protected String clientDir;
   protected String serverHdfsUrl;
   protected String currentDB;
+  protected String jobConfUrl;
+  protected String startDate;
+
 
   public ServiceManagerHelper(String envFileName) {
     Properties prop = Util.getPropertiesObj(envFileName);
@@ -79,6 +87,8 @@ public abstract class ServiceManagerHelper {
     this.clientDir = prop.getProperty(LENS_CLIENT_DIR);
     this.serverHdfsUrl = prop.getProperty(LENS_SERVER_HDFS_URL);
     this.currentDB = prop.getProperty(LENS_CURRENT_DB);
+    this.jobConfUrl = prop.getProperty(JOB_CONF_URL);
+    this.startDate = prop.getProperty(START_DATE);
   }
 
   public ServiceManagerHelper() {
@@ -140,6 +150,15 @@ public abstract class ServiceManagerHelper {
     return currentDB;
   }
 
+  public String getJobConfUrl() {
+    return jobConfUrl;
+  }
+
+  public String getStartDate() {
+    return startDate;
+  }
+
+
   public String openSession(String database) throws JAXBException, 
LensException {
     FormBuilder formData = new FormBuilder();
     formData.add("username", this.getUserName());
@@ -147,6 +166,13 @@ public abstract class ServiceManagerHelper {
     if (database != null) {
       formData.add("database", database);
     }
+
+    LensConf conf = new LensConf();
+    formData.getForm().bodyPart(
+        new 
FormDataBodyPart(FormDataContentDisposition.name("sessionconf").fileName("sessionconf").build(),
 conf,
+            MediaType.APPLICATION_XML_TYPE));
+    formData.add("sessionconf", conf.toString(), 
MediaType.APPLICATION_JSON_TYPE);
+
     Response response = this.exec("post", SessionURL.SESSION_BASE_URL, 
ServiceManagerHelper.servLens, null, null,
         MediaType.MULTIPART_FORM_DATA_TYPE, MediaType.APPLICATION_XML, 
formData.getForm());
     AssertUtil.assertSucceededResponse(response);
@@ -198,10 +224,10 @@ public abstract class ServiceManagerHelper {
     String className = this.getClass().getName();
 
     if (outputMediaType == null) {
-      outputMediaType = MediaType.WILDCARD;
+      outputMediaType = MediaType.APPLICATION_XML;
     }
     if (inputMediaType == null) {
-      inputMediaType = MediaType.WILDCARD_TYPE;
+      inputMediaType = MediaType.APPLICATION_XML_TYPE;
     }
 
     builder = service.path(path);
@@ -225,20 +251,10 @@ public abstract class ServiceManagerHelper {
       result = method.invoke(methodObject, build, inputMediaType, 
responseClass, inputObject);
       return result;
 
-    } catch (NoSuchMethodException e) {
-      return e.getMessage();
-    } catch (InstantiationException e) {
-      return e.getMessage();
-    } catch (IllegalAccessException e) {
-      return e.getMessage();
-    } catch (InvocationTargetException e) {
-      return e.getMessage();
-    } catch (ClassNotFoundException e) {
-      return e.getMessage();
     } catch (Exception e) {
-      return e.getMessage();
+      log.error("Exception in exec", e);
+      return null;
     }
-
   }
 
   public <T> Response exec(String functionName, String path, WebTarget 
service, FormDataMultiPart headers,
@@ -250,7 +266,7 @@ public abstract class ServiceManagerHelper {
       cl = (Response) exec(functionName, path, service, headers, queryParams, 
inputMediaType, outputMediaType,
           responseClass, inputObject);
     } catch (Exception e) {
-      System.out.println(e);
+      log.error("Exception in exec", e);
     }
     return cl;
   }

http://git-wip-us.apache.org/repos/asf/lens/blob/44bb7edb/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/SessionHelper.java
----------------------------------------------------------------------
diff --git 
a/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/SessionHelper.java
 
b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/SessionHelper.java
index c829f2a..64268a6 100644
--- 
a/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/SessionHelper.java
+++ 
b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/SessionHelper.java
@@ -22,19 +22,25 @@ package org.apache.lens.regression.core.helpers;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.ws.rs.core.GenericType;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-import javax.xml.bind.JAXBException;
 
-import org.apache.lens.api.APIResult;
+import org.apache.lens.api.LensConf;
+import org.apache.lens.api.LensSessionHandle;
+import org.apache.lens.api.StringList;
 import org.apache.lens.regression.core.type.FormBuilder;
 import org.apache.lens.regression.core.type.MapBuilder;
 import org.apache.lens.regression.util.AssertUtil;
 import org.apache.lens.regression.util.Util;
 import org.apache.lens.server.api.error.LensException;
 
+import org.glassfish.jersey.media.multipart.FormDataBodyPart;
+import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
+
 import lombok.extern.slf4j.Slf4j;
 
+
 @Slf4j
 public class SessionHelper extends ServiceManagerHelper {
 
@@ -55,48 +61,70 @@ public class SessionHelper extends ServiceManagerHelper {
    * @return the sessionHandle String
    */
 
-  public String openNewSession(String userName, String password, String 
database) throws JAXBException, LensException {
+  public Response openSessionReturnResponse(String userName, String password, 
String database, String outputMediaType)
+    throws LensException {
     FormBuilder formData = new FormBuilder();
     formData.add("username", userName);
     formData.add("password", password);
     if (database != null) {
       formData.add("database", database);
     }
+    LensConf conf = new LensConf();
+    formData.getForm().bodyPart(
+        new 
FormDataBodyPart(FormDataContentDisposition.name("sessionconf").fileName("sessionconf").build(),
 conf,
+            MediaType.APPLICATION_XML_TYPE));
+    formData.add("sessionconf", conf.toString(), 
MediaType.APPLICATION_JSON_TYPE);
+
     Response response = this
-        .exec("post", "/session", servLens, null, null, 
MediaType.MULTIPART_FORM_DATA_TYPE, MediaType.APPLICATION_XML,
+        .exec("post", "/session", servLens, null, null, 
MediaType.MULTIPART_FORM_DATA_TYPE, outputMediaType,
             formData.getForm());
+    return response;
+  }
+
+  public String openNewSession(String userName, String password, String 
database, String outputMediaType)
+    throws LensException {
+    Response response = openSessionReturnResponse(userName, password, 
database, outputMediaType);
     AssertUtil.assertSucceededResponse(response);
     String newSessionHandleString = response.readEntity(String.class);
     log.info("Session Handle String:{}", newSessionHandleString);
     return newSessionHandleString;
   }
 
-  public String openNewSession(String userName, String password) throws 
JAXBException, LensException {
-    return openNewSession(userName, password, null);
+  public String openNewSession(String userName, String password) throws 
LensException {
+    return openNewSession(userName, password, null, MediaType.APPLICATION_XML);
+  }
+
+  public String openNewSession(String userName, String password, String 
database) throws LensException {
+    return openNewSession(userName, password, database, 
MediaType.APPLICATION_XML);
+  }
+
+  public LensSessionHandle openNewSessionJson(String userName, String 
password, String database, String outputMediaType)
+    throws LensException {
+
+    Response response = openSessionReturnResponse(userName, password, 
database, outputMediaType);
+    AssertUtil.assertSucceededResponse(response);
+    LensSessionHandle newSessionHandleString = response.readEntity(new 
GenericType<LensSessionHandle>(){});
+    log.info("Session Handle String:{}", newSessionHandleString);
+    return newSessionHandleString;
   }
 
   /**
    * Close a Session
-   *
    * @param sessionHandleString
    */
-  public void closeNewSession(String sessionHandleString) throws 
JAXBException, LensException {
-    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
-    Response response = this.exec("delete", "/session", servLens, null, query);
 
-    APIResult result = response.readEntity(APIResult.class);
-    if (result.getStatus() != APIResult.Status.SUCCEEDED) {
-      throw new LensException("Status should be SUCCEEDED");
-    }
-    if (response.getStatus() != Response.Status.OK.getStatusCode()) {
-      throw new LensException("Status code should be 200");
-    }
-    if (result.getMessage() == null) {
-      throw new LensException("Status message is null");
-    }
+  public void closeNewSession(String sessionHandleString, String 
outputMediaType) throws LensException {
+
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    Response response = this.exec("delete", "/session", servLens, null, query, 
null, outputMediaType, null);
+    AssertUtil.assertSucceededResponse(response);
     log.info("Closed Session : {}", sessionHandleString);
   }
 
+  public void closeNewSession(String sessionHandleString) throws LensException 
{
+    closeNewSession(sessionHandleString, null);
+  }
+
   /**
    * Set and Validate Session Params
    *
@@ -105,22 +133,22 @@ public class SessionHelper extends ServiceManagerHelper {
    * @param value
    */
   public void setAndValidateParam(String sessionHandleString, String param, 
String value) throws Exception {
-    boolean success;
+
     FormBuilder formData = new FormBuilder();
     formData.add("sessionid", sessionHandleString);
     formData.add("key", param);
     formData.add("value", value);
-    Response response = this
-        .exec("put", "/session/params", servLens, null, null, 
MediaType.MULTIPART_FORM_DATA_TYPE, null,
-            formData.getForm());
-    AssertUtil.assertSucceeded(response);
+    Response response = this.exec("put", "/session/params", servLens, null, 
null, MediaType.MULTIPART_FORM_DATA_TYPE,
+         null, formData.getForm());
+    AssertUtil.assertSucceededResponse(response);
+
     MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
     query.put("key", param);
     response = this.exec("get", "/session/params", servLens, null, query);
     AssertUtil.assertSucceededResponse(response);
-    String responseString = response.readEntity(String.class);
-    log.info(responseString);
-    HashMap<String, String> map = Util.stringListToMap(responseString);
+    StringList strList = response.readEntity(new 
GenericType<StringList>(StringList.class));
+    HashMap<String, String> map = Util.stringListToMap(strList);
+
     if (!map.get(param).equals(value)) {
       throw new LensException("Could not set property");
     }
@@ -147,20 +175,19 @@ public class SessionHelper extends ServiceManagerHelper {
    * @param path
    * @param sessionHandleString
    */
-  public void addResourcesJar(String path, String sessionHandleString) throws 
JAXBException, LensException {
+  public void addResourcesJar(String path, String sessionHandleString) throws 
LensException {
     log.info("Adding Resources {}", path);
     FormBuilder formData = new FormBuilder();
     formData.add("sessionid", sessionHandleString);
     formData.add("type", "jar");
     formData.add("path", path);
-    Response response = this
-        .exec("put", "/session/resources/add", servLens, null, null, 
MediaType.MULTIPART_FORM_DATA_TYPE, null,
-            formData.getForm());
+    Response response = this.exec("put", "/session/resources/add", servLens, 
null, null,
+        MediaType.MULTIPART_FORM_DATA_TYPE, null, formData.getForm());
     log.info("Response : {}", response);
     AssertUtil.assertSucceeded(response);
   }
 
-  public void addResourcesJar(String path) throws JAXBException, LensException 
{
+  public void addResourcesJar(String path) throws  LensException {
     addResourcesJar(path, sessionHandleString);
   }
 
@@ -170,20 +197,19 @@ public class SessionHelper extends ServiceManagerHelper {
    * @param path
    * @param sessionHandleString
    */
-  public void removeResourcesJar(String path, String sessionHandleString) 
throws JAXBException, LensException {
+  public void removeResourcesJar(String path, String sessionHandleString) 
throws LensException {
     log.info("Removing Resources {}", path);
     FormBuilder formData = new FormBuilder();
     formData.add("sessionid", sessionHandleString);
     formData.add("type", "jar");
     formData.add("path", path);
-    Response response = this
-        .exec("put", "/session/resources/delete", servLens, null, null, 
MediaType.MULTIPART_FORM_DATA_TYPE, null,
-            formData.getForm());
+    Response response = this.exec("put", "/session/resources/delete", 
servLens, null, null,
+        MediaType.MULTIPART_FORM_DATA_TYPE, null,  formData.getForm());
     log.info("Response : {}", response);
     AssertUtil.assertSucceeded(response);
   }
 
-  public void removeResourcesJar(String path) throws JAXBException, 
LensException {
+  public void removeResourcesJar(String path) throws LensException {
     removeResourcesJar(path, sessionHandleString);
   }
 
@@ -192,13 +218,13 @@ public class SessionHelper extends ServiceManagerHelper {
     query.put("key", param);
     Response response = this.exec("get", "/session/params", servLens, null, 
query);
     AssertUtil.assertSucceededResponse(response);
-    String responseString = response.readEntity(String.class);
-    log.info(responseString);
-    HashMap<String, String> map = Util.stringListToMap(responseString);
+    StringList strList = response.readEntity(new 
GenericType<StringList>(StringList.class));
+    HashMap<String, String> map = Util.stringListToMap(strList);
     return map.get(param);
   }
 
   public String getSessionParam(String param) throws Exception {
     return getSessionParam(sessionHandleString, param);
   }
+
 }

http://git-wip-us.apache.org/repos/asf/lens/blob/44bb7edb/lens-regression/src/main/java/org/apache/lens/regression/util/Util.java
----------------------------------------------------------------------
diff --git 
a/lens-regression/src/main/java/org/apache/lens/regression/util/Util.java 
b/lens-regression/src/main/java/org/apache/lens/regression/util/Util.java
index 7bda529..6c3d234 100644
--- a/lens-regression/src/main/java/org/apache/lens/regression/util/Util.java
+++ b/lens-regression/src/main/java/org/apache/lens/regression/util/Util.java
@@ -62,7 +62,6 @@ import lombok.extern.slf4j.Slf4j;
 public class Util {
 
   private static final String PROPERTY_FILE = "lens.properties";
-  private static Properties properties;
   private static String localFilePath = "src/test/resources/";
   private static String localFile;
   private static String backupFile;
@@ -72,17 +71,14 @@ public class Util {
 
   }
 
-  public static synchronized Properties getPropertiesObj(String filename) {
+  public static Properties getPropertiesObj(String filename) {
     try {
-      if (properties == null) {
-        properties = new Properties();
-        log.info("filename: {}", filename);
-        InputStream confStream = Util.class.getResourceAsStream("/" + 
filename);
-        properties.load(confStream);
-        confStream.close();
-      }
+      Properties properties = new Properties();
+      log.info("filename: {}", filename);
+      InputStream confStream = Util.class.getResourceAsStream("/" + filename);
+      properties.load(confStream);
+      confStream.close();
       return properties;
-
     } catch (IOException e) {
       log.info("Error in getProperies:", e);
     }
@@ -154,8 +150,7 @@ public class Util {
   }
 
   @SuppressWarnings("unchecked")
-  public static <T> Object extractObject(String queryString, Class<T> c)
-    throws InstantiationException, IllegalAccessException {
+  public static <T> Object extractObject(String queryString, Class<T> c) 
throws IllegalAccessException {
     JAXBContext jaxbContext = null;
     Unmarshaller unmarshaller = null;
     StringReader reader = new StringReader(queryString);
@@ -171,8 +166,7 @@ public class Util {
   }
 
   @SuppressWarnings("unchecked")
-  public static <T> Object getObject(String queryString, Class<T> c)
-    throws InstantiationException, IllegalAccessException {
+  public static <T> Object getObject(String queryString, Class<T> c) throws 
IllegalAccessException {
     JAXBContext jaxbContext = null;
     Unmarshaller unmarshaller = null;
     StringReader reader = new StringReader(queryString);
@@ -188,8 +182,8 @@ public class Util {
 
   @SuppressWarnings("unchecked")
   public static <T> String convertObjectToXml(T object, Class<T> clazz, String 
functionName)
-    throws SecurityException, NoSuchMethodException, IllegalArgumentException, 
IllegalAccessException,
-    InvocationTargetException {
+    throws SecurityException, NoSuchMethodException, 
InvocationTargetException, IllegalAccessException {
+
     JAXBElement<T> root = null;
     StringWriter stringWriter = new StringWriter();
     ObjectFactory methodObject = new ObjectFactory();
@@ -312,8 +306,9 @@ public class Util {
   /*
    * function to download or upload a file to a remote server
    */
-  public static void remoteFile(String function, String remotePath, String 
localPath)
-    throws JSchException, SftpException {
+  public static void remoteFile(String function, String remotePath, String 
localPath) throws JSchException,
+      SftpException {
+
     String serverUrl = getProperty("lens.remote.host");
     String serverUname = getProperty("lens.remote.username");
     String serverPass = getProperty("lens.remote.password");
@@ -360,7 +355,7 @@ public class Util {
   public static Map<String, String> mapFromXProperties(XProperties 
xProperties) {
     Map<String, String> properties = new HashMap<String, String>();
     if (xProperties != null && xProperties.getProperty() != null
-      && !xProperties.getProperty().isEmpty()) {
+        && !xProperties.getProperty().isEmpty()) {
       for (XProperty xp : xProperties.getProperty()) {
         properties.put(xp.getName(), xp.getValue());
       }
@@ -412,5 +407,4 @@ public class Util {
       return null;
     }
   }
-
 }

Reply via email to