You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by ar...@apache.org on 2015/06/01 12:48:22 UTC

[2/2] incubator-lens git commit: LENS-242:Add Helper class for lens-regression

LENS-242:Add Helper class for lens-regression


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

Branch: refs/heads/master
Commit: 6a4b247041d7aea64fce352556fadf47c7529e2c
Parents: 1254a1e
Author: arshad-matin <ar...@C1MNH5W0DTY3.local>
Authored: Mon Jun 1 16:06:31 2015 +0530
Committer: arshad-matin <ar...@C1MNH5W0DTY3.local>
Committed: Mon Jun 1 16:06:31 2015 +0530

----------------------------------------------------------------------
 lens-regression/pom.xml                         |  18 +
 .../regression/core/constants/MetastoreURL.java |  39 +
 .../regression/core/constants/QueryURL.java     |  32 +
 .../regression/core/constants/SessionURL.java   |  34 +
 .../regression/core/helpers/LensHelper.java     |  58 ++
 .../core/helpers/LensServerHelper.java          |  71 ++
 .../core/helpers/MetastoreHelper.java           | 156 ++++
 .../regression/core/helpers/QueryHelper.java    | 868 +++++++++++++++++++
 .../core/helpers/ServiceManagerHelper.java      | 292 +++++++
 .../regression/core/helpers/SessionHelper.java  | 198 +++++
 .../lens/regression/core/type/FormBuilder.java  |  80 ++
 .../lens/regression/core/type/MapBuilder.java   |  67 ++
 .../core/type/PrepareQueryHandles.java          |  46 +
 .../lens/regression/core/type/QueryHandles.java |  46 +
 .../apache/lens/regression/util/AssertUtil.java | 142 +++
 .../org/apache/lens/regression/util/Util.java   | 113 ++-
 .../lens/regression/sanity/ITSmokeTest.java     |   3 +-
 17 files changed, 2255 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/6a4b2470/lens-regression/pom.xml
