/** Test the setters for resources needs. */ public void testWithNewNeeds() { DefaultVirtualMachine n = new DefaultVirtualMachine("N1", 1, 3, 1024); n.setCPUNeed(5); n.setMemoryNeed(10); Assert.assertEquals(n.getCPUDemand(), 5); Assert.assertEquals(n.getMemoryDemand(), 10); }
/** Test the copy constructor and check if there is no side-effects. */ public void testCopyConstructor() { final DefaultVirtualMachine n = new DefaultVirtualMachine("N1", 1, 3, 1024); n.setCPUNeed(15); final DefaultVirtualMachine n2 = new DefaultVirtualMachine(n); Assert.assertEquals(n2.getMemoryConsumption(), 1024); Assert.assertEquals(n2.getMemoryDemand(), 1024); Assert.assertEquals(n2.getNbOfCPUs(), 1); Assert.assertEquals(n2.getCPUConsumption(), 3); Assert.assertEquals(n2.getCPUDemand(), 15); n.updateValue(DefaultVirtualMachine.CPU_NB, 2); n.updateValue(DefaultVirtualMachine.MEMORY, 2048); n.updateValue(DefaultVirtualMachine.CPU_CONSUMPTION, 5); Assert.assertEquals(n2.getMemoryConsumption(), 1024); Assert.assertEquals(n2.getNbOfCPUs(), 1); Assert.assertEquals(n2.getCPUConsumption(), 3); }