Ejemplo n.º 1
0
 @Test()
 public void testStartAppsWithOverloadedLogic() throws InvalidOperationException {
   controller.setConfigurationReader(configurationReader);
   controller.startTablet();
   TabletStatus status = controller.getCurrentStatus();
   status.applications = 100;
   controller.startApps(1, 100);
   assertEquals(6505, status.cpuSpeed);
   assertEquals(0, status.freeMemory);
   assertEquals(true, status.isOverloaded);
 }
Ejemplo n.º 2
0
  @Test()
  public void testWithMock() throws InvalidOperationException {
    TabletStatus status = new TabletStatus();

    status.isOverloaded = false;
    status.cpuSpeed = 1000;
    status.freeMemory = 3000;
    status.applications = 0;

    when(mockConfigurationReader.getStatus()).thenReturn(status);
    when(mockConfigurationReader.updateStatus()).thenReturn(true);

    controller.setConfigurationReader(mockConfigurationReader);

    TabletStatus returnStatus = controller.startApps(1, 1);
    Assert.assertEquals(false, returnStatus.isOverloaded);
    Assert.assertEquals(1055, returnStatus.cpuSpeed);
    Assert.assertEquals(2950, returnStatus.freeMemory);
    Assert.assertEquals(1, returnStatus.applications);
  }