You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vg...@apache.org on 2011/12/22 00:12:58 UTC
svn commit: r1221934 -
/incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/resource/statemachine/TestClusterImpl.java
Author: vgogate
Date: Wed Dec 21 23:12:58 2011
New Revision: 1221934
URL: http://svn.apache.org/viewvc?rev=1221934&view=rev
Log:
AMBARI-170. Update the cluster state after state machine transitions it to final ACTIVE/INACTIVE state
Modified:
incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/resource/statemachine/TestClusterImpl.java
Modified: incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/resource/statemachine/TestClusterImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/resource/statemachine/TestClusterImpl.java?rev=1221934&r1=1221933&r2=1221934&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/resource/statemachine/TestClusterImpl.java (original)
+++ incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/resource/statemachine/TestClusterImpl.java Wed Dec 21 23:12:58 2011
@@ -41,6 +41,7 @@ public class TestClusterImpl {
ClusterState clsState;
Cluster cluster;
+ int numUpdateClusterMethodCalls = 0;
@BeforeMethod
public void setup() throws IOException{
@@ -52,6 +53,7 @@ public class TestClusterImpl {
when(cluster.getClusterDefinition(anyInt())).thenReturn(clusterDef);
when(cluster.getClusterState()).thenReturn(clsState);
clusterImpl = new ClusterImpl(cluster, 1);
+ numUpdateClusterMethodCalls = 0;
}
/**
@@ -64,10 +66,12 @@ public class TestClusterImpl {
public Void answer(InvocationOnMock invocation) throws Throwable {
ClusterState cs = (ClusterState)invocation.getArguments()[0];
assertTrue(cs.getState().equals(ClusterState.CLUSTER_STATE_ACTIVE));
+ numUpdateClusterMethodCalls++;
return null;
}
}).when(cluster).updateClusterState(clsState);
verifyTransitions(ClusterStateFSM.INACTIVE, startEvents, startStates);
+ assertTrue(numUpdateClusterMethodCalls == 1);
}
@@ -81,10 +85,12 @@ public class TestClusterImpl {
public Void answer(InvocationOnMock invocation) throws Throwable {
ClusterState cs = (ClusterState)invocation.getArguments()[0];
assertTrue(cs.getState().equals(ClusterState.CLUSTER_STATE_ACTIVE));
+ numUpdateClusterMethodCalls++;
return null;
}
}).when(cluster).updateClusterState(clsState);
verifyTransitions(ClusterStateFSM.FAIL, startEvents, startStates);
+ assertTrue(numUpdateClusterMethodCalls == 1);
}
ClusterEventType [] stopEvents = {
@@ -108,10 +114,12 @@ public class TestClusterImpl {
public Void answer(InvocationOnMock invocation) throws Throwable {
ClusterState cs = (ClusterState)invocation.getArguments()[0];
assertTrue(cs.getState().equals(ClusterState.CLUSTER_STATE_INACTIVE));
+ numUpdateClusterMethodCalls++;
return null;
}
}).when(cluster).updateClusterState(clsState);
verifyTransitions(ClusterStateFSM.ACTIVE, stopEvents, stopStates);
+ assertTrue(numUpdateClusterMethodCalls == 1);
}
@@ -125,10 +133,12 @@ public class TestClusterImpl {
public Void answer(InvocationOnMock invocation) throws Throwable {
ClusterState cs = (ClusterState)invocation.getArguments()[0];
assertTrue(cs.getState().equals(ClusterState.CLUSTER_STATE_INACTIVE));
+ numUpdateClusterMethodCalls++;
return null;
}
}).when(cluster).updateClusterState(clsState);
verifyTransitions(ClusterStateFSM.FAIL, stopEvents, stopStates);
+ assertTrue(numUpdateClusterMethodCalls == 1);
}
private void verifyTransitions(ClusterStateFSM startState, ClusterEventType[] ClusterEvents,