Repository: incubator-griffin Updated Branches: refs/heads/master b6add9c24 -> f8574521e
Test Author: Eugene <[email protected]> Closes #347 from toyboxman/test. Project: http://git-wip-us.apache.org/repos/asf/incubator-griffin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-griffin/commit/f8574521 Tree: http://git-wip-us.apache.org/repos/asf/incubator-griffin/tree/f8574521 Diff: http://git-wip-us.apache.org/repos/asf/incubator-griffin/diff/f8574521 Branch: refs/heads/master Commit: f8574521eedd0f18b39e5bbe9a047bf51f3fa352 Parents: b6add9c Author: Eugene <[email protected]> Authored: Fri Jul 13 08:33:22 2018 +0800 Committer: William Guo <[email protected]> Committed: Fri Jul 13 08:33:22 2018 +0800 ---------------------------------------------------------------------- .../core/config/PropertiesConfigTest.java | 252 +++++++++---------- service/src/test/resources/sparkProperties.json | 16 ++ 2 files changed, 141 insertions(+), 127 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/f8574521/service/src/test/java/org/apache/griffin/core/config/PropertiesConfigTest.java ---------------------------------------------------------------------- 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 b452b46..5783b4b 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 @@ -1,127 +1,125 @@ -///* -//Licensed to the Apache Software Foundation (ASF) under one -//or more contributor license agreements. See the NOTICE file -//distributed with this work for additional information -//regarding copyright ownership. The ASF licenses this file -//to you under the Apache License, Version 2.0 (the -//"License"); you may not use this file except in compliance -//with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -//Unless required by applicable law or agreed to in writing, -//software distributed under the License is distributed on an -//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -//KIND, either express or implied. See the License for the -//specific language governing permissions and limitations -//under the License. -//*/ -// -//package org.apache.griffin.core.config; -// -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.beans.factory.annotation.Qualifier; -//import org.springframework.boot.test.context.TestConfiguration; -//import org.springframework.context.annotation.Bean; -//import org.springframework.test.context.junit4.SpringRunner; -// -//import java.io.FileNotFoundException; -//import java.util.Properties; -// -//import static org.junit.Assert.assertEquals; -// -//@RunWith(SpringRunner.class) -//public class PropertiesConfigTest { -// -// @TestConfiguration -// public static class PropertiesConf { -// -//// @Bean(name = "noLivyConf") -//// public PropertiesConfig noSparkConf() { -//// return new PropertiesConfig(null); -//// } -//// -//// @Bean(name = "livyConf") -//// public PropertiesConfig sparkConf() { -//// return new PropertiesConfig("src/test/resources"); -//// } -//// -//// @Bean(name = "livyNotFoundConfig") -//// public PropertiesConfig sparkNotFoundConfig() { -//// return new PropertiesConfig("test"); -//// } -//// -//// @Bean(name = "noQuartzConf") -//// public PropertiesConfig noQuartzConf() { -//// return new PropertiesConfig(null); -//// } -//// -//// @Bean(name = "quartzConf") -//// public PropertiesConfig quartzConf() { -//// return new PropertiesConfig("src/test/resources"); -//// } -//// -//// @Bean(name = "quartzNotFoundConfig") -//// public PropertiesConfig quartzNotFoundConfig() { -//// return new PropertiesConfig("test"); -//// } -// } -// -// @Autowired -// @Qualifier(value = "noLivyConf") -// private PropertiesConfig noLivyConf; -// -// @Autowired -// @Qualifier(value = "livyConf") -// private PropertiesConfig livyConf; -// -// @Autowired -// @Qualifier(value = "livyNotFoundConfig") -// private PropertiesConfig livyNotFoundConfig; -// -// -// @Autowired -// @Qualifier(value = "noQuartzConf") -// private PropertiesConfig noQuartzConf; -// -// @Autowired -// @Qualifier(value = "quartzConf") -// private PropertiesConfig quartzConf; -// -// @Autowired -// @Qualifier(value = "quartzNotFoundConfig") -// private PropertiesConfig quartzNotFoundConfig; -// -//// @Test -//// public void appConf() { -//// Properties conf = noLivyConf.appConf(); -//// assertEquals(conf.get("spring.datasource.username"), "test"); -//// } -// -//// @Test -//// public void livyConfWithLocationNotNull() throws Exception { -//// Properties conf = livyConf.livyConf(); -//// assertEquals(conf.get("sparkJob.name"), "test"); -//// } -// -//// @Test -//// public void livyConfWithLocationNull() throws Exception { -//// Properties conf = noLivyConf.livyConf(); -//// assertEquals(conf.get("sparkJob.name"), "test"); -//// } -// -// -// @Test -// public void quartzConfWithLocationNotNull() throws Exception { -// Properties conf = quartzConf.quartzConf(); -// assertEquals(conf.get("org.quartz.scheduler.instanceName"), "spring-boot-quartz-test"); -// } -// -// @Test -// public void quartzConfWithLocationNull() throws Exception { -// Properties conf = noQuartzConf.quartzConf(); -// assertEquals(conf.get("org.quartz.scheduler.instanceName"), "spring-boot-quartz-test"); -// } -//} \ No newline at end of file +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +package org.apache.griffin.core.config; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.Properties; + +import static org.junit.Assert.assertEquals; + +@RunWith(SpringRunner.class) +public class PropertiesConfigTest { + + @TestConfiguration + public static class PropertiesConf { + + @Bean(name = "noLivyConf") + public PropertiesConfig noSparkConf() { + return new PropertiesConfig(null, null); + } + + @Bean(name = "livyConf") + public PropertiesConfig sparkConf() { + return new PropertiesConfig("src/test/resources", null); + } + + @Bean(name = "livyNotFoundConfig") + public PropertiesConfig sparkNotFoundConfig() { + return new PropertiesConfig("test", null); + } + + @Bean(name = "noQuartzConf") + public PropertiesConfig noQuartzConf() { + return new PropertiesConfig(null, null); + } + + @Bean(name = "quartzConf") + public PropertiesConfig quartzConf() { + return new PropertiesConfig("src/test/resources", null); + } + + @Bean(name = "quartzNotFoundConfig") + public PropertiesConfig quartzNotFoundConfig() { + return new PropertiesConfig("test", null); + } + } + + @Autowired + @Qualifier(value = "noLivyConf") + private PropertiesConfig noLivyConf; + + @Autowired + @Qualifier(value = "livyConf") + private PropertiesConfig livyConf; + + @Autowired + @Qualifier(value = "livyNotFoundConfig") + private PropertiesConfig livyNotFoundConfig; + + + @Autowired + @Qualifier(value = "noQuartzConf") + private PropertiesConfig noQuartzConf; + + @Autowired + @Qualifier(value = "quartzConf") + private PropertiesConfig quartzConf; + + @Autowired + @Qualifier(value = "quartzNotFoundConfig") + private PropertiesConfig quartzNotFoundConfig; + + @Test + public void appConf() throws Exception { + String conf = (String) noLivyConf.livyConfMap.get("name"); + assertEquals("test", conf); + } + + @Test + public void livyConfWithLocationNotNull() throws Exception { + String conf = (String) livyConf.livyConfMap.get("sparkJob.name"); + assertEquals("testJob", conf); + } + + @Test + public void livyConfWithLocationNull() throws Exception { + String conf = (String) noLivyConf.livyConfMap.get("sparkJob.name"); + assertEquals("testJob", conf); + } + + @Test + public void quartzConfWithLocationNotNull() throws Exception { + Properties conf = quartzConf.quartzConf(); + assertEquals(conf.get("org.quartz.scheduler.instanceName"), "spring-boot-quartz-test"); + } + + @Test + public void quartzConfWithLocationNull() throws Exception { + Properties conf = noQuartzConf.quartzConf(); + assertEquals(conf.get("org.quartz.scheduler.instanceName"), "spring-boot-quartz-test"); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/f8574521/service/src/test/resources/sparkProperties.json ---------------------------------------------------------------------- diff --git a/service/src/test/resources/sparkProperties.json b/service/src/test/resources/sparkProperties.json new file mode 100644 index 0000000..866e22a --- /dev/null +++ b/service/src/test/resources/sparkProperties.json @@ -0,0 +1,16 @@ +{ + "file": "hdfs:///griffin/griffin-measure.jar", + "className": "org.apache.griffin.measure.Application", + "name": "test", + "queue": "default", + "numExecutors": 3, + "executorCores": 1, + "driverMemory": "1g", + "executorMemory": "1g", + "sparkJob.name": "testJob", + "conf": { + "spark.yarn.dist.files": "hdfs:///home/spark_conf/hive-site.xml" + }, + "files": [ + ] +} \ No newline at end of file
