CLOUDSTACK-2459 Fix the scale vm tests
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/24cdddbf Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/24cdddbf Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/24cdddbf Branch: refs/heads/ui-vpc-redesign Commit: 24cdddbf5e645da92855f3f19c8d81b1ddf57e06 Parents: 39caa0e Author: Nitin Mehta <[email protected]> Authored: Wed May 15 14:25:39 2013 +0530 Committer: Nitin Mehta <[email protected]> Committed: Wed May 15 14:25:39 2013 +0530 ---------------------------------------------------------------------- server/test/com/cloud/vm/UserVmManagerTest.java | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/24cdddbf/server/test/com/cloud/vm/UserVmManagerTest.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/vm/UserVmManagerTest.java b/server/test/com/cloud/vm/UserVmManagerTest.java index 939ecdc..6a97114 100755 --- a/server/test/com/cloud/vm/UserVmManagerTest.java +++ b/server/test/com/cloud/vm/UserVmManagerTest.java @@ -246,8 +246,8 @@ public class UserVmManagerTest { } - // Test scaleVm on incompatible HV. - //@Test(expected=InvalidParameterValueException.class) + // Test scaleVm on equal service offerings. + @Test(expected=InvalidParameterValueException.class) public void testScaleVMF2() throws Exception { ScaleVMCmd cmd = new ScaleVMCmd(); @@ -261,14 +261,11 @@ public class UserVmManagerTest { serviceOfferingIdField.setAccessible(true); serviceOfferingIdField.set(cmd, 1L); - //UserContext.current().setEventDetails("Vm Id: "+getId()); - // Account account = (Account) new AccountVO("testaccount", 1L, "networkdomain", (short) 0, 1); - //AccountVO(String accountName, long domainId, String networkDomain, short type, int regionId) - // UserContext.registerContext(1, account, null, true); when(_vmInstanceDao.findById(anyLong())).thenReturn(_vmInstance); doReturn(Hypervisor.HypervisorType.XenServer).when(_vmInstance).getHypervisorType(); + doReturn(VirtualMachine.State.Running).when(_vmInstance).getState(); doNothing().when(_accountMgr).checkAccess(_account, null, true, _templateMock); @@ -285,8 +282,8 @@ public class UserVmManagerTest { } - // Test scaleVm for Stopped vm. Full positive test. - //@Test + // Test scaleVm for Stopped vm. + @Test(expected=InvalidParameterValueException.class) public void testScaleVMF3() throws Exception { ScaleVMCmd cmd = new ScaleVMCmd(); @@ -316,10 +313,12 @@ public class UserVmManagerTest { when(_configMgr.getServiceOffering(1L)).thenReturn(so1); doReturn(VirtualMachine.State.Stopped).when(_vmInstance).getState(); + when(_vmDao.findById(anyLong())).thenReturn(null); + doReturn(true).when(_itMgr).upgradeVmDb(anyLong(),anyLong()); - when(_vmDao.findById(anyLong())).thenReturn(_vmMock); + //when(_vmDao.findById(anyLong())).thenReturn(_vmMock); _userVmMgr.upgradeVirtualMachine(cmd);
