|
22 | 22 | import org.apache.cloudstack.api.BaseCmd.HTTPMethod; |
23 | 23 | import org.apache.cloudstack.api.command.user.vm.UpdateVMCmd; |
24 | 24 | import org.apache.cloudstack.context.CallContext; |
25 | | -import org.junit.Assert; |
26 | 25 | import org.junit.Before; |
27 | 26 | import org.junit.Test; |
28 | 27 | import org.junit.runner.RunWith; |
|
48 | 47 | import com.cloud.vm.dao.UserVmDao; |
49 | 48 | import com.cloud.vm.dao.UserVmDetailsDao; |
50 | 49 |
|
| 50 | +import static org.junit.Assert.assertEquals; |
| 51 | +import static org.junit.Assert.assertFalse; |
| 52 | +import static org.junit.Assert.assertTrue; |
| 53 | + |
51 | 54 | @RunWith(PowerMockRunner.class) |
52 | 55 | public class UserVmManagerImplTest { |
53 | 56 |
|
@@ -274,6 +277,18 @@ private void configureValidateOrReplaceMacAddressTest(int times, String macAddre |
274 | 277 | String returnedMacAddress = userVmManagerImpl.validateOrReplaceMacAddress(macAddress, 1l); |
275 | 278 |
|
276 | 279 | Mockito.verify(networkModel, Mockito.times(times)).getNextAvailableMacAddressInNetwork(Mockito.anyLong()); |
277 | | - Assert.assertEquals(expectedMacAddress, returnedMacAddress); |
| 280 | + assertEquals(expectedMacAddress, returnedMacAddress); |
| 281 | + } |
| 282 | + |
| 283 | + @Test |
| 284 | + public void testValidatekeyValuePair() throws Exception { |
| 285 | + assertTrue(userVmManagerImpl.isValidKeyValuePair("is-a-template=true\nHVM-boot-policy=\nPV-bootloader=pygrub\nPV-args=hvc0")); |
| 286 | + assertTrue(userVmManagerImpl.isValidKeyValuePair("is-a-template=true HVM-boot-policy= PV-bootloader=pygrub PV-args=hvc0")); |
| 287 | + assertTrue(userVmManagerImpl.isValidKeyValuePair("nvp.vm-uuid=34b3d5ea-1c25-4bb0-9250-8dc3388bfa9b")); |
| 288 | + assertFalse(userVmManagerImpl.isValidKeyValuePair("key")); |
| 289 | + //key-1=value1, param:key-2=value2, my.config.v0=False" |
| 290 | + assertTrue(userVmManagerImpl.isValidKeyValuePair("key-1=value1")); |
| 291 | + assertTrue(userVmManagerImpl.isValidKeyValuePair("param:key-2=value2")); |
| 292 | + assertTrue(userVmManagerImpl.isValidKeyValuePair("my.config.v0=False")); |
278 | 293 | } |
279 | 294 | } |
0 commit comments