@Test
public void testIsReadyToAccept() throws Exception {

  expect(serviceRegistry.getRegistryHostname()).andReturn("test").anyTimes();
  expect(serviceRegistry.getMaxLoadOnNode("test")).andReturn(new NodeLoad("test", 0.0f, 4.0f)).anyTimes();
  //Initially zero load + 1.0f
  expect(serviceRegistry.getOwnLoad()).andReturn(1.0f);
  //Initially 4.0 load + 1.0f
  expect(serviceRegistry.getOwnLoad()).andReturn(5.0f);
  //Initially zero load + 10.0f
  expect(serviceRegistry.getOwnLoad()).andReturn(10.0f);
  replayAll();
  jobProducer.setAcceptOversizeJobs(false);
  Job job = new JobImpl(3);
  job.setJobType("test");
  job.setStatus(Status.DISPATCHING);
  job.setProcessingHost("same");
  // Job load lower than max load and enough free load available
  job.setJobLoad(1.0f);
  assertTrue("Job load + current load < max load, so accept job", jobProducer.isReadyToAccept(job));
  job.setJobLoad(1.0f);
  assertFalse("Job load + current load >= max load, so reject job", jobProducer.isReadyToAccept(job));
  // Job load higher than max load but some load on host
  job.setJobLoad(10.0f);
  assertFalse("Job load >= max load, so reject job", jobProducer.isReadyToAccept(job));
}