knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dillido...@apache.org
Subject git commit: KNOX-223 : generated shiro.ini file does not preserve property order
Date Wed, 04 Dec 2013 01:08:56 GMT
Updated Branches:
  refs/heads/master d4d9be2ae -> 41284da8c


KNOX-223 : generated shiro.ini file does not preserve property order


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

Branch: refs/heads/master
Commit: 41284da8c6faac7366bb1b85111b0ad113ebc35d
Parents: d4d9be2
Author: Dilli Dorai Arumugam <darumugam@hortonworks.com>
Authored: Tue Dec 3 17:07:55 2013 -0800
Committer: Dilli Dorai Arumugam <darumugam@hortonworks.com>
Committed: Tue Dec 3 17:07:55 2013 -0800

----------------------------------------------------------------------
 .../hadoop/gateway/deploy/impl/ShiroConfig.java |  6 +-
 .../topology/file/FileTopologyProviderTest.java | 67 +++++++++++++++-----
 .../hadoop/gateway/topology/Provider.java       |  4 +-
 3 files changed, 55 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41284da8/gateway-provider-security-shiro/src/main/java/org/apache/hadoop/gateway/deploy/impl/ShiroConfig.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-shiro/src/main/java/org/apache/hadoop/gateway/deploy/impl/ShiroConfig.java
b/gateway-provider-security-shiro/src/main/java/org/apache/hadoop/gateway/deploy/impl/ShiroConfig.java
index 259a88f..802d499 100644
--- a/gateway-provider-security-shiro/src/main/java/org/apache/hadoop/gateway/deploy/impl/ShiroConfig.java
+++ b/gateway-provider-security-shiro/src/main/java/org/apache/hadoop/gateway/deploy/impl/ShiroConfig.java
@@ -19,12 +19,12 @@ package org.apache.hadoop.gateway.deploy.impl;
 
 import org.apache.hadoop.gateway.topology.Provider;
 
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 
 public class ShiroConfig {
-  private Map<String, Map<String, String>> sections = new HashMap<String,
Map<String, String>>();
+  private Map<String, Map<String, String>> sections = new LinkedHashMap<String,
Map<String, String>>();
   
   public ShiroConfig(Provider provider) {
     Map<String, String> params = provider.getParams();
@@ -43,7 +43,7 @@ public class ShiroConfig {
   private void addNameValueToSection(String name, String value, String sectionName) {
     Map<String, String> section = sections.get(sectionName);
     if (section == null) {
-      section = new HashMap<String, String>();
+      section = new LinkedHashMap<String, String>();
       sections.put(sectionName, section);
     }
     section.put(name, value);

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41284da8/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/file/FileTopologyProviderTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/file/FileTopologyProviderTest.java
b/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/file/FileTopologyProviderTest.java
index c7ae040..e66a94e 100644
--- a/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/file/FileTopologyProviderTest.java
+++ b/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/file/FileTopologyProviderTest.java
@@ -17,6 +17,24 @@
  */
 package org.apache.hadoop.gateway.topology.file;
 
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.vfs2.FileChangeEvent;
 import org.apache.commons.vfs2.FileListener;
@@ -25,6 +43,8 @@ import org.apache.commons.vfs2.FileSystemException;
 import org.apache.commons.vfs2.FileSystemManager;
 import org.apache.commons.vfs2.VFS;
 import org.apache.commons.vfs2.impl.DefaultFileMonitor;
+import org.apache.hadoop.gateway.topology.Provider;
+import org.apache.hadoop.gateway.topology.ProviderParam;
 import org.apache.hadoop.gateway.topology.Topology;
 import org.apache.hadoop.gateway.topology.TopologyEvent;
 import org.apache.hadoop.gateway.topology.TopologyListener;
@@ -32,23 +52,6 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
 public class FileTopologyProviderTest {
 
   @Before
@@ -217,6 +220,36 @@ public class FileTopologyProviderTest {
     assertThat( topology.getTimestamp(), is( 1L ) );
   }
 
+  @Test
+  public void testProviderParamsOrderIsPreserved() {
+    
+    Provider provider = new Provider();
+    String names[] = {"ldapRealm=", 
+        "ldapContextFactory", 
+        "ldapRealm.contextFactory", 
+        "ldapGroupRealm", 
+        "ldapGroupRealm.contextFactory",
+        "ldapGroupRealm.contextFactory.systemAuthenticationMechanism"
+    };
+    
+    ProviderParam param = null;
+    for (String name : names) {
+      param = new ProviderParam();
+      param.setName(name);
+      param.setValue(name);
+      provider.addParam(param);
+      
+    }
+    Map<String, String> params = provider.getParams();
+    Set<String> keySet = params.keySet();
+    Iterator<String> iter = keySet.iterator();
+    int i = 0;
+    while (iter.hasNext()) {
+      assertTrue(iter.next().equals(names[i++]));
+    }
+
+  }
+  
   private class FileListenerDelegator implements FileListener {
     private FileListener delegate;
 

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41284da8/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Provider.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Provider.java b/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Provider.java
index b7d5ff4..0a771ea 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Provider.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/topology/Provider.java
@@ -17,14 +17,14 @@
  */
 package org.apache.hadoop.gateway.topology;
 
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 public class Provider {
   private String role;
   private String name;
   private boolean enabled;
-  private Map<String, String> params = new HashMap<String, String>();
+  private Map<String, String> params = new LinkedHashMap<String, String>();
 
   public Provider() {
   }


Mime
View raw message