You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2012/09/28 07:55:11 UTC

svn commit: r1391311 - in /incubator/ambari/branches/AMBARI-666: AMBARI-666-CHANGES.txt ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java

Author: mahadev
Date: Fri Sep 28 05:55:11 2012
New Revision: 1391311

URL: http://svn.apache.org/viewvc?rev=1391311&view=rev
Log:
AMBARI-774. Renable and fix AgentResourceTest. (mahadev)

Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java

Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1391311&r1=1391310&r2=1391311&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Fri Sep 28 05:55:11 2012
@@ -171,6 +171,8 @@ AMBARI-666 branch (unreleased changes)
 
   BUG FIXES
 
+  AMBARI-774. Renable and fix AgentResourceTest. (mahadev) 
+
   AMBARI-773. Change Host FSM as per new requirements of heartbeat handler. (hitesh)
 
   AMBARI-761. Fix broken build for adding guice servlet dependency. (mahadev)

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java?rev=1391311&r1=1391310&r2=1391311&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java Fri Sep 28 05:55:11 2012
@@ -32,6 +32,10 @@ public abstract class AgentCommand {
   @XmlElement
   private AgentCommandType commandType;
   
+  public AgentCommand() {
+    this.commandType = AgentCommandType.STATUS_COMMAND;
+  }
+  
   public AgentCommand(AgentCommandType type) {
     this.commandType = type;
   }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java?rev=1391311&r1=1391310&r2=1391311&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java Fri Sep 28 05:55:11 2012
@@ -19,7 +19,8 @@
 package org.apache.ambari.server.agent;
 
 import static org.mockito.Mockito.mock;
-
+import static org.mockito.Mockito.when;
+import static org.mockito.Matchers.any;
 import javax.ws.rs.core.MediaType;
 
 import junit.framework.Assert;
@@ -56,13 +57,24 @@ public class AgentResourceTest extends J
   }
   
   public class MockModule extends AbstractModule {
-
+    
+    RegistrationResponse response = new RegistrationResponse();
+    HeartBeatResponse hresponse = new HeartBeatResponse();
+    
     @Override
     protected void configure() {
+      handler = mock(HeartBeatHandler.class);
+      response.setResponseStatus(RegistrationStatus.OK);
+      hresponse.setResponseId(0L);
+      when(handler.handleRegistration(any(Register.class))).thenReturn(
+          response);
+      when(handler.handleHeartBeat(any(HeartBeat.class))).thenReturn(hresponse);
       requestStaticInjection(AgentResource.class);
       bind(Clusters.class).to(ClustersImpl.class);
       actionManager = mock(ActionManager.class);
       bind(ActionManager.class).toInstance(actionManager);
+      bind(AgentCommand.class).to(ExecutionCommand.class);
+      bind(HeartBeatHandler.class).toInstance(handler);
     }    
   }
   
@@ -90,7 +102,7 @@ public class AgentResourceTest extends J
     return json;
   }
   
-  //@Test
+  @Test
   public void agentRegistration() throws UniformInterfaceException, JSONException {
     RegistrationResponse response;
     WebResource webResource = resource();
@@ -100,7 +112,7 @@ public class AgentResourceTest extends J
     Assert.assertEquals(response.getResponseStatus(), RegistrationStatus.OK);
   }
   
-  //@Test
+  @Test
   public void agentHeartBeat() throws UniformInterfaceException, JSONException {
     HeartBeatResponse response;
     WebResource resource = resource();