@Test
public void testRegistrationWithBadVersion() throws Exception,
    InvalidStateTransitionException {

  ActionManager am = actionManagerTestHelper.getMockActionManager();
  replay(am);
  Clusters fsm = clusters;
  HeartBeatHandler handler = new HeartBeatHandler(fsm, new ActionQueue(), am,
      injector);
  clusters.addHost(DummyHostname1);
  Host hostObject = clusters.getHost(DummyHostname1);
  hostObject.setIPv4("ipv4");
  hostObject.setIPv6("ipv6");
  Register reg = new Register();
  HostInfo hi = new HostInfo();
  hi.setHostName(DummyHostname1);
  hi.setOS(DummyOsType);
  reg.setHostname(DummyHostname1);
  reg.setHardwareProfile(hi);
  reg.setAgentVersion(""); // Invalid agent version
  reg.setPrefix(Configuration.PREFIX_DIR);
  try {
    handler.handleRegistration(reg);
    fail ("Expected failure for non compatible agent version");
  } catch (AmbariException e) {
    log.debug("Error:" + e.getMessage());
    Assert.assertTrue(e.getMessage().contains(
        "Cannot register host with non compatible agent version"));
  }
  reg.setAgentVersion(null); // Invalid agent version
  try {
    handler.handleRegistration(reg);
    fail ("Expected failure for non compatible agent version");
  } catch (AmbariException e) {
    log.debug("Error:" + e.getMessage());
    Assert.assertTrue(e.getMessage().contains(
        "Cannot register host with non compatible agent version"));
  }
}