----------------------------------------------------------------------
diff --git a/lens-regression/pom.xml b/lens-regression/pom.xml
index 037b2e9..59d1284 100644
--- a/lens-regression/pom.xml
+++ b/lens-regression/pom.xml
@@ -40,6 +40,11 @@
       <version>${project.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.lens</groupId>
+      <artifactId>lens-cube</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
     </dependency>
@@ -51,6 +56,19 @@
       <groupId>org.testng</groupId>
       <artifactId>testng</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.glassfish.jersey.core</groupId>
+      <artifactId>jersey-client</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.glassfish.jersey.core</groupId>
+      <artifactId>jersey-server</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.glassfish.jersey.media</groupId>
+      <artifactId>jersey-media-multipart</artifactId>
+    </dependency>
+
   </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/6a4b2470/lens-regression/src/main/java/org/apache/lens/regression/core/constants/MetastoreURL.java
----------------------------------------------------------------------
diff --git a/lens-regression/src/main/java/org/apache/lens/regression/core/constants/MetastoreURL.java b/lens-regression/src/main/java/org/apache/lens/regression/core/constants/MetastoreURL.java
new file mode 100644
index 0000000..84cb310
--- /dev/null
+++ b/lens-regression/src/main/java/org/apache/lens/regression/core/constants/MetastoreURL.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.regression.core.constants;
+
+public class MetastoreURL {
+
+  private MetastoreURL() {
+
+  }
+
+  public static final String METASTORE_BASE_URL = "/metastore";
+  public static final String METASTORE_CUBES_URL = METASTORE_BASE_URL + "/cubes";
+  public static final String METASTORE_DATABASES_URL = METASTORE_BASE_URL + "/databases";
+  public static final String METASTORE_DATABASES_CURRENT_URL = METASTORE_DATABASES_URL + "/current";
+  public static final String METASTORE_DIMENSIONS_URL = METASTORE_BASE_URL + "/dimensions";
+  public static final String METASTORE_DIMTABLES_URL = METASTORE_BASE_URL + "/dimtables";
+  public static final String METASTORE_FACTS_URL = METASTORE_BASE_URL + "/facts";
+  public static final String METASTORE_FLATTENED_URL = METASTORE_BASE_URL + "/flattened";
+  public static final String METASTORE_NATIVETABLES_URL = METASTORE_BASE_URL + "/nativetables";
+  public static final String METASTORE_STORAGES_URL = METASTORE_BASE_URL + "/storages";
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/6a4b2470/lens-regression/src/main/java/org/apache/lens/regression/core/constants/QueryURL.java
----------------------------------------------------------------------
diff --git a/lens-regression/src/main/java/org/apache/lens/regression/core/constants/QueryURL.java b/lens-regression/src/main/java/org/apache/lens/regression/core/constants/QueryURL.java
new file mode 100644
index 0000000..fcbf14d
--- /dev/null
+++ b/lens-regression/src/main/java/org/apache/lens/regression/core/constants/QueryURL.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.regression.core.constants;
+
+public class QueryURL {
+
+  private QueryURL() {
+
+  }
+
+  public static final String QUERYAPI_BASE_URL = "/queryapi";
+  public static final String QUERY_URL = QUERYAPI_BASE_URL + "/queries";
+  public static final String PREPAREDQUERY_URL = QUERYAPI_BASE_URL + "/preparedqueries";
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/6a4b2470/lens-regression/src/main/java/org/apache/lens/regression/core/constants/SessionURL.java
----------------------------------------------------------------------
diff --git a/lens-regression/src/main/java/org/apache/lens/regression/core/constants/SessionURL.java b/lens-regression/src/main/java/org/apache/lens/regression/core/constants/SessionURL.java
new file mode 100644
index 0000000..365146b
--- /dev/null
+++ b/lens-regression/src/main/java/org/apache/lens/regression/core/constants/SessionURL.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.regression.core.constants;
+
+public class SessionURL {
+
+  private SessionURL() {
+
+  }
+
+  public static final String SESSION_BASE_URL = "/session";
+  public static final String SESSION_PARAMS_URL = SESSION_BASE_URL + "/params";
+  public static final String SESSION_ADD_RESOURCE_URL = SESSION_BASE_URL + "/resources/add";
+  public static final String SESSION_REMOVE_RESOURCE_URL = SESSION_BASE_URL + "/resources/delete";
+  public static final String SESSION_LIST_RESOURCE_URL = SESSION_BASE_URL + "/resources/list";
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/6a4b2470/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/LensHelper.java
----------------------------------------------------------------------
diff --git a/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/LensHelper.java b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/LensHelper.java
new file mode 100644
index 0000000..c74da5d
--- /dev/null
+++ b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/LensHelper.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.regression.core.helpers;
+
+public class LensHelper {
+
+  protected QueryHelper queryHelper;
+  protected MetastoreHelper metastoreHelper;
+  protected SessionHelper sessionHelper;
+  protected LensServerHelper serverHelper;
+  protected String envFileName;
+
+  public LensHelper(String envFileName) {
+    this.envFileName = envFileName;
+    queryHelper = new QueryHelper(envFileName);
+    metastoreHelper = new MetastoreHelper(envFileName);
+    sessionHelper = new SessionHelper(envFileName);
+    serverHelper = new LensServerHelper(envFileName);
+  }
+
+  public QueryHelper getQueryHelper() {
+    return queryHelper;
+  }
+
+  public MetastoreHelper getMetastoreHelper() {
+    return metastoreHelper;
+  }
+
+  public SessionHelper getSessionHelper() {
+    return sessionHelper;
+  }
+
+  public LensServerHelper getServerHelper() {
+    return serverHelper;
+  }
+
+  public String getEnvFileName() {
+    return envFileName;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/6a4b2470/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
new file mode 100644
index 0000000..ad67d7d
--- /dev/null
+++ b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/LensServerHelper.java
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.regression.core.helpers;
+
+import java.io.IOException;
+
+import javax.ws.rs.client.WebTarget;
+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;
+import org.apache.lens.server.api.error.LensException;
+
+import org.apache.log4j.Logger;
+
+import com.jcraft.jsch.JSchException;
+
+
+public class LensServerHelper extends ServiceManagerHelper {
+
+  private static Logger logger = Logger.getLogger(LensServerHelper.class);
+
+  private WebTarget servLens = ServiceManagerHelper.getServerLens();
+  private String sessionHandleString = ServiceManagerHelper.getSessionHandle();
+
+  public LensServerHelper() {
+  }
+
+  public LensServerHelper(String envFileName) {
+    super(envFileName);
+  }
+
+  /**
+   * Restart Lens server
+   */
+
+  public void restart() throws JSchException, IOException, InterruptedException, JAXBException, 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);
+    while (response == null && counter < 40) {
+      Thread.sleep(5000);
+      logger.info("Waiting for Lens server to come up ");
+      response = this.exec("get", "", servLens, null, null);
+      logger.info(response);
+      counter++;
+    }
+    AssertUtil.assertSucceededResponse(response);
+  }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/6a4b2470/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/MetastoreHelper.java
----------------------------------------------------------------------
diff --git a/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/MetastoreHelper.java b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/MetastoreHelper.java
new file mode 100644
index 0000000..7fd3c47
--- /dev/null
+++ b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/MetastoreHelper.java
@@ -0,0 +1,156 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.regression.core.helpers;
+
+
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import javax.xml.bind.JAXBException;
+
+import org.apache.lens.api.StringList;
+import org.apache.lens.regression.core.constants.MetastoreURL;
+import org.apache.lens.regression.core.type.MapBuilder;
+import org.apache.lens.regression.util.AssertUtil;
+import org.apache.lens.server.api.error.LensException;
+
+import org.apache.log4j.Logger;
+
+
+
+
+public class MetastoreHelper extends ServiceManagerHelper {
+
+  private static Logger logger = Logger.getLogger(MetastoreHelper.class);
+
+  private WebTarget servLens = ServiceManagerHelper.getServerLens();
+  private String sessionHandleString = ServiceManagerHelper.getSessionHandle();
+
+  public MetastoreHelper() {
+  }
+
+  public MetastoreHelper(String envFileName) {
+    super(envFileName);
+  }
+
+  /**
+   * Set Current Database for a Session
+   *
+   * @param sessionHandleString
+   * @param currentDBName
+   */
+
+  public void setCurrentDatabase(String sessionHandleString, String currentDBName) throws JAXBException, LensException {
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    Response response = this.exec("put", MetastoreURL.METASTORE_DATABASES_CURRENT_URL, servLens, null, query,
+        MediaType.APPLICATION_XML_TYPE, null, currentDBName);
+    AssertUtil.assertSucceededResponse(response);
+    response = this.exec("get", MetastoreURL.METASTORE_DATABASES_CURRENT_URL, servLens, null, query);
+    String responseString = response.readEntity(String.class);
+    AssertUtil.assertSucceededResponse(response);
+    logger.info(responseString.trim());
+    if (!responseString.trim().equals(currentDBName)) {
+      throw new LensException("Could not set database");
+    }
+    logger.info("Set Current database to " + currentDBName);
+  }
+
+  public void setCurrentDatabase(String currentDBName) throws JAXBException, LensException {
+    setCurrentDatabase(sessionHandleString, currentDBName);
+  }
+
+  /**
+   * Get Current Database for a Session
+   *
+   * @param sessionHandleString
+   * @return the current DB Name
+   */
+
+  public String getCurrentDatabase(String sessionHandleString) throws JAXBException, LensException {
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    Response response = this.exec("get", MetastoreURL.METASTORE_DATABASES_CURRENT_URL, servLens, null, query,
+        MediaType.APPLICATION_XML_TYPE, null);
+    AssertUtil.assertSucceededResponse(response);
+    return response.readEntity(String.class);
+  }
+
+  public String getCurrentDatabase() throws JAXBException, LensException {
+    return getCurrentDatabase(sessionHandleString);
+  }
+
+  /**
+   * Get list of databases
+   *
+   * @param sessionHandleString
+   * @return List of all the Databases
+   */
+
+  public StringList listDatabases(String sessionHandleString) throws JAXBException, LensException {
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    Response response = this
+        .exec("get", MetastoreURL.METASTORE_DATABASES_URL, servLens, null, query, MediaType.APPLICATION_XML_TYPE, null);
+    AssertUtil.assertSucceededResponse(response);
+    StringList responseString = response.readEntity(StringList.class);
+    return responseString;
+  }
+
+  public StringList listDatabases() throws JAXBException, LensException {
+    return listDatabases(sessionHandleString);
+  }
+
+  /**
+   * Create a database
+   *
+   * @param dbName
+   * @param sessionHandleString
+   */
+
+  public void createDatabase(String dbName, String sessionHandleString) throws JAXBException, LensException {
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    Response response = this
+        .exec("post", MetastoreURL.METASTORE_DATABASES_URL, servLens, null, query, MediaType.APPLICATION_XML_TYPE, null,
+            dbName);
+    AssertUtil.assertSucceeded(response);
+  }
+
+  public void createDatabase(String dbName) throws JAXBException, LensException {
+    createDatabase(dbName, sessionHandleString);
+  }
+
+  /**
+   * Drop a DB
+   *
+   * @param dbName
+   * @param sessionHandleString
+   */
+  public void dropDatabase(String dbName, String sessionHandleString) throws JAXBException, LensException {
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    query.put("cascade", "true");
+    Response response = this.exec("delete", MetastoreURL.METASTORE_DATABASES_URL + "/" + dbName, servLens, null, query,
+        MediaType.APPLICATION_XML_TYPE, null);
+    AssertUtil.assertSucceeded(response);
+  }
+
+  public void dropDatabase(String dbName) throws JAXBException, LensException {
+    dropDatabase(dbName, sessionHandleString);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/6a4b2470/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
new file mode 100644
index 0000000..6b8bdda
--- /dev/null
+++ b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/QueryHelper.java
@@ -0,0 +1,868 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.regression.core.helpers;
+
+import java.util.List;
+
+import javax.ws.rs.client.WebTarget;
+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.*;
+import org.apache.lens.api.response.LensResponse;
+import org.apache.lens.regression.core.constants.QueryURL;
+import org.apache.lens.regression.core.type.FormBuilder;
+import org.apache.lens.regression.core.type.MapBuilder;
+import org.apache.lens.regression.core.type.PrepareQueryHandles;
+import org.apache.lens.regression.core.type.QueryHandles;
+import org.apache.lens.regression.util.AssertUtil;
+import org.apache.lens.regression.util.Util;
+import org.apache.lens.server.api.error.LensException;
+
+import org.apache.log4j.Logger;
+
+import org.glassfish.jersey.media.multipart.FormDataBodyPart;
+import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
+
+
+
+public class QueryHelper extends ServiceManagerHelper {
+
+  private static Logger logger = Logger.getLogger(QueryHelper.class);
+  private WebTarget servLens = ServiceManagerHelper.getServerLens();
+  private String sessionHandleString = ServiceManagerHelper.getSessionHandle();
+
+  public QueryHelper() {
+  }
+
+  public QueryHelper(String envFileName) {
+    super(envFileName);
+  }
+
+  /**
+   * Execute with conf
+   *
+   * @param queryString
+   * @param queryName
+   * @param sessionHandleString
+   * @param conf
+   * @return the query Handle
+   */
+  public QueryHandle executeQuery(String queryString, String queryName, String sessionHandleString, String conf) throws
+      InstantiationException, IllegalAccessException, JAXBException, LensException {
+    FormBuilder formData = new FormBuilder();
+    formData.add("sessionid", sessionHandleString);
+    formData.add("query", queryString);
+    formData.add("operation", "EXECUTE");
+    formData.add("conf", conf);
+    if (queryName != null) {
+      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());
+    AssertUtil.assertSucceededResponse(response);
+    String queryHandleString = response.readEntity(String.class);
+    logger.info(queryHandleString);
+    LensResponse successResponse = (LensResponse) Util.getObject(queryHandleString, LensResponse.class);
+    QueryHandle queryHandle = (QueryHandle) successResponse.getData();
+    if (queryHandle == null) {
+      throw new LensException("Query Execute Failed");
+    }
+    logger.info("Query Handle : " + queryHandle);
+    return queryHandle;
+  }
+
+  public QueryHandle executeQuery(String queryString, String queryName, String sessionHandleString) throws
+      InstantiationException, IllegalAccessException, JAXBException, LensException {
+    return executeQuery(queryString, queryName, sessionHandleString,
+        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><conf />");
+  }
+
+  public QueryHandle executeQuery(String queryString, String queryName) throws
+      InstantiationException, IllegalAccessException, JAXBException, LensException {
+    return executeQuery(queryString, queryName, sessionHandleString);
+  }
+
+  public QueryHandle executeQuery(String queryString) throws
+      InstantiationException, IllegalAccessException, JAXBException, LensException {
+    return executeQuery(queryString, null);
+  }
+
+  /**
+   * Execute with timeout
+   *
+   * @param queryString
+   * @param timeout
+   * @param queryName
+   * @param sessionHandleString
+   * @param conf
+   * @return the queryHandleWithResultSet
+   */
+
+  public QueryHandleWithResultSet executeQueryTimeout(String queryString, String timeout, String queryName,
+      String sessionHandleString, String conf) throws InstantiationException, IllegalAccessException, JAXBException,
+      LensException {
+    FormBuilder formData = new FormBuilder();
+    formData.add("sessionid", sessionHandleString);
+    formData.add("query", queryString);
+    formData.add("operation", "EXECUTE_WITH_TIMEOUT");
+    formData.add("conf", conf);
+    if (timeout != null) {
+      formData.add("timeoutmillis", timeout);
+    }
+    if (queryName != null) {
+      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());
+    AssertUtil.assertSucceededResponse(response);
+    String queryHandleString = response.readEntity(String.class);
+    logger.info(queryHandleString);
+    LensResponse successResponse = (LensResponse) Util.getObject(queryHandleString, LensResponse.class);
+    QueryHandleWithResultSet queryHandleWithResultSet = (QueryHandleWithResultSet) successResponse.getData();
+    if (queryHandleWithResultSet==null) {
+      throw new LensException("Query Execute Failed");
+    }
+    logger.info("Query Handle with ResultSet : " + queryHandleWithResultSet);
+    return queryHandleWithResultSet;
+  }
+
+  public QueryHandleWithResultSet executeQueryTimeout(String queryString, String timeout, String queryName,
+      String sessionHandleString) throws InstantiationException, IllegalAccessException, JAXBException, LensException {
+    return executeQueryTimeout(queryString, timeout, queryName, sessionHandleString,
+        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><conf />");
+  }
+
+  public QueryHandleWithResultSet executeQueryTimeout(String queryString, String timeout, String queryName) throws
+      InstantiationException, IllegalAccessException, JAXBException, LensException {
+    return executeQueryTimeout(queryString, timeout, queryName, sessionHandleString);
+  }
+
+  public QueryHandleWithResultSet executeQueryTimeout(String queryString, String timeout) throws
+      InstantiationException, IllegalAccessException, JAXBException, LensException {
+    return executeQueryTimeout(queryString, timeout, null);
+  }
+
+  public QueryHandleWithResultSet executeQueryTimeout(String queryString) throws
+      InstantiationException, IllegalAccessException, JAXBException, LensException {
+    return executeQueryTimeout(queryString, null);
+  }
+
+  /**
+   * Execute the query
+   *
+   * @param queryString
+   * @param queryName
+   * @param user
+   * @param sessionHandleString
+   * @param conf
+   * @return the query Handle
+   */
+
+  public QueryHandle executeQuery(String queryString, String queryName, String user, String sessionHandleString,
+      LensConf conf) throws JAXBException, InstantiationException, IllegalAccessException, LensException {
+
+    FormBuilder formData = new FormBuilder();
+    formData.add("sessionid", sessionHandleString);
+    formData.add("query", queryString);
+    formData.add("operation", "EXECUTE");
+    if (queryName != null) {
+      formData.add("queryName", queryName);
+    }
+    if (user != null) {
+      formData.add("user", user);
+    }
+    formData.getForm().bodyPart(
+        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());
+    AssertUtil.assertSucceededResponse(response);
+    String queryHandleString = response.readEntity(String.class);
+    logger.info(queryHandleString);
+    LensResponse successResponse = (LensResponse) Util.getObject(queryHandleString, LensResponse.class);
+    QueryHandle queryHandle = (QueryHandle) successResponse.getData();
+    return queryHandle;
+  }
+
+  /**
+   * Explain the query
+   *
+   * @param queryString
+   * @param sessionHandleString
+   * @param conf
+   * @return the query Plan
+   */
+
+  public QueryPlan explainQuery(String queryString, String sessionHandleString, String conf) throws
+      JAXBException, InstantiationException, IllegalAccessException, LensException {
+    FormBuilder formData = new FormBuilder();
+    formData.add("sessionid", sessionHandleString);
+    formData.add("query", queryString);
+    formData.add("operation", "EXPLAIN");
+    formData.getForm().bodyPart(
+        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());
+    AssertUtil.assertSucceededResponse(response);
+    String queryPlanString = response.readEntity(String.class);
+    logger.info(queryPlanString);
+    LensResponse successResponse = (LensResponse) Util.getObject(queryPlanString, LensResponse.class);
+    QueryPlan queryPlan = (QueryPlan) successResponse.getData();
+    return queryPlan;
+  }
+
+  public QueryPlan explainQuery(String queryString, String sessionHandleString) throws
+      JAXBException, InstantiationException, IllegalAccessException, LensException {
+    return explainQuery(queryString, sessionHandleString,
+        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><conf />");
+  }
+
+  public QueryPlan explainQuery(String queryString) throws
+      JAXBException, InstantiationException, IllegalAccessException, LensException {
+    return explainQuery(queryString, sessionHandleString);
+  }
+
+  /**
+   * Estimate the query
+   *
+   * @param queryString
+   * @param sessionHandleString
+   * @param conf
+   * @return the Estimate result
+   */
+
+  public QueryCost estimateQuery(String queryString, String sessionHandleString, String conf) throws
+      InstantiationException, IllegalAccessException, JAXBException, LensException {
+    FormBuilder formData = new FormBuilder();
+    formData.add("sessionid", sessionHandleString);
+    formData.add("query", queryString);
+    formData.add("operation", "ESTIMATE");
+    formData.add("conf", conf);
+    Response response = this.exec("post", QueryURL.QUERY_URL, servLens, null, null, MediaType.MULTIPART_FORM_DATA_TYPE,
+        MediaType.APPLICATION_XML, formData.getForm());
+    AssertUtil.assertSucceededResponse(response);
+    String queryCostString = response.readEntity(String.class);
+    logger.info(queryCostString);
+    LensResponse successResponse = (LensResponse) Util.getObject(queryCostString, LensResponse.class);
+    QueryCost queryCost = (QueryCost) successResponse.getData();
+    if (queryCost == null) {
+      throw new LensException("Estimate Failed");
+    }
+    return queryCost;
+  }
+
+  public QueryCost estimateQuery(String queryString, String sessionHandleString) throws
+      InstantiationException, IllegalAccessException, JAXBException, LensException {
+    return estimateQuery(queryString, sessionHandleString,
+        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><conf />");
+  }
+
+  public QueryCost estimateQuery(String queryString) throws
+      InstantiationException, IllegalAccessException, JAXBException, LensException {
+    return estimateQuery(queryString, sessionHandleString);
+  }
+
+  /**
+   * Prepare and Explain the query
+   *
+   * @param queryString
+   * @param sessionHandleString
+   * @param conf
+   * @return the query Plan
+   */
+
+  public QueryPlan explainAndPrepareQuery(String queryString, String sessionHandleString, String conf) throws
+      InstantiationException, IllegalAccessException, JAXBException, LensException {
+
+    FormBuilder formData = new FormBuilder();
+    formData.add("sessionid", sessionHandleString);
+    formData.add("query", queryString);
+    formData.add("operation", "EXPLAIN_AND_PREPARE");
+    formData.add("conf", conf);
+    Response response = this
+        .exec("post", "/queryapi/preparedqueries", servLens, null, null, MediaType.MULTIPART_FORM_DATA_TYPE,
+            MediaType.APPLICATION_XML, formData.getForm());
+    String queryPlanString = response.readEntity(String.class);
+    logger.info(queryPlanString);
+    QueryPlan queryPlan = (QueryPlan) Util.getObject(queryPlanString, QueryPlan.class);
+    return queryPlan;
+  }
+
+  public QueryPlan explainAndPrepareQuery(String queryString, String sessionHandleString) throws
+      JAXBException, InstantiationException, IllegalAccessException, 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 {
+    return explainAndPrepareQuery(queryString, sessionHandleString);
+  }
+
+  /**
+   * Get the Result set
+   *
+   * @param queryHandle
+   * @param fromIndex
+   * @param fetchSize
+   * @param sessionHandleString
+   * @return the query Result
+   */
+  public QueryResult getResultSet(QueryHandle queryHandle, String fromIndex, String fetchSize,
+      String sessionHandleString) throws JAXBException, InstantiationException, IllegalAccessException, 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);
+    AssertUtil.assertSucceededResponse(response);
+    logger.info(response);
+    String queryResultString = response.readEntity(String.class);
+    logger.info(queryResultString);
+    QueryResult queryResult = (QueryResult) Util.getObject(queryResultString, QueryResult.class);
+    return queryResult;
+  }
+
+  public QueryResult getResultSet(QueryHandle queryHandle, String fromIndex, String fetchSize) throws
+      JAXBException, InstantiationException, IllegalAccessException, LensException {
+    return getResultSet(queryHandle, fromIndex, fetchSize, sessionHandleString);
+  }
+
+  public QueryResult getResultSet(QueryHandle queryHandle) throws
+      JAXBException, InstantiationException, IllegalAccessException, LensException {
+    return getResultSet(queryHandle, "0", "100", sessionHandleString);
+  }
+
+  /**
+   * Get the HTTP result set
+   *
+   * @param queryHandle
+   * @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);
+    AssertUtil.assertSucceededResponse(response);
+    logger.info(response);
+    String queryResultString = response.readEntity(String.class);
+    logger.info(queryResultString);
+    QueryResult queryResult = (QueryResult) Util.getObject(queryResultString, QueryResult.class);
+    return queryResult;
+  }
+
+  /**
+   * Execute prepared Query
+   *
+   * @param queryHandle
+   * @param sessionHandleString
+   * @param conf
+   * @return the query Handle
+   */
+
+  public QueryHandle executePreparedQuery(QueryPrepareHandle queryHandle, String sessionHandleString,
+      String conf) throws InstantiationException, IllegalAccessException, JAXBException, 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());
+    String queryHandleString = response.readEntity(String.class);
+    AssertUtil.assertSucceededResponse(response);
+    logger.info(queryHandleString);
+    QueryHandle handle = (QueryHandle) Util.getObject(queryHandleString, QueryHandle.class);
+    return handle;
+  }
+
+  public QueryHandle executePreparedQuery(QueryPrepareHandle queryHandle, String sessionHandleString) throws
+      InstantiationException, IllegalAccessException, JAXBException, 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 {
+    return executePreparedQuery(queryHandle, sessionHandleString);
+  }
+
+  /**
+   * Execute prepared Query with timeout
+   *
+   * @param queryHandle
+   * @param timeout
+   * @param sessionHandleString
+   * @param conf
+   * @return the query Handle with result set
+   */
+
+  public QueryHandleWithResultSet executePreparedQueryTimeout(QueryPrepareHandle queryHandle, String timeout,
+      String sessionHandleString, String conf) throws InstantiationException, IllegalAccessException,
+      JAXBException, LensException {
+    FormBuilder formData = new FormBuilder();
+    formData.add("sessionid", sessionHandleString);
+    formData.add("prepareHandle", queryHandle.toString());
+    formData.add("operation", "EXECUTE_WITH_TIMEOUT");
+    formData.add("conf", conf);
+    if (timeout != null) {
+      formData.add("timeoutmillis", timeout);
+    }
+    Response response = this.exec("post", "/queryapi/preparedqueries/" + queryHandle.toString(), servLens, null, null,
+        MediaType.MULTIPART_FORM_DATA_TYPE, MediaType.APPLICATION_XML, formData.getForm());
+    String queryHandleString = response.readEntity(String.class);
+    AssertUtil.assertSucceededResponse(response);
+    logger.info(queryHandleString);
+    QueryHandleWithResultSet handle = (QueryHandleWithResultSet) Util
+        .getObject(queryHandleString, QueryHandleWithResultSet.class);
+    return handle;
+  }
+
+  public QueryHandleWithResultSet executePreparedQueryTimeout(QueryPrepareHandle queryHandle, String timeout,
+      String sessionHandleString) throws InstantiationException, IllegalAccessException, JAXBException, 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 {
+    return executePreparedQueryTimeout(queryHandle, timeout, sessionHandleString);
+  }
+
+  public QueryHandleWithResultSet executePreparedQueryTimeout(QueryPrepareHandle queryHandle) throws
+      InstantiationException, IllegalAccessException, JAXBException, LensException {
+    return executePreparedQueryTimeout(queryHandle, null);
+  }
+
+  /**
+   * Submit prepared Query
+   *
+   * @param queryString
+   * @param sessionHandleString
+   * @param conf
+   * @return the query Prepare Handle
+   */
+
+  public QueryPrepareHandle submitPreparedQuery(String queryString, String queryName, String sessionHandleString,
+      String conf) throws JAXBException, InstantiationException, IllegalAccessException, LensException {
+    FormBuilder formData = new FormBuilder();
+    formData.add("sessionid", sessionHandleString);
+    formData.add("query", queryString);
+    formData.add("operation", "PREPARE");
+    formData.add("conf", conf);
+    if (queryName != null) {
+      formData.add("queryName", queryName);
+    }
+    Response response = this
+        .exec("post", "/queryapi/preparedqueries", servLens, null, null, MediaType.MULTIPART_FORM_DATA_TYPE,
+            MediaType.APPLICATION_XML, formData.getForm());
+    String queryHandleString = response.readEntity(String.class);
+    logger.info(queryHandleString);
+    AssertUtil.assertSucceededResponse(response);
+    QueryPrepareHandle queryHandle = (QueryPrepareHandle) Util.getObject(queryHandleString, QueryPrepareHandle.class);
+    return queryHandle;
+  }
+
+  public QueryPrepareHandle submitPreparedQuery(String queryString, String queryName, String sessionHandleString) throws
+      JAXBException, InstantiationException, IllegalAccessException, 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 {
+    return submitPreparedQuery(queryString, queryName, sessionHandleString);
+  }
+
+  public QueryPrepareHandle submitPreparedQuery(String queryString) throws
+      JAXBException, InstantiationException, IllegalAccessException, LensException {
+    return submitPreparedQuery(queryString, null);
+  }
+
+  /**
+   * Destroy prepared Query
+   *
+   * @param queryPreparedHandle
+   * @param sessionHandleString
+   */
+
+  public void destoryPreparedQueryByHandle(QueryPrepareHandle queryPreparedHandle, String sessionHandleString) throws
+      JAXBException, LensException {
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    Response response = this
+        .exec("delete", QueryURL.PREPAREDQUERY_URL + "/" + queryPreparedHandle.toString(), servLens, null, query);
+    logger.info("Response : " + response);
+    AssertUtil.assertSucceededResponse(response);
+  }
+
+  public void destoryPreparedQueryByHandle(QueryPrepareHandle queryPreparedHandle) throws JAXBException, LensException {
+    destoryPreparedQueryByHandle(queryPreparedHandle, sessionHandleString);
+  }
+
+  /**
+   * Get Prepared QueryHandle List
+   *
+   * @param queryName
+   * @param user
+   * @param sessionHandleString
+   * @param fromDate
+   * @param toDate
+   * @return the query Handle
+   */
+
+  public List<QueryPrepareHandle> getPreparedQueryHandleList(String queryName, String user, String sessionHandleString,
+      String fromDate, String toDate) throws InstantiationException, IllegalAccessException {
+    MapBuilder queryList = new MapBuilder("sessionid", sessionHandleString);
+    if (queryName != null) {
+      queryList.put("queryName", queryName);
+    }
+    if (user != null) {
+      queryList.put("user", user);
+    }
+    if (fromDate != null) {
+      queryList.put("fromDate", fromDate);
+    }
+    if (toDate != null) {
+      queryList.put("toDate", toDate);
+    }
+    Response response = this.sendQuery("get", QueryURL.PREPAREDQUERY_URL, queryList);
+    logger.info("Response : " + response);
+    String responseString = response.readEntity(String.class);
+    logger.info(responseString);
+    PrepareQueryHandles result = (PrepareQueryHandles) Util.getObject(responseString, PrepareQueryHandles.class);
+    List<QueryPrepareHandle> list = result.getQueryHandles();
+    return list;
+  }
+
+  public List<QueryPrepareHandle> getPreparedQueryHandleList(String queryName, String user,
+      String sessionHandleString) throws InstantiationException, IllegalAccessException {
+    return getPreparedQueryHandleList(queryName, user, sessionHandleString, null, null);
+  }
+
+  public List<QueryPrepareHandle> getPreparedQueryHandleList(String queryName, String user) throws
+      InstantiationException, IllegalAccessException {
+    return getPreparedQueryHandleList(queryName, user, sessionHandleString);
+  }
+
+  public List<QueryPrepareHandle> getPreparedQueryHandleList(String queryName) throws
+      InstantiationException, IllegalAccessException {
+    return getPreparedQueryHandleList(queryName, null);
+  }
+
+  public List<QueryPrepareHandle> getPreparedQueryHandleList() throws InstantiationException, IllegalAccessException {
+    return getPreparedQueryHandleList(null);
+  }
+
+  /**
+   * Destroy prepared Query
+   *
+   * @param queryName
+   * @param sessionHandleString
+   * @param fromDate
+   * @param toDate
+   */
+
+  public void destroyPreparedQuery(String queryName, String user, String sessionHandleString, String fromDate,
+      String toDate) throws JAXBException, LensException {
+
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    if (queryName != null) {
+      query.put("queryName", queryName);
+    }
+    if (user != null) {
+      query.put("user", user);
+    }
+    if (fromDate != null) {
+      query.put("fromDate", fromDate);
+    }
+    if (toDate != null) {
+      query.put("toDate", toDate);
+    }
+
+    Response response = this.exec("delete", QueryURL.PREPAREDQUERY_URL, servLens, null, query);
+    logger.info("Response : " + response);
+    AssertUtil.assertSucceededResponse(response);
+  }
+
+  public void destroyPreparedQuery(String queryName, String user, String sessionHandleString) throws
+      JAXBException, LensException {
+    destroyPreparedQuery(queryName, user, sessionHandleString, null, null);
+  }
+
+  public void destroyPreparedQuery(String queryName, String user) throws JAXBException, LensException {
+    destroyPreparedQuery(queryName, user, sessionHandleString);
+  }
+
+  public void destroyPreparedQuery(String queryName) throws JAXBException, LensException {
+    destroyPreparedQuery(queryName, null);
+  }
+
+  public void destroyPreparedQuery() throws JAXBException, LensException {
+    destroyPreparedQuery(null);
+  }
+
+  /**
+   * Get prepared Query
+   *
+   * @param queryPrepareHandle
+   * @param sessionHandleString
+   * @return the client response
+   */
+
+  public Response getPreparedQuery(QueryPrepareHandle queryPrepareHandle, String sessionHandleString) {
+
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    Response response = this
+        .exec("get", QueryURL.PREPAREDQUERY_URL + "/" + queryPrepareHandle.toString(), servLens, null, query);
+    return response;
+  }
+
+  public Response getPreparedQuery(QueryPrepareHandle queryPrepareHandle) {
+    return getPreparedQuery(queryPrepareHandle, sessionHandleString);
+  }
+
+  /**
+   * List Query Handle
+   *
+   * @param queryName
+   * @param state
+   * @param user
+   * @param sessionHandleString
+   * @param fromDate
+   * @param toDate
+   * @return the query Handle list
+   */
+  public List<QueryHandle> getQueryHandleList(String queryName, String state, String user, String sessionHandleString,
+      String fromDate, String toDate) throws InstantiationException, IllegalAccessException {
+    MapBuilder queryList = new MapBuilder("sessionid", sessionHandleString);
+    if (queryName != null) {
+      queryList.put("queryName", queryName);
+    }
+    if (state != null) {
+      queryList.put("state", state);
+    }
+    if (user != null) {
+      queryList.put("user", user);
+    }
+    if (fromDate != null) {
+      queryList.put("fromDate", fromDate);
+    }
+    if (toDate != null) {
+      queryList.put("toDate", toDate);
+    }
+    Response response = this.sendQuery("get", QueryURL.QUERY_URL, queryList);
+    logger.info("Response : " + response);
+    String responseString = response.readEntity(String.class);
+    QueryHandles result = (QueryHandles) Util.getObject(responseString, QueryHandles.class);
+    List<QueryHandle> list = result.getQueryHandles();
+    return list;
+  }
+
+  public List<QueryHandle> getQueryHandleList(String queryName, String state, String user,
+      String sessionHandleString) throws InstantiationException, IllegalAccessException {
+    return getQueryHandleList(queryName, state, user, sessionHandleString, null, null);
+  }
+
+  public List<QueryHandle> getQueryHandleList(String queryName, String state, String user) throws
+      InstantiationException, IllegalAccessException {
+    return getQueryHandleList(queryName, state, user, sessionHandleString);
+  }
+
+  public List<QueryHandle> getQueryHandleList(String queryName, String state) throws
+      InstantiationException, IllegalAccessException {
+    return getQueryHandleList(queryName, state, null);
+  }
+
+  public List<QueryHandle> getQueryHandleList(String queryName) throws InstantiationException, IllegalAccessException {
+    return getQueryHandleList(queryName, null);
+  }
+
+  public List<QueryHandle> getQueryHandleList() throws InstantiationException, IllegalAccessException {
+    return getQueryHandleList(null);
+  }
+
+  /**
+   * Wait for Completion
+   *
+   * @param sessionHandleString
+   * @param queryHandle
+   * @return the lens query
+   */
+
+  public LensQuery waitForCompletion(String sessionHandleString, QueryHandle queryHandle) throws
+      JAXBException, InterruptedException, InstantiationException, IllegalAccessException, LensException {
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    Response response = this.exec("get", QueryURL.QUERY_URL + "/" + queryHandle.toString(), servLens, null, query);
+    AssertUtil.assertSucceededResponse(response);
+    String responseString = response.readEntity(String.class);
+    LensQuery lensQuery = (LensQuery) Util.getObject(responseString, LensQuery.class);
+    while (!lensQuery.getStatus().finished()) {
+      Thread.sleep(1000);
+      logger.info("Waiting...");
+      response = this.exec("get", QueryURL.QUERY_URL + "/" + queryHandle.toString(), servLens, null, query);
+      lensQuery = (LensQuery) Util.getObject(response.readEntity(String.class), LensQuery.class);
+    }
+    logger.info(lensQuery.getStatus().getStatusMessage());
+    return lensQuery;
+  }
+
+  public LensQuery waitForCompletion(QueryHandle queryHandle) throws
+      JAXBException, InterruptedException, InstantiationException, IllegalAccessException, LensException {
+    return waitForCompletion(sessionHandleString, queryHandle);
+  }
+
+  /**
+   * Wait for Query to run
+   *
+   * @param queryHandle
+   * @param sessionHandleString
+   * @return the query status
+   */
+
+  public QueryStatus waitForQueryToRun(QueryHandle queryHandle, String sessionHandleString) throws
+      JAXBException, InterruptedException, InstantiationException, IllegalAccessException, LensException {
+    QueryStatus queryStatus = getQueryStatus(sessionHandleString, queryHandle);
+    while (queryStatus.getStatus() == QueryStatus.Status.QUEUED) {
+      logger.info("Waiting for Query to be in Running Phase");
+      Thread.sleep(1000);
+      queryStatus = getQueryStatus(sessionHandleString, queryHandle);
+    }
+    return queryStatus;
+  }
+
+  public QueryStatus waitForQueryToRun(QueryHandle queryHandle) throws
+      JAXBException, InterruptedException, InstantiationException, IllegalAccessException, LensException {
+    return waitForQueryToRun(queryHandle, sessionHandleString);
+  }
+
+  /**
+   * Get Query Status
+   *
+   * @param sessionHandleString
+   * @param queryHandle
+   * @return the query Status
+   */
+
+  public QueryStatus getQueryStatus(String sessionHandleString, QueryHandle queryHandle) throws
+      JAXBException, InstantiationException, IllegalAccessException, LensException {
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    Response response = this.exec("get", QueryURL.QUERY_URL + "/" + queryHandle.toString(), servLens, null, query);
+    logger.info("Response : " + response);
+    AssertUtil.assertSucceededResponse(response);
+    LensQuery lensQuery = (LensQuery) Util.getObject(response.readEntity(String.class), LensQuery.class);
+    QueryStatus qStatus = lensQuery.getStatus();
+    logger.info("Query Status : " + qStatus);
+    return qStatus;
+  }
+
+  public QueryStatus getQueryStatus(QueryHandle queryHandle) throws
+      JAXBException, InstantiationException, IllegalAccessException, LensException {
+    return getQueryStatus(sessionHandleString, queryHandle);
+  }
+
+  /**
+   * Kill Query by QueryHandle
+   *
+   * @param sessionHandleString
+   * @param queryHandle
+   */
+
+  public void killQueryByQueryHandle(String sessionHandleString, QueryHandle queryHandle) throws
+      JAXBException, LensException {
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    Response response = this.exec("delete", QueryURL.QUERY_URL + "/" + queryHandle.toString(), servLens, null, query);
+    logger.info("Response : " + response);
+    AssertUtil.assertSucceededResponse(response);
+  }
+
+  public void killQueryByQueryHandle(QueryHandle queryHandle) throws JAXBException, LensException {
+    killQueryByQueryHandle(sessionHandleString, queryHandle);
+  }
+
+  /**
+   * Kill Query
+   *
+   * @param queryName
+   * @param state
+   * @param user
+   * @param sessionHandleString
+   * @param fromDate
+   * @param toDate
+   */
+
+  public void killQuery(String queryName, String state, String user, String sessionHandleString, String fromDate,
+      String toDate) throws JAXBException, LensException {
+
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    if (queryName != null) {
+      query.put("queryName", queryName);
+    }
+
+    if (state != null) {
+      query.put("state", state);
+    }
+
+    if (user != null) {
+      query.put("user", user);
+    }
+
+    if (fromDate != null) {
+      query.put("fromDate", fromDate);
+    }
+
+    if (toDate != null) {
+      query.put("toDate", toDate);
+    }
+
+    Response response = this.exec("delete", QueryURL.QUERY_URL, servLens, null, query);
+    logger.info("Response : " + response);
+    AssertUtil.assertSucceededResponse(response);
+  }
+
+  public void killQuery(String queryName, String state, String user, String sessionHandleString) throws
+      JAXBException, LensException {
+    killQuery(queryName, state, user, sessionHandleString, null, null);
+  }
+
+  public void killQuery(String queryName, String state, String user) throws JAXBException, LensException {
+    killQuery(queryName, state, user, sessionHandleString);
+  }
+
+  public void killQuery(String queryName, String state) throws JAXBException, LensException {
+    killQuery(queryName, state, null);
+  }
+
+  public void killQuery(String queryName) throws JAXBException, LensException {
+    killQuery(queryName, null);
+  }
+
+  public void killQuery() throws JAXBException, LensException {
+    killQuery(null);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/6a4b2470/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
new file mode 100644
index 0000000..2aecbfd
--- /dev/null
+++ b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/ServiceManagerHelper.java
@@ -0,0 +1,292 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+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;
+import java.util.Properties;
+
+import javax.ws.rs.client.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+
+import javax.xml.bind.JAXBException;
+
+import org.apache.lens.api.APIResult;
+import org.apache.lens.regression.core.constants.SessionURL;
+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.apache.log4j.Logger;
+
+import org.glassfish.jersey.media.multipart.FormDataMultiPart;
+import org.glassfish.jersey.media.multipart.MultiPartFeature;
+
+
+public abstract class ServiceManagerHelper {
+
+  private static final String LENS_BASE_URL = "lens.baseurl";
+  private static final String LENS_ADMIN_URL = "lens.adminurl";
+  private static final String LENS_USERNAME = "lens.username";
+  private static final String LENS_PASSWORD = "lens.password";
+  private static final String LENS_SERVER_DIR = "lens.server.dir";
+  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 String sessionHandleString;
+  private static WebTarget servLens;
+
+  protected String baseUrl;
+  protected String adminUrl;
+  protected String userName;
+  protected String password;
+  protected String serverDir;
+  protected String clientDir;
+  protected String serverHdfsUrl;
+  protected String currentDB;
+
+  private Logger logger = Logger.getLogger(ServiceManagerHelper.class);
+
+  public ServiceManagerHelper(String envFileName) {
+    Properties prop = Util.getPropertiesObj(envFileName);
+    this.baseUrl = prop.getProperty(LENS_BASE_URL);
+    this.adminUrl = prop.getProperty(LENS_ADMIN_URL);
+    this.userName = prop.getProperty(LENS_USERNAME);
+    this.password = prop.getProperty(LENS_PASSWORD);
+    this.serverDir = prop.getProperty(LENS_SERVER_DIR);
+    this.clientDir = prop.getProperty(LENS_CLIENT_DIR);
+    this.serverHdfsUrl = prop.getProperty(LENS_SERVER_HDFS_URL);
+    this.currentDB = prop.getProperty(LENS_CURRENT_DB);
+  }
+
+  public ServiceManagerHelper() {
+
+  }
+
+  public static WebTarget init() {
+    Client client = ClientBuilder.newBuilder().register(MultiPartFeature.class).build();
+    String baseUri = Util.getProperty("lens.baseurl");
+    servLens = client.target(UriBuilder.fromUri(baseUri).build());
+    return servLens;
+  }
+
+  public static WebTarget getServerLens() {
+    return servLens;
+  }
+
+  public static String getSessionHandle() {
+    return sessionHandleString;
+  }
+
+  public static URI getServiceURI(String baseUri) {
+    return UriBuilder.fromUri(baseUri).build();
+  }
+
+  public String getBaseUrl() {
+    return baseUrl;
+  }
+
+  public String getAdminUrl() {
+    return adminUrl;
+  }
+
+  public String getUserName() {
+    return userName;
+  }
+
+  public String getPassword() {
+    return password;
+  }
+
+  public String getServerDir() {
+    return serverDir;
+  }
+
+  public String getClientDir() {
+    return clientDir;
+  }
+
+  public String getServerHdfsUrl() {
+    return serverHdfsUrl;
+  }
+
+  public String getSessionHandleString() {
+    return sessionHandleString;
+  }
+
+  public String getCurrentDB() {
+    return currentDB;
+  }
+
+  public String openSession(String database) throws JAXBException, LensException {
+    FormBuilder formData = new FormBuilder();
+    formData.add("username", this.getUserName());
+    formData.add("password", this.getPassword());
+    if (database != null) {
+      formData.add("database", database);
+    }
+    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);
+    sessionHandleString = response.readEntity(String.class);
+    logger.info("Session Handle String" + sessionHandleString);
+    return sessionHandleString;
+  }
+
+  public String openSession() throws JAXBException, LensException {
+    return openSession(null);
+  }
+
+  public void closeSession() throws JAXBException, LensException {
+    MapBuilder query = new MapBuilder("sessionid", sessionHandleString);
+    Response response = this.exec("delete", SessionURL.SESSION_BASE_URL, ServiceManagerHelper.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() == 200) {
+      throw new LensException("Status code should be 200");
+    }
+    if (result.getMessage() == null) {
+      throw new LensException("Status message is null");
+    }
+    logger.info("Closed Session : " + sessionHandleString);
+  }
+
+  public <T> Response exec(String functionName, String path, WebTarget service, FormDataMultiPart headers,
+      MapBuilder queryParams, MediaType inputMediaType, String outputMediaType) {
+    return exec(functionName, path, service, headers, queryParams, inputMediaType, outputMediaType, null);
+  }
+
+  public <T> Response exec(String functionName, String path, WebTarget service, FormDataMultiPart headers,
+      MapBuilder queryParams, MediaType inputMediaType) {
+    return exec(functionName, path, service, headers, queryParams, inputMediaType, null, null);
+  }
+
+  public <T> Response exec(String functionName, String path, WebTarget service, FormDataMultiPart headers,
+      MapBuilder queryParams) {
+    return exec(functionName, path, service, headers, queryParams, null, null, null);
+  }
+
+  public <T> Object exec(String functionName, String path, WebTarget service, FormDataMultiPart headers,
+      MapBuilder queryParams, MediaType inputMediaType, String outputMediaType, Class responseClass, T inputObject) {
+
+    Object result;
+    WebTarget builder = null;
+    String className = this.getClass().getName();
+
+    if (outputMediaType == null) {
+      outputMediaType = MediaType.WILDCARD;
+    }
+    if (inputMediaType == null) {
+      inputMediaType = MediaType.WILDCARD_TYPE;
+    }
+
+    builder = service.path(path);
+    if (queryParams != null) {
+      for (Map.Entry<String, String> queryMapEntry : queryParams.getMap().entrySet()) {
+        builder = builder.queryParam(queryMapEntry.getKey(), queryMapEntry.getValue());
+      }
+    }
+
+    Invocation.Builder build = builder.request(outputMediaType);
+
+    functionName = "exec" + functionName.toUpperCase();
+
+    try {
+      Class methodClass = Class.forName(className);
+      Object methodObject = methodClass.newInstance();
+
+      Method method = methodObject.getClass()
+          .getMethod(functionName, Invocation.Builder.class, inputMediaType.getClass(), responseClass.getClass(),
+              Object.class);
+      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();
+    }
+
+  }
+
+  public <T> Response exec(String functionName, String path, WebTarget service, FormDataMultiPart headers,
+      MapBuilder queryParams, MediaType inputMediaType, String outputMediaType, T inputObject) {
+
+    Class responseClass = Response.class;
+    Response cl = null;
+    try {
+      cl = (Response) exec(functionName, path, service, headers, queryParams, inputMediaType, outputMediaType,
+          responseClass, inputObject);
+    } catch (Exception e) {
+      System.out.println(e);
+    }
+    return cl;
+  }
+
+  public <T> Object execPUT(Invocation.Builder builder, MediaType inputMediaType, Class<?> responseClass,
+      T inputObject) {
+    return builder.put(Entity.entity(inputObject, inputMediaType), responseClass);
+  }
+
+  public <T> Object execGET(Invocation.Builder builder, MediaType inputMediaType, Class<?> responseClass,
+      T inputObject) {
+    return builder.get(responseClass);
+  }
+
+  public <T> Object execPOST(Invocation.Builder builder, MediaType inputMediaType, Class<?> responseClass,
+      T inputObject) {
+    return builder.post(Entity.entity(inputObject, inputMediaType), responseClass);
+  }
+
+  public <T> Object execDELETE(Invocation.Builder builder, MediaType inputMediaType, Class<?> responseClass,
+      T inputObject) {
+    return builder.delete(responseClass);
+  }
+
+  public Response sendForm(String methodName, String url, FormBuilder formData) {
+    Response response = this
+        .exec(methodName, url, servLens, null, null, MediaType.MULTIPART_FORM_DATA_TYPE, MediaType.APPLICATION_XML,
+            formData.getForm());
+    return response;
+  }
+
+  public Response sendQuery(String methodName, String url, MapBuilder query) {
+    Response response = this.exec(methodName, url, servLens, null, query);
+    return response;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/6a4b2470/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
new file mode 100644
index 0000000..ca59e3e
--- /dev/null
+++ b/lens-regression/src/main/java/org/apache/lens/regression/core/helpers/SessionHelper.java
@@ -0,0 +1,198 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.regression.core.helpers;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.client.WebTarget;
+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.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.apache.log4j.Logger;
+
+
+
+
+public class SessionHelper extends ServiceManagerHelper {
+
+  private static Logger logger = Logger.getLogger(SessionHelper.class);
+
+  private WebTarget servLens = ServiceManagerHelper.getServerLens();
+  private String sessionHandleString = ServiceManagerHelper.getSessionHandle();
+
+  public SessionHelper() {
+  }
+
+  public SessionHelper(String envFileName) {
+    super(envFileName);
+  }
+
+  /**
+   * Open a New Session
+   *
+   * @param userName
+   * @param password
+   * @param database
+   * @return the sessionHandle String
+   */
+
+  public String openNewSession(String userName, String password, String database) throws JAXBException, LensException {
+    FormBuilder formData = new FormBuilder();
+    formData.add("username", userName);
+    formData.add("password", password);
+    if (database != null) {
+      formData.add("database", database);
+    }
+    Response response = this
+        .exec("post", "/session", servLens, null, null, MediaType.MULTIPART_FORM_DATA_TYPE, MediaType.APPLICATION_XML,
+            formData.getForm());
+    AssertUtil.assertSucceededResponse(response);
+    String newSessionHandleString = response.readEntity(String.class);
+    logger.info("Session Handle String" + newSessionHandleString);
+    return newSessionHandleString;
+  }
+
+  public String openNewSession(String userName, String password) throws JAXBException, LensException {
+    return openNewSession(userName, password, null);
+  }
+
+  /**
+   * 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() == 200) {
+      throw new LensException("Status code should be 200");
+    }
+    if (result.getMessage() == null) {
+      throw new LensException("Status message is null");
+    }
+    logger.info("Closed Session : " + sessionHandleString);
+  }
+
+  /**
+   * Set and Validate Session Params
+   *
+   * @param sessionHandleString
+   * @param param
+   * @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);
+    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);
+    logger.info(responseString);
+    HashMap<String, String> map = Util.stringListToMap(responseString);
+    if (!map.get(param).equals(value)) {
+      throw new LensException("Could not set property");
+    }
+    logger.info("Added property " + param + " = " + value);
+  }
+
+  public void setAndValidateParam(String param, String value) throws Exception {
+    setAndValidateParam(sessionHandleString, param, value);
+  }
+
+  public void setAndValidateParam(Map<String, String> map, String sessionHandleString) throws Exception {
+    for (Map.Entry<String, String> entry : map.entrySet()) {
+      setAndValidateParam(sessionHandleString, entry.getKey(), entry.getValue());
+    }
+  }
+
+  public void setAndValidateParam(Map<String, String> map) throws Exception {
+    setAndValidateParam(map, sessionHandleString);
+  }
+
+  /**
+   * Add resources to a session
+   *
+   * @param path
+   * @param sessionHandleString
+   */
+  public void addResourcesJar(String path, String sessionHandleString) throws JAXBException, LensException {
+    logger.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());
+    logger.info("Response : " + response);
+    AssertUtil.assertSucceeded(response);
+  }
+
+  public void addResourcesJar(String path) throws JAXBException, LensException {
+    addResourcesJar(path, sessionHandleString);
+  }
+
+  /**
+   * Remove resources from a session
+   *
+   * @param path
+   * @param sessionHandleString
+   */
+  public void removeResourcesJar(String path, String sessionHandleString) throws JAXBException, LensException {
+    logger.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());
+    logger.info("Response : " + response);
+    AssertUtil.assertSucceeded(response);
+  }
+
+  public void removeResourcesJar(String path) throws JAXBException, LensException {
+    removeResourcesJar(path, sessionHandleString);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/6a4b2470/lens-regression/src/main/java/org/apache/lens/regression/core/type/FormBuilder.java
----------------------------------------------------------------------
diff --git a/lens-regression/src/main/java/org/apache/lens/regression/core/type/FormBuilder.java b/lens-regression/src/main/java/org/apache/lens/regression/core/type/FormBuilder.java
new file mode 100644
index 0000000..a167441
--- /dev/null
+++ b/lens-regression/src/main/java/org/apache/lens/regression/core/type/FormBuilder.java
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.regression.core.type;
+
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.ws.rs.core.MediaType;
+
+
+import org.glassfish.jersey.media.multipart.FormDataMultiPart;
+
+
+public class FormBuilder {
+  private FormDataMultiPart formData;
+
+  public FormBuilder() {
+    formData = new FormDataMultiPart();
+  }
+
+  public FormBuilder(FormDataMultiPart form) {
+    formData = new FormDataMultiPart();
+    formData = form;
+  }
+
+  public FormBuilder(String fieldName, String value) {
+    formData = new FormDataMultiPart();
+    formData.field(fieldName, value);
+  }
+
+  public FormBuilder(Properties newProperty) {
+    formData = new FormDataMultiPart();
+    Enumeration<?> e = newProperty.propertyNames();
+    while (e.hasMoreElements()) {
+      String key = (String) e.nextElement();
+      formData.field(key, newProperty.getProperty(key));
+    }
+  }
+
+  public FormBuilder(Map<String, String> map) {
+    formData = new FormDataMultiPart();
+    for (Map.Entry<String, String> entry : map.entrySet()) {
+      formData.field(entry.getKey(), entry.getValue());
+    }
+  }
+
+  public void add(String fieldName, String value) {
+    formData.field(fieldName, value);
+  }
+
+  public void add(String fieldName, Object value, MediaType mediaType) {
+    formData.field(fieldName, value, mediaType);
+  }
+
+  public void addFile(String fieldName, String filename) {
+  }
+
+  public FormDataMultiPart getForm() {
+    return formData;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/6a4b2470/lens-regression/src/main/java/org/apache/lens/regression/core/type/MapBuilder.java
----------------------------------------------------------------------
diff --git a/lens-regression/src/main/java/org/apache/lens/regression/core/type/MapBuilder.java b/lens-regression/src/main/java/org/apache/lens/regression/core/type/MapBuilder.java
new file mode 100644
index 0000000..eae8a06
--- /dev/null
+++ b/lens-regression/src/main/java/org/apache/lens/regression/core/type/MapBuilder.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.regression.core.type;
+
+import java.util.HashMap;
+
+public class MapBuilder {
+  private HashMap<String, String> map;
+
+  public MapBuilder() {
+    map = new HashMap<String, String>();
+  }
+
+  public MapBuilder(HashMap<String, String> h) {
+    map = h;
+  }
+
+  public MapBuilder(String key, String value) {
+    map = new HashMap<String, String>();
+    map.put(key, value);
+  }
+
+  public MapBuilder(String[] keys, String[] values) {
+    map = new HashMap<String, String>();
+    for (int i = 0; i < keys.length; i++) {
+      map.put(keys[i], values[i]);
+    }
+  }
+
+  public void put(String key, String value) {
+    map.put(key, value);
+  }
+
+  public String get(String key) {
+    return map.get(key);
+  }
+
+  public void remove(String key) {
+    map.remove(key);
+  }
+
+  public void clear() {
+    map.clear();
+  }
+
+  public HashMap<String, String> getMap() {
+    return map;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/6a4b2470/lens-regression/src/main/java/org/apache/lens/regression/core/type/PrepareQueryHandles.java
----------------------------------------------------------------------
diff --git a/lens-regression/src/main/java/org/apache/lens/regression/core/type/PrepareQueryHandles.java b/lens-regression/src/main/java/org/apache/lens/regression/core/type/PrepareQueryHandles.java
new file mode 100644
index 0000000..f04dfb8
--- /dev/null
+++ b/lens-regression/src/main/java/org/apache/lens/regression/core/type/PrepareQueryHandles.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.regression.core.type;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.lens.api.query.QueryPrepareHandle;
+
+
+
+@XmlRootElement(name = "queryPrepareHandles")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class PrepareQueryHandles {
+  @XmlElement(name = "queryPrepareHandle")
+  private List<QueryPrepareHandle> queryPrepareHandles = null;
+
+  public List<QueryPrepareHandle> getQueryHandles() {
+    return queryPrepareHandles;
+  }
+
+  public void setPreparedQueryHandles(List<QueryPrepareHandle> queryPrepareHandles) {
+    this.queryPrepareHandles = queryPrepareHandles;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/6a4b2470/lens-regression/src/main/java/org/apache/lens/regression/core/type/QueryHandles.java
----------------------------------------------------------------------
diff --git a/lens-regression/src/main/java/org/apache/lens/regression/core/type/QueryHandles.java b/lens-regression/src/main/java/org/apache/lens/regression/core/type/QueryHandles.java
new file mode 100644
index 0000000..94d96b2
--- /dev/null
+++ b/lens-regression/src/main/java/org/apache/lens/regression/core/type/QueryHandles.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.regression.core.type;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.lens.api.query.QueryHandle;
+
+
+
+@XmlRootElement(name = "queryHandles")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class QueryHandles {
+  @XmlElement(name = "queryHandle")
+  private List<QueryHandle> queryHandles = null;
+
+  public List<QueryHandle> getQueryHandles() {
+    return queryHandles;
+  }
+
+  public void setQueryHandles(List<QueryHandle> queryHandles) {
+    this.queryHandles = queryHandles;
+  }
+}