ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [1/3] ambari git commit: AMBARI-21450 - Fixing Unit Test Logic From trunk Merge (jonathanhurley)
Date Mon, 24 Jul 2017 17:28:03 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-21450 51e3080ef -> 15cd3d837


http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
index 70f0332..2b4a008 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -145,14 +145,14 @@ public class ClusterResourceProviderTest {
     Set<Map<String, Object>> requestProperties = createBlueprintRequestProperties(CLUSTER_NAME,
BLUEPRINT_NAME);
     Map<String, Object> properties = requestProperties.iterator().next();
     properties.put(BaseClusterRequest.PROVISION_ACTION_PROPERTY, "INSTALL_ONLY");
-    Map<String, String> requestInfoProperties = new HashMap<String, String>();
+    Map<String, String> requestInfoProperties = new HashMap<>();
     requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{}");
 
     // set expectations
     expect(request.getProperties()).andReturn(requestProperties).anyTimes();
     expect(request.getRequestInfoProperties()).andReturn(requestInfoProperties).anyTimes();
 
-    expect(securityFactory.createSecurityConfigurationFromRequest(anyObject(HashMap.class),
anyBoolean())).andReturn(null)
+    expect(securityFactory.createSecurityConfigurationFromRequest(EasyMock.<Map<String,
Object>>anyObject(), anyBoolean())).andReturn(null)
       .once();
     expect(topologyFactory.createProvisionClusterRequest(properties, null)).andReturn(topologyRequest).once();
     expect(topologyManager.provisionCluster(topologyRequest)).andReturn(requestStatusResponse).once();
@@ -174,7 +174,7 @@ public class ClusterResourceProviderTest {
   public void testCreateResource_blueprint_withInvalidSecurityConfiguration() throws Exception
{
     Set<Map<String, Object>> requestProperties = createBlueprintRequestProperties(CLUSTER_NAME,
BLUEPRINT_NAME);
     Map<String, Object> properties = requestProperties.iterator().next();
-    Map<String, String> requestInfoProperties = new HashMap<String, String>();
+    Map<String, String> requestInfoProperties = new HashMap<>();
     requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{\"security\" : {\n\"type\"
: \"NONE\"," +
       "\n\"kerberos_descriptor_reference\" : " + "\"testRef\"\n}}");
     SecurityConfiguration blueprintSecurityConfiguration = new SecurityConfiguration(SecurityType.KERBEROS,
"testRef",
@@ -185,7 +185,7 @@ public class ClusterResourceProviderTest {
     expect(request.getProperties()).andReturn(requestProperties).anyTimes();
     expect(request.getRequestInfoProperties()).andReturn(requestInfoProperties).anyTimes();
 
-    expect(securityFactory.createSecurityConfigurationFromRequest(anyObject(HashMap.class),
anyBoolean())).andReturn
+    expect(securityFactory.createSecurityConfigurationFromRequest(EasyMock.<Map<String,
Object>>anyObject(), anyBoolean())).andReturn
       (securityConfiguration).once();
     expect(topologyFactory.createProvisionClusterRequest(properties, securityConfiguration)).andReturn(topologyRequest).once();
     expect(topologyRequest.getBlueprint()).andReturn(blueprint).anyTimes();
@@ -203,7 +203,7 @@ public class ClusterResourceProviderTest {
     Map<String, Object> properties = requestProperties.iterator().next();
     SecurityConfiguration securityConfiguration = new SecurityConfiguration(SecurityType.KERBEROS,
"testRef", null);
 
-    Map<String, String> requestInfoProperties = new HashMap<String, String>();
+    Map<String, String> requestInfoProperties = new HashMap<>();
     requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{\"security\" : {\n\"type\"
: \"KERBEROS\",\n\"kerberos_descriptor_reference\" : " +
       "\"testRef\"\n}}");
 
@@ -212,7 +212,7 @@ public class ClusterResourceProviderTest {
     expect(request.getRequestInfoProperties()).andReturn(requestInfoProperties).anyTimes();
 
     expect(topologyFactory.createProvisionClusterRequest(properties, securityConfiguration)).andReturn(topologyRequest).once();
-    expect(securityFactory.createSecurityConfigurationFromRequest(anyObject(HashMap.class),
anyBoolean())).andReturn
+    expect(securityFactory.createSecurityConfigurationFromRequest(EasyMock.<Map<String,
Object>>anyObject(), anyBoolean())).andReturn
       (securityConfiguration).once();
     expect(topologyManager.provisionCluster(topologyRequest)).andReturn(requestStatusResponse).once();
     expect(requestStatusResponse.getRequestId()).andReturn(5150L).anyTimes();
@@ -284,10 +284,10 @@ public class ClusterResourceProviderTest {
     ((ObservableResourceProvider)provider).addObserver(observer);
 
     // add the property map to a set for the request.  add more maps for multiple creates
-    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String,
Object>>();
+    Set<Map<String, Object>> propertySet = new LinkedHashSet<>();
 
     // Cluster 1: create a map of properties for the request
-    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+    Map<String, Object> properties = new LinkedHashMap<>();
 
     // add the cluster name to the properties map
     properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -332,21 +332,21 @@ public class ClusterResourceProviderTest {
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
     Clusters clusters = createMock(Clusters.class);
 
-    Set<ClusterResponse> allResponse = new HashSet<ClusterResponse>();
-    allResponse.add(new ClusterResponse(100L, "Cluster100", State.INSTALLED, SecurityType.NONE,
null, null, null, null));
-    allResponse.add(new ClusterResponse(101L, "Cluster101", State.INSTALLED, SecurityType.NONE,
null, null, null, null));
-    allResponse.add(new ClusterResponse(102L, "Cluster102", State.INSTALLED, SecurityType.NONE,
null, null, null, null));
-    allResponse.add(new ClusterResponse(103L, "Cluster103", State.INSTALLED, SecurityType.NONE,
null, null, null, null));
-    allResponse.add(new ClusterResponse(104L, "Cluster104", State.INSTALLED, SecurityType.NONE,
null, null, null, null));
+    Set<ClusterResponse> allResponse = new HashSet<>();
+    allResponse.add(new ClusterResponse(100L, "Cluster100", State.INSTALLED, SecurityType.NONE,
null, 0, null, null));
+    allResponse.add(new ClusterResponse(101L, "Cluster101", State.INSTALLED, SecurityType.NONE,
null, 0, null, null));
+    allResponse.add(new ClusterResponse(102L, "Cluster102", State.INSTALLED, SecurityType.NONE,
null, 0, null, null));
+    allResponse.add(new ClusterResponse(103L, "Cluster103", State.INSTALLED, SecurityType.NONE,
null, 0, null, null));
+    allResponse.add(new ClusterResponse(104L, "Cluster104", State.INSTALLED, SecurityType.NONE,
null, 0, null, null));
 
-    Set<ClusterResponse> nameResponse = new HashSet<ClusterResponse>();
-    nameResponse.add(new ClusterResponse(102L, "Cluster102", State.INSTALLED, SecurityType.NONE,
null, null, null, null));
+    Set<ClusterResponse> nameResponse = new HashSet<>();
+    nameResponse.add(new ClusterResponse(102L, "Cluster102", State.INSTALLED, SecurityType.NONE,
null, 0, null, null));
 
-    Set<ClusterResponse> idResponse = new HashSet<ClusterResponse>();
-    idResponse.add(new ClusterResponse(103L, "Cluster103", State.INSTALLED, SecurityType.NONE,
null, null, null, null));
+    Set<ClusterResponse> idResponse = new HashSet<>();
+    idResponse.add(new ClusterResponse(103L, "Cluster103", State.INSTALLED, SecurityType.NONE,
null, 0, null, null));
 
     // set expectations
-    Capture<Set<ClusterRequest>> captureClusterRequests = new Capture<Set<ClusterRequest>>();
+    Capture<Set<ClusterRequest>> captureClusterRequests = EasyMock.newCapture();
 
     expect(managementController.getClusters(capture(captureClusterRequests))).andReturn(allResponse).once();
     expect(managementController.getClusters(capture(captureClusterRequests))).andReturn(nameResponse).once();
@@ -365,7 +365,7 @@ public class ClusterResourceProviderTest {
         PropertyHelper.getKeyPropertyIds(type),
         managementController);
 
-    Set<String> propertyIds = new HashSet<String>();
+    Set<String> propertyIds = new HashSet<>();
 
     propertyIds.add(ClusterResourceProvider.CLUSTER_ID_PROPERTY_ID);
     propertyIds.add(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID);
@@ -452,40 +452,40 @@ public class ClusterResourceProviderTest {
 
   //todo: configuration properties are not being added to props
   private Set<Map<String, Object>> createBlueprintRequestProperties(String clusterName,
String blueprintName) {
-    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String,
Object>>();
-    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+    Set<Map<String, Object>> propertySet = new LinkedHashSet<>();
+    Map<String, Object> properties = new LinkedHashMap<>();
 
     properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, clusterName);
     properties.put(ClusterResourceProvider.BLUEPRINT_PROPERTY_ID, blueprintName);
     propertySet.add(properties);
 
-    Collection<Map<String, Object>> hostGroups = new ArrayList<Map<String,
Object>>();
-    Map<String, Object> hostGroupProperties = new HashMap<String, Object>();
+    Collection<Map<String, Object>> hostGroups = new ArrayList<>();
+    Map<String, Object> hostGroupProperties = new HashMap<>();
     hostGroups.add(hostGroupProperties);
     hostGroupProperties.put("name", "group1");
-    Collection<Map<String, String>> hostGroupHosts = new ArrayList<Map<String,
String>>();
+    Collection<Map<String, String>> hostGroupHosts = new ArrayList<>();
     hostGroupProperties.put("hosts", hostGroupHosts);
-    Map<String, String> hostGroupHostProperties = new HashMap<String, String>();
+    Map<String, String> hostGroupHostProperties = new HashMap<>();
     hostGroupHostProperties.put("fqdn", "host.domain");
     hostGroupHosts.add(hostGroupHostProperties);
     properties.put("host_groups", hostGroups);
 
-    Map<String, String> mapGroupConfigProperties = new HashMap<String, String>();
+    Map<String, String> mapGroupConfigProperties = new HashMap<>();
     mapGroupConfigProperties.put("myGroupProp", "awesomeValue");
 
     // blueprint core-site cluster configuration properties
-    Map<String, String> blueprintCoreConfigProperties = new HashMap<String, String>();
+    Map<String, String> blueprintCoreConfigProperties = new HashMap<>();
     blueprintCoreConfigProperties.put("property1", "value2");
     blueprintCoreConfigProperties.put("new.property", "new.property.value");
 
-    Map<String, String> blueprintGlobalConfigProperties = new HashMap<String, String>();
+    Map<String, String> blueprintGlobalConfigProperties = new HashMap<>();
     blueprintGlobalConfigProperties.put("hive_database", "New MySQL Database");
 
-    Map<String, String> oozieEnvConfigProperties = new HashMap<String, String>();
+    Map<String, String> oozieEnvConfigProperties = new HashMap<>();
     oozieEnvConfigProperties.put("property1","value2");
-    Map<String, String> hbaseEnvConfigProperties = new HashMap<String, String>();
+    Map<String, String> hbaseEnvConfigProperties = new HashMap<>();
     hbaseEnvConfigProperties.put("property1","value2");
-    Map<String, String> falconEnvConfigProperties = new HashMap<String, String>();
+    Map<String, String> falconEnvConfigProperties = new HashMap<>();
     falconEnvConfigProperties.put("property1","value2");
 
     return propertySet;
@@ -494,14 +494,14 @@ public class ClusterResourceProviderTest {
   private void testCreateResource_blueprint(Authentication authentication) throws Exception
{
     Set<Map<String, Object>> requestProperties = createBlueprintRequestProperties(CLUSTER_NAME,
BLUEPRINT_NAME);
     Map<String, Object> properties = requestProperties.iterator().next();
-    Map<String, String> requestInfoProperties = new HashMap<String, String>();
+    Map<String, String> requestInfoProperties = new HashMap<>();
     requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{}");
 
     // set expectations
     expect(request.getProperties()).andReturn(requestProperties).anyTimes();
     expect(request.getRequestInfoProperties()).andReturn(requestInfoProperties).anyTimes();
 
-    expect(securityFactory.createSecurityConfigurationFromRequest(anyObject(HashMap.class),
anyBoolean())).andReturn(null)
+    expect(securityFactory.createSecurityConfigurationFromRequest(EasyMock.<Map<String,
Object>>anyObject(), anyBoolean())).andReturn(null)
         .once();
     expect(topologyFactory.createProvisionClusterRequest(properties, null)).andReturn(topologyRequest).once();
     expect(topologyManager.provisionCluster(topologyRequest)).andReturn(requestStatusResponse).once();
@@ -545,10 +545,10 @@ public class ClusterResourceProviderTest {
     ((ObservableResourceProvider)provider).addObserver(observer);
 
     // add the property map to a set for the request.  add more maps for multiple creates
-    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String,
Object>>();
+    Set<Map<String, Object>> propertySet = new LinkedHashSet<>();
 
     // Cluster 1: create a map of properties for the request
-    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+    Map<String, Object> properties = new LinkedHashMap<>();
 
     // add the cluster name to the properties map
     properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -559,7 +559,7 @@ public class ClusterResourceProviderTest {
     propertySet.add(properties);
 
     // Cluster 2: create a map of properties for the request
-    properties = new LinkedHashMap<String, Object>();
+    properties = new LinkedHashMap<>();
 
     // add the cluster id to the properties map
     properties.put(ClusterResourceProvider.CLUSTER_ID_PROPERTY_ID, 99L);
@@ -593,10 +593,10 @@ public class ClusterResourceProviderTest {
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
     RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
 
-    Set<ClusterResponse> nameResponse = new HashSet<ClusterResponse>();
-    nameResponse.add(new ClusterResponse(102L, "Cluster102", State.INIT, SecurityType.NONE,
null, null, null, null));
+    Set<ClusterResponse> nameResponse = new HashSet<>();
+    nameResponse.add(new ClusterResponse(102L, "Cluster102", State.INIT, SecurityType.NONE,
null, 0, null, null));
 
-    Map<String, String> mapRequestProps = new HashMap<String, String>();
+    Map<String, String> mapRequestProps = new HashMap<>();
     mapRequestProps.put("context", "Called from a test");
 
     // set expectations
@@ -628,7 +628,7 @@ public class ClusterResourceProviderTest {
 
     ((ObservableResourceProvider)provider).addObserver(observer);
 
-    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+    Map<String, Object> properties = new LinkedHashMap<>();
 
     properties.put(ClusterResourceProvider.CLUSTER_VERSION_PROPERTY_ID, "HDP-0.1");
 
@@ -661,10 +661,10 @@ public class ClusterResourceProviderTest {
     Clusters clusters = createMock(Clusters.class);
     RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
 
-    Set<ClusterResponse> nameResponse = new HashSet<ClusterResponse>();
-    nameResponse.add(new ClusterResponse(100L, "Cluster100", State.INSTALLED, SecurityType.NONE,
null, null, null, null));
+    Set<ClusterResponse> nameResponse = new HashSet<>();
+    nameResponse.add(new ClusterResponse(100L, "Cluster100", State.INSTALLED, SecurityType.NONE,
null, 0, null, null));
 
-    Map<String, String> mapRequestProps = new HashMap<String, String>();
+    Map<String, String> mapRequestProps = new HashMap<>();
     mapRequestProps.put("context", "Called from a test");
 
     // set expectations
@@ -680,7 +680,7 @@ public class ClusterResourceProviderTest {
 
     SecurityContextHolder.getContext().setAuthentication(authentication);
 
-    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+    Map<String, Object> properties = new LinkedHashMap<>();
 
     properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100");
     properties.put(PropertyHelper.getPropertyId("Clusters.desired_config", "type"), "global");
@@ -689,7 +689,7 @@ public class ClusterResourceProviderTest {
     properties.put(PropertyHelper.getPropertyId("Clusters.desired_config.properties", "x"),
"y");
 
 
-    Map<String, Object> properties2 = new LinkedHashMap<String, Object>();
+    Map<String, Object> properties2 = new LinkedHashMap<>();
 
     properties2.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100");
     properties2.put(PropertyHelper.getPropertyId("Clusters.desired_config", "type"), "mapred-site");
@@ -697,7 +697,7 @@ public class ClusterResourceProviderTest {
     properties2.put(PropertyHelper.getPropertyId("Clusters.desired_config.properties", "foo"),
"A1");
     properties2.put(PropertyHelper.getPropertyId("Clusters.desired_config.properties", "bar"),
"B2");
 
-    Set<Map<String, Object>> propertySet = new HashSet<Map<String, Object>>();
+    Set<Map<String, Object>> propertySet = new HashSet<>();
 
     propertySet.add(properties);
     propertySet.add(properties2);
@@ -806,10 +806,10 @@ public class ClusterResourceProviderTest {
         managementController);
 
     // add the property map to a set for the request.  add more maps for multiple creates
-    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String,
Object>>();
+    Set<Map<String, Object>> propertySet = new LinkedHashSet<>();
 
     // Cluster 1: create a map of properties for the request
-    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+    Map<String, Object> properties = new LinkedHashMap<>();
     properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100");
     properties.put(ClusterResourceProvider.CLUSTER_VERSION_PROPERTY_ID, "HDP-0.1");
     properties.put(ClusterResourceProvider.CLUSTER_REPO_VERSION, "2.1.1");
@@ -826,7 +826,6 @@ public class ClusterResourceProviderTest {
 
     assertTrue(cap.hasCaptured());
     assertNotNull(cap.getValue());
-    assertEquals("2.1.1", cap.getValue().getRepositoryVersion());
   }
 
   @Test
@@ -844,7 +843,7 @@ public class ClusterResourceProviderTest {
     expect(request.getProperties()).andReturn(requestProperties).anyTimes();
     expect(request.getRequestInfoProperties()).andReturn(requestInfoProperties).anyTimes();
 
-    expect(securityFactory.createSecurityConfigurationFromRequest(anyObject(HashMap.class),
anyBoolean())).andReturn(null)
+    expect(securityFactory.createSecurityConfigurationFromRequest(EasyMock.<Map<String,
Object>>anyObject(), anyBoolean())).andReturn(null)
         .once();
     expect(topologyFactory.createProvisionClusterRequest(properties, null)).andReturn(topologyRequest).once();
     expect(topologyManager.provisionCluster(topologyRequest)).andReturn(requestStatusResponse).once();
@@ -861,4 +860,4 @@ public class ClusterResourceProviderTest {
     verifyAll();
   }
 
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
index f133784..fdd1dc5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
@@ -124,8 +124,7 @@ public class JMXHostProviderTest {
       dStateStr = desiredState.toString();
     }
 
-    ServiceRequest r1 = new ServiceRequest(clusterName, serviceName, STACK_ID.getStackId(),
-        REPO_VERSION, dStateStr);
+    ServiceRequest r1 = new ServiceRequest(clusterName, serviceName, m_repositoryVersion.getId(),
dStateStr);
 
     Set<ServiceRequest> requests = new HashSet<>();
     requests.add(r1);

http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
index 7fe888d..a0c58ea 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
@@ -153,7 +153,7 @@ public class ServiceResourceProviderTest {
     properties.put(ServiceResourceProvider.SERVICE_SERVICE_NAME_PROPERTY_ID, "Service100");
     properties.put(ServiceResourceProvider.SERVICE_SERVICE_STATE_PROPERTY_ID, "INIT");
     properties.put(ServiceResourceProvider.SERVICE_DESIRED_STACK_PROPERTY_ID, "HDP-1.1");
-    properties.put(ServiceResourceProvider.SERVICE_DESIRED_REPO_VERSION_PROPERTY_ID, "1");
+    properties.put(ServiceResourceProvider.SERVICE_DESIRED_REPO_VERSION_ID_PROPERTY_ID, "1");
 
     propertySet.add(properties);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
index d07ac15..2e216e6 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
@@ -91,7 +91,7 @@ public class ComponentVersionCheckActionTest {
   private static final StackId HDP_21_STACK = new StackId("HDP-2.1.1");
   private static final StackId HDP_22_STACK = new StackId("HDP-2.2.0");
 
-  private static final String HDP_211_CENTOS6_REPO_URL = "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.0";
+  private static final String HDP_211_CENTOS6_REPO_URL = "http://s3.amazonaws.com/dev.hortonworks.com/HDP/centos6/2.x/BUILDS/2.1.1.0-118";
 
   private Injector m_injector;
 
@@ -544,4 +544,4 @@ public class ComponentVersionCheckActionTest {
     configFactory.createNew(cluster, "core-site", "version1", properties, propertiesAttributes);
     configFactory.createNew(cluster, "foo-site", "version1", properties, propertiesAttributes);
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java
index 731e100..e80b59b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java
@@ -137,12 +137,9 @@ public class ConfigureActionTest {
     m_injector.getInstance(GuiceJpaInitializer.class);
     m_injector.injectMembers(this);
 
-    repoVersion2110 = m_helper.getOrCreateRepositoryVersion(new StackId("HDP-2.1.1"),
-        "2.1.1.0-1234");
-    repoVersion2111 = m_helper.getOrCreateRepositoryVersion(new StackId("HDP-2.1.1"),
-        "2.1.1.1-5678");
-    repoVersion2200 = m_helper.getOrCreateRepositoryVersion(new StackId("HDP-2.2.0"),
-        "2.2.0.0-1234");
+    repoVersion2110 = m_helper.getOrCreateRepositoryVersion(new StackId("HDP-2.1.1"), "2.1.1.0-1234");
+    repoVersion2111 = m_helper.getOrCreateRepositoryVersion(new StackId("HDP-2.1.1"), "2.1.1.1-5678");
+    repoVersion2200 = m_helper.getOrCreateRepositoryVersion(new StackId("HDP-2.2.0"), "2.2.0.0-1234");
 
     makeUpgradeCluster();
   }
@@ -170,7 +167,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -220,13 +217,16 @@ public class ConfigureActionTest {
     Cluster c = clusters.getCluster("c1");
     assertEquals(1, c.getConfigsByType("zoo.cfg").size());
 
+    c.setCurrentStackVersion(repoVersion2110.getStackId());
+    c.setDesiredStackVersion(repoVersion2200.getStackId());
+
     Map<String, String> properties = new HashMap<String, String>() {
       {
         put("initLimit", "10");
       }
     };
 
-    Config config = createConfig(c, repoVersion2200, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -282,7 +282,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -340,7 +340,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -470,7 +470,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -528,7 +528,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -594,7 +594,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -643,13 +643,16 @@ public class ConfigureActionTest {
     Cluster c = clusters.getCluster("c1");
     assertEquals(1, c.getConfigsByType("zoo.cfg").size());
 
+    c.setCurrentStackVersion(repoVersion2110.getStackId());
+    c.setDesiredStackVersion(repoVersion2200.getStackId());
+
     Map<String, String> properties = new HashMap<String, String>() {
       {
         put("fooKey", "barValue");
       }
     };
 
-    Config config = createConfig(c, repoVersion2200, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -701,6 +704,9 @@ public class ConfigureActionTest {
     Cluster c = clusters.getCluster("c1");
     assertEquals(1, c.getConfigsByType("zoo.cfg").size());
 
+    c.setCurrentStackVersion(repoVersion2110.getStackId());
+    c.setDesiredStackVersion(repoVersion2200.getStackId());
+
     Map<String, String> properties = new HashMap<String, String>() {
       {
         put("set.key.1", "s1");
@@ -710,7 +716,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2200, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -798,7 +804,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2200, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -863,10 +869,12 @@ public class ConfigureActionTest {
   @Test
   public void testAllowedReplacment() throws Exception {
 
-
     Cluster c = clusters.getCluster("c1");
     assertEquals(1, c.getConfigsByType("zoo.cfg").size());
 
+    c.setCurrentStackVersion(repoVersion2110.getStackId());
+    c.setDesiredStackVersion(repoVersion2200.getStackId());
+
     Map<String, String> properties = new HashMap<String, String>() {
       {
         put("replace.key.1", "r1");
@@ -877,7 +885,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2200, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -964,7 +972,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -1044,7 +1052,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -1153,7 +1161,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -1249,7 +1257,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -1351,7 +1359,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -1448,7 +1456,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -1542,7 +1550,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -1633,7 +1641,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);
+    Config config = createConfig(c, "zoo.cfg", "version2", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
     assertEquals(2, c.getConfigsByType("zoo.cfg").size());
@@ -1735,7 +1743,7 @@ public class ConfigureActionTest {
       }
     };
 
-    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version1", properties);
+    Config config = createConfig(c, "zoo.cfg", "version1", properties);
 
     c.addDesiredConfig("user", Collections.singleton(config));
 
@@ -1847,8 +1855,8 @@ public class ConfigureActionTest {
     return executionCommand;
   }
 
-  private Config createConfig(Cluster cluster, RepositoryVersionEntity repoVersion, String
type,
-      String tag, Map<String, String> properties) {
+  private Config createConfig(Cluster cluster, String type, String tag,
+      Map<String, String> properties) {
     return configFactory.createNew(cluster, type, tag, properties,
         NO_ATTRIBUTES);
   }


Mime
View raw message