diff --git a/beeline/src/java/org/apache/hive/beeline/hs2connection/BeelineSiteParser.java b/beeline/src/java/org/apache/hive/beeline/hs2connection/BeelineSiteParser.java index 600d84e..4c55104 100644 --- a/beeline/src/java/org/apache/hive/beeline/hs2connection/BeelineSiteParser.java +++ b/beeline/src/java/org/apache/hive/beeline/hs2connection/BeelineSiteParser.java @@ -63,7 +63,7 @@ public BeelineSiteParser() { locations .add(System.getenv("HIVE_CONF_DIR") + File.separator + DEFAULT_BEELINE_SITE_FILE_NAME); } - locations.add(ETC_HIVE_CONF_LOCATION + DEFAULT_BEELINE_SITE_FILE_NAME); + locations.add(ETC_HIVE_CONF_LOCATION + File.separator + DEFAULT_BEELINE_SITE_FILE_NAME); } @VisibleForTesting diff --git a/beeline/src/java/org/apache/hive/beeline/hs2connection/UserHS2ConnectionFileParser.java b/beeline/src/java/org/apache/hive/beeline/hs2connection/UserHS2ConnectionFileParser.java index 9d45daf..47dee4c 100644 --- a/beeline/src/java/org/apache/hive/beeline/hs2connection/UserHS2ConnectionFileParser.java +++ b/beeline/src/java/org/apache/hive/beeline/hs2connection/UserHS2ConnectionFileParser.java @@ -56,7 +56,7 @@ public UserHS2ConnectionFileParser() { locations.add( System.getenv("HIVE_CONF_DIR") + File.separator + DEFAULT_CONNECTION_CONFIG_FILE_NAME); } - locations.add(ETC_HIVE_CONF_LOCATION + DEFAULT_CONNECTION_CONFIG_FILE_NAME); + locations.add(ETC_HIVE_CONF_LOCATION + File.separator + DEFAULT_CONNECTION_CONFIG_FILE_NAME); } @VisibleForTesting diff --git a/beeline/src/test/org/apache/hive/beeline/hs2connection/TestBeelineSiteParser.java b/beeline/src/test/org/apache/hive/beeline/hs2connection/TestBeelineSiteParser.java new file mode 100644 index 0000000..fc2b44d --- /dev/null +++ b/beeline/src/test/org/apache/hive/beeline/hs2connection/TestBeelineSiteParser.java @@ -0,0 +1,41 @@ +/* + * 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.hive.beeline.hs2connection; + +import java.io.File; +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.List; +import org.junit.Assert; +import org.junit.Test; + +public class TestBeelineSiteParser { + @Test + public void testConfigLocationPathInEtc() throws Exception { + BeelineSiteParser testHS2ConfigManager = + new BeelineSiteParser(); + Field locations = testHS2ConfigManager.getClass().getDeclaredField("locations"); + locations.setAccessible(true); + Collection locs = (List)locations.get(testHS2ConfigManager); + Assert.assertTrue(locs.contains( + BeelineSiteParser.ETC_HIVE_CONF_LOCATION + + File.separator + + BeelineSiteParser.DEFAULT_BEELINE_SITE_FILE_NAME)); + + } +} diff --git a/beeline/src/test/org/apache/hive/beeline/hs2connection/TestUserHS2ConnectionFileParser.java b/beeline/src/test/org/apache/hive/beeline/hs2connection/TestUserHS2ConnectionFileParser.java index f5923d1..78c3a77 100644 --- a/beeline/src/test/org/apache/hive/beeline/hs2connection/TestUserHS2ConnectionFileParser.java +++ b/beeline/src/test/org/apache/hive/beeline/hs2connection/TestUserHS2ConnectionFileParser.java @@ -18,7 +18,9 @@ package org.apache.hive.beeline.hs2connection; import java.io.File; +import java.lang.reflect.Field; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import org.apache.hive.beeline.hs2connection.BeelineHS2ConnectionFileParseException; @@ -171,6 +173,20 @@ public void testGetLocationOrder() throws Exception { LOCATION_2.equals(testHS2ConfigManager.getFileLocation())); } + @Test + public void testConfigLocationPathInEtc() throws Exception { + UserHS2ConnectionFileParser testHS2ConfigManager = + new UserHS2ConnectionFileParser(); + Field locations = testHS2ConfigManager.getClass().getDeclaredField("locations"); + locations.setAccessible(true); + Collection locs = (List)locations.get(testHS2ConfigManager); + Assert.assertTrue(locs.contains( + UserHS2ConnectionFileParser.ETC_HIVE_CONF_LOCATION + + File.separator + + UserHS2ConnectionFileParser.DEFAULT_CONNECTION_CONFIG_FILE_NAME)); + + } + private String getParsedUrlFromConfigFile(String filename) throws BeelineHS2ConnectionFileParseException { String path = HiveTestUtils.getFileFromClasspath(filename);