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:47 UTC
[04/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/LensTestUtil.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/LensTestUtil.java b/lens-server/src/test/java/org/apache/lens/server/LensTestUtil.java
index f943045..320557b 100644
--- a/lens-server/src/test/java/org/apache/lens/server/LensTestUtil.java
+++ b/lens-server/src/test/java/org/apache/lens/server/LensTestUtil.java
@@ -29,17 +29,19 @@ import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
-import org.apache.hadoop.hive.metastore.TableType;
-import org.apache.hadoop.hive.metastore.api.FieldSchema;
-import org.apache.hadoop.hive.ql.metadata.Hive;
-import org.apache.hadoop.hive.ql.metadata.HiveException;
-import org.apache.hadoop.hive.ql.metadata.Table;
import org.apache.lens.api.LensConf;
import org.apache.lens.api.LensSessionHandle;
import org.apache.lens.api.query.LensQuery;
import org.apache.lens.api.query.QueryHandle;
import org.apache.lens.api.query.QueryStatus;
import org.apache.lens.server.api.LensConfConstants;
+
+import org.apache.hadoop.hive.metastore.TableType;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.ql.metadata.Hive;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.metadata.Table;
+
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
@@ -48,24 +50,22 @@ import org.testng.Assert;
/**
* The Class LensTestUtil.
*/
-public class LensTestUtil {
+public final class LensTestUtil {
+ private LensTestUtil() {
+
+ }
/**
* Creates the table.
*
- * @param tblName
- * the tbl name
- * @param parent
- * the parent
- * @param lensSessionId
- * the lens session id
- * @param schemaStr
- * the schema string, with surrounding parenthesis.
- * @throws InterruptedException
- * the interrupted exception
+ * @param tblName the tbl name
+ * @param parent the parent
+ * @param lensSessionId the lens session id
+ * @param schemaStr the schema string, with surrounding parenthesis.
+ * @throws InterruptedException the interrupted exception
*/
- public static void createTable (String tblName, WebTarget parent, LensSessionHandle lensSessionId, String schemaStr)
- throws InterruptedException {
+ public static void createTable(String tblName, WebTarget parent, LensSessionHandle lensSessionId, String schemaStr)
+ throws InterruptedException {
LensConf conf = new LensConf();
conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false");
final WebTarget target = parent.path("queryapi/queries");
@@ -74,18 +74,18 @@ public class LensTestUtil {
String createTable = "CREATE TABLE IF NOT EXISTS " + tblName + schemaStr;
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(), createTable));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryHandle handle = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandle.class);
+ QueryHandle.class);
// wait till the query finishes
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);
@@ -104,42 +104,38 @@ public class LensTestUtil {
throws InterruptedException {
createTable(tblName, parent, lensSessionId, "(ID INT, IDSTR STRING)");
}
+
/**
* Load data.
*
- * @param tblName
- * the tbl name
- * @param TEST_DATA_FILE
- * the test data file
- * @param parent
- * the parent
- * @param lensSessionId
- * the lens session id
- * @throws InterruptedException
- * the interrupted exception
+ * @param tblName the tbl name
+ * @param testDataFile the test data file
+ * @param parent the parent
+ * @param lensSessionId the lens session id
+ * @throws InterruptedException the interrupted exception
*/
- public static void loadData(String tblName, final String TEST_DATA_FILE, WebTarget parent,
- LensSessionHandle lensSessionId) throws InterruptedException {
+ public static void loadData(String tblName, final String testDataFile, WebTarget parent,
+ LensSessionHandle lensSessionId) throws InterruptedException {
LensConf conf = new LensConf();
conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false");
final WebTarget target = parent.path("queryapi/queries");
final FormDataMultiPart mp = new FormDataMultiPart();
- String dataLoad = "LOAD DATA LOCAL INPATH '" + TEST_DATA_FILE + "' OVERWRITE INTO TABLE " + tblName;
+ String dataLoad = "LOAD DATA LOCAL INPATH '" + testDataFile + "' OVERWRITE INTO TABLE " + tblName;
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(), dataLoad));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryHandle handle = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandle.class);
+ QueryHandle.class);
// wait till the query finishes
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);
@@ -153,17 +149,13 @@ public class LensTestUtil {
/**
* Drop table.
*
- * @param tblName
- * the tbl name
- * @param parent
- * the parent
- * @param lensSessionId
- * the lens session id
- * @throws InterruptedException
- * the interrupted exception
+ * @param tblName the tbl name
+ * @param parent the parent
+ * @param lensSessionId the lens session id
+ * @throws InterruptedException the interrupted exception
*/
public static void dropTable(String tblName, WebTarget parent, LensSessionHandle lensSessionId)
- throws InterruptedException {
+ throws InterruptedException {
LensConf conf = new LensConf();
conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false");
final WebTarget target = parent.path("queryapi/queries");
@@ -172,18 +164,18 @@ public class LensTestUtil {
String createTable = "DROP TABLE IF EXISTS " + tblName;
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(), createTable));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
final QueryHandle handle = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
- QueryHandle.class);
+ QueryHandle.class);
// wait till the query finishes
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);
@@ -196,10 +188,8 @@ public class LensTestUtil {
/**
* Creates the hive table.
*
- * @param tableName
- * the table name
- * @throws HiveException
- * the hive exception
+ * @param tableName the table name
+ * @throws HiveException the hive exception
*/
public static void createHiveTable(String tableName) throws HiveException {
List<FieldSchema> columns = new ArrayList<FieldSchema>();
@@ -219,10 +209,8 @@ public class LensTestUtil {
/**
* Drop hive table.
*
- * @param tableName
- * the table name
- * @throws HiveException
- * the hive exception
+ * @param tableName the table name
+ * @throws HiveException the hive exception
*/
public static void dropHiveTable(String tableName) throws HiveException {
Hive.get().dropTable(tableName);
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/MockNonLensService.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/MockNonLensService.java b/lens-server/src/test/java/org/apache/lens/server/MockNonLensService.java
index 7cdec3e..e948fb9 100644
--- a/lens-server/src/test/java/org/apache/lens/server/MockNonLensService.java
+++ b/lens-server/src/test/java/org/apache/lens/server/MockNonLensService.java
@@ -28,8 +28,7 @@ public class MockNonLensService extends AbstractService {
/**
* Instantiates a new mock non lens service.
*
- * @param name
- * the name
+ * @param name the name
*/
public MockNonLensService(String name) {
super(name);
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/TestIndexResource.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/TestIndexResource.java b/lens-server/src/test/java/org/apache/lens/server/TestIndexResource.java
index 6985068..e149116 100644
--- a/lens-server/src/test/java/org/apache/lens/server/TestIndexResource.java
+++ b/lens-server/src/test/java/org/apache/lens/server/TestIndexResource.java
@@ -21,7 +21,6 @@ package org.apache.lens.server;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Application;
-import org.apache.lens.server.IndexApp;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
@@ -35,7 +34,7 @@ public class TestIndexResource extends LensJerseyTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#setUp()
*/
@BeforeTest
@@ -45,7 +44,7 @@ public class TestIndexResource extends LensJerseyTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#tearDown()
*/
@AfterTest
@@ -55,7 +54,7 @@ public class TestIndexResource extends LensJerseyTest {
/*
* (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/TestLensApplication.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/TestLensApplication.java b/lens-server/src/test/java/org/apache/lens/server/TestLensApplication.java
index 4cf63c8..1e31fad 100644
--- a/lens-server/src/test/java/org/apache/lens/server/TestLensApplication.java
+++ b/lens-server/src/test/java/org/apache/lens/server/TestLensApplication.java
@@ -22,18 +22,18 @@ import static org.testng.Assert.assertEquals;
import java.util.List;
-import org.apache.lens.server.LensApplication;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Response;
+
import org.apache.lens.server.api.metrics.MetricsService;
+
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.codahale.metrics.ScheduledReporter;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Response;
-
/**
* The Class TestLensApplication.
*/
@@ -42,7 +42,7 @@ public class TestLensApplication extends LensJerseyTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#configure()
*/
@Override
@@ -53,8 +53,7 @@ public class TestLensApplication extends LensJerseyTest {
/**
* Setup.
*
- * @throws Exception
- * the exception
+ * @throws Exception the exception
*/
@BeforeTest
public void setup() throws Exception {
@@ -64,8 +63,7 @@ public class TestLensApplication extends LensJerseyTest {
/**
* Test ws resources loaded.
*
- * @throws InterruptedException
- * the interrupted exception
+ * @throws InterruptedException the interrupted exception
*/
@Test
public void testWSResourcesLoaded() throws InterruptedException {
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/TestResource.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/TestResource.java b/lens-server/src/test/java/org/apache/lens/server/TestResource.java
index 0adab4e..da07a6c 100644
--- a/lens-server/src/test/java/org/apache/lens/server/TestResource.java
+++ b/lens-server/src/test/java/org/apache/lens/server/TestResource.java
@@ -18,14 +18,14 @@
*/
package org.apache.lens.server;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* The Class TestResource.
*/
@@ -41,7 +41,7 @@ public class TestResource {
* @return Simple text saying its up
*/
@GET
- @Produces({ MediaType.TEXT_PLAIN })
+ @Produces({MediaType.TEXT_PLAIN})
public String getMessage() {
return "OK";
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/TestServerMode.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/TestServerMode.java b/lens-server/src/test/java/org/apache/lens/server/TestServerMode.java
index dcea1a7..554cf70 100644
--- a/lens-server/src/test/java/org/apache/lens/server/TestServerMode.java
+++ b/lens-server/src/test/java/org/apache/lens/server/TestServerMode.java
@@ -35,8 +35,8 @@ import org.apache.lens.api.LensSessionHandle;
import org.apache.lens.api.query.LensQuery;
import org.apache.lens.api.query.QueryHandle;
import org.apache.lens.api.query.QueryStatus;
-import org.apache.lens.server.LensServices;
import org.apache.lens.server.LensServices.SERVICE_MODE;
+
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
@@ -53,7 +53,7 @@ public class TestServerMode extends LensAllApplicationJerseyTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#setUp()
*/
@BeforeTest
@@ -63,7 +63,7 @@ public class TestServerMode extends LensAllApplicationJerseyTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#tearDown()
*/
@AfterTest
@@ -75,8 +75,7 @@ public class TestServerMode extends LensAllApplicationJerseyTest {
/**
* Test read only mode.
*
- * @throws InterruptedException
- * the interrupted exception
+ * @throws InterruptedException the interrupted exception
*/
@Test
public void testReadOnlyMode() throws InterruptedException {
@@ -86,8 +85,7 @@ public class TestServerMode extends LensAllApplicationJerseyTest {
/**
* Test metastore no drop mode.
*
- * @throws InterruptedException
- * the interrupted exception
+ * @throws InterruptedException the interrupted exception
*/
@Test
public void testMetastoreNoDropMode() throws InterruptedException {
@@ -97,8 +95,7 @@ public class TestServerMode extends LensAllApplicationJerseyTest {
/**
* Test metastore read only mode.
*
- * @throws InterruptedException
- * the interrupted exception
+ * @throws InterruptedException the interrupted exception
*/
@Test
public void testMetastoreReadOnlyMode() throws InterruptedException {
@@ -108,8 +105,7 @@ public class TestServerMode extends LensAllApplicationJerseyTest {
/**
* Test open mode.
*
- * @throws InterruptedException
- * the interrupted exception
+ * @throws InterruptedException the interrupted exception
*/
@Test
public void testOpenMode() throws InterruptedException {
@@ -119,10 +115,8 @@ public class TestServerMode extends LensAllApplicationJerseyTest {
/**
* Test mode.
*
- * @param mode
- * the mode
- * @throws InterruptedException
- * the interrupted exception
+ * @param mode the mode
+ * @throws InterruptedException the interrupted exception
*/
private void testMode(SERVICE_MODE mode) throws InterruptedException {
LensServices.get().setServiceMode(mode);
@@ -134,10 +128,10 @@ public class TestServerMode extends LensAllApplicationJerseyTest {
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("username").build(), "foo"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("password").build(), "bar"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionconf").fileName("sessionconf").build(),
- new LensConf(), MediaType.APPLICATION_XML_TYPE));
+ new LensConf(), MediaType.APPLICATION_XML_TYPE));
final LensSessionHandle lensSessionId = target.request().post(
- Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), LensSessionHandle.class);
+ Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), LensSessionHandle.class);
Assert.assertNotNull(lensSessionId);
// creata a database
@@ -145,7 +139,7 @@ public class TestServerMode extends LensAllApplicationJerseyTest {
try {
APIResult result = dbTarget.queryParam("sessionid", lensSessionId).request(MediaType.APPLICATION_XML_TYPE)
- .post(Entity.xml("newdb"), APIResult.class);
+ .post(Entity.xml("newdb"), APIResult.class);
assertNotNull(result);
assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
} catch (NotAllowedException nae) {
@@ -164,7 +158,7 @@ public class TestServerMode extends LensAllApplicationJerseyTest {
assertEquals(drop.getStatus(), APIResult.Status.SUCCEEDED);
} catch (NotAllowedException nae) {
if (mode.equals(SERVICE_MODE.READ_ONLY) || mode.equals(SERVICE_MODE.METASTORE_READONLY)
- || mode.equals(SERVICE_MODE.METASTORE_NODROP)) {
+ || mode.equals(SERVICE_MODE.METASTORE_NODROP)) {
// expected
System.out.println("Drop databse not allowed in mode:" + mode);
} else {
@@ -178,11 +172,11 @@ public class TestServerMode extends LensAllApplicationJerseyTest {
final FormDataMultiPart query = new FormDataMultiPart();
query.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
query.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select name from table"));
query.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
query.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(),
- new LensConf(), MediaType.APPLICATION_XML_TYPE));
+ new LensConf(), MediaType.APPLICATION_XML_TYPE));
QueryHandle qhandle = null;
try {
@@ -198,22 +192,22 @@ public class TestServerMode extends LensAllApplicationJerseyTest {
// Get all queries; should always pass
List<QueryHandle> allQueriesXML = queryTarget.queryParam("sessionid", lensSessionId)
- .request(MediaType.APPLICATION_XML).get(new GenericType<List<QueryHandle>>() {
- });
+ .request(MediaType.APPLICATION_XML).get(new GenericType<List<QueryHandle>>() {
+ });
Assert.assertTrue(allQueriesXML.size() >= 1);
if (!mode.equals(SERVICE_MODE.READ_ONLY)) {
assertNotNull(qhandle);
// wait for query completion if mode is not read only
LensQuery ctx = queryTarget.path(qhandle.toString()).queryParam("sessionid", lensSessionId).request()
- .get(LensQuery.class);
+ .get(LensQuery.class);
// Assert.assertEquals(ctx.getStatus().getStatus(), QueryStatus.Status.QUEUED);
// wait till the query finishes
QueryStatus stat = ctx.getStatus();
while (!stat.isFinished()) {
ctx = queryTarget.path(qhandle.toString()).queryParam("sessionid", lensSessionId).request()
- .get(LensQuery.class);
+ .get(LensQuery.class);
stat = ctx.getStatus();
Thread.sleep(1000);
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/TestServerRestart.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/TestServerRestart.java b/lens-server/src/test/java/org/apache/lens/server/TestServerRestart.java
index ff06df4..6306b51 100644
--- a/lens-server/src/test/java/org/apache/lens/server/TestServerRestart.java
+++ b/lens-server/src/test/java/org/apache/lens/server/TestServerRestart.java
@@ -26,29 +26,27 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
+
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hive.service.Service;
-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.StringList;
+import org.apache.lens.api.*;
import org.apache.lens.api.APIResult.Status;
import org.apache.lens.api.query.LensQuery;
import org.apache.lens.api.query.PersistentQueryResult;
import org.apache.lens.api.query.QueryHandle;
import org.apache.lens.api.query.QueryStatus;
import org.apache.lens.driver.hive.TestRemoteHiveDriver;
-import org.apache.lens.server.LensServices;
import org.apache.lens.server.query.QueryExecutionServiceImpl;
import org.apache.lens.server.query.TestQueryService;
-import org.apache.lens.server.session.LensSessionImpl;
import org.apache.lens.server.session.HiveSessionService;
+import org.apache.lens.server.session.LensSessionImpl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hive.service.Service;
+
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
@@ -71,7 +69,7 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#setUp()
*/
@BeforeTest
@@ -81,7 +79,7 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#tearDown()
*/
@AfterTest
@@ -93,13 +91,12 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
private boolean fileCreated;
/** The nrows. */
- final int NROWS = 10000;
+ public static final int NROWS = 10000;
/**
* Creates the restart test data file.
*
- * @throws FileNotFoundException
- * the file not found exception
+ * @throws FileNotFoundException the file not found exception
*/
private void createRestartTestDataFile() throws FileNotFoundException {
if (fileCreated) {
@@ -121,12 +118,9 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
/**
* Test query service.
*
- * @throws InterruptedException
- * the interrupted exception
- * @throws IOException
- * Signals that an I/O exception has occurred.
- * @throws LensException
- * the lens exception
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws LensException the lens exception
*/
@Test
public void testQueryService() throws InterruptedException, IOException, LensException {
@@ -163,18 +157,18 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
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 COUNT(ID) from test_server_restart"));
+ "select COUNT(ID) from test_server_restart"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(),
- new LensConf(), MediaType.APPLICATION_XML_TYPE));
+ new LensConf(), 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();
LOG.info(i + " submitted query " + handle + " state: " + ctx.getStatus().getStatus());
launchedQueries.add(handle);
@@ -191,7 +185,7 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
LOG.info("Polling query " + handle);
try {
LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
- .get(LensQuery.class);
+ .get(LensQuery.class);
QueryStatus stat = ctx.getStatus();
while (!stat.isFinished()) {
LOG.info("Polling query " + handle + " Status:" + stat);
@@ -200,9 +194,9 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
Thread.sleep(1000);
}
Assert.assertEquals(ctx.getStatus().getStatus(), QueryStatus.Status.SUCCESSFUL, "Expected to be successful "
- + handle);
+ + handle);
PersistentQueryResult resultset = target.path(handle.toString()).path("resultset")
- .queryParam("sessionid", lensSessionId).request().get(PersistentQueryResult.class);
+ .queryParam("sessionid", lensSessionId).request().get(PersistentQueryResult.class);
List<String> rows = TestQueryService.readResultSet(resultset, handle, true);
Assert.assertEquals(rows.size(), 1);
Assert.assertEquals(rows.get(0), "" + NROWS);
@@ -220,8 +214,7 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
/**
* Test hive server restart.
*
- * @throws Exception
- * the exception
+ * @throws Exception the exception
*/
@Test
public void testHiveServerRestart() throws Exception {
@@ -247,19 +240,19 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
// Submit query, restart HS2, submit another query
FormDataMultiPart mp = new FormDataMultiPart();
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(),
- "select COUNT(ID) from test_hive_server_restart"));
+ "select COUNT(ID) from test_hive_server_restart"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(),
- MediaType.APPLICATION_XML_TYPE));
+ 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);
List<LensSessionImpl.ResourceEntry> sessionResources = queryService.getSession(lensSessionId)
- .getLensSessionPersistInfo().getResources();
+ .getLensSessionPersistInfo().getResources();
int[] restoreCounts = new int[sessionResources.size()];
for (int i = 0; i < sessionResources.size(); i++) {
restoreCounts[i] = sessionResources.get(i).getRestoreCount();
@@ -285,7 +278,7 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
// Poll for first query, we should not get any exception
LensQuery ctx = target.path(handle.toString()).queryParam("sessionid", lensSessionId).request()
- .get(LensQuery.class);
+ .get(LensQuery.class);
QueryStatus stat = ctx.getStatus();
while (!stat.isFinished()) {
LOG.info("Polling query " + handle + " Status:" + stat);
@@ -301,12 +294,12 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
// Submit another query, again no exception expected
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 COUNT(ID) from test_hive_server_restart"));
+ "select COUNT(ID) from test_hive_server_restart"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(),
- new LensConf(), MediaType.APPLICATION_XML_TYPE));
+ new LensConf(), MediaType.APPLICATION_XML_TYPE));
handle = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), QueryHandle.class);
Assert.assertNotNull(handle);
@@ -326,7 +319,7 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
for (int i = 0; i < sessionResources.size(); i++) {
LensSessionImpl.ResourceEntry resourceEntry = sessionResources.get(i);
Assert.assertEquals(resourceEntry.getRestoreCount(), 1 + restoreCounts[i], "Restore test failed for "
- + resourceEntry + " pre count=" + restoreCounts[i] + " post count=" + resourceEntry.getRestoreCount());
+ + resourceEntry + " pre count=" + restoreCounts[i] + " post count=" + resourceEntry.getRestoreCount());
LOG.info("@@ Latest count " + resourceEntry + " = " + resourceEntry.getRestoreCount());
}
// Assert.assertEquals(stat.getStatus(), QueryStatus.Status.SUCCESSFUL,
@@ -340,8 +333,7 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
/**
* Test session restart.
*
- * @throws Exception
- * the exception
+ * @throws Exception the exception
*/
@Test
public void testSessionRestart() throws Exception {
@@ -353,22 +345,22 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
sessionForm.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("username").build(), "foo"));
sessionForm.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("password").build(), "bar"));
sessionForm.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionconf").fileName("sessionconf")
- .build(), new LensConf(), MediaType.APPLICATION_XML_TYPE));
+ .build(), new LensConf(), MediaType.APPLICATION_XML_TYPE));
final LensSessionHandle restartTestSession = sessionTarget.request().post(
- Entity.entity(sessionForm, MediaType.MULTIPART_FORM_DATA_TYPE), LensSessionHandle.class);
+ Entity.entity(sessionForm, MediaType.MULTIPART_FORM_DATA_TYPE), LensSessionHandle.class);
Assert.assertNotNull(restartTestSession);
// Set a param
WebTarget paramTarget = sessionTarget.path("params");
FormDataMultiPart setpart = new FormDataMultiPart();
setpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), restartTestSession,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
setpart
- .bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("key").build(), "lens.session.testRestartKey"));
+ .bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("key").build(), "lens.session.testRestartKey"));
setpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("value").build(), "myvalue"));
APIResult result = paramTarget.request().put(Entity.entity(setpart, MediaType.MULTIPART_FORM_DATA_TYPE),
- APIResult.class);
+ APIResult.class);
Assert.assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
// Add resource
@@ -376,12 +368,12 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
final WebTarget resourcetarget = target().path("session/resources");
final FormDataMultiPart mp1 = new FormDataMultiPart();
mp1.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), restartTestSession,
- MediaType.APPLICATION_XML_TYPE));
+ MediaType.APPLICATION_XML_TYPE));
mp1.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("type").build(), "file"));
mp1.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("path").build(),
- "target/test-classes/lens-site.xml"));
+ "target/test-classes/lens-site.xml"));
result = resourcetarget.path("add").request()
- .put(Entity.entity(mp1, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class);
+ .put(Entity.entity(mp1, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class);
Assert.assertEquals(result.getStatus(), Status.SUCCEEDED);
// restart server
@@ -391,9 +383,9 @@ public class TestServerRestart extends LensAllApplicationJerseyTest {
// Try and get params back
StringList sessionParams = paramTarget.queryParam("sessionid", restartTestSession).queryParam("verbose", true)
- .request().get(StringList.class);
+ .request().get(StringList.class);
sessionParams = paramTarget.queryParam("sessionid", restartTestSession)
- .queryParam("key", "lens.session.testRestartKey").request().get(StringList.class);
+ .queryParam("key", "lens.session.testRestartKey").request().get(StringList.class);
System.out.println("Session params:" + sessionParams.getElements());
Assert.assertEquals(sessionParams.getElements().size(), 1);
Assert.assertTrue(sessionParams.getElements().contains("lens.session.testRestartKey=myvalue"));
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/TestServiceProvider.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/TestServiceProvider.java b/lens-server/src/test/java/org/apache/lens/server/TestServiceProvider.java
index 734389b..5dfe780 100644
--- a/lens-server/src/test/java/org/apache/lens/server/TestServiceProvider.java
+++ b/lens-server/src/test/java/org/apache/lens/server/TestServiceProvider.java
@@ -18,14 +18,14 @@
*/
package org.apache.lens.server;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.lens.server.LensServerConf;
-import org.apache.lens.server.LensServices;
import org.apache.lens.server.api.LensConfConstants;
import org.apache.lens.server.api.ServiceProvider;
import org.apache.lens.server.api.ServiceProviderFactory;
import org.apache.lens.server.api.events.LensEventService;
import org.apache.lens.server.api.query.QueryExecutionService;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -38,14 +38,13 @@ public class TestServiceProvider extends LensAllApplicationJerseyTest {
/**
* Test service provider.
*
- * @throws Exception
- * the exception
+ * @throws Exception the exception
*/
@Test
public void testServiceProvider() throws Exception {
HiveConf conf = LensServerConf.get();
Class<? extends ServiceProviderFactory> spfClass = conf.getClass(LensConfConstants.SERVICE_PROVIDER_FACTORY, null,
- ServiceProviderFactory.class);
+ ServiceProviderFactory.class);
ServiceProviderFactory spf = spfClass.newInstance();
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/TestStartupOnMetastoreDown.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/TestStartupOnMetastoreDown.java b/lens-server/src/test/java/org/apache/lens/server/TestStartupOnMetastoreDown.java
index 2254bd8..decd6ef 100644
--- a/lens-server/src/test/java/org/apache/lens/server/TestStartupOnMetastoreDown.java
+++ b/lens-server/src/test/java/org/apache/lens/server/TestStartupOnMetastoreDown.java
@@ -22,11 +22,11 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.metadata.Hive;
+
import org.testng.Assert;
-import org.testng.annotations.Test;
public class TestStartupOnMetastoreDown {
- private static Log LOG = LogFactory.getLog(TestStartupOnMetastoreDown.class);
+ private static final Log LOG = LogFactory.getLog(TestStartupOnMetastoreDown.class);
// @Test
public void testServicesStartOnMetastoreDown() throws Exception {
@@ -41,7 +41,7 @@ public class TestStartupOnMetastoreDown {
Assert.fail("Expected init to fail because of invalid metastore config");
} catch (Throwable th) {
Assert.assertTrue(th.getMessage().contains(
- "Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient"));
+ "Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient"));
} finally {
try {
services.stop();
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/TestStaticFileResource.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/TestStaticFileResource.java b/lens-server/src/test/java/org/apache/lens/server/TestStaticFileResource.java
index abfef50..cf3b579 100644
--- a/lens-server/src/test/java/org/apache/lens/server/TestStaticFileResource.java
+++ b/lens-server/src/test/java/org/apache/lens/server/TestStaticFileResource.java
@@ -18,24 +18,25 @@
*/
package org.apache.lens.server;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.lens.server.LensServices;
-import org.apache.lens.server.api.LensConfConstants;
-import org.apache.lens.server.ui.UIApp;
-import org.glassfish.jersey.filter.LoggingFilter;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+import java.util.Set;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
-import java.net.URI;
-import java.util.Set;
+import org.apache.lens.server.api.LensConfConstants;
+import org.apache.lens.server.ui.UIApp;
-import static org.testng.Assert.assertEquals;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.glassfish.jersey.filter.LoggingFilter;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
/**
* The Class TestStaticFileResource.
@@ -47,7 +48,7 @@ public class TestStaticFileResource extends LensJerseyTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#setUp()
*/
@BeforeTest
@@ -57,7 +58,7 @@ public class TestStaticFileResource extends LensJerseyTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#tearDown()
*/
@AfterTest
@@ -67,7 +68,7 @@ public class TestStaticFileResource extends LensJerseyTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.glassfish.jersey.test.JerseyTest#configure()
*/
@Override
@@ -95,8 +96,7 @@ public class TestStaticFileResource extends LensJerseyTest {
/**
* Test static file resource.
*
- * @throws Exception
- * the exception
+ * @throws Exception the exception
*/
@Test
public void testStaticFileResource() throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/auth/FooBarAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/auth/FooBarAuthenticationProvider.java b/lens-server/src/test/java/org/apache/lens/server/auth/FooBarAuthenticationProvider.java
index adcc7b5..8e22837 100644
--- a/lens-server/src/test/java/org/apache/lens/server/auth/FooBarAuthenticationProvider.java
+++ b/lens-server/src/test/java/org/apache/lens/server/auth/FooBarAuthenticationProvider.java
@@ -18,25 +18,26 @@
*/
package org.apache.lens.server.auth;
-import org.apache.hive.service.auth.PasswdAuthenticationProvider;
-
import javax.security.sasl.AuthenticationException;
+import org.apache.hive.service.auth.PasswdAuthenticationProvider;
+
/**
* The Class FooBarAuthenticationProvider.
*/
public class FooBarAuthenticationProvider implements PasswdAuthenticationProvider {
/** The msg. */
- public static String MSG = "<username,password>!=<foo@localhost,bar>";
+ public static final String MSG = "<username,password>!=<foo@localhost,bar>";
/** The allowed combinations. */
- private final String[][] allowedCombinations = new String[][] { { "foo", "bar" }, { "anonymous", "" }, };
+ private final String[][] allowedCombinations = new String[][]{{"foo", "bar"}, {"anonymous", ""}};
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.hive.service.auth.PasswdAuthenticationProvider#Authenticate(java.lang.String, java.lang.String)
+ * SUSPEND CHECKSTYLE CHECK MethodName
*/
@Override
public void Authenticate(String username, String password) throws AuthenticationException {
@@ -47,4 +48,5 @@ public class FooBarAuthenticationProvider implements PasswdAuthenticationProvide
}
throw new AuthenticationException(MSG);
}
+ // RESUME CHECKSTYLE CHECK MethodName
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/common/LenServerTestException.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/common/LenServerTestException.java b/lens-server/src/test/java/org/apache/lens/server/common/LenServerTestException.java
index f2abfd9..7693f44 100644
--- a/lens-server/src/test/java/org/apache/lens/server/common/LenServerTestException.java
+++ b/lens-server/src/test/java/org/apache/lens/server/common/LenServerTestException.java
@@ -24,7 +24,8 @@ public class LenServerTestException extends Exception {
public LenServerTestException(final String errorMsg) {
super(errorMsg);
}
+
public LenServerTestException(final String errorMsg, final Throwable cause) {
- super(errorMsg,cause);
+ super(errorMsg, cause);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/test/java/org/apache/lens/server/common/LensServerTestFileUtils.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/common/LensServerTestFileUtils.java b/lens-server/src/test/java/org/apache/lens/server/common/LensServerTestFileUtils.java
index 5962ebb..85e8a0b 100644
--- a/lens-server/src/test/java/org/apache/lens/server/common/LensServerTestFileUtils.java
+++ b/lens-server/src/test/java/org/apache/lens/server/common/LensServerTestFileUtils.java
@@ -21,11 +21,14 @@ package org.apache.lens.server.common;
import java.io.File;
-public class LensServerTestFileUtils {
+public final class LensServerTestFileUtils {
+ private LensServerTestFileUtils() {
+
+ }
public static void deleteFile(final File file) throws LenServerTestException {
if (!file.delete()) {
- throw new LenServerTestException("Could not delete file:"+file.getPath());
+ throw new LenServerTestException("Could not delete file:" + file.getPath());
}
}
}