Repository: incubator-lens Updated Branches: refs/heads/current-release-line db73c5e97 -> b0edfb964
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-server/src/test/java/org/apache/lens/server/metastore/TestMetastoreService.java ---------------------------------------------------------------------- diff --git a/lens-server/src/test/java/org/apache/lens/server/metastore/TestMetastoreService.java b/lens-server/src/test/java/org/apache/lens/server/metastore/TestMetastoreService.java index 885a69a..dc1dc1d 100644 --- a/lens-server/src/test/java/org/apache/lens/server/metastore/TestMetastoreService.java +++ b/lens-server/src/test/java/org/apache/lens/server/metastore/TestMetastoreService.java @@ -54,8 +54,6 @@ import org.apache.hadoop.hive.metastore.api.FieldSchema; import org.apache.hadoop.hive.ql.session.SessionState; import org.apache.hadoop.mapred.SequenceFileInputFormat; import org.apache.log4j.BasicConfigurator; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.media.multipart.FormDataBodyPart; @@ -67,9 +65,11 @@ import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; +import lombok.extern.slf4j.Slf4j; + +@Slf4j @Test(groups = "unit-test") public class TestMetastoreService extends LensJerseyTest { - public static final Logger LOG = LogManager.getLogger(TestMetastoreService.class); private ObjectFactory cubeObjectFactory; protected String mediaType = MediaType.APPLICATION_XML; protected MediaType medType = MediaType.APPLICATION_XML_TYPE; @@ -152,7 +152,7 @@ public class TestMetastoreService extends LensJerseyTest { result = dbTarget.queryParam("sessionid", lensSessionId).queryParam("ignoreIfExisting", false) .request(mediaType).post(Entity.xml(newDb), APIResult.class); assertEquals(result.getStatus(), APIResult.Status.FAILED); - LOG.info(">> Result message " + result.getMessage()); + log.info(">> Result message " + result.getMessage()); // Drop dbTarget.path(newDb).queryParam("sessionid", lensSessionId).request().delete(); @@ -768,7 +768,7 @@ public class TestMetastoreService extends LensJerseyTest { .get(new GenericType<JAXBElement<XCube>>() {}); fail("Should have thrown 404, got:" + got); } catch (NotFoundException ex) { - ex.printStackTrace(); + log.error("Resource not found.", ex); } target = target().path("metastore").path("cubes").path("test_drop_cube"); @@ -782,7 +782,7 @@ public class TestMetastoreService extends LensJerseyTest { .get(new GenericType<JAXBElement<XCube>>() {}); fail("Should have thrown 404, got :" + got); } catch (NotFoundException ex) { - ex.printStackTrace(); + log.error("Resource not found.", ex); } } finally { dropDatabase(DB); @@ -1222,7 +1222,7 @@ public class TestMetastoreService extends LensJerseyTest { mediaType).get(new GenericType<JAXBElement<XDimension>>() {}); fail("Should have thrown 404, but got" + got.getValue().getName()); } catch (NotFoundException ex) { - ex.printStackTrace(); + log.error("Resource not found.", ex); } try { @@ -1230,7 +1230,7 @@ public class TestMetastoreService extends LensJerseyTest { .queryParam("sessionid", lensSessionId).request(mediaType).delete(APIResult.class); fail("Should have thrown 404, but got" + result.getStatus()); } catch (NotFoundException ex) { - ex.printStackTrace(); + log.error("Resource not found.", ex); } } finally { dropDatabase(DB); @@ -1264,7 +1264,7 @@ public class TestMetastoreService extends LensJerseyTest { .queryParam("sessionid", lensSessionId).request(mediaType).delete(APIResult.class); fail("Should have got 404"); } catch (NotFoundException e404) { - LOG.info("correct"); + log.info("correct"); } } finally { http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/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 dc243aa..62c24ba 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 @@ -63,8 +63,6 @@ import org.apache.lens.server.error.LensExceptionMapper; 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.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FileStatus; @@ -85,15 +83,15 @@ import org.testng.annotations.Test; import com.codahale.metrics.MetricRegistry; +import lombok.extern.slf4j.Slf4j; + /** * The Class TestQueryService. */ +@Slf4j @Test(groups = "unit-test") public class TestQueryService extends LensJerseyTest { - /** The Constant LOG. */ - public static final Log LOG = LogFactory.getLog(TestQueryService.class); - /** The query service. */ QueryExecutionServiceImpl queryService; @@ -736,7 +734,7 @@ public class TestQueryService extends LensJerseyTest { } // Test http download end point - LOG.info("Starting httpendpoint test"); + log.info("Starting httpendpoint test"); final FormDataMultiPart mp3 = new FormDataMultiPart(); mp3.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, MediaType.APPLICATION_XML_TYPE)); @@ -894,7 +892,7 @@ public class TestQueryService extends LensJerseyTest { */ static void validateHttpEndPoint(WebTarget parent, LensSessionHandle lensSessionId, QueryHandle handle, String redirectUrl) throws IOException { - LOG.info("@@@ validateHttpEndPoint sessionid " + lensSessionId); + log.info("@@@ validateHttpEndPoint sessionid " + lensSessionId); Response response = parent.path("queryapi/queries/" + handle.toString() + "/httpresultset") .queryParam("sessionid", lensSessionId).request().get(); @@ -933,7 +931,7 @@ public class TestQueryService extends LensJerseyTest { Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); } catch (NotFoundException e) { // expected - e.printStackTrace(); + log.error("Resource not found.", e); } } @@ -1348,7 +1346,7 @@ public class TestQueryService extends LensJerseyTest { File testJarFile = new File("testdata/test2.jar"); sessionService.addResourceToAllServices(sessionHandle, "jar", "file://" + testJarFile.getAbsolutePath()); - LOG.info("@@@ Opened session " + sessionHandle.getPublicId() + " with database " + LensTestUtil.DB_WITH_JARS); + log.info("@@@ Opened session " + sessionHandle.getPublicId() + " with database " + LensTestUtil.DB_WITH_JARS); LensSessionImpl session = sessionService.getSession(sessionHandle); // Jars should be pending until query is run @@ -1373,7 +1371,7 @@ public class TestQueryService extends LensJerseyTest { Assert.assertTrue(addedToHiveDriver); // Switch database - LOG.info("@@@# database switch test"); + log.info("@@@# database switch test"); session.setCurrentDatabase(LensTestUtil.DB_WITH_JARS_2); LensTestUtil.createTable(tableInDBWithJars + "_2", target(), sessionHandle, "(ID INT, IDSTR STRING) " + "ROW FORMAT SERDE \"DatabaseJarSerde\""); @@ -1393,12 +1391,12 @@ public class TestQueryService extends LensJerseyTest { Assert.assertTrue(session.getPendingSessionResourcesForDatabase(LensTestUtil.DB_WITH_JARS_2).isEmpty()); } finally { - LOG.info("@@@ TEST_OVER"); + log.info("@@@ TEST_OVER"); try { LensTestUtil.dropTable(tableInDBWithJars, target(), sessionHandle); LensTestUtil.dropTable(tableInDBWithJars + "_2", target(), sessionHandle); } catch (Throwable th) { - th.printStackTrace(); + log.error("Exception while dropping table.", th); } sessionService.closeSession(sessionHandle); } http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-server/src/test/java/org/apache/lens/server/session/TestDatabaseResourceService.java ---------------------------------------------------------------------- diff --git a/lens-server/src/test/java/org/apache/lens/server/session/TestDatabaseResourceService.java b/lens-server/src/test/java/org/apache/lens/server/session/TestDatabaseResourceService.java index 640cc41..28bed27 100644 --- a/lens-server/src/test/java/org/apache/lens/server/session/TestDatabaseResourceService.java +++ b/lens-server/src/test/java/org/apache/lens/server/session/TestDatabaseResourceService.java @@ -27,8 +27,6 @@ import java.util.List; import org.apache.lens.server.LensTestUtil; import org.apache.lens.server.api.LensConfConstants; -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; @@ -37,9 +35,11 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import lombok.extern.slf4j.Slf4j; + +@Slf4j public class TestDatabaseResourceService { private static final String DB_PFX = TestDatabaseResourceService.class.getSimpleName(); - public static final Log LOG = LogFactory.getLog(TestDatabaseResourceService.class); public static final String TEST_CLASS = "ClassLoaderTestClass"; @@ -85,7 +85,7 @@ public class TestDatabaseResourceService { for (URL url : db1Loader.getURLs()) { String jarFile = url.getPath(); if (jarFile.endsWith(db + ".jar")) { - LOG.info("Found jar url " + url.toString()); + log.info("Found jar url " + url.toString()); return true; } } @@ -132,7 +132,7 @@ public class TestDatabaseResourceService { Class clz = Class.forName("ClassLoaderTestClass", true, getClass().getClassLoader()); Assert.fail("Expected class loading to fail"); } catch (Throwable th) { - LOG.error("Expected error " + th + " msg = "+th.getMessage()); + log.error("Expected error " + th + " msg = "+th.getMessage(), th); } // Should pass now http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-server/src/test/java/org/apache/lens/server/stats/TestStatisticsLogFileScannerTask.java ---------------------------------------------------------------------- diff --git a/lens-server/src/test/java/org/apache/lens/server/stats/TestStatisticsLogFileScannerTask.java b/lens-server/src/test/java/org/apache/lens/server/stats/TestStatisticsLogFileScannerTask.java index bf0526f..d5e60c4 100644 --- a/lens-server/src/test/java/org/apache/lens/server/stats/TestStatisticsLogFileScannerTask.java +++ b/lens-server/src/test/java/org/apache/lens/server/stats/TestStatisticsLogFileScannerTask.java @@ -37,9 +37,12 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import lombok.extern.slf4j.Slf4j; + /** * The Class TestStatisticsLogFileScannerTask. */ +@Slf4j @Test(groups = "unit-test") public class TestStatisticsLogFileScannerTask { @@ -100,7 +103,7 @@ public class TestStatisticsLogFileScannerTask { } }).when(service).notifyEvent(Mockito.any(PartitionEvent.class)); } catch (Exception e) { - e.printStackTrace(); + log.error("Error while running test.", e); } task.setService(service); task.run();
