/** Unit tests for get/set nbOfCPUs. */ public void testNbOfCPUs() { final DefaultVirtualMachine n = new DefaultVirtualMachine("N1", 1, 3, 1024); // Test default value Assert.assertEquals(n.getNbOfCPUs(), 1); // Test the binding n.updateValue(DefaultVirtualMachine.CPU_NB, 2); Assert.assertEquals(n.getNbOfCPUs(), 2); }
/** 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); }