Merge branch 'master' of https://github.com/apache/incubator-griffin into apache-master
diff --git a/griffin-doc/service/hibernate_eclipselink_switch.md b/griffin-doc/service/hibernate_eclipselink_switch.md
index 6bfae3b..edb87af 100644
--- a/griffin-doc/service/hibernate_eclipselink_switch.md
+++ b/griffin-doc/service/hibernate_eclipselink_switch.md
@@ -139,6 +139,9 @@
 ## Migration from EclipseLink to Hibernate
 Here we'll go through steps necessary to migrate applications from using EclipseLink JPA to using Hibernate JPA.The migration will not need to convert any EclipseLink annotations to Hibernate annotations in application code. 
 
+## Quick use
+In Griffin, we provide **hibernate_mysql_pom.xml** file for hibernate and mysql. If you want to quick use hibernate and mysql with jar, firstly you should [configure properties](#2.3) and then use command `mvn clean package -f pom_hibernate.xml` to package jar.
+
 ## Migration main steps
 - [add hibernate dependency](#2.1)
 - [remove EclipseLink](#2.2)
@@ -147,7 +150,7 @@
 <h2 id = "2.1"></h2>
 
 ### Add hibernate dependency
-By default, Spring Data uses Hibernate as the default JPA implementation provider.So we just add **spring-boot-starter-data-jpa** dependency.If you have already added it, skip this step.
+By default, Spring Data uses Hibernate as the default JPA implementation provider.So we just add **spring-boot-starter-data-jpa** dependency.**If you have already added it, skip this step.**
 
     <dependency>
         <groupId>org.springframework.boot</groupId>
diff --git a/griffin-doc/service/mysql_postgresql_switch.md b/griffin-doc/service/mysql_postgresql_switch.md
index 081307c..4d8c07f 100644
--- a/griffin-doc/service/mysql_postgresql_switch.md
+++ b/griffin-doc/service/mysql_postgresql_switch.md
@@ -20,7 +20,40 @@
 # Mysql and postgresql switch
 
 ## Overview
-By default, Griffin uses EclipseLink as the default JPA implementation. 
+By default, Griffin uses EclipseLink as the default JPA implementation. This document provides ways to switch mysql and postgresql.
+
+- [Use mysql database](#1.1)
+- [Use postgresql database](#1.2)
+
+<h2 id = "1.1"></h2>
+
+## Use mysql database 
+### Add mysql dependency
+
+    <dependency>
+        <groupId>mysql</groupId>
+        <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+### Configure properties
+
+- configure application.properties
+
+        spring.datasource.url = jdbc:mysql://localhost:3306/quartz?autoReconnect=true&useSSL=false
+        spring.datasource.username = griffin
+        spring.datasource.password = 123456
+        spring.jpa.generate-ddl=true
+        spring.datasource.driver-class-name = com.mysql.jdbc.Driver
+        spring.jpa.show-sql = true
+   If you use hibernate as your jpa implentation, you need also to add following configuration.
+     
+        spring.jpa.hibernate.ddl-auto = update
+        spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
+- configure quartz.properties
+
+      org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
+
+<h2 id = "1.2"></h2>
+
 ## Use postgresql database 
 
 ### Add postgresql dependency
@@ -48,28 +81,3 @@
 
       org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
       
-## Use mysql database 
-### Add mysql dependency
-
-    <dependency>
-        <groupId>mysql</groupId>
-        <artifactId>mysql-connector-java</artifactId>
-    </dependency>
-### Configure properties
-
-- configure application.properties
-
-        spring.datasource.url = jdbc:mysql://localhost:3306/quartz?autoReconnect=true&useSSL=false
-        spring.datasource.username = griffin
-        spring.datasource.password = 123456
-        spring.jpa.generate-ddl=true
-        spring.datasource.driver-class-name = com.mysql.jdbc.Driver
-        spring.jpa.show-sql = true
-   If you use hibernate as your jpa implentation, you need also to add following configuration.
-     
-        spring.jpa.hibernate.ddl-auto = update
-        spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
-- configure quartz.properties
-
-      org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
-
diff --git a/service/hibernate_mysql_pom.xml b/service/hibernate_mysql_pom.xml
new file mode 100644
index 0000000..5a1be46
--- /dev/null
+++ b/service/hibernate_mysql_pom.xml
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.griffin</groupId>
+        <artifactId>griffin</artifactId>
+        <version>0.2.0-incubating-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>service</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Apache Griffin :: Web Service</name>
+
+    <properties>
+        <java.version>1.8</java.version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <hadoop.version>2.7.1</hadoop.version>
+        <hive.version>1.2.1</hive.version>
+        <scala.version>2.10</scala.version>
+        <spring.boot.version>1.5.1.RELEASE</spring.boot.version>
+        <confluent.version>3.2.0</confluent.version>
+        <quartz.version>2.2.1</quartz.version>
+        <start-class>org.apache.griffin.core.GriffinWebApplication</start-class>
+        <powermock.version>1.6.6</powermock.version>
+        <mockito.version>1.10.19</mockito.version>
+        <spring-boot-maven-plugin.version>1.5.1.RELEASE</spring-boot-maven-plugin.version>
+        <derby.version>10.14.1.0</derby.version>
+        <eclipselink.version>2.6.0</eclipselink.version>
+    </properties>
+
+    <repositories>
+        <repository>
+            <id>confluent</id>
+            <url>http://packages.confluent.io/maven/</url>
+        </repository>
+    </repositories>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-dependencies</artifactId>
+                <version>${spring.boot.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-aspects</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.jpa</artifactId>
+            <version>${eclipselink.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.retry</groupId>
+            <artifactId>spring-retry</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.6.3</version>
+        </dependency>
+        <!-- to access metastore from hive-->
+        <dependency>
+            <groupId>org.apache.hadoop</groupId>
+            <artifactId>hadoop-client</artifactId>
+            <version>${hadoop.version}</version>
+            <!--<scope>provided</scope>-->
+            <exclusions>
+                <exclusion>
+                    <artifactId>servlet-api</artifactId>
+                    <groupId>javax.servlet</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.hive</groupId>
+            <artifactId>hive-metastore</artifactId>
+            <version>${hive.version}</version>
+        </dependency>
+
+        <!-- to access confluent schema registry -->
+        <dependency>
+            <groupId>io.confluent</groupId>
+            <artifactId>kafka-schema-registry-client</artifactId>
+            <version>${confluent.version}</version>
+        </dependency>
+
+        <!--schedule-->
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context-support</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.quartz-scheduler</groupId>
+            <artifactId>quartz</artifactId>
+            <version>2.2.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.quartz-scheduler</groupId>
+            <artifactId>quartz-jobs</artifactId>
+            <version>2.2.2</version>
+        </dependency>
+
+        <!--livy-core-->
+        <dependency>
+            <groupId>com.cloudera.livy</groupId>
+            <artifactId>livy-core_2.10</artifactId>
+            <version>0.3.0</version>
+        </dependency>
+
+        <!-- test -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.powermock</groupId>
+            <artifactId>powermock-api-mockito</artifactId>
+            <version>${powermock.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.powermock</groupId>
+            <artifactId>powermock-module-junit4</artifactId>
+            <version>${powermock.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.elasticsearch.client</groupId>
+            <artifactId>elasticsearch-rest-client</artifactId>
+            <version>6.0.1</version>
+        </dependency>
+    </dependencies>
+    <profiles>
+    </profiles>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring-boot-maven-plugin.version}</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <fork>true</fork>
+                    <layout>ZIP</layout>
+                    <mainClass>org.apache.griffin.core.GriffinWebApplication</mainClass>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                </configuration>
+
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/service/src/main/java/org/apache/griffin/core/util/PropertiesUtil.java b/service/src/main/java/org/apache/griffin/core/util/PropertiesUtil.java
index 415c9c1..28cd4e8 100644
--- a/service/src/main/java/org/apache/griffin/core/util/PropertiesUtil.java
+++ b/service/src/main/java/org/apache/griffin/core/util/PropertiesUtil.java
@@ -51,9 +51,9 @@
     }
 
     /**
-     * @param name properties name like sparkJob.properties
+     * @param name        properties name like sparkJob.properties
      * @param defaultPath properties classpath like /application.properties
-     * @param location custom properties path
+     * @param location    custom properties path
      * @return Properties
      * @throws FileNotFoundException location setting is wrong that there is no target file.
      */
@@ -66,10 +66,10 @@
         } else {
             resource = new InputStreamResource(new FileInputStream(path));
         }
-        return PropertiesUtil.getProperties(path, resource);
+        return getProperties(path, resource);
     }
 
-    private static String getConfPath(String name, String location) throws FileNotFoundException {
+    private static String getConfPath(String name, String location) {
         if (StringUtils.isEmpty(location)) {
             LOGGER.info("Config location is empty. Read from default path.");
             return null;
@@ -78,8 +78,8 @@
         LOGGER.info("File absolute path:" + file.getAbsolutePath());
         File[] files = file.listFiles();
         if (files == null) {
-            LOGGER.warn("The defaultPath {} does not exist.Please check your config in application.properties.", location);
-            throw new FileNotFoundException();
+            LOGGER.warn("The external.config.location '{}' does not exist.Read from default path.", location);
+            return null;
         }
         return getConfPath(name, files, location);
     }
diff --git a/service/src/main/resources/application.properties b/service/src/main/resources/application.properties
index c8f1992..555e317 100644
--- a/service/src/main/resources/application.properties
+++ b/service/src/main/resources/application.properties
@@ -22,14 +22,10 @@
 spring.datasource.password = 123456
 spring.jpa.generate-ddl=true
 
-spring.datasource.driverClassName = org.postgresql.Driver
+spring.datasource.driver-class-name = org.postgresql.Driver
 
 spring.jpa.show-sql = true
 
-#spring.jpa.properties.eclipselink.weaving=static
-#spring.jpa.properties.persistence-unit-name=eclipselink-example
-#spring.jpa.properties.persistence-xml-location=persistence.xml
-
 # Hive metastore
 hive.metastore.uris = thrift://localhost:9083
 hive.metastore.dbname = default
diff --git a/service/src/main/resources/quartz.properties b/service/src/main/resources/quartz.properties
index aaf24fe..503a8bc 100644
--- a/service/src/main/resources/quartz.properties
+++ b/service/src/main/resources/quartz.properties
@@ -22,6 +22,8 @@
 org.quartz.scheduler.instanceId=AUTO
 org.quartz.threadPool.threadCount=5
 org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
+# If you use postgresql as your database,set this property value to org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
+# If you use mysql as your database,set this property value to org.quartz.impl.jdbcjobstore.StdJDBCDelegate
 org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
 org.quartz.jobStore.useProperties=true
 org.quartz.jobStore.misfireThreshold=60000
diff --git a/service/src/test/java/org/apache/griffin/core/config/PropertiesConfigTest.java b/service/src/test/java/org/apache/griffin/core/config/PropertiesConfigTest.java
index 2b8b2cf..547cb97 100644
--- a/service/src/test/java/org/apache/griffin/core/config/PropertiesConfigTest.java
+++ b/service/src/test/java/org/apache/griffin/core/config/PropertiesConfigTest.java
@@ -112,10 +112,6 @@
         assertEquals(conf.get("sparkJob.name"), "test");
     }
 
-    @Test(expected = FileNotFoundException.class)
-    public void livyConfWithFileNotFoundException() throws FileNotFoundException {
-        livyNotFoundConfig.livyConf();
-    }
 
     @Test
     public void quartzConfWithLocationNotNull() throws Exception {
@@ -128,10 +124,4 @@
         Properties conf = noQuartzConf.quartzConf();
         assertEquals(conf.get("org.quartz.scheduler.instanceName"), "spring-boot-quartz-test");
     }
-
-    @Test(expected = FileNotFoundException.class)
-    public void quartzConfWithFileNotFoundException() throws FileNotFoundException {
-        quartzNotFoundConfig.livyConf();
-    }
-
 }
\ No newline at end of file
diff --git a/service/src/test/java/org/apache/griffin/core/measure/MeasureOrgServiceImplTest.java b/service/src/test/java/org/apache/griffin/core/measure/MeasureOrgServiceImplTest.java
index 939c0da..cc3828a 100644
--- a/service/src/test/java/org/apache/griffin/core/measure/MeasureOrgServiceImplTest.java
+++ b/service/src/test/java/org/apache/griffin/core/measure/MeasureOrgServiceImplTest.java
@@ -28,10 +28,7 @@
 import org.mockito.Mock;
 import org.springframework.test.context.junit4.SpringRunner;
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import static org.apache.griffin.core.util.EntityHelper.createGriffinMeasure;
 import static org.apache.griffin.core.util.EntityHelper.createJobDetailMap;
@@ -76,10 +73,10 @@
     }
 
     @Test
-    public void testGetMeasureNamesGroupByOrgWithNull() throws Exception {
-        when(measureRepo.findByDeleted(false)).thenReturn(null);
+    public void testGetMeasureNamesGroupByOrgWithEmpty(){
+        when(measureRepo.findByDeleted(false)).thenReturn(new ArrayList<>());
         Map<String, List<String>> map = service.getMeasureNamesGroupByOrg();
-        assert map == null;
+        assert map.size() == 0;
     }
 
     @Test
diff --git a/service/src/test/java/org/apache/griffin/core/util/PropertiesUtilTest.java b/service/src/test/java/org/apache/griffin/core/util/PropertiesUtilTest.java
index 80481b3..e0ffbb6 100644
--- a/service/src/test/java/org/apache/griffin/core/util/PropertiesUtilTest.java
+++ b/service/src/test/java/org/apache/griffin/core/util/PropertiesUtilTest.java
@@ -62,14 +62,6 @@
         assert properties != null;
     }
 
-    @Test(expected = FileNotFoundException.class)
-    public void testGetConfWithLocationWrong() throws FileNotFoundException {
-        String name = "sparkJob.properties";
-        String defaultPath = "/" + name;
-        String location = "wrong/path";
-        getConf(name, defaultPath, location);
-    }
-
     @Test
     public void testGetConfWithNoLocation() throws FileNotFoundException {
         String name = "sparkJob.properties";