KNOX-485 - make the data/deployments directory configurable (Andreina J via 
lmccay)

Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/c1b9a27b
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/c1b9a27b
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/c1b9a27b

Branch: refs/heads/master
Commit: c1b9a27bf8061074a2635f7f90ef73504faf8f91
Parents: 8c39133
Author: Larry McCay <lmc...@hortonworks.com>
Authored: Tue Jan 27 08:58:45 2015 -0500
Committer: Larry McCay <lmc...@hortonworks.com>
Committed: Tue Jan 27 08:58:45 2015 -0500

----------------------------------------------------------------------
 .../gateway/config/impl/GatewayConfigImpl.java    |  2 +-
 .../hadoop/gateway/GatewayGlobalConfigTest.java   | 18 ++++++++++++++++++
 .../resources/conf-demo/conf/gateway-default.xml  |  5 +++++
 .../resources/conf-demo/conf/gateway-site.xml     |  5 +++++
 4 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/c1b9a27b/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
----------------------------------------------------------------------
diff --git 
a/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
 
b/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
index d4819c1..87691b9 100644
--- 
a/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
+++ 
b/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
@@ -275,7 +275,7 @@ public class GatewayConfigImpl extends Configuration 
implements GatewayConfig {
 
   @Override
   public String getGatewayDeploymentDir() {
-    return getGatewayDataDir() + File.separator + "deployments";
+    return get(DEPLOYMENT_DIR, getGatewayDataDir() + File.separator + 
DEFAULT_DEPLOYMENT_DIR);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/knox/blob/c1b9a27b/gateway-server/src/test/java/org/apache/hadoop/gateway/GatewayGlobalConfigTest.java
----------------------------------------------------------------------
diff --git 
a/gateway-server/src/test/java/org/apache/hadoop/gateway/GatewayGlobalConfigTest.java
 
b/gateway-server/src/test/java/org/apache/hadoop/gateway/GatewayGlobalConfigTest.java
index 279198c..4534165 100644
--- 
a/gateway-server/src/test/java/org/apache/hadoop/gateway/GatewayGlobalConfigTest.java
+++ 
b/gateway-server/src/test/java/org/apache/hadoop/gateway/GatewayGlobalConfigTest.java
@@ -84,4 +84,22 @@ public class GatewayGlobalConfigTest {
     GatewayConfig config = new GatewayConfigImpl();
     assertThat( config.getDefaultAppRedirectPath(), is( "/gateway/sandbox" ) );
   }
+
+  @Test
+  public void testForUpdatedDeploymentDir() {
+    String homeDirName = getHomeDirName("conf-demo/conf/gateway-site.xml");
+    System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, homeDirName);
+    System.setProperty(GatewayConfigImpl.GATEWAY_DATA_HOME_VAR, homeDirName);
+    GatewayConfig config = new GatewayConfigImpl();
+    assertTrue(("/test").equalsIgnoreCase(config.getGatewayDeploymentDir()));
+  }
+
+  @Test
+  public void testDefaultDeploymentDir() {
+    String homeDirName = getHomeDirName("conf-site/conf/gateway-site.xml");
+    System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, homeDirName);
+    System.setProperty(GatewayConfigImpl.GATEWAY_DATA_HOME_VAR, homeDirName);
+    GatewayConfig config = new GatewayConfigImpl();
+    assertThat(config.getGatewayDeploymentDir(), is(homeDirName + 
File.separator + "deployments"));
+  }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/c1b9a27b/gateway-server/src/test/resources/conf-demo/conf/gateway-default.xml
----------------------------------------------------------------------
diff --git 
a/gateway-server/src/test/resources/conf-demo/conf/gateway-default.xml 
b/gateway-server/src/test/resources/conf-demo/conf/gateway-default.xml
index 80a4c96..0adf47f 100644
--- a/gateway-server/src/test/resources/conf-demo/conf/gateway-default.xml
+++ b/gateway-server/src/test/resources/conf-demo/conf/gateway-default.xml
@@ -48,4 +48,9 @@ limitations under the License.
         <value>SSLv3</value>
         <description>Excluded SSL protocols.</description>
     </property>
+    <property>
+        <name>gateway.deployment.dir</name>
+        <value>/test</value>
+        <description>The path that contains deployments.</description>
+    </property>
 </configuration>

http://git-wip-us.apache.org/repos/asf/knox/blob/c1b9a27b/gateway-server/src/test/resources/conf-demo/conf/gateway-site.xml
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/resources/conf-demo/conf/gateway-site.xml 
b/gateway-server/src/test/resources/conf-demo/conf/gateway-site.xml
index 518e737..0635bde 100644
--- a/gateway-server/src/test/resources/conf-demo/conf/gateway-site.xml
+++ b/gateway-server/src/test/resources/conf-demo/conf/gateway-site.xml
@@ -54,5 +54,10 @@ limitations under the License.
         <value>shiro.ini</value>
         <description>The location of the Shiro configuration 
file.</description>
     </property>
+    <property>
+        <name>gateway.deployment.dir</name>
+        <value>/test</value>
+        <description>The path that contains deployments.</description>
+    </property>
 
 </configuration>

Reply via email to