You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by am...@apache.org on 2015/02/05 07:01:45 UTC
[02/10] incubator-lens git commit: LENS-249 : Fix check style issues
in lens-server module (Rajat Khandelwal via amareshwari)
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/query/TestLensDAO.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/TestLensDAO.java b/lens-server/src/test/java/org/apache/lens/server/query/TestLensDAO.java
index 1dd53c6..ec2656f 100644
--- a/lens-server/src/test/java/org/apache/lens/server/query/TestLensDAO.java
+++ b/lens-server/src/test/java/org/apache/lens/server/query/TestLensDAO.java
@@ -18,7 +18,11 @@
*/
package org.apache.lens.server.query;
-import org.apache.hadoop.conf.Configuration;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.ws.rs.core.Application;
+
import org.apache.lens.api.LensConf;
import org.apache.lens.api.LensSessionHandle;
import org.apache.lens.api.query.LensQuery;
@@ -28,15 +32,12 @@ import org.apache.lens.server.LensJerseyTest;
import org.apache.lens.server.LensServices;
import org.apache.lens.server.api.query.FinishedLensQuery;
import org.apache.lens.server.api.query.QueryContext;
-import org.apache.lens.server.query.QueryApp;
-import org.apache.lens.server.query.QueryExecutionServiceImpl;
+
+import org.apache.hadoop.conf.Configuration;
+
import org.testng.Assert;
import org.testng.annotations.Test;
-import javax.ws.rs.core.Application;
-import java.util.HashMap;
-import java.util.List;
-
/**
* The Class TestLensDAO.
*/
@@ -46,8 +47,7 @@ public class TestLensDAO extends LensJerseyTest {
/**
* Test lens server dao.
*
- * @throws Exception
- * the exception
+ * @throws Exception the exception
*/
@Test
public void testLensServerDAO() throws Exception {
@@ -55,7 +55,7 @@ public class TestLensDAO extends LensJerseyTest {
// Test insert query
QueryContext queryContext = service.createContext("SELECT ID FROM testTable", "foo@localhost", new LensConf(),
- new Configuration());
+ new Configuration());
long submissionTime = queryContext.getSubmissionTime();
queryContext.setQueryName("daoTestQuery1");
FinishedLensQuery finishedLensQuery = new FinishedLensQuery(queryContext);
@@ -69,27 +69,27 @@ public class TestLensDAO extends LensJerseyTest {
LensSessionHandle session = service.openSession("foo@localhost", "bar", new HashMap<String, String>());
List<QueryHandle> persistedHandles = service.lensServerDao.findFinishedQueries(null, null, null, submissionTime,
- System.currentTimeMillis());
+ System.currentTimeMillis());
if (persistedHandles != null) {
for (QueryHandle handle : persistedHandles) {
LensQuery query = service.getQuery(session, handle);
if (!handle.getHandleId().toString().equals(finishedHandle)) {
Assert.assertTrue(query.getStatus().isFinished(), query.getQueryHandle() + " STATUS="
- + query.getStatus().getStatus());
+ + query.getStatus().getStatus());
}
}
}
System.out.println("@@ State = " + queryContext.getStatus().getStatus().name());
List<QueryHandle> daoTestQueryHandles = service.lensServerDao.findFinishedQueries(finishedLensQuery.getStatus(),
- queryContext.getSubmittedUser(), "daotestquery1", -1L, Long.MAX_VALUE);
+ queryContext.getSubmittedUser(), "daotestquery1", -1L, Long.MAX_VALUE);
Assert.assertEquals(daoTestQueryHandles.size(), 1);
Assert.assertEquals(daoTestQueryHandles.get(0).getHandleId().toString(), finishedHandle);
}
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#configure()
*/
@Override
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/query/TestQueryService.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/TestQueryService.java b/lens-server/src/test/java/org/apache/lens/server/query/TestQueryService.java
index 1ecd822..9b3ae68 100644
--- a/lens-server/src/test/java/org/apache/lens/server/query/TestQueryService.java
+++ b/lens-server/src/test/java/org/apache/lens/server/query/TestQueryService.java
@@ -18,60 +18,50 @@
*/
package org.apache.lens.server.query;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.*;
import java.io.*;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.io.IOUtils;
-import org.apache.lens.driver.hive.TestHiveDriver;
-import org.apache.lens.server.api.query.QueryContext;
-import org.glassfish.jersey.client.ClientConfig;
-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;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FSDataInputStream;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.lens.api.*;
-import org.apache.lens.api.query.LensPreparedQuery;
-import org.apache.lens.api.query.LensQuery;
-import org.apache.lens.api.query.InMemoryQueryResult;
-import org.apache.lens.api.query.PersistentQueryResult;
-import org.apache.lens.api.query.QueryHandle;
-import org.apache.lens.api.query.QueryHandleWithResultSet;
-import org.apache.lens.api.query.QueryPlan;
-import org.apache.lens.api.query.QueryPrepareHandle;
-import org.apache.lens.api.query.QueryResultSetMetadata;
-import org.apache.lens.api.query.QueryStatus;
+import org.apache.lens.api.APIResult;
+import org.apache.lens.api.LensConf;
+import org.apache.lens.api.LensException;
+import org.apache.lens.api.LensSessionHandle;
+import org.apache.lens.api.query.*;
import org.apache.lens.api.query.QueryStatus.Status;
import org.apache.lens.driver.hive.HiveDriver;
+import org.apache.lens.driver.hive.TestHiveDriver;
import org.apache.lens.server.LensJerseyTest;
import org.apache.lens.server.LensServices;
import org.apache.lens.server.LensTestUtil;
import org.apache.lens.server.api.LensConfConstants;
import org.apache.lens.server.api.driver.LensDriver;
import org.apache.lens.server.api.metrics.MetricsService;
+import org.apache.lens.server.api.query.QueryContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.IOUtils;
+
+import org.glassfish.jersey.client.ClientConfig;
+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;
import org.subethamail.wiser.Wiser;
import org.subethamail.wiser.WiserMessage;
import org.testng.Assert;
@@ -97,9 +87,6 @@ public class TestQueryService extends LensJerseyTest {
/** The lens session id. */
LensSessionHandle lensSessionId;
- /** The nrows. */
- final int NROWS = 10000;
-
/** The wiser. */
private Wiser wiser;
@@ -119,7 +106,7 @@ public class TestQueryService extends LensJerseyTest {
Map<String, String> sessionconf = new HashMap<String, String>();
sessionconf.put("test.session.key", "svalue");
lensSessionId = queryService.openSession("foo@localhost", "bar", sessionconf); // @localhost should be removed
- // automatically
+ // automatically
createTable(testTable);
loadData(testTable, TEST_DATA_FILE);
}
@@ -170,10 +157,8 @@ public class TestQueryService extends LensJerseyTest {
/**
* Creates the table.
*
- * @param tblName
- * the tbl name
- * @throws InterruptedException
- * the interrupted exception
+ * @param tblName the tbl name
+ * @throws InterruptedException the interrupted exception
*/
private void createTable(String tblName) throws InterruptedException {
LensTestUtil.createTable(tblName, target(), lensSessionId);
@@ -182,30 +167,26 @@ public class TestQueryService extends LensJerseyTest {
/**
* Load data.
*
- * @param tblName
- * the tbl name
- * @param TEST_DATA_FILE
- * the test data file
- * @throws InterruptedException
- * the interrupted exception
+ * @param tblName the tbl name
+ * @param testDataFile the test data file
+ * @throws InterruptedException the interrupted exception
*/
- private void loadData(String tblName, final String TEST_DATA_FILE) throws InterruptedException {
- LensTestUtil.loadData(tblName, TEST_DATA_FILE, target(), lensSessionId);
+ private void loadData(String tblName, final String testDataFile) throws InterruptedException {
+ LensTestUtil.loadData(tblName, testDataFile, target(), lensSessionId);
}
/**
* Drop table.
*
- * @param tblName
- * the tbl name
- * @throws InterruptedException
- * the interrupted exception
+ * @param tblName the tbl name
+ * @throws InterruptedException the interrupted exception
*/
private void dropTable(String tblName) throws InterruptedException {
LensTestUtil.dropTable(tblName, target(), lensSessionId);
}
// test get a random query, should return 400
+
/**
* Test get random query.
*/
@@ -220,8 +201,7 @@ public class TestQueryService extends LensJerseyTest {
/**
* Test launch fail.
*
- * @throws InterruptedException
- * the interrupted exception
+ * @throws InterruptedException the interrupted exception
*/
@Test
public void testLaunchFail() throws InterruptedException {
@@ -231,18 +211,19 @@ public class TestQueryService extends LensJerseyTest {
LensConf conf = new LensConf();
final FormDataMultiPart mp = new FormDataMultiPart();
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
- mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID from non_exist_table"));
+ MediaType.APPLICATION_XML_TYPE));
+ mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(),
+ "select ID from non_exist_table"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryHandle handle = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandle.class);
+ QueryHandle.class);
Assert.assertNotNull(handle);
LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
- .get(LensQuery.class);
+ .get(LensQuery.class);
QueryStatus stat = ctx.getStatus();
while (!stat.isFinished()) {
ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request().get(LensQuery.class);
@@ -263,11 +244,11 @@ public class TestQueryService extends LensJerseyTest {
// test with execute async post, get all queries, get query context,
// get wrong uuid query
+
/**
* Test queries api.
*
- * @throws InterruptedException
- * the interrupted exception
+ * @throws InterruptedException the interrupted exception
*/
@Test
public void testQueriesAPI() throws InterruptedException {
@@ -277,26 +258,26 @@ public class TestQueryService extends LensJerseyTest {
conf.addProperty("hive.exec.driver.run.hooks", TestHiveDriver.FailHook.class.getCanonicalName());
final FormDataMultiPart mp = new FormDataMultiPart();
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID from " + testTable));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
long queuedQueries = metricsSvc.getQueuedQueries();
long runningQueries = metricsSvc.getRunningQueries();
long finishedQueries = metricsSvc.getFinishedQueries();
final QueryHandle handle = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandle.class);
+ QueryHandle.class);
Assert.assertNotNull(handle);
// Get all queries
// XML
List<QueryHandle> allQueriesXML = target.queryParam("sessionid", lensSessionId).request(MediaType.APPLICATION_XML)
- .get(new GenericType<List<QueryHandle>>() {
- });
+ .get(new GenericType<List<QueryHandle>>() {
+ });
Assert.assertTrue(allQueriesXML.size() >= 1);
// JSON
@@ -306,8 +287,8 @@ public class TestQueryService extends LensJerseyTest {
// Assert.assertEquals(allQueriesJSON.size(), 1);
// JAXB
List<QueryHandle> allQueries = (List<QueryHandle>) target.queryParam("sessionid", lensSessionId).request()
- .get(new GenericType<List<QueryHandle>>() {
- });
+ .get(new GenericType<List<QueryHandle>>() {
+ });
Assert.assertTrue(allQueries.size() >= 1);
Assert.assertTrue(allQueries.contains(handle));
@@ -316,14 +297,14 @@ public class TestQueryService extends LensJerseyTest {
// String responseJSON = builderjson.get(String.class);
// System.out.println("query JSON:" + responseJSON);
String queryXML = target.path(handle.toString()).queryParam("sessionid", lensSessionId)
- .request(MediaType.APPLICATION_XML).get(String.class);
+ .request(MediaType.APPLICATION_XML).get(String.class);
System.out.println("query XML:" + queryXML);
Response response = target.path(handle.toString() + "001").queryParam("sessionid", lensSessionId).request().get();
Assert.assertEquals(response.getStatus(), 404);
LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
- .get(LensQuery.class);
+ .get(LensQuery.class);
// Assert.assertEquals(ctx.getStatus().getStatus(), QueryStatus.Status.QUEUED);
// wait till the query finishes
@@ -351,19 +332,18 @@ public class TestQueryService extends LensJerseyTest {
conf = new LensConf();
conf.addProperty("my.property", "myvalue");
confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
APIResult updateConf = target.path(handle.toString()).request()
- .put(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class);
+ .put(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class);
Assert.assertEquals(updateConf.getStatus(), APIResult.Status.FAILED);
}
/**
* Test execute without session id.
*
- * @throws Exception
- * the exception
+ * @throws Exception the exception
*/
@Test
public void testExecuteWithoutSessionId() throws Exception {
@@ -378,11 +358,11 @@ public class TestQueryService extends LensJerseyTest {
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID from " + testTable));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
try {
final QueryHandle handle = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandle.class);
+ QueryHandle.class);
Assert.fail("Should have thrown bad request error");
} catch (BadRequestException badReqeust) {
// pass
@@ -390,11 +370,11 @@ public class TestQueryService extends LensJerseyTest {
}
// Test explain query
+
/**
* Test explain query.
*
- * @throws InterruptedException
- * the interrupted exception
+ * @throws InterruptedException the interrupted exception
*/
@Test
public void testExplainQuery() throws InterruptedException {
@@ -402,14 +382,14 @@ public class TestQueryService extends LensJerseyTest {
final FormDataMultiPart mp = new FormDataMultiPart();
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID from " + testTable));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "explain"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(),
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryPlan plan = target.request()
- .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), QueryPlan.class);
+ .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), QueryPlan.class);
Assert.assertEquals(plan.getNumSels(), 1);
Assert.assertEquals(plan.getTablesQueried().size(), 1);
Assert.assertTrue(plan.getTablesQueried().get(0).endsWith(testTable.toLowerCase()));
@@ -420,14 +400,14 @@ public class TestQueryService extends LensJerseyTest {
final FormDataMultiPart mp2 = new FormDataMultiPart();
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID from " + testTable));
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "explain_and_prepare"));
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(),
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryPlan plan2 = ptarget.request().post(Entity.entity(mp2, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryPlan.class);
+ QueryPlan.class);
Assert.assertEquals(plan2.getNumSels(), 1);
Assert.assertEquals(plan2.getTablesQueried().size(), 1);
Assert.assertTrue(plan2.getTablesQueried().get(0).endsWith(testTable.toLowerCase()));
@@ -435,11 +415,11 @@ public class TestQueryService extends LensJerseyTest {
}
// Test explain failure
+
/**
* Test explain failure.
*
- * @throws InterruptedException
- * the interrupted exception
+ * @throws InterruptedException the interrupted exception
*/
@Test
public void testExplainFailure() throws InterruptedException {
@@ -447,38 +427,39 @@ public class TestQueryService extends LensJerseyTest {
final FormDataMultiPart mp = new FormDataMultiPart();
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
- mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select NO_ID from " + testTable));
+ MediaType.APPLICATION_XML_TYPE));
+ mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(),
+ "select NO_ID from " + testTable));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "explain"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(),
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryPlan plan = target.request()
- .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), QueryPlan.class);
+ .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), QueryPlan.class);
Assert.assertTrue(plan.isError());
Assert.assertNotNull(plan.getErrorMsg());
- Assert.assertTrue(plan.getErrorMsg().contains("Invalid table alias or column reference 'NO_ID': " +
- "(possible column names are: id, idstr)"));
+ Assert.assertTrue(plan.getErrorMsg().contains("Invalid table alias or column reference 'NO_ID': "
+ + "(possible column names are: id, idstr)"));
// Test explain and prepare
final WebTarget ptarget = target().path("queryapi/preparedqueries");
final FormDataMultiPart mp2 = new FormDataMultiPart();
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select NO_ID from "
- + testTable));
+ + testTable));
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "explain_and_prepare"));
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(),
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryPlan plan2 = ptarget.request().post(Entity.entity(mp2, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryPlan.class);
+ QueryPlan.class);
Assert.assertTrue(plan2.isError());
Assert.assertNotNull(plan2.getErrorMsg());
Assert.assertNull(plan2.getPrepareHandle());
- Assert.assertTrue(plan.getErrorMsg().contains("Invalid table alias or column reference 'NO_ID': " +
- "(possible column names are: id, idstr)"));
+ Assert.assertTrue(plan.getErrorMsg().contains("Invalid table alias or column reference 'NO_ID': "
+ + "(possible column names are: id, idstr)"));
}
// post to preparedqueries
@@ -487,11 +468,11 @@ public class TestQueryService extends LensJerseyTest {
// update a prepared query
// post to prepared query multiple times
// delete a prepared query
+
/**
* Test prepare query.
*
- * @throws InterruptedException
- * the interrupted exception
+ * @throws InterruptedException the interrupted exception
*/
@Test
public void testPrepareQuery() throws InterruptedException {
@@ -499,30 +480,30 @@ public class TestQueryService extends LensJerseyTest {
final FormDataMultiPart mp = new FormDataMultiPart();
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID from " + testTable));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "prepare"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("queryName").build(), "testQuery1"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(),
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryPrepareHandle pHandle = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryPrepareHandle.class);
+ QueryPrepareHandle.class);
// Get all prepared queries
List<QueryPrepareHandle> allQueries = (List<QueryPrepareHandle>) target.queryParam("sessionid", lensSessionId)
- .queryParam("queryName", "testQuery1").request().get(new GenericType<List<QueryPrepareHandle>>() {
- });
+ .queryParam("queryName", "testQuery1").request().get(new GenericType<List<QueryPrepareHandle>>() {
+ });
Assert.assertTrue(allQueries.size() >= 1);
Assert.assertTrue(allQueries.contains(pHandle));
LensPreparedQuery ctx = target.path(pHandle.toString()).queryParam("sessionid", lensSessionId).request()
- .get(LensPreparedQuery.class);
+ .get(LensPreparedQuery.class);
Assert.assertTrue(ctx.getUserQuery().equalsIgnoreCase("select ID from " + testTable));
Assert.assertTrue(ctx.getDriverQuery().equalsIgnoreCase("select ID from " + testTable));
Assert.assertEquals(ctx.getSelectedDriverClassName(),
- org.apache.lens.driver.hive.HiveDriver.class.getCanonicalName());
+ org.apache.lens.driver.hive.HiveDriver.class.getCanonicalName());
Assert.assertNull(ctx.getConf().getProperties().get("my.property"));
// Update conf for prepared query
@@ -530,48 +511,48 @@ public class TestQueryService extends LensJerseyTest {
LensConf conf = new LensConf();
conf.addProperty("my.property", "myvalue");
confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
APIResult updateConf = target.path(pHandle.toString()).request()
- .put(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class);
+ .put(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class);
Assert.assertEquals(updateConf.getStatus(), APIResult.Status.SUCCEEDED);
ctx = target.path(pHandle.toString()).queryParam("sessionid", lensSessionId).request().get(LensPreparedQuery.class);
Assert.assertEquals(ctx.getConf().getProperties().get("my.property"), "myvalue");
QueryHandle handle1 = target.path(pHandle.toString()).request()
- .post(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), QueryHandle.class);
+ .post(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), QueryHandle.class);
// Override query name
confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("queryName").build(), "testQueryName2"));
// do post once again
QueryHandle handle2 = target.path(pHandle.toString()).request()
- .post(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), QueryHandle.class);
+ .post(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), QueryHandle.class);
Assert.assertNotEquals(handle1, handle2);
LensQuery ctx1 = target().path("queryapi/queries").path(handle1.toString()).queryParam("sessionid", lensSessionId)
- .request().get(LensQuery.class);
+ .request().get(LensQuery.class);
Assert.assertEquals(ctx1.getQueryName().toLowerCase(), "testquery1");
// wait till the query finishes
QueryStatus stat = ctx1.getStatus();
while (!stat.isFinished()) {
ctx1 = target().path("queryapi/queries").path(handle1.toString()).queryParam("sessionid", lensSessionId)
- .request().get(LensQuery.class);
+ .request().get(LensQuery.class);
stat = ctx1.getStatus();
Thread.sleep(1000);
}
Assert.assertEquals(ctx1.getStatus().getStatus(), QueryStatus.Status.SUCCESSFUL);
LensQuery ctx2 = target().path("queryapi/queries").path(handle2.toString()).queryParam("sessionid", lensSessionId)
- .request().get(LensQuery.class);
+ .request().get(LensQuery.class);
Assert.assertNotNull(ctx2);
Assert.assertEquals(ctx2.getQueryName().toLowerCase(), "testqueryname2");
// wait till the query finishes
stat = ctx2.getStatus();
while (!stat.isFinished()) {
ctx2 = target().path("queryapi/queries").path(handle1.toString()).queryParam("sessionid", lensSessionId)
- .request().get(LensQuery.class);
+ .request().get(LensQuery.class);
stat = ctx2.getStatus();
Thread.sleep(1000);
}
@@ -579,20 +560,19 @@ public class TestQueryService extends LensJerseyTest {
// destroy prepared
APIResult result = target.path(pHandle.toString()).queryParam("sessionid", lensSessionId).request()
- .delete(APIResult.class);
+ .delete(APIResult.class);
Assert.assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
// Post on destroyed query
Response response = target.path(pHandle.toString()).request()
- .post(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), Response.class);
+ .post(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), Response.class);
Assert.assertEquals(response.getStatus(), 404);
}
/**
* Test explain and prepare query.
*
- * @throws InterruptedException
- * the interrupted exception
+ * @throws InterruptedException the interrupted exception
*/
@Test
public void testExplainAndPrepareQuery() throws InterruptedException {
@@ -600,25 +580,25 @@ public class TestQueryService extends LensJerseyTest {
final FormDataMultiPart mp = new FormDataMultiPart();
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID from " + testTable));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "explain_and_prepare"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(),
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryPlan plan = target.request()
- .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), QueryPlan.class);
+ .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), QueryPlan.class);
Assert.assertEquals(plan.getNumSels(), 1);
Assert.assertEquals(plan.getTablesQueried().size(), 1);
Assert.assertTrue(plan.getTablesQueried().get(0).endsWith(testTable.toLowerCase()));
Assert.assertNotNull(plan.getPrepareHandle());
LensPreparedQuery ctx = target.path(plan.getPrepareHandle().toString()).queryParam("sessionid", lensSessionId)
- .request().get(LensPreparedQuery.class);
+ .request().get(LensPreparedQuery.class);
Assert.assertTrue(ctx.getUserQuery().equalsIgnoreCase("select ID from " + testTable));
Assert.assertTrue(ctx.getDriverQuery().equalsIgnoreCase("select ID from " + testTable));
Assert.assertEquals(ctx.getSelectedDriverClassName(),
- org.apache.lens.driver.hive.HiveDriver.class.getCanonicalName());
+ org.apache.lens.driver.hive.HiveDriver.class.getCanonicalName());
Assert.assertNull(ctx.getConf().getProperties().get("my.property"));
// Update conf for prepared query
@@ -626,44 +606,44 @@ public class TestQueryService extends LensJerseyTest {
LensConf conf = new LensConf();
conf.addProperty("my.property", "myvalue");
confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
APIResult updateConf = target.path(plan.getPrepareHandle().toString()).request()
- .put(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class);
+ .put(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class);
Assert.assertEquals(updateConf.getStatus(), APIResult.Status.SUCCEEDED);
ctx = target.path(plan.getPrepareHandle().toString()).queryParam("sessionid", lensSessionId).request()
- .get(LensPreparedQuery.class);
+ .get(LensPreparedQuery.class);
Assert.assertEquals(ctx.getConf().getProperties().get("my.property"), "myvalue");
QueryHandle handle1 = target.path(plan.getPrepareHandle().toString()).request()
- .post(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), QueryHandle.class);
+ .post(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), QueryHandle.class);
// do post once again
QueryHandle handle2 = target.path(plan.getPrepareHandle().toString()).request()
- .post(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), QueryHandle.class);
+ .post(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), QueryHandle.class);
Assert.assertNotEquals(handle1, handle2);
LensQuery ctx1 = target().path("queryapi/queries").path(handle1.toString()).queryParam("sessionid", lensSessionId)
- .request().get(LensQuery.class);
+ .request().get(LensQuery.class);
// wait till the query finishes
QueryStatus stat = ctx1.getStatus();
while (!stat.isFinished()) {
ctx1 = target().path("queryapi/queries").path(handle1.toString()).queryParam("sessionid", lensSessionId)
- .request().get(LensQuery.class);
+ .request().get(LensQuery.class);
stat = ctx1.getStatus();
Thread.sleep(1000);
}
Assert.assertEquals(ctx1.getStatus().getStatus(), QueryStatus.Status.SUCCESSFUL);
LensQuery ctx2 = target().path("queryapi/queries").path(handle2.toString()).queryParam("sessionid", lensSessionId)
- .request().get(LensQuery.class);
+ .request().get(LensQuery.class);
// wait till the query finishes
stat = ctx2.getStatus();
while (!stat.isFinished()) {
ctx2 = target().path("queryapi/queries").path(handle1.toString()).queryParam("sessionid", lensSessionId)
- .request().get(LensQuery.class);
+ .request().get(LensQuery.class);
stat = ctx2.getStatus();
Thread.sleep(1000);
}
@@ -671,25 +651,24 @@ public class TestQueryService extends LensJerseyTest {
// destroy prepared
APIResult result = target.path(plan.getPrepareHandle().toString()).queryParam("sessionid", lensSessionId).request()
- .delete(APIResult.class);
+ .delete(APIResult.class);
Assert.assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
// Post on destroyed query
Response response = target.path(plan.getPrepareHandle().toString()).request()
- .post(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), Response.class);
+ .post(Entity.entity(confpart, MediaType.MULTIPART_FORM_DATA_TYPE), Response.class);
Assert.assertEquals(response.getStatus(), 404);
}
// test with execute async post, get query, get results
// test cancel query
+
/**
* Test execute async.
*
- * @throws InterruptedException
- * the interrupted exception
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
public void testExecuteAsync() throws InterruptedException, IOException {
@@ -701,23 +680,23 @@ public class TestQueryService extends LensJerseyTest {
final FormDataMultiPart mp = new FormDataMultiPart();
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID, IDSTR from "
- + testTable));
+ + testTable));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(),
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryHandle handle = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandle.class);
+ QueryHandle.class);
Assert.assertNotNull(handle);
// Get query
LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
- .get(LensQuery.class);
+ .get(LensQuery.class);
Assert.assertTrue(ctx.getStatus().getStatus().equals(Status.QUEUED)
- || ctx.getStatus().getStatus().equals(Status.LAUNCHED) || ctx.getStatus().getStatus().equals(Status.RUNNING)
- || ctx.getStatus().getStatus().equals(Status.SUCCESSFUL));
+ || ctx.getStatus().getStatus().equals(Status.LAUNCHED) || ctx.getStatus().getStatus().equals(Status.RUNNING)
+ || ctx.getStatus().getStatus().equals(Status.SUCCESSFUL));
// wait till the query finishes
QueryStatus stat = ctx.getStatus();
@@ -727,7 +706,7 @@ public class TestQueryService extends LensJerseyTest {
switch (stat.getStatus()) {
case RUNNING:
assertEquals(metricsSvc.getRunningQueries(), runningQueries + 1,
- "Asserting queries for " + ctx.getQueryHandle());
+ "Asserting queries for " + ctx.getQueryHandle());
break;
case QUEUED:
assertEquals(metricsSvc.getQueuedQueries(), queuedQueries + 1);
@@ -747,17 +726,17 @@ public class TestQueryService extends LensJerseyTest {
// test cancel query
final QueryHandle handle2 = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandle.class);
+ QueryHandle.class);
Assert.assertNotNull(handle2);
APIResult result = target.path(handle2.toString()).queryParam("sessionid", lensSessionId).request()
- .delete(APIResult.class);
+ .delete(APIResult.class);
// cancel would fail query is already successful
Assert.assertTrue(result.getStatus().equals(APIResult.Status.SUCCEEDED)
- || result.getStatus().equals(APIResult.Status.FAILED));
+ || result.getStatus().equals(APIResult.Status.FAILED));
LensQuery ctx2 = target.path(handle2.toString()).queryParam("sessionid", lensSessionId).request()
- .get(LensQuery.class);
+ .get(LensQuery.class);
if (result.getStatus().equals(APIResult.Status.FAILED)) {
Assert.assertTrue(ctx2.getStatus().getStatus() == QueryStatus.Status.SUCCESSFUL);
} else {
@@ -768,17 +747,17 @@ public class TestQueryService extends LensJerseyTest {
LOG.info("Starting httpendpoint test");
final FormDataMultiPart mp3 = new FormDataMultiPart();
mp3.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp3.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID, IDSTR from "
- + testTable));
+ + testTable));
mp3.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
LensConf conf = new LensConf();
conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_SET, "true");
mp3.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryHandle handle3 = target.request().post(Entity.entity(mp3, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandle.class);
+ QueryHandle.class);
// Get query
ctx = target.path(handle3.toString()).queryParam("sessionid", lensSessionId).request().get(LensQuery.class);
@@ -795,10 +774,8 @@ public class TestQueryService extends LensJerseyTest {
/**
* Test notification.
*
- * @throws IOException
- * Signals that an I/O exception has occurred.
- * @throws InterruptedException
- * the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
*/
@Test
public void testNotification() throws IOException, InterruptedException {
@@ -810,22 +787,22 @@ public class TestQueryService extends LensJerseyTest {
conf.addProperty(LensConfConstants.QUERY_MAIL_NOTIFY, "true");
conf.addProperty(LensConfConstants.QUERY_RESULT_EMAIL_CC, "foo1@localhost,foo2@localhost,foo3@localhost");
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID, IDSTR from "
- + testTable));
+ + testTable));
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryHandle handle = target.request().post(Entity.entity(mp2, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandle.class);
+ QueryHandle.class);
Assert.assertNotNull(handle);
LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
- .get(LensQuery.class);
+ .get(LensQuery.class);
Assert.assertTrue(ctx.getStatus().getStatus().equals(Status.QUEUED)
- || ctx.getStatus().getStatus().equals(Status.LAUNCHED) || ctx.getStatus().getStatus().equals(Status.RUNNING)
- || ctx.getStatus().getStatus().equals(Status.SUCCESSFUL));
+ || ctx.getStatus().getStatus().equals(Status.LAUNCHED) || ctx.getStatus().getStatus().equals(Status.RUNNING)
+ || ctx.getStatus().getStatus().equals(Status.SUCCESSFUL));
// wait till the query finishes
QueryStatus stat = ctx.getStatus();
@@ -852,19 +829,14 @@ public class TestQueryService extends LensJerseyTest {
/**
* Validate persisted result.
*
- * @param handle
- * the handle
- * @param parent
- * the parent
- * @param lensSessionId
- * the lens session id
- * @param isDir
- * the is dir
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @param handle the handle
+ * @param parent the parent
+ * @param lensSessionId the lens session id
+ * @param isDir the is dir
+ * @throws IOException Signals that an I/O exception has occurred.
*/
static void validatePersistedResult(QueryHandle handle, WebTarget parent, LensSessionHandle lensSessionId,
- String[][] schema, boolean isDir) throws IOException {
+ String[][] schema, boolean isDir) throws IOException {
final WebTarget target = parent.path("queryapi/queries");
// fetch results
validateResultSetMetadata(handle, "",
@@ -872,11 +844,11 @@ public class TestQueryService extends LensJerseyTest {
parent, lensSessionId);
String presultset = target.path(handle.toString()).path("resultset").queryParam("sessionid", lensSessionId)
- .request().get(String.class);
+ .request().get(String.class);
System.out.println("PERSISTED RESULT:" + presultset);
PersistentQueryResult resultset = target.path(handle.toString()).path("resultset")
- .queryParam("sessionid", lensSessionId).request().get(PersistentQueryResult.class);
+ .queryParam("sessionid", lensSessionId).request().get(PersistentQueryResult.class);
validatePersistentResult(resultset, handle, isDir);
if (isDir) {
@@ -887,18 +859,14 @@ public class TestQueryService extends LensJerseyTest {
/**
* Read result set.
*
- * @param resultset
- * the resultset
- * @param handle
- * the handle
- * @param isDir
- * the is dir
+ * @param resultset the resultset
+ * @param handle the handle
+ * @param isDir the is dir
* @return the list
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @throws IOException Signals that an I/O exception has occurred.
*/
public static List<String> readResultSet(PersistentQueryResult resultset, QueryHandle handle, boolean isDir)
- throws IOException {
+ throws IOException {
Assert.assertTrue(resultset.getPersistedURI().contains(handle.toString()));
Path actualPath = new Path(resultset.getPersistedURI());
FileSystem fs = actualPath.getFileSystem(new Configuration());
@@ -918,14 +886,10 @@ public class TestQueryService extends LensJerseyTest {
/**
* Adds the rows from file.
*
- * @param actualRows
- * the actual rows
- * @param fs
- * the fs
- * @param path
- * the path
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @param actualRows the actual rows
+ * @param fs the fs
+ * @param path the path
+ * @throws IOException Signals that an I/O exception has occurred.
*/
static void addRowsFromFile(List<String> actualRows, FileSystem fs, Path path) throws IOException {
FSDataInputStream in = fs.open(path);
@@ -950,17 +914,13 @@ public class TestQueryService extends LensJerseyTest {
/**
* Validate persistent result.
*
- * @param resultset
- * the resultset
- * @param handle
- * the handle
- * @param isDir
- * the is dir
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @param resultset the resultset
+ * @param handle the handle
+ * @param isDir the is dir
+ * @throws IOException Signals that an I/O exception has occurred.
*/
static void validatePersistentResult(PersistentQueryResult resultset, QueryHandle handle, boolean isDir)
- throws IOException {
+ throws IOException {
List<String> actualRows = readResultSet(resultset, handle, isDir);
validatePersistentResult(actualRows);
}
@@ -971,16 +931,16 @@ public class TestQueryService extends LensJerseyTest {
"\\Ntwo123item1item2",
"3\\Nitem1item2",
"\\N\\N",
- "5nothing"
+ "5nothing",
};
String[] expected2 = new String[]{
"1one[][]",
"\\Ntwo[1,2,3][\"item1\",\"item2\"]",
"3\\N[][\"item1\",\"item2\"]",
"\\N\\N[][]",
- "5[][\"nothing\"]"
+ "5[][\"nothing\"]",
};
- for(int i = 0; i < actualRows.size(); i++) {
+ for (int i = 0; i < actualRows.size(); i++) {
Assert.assertEquals(
expected1[i].indexOf(actualRows.get(i)) == 0 || expected2[i].indexOf(actualRows.get(i)) == 0, true);
}
@@ -989,22 +949,17 @@ public class TestQueryService extends LensJerseyTest {
/**
* Validate http end point.
*
- * @param parent
- * the parent
- * @param lensSessionId
- * the lens session id
- * @param handle
- * the handle
- * @param redirectUrl
- * the redirect url
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @param parent the parent
+ * @param lensSessionId the lens session id
+ * @param handle the handle
+ * @param redirectUrl the redirect url
+ * @throws IOException Signals that an I/O exception has occurred.
*/
static void validateHttpEndPoint(WebTarget parent, LensSessionHandle lensSessionId, QueryHandle handle,
- String redirectUrl) throws IOException {
+ String redirectUrl) throws IOException {
LOG.info("@@@ validateHttpEndPoint sessionid " + lensSessionId);
Response response = parent.path("queryapi/queries/" + handle.toString() + "/httpresultset")
- .queryParam("sessionid", lensSessionId).request().get();
+ .queryParam("sessionid", lensSessionId).request().get();
Assert.assertTrue(response.getHeaderString("content-disposition").contains(handle.toString()));
@@ -1027,17 +982,14 @@ public class TestQueryService extends LensJerseyTest {
/**
* Valid not found for http result.
*
- * @param parent
- * the parent
- * @param lensSessionId
- * the lens session id
- * @param handle
- * the handle
+ * @param parent the parent
+ * @param lensSessionId the lens session id
+ * @param handle the handle
*/
static void validNotFoundForHttpResult(WebTarget parent, LensSessionHandle lensSessionId, QueryHandle handle) {
try {
Response response = parent.path("queryapi/queries/" + handle.toString() + "/httpresultset")
- .queryParam("sessionid", lensSessionId).request().get();
+ .queryParam("sessionid", lensSessionId).request().get();
if (Response.Status.NOT_FOUND.getStatusCode() != response.getStatus()) {
Assert.fail("Expected not found excepiton, but got:" + response.getStatus());
}
@@ -1051,13 +1003,12 @@ public class TestQueryService extends LensJerseyTest {
// test with execute async post, get query, get results
// test cancel query
+
/**
* Test execute async in memory result.
*
- * @throws InterruptedException
- * the interrupted exception
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
public void testExecuteAsyncInMemoryResult() throws InterruptedException, IOException {
@@ -1068,23 +1019,23 @@ public class TestQueryService extends LensJerseyTest {
LensConf conf = new LensConf();
conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false");
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID, IDSTR from "
- + testTable));
+ + testTable));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryHandle handle = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandle.class);
+ QueryHandle.class);
Assert.assertNotNull(handle);
// Get query
LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
- .get(LensQuery.class);
+ .get(LensQuery.class);
Assert.assertTrue(ctx.getStatus().getStatus().equals(Status.QUEUED)
- || ctx.getStatus().getStatus().equals(Status.LAUNCHED) || ctx.getStatus().getStatus().equals(Status.RUNNING)
- || ctx.getStatus().getStatus().equals(Status.SUCCESSFUL));
+ || ctx.getStatus().getStatus().equals(Status.LAUNCHED) || ctx.getStatus().getStatus().equals(Status.RUNNING)
+ || ctx.getStatus().getStatus().equals(Status.SUCCESSFUL));
// wait till the query finishes
QueryStatus stat = ctx.getStatus();
@@ -1102,7 +1053,7 @@ public class TestQueryService extends LensJerseyTest {
InMemoryQueryResult resultset = target.path(handle.toString()).path("resultset")
- .queryParam("sessionid", lensSessionId).request().get(InMemoryQueryResult.class);
+ .queryParam("sessionid", lensSessionId).request().get(InMemoryQueryResult.class);
validateInmemoryResult(resultset);
validNotFoundForHttpResult(target(), lensSessionId, handle);
@@ -1111,10 +1062,8 @@ public class TestQueryService extends LensJerseyTest {
/**
* Test execute async temp table.
*
- * @throws InterruptedException
- * the interrupted exception
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
public void testExecuteAsyncTempTable() throws InterruptedException, IOException {
@@ -1125,23 +1074,23 @@ public class TestQueryService extends LensJerseyTest {
LensConf conf = new LensConf();
conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false");
drop.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
drop.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(),
- "drop table if exists temp_output"));
+ "drop table if exists temp_output"));
drop.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
drop.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryHandle dropHandle = target.request().post(Entity.entity(drop, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandle.class);
+ QueryHandle.class);
Assert.assertNotNull(dropHandle);
// Get query
LensQuery ctx = target.path(dropHandle.toString()).queryParam("sessionid", lensSessionId).request()
- .get(LensQuery.class);
+ .get(LensQuery.class);
Assert.assertTrue(ctx.getStatus().getStatus().equals(Status.QUEUED)
- || ctx.getStatus().getStatus().equals(Status.LAUNCHED) || ctx.getStatus().getStatus().equals(Status.RUNNING)
- || ctx.getStatus().getStatus().equals(Status.SUCCESSFUL));
+ || ctx.getStatus().getStatus().equals(Status.LAUNCHED) || ctx.getStatus().getStatus().equals(Status.RUNNING)
+ || ctx.getStatus().getStatus().equals(Status.SUCCESSFUL));
// wait till the query finishes
QueryStatus stat = ctx.getStatus();
@@ -1156,22 +1105,22 @@ public class TestQueryService extends LensJerseyTest {
conf = new LensConf();
conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false");
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(),
- "create table temp_output as select ID, IDSTR from " + testTable));
+ "create table temp_output as select ID, IDSTR from " + testTable));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryHandle handle = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandle.class);
+ QueryHandle.class);
Assert.assertNotNull(handle);
// Get query
ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request().get(LensQuery.class);
Assert.assertTrue(ctx.getStatus().getStatus().equals(Status.QUEUED)
- || ctx.getStatus().getStatus().equals(Status.LAUNCHED) || ctx.getStatus().getStatus().equals(Status.RUNNING)
- || ctx.getStatus().getStatus().equals(Status.SUCCESSFUL));
+ || ctx.getStatus().getStatus().equals(Status.LAUNCHED) || ctx.getStatus().getStatus().equals(Status.RUNNING)
+ || ctx.getStatus().getStatus().equals(Status.SUCCESSFUL));
// wait till the query finishes
stat = ctx.getStatus();
@@ -1185,13 +1134,13 @@ public class TestQueryService extends LensJerseyTest {
String select = "SELECT * FROM temp_output";
final FormDataMultiPart fetch = new FormDataMultiPart();
fetch.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
fetch.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), select));
fetch.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
fetch.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryHandle handle2 = target.request().post(Entity.entity(fetch, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandle.class);
+ QueryHandle.class);
Assert.assertNotNull(handle2);
@@ -1212,19 +1161,16 @@ public class TestQueryService extends LensJerseyTest {
target(), lensSessionId);
InMemoryQueryResult resultset = target.path(handle2.toString()).path("resultset")
- .queryParam("sessionid", lensSessionId).request().get(InMemoryQueryResult.class);
+ .queryParam("sessionid", lensSessionId).request().get(InMemoryQueryResult.class);
validateInmemoryResult(resultset);
}
/**
* Validate result set metadata.
*
- * @param handle
- * the handle
- * @param parent
- * the parent
- * @param lensSessionId
- * the lens session id
+ * @param handle the handle
+ * @param parent the parent
+ * @param lensSessionId the lens session id
*/
static void validateResultSetMetadata(QueryHandle handle, WebTarget parent, LensSessionHandle lensSessionId) {
validateResultSetMetadata(handle, "",
@@ -1235,26 +1181,23 @@ public class TestQueryService extends LensJerseyTest {
/**
* Validate result set metadata.
*
- * @param handle
- * the handle
- * @param outputTablePfx
- * the output table pfx
- * @param parent
- * the parent
- * @param lensSessionId
- * the lens session id
+ * @param handle the handle
+ * @param outputTablePfx the output table pfx
+ * @param parent the parent
+ * @param lensSessionId the lens session id
*/
static void validateResultSetMetadata(QueryHandle handle, String outputTablePfx, String[][] columns, WebTarget parent,
- LensSessionHandle lensSessionId) {
+ LensSessionHandle lensSessionId) {
final WebTarget target = parent.path("queryapi/queries");
QueryResultSetMetadata metadata = target.path(handle.toString()).path("resultsetmetadata")
- .queryParam("sessionid", lensSessionId).request().get(QueryResultSetMetadata.class);
+ .queryParam("sessionid", lensSessionId).request().get(QueryResultSetMetadata.class);
Assert.assertEquals(metadata.getColumns().size(), columns.length);
- for(int i = 0; i < columns.length; i++) {
- assertTrue(metadata.getColumns().get(i).getName().toLowerCase().equals
- ((outputTablePfx + columns[i][0]).toLowerCase())
- || metadata.getColumns().get(i).getName().toLowerCase().equals(columns[i][0].toLowerCase()));
+ for (int i = 0; i < columns.length; i++) {
+ assertTrue(
+ metadata.getColumns().get(i).getName().toLowerCase().equals(outputTablePfx + columns[i][0].toLowerCase())
+ || metadata.getColumns().get(i).getName().toLowerCase().equals(columns[i][0].toLowerCase())
+ );
assertEquals(columns[i][1].toLowerCase(), metadata.getColumns().get(i).getType().name().toLowerCase());
}
}
@@ -1262,8 +1205,7 @@ public class TestQueryService extends LensJerseyTest {
/**
* Validate inmemory result.
*
- * @param resultset
- * the resultset
+ * @param resultset the resultset
*/
private void validateInmemoryResult(InMemoryQueryResult resultset) {
Assert.assertEquals(resultset.getRows().size(), 5);
@@ -1284,13 +1226,12 @@ public class TestQueryService extends LensJerseyTest {
// test execute with timeout, fetch results
// cancel the query with execute_with_timeout
+
/**
* Test execute with timeout query.
*
- * @throws IOException
- * Signals that an I/O exception has occurred.
- * @throws InterruptedException
- * the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
*/
@Test
public void testExecuteWithTimeoutQuery() throws IOException, InterruptedException {
@@ -1298,17 +1239,17 @@ public class TestQueryService extends LensJerseyTest {
final FormDataMultiPart mp = new FormDataMultiPart();
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID, IDSTR from "
- + testTable));
+ + testTable));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute_with_timeout"));
// set a timeout value enough for tests
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("timeoutmillis").build(), "300000"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(),
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
QueryHandleWithResultSet result = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandleWithResultSet.class);
+ QueryHandleWithResultSet.class);
Assert.assertNotNull(result.getQueryHandle());
Assert.assertNotNull(result.getResult());
validatePersistentResult((PersistentQueryResult) result.getResult(), result.getQueryHandle(), true);
@@ -1317,17 +1258,17 @@ public class TestQueryService extends LensJerseyTest {
LensConf conf = new LensConf();
conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false");
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID, IDSTR from "
- + testTable));
+ + testTable));
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute_with_timeout"));
// set a timeout value enough for tests
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("timeoutmillis").build(), "300000"));
mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
result = target.request().post(Entity.entity(mp2, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandleWithResultSet.class);
+ QueryHandleWithResultSet.class);
Assert.assertNotNull(result.getQueryHandle());
Assert.assertNotNull(result.getResult());
validateInmemoryResult((InMemoryQueryResult) result.getResult());
@@ -1336,8 +1277,7 @@ public class TestQueryService extends LensJerseyTest {
/**
* Test default config.
*
- * @throws LensException
- * the lens exception
+ * @throws LensException the lens exception
*/
@Test
public void testDefaultConfig() throws LensException {
@@ -1367,7 +1307,7 @@ public class TestQueryService extends LensJerseyTest {
final String query = "select ID from " + testTable;
QueryContext ctx = new QueryContext(query, null, queryConf, conf, queryService.getDrivers());
Map<LensDriver, String> driverQueries = new HashMap<LensDriver, String>();
- for (LensDriver driver :queryService.getDrivers()) {
+ for (LensDriver driver : queryService.getDrivers()) {
driverQueries.put(driver, query);
}
ctx.setDriverQueriesAndPlans(driverQueries);
@@ -1375,7 +1315,7 @@ public class TestQueryService extends LensJerseyTest {
Assert.assertEquals(queryService.getSession(lensSessionId).getHiveConf().getClassLoader(), ctx.getConf()
.getClassLoader());
Assert.assertEquals(queryService.getSession(lensSessionId).getHiveConf().getClassLoader(),
- ctx.getDriverContext().getDriverConf(queryService.getDrivers().iterator().next()).getClassLoader());
+ ctx.getDriverContext().getDriverConf(queryService.getDrivers().iterator().next()).getClassLoader());
Assert.assertTrue(ctx.isSelectedDriverQueryExplicitlySet());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/query/TestResultFormatting.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/TestResultFormatting.java b/lens-server/src/test/java/org/apache/lens/server/query/TestResultFormatting.java
index 75ae2d3..efa84ec 100644
--- a/lens-server/src/test/java/org/apache/lens/server/query/TestResultFormatting.java
+++ b/lens-server/src/test/java/org/apache/lens/server/query/TestResultFormatting.java
@@ -28,7 +28,6 @@ import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
-import org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe;
import org.apache.lens.api.LensConf;
import org.apache.lens.api.LensSessionHandle;
import org.apache.lens.api.query.LensQuery;
@@ -42,8 +41,9 @@ import org.apache.lens.server.api.LensConfConstants;
import org.apache.lens.server.api.query.InMemoryOutputFormatter;
import org.apache.lens.server.api.query.PersistedOutputFormatter;
import org.apache.lens.server.api.query.QueryContext;
-import org.apache.lens.server.query.QueryApp;
-import org.apache.lens.server.query.QueryExecutionServiceImpl;
+
+import org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe;
+
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
@@ -69,7 +69,7 @@ public class TestResultFormatting extends LensJerseyTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#setUp()
*/
@BeforeTest
@@ -77,13 +77,14 @@ public class TestResultFormatting extends LensJerseyTest {
super.setUp();
queryService = (QueryExecutionServiceImpl) LensServices.get().getService("query");
lensSessionId = queryService.openSession("foo", "bar", new HashMap<String, String>());
- LensTestUtil.createTable(testTable, target(), lensSessionId, "(ID INT, IDSTR STRING, IDARR ARRAY<INT>, IDSTRARR ARRAY<STRING>)");
+ LensTestUtil.createTable(testTable, target(), lensSessionId,
+ "(ID INT, IDSTR STRING, IDARR ARRAY<INT>, IDSTRARR ARRAY<STRING>)");
LensTestUtil.loadData(testTable, TEST_DATA_FILE, target(), lensSessionId);
}
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#tearDown()
*/
@AfterTest
@@ -95,7 +96,7 @@ public class TestResultFormatting extends LensJerseyTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#configure()
*/
@Override
@@ -105,7 +106,7 @@ public class TestResultFormatting extends LensJerseyTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#configureClient(org.glassfish.jersey.client.ClientConfig)
*/
@Override
@@ -117,13 +118,12 @@ public class TestResultFormatting extends LensJerseyTest {
private static String testTable = "RESULT_TEST_TABLE";
// test with execute async post with result formatter, get query, get results
+
/**
* Test result formatter in memory result.
*
- * @throws InterruptedException
- * the interrupted exception
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
public void testResultFormatterInMemoryResult() throws InterruptedException, IOException {
@@ -138,13 +138,12 @@ public class TestResultFormatting extends LensJerseyTest {
}
// test with execute async post with result formatter, get query, get results
+
/**
* Test result formatter hdf spersistent result.
*
- * @throws InterruptedException
- * the interrupted exception
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
public void testResultFormatterHDFSpersistentResult() throws InterruptedException, IOException {
@@ -159,10 +158,8 @@ public class TestResultFormatting extends LensJerseyTest {
/**
* Test persistent result with max size.
*
- * @throws InterruptedException
- * the interrupted exception
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
public void testPersistentResultWithMaxSize() throws InterruptedException, IOException {
@@ -175,10 +172,8 @@ public class TestResultFormatting extends LensJerseyTest {
/**
* Test result formatter failure.
*
- * @throws InterruptedException
- * the interrupted exception
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
public void testResultFormatterFailure() throws InterruptedException, IOException {
@@ -189,44 +184,39 @@ public class TestResultFormatting extends LensJerseyTest {
}
// test with execute async post with result formatter, get query, get results
+
/**
* Test result formatter.
*
- * @param conf
- * the conf
- * @param status
- * the status
- * @param isDir
- * the is dir
- * @param reDirectUrl
- * the re direct url
- * @throws InterruptedException
- * the interrupted exception
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @param conf the conf
+ * @param status the status
+ * @param isDir the is dir
+ * @param reDirectUrl the re direct url
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
*/
private void testResultFormatter(LensConf conf, Status status, boolean isDir, String reDirectUrl)
- throws InterruptedException, IOException {
+ throws InterruptedException, IOException {
// test post execute op
final WebTarget target = target().path("queryapi/queries");
final FormDataMultiPart mp = new FormDataMultiPart();
conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_SET, "true");
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(),
"select ID, IDSTR, IDARR, IDSTRARR from " + testTable));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
QueryHandle handle = target.request()
- .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), QueryHandle.class);
+ .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), QueryHandle.class);
Assert.assertNotNull(handle);
// Get query
LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
- .get(LensQuery.class);
+ .get(LensQuery.class);
// wait till the query finishes
QueryStatus stat = ctx.getStatus();
while (!stat.isFinished()) {
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/session/TestSessionExpiry.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/session/TestSessionExpiry.java b/lens-server/src/test/java/org/apache/lens/server/session/TestSessionExpiry.java
index dc0b4e6..6a30e90 100644
--- a/lens-server/src/test/java/org/apache/lens/server/session/TestSessionExpiry.java
+++ b/lens-server/src/test/java/org/apache/lens/server/session/TestSessionExpiry.java
@@ -18,20 +18,18 @@
*/
package org.apache.lens.server.session;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hive.service.cli.CLIService;
+import static org.testng.Assert.*;
+
+import java.util.HashMap;
+
import org.apache.lens.api.LensSessionHandle;
import org.apache.lens.server.LensServerConf;
import org.apache.lens.server.api.LensConfConstants;
-import org.apache.lens.server.session.LensSessionImpl;
-import org.apache.lens.server.session.HiveSessionService;
-import org.testng.annotations.Test;
-import java.util.HashMap;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hive.service.cli.CLIService;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
/**
* The Class TestSessionExpiry.
@@ -42,8 +40,7 @@ public class TestSessionExpiry {
/**
* Test session expiry.
*
- * @throws Exception
- * the exception
+ * @throws Exception the exception
*/
public void testSessionExpiry() throws Exception {
HiveConf conf = LensServerConf.get();
@@ -60,7 +57,7 @@ public class TestSessionExpiry {
LensSessionImpl session = lensService.getSession(sessionHandle);
assertTrue(session.isActive());
session.setLastAccessTime(session.getLastAccessTime() - 2000
- * conf.getLong(LensConfConstants.SESSION_TIMEOUT_SECONDS, LensConfConstants.SESSION_TIMEOUT_SECONDS_DEFAULT));
+ * conf.getLong(LensConfConstants.SESSION_TIMEOUT_SECONDS, LensConfConstants.SESSION_TIMEOUT_SECONDS_DEFAULT));
assertFalse(session.isActive());
// run the expiry thread