ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject ambari git commit: AMBARI-13608. Fix the fixture for the TopologyManagerTest. (Laszlo Puskas via swagle)
Date Tue, 10 Nov 2015 17:44:07 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 44191d5ce -> e5f743416


AMBARI-13608. Fix the fixture for the TopologyManagerTest. (Laszlo Puskas via swagle)


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

Branch: refs/heads/branch-2.1
Commit: e5f743416639f1f283ffa707743fc1a4a9af5282
Parents: 44191d5
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Tue Nov 10 09:43:54 2015 -0800
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Tue Nov 10 09:43:54 2015 -0800

----------------------------------------------------------------------
 .../ambari/server/controller/AmbariServer.java  |   1 -
 .../server/controller/ControllerModule.java     |   4 +
 .../ambari/server/topology/AmbariContext.java   |   5 +-
 .../server/topology/PersistedStateImpl.java     |  40 +++----
 .../ambari/server/topology/TopologyManager.java |  25 ++--
 .../AmbariCustomCommandExecutionHelperTest.java |   4 +-
 .../AmbariManagementControllerTest.java         |   3 +-
 .../BackgroundCustomCommandExecutionTest.java   |   5 +-
 .../UpgradeResourceProviderHDP22Test.java       |   3 +-
 .../internal/UpgradeResourceProviderTest.java   |   3 +-
 .../server/topology/TopologyManagerTest.java    | 115 +++++++++++--------
 .../ambari/server/utils/StageUtilsTest.java     |   2 +
 12 files changed, 120 insertions(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e5f74341/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index bdd82dd..33bb95c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
@@ -708,7 +708,6 @@ public class AmbariServer {
     ClusterPrivilegeResourceProvider.init(injector.getInstance(ClusterDAO.class));
     AmbariPrivilegeResourceProvider.init(injector.getInstance(ClusterDAO.class));
     ActionManager.setTopologyManager(injector.getInstance(TopologyManager.class));
-    TopologyManager.init(injector.getInstance(StackAdvisorBlueprintProcessor.class));
     StackAdvisorBlueprintProcessor.init(injector.getInstance(StackAdvisorHelper.class));
 
     RetryHelper.init(configs.getOperationsRetryAttempts());

http://git-wip-us.apache.org/repos/asf/ambari/blob/e5f74341/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
index 20f0482..20fe2c7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
@@ -103,6 +103,8 @@ import org.apache.ambari.server.state.scheduler.RequestExecutionImpl;
 import org.apache.ambari.server.state.stack.OsFamily;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostImpl;
 import org.apache.ambari.server.topology.BlueprintFactory;
+import org.apache.ambari.server.topology.PersistedState;
+import org.apache.ambari.server.topology.PersistedStateImpl;
 import org.apache.ambari.server.topology.SecurityConfigurationFactory;
 import org.apache.ambari.server.view.ViewInstanceHandlerList;
 import org.eclipse.jetty.server.SessionIdManager;
@@ -342,6 +344,8 @@ public class ControllerModule extends AbstractModule {
     bind(TimelineMetricCacheEntryFactory.class);
     bind(SecurityConfigurationFactory.class).in(Scopes.SINGLETON);
 
+    bind(PersistedState.class).to(PersistedStateImpl.class);
+
     requestStaticInjection(ExecutionCommandWrapper.class);
     requestStaticInjection(DatabaseChecker.class);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e5f74341/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
index 4b0a1d1..608e6ca 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
@@ -60,6 +60,7 @@ import org.apache.ambari.server.utils.RetryHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.inject.Inject;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -77,7 +78,9 @@ public class AmbariContext {
 
   public enum TaskType {INSTALL, START}
 
-  private static PersistedState persistedState = new PersistedStateImpl();
+  @Inject
+  private PersistedState persistedState;
+
   private static AmbariManagementController controller;
   private static ClusterController clusterController;
   //todo: task id's.  Use existing mechanism for getting next task id sequence

http://git-wip-us.apache.org/repos/asf/ambari/blob/e5f74341/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
index e0caa18..dcff49c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
@@ -18,17 +18,9 @@
 
 package org.apache.ambari.server.topology;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import com.google.gson.Gson;
 import com.google.inject.Inject;
 import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.StaticallyInject;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
@@ -48,41 +40,49 @@ import org.apache.ambari.server.stack.NoSuchStackException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.inject.Singleton;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * Implementation which uses Ambari Database DAO and Entity objects for persistence
  * of topology related information.
  */
-@StaticallyInject
+@Singleton
 public class PersistedStateImpl implements PersistedState {
 
   protected final static Logger LOG = LoggerFactory.getLogger(PersistedState.class);
 
   @Inject
-  private static TopologyRequestDAO topologyRequestDAO;
+  private TopologyRequestDAO topologyRequestDAO;
 
   @Inject
-  private static TopologyHostGroupDAO hostGroupDAO;
+  private TopologyHostGroupDAO hostGroupDAO;
 
   @Inject
-  private static TopologyHostRequestDAO hostRequestDAO;
+  private TopologyHostRequestDAO hostRequestDAO;
 
   @Inject
-  private static TopologyLogicalTaskDAO topologyLogicalTaskDAO;
+  private TopologyLogicalTaskDAO topologyLogicalTaskDAO;
 
   @Inject
-  private static HostRoleCommandDAO hostRoleCommandDAO;
+  private HostRoleCommandDAO hostRoleCommandDAO;
 
   @Inject
-  private static HostRoleCommandDAO physicalTaskDAO;
+  private HostRoleCommandDAO physicalTaskDAO;
 
   @Inject
-  private static BlueprintFactory blueprintFactory;
+  private BlueprintFactory blueprintFactory;
 
   @Inject
-  private static LogicalRequestFactory logicalRequestFactory;
+  private LogicalRequestFactory logicalRequestFactory;
 
   @Inject
-  private static AmbariContext ambariContext;
+  private AmbariContext ambariContext;
 
   private static Gson jsonSerializer = new Gson();
 
@@ -133,7 +133,7 @@ public class PersistedStateImpl implements PersistedState {
 
     Map<Long, ClusterTopology> topologyRequests = new HashMap<Long, ClusterTopology>();
     for (TopologyRequestEntity entity : entities) {
-      TopologyRequest replayedRequest = new ReplayedTopologyRequest(entity);
+      TopologyRequest replayedRequest = new ReplayedTopologyRequest(entity, blueprintFactory);
       ClusterTopology clusterTopology = topologyRequests.get(replayedRequest.getClusterId());
       if (clusterTopology == null) {
         try {
@@ -306,7 +306,7 @@ public class PersistedStateImpl implements PersistedState {
     private final Configuration configuration;
     private final Map<String, HostGroupInfo> hostGroupInfoMap = new HashMap<String,
HostGroupInfo>();
 
-    public ReplayedTopologyRequest(TopologyRequestEntity entity) {
+    public ReplayedTopologyRequest(TopologyRequestEntity entity, BlueprintFactory blueprintFactory)
{
       clusterId = entity.getClusterId();
       type = Type.valueOf(entity.getAction());
       description = entity.getDescription();

http://git-wip-us.apache.org/repos/asf/ambari/blob/e5f74341/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
index a688464..9e902a7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
@@ -82,13 +82,16 @@ public class TopologyManager {
   //todo: currently only support a single cluster
   private Map<Long, ClusterTopology> clusterTopologyMap = new HashMap<Long, ClusterTopology>();
 
-  //todo: inject
-  private static LogicalRequestFactory logicalRequestFactory = new LogicalRequestFactory();
-  private static AmbariContext ambariContext = new AmbariContext();
-  private static StackAdvisorBlueprintProcessor stackAdvisorBlueprintProcessor;
+  @Inject
+  private StackAdvisorBlueprintProcessor stackAdvisorBlueprintProcessor;
 
-  private final Object initializationLock = new Object();
+  @Inject
+  private LogicalRequestFactory logicalRequestFactory;
 
+  @Inject
+  private AmbariContext ambariContext;
+
+  private final Object initializationLock = new Object();
 
   @Inject
   private SecurityConfigurationFactory securityConfigurationFactory;
@@ -106,6 +109,10 @@ public class TopologyManager {
   private final static Logger LOG = LoggerFactory.getLogger(TopologyManager.class);
 
   public TopologyManager() {
+  }
+
+  @Inject
+  private void setPersistedState() {
     persistedState = ambariContext.getPersistedTopologyState();
   }
 
@@ -222,8 +229,8 @@ public class TopologyManager {
       // todo - perform this logic at request creation instead!
       LOG.debug("There's no security configuration in the request, retrieving it from the
associated blueprint");
       securityConfiguration = request.getBlueprint().getSecurity();
-      if (securityConfiguration.getType() == SecurityType.KERBEROS &&
-        securityConfiguration.getDescriptorReference() != null) {
+      if (securityConfiguration != null && securityConfiguration.getType() == SecurityType.KERBEROS
&&
+          securityConfiguration.getDescriptorReference() != null) {
         securityConfiguration = securityConfigurationFactory.loadSecurityConfigurationByReference
           (securityConfiguration.getDescriptorReference());
       }
@@ -671,10 +678,6 @@ public class TopologyManager {
     executor.execute(new ConfigureClusterTask(topology, configurationRequest));
   }
 
-  public static void init(StackAdvisorBlueprintProcessor instance) {
-    stackAdvisorBlueprintProcessor = instance;
-  }
-
   private class ConfigureClusterTask implements Runnable {
     private ClusterConfigurationRequest configRequest;
     private ClusterTopology topology;

http://git-wip-us.apache.org/repos/asf/ambari/blob/e5f74341/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
index 8ccb445..baa394c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
@@ -70,6 +70,7 @@ public class AmbariCustomCommandExecutionHelperTest {
   private AmbariManagementController controller;
   private AmbariMetaInfo ambariMetaInfo;
   private Clusters clusters;
+  private TopologyManager topologyManager;
   
   
   private static final String REQUEST_CONTEXT_PROPERTY = "context";
@@ -93,7 +94,8 @@ public class AmbariCustomCommandExecutionHelperTest {
     controller = injector.getInstance(AmbariManagementController.class);
     clusters = injector.getInstance(Clusters.class);
     ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
-    StageUtils.setTopologyManager(new TopologyManager());
+    topologyManager = injector.getInstance(TopologyManager.class);
+    StageUtils.setTopologyManager(topologyManager);
   }
   @After
   public void teardown() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/e5f74341/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 38231cd..bd32dc9 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -200,6 +200,7 @@ public class AmbariManagementControllerTest {
   private OrmTestHelper helper;
   private StageFactory stageFactory;
   private HostDAO hostDAO;
+  private TopologyManager topologyManager;
 
   @Rule
   public ExpectedException expectedException = ExpectedException.none();
@@ -228,7 +229,7 @@ public class AmbariManagementControllerTest {
     helper = injector.getInstance(OrmTestHelper.class);
     stageFactory = injector.getInstance(StageFactory.class);
     hostDAO = injector.getInstance(HostDAO.class);
-    TopologyManager topologyManager = new TopologyManager();
+     topologyManager = injector.getInstance(TopologyManager.class);
     StageUtils.setTopologyManager(topologyManager);
     ActionManager.setTopologyManager(topologyManager);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/e5f74341/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
index d1475e0..30be261 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
@@ -70,7 +70,7 @@ public class BackgroundCustomCommandExecutionTest {
   private AmbariMetaInfo ambariMetaInfo;
   private Configuration configuration;
   private Clusters clusters;
-  
+  private TopologyManager topologyManager;
   
   private static final String REQUEST_CONTEXT_PROPERTY = "context";
   
@@ -96,11 +96,12 @@ public class BackgroundCustomCommandExecutionTest {
     controller = injector.getInstance(AmbariManagementController.class);
     clusters = injector.getInstance(Clusters.class);
     configuration = injector.getInstance(Configuration.class);
+    topologyManager = injector.getInstance(TopologyManager.class);
     
     Assert.assertEquals("src/main/resources/custom_action_definitions", configuration.getCustomActionDefinitionPath());
     
     ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
-    StageUtils.setTopologyManager(new TopologyManager());
+    StageUtils.setTopologyManager(topologyManager);
   }
   @After
   public void teardown() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/e5f74341/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java
index 8997f58..c6fd6f7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java
@@ -103,6 +103,7 @@ public class UpgradeResourceProviderHDP22Test {
   private AmbariManagementController amc;
   private ConfigHelper configHelper;
   private StackDAO stackDAO;
+  private TopologyManager topologyManager;
 
   private static final String configTagVersion1 = "version1";
   private static final String configTagVersion2 = "version2";
@@ -221,7 +222,7 @@ public class UpgradeResourceProviderHDP22Test {
     component = service.addServiceComponent("HIVE_CLIENT");
     sch = component.addServiceComponentHost(s_serverHostName);
     sch.setVersion("2.2.0.0");
-    TopologyManager topologyManager = new TopologyManager();
+    topologyManager = injector.getInstance(TopologyManager.class);
     StageUtils.setTopologyManager(topologyManager);
     ActionManager.setTopologyManager(topologyManager);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/e5f74341/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
index c230c44..4a203f2 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
@@ -117,6 +117,7 @@ public class UpgradeResourceProviderTest {
   private ConfigHelper configHelper;
   private StackDAO stackDAO;
   private AmbariMetaInfo ambariMetaInfo;
+  private TopologyManager topologyManager;
 
   @Before
   public void before() throws Exception {
@@ -224,7 +225,7 @@ public class UpgradeResourceProviderTest {
     sch = component.addServiceComponentHost("h1");
     sch.setVersion("2.1.1.0");
 
-    TopologyManager topologyManager = new TopologyManager();
+    topologyManager = injector.getInstance(TopologyManager.class);
     StageUtils.setTopologyManager(topologyManager);
     ActionManager.setTopologyManager(topologyManager);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/e5f74341/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java
index 92e3e1c..3326bd4 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java
@@ -23,9 +23,12 @@ import org.apache.ambari.server.controller.ConfigurationRequest;
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
 import org.apache.ambari.server.controller.internal.Stack;
+import org.apache.ambari.server.controller.spi.ClusterController;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+import org.apache.ambari.server.security.encryption.CredentialStoreService;
 import org.apache.ambari.server.state.SecurityType;
 import org.easymock.Capture;
-import org.easymock.EasyMock;
 import org.easymock.EasyMockRule;
 import org.easymock.EasyMockSupport;
 import org.easymock.Mock;
@@ -33,7 +36,6 @@ import org.easymock.MockType;
 import org.easymock.TestSubject;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -47,24 +49,21 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutorService;
 
+import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.createStrictMock;
 import static org.easymock.EasyMock.eq;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
 import static org.easymock.EasyMock.isA;
 import static org.easymock.EasyMock.isNull;
+import static org.easymock.EasyMock.newCapture;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.same;
 import static org.easymock.EasyMock.verify;
 
 /**
  * TopologyManager unit tests
  */
-@Ignore("The setup needs to be rethought as it's hard to follow!")
 public class TopologyManagerTest {
 
   private static final String CLUSTER_NAME = "test-cluster";
@@ -73,27 +72,51 @@ public class TopologyManagerTest {
   private static final String STACK_NAME = "test-stack";
   private static final String STACK_VERSION = "test-stack-version";
 
+  @Rule
+  public EasyMockRule mocks = new EasyMockRule(this);
+
   @TestSubject
   private TopologyManager topologyManager = new TopologyManager();
 
-  private final Blueprint blueprint = createNiceMock(Blueprint.class);
-  private final Stack stack = createNiceMock(Stack.class);
-  private final ProvisionClusterRequest request = createNiceMock(ProvisionClusterRequest.class);
-  private final PersistedTopologyRequest persistedTopologyRequest = new PersistedTopologyRequest(1,
request);
-  private final LogicalRequestFactory logicalRequestFactory = createStrictMock(LogicalRequestFactory.class);
-  private final LogicalRequest logicalRequest = createMock(LogicalRequest.class);
-  private final AmbariContext ambariContext = createMock(AmbariContext.class);
-  private final ConfigurationRequest configurationRequest = createNiceMock(ConfigurationRequest.class);
-  private final ConfigurationRequest configurationRequest2 = createNiceMock(ConfigurationRequest.class);
-  private final ConfigurationRequest configurationRequest3 = createNiceMock(ConfigurationRequest.class);
-
-  private final RequestStatusResponse requestStatusResponse = createNiceMock(RequestStatusResponse.class);
-  private final ExecutorService executor = createStrictMock(ExecutorService.class);
-  private final PersistedState persistedState = createStrictMock(PersistedState.class);
+  @Mock(type = MockType.NICE)
+  private Blueprint blueprint;
 
-  private final HostGroup group1 = createNiceMock(HostGroup.class);
-  private final HostGroup group2 = createNiceMock(HostGroup.class);
+  @Mock(type = MockType.NICE)
+  private Stack stack;
 
+  @Mock(type = MockType.NICE)
+  private ProvisionClusterRequest request;
+  private final PersistedTopologyRequest persistedTopologyRequest = new PersistedTopologyRequest(1,
request);
+  @Mock(type = MockType.STRICT)
+  private LogicalRequestFactory logicalRequestFactory;
+  @Mock(type = MockType.DEFAULT)
+  private LogicalRequest logicalRequest;
+  @Mock(type = MockType.NICE)
+  private AmbariContext ambariContext;
+  @Mock(type = MockType.NICE)
+  private ConfigurationRequest configurationRequest;
+  @Mock(type = MockType.NICE)
+  private ConfigurationRequest configurationRequest2;
+  @Mock(type = MockType.NICE)
+  private ConfigurationRequest configurationRequest3;
+  @Mock(type = MockType.NICE)
+  private RequestStatusResponse requestStatusResponse;
+  @Mock(type = MockType.STRICT)
+  private ExecutorService executor;
+  @Mock(type = MockType.STRICT)
+  private PersistedState persistedState;
+  @Mock(type = MockType.NICE)
+  private HostGroup group1;
+  @Mock(type = MockType.NICE)
+  private HostGroup group2;
+  @Mock(type = MockType.STRICT)
+  private SecurityConfigurationFactory securityConfigurationFactory;
+  @Mock(type = MockType.STRICT)
+  private CredentialStoreService credentialStoreService;
+  @Mock(type = MockType.STRICT)
+  private ClusterController clusterController;
+  @Mock(type = MockType.STRICT)
+  private ResourceProvider resourceProvider;
   private final Configuration stackConfig = new Configuration(new HashMap<String, Map<String,
String>>(),
       new HashMap<String, Map<String, Map<String, String>>>());
   private final Configuration bpConfiguration = new Configuration(new HashMap<String,
Map<String, String>>(),
@@ -133,22 +156,14 @@ public class TopologyManagerTest {
   private Capture<ClusterRequest> updateClusterConfigRequestCapture;
   private Capture<Runnable> updateConfigTaskCapture;
 
-
-  @Rule
-  public EasyMockRule mocks = new EasyMockRule(this);
-
-  @Mock(type = MockType.STRICT)
-  private SecurityConfigurationFactory securityConfigurationFactory;
-
-
   @Before
   public void setup() throws Exception {
-    clusterTopologyCapture = new Capture<ClusterTopology>();
-    configRequestPropertiesCapture = new Capture<Map<String, Object>>();
-    configRequestPropertiesCapture2 = new Capture<Map<String, Object>>();
-    configRequestPropertiesCapture3 = new Capture<Map<String, Object>>();
-    updateClusterConfigRequestCapture = new Capture<ClusterRequest>();
-    updateConfigTaskCapture = new Capture<Runnable>();
+    clusterTopologyCapture = newCapture();
+    configRequestPropertiesCapture = newCapture();
+    configRequestPropertiesCapture2 = newCapture();
+    configRequestPropertiesCapture3 = newCapture();
+    updateClusterConfigRequestCapture = newCapture();
+    updateConfigTaskCapture = newCapture();
 
     topoConfiguration.setProperty("service1-site", "s1-prop", "s1-prop-value");
     topoConfiguration.setProperty("service2-site", "s2-prop", "s2-prop-value");
@@ -221,8 +236,12 @@ public class TopologyManagerTest {
     expect(request.getConfiguration()).andReturn(topoConfiguration).anyTimes();
     expect(request.getHostGroupInfo()).andReturn(groupInfoMap).anyTimes();
     expect(request.getTopologyValidators()).andReturn(topologyValidators).anyTimes();
+
     expect(request.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.NEVER_APPLY);
 
+    expect(request.getSecurityConfiguration()).andReturn(null).anyTimes();
+
+
     expect(group1.getBlueprintName()).andReturn(BLUEPRINT_NAME).anyTimes();
     expect(group1.getCardinality()).andReturn("test cardinality").anyTimes();
     expect(group1.containsMasterComponent()).andReturn(true).anyTimes();
@@ -246,7 +265,7 @@ public class TopologyManagerTest {
     expect(group2.getStack()).andReturn(stack).anyTimes();
 
 
-    expect(logicalRequestFactory.createRequest(eq(1L), same(request), capture(clusterTopologyCapture))).
+    expect(logicalRequestFactory.createRequest(eq(1L), (TopologyRequest) anyObject(), capture(clusterTopologyCapture))).
         andReturn(logicalRequest).anyTimes();
     expect(logicalRequest.getRequestId()).andReturn(1L).anyTimes();
     expect(logicalRequest.getReservedHosts()).andReturn(Collections.singleton("host1")).anyTimes();
@@ -274,6 +293,8 @@ public class TopologyManagerTest {
     ambariContext.persistInstallStateForUI(CLUSTER_NAME, STACK_NAME, STACK_VERSION);
     expectLastCall().once();
 
+    expect(clusterController.ensureResourceProvider(anyObject(Resource.Type.class))).andReturn(resourceProvider);
+
     executor.execute(capture(updateConfigTaskCapture));
     expectLastCall().times(1);
 
@@ -282,26 +303,18 @@ public class TopologyManagerTest {
     expect(persistedState.persistTopologyRequest(request)).andReturn(persistedTopologyRequest).once();
     persistedState.persistLogicalRequest(logicalRequest, 1);
 
-    replay(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory,
-        logicalRequest, configurationRequest, configurationRequest2, configurationRequest3,
-        requestStatusResponse, executor, persistedState);
+    replay(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory,
logicalRequest,
+        configurationRequest, configurationRequest2, configurationRequest3, requestStatusResponse,
executor,
+        persistedState, securityConfigurationFactory, credentialStoreService, clusterController,
resourceProvider);
 
     Class clazz = TopologyManager.class;
-    Field f = clazz.getDeclaredField("logicalRequestFactory");
-    f.setAccessible(true);
-    f.set(null, logicalRequestFactory);
 
-    f = clazz.getDeclaredField("ambariContext");
-    f.setAccessible(true);
-    f.set(null, ambariContext);
-
-
-    f = clazz.getDeclaredField("executor");
+    Field f = clazz.getDeclaredField("executor");
     f.setAccessible(true);
     f.set(topologyManager, executor);
 
     EasyMockSupport.injectMocks(topologyManager);
-    EasyMock.replay(securityConfigurationFactory);
+
   }
 
   @After

http://git-wip-us.apache.org/repos/asf/ambari/blob/e5f74341/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
index 3262364..96d9a88 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
@@ -46,6 +46,7 @@ import org.apache.ambari.server.state.cluster.ClusterFactory;
 import org.apache.ambari.server.state.cluster.ClustersImpl;
 import org.apache.ambari.server.state.host.HostFactory;
 import org.apache.ambari.server.state.stack.OsFamily;
+import org.apache.ambari.server.topology.PersistedState;
 import org.apache.ambari.server.topology.TopologyManager;
 import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.map.JsonMappingException;
@@ -105,6 +106,7 @@ public class StageUtilsTest extends EasyMockSupport {
         bind(Clusters.class).toInstance(createNiceMock(ClustersImpl.class));
         bind(StackManagerFactory.class).toInstance(createNiceMock(StackManagerFactory.class));
         bind(ServiceComponentHostFactory.class).toInstance(createNiceMock(ServiceComponentHostFactory.class));
+        bind(PersistedState.class).toInstance(createNiceMock(PersistedState.class));
       }
     });
 


Mime
View raw message