You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2015/11/23 16:04:42 UTC

[2/2] ambari git commit: AMBARI-14013. Bunch of unit tests fail with JDK 1.8 (aonishuk)

AMBARI-14013. Bunch of unit tests fail with JDK 1.8 (aonishuk)


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

Branch: refs/heads/branch-2.1
Commit: adf345b4ded8847a785fff656c0f6dc81575c3a7
Parents: 005ba8e
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Mon Nov 23 17:04:30 2015 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Mon Nov 23 17:04:30 2015 +0200

----------------------------------------------------------------------
 ambari-project/pom.xml                          |  2 +-
 ambari-server/pom.xml                           |  2 +-
 .../ExecutionCommandWrapperTest.java            |  2 -
 .../services/ViewSubResourceServiceTest.java    |  9 +--
 .../serializers/JsonSerializerTest.java         | 26 +++----
 .../controller/AuthToLocalBuilderTest.java      | 35 ++++++----
 .../AlertTargetResourceProviderTest.java        | 11 +--
 .../BlueprintConfigurationProcessorTest.java    | 13 +++-
 ...leRepositoryVersionResourceProviderTest.java |  4 +-
 .../StackDependencyResourceProviderTest.java    |  4 +-
 .../internal/WidgetResourceProviderTest.java    |  4 +-
 .../ganglia/GangliaPropertyProviderTest.java    | 25 +++++--
 .../server/metadata/RoleCommandOrderTest.java   | 37 +++++++---
 .../topology/BlueprintValidatorImplTest.java    |  3 +-
 .../server/update/HostUpdateHelperTest.java     | 12 +++-
 .../utils/CollectionPresentationUtils.java      | 73 ++++++++++++++++++++
 .../view/persistence/DataStoreImplTest.java     |  2 +-
 .../InstanceValidationResultImplTest.java       |  3 +-
 18 files changed, 200 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-project/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-project/pom.xml b/ambari-project/pom.xml
index f4ba977..4d0b3af 100644
--- a/ambari-project/pom.xml
+++ b/ambari-project/pom.xml
@@ -28,7 +28,7 @@
   <packaging>pom</packaging>
   <properties>
     <ambari.dir>${project.parent.basedir}</ambari.dir>
-    <powermock.version>1.6.2</powermock.version>
+    <powermock.version>1.6.3</powermock.version>
   </properties>
   <profiles>
     <profile>

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml
index c76629a..390b448 100644
--- a/ambari-server/pom.xml
+++ b/ambari-server/pom.xml
@@ -1872,7 +1872,7 @@
     <dependency>
       <groupId>org.easymock</groupId>
       <artifactId>easymock</artifactId>
-      <version>3.3</version>
+      <version>3.4</version>
       <scope>test</scope>
     </dependency>
     <dependency>

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
index 75e6f75..df033d1 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
@@ -69,7 +69,6 @@ public class ExecutionCommandWrapperTest {
   private static final String SERVICE_SITE_VAL1 = "ssv1";
   private static final String SERVICE_SITE_VAL1_S = "ssv1_s";
   private static final String SERVICE_SITE_VAL2 = "ssv2";
-  private static final String SERVICE_SITE_VAL2_S = "ssv2_s";
   private static final String SERVICE_SITE_VAL2_H = "ssv2_h";
   private static final String SERVICE_SITE_VAL3 = "ssv3";
   private static final String SERVICE_SITE_VAL4 = "ssv4";
@@ -117,7 +116,6 @@ public class ExecutionCommandWrapperTest {
 
     SERVICE_SITE_SERVICE = new HashMap<String, String>();
     SERVICE_SITE_SERVICE.put(SERVICE_SITE_NAME1, SERVICE_SITE_VAL1_S);
-    SERVICE_SITE_SERVICE.put(SERVICE_SITE_NAME2, SERVICE_SITE_VAL2_S);
     SERVICE_SITE_SERVICE.put(SERVICE_SITE_NAME5, SERVICE_SITE_VAL5_S);
 
     SERVICE_SITE_HOST = new HashMap<String, String>();

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/api/services/ViewSubResourceServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/ViewSubResourceServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/ViewSubResourceServiceTest.java
index 25b477f..158ccf8 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/ViewSubResourceServiceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/ViewSubResourceServiceTest.java
@@ -36,6 +36,7 @@ import javax.ws.rs.core.UriInfo;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -105,15 +106,15 @@ public class ViewSubResourceServiceTest extends BaseServiceTest {
     child.setProperty("href", "this is an href");
 
     // resource properties
-    HashMap<String, Object> mapRootProps = new HashMap<String, Object>();
-    mapRootProps.put("prop1", "value1");
+    Map<String, Object> mapRootProps = new LinkedHashMap<String, Object>();
     mapRootProps.put("prop2", "value2");
+    mapRootProps.put("prop1", "value1");
 
-    HashMap<String, Object> mapCategoryProps = new HashMap<String, Object>();
+    Map<String, Object> mapCategoryProps = new LinkedHashMap<String, Object>();
     mapCategoryProps.put("catProp1", "catValue1");
     mapCategoryProps.put("catProp2", "catValue2");
 
-    Map<String, Map<String, Object>> propertyMap = new HashMap<String, Map<String, Object>>();
+    Map<String, Map<String, Object>> propertyMap = new LinkedHashMap<>();
 
     propertyMap.put(null, mapRootProps);
     propertyMap.put("category", mapCategoryProps);

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java
index 2ea45dc..d854dcf 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java
@@ -27,7 +27,7 @@ import org.junit.Test;
 
 import javax.ws.rs.core.UriInfo;
 
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 import static org.easymock.EasyMock.*;
@@ -52,15 +52,15 @@ public class JsonSerializerTest {
     //child.addChild(resource2, "sub-resource");
 
     // resource properties
-    HashMap<String, Object> mapRootProps = new HashMap<String, Object>();
-    mapRootProps.put("prop1", "value1");
+    Map<String, Object> mapRootProps = new LinkedHashMap<>();
     mapRootProps.put("prop2", "value2");
+    mapRootProps.put("prop1", "value1");
 
-    HashMap<String, Object> mapCategoryProps = new HashMap<String, Object>();
+    Map<String, Object> mapCategoryProps = new LinkedHashMap<String, Object>();
     mapCategoryProps.put("catProp1", "catValue1");
     mapCategoryProps.put("catProp2", "catValue2");
 
-    Map<String, Map<String, Object>> propertyMap = new HashMap<String, Map<String, Object>>();
+    Map<String, Map<String, Object>> propertyMap = new LinkedHashMap<String, Map<String, Object>>();
 
     propertyMap.put(null, mapRootProps);
     propertyMap.put("category", mapCategoryProps);
@@ -106,15 +106,15 @@ public class JsonSerializerTest {
     resourcesNode.addChild(resource, "resource1");
 
     // resource properties
-    HashMap<String, Object> mapRootProps = new HashMap<String, Object>();
-    mapRootProps.put("prop1", "value1");
+    Map<String, Object> mapRootProps = new LinkedHashMap<String, Object>();
     mapRootProps.put("prop2", "value2");
+    mapRootProps.put("prop1", "value1");
 
-    HashMap<String, Object> mapCategoryProps = new HashMap<String, Object>();
+    Map<String, Object> mapCategoryProps = new LinkedHashMap<String, Object>();
     mapCategoryProps.put("catProp1", "catValue1");
     mapCategoryProps.put("catProp2", "catValue2");
 
-    Map<String, Map<String, Object>> propertyMap = new HashMap<String, Map<String, Object>>();
+    Map<String, Map<String, Object>> propertyMap = new LinkedHashMap<String, Map<String, Object>>();
 
     propertyMap.put(null, mapRootProps);
     propertyMap.put("category", mapCategoryProps);
@@ -162,15 +162,15 @@ public class JsonSerializerTest {
     //child.addChild(resource2, "sub-resource");
 
     // resource properties
-    HashMap<String, Object> mapRootProps = new HashMap<String, Object>();
-    mapRootProps.put("prop1", "value1");
+    Map<String, Object> mapRootProps = new LinkedHashMap<String, Object>();
     mapRootProps.put("prop2", "value2");
+    mapRootProps.put("prop1", "value1");
 
-    HashMap<String, Object> mapCategoryProps = new HashMap<String, Object>();
+    Map<String, Object> mapCategoryProps = new LinkedHashMap<String, Object>();
     mapCategoryProps.put("catProp1", "catValue1");
     mapCategoryProps.put("catProp2", "catValue2");
 
-    Map<String, Map<String, Object>> propertyMap = new HashMap<String, Map<String, Object>>();
+    Map<String, Map<String, Object>> propertyMap = new LinkedHashMap<String, Map<String, Object>>();
 
     propertyMap.put(null, mapRootProps);
     propertyMap.put("category", mapCategoryProps);

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/controller/AuthToLocalBuilderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AuthToLocalBuilderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AuthToLocalBuilderTest.java
index cbcffe6..122e632 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AuthToLocalBuilderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AuthToLocalBuilderTest.java
@@ -18,8 +18,12 @@
 
 package org.apache.ambari.server.controller;
 
+import org.apache.ambari.server.utils.CollectionPresentationUtils;
 import org.junit.Test;
 
+import java.util.Arrays;
+import java.util.List;
+
 import static org.junit.Assert.*;
 
 public class AuthToLocalBuilderTest {
@@ -329,21 +333,22 @@ public class AuthToLocalBuilderTest {
     builder.addRule("hm/_HOST@EXAMPLE.COM", "hbase");
     builder.addRule("rs/_HOST@EXAMPLE.COM", "hbase");
 
-    assertEquals(
-        "RULE:[1:$1@$0](.*@FOOBAR.COM)s/@.*//\n" +
-            "RULE:[1:$1@$0](.*@EXAMPLE.COM)s/@.*//\n" +
-            "RULE:[1:$1@$0](.*@REALM2)s/@.*//\n" +
-            "RULE:[1:$1@$0](.*@REALM1)s/@.*//\n" +
-            "RULE:[1:$1@$0](.*@REALM3)s/@.*//\n" +
-            "RULE:[2:$1@$0](dn@EXAMPLE.COM)s/.*/hdfs/\n" +
-            "RULE:[2:$1@$0](hm@EXAMPLE.COM)s/.*/hbase/\n" +
-            "RULE:[2:$1@$0](jhs@EXAMPLE.COM)s/.*/mapred/\n" +
-            "RULE:[2:$1@$0](jn@EXAMPLE.COM)s/.*/hdfs/\n" +
-            "RULE:[2:$1@$0](nn@EXAMPLE.COM)s/.*/hdfs/\n" +
-            "RULE:[2:$1@$0](rm@EXAMPLE.COM)s/.*/yarn/\n" +
-            "RULE:[2:$1@$0](rs@EXAMPLE.COM)s/.*/hbase/\n" +
-            "DEFAULT",
-        builder.generate("EXAMPLE.COM"));
+    // Depends on hashing, string representation can be different
+    List<String> rules = Arrays.asList(new String[]{"RULE:[1:$1@$0](.*@FOOBAR.COM)s/@.*//",
+                                                    "RULE:[1:$1@$0](.*@EXAMPLE.COM)s/@.*//",
+                                                    "RULE:[1:$1@$0](.*@REALM2)s/@.*//",
+                                                    "RULE:[1:$1@$0](.*@REALM1)s/@.*//",
+                                                    "RULE:[1:$1@$0](.*@REALM3)s/@.*//",
+                                                    "RULE:[2:$1@$0](dn@EXAMPLE.COM)s/.*/hdfs/",
+                                                    "RULE:[2:$1@$0](hm@EXAMPLE.COM)s/.*/hbase/",
+                                                    "RULE:[2:$1@$0](jhs@EXAMPLE.COM)s/.*/mapred/",
+                                                    "RULE:[2:$1@$0](jn@EXAMPLE.COM)s/.*/hdfs/",
+                                                    "RULE:[2:$1@$0](nn@EXAMPLE.COM)s/.*/hdfs/",
+                                                    "RULE:[2:$1@$0](rm@EXAMPLE.COM)s/.*/yarn/",
+                                                    "RULE:[2:$1@$0](rs@EXAMPLE.COM)s/.*/hbase/",
+                                                    "DEFAULT"});
+    assertTrue(CollectionPresentationUtils.isStringPermutationOfCollection(builder.generate("EXAMPLE.COM"), rules,
+               "\n", 0, 0));
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProviderTest.java
index b610d8e..6cde0c2 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProviderTest.java
@@ -57,6 +57,7 @@ import org.apache.ambari.server.state.AlertState;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.alert.TargetType;
+import org.apache.ambari.server.utils.CollectionPresentationUtils;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.junit.Assert;
@@ -225,7 +226,7 @@ public class AlertTargetResourceProviderTest {
     assertEquals(ALERT_TARGET_NAME, entity.getTargetName());
     assertEquals(ALERT_TARGET_DESC, entity.getDescription());
     assertEquals(ALERT_TARGET_TYPE, entity.getNotificationType());
-    assertEquals(ALERT_TARGET_PROPS, entity.getProperties());
+    assertTrue(CollectionPresentationUtils.isJsonsEquals(ALERT_TARGET_PROPS, entity.getProperties()));
     assertEquals(false, entity.isGlobal());
 
     // no alert states were set explicitely in the request, so all should be set
@@ -274,7 +275,7 @@ public class AlertTargetResourceProviderTest {
     assertEquals(ALERT_TARGET_NAME, entity.getTargetName());
     assertEquals(ALERT_TARGET_DESC, entity.getDescription());
     assertEquals(ALERT_TARGET_TYPE, entity.getNotificationType());
-    assertEquals(ALERT_TARGET_PROPS, entity.getProperties());
+    assertTrue(CollectionPresentationUtils.isJsonsEquals(ALERT_TARGET_PROPS, entity.getProperties()));
     assertEquals(false, entity.isGlobal());
     assertEquals(3, entity.getAlertGroups().size());
 
@@ -315,7 +316,7 @@ public class AlertTargetResourceProviderTest {
     assertEquals(ALERT_TARGET_NAME, entity.getTargetName());
     assertEquals(ALERT_TARGET_DESC, entity.getDescription());
     assertEquals(ALERT_TARGET_TYPE, entity.getNotificationType());
-    assertEquals(ALERT_TARGET_PROPS, entity.getProperties());
+    assertTrue(CollectionPresentationUtils.isJsonsEquals(ALERT_TARGET_PROPS, entity.getProperties()));
     assertEquals(true, entity.isGlobal());
 
     // no alert states were set explicitely in the request, so all should be set
@@ -394,7 +395,7 @@ public class AlertTargetResourceProviderTest {
     assertEquals(ALERT_TARGET_NAME, entity.getTargetName());
     assertEquals(ALERT_TARGET_DESC, entity.getDescription());
     assertEquals(ALERT_TARGET_TYPE, entity.getNotificationType());
-    assertEquals(ALERT_TARGET_PROPS, entity.getProperties());
+    assertTrue(CollectionPresentationUtils.isJsonsEquals(ALERT_TARGET_PROPS, entity.getProperties()));
 
     Set<AlertState> alertStates = entity.getAlertStates();
     assertNotNull(alertStates);
@@ -585,7 +586,7 @@ public class AlertTargetResourceProviderTest {
     assertEquals(ALERT_TARGET_NAME, entity.getTargetName());
     assertEquals(ALERT_TARGET_DESC, entity.getDescription());
     assertEquals(ALERT_TARGET_TYPE, entity.getNotificationType());
-    assertEquals(ALERT_TARGET_PROPS, entity.getProperties());
+    assertTrue(CollectionPresentationUtils.isJsonsEquals(ALERT_TARGET_PROPS, entity.getProperties()));
     assertEquals(false, entity.isGlobal());
 
     // no alert states were set explicitely in the request, so all should be set

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java
index d5f0395..30ad8eb 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java
@@ -34,6 +34,7 @@ import org.apache.ambari.server.topology.HostGroup;
 import org.apache.ambari.server.topology.HostGroupImpl;
 import org.apache.ambari.server.topology.HostGroupInfo;
 import org.apache.ambari.server.topology.InvalidTopologyException;
+import org.apache.ambari.server.utils.CollectionPresentationUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -2664,10 +2665,16 @@ public class BlueprintConfigurationProcessorTest {
 
     // verify that the host name for the metastore.uris property has been updated, and
     // that both MetaStore Server URIs are included, using the required Hive Syntax
+    // Depends on hashing, string representation can be different
     assertEquals("Unexpected config update for templeton.hive.properties",
-        "hive.metastore.local=false,hive.metastore.uris=thrift://" + expectedHostNameOne + ":9933\\," + "thrift://" +
-        expectedHostNameTwo + ":9933" + "," + "hive.metastore.sasl.enabled=false",
-        webHCatSiteProperties.get("templeton.hive.properties"));
+        "hive.metastore.local=false,hive.metastore.uris=", webHCatSiteProperties.get("templeton.hive.properties").substring(0, 47));
+    assertEquals("Unexpected config update for templeton.hive.properties",
+        ",hive.metastore.sasl.enabled=false", webHCatSiteProperties.get("templeton.hive.properties").substring(123));
+    List<String> parts = Arrays.asList(new String[]{"thrift://" + expectedHostNameOne + ":9933", "thrift://" +
+        expectedHostNameTwo + ":9933"});
+    assertTrue("Unexpected config update for templeton.hive.properties",
+        CollectionPresentationUtils.isStringPermutationOfCollection(webHCatSiteProperties.get("templeton.hive.properties"), parts, "\\,", 47, 34));
+
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java
index d7b1c39..4e4386e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java
@@ -278,7 +278,9 @@ public class CompatibleRepositoryVersionResourceProviderTest {
         Map<String, Object> propMap = resPropMap.get(resource);
         String stackVersion = propMap.get("stack_version").toString();
         if (versionToUpgradeTypesMap.containsKey(stackVersion)) {
-          assertEquals(versionToUpgradeTypesMap.get(stackVersion), (List<String>) propMap.get("upgrade_types"));
+          List<String> upgradeTypes = new ArrayList<>((List<String>)propMap.get("upgrade_types"));
+          Collections.sort(upgradeTypes);
+          assertEquals(versionToUpgradeTypesMap.get(stackVersion), upgradeTypes);
           count++;
         }
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDependencyResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDependencyResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDependencyResourceProviderTest.java
index eafa2a5..e97ccd5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDependencyResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDependencyResourceProviderTest.java
@@ -40,8 +40,8 @@ import org.junit.Test;
 
 import java.util.Set;
 
+import static org.easymock.EasyMock.createMock;
 import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.createStrictMock;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.reset;
@@ -53,7 +53,7 @@ import static org.junit.Assert.assertEquals;
  */
 public class StackDependencyResourceProviderTest {
 
-  private static final AmbariMetaInfo metaInfo = createStrictMock(AmbariMetaInfo.class);
+  private static final AmbariMetaInfo metaInfo = createMock(AmbariMetaInfo.class);
   @BeforeClass
   public static void initClass() {
     StackDependencyResourceProvider.init(metaInfo);

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetResourceProviderTest.java
index 4c8892e..8192f38 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetResourceProviderTest.java
@@ -35,6 +35,7 @@ import org.apache.ambari.server.orm.entities.WidgetEntity;
 import org.apache.ambari.server.security.encryption.CredentialStoreService;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.utils.CollectionPresentationUtils;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.junit.Assert;
@@ -352,7 +353,8 @@ public class WidgetResourceProviderTest {
     Assert.assertFalse(oldMetrics.equals(entity.getMetrics()));
     Assert.assertFalse(oldProperties.equals(entity.getProperties()));
     Assert.assertEquals("[{\"name\":\"new_value\",\"new_name\":\"new_value2\"}]",entity.getMetrics());
-    Assert.assertEquals("{\"new_property\":\"new_value2\",\"property1\":\"new_value1\"}",entity.getProperties());
+    // Depends on hashing, string representation can be different
+    Assert.assertTrue(CollectionPresentationUtils.isJsonsEquals("{\"new_property\":\"new_value2\",\"property1\":\"new_value1\"}", entity.getProperties()));
     Assert.assertEquals("widget name2",entity.getWidgetName());
     Assert.assertEquals(null,entity.getDefaultSectionName());
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProviderTest.java
index 98de9cf..6fefffe 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProviderTest.java
@@ -29,6 +29,7 @@ import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.SystemException;
 import org.apache.ambari.server.controller.spi.TemporalInfo;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.ambari.server.utils.CollectionPresentationUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.Predicate;
 import org.apache.http.NameValuePair;
@@ -333,8 +334,18 @@ public class GangliaPropertyProviderTest {
     uriBuilder.setParameter("r", "1");
 
     String expected = uriBuilder.toString();
-    
-    Assert.assertEquals(expected, streamProvider.getLastSpec());
+
+    // Depends on hashing, string representation can be different
+    List<String> components = Arrays.asList(new String[]{"HDPJobTracker", "HDPHBaseMaster", "HDPResourceManager", "HDPFlumeServer",
+        "HDPSlaves", "HDPHistoryServer", "HDPJournalNode", "HDPTaskTracker", "HDPHBaseRegionServer", "HDPNameNode"});
+    List<String> hosts = Arrays.asList(new String[]{"domU-12-31-39-0E-34-E3.compute-1.internal", "domU-12-31-39-0E-34-E1.compute-1.internal",
+        "domU-12-31-39-0E-34-E2.compute-1.internal"});
+    int httpsVariation = configuration.isGangliaSSL() ? 1 : 0;
+
+    Assert.assertEquals(expected.substring(0, 66 + httpsVariation), streamProvider.getLastSpec().substring(0, 66 + httpsVariation));
+    Assert.assertTrue(CollectionPresentationUtils.isStringPermutationOfCollection(streamProvider.getLastSpec().substring(66 + httpsVariation, 236 + httpsVariation), components, "%2C", 0, 0));
+    Assert.assertTrue(CollectionPresentationUtils.isStringPermutationOfCollection(streamProvider.getLastSpec().substring(239 + httpsVariation, 368 + httpsVariation), hosts, "%2C", 0, 0));
+    Assert.assertEquals(expected.substring(369 + httpsVariation), streamProvider.getLastSpec().substring(369 + httpsVariation));
 
     for (Resource res : resources) {
       Assert.assertEquals(2, PropertyHelper.getProperties(res).size());
@@ -549,8 +560,14 @@ public class GangliaPropertyProviderTest {
 
     String expected = (configuration.isGangliaSSL() ? "https" : "http") +
         "://domU-12-31-39-0E-34-E1.compute-1.internal/cgi-bin/rrd.py?c=HDPFlumeServer%2CHDPSlaves&h=ip-10-39-113-33.ec2.internal&m=";
-    
-    Assert.assertTrue(streamProvider.getLastSpec().startsWith(expected));
+
+    // Depends on hashing, string representation can be different
+    List<String> components = Arrays.asList(new String[]{"HDPFlumeServer", "HDPSlaves"});
+    int httpsVariation = configuration.isGangliaSSL() ? 1 : 0;
+
+    Assert.assertEquals(expected.substring(0, 66 + httpsVariation), streamProvider.getLastSpec().substring(0, 66 + httpsVariation));
+    Assert.assertTrue(CollectionPresentationUtils.isStringPermutationOfCollection(streamProvider.getLastSpec().substring(66 + httpsVariation, 92 + httpsVariation), components, "%2C", 0, 0));
+    Assert.assertTrue(streamProvider.getLastSpec().substring(92 + httpsVariation).startsWith(expected.substring(92 + httpsVariation)));
 
     Assert.assertEquals(33, PropertyHelper.getProperties(resource).size());
     Assert.assertNotNull(resource.getPropertyValue(FLUME_CHANNEL_CAPACITY_PROPERTY));

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleCommandOrderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleCommandOrderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleCommandOrderTest.java
index 47c8e53..7f852f0 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleCommandOrderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleCommandOrderTest.java
@@ -29,10 +29,13 @@ import static org.easymock.EasyMock.verify;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.regex.Pattern;
 
 import junit.framework.Assert;
 
@@ -48,6 +51,7 @@ import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.cluster.ClusterImpl;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostImpl;
+import org.apache.ambari.server.utils.CollectionPresentationUtils;
 import org.codehaus.jackson.annotate.JsonAutoDetect;
 import org.codehaus.jackson.annotate.JsonMethod;
 import org.codehaus.jackson.map.ObjectMapper;
@@ -281,16 +285,29 @@ public class RoleCommandOrderTest {
     mapper.setVisibility(JsonMethod.ALL, JsonAutoDetect.Visibility.ANY);
     String dump = mapper.writeValueAsString(rco.getDependencies());
 
-    String expected = "{\"RoleCommandPair{role=SECONDARY_NAMENODE, " +
-        "cmd=UPGRADE}\":[{\"role\":{\"name\":\"NAMENODE\"},\"cmd\":\"UPGRADE\"}]," +
-        "\"RoleCommandPair{role=SECONDARY_NAMENODE, cmd=START}\":[{\"role\":{\"name\":\"NAMENODE\"}," +
-    		"\"cmd\":\"START\"}],\"RoleCommandPair{role=DATANODE, cmd=STOP}\":[{\"role\":" +
-        "{\"name\":\"HBASE_MASTER\"},\"cmd\":\"STOP\"},{\"role\":{\"name\":\"RESOURCEMANAGER\"}," +
-    		"\"cmd\":\"STOP\"},{\"role\":{\"name\":\"TASKTRACKER\"},\"cmd\":\"STOP\"}," +
-        "{\"role\":{\"name\":\"NODEMANAGER\"},\"cmd\":\"STOP\"},{\"role\":{\"name\":\"HISTORYSERVER\"}," +
-    		"\"cmd\":\"STOP\"},{\"role\":{\"name\":\"JOBTRACKER\"},\"cmd\":\"STOP\"}]}";
-
-    assertEquals(expected, dump);
+    // Depends on hashing, string representation can be different
+    // We need a sophisticated comparison
+    List<String> parts = Arrays.asList(dump.substring(1, 522).split(Pattern.quote("],")));
+    assertEquals(3, parts.size());
+    assertTrue(parts.contains("\"RoleCommandPair{role=SECONDARY_NAMENODE, cmd=UPGRADE}\":[{\"role\":{\"name\":\"NAMENODE\"},\"cmd\":\"UPGRADE\"}"));
+    assertTrue(parts.contains("\"RoleCommandPair{role=SECONDARY_NAMENODE, cmd=START}\":[{\"role\":{\"name\":\"NAMENODE\"},\"cmd\":\"START\"}"));
+    boolean datanodeCommandExists = false;
+    for (String part : parts) {
+      if (part.contains("RoleCommandPair{role=DATANODE, cmd=STOP}")) {
+        datanodeCommandExists = true;
+        String[] parts2 = part.split(Pattern.quote(":["));
+        assertEquals(2, parts2.length);
+        assertEquals("\"RoleCommandPair{role=DATANODE, cmd=STOP}\"", parts2[0]);
+        List<String> components = Arrays.asList(new String[]{"\"role\":{\"name\":\"HBASE_MASTER\"},\"cmd\":\"STOP\"",
+                                                             "\"role\":{\"name\":\"RESOURCEMANAGER\"},\"cmd\":\"STOP\"",
+                                                             "\"role\":{\"name\":\"TASKTRACKER\"},\"cmd\":\"STOP\"",
+                                                             "\"role\":{\"name\":\"NODEMANAGER\"},\"cmd\":\"STOP\"",
+                                                             "\"role\":{\"name\":\"HISTORYSERVER\"},\"cmd\":\"STOP\"",
+                                                             "\"role\":{\"name\":\"JOBTRACKER\"},\"cmd\":\"STOP\""});
+        Assert.assertTrue(CollectionPresentationUtils.isStringPermutationOfCollection(parts2[1], components, "},{", 1, 1));
+      }
+    }
+    assertTrue(datanodeCommandExists);
   }
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintValidatorImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintValidatorImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintValidatorImplTest.java
index 8ab4ba1..304cded 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintValidatorImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintValidatorImplTest.java
@@ -30,6 +30,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 import static org.easymock.EasyMock.createNiceMock;
@@ -47,7 +48,7 @@ public class BlueprintValidatorImplTest{
   private final Stack stack = createNiceMock(Stack.class);
   private final HostGroup group1 = createNiceMock(HostGroup.class);
   private final HostGroup group2 = createNiceMock(HostGroup.class);
-  private final Map<String, HostGroup> hostGroups = new HashMap<String, HostGroup>();
+  private final Map<String, HostGroup> hostGroups = new LinkedHashMap<>();
 
   private final Collection<String> group1Components = new ArrayList<String>();
   private final Collection<String> group2Components = new ArrayList<String>();

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/update/HostUpdateHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/update/HostUpdateHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/update/HostUpdateHelperTest.java
index 0755674..c59aac2 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/update/HostUpdateHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/update/HostUpdateHelperTest.java
@@ -21,6 +21,7 @@ package org.apache.ambari.server.update;
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
+import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.orm.DBAccessor;
@@ -41,6 +42,9 @@ import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.stack.OsFamily;
+import org.apache.ambari.server.utils.CollectionPresentationUtils;
+import org.easymock.Capture;
+import org.easymock.EasyMock;
 import org.easymock.EasyMockSupport;
 import org.junit.Test;
 
@@ -277,8 +281,8 @@ public class HostUpdateHelperTest {
     expect(mockClusterConfigEntity4.getType()).andReturn("testType2").atLeastOnce();
     expect(mockClusterConfigEntity4.getVersion()).andReturn(2L).atLeastOnce();
 
-    mockClusterConfigEntity3.setData("{\"testProperty4\":\"testValue_host11\",\"testProperty3\":\"testValue_host55\"," +
-            "\"testProperty2\":\"testValue_host1\",\"testProperty1\":\"testValue_host5\"}");
+    Capture<String> dataCapture = EasyMock.newCapture();
+    mockClusterConfigEntity3.setData(EasyMock.capture(dataCapture));
     expectLastCall();
 
     mockClusterConfigEntity4.setData("{\"testProperty5\":\"test_host5_test_host1_test_host55_test_host11\"}");
@@ -291,6 +295,10 @@ public class HostUpdateHelperTest {
     easyMockSupport.replayAll();
     hostUpdateHelper.updateHostsInConfigurations();
     easyMockSupport.verifyAll();
+
+    // Depends on hashing, string representation can be different
+    Assert.assertTrue(CollectionPresentationUtils.isJsonsEquals("{\"testProperty4\":\"testValue_host11\",\"testProperty3\":\"testValue_host55\"," +
+        "\"testProperty2\":\"testValue_host1\",\"testProperty1\":\"testValue_host5\"}", dataCapture.getValue()));
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/utils/CollectionPresentationUtils.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/utils/CollectionPresentationUtils.java b/ambari-server/src/test/java/org/apache/ambari/server/utils/CollectionPresentationUtils.java
new file mode 100644
index 0000000..5a7cb7b
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/utils/CollectionPresentationUtils.java
@@ -0,0 +1,73 @@
+/**
+ * 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.ambari.server.utils;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import junit.framework.Assert;
+import org.junit.Test;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+/**
+ * Complementary class used in tests to check if string representation corresponds to Set/Map
+ */
+public class CollectionPresentationUtils {
+
+  /**
+   * Checks if string representation corresponds to the collection. Parts of an expected collection should not contain
+   * delimiter.
+   */
+  public static boolean isStringPermutationOfCollection(String input, Collection<String> expected, String delimeter,
+                                                        int trimFromStart, int trimFromEnd) {
+    input = input.substring(trimFromStart, input.length() - trimFromEnd);
+    List<String> parts = new ArrayList<>(Arrays.asList(input.split(Pattern.quote(delimeter))));
+    for (String part : expected) {
+      if (parts.contains(part)) {
+        parts.remove(part);
+      }
+    }
+    return parts.isEmpty();
+  }
+
+  public static boolean isJsonsEquals(String input1, String input2) {
+    JsonParser parser = new JsonParser();
+    JsonElement input1Parsed = parser.parse(input1);
+    JsonElement input2Parsed = parser.parse(input2);
+    return input1Parsed.equals(input2Parsed);
+  }
+
+  @Test
+  public void testIsStringPermutationOfCollection() {
+    String input1 = "{\"foo\":\"bar\",\"foobar\":\"baz\"}";
+    String input2 = "{\"foobar\":\"baz\",\"foo\":\"bar\"}";
+    String input3 = "{\"fooba\":\"baz\",\"foo\":\"bar\"}";
+    Set<String> expected = new HashSet<>(Arrays.asList(new String[]{"\"foo\":\"bar\"", "\"foobar\":\"baz\""}));
+
+    Assert.assertTrue(CollectionPresentationUtils.isStringPermutationOfCollection(input1, expected, ",", 1, 1));
+    Assert.assertTrue(CollectionPresentationUtils.isStringPermutationOfCollection(input2, expected, ",", 1, 1));
+    Assert.assertFalse(CollectionPresentationUtils.isStringPermutationOfCollection(input3, expected, ",", 1, 1));
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/view/persistence/DataStoreImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/view/persistence/DataStoreImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/view/persistence/DataStoreImplTest.java
index 9be6e4f..d14f120 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/view/persistence/DataStoreImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/view/persistence/DataStoreImplTest.java
@@ -313,7 +313,7 @@ public class DataStoreImplTest {
     }
     String longString = sb.toString();
 
-    expect(dynamicEntity.set("DS_id", 99)).andReturn(dynamicEntity);
+    expect(dynamicEntity.set("DS_id", 99)).andReturn(dynamicEntity).times(0, 1);
 
     transaction.begin();
     expect(transaction.isActive()).andReturn(true).anyTimes();

http://git-wip-us.apache.org/repos/asf/ambari/blob/adf345b4/ambari-server/src/test/java/org/apache/ambari/server/view/validation/InstanceValidationResultImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/view/validation/InstanceValidationResultImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/view/validation/InstanceValidationResultImplTest.java
index b375cd2..c4d35e6 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/view/validation/InstanceValidationResultImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/view/validation/InstanceValidationResultImplTest.java
@@ -23,6 +23,7 @@ import org.apache.ambari.view.validation.ValidationResult;
 import org.junit.Test;
 
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 /**
@@ -53,7 +54,7 @@ public class InstanceValidationResultImplTest {
   @Test
   public void testToJson() throws Exception {
     ValidationResult result = new ValidationResultImpl(true, "detail");
-    Map<String, ValidationResult> propertyResults = new HashMap<String, ValidationResult>();
+    Map<String, ValidationResult> propertyResults = new LinkedHashMap<>();
 
     propertyResults.put("foo", new ValidationResultImpl(true, "foo detail"));
     propertyResults.put("bar", new ValidationResultImpl(false, "bar detail"));