mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Reworked the formatting and structure of the api project's unit tests.
Signed-off-by: Chip Childers <chip.childers@gmail.com>
This commit is contained in:
parent
e953b77492
commit
b1c063298d
@ -23,18 +23,18 @@ import com.cloud.network.PhysicalNetworkSetupInfo;
|
|||||||
public class CheckNetworkCommand extends Command {
|
public class CheckNetworkCommand extends Command {
|
||||||
|
|
||||||
List<PhysicalNetworkSetupInfo> networkInfoList;
|
List<PhysicalNetworkSetupInfo> networkInfoList;
|
||||||
|
|
||||||
public CheckNetworkCommand(List<PhysicalNetworkSetupInfo> networkInfoList) {
|
public CheckNetworkCommand(List<PhysicalNetworkSetupInfo> networkInfoList) {
|
||||||
this.networkInfoList = networkInfoList;
|
this.networkInfoList = networkInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PhysicalNetworkSetupInfo> getPhysicalNetworkInfoList() {
|
public List<PhysicalNetworkSetupInfo> getPhysicalNetworkInfoList() {
|
||||||
return networkInfoList;
|
return networkInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CheckNetworkCommand() {
|
protected CheckNetworkCommand() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeInSequence() {
|
public boolean executeInSequence() {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -17,37 +17,38 @@
|
|||||||
package com.cloud.agent.api;
|
package com.cloud.agent.api;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This currently assumes that both primary and secondary storage are mounted on the XenServer.
|
* This currently assumes that both primary and secondary storage are mounted on
|
||||||
|
* the XenServer.
|
||||||
*/
|
*/
|
||||||
public class SnapshotCommand extends Command {
|
public class SnapshotCommand extends Command {
|
||||||
protected String primaryStoragePoolNameLabel;
|
protected String primaryStoragePoolNameLabel;
|
||||||
private String snapshotUuid;
|
private String snapshotUuid;
|
||||||
private String snapshotName;
|
private String snapshotName;
|
||||||
private String secondaryStorageUrl;
|
private String secondaryStorageUrl;
|
||||||
private Long dcId;
|
private Long dcId;
|
||||||
private Long accountId;
|
private Long accountId;
|
||||||
private Long volumeId;
|
private Long volumeId;
|
||||||
private String volumePath;
|
private String volumePath;
|
||||||
|
|
||||||
protected SnapshotCommand() {
|
protected SnapshotCommand() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param primaryStoragePoolNameLabel The primary storage Pool
|
* @param primaryStoragePoolNameLabel
|
||||||
* @param snapshotUuid The UUID of the snapshot which is going to be backed up
|
* The primary storage Pool
|
||||||
* @param secondaryStoragePoolURL This is what shows up in the UI when you click on Secondary storage.
|
* @param snapshotUuid
|
||||||
* In the code, it is present as: In the vmops.host_details table, there is a field mount.parent. This is the value of that field
|
* The UUID of the snapshot which is going to be backed up
|
||||||
* If you have better ideas on how to get it, you are welcome.
|
* @param secondaryStoragePoolURL
|
||||||
|
* This is what shows up in the UI when you click on Secondary
|
||||||
|
* storage. In the code, it is present as: In the
|
||||||
|
* vmops.host_details table, there is a field mount.parent. This
|
||||||
|
* is the value of that field If you have better ideas on how to
|
||||||
|
* get it, you are welcome.
|
||||||
*/
|
*/
|
||||||
public SnapshotCommand(String primaryStoragePoolNameLabel,
|
public SnapshotCommand(String primaryStoragePoolNameLabel,
|
||||||
String secondaryStorageUrl,
|
String secondaryStorageUrl, String snapshotUuid,
|
||||||
String snapshotUuid,
|
String snapshotName, Long dcId, Long accountId, Long volumeId) {
|
||||||
String snapshotName,
|
|
||||||
Long dcId,
|
|
||||||
Long accountId,
|
|
||||||
Long volumeId)
|
|
||||||
{
|
|
||||||
this.primaryStoragePoolNameLabel = primaryStoragePoolNameLabel;
|
this.primaryStoragePoolNameLabel = primaryStoragePoolNameLabel;
|
||||||
this.snapshotUuid = snapshotUuid;
|
this.snapshotUuid = snapshotUuid;
|
||||||
this.secondaryStorageUrl = secondaryStorageUrl;
|
this.secondaryStorageUrl = secondaryStorageUrl;
|
||||||
@ -70,11 +71,11 @@ public class SnapshotCommand extends Command {
|
|||||||
public String getSnapshotUuid() {
|
public String getSnapshotUuid() {
|
||||||
return snapshotUuid;
|
return snapshotUuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSnapshotName() {
|
public String getSnapshotName() {
|
||||||
return snapshotName;
|
return snapshotName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the secondaryStoragePoolURL
|
* @return the secondaryStoragePoolURL
|
||||||
*/
|
*/
|
||||||
@ -82,7 +83,6 @@ public class SnapshotCommand extends Command {
|
|||||||
return secondaryStorageUrl;
|
return secondaryStorageUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Long getDataCenterId() {
|
public Long getDataCenterId() {
|
||||||
return dcId;
|
return dcId;
|
||||||
}
|
}
|
||||||
@ -94,13 +94,13 @@ public class SnapshotCommand extends Command {
|
|||||||
public Long getVolumeId() {
|
public Long getVolumeId() {
|
||||||
return volumeId;
|
return volumeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVolumePath() {
|
public String getVolumePath() {
|
||||||
return volumePath;
|
return volumePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVolumePath(String path) {
|
public void setVolumePath(String path) {
|
||||||
volumePath = path;
|
volumePath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -16,17 +16,20 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class AgentControlAnswerTest {
|
import com.cloud.agent.api.AgentControlAnswer;
|
||||||
AgentControlCommand acc = new AgentControlCommand();
|
import com.cloud.agent.api.AgentControlCommand;
|
||||||
AgentControlAnswer aca = new AgentControlAnswer(acc);
|
|
||||||
|
|
||||||
@Test
|
public class AgentControlAnswerTest {
|
||||||
public void testExecuteInSequence() {
|
AgentControlCommand acc = new AgentControlCommand();
|
||||||
boolean b = acc.executeInSequence();
|
AgentControlAnswer aca = new AgentControlAnswer(acc);
|
||||||
assertFalse(b);
|
|
||||||
}
|
@Test
|
||||||
|
public void testExecuteInSequence() {
|
||||||
|
boolean b = acc.executeInSequence();
|
||||||
|
assertFalse(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,16 +16,18 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class AgentControlCommandTest {
|
import com.cloud.agent.api.AgentControlCommand;
|
||||||
AgentControlCommand acc = new AgentControlCommand();
|
|
||||||
|
|
||||||
@Test
|
public class AgentControlCommandTest {
|
||||||
public void testExecuteInSequence() {
|
AgentControlCommand acc = new AgentControlCommand();
|
||||||
boolean b = acc.executeInSequence();
|
|
||||||
assertFalse(b);
|
@Test
|
||||||
}
|
public void testExecuteInSequence() {
|
||||||
|
boolean b = acc.executeInSequence();
|
||||||
|
assertFalse(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,52 +16,58 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.cloud.agent.api.AgentControlCommand;
|
||||||
|
import com.cloud.agent.api.Answer;
|
||||||
|
import com.cloud.agent.api.UnsupportedAnswer;
|
||||||
|
|
||||||
public class AnswerTest {
|
public class AnswerTest {
|
||||||
AgentControlCommand acc = new AgentControlCommand();
|
AgentControlCommand acc = new AgentControlCommand();
|
||||||
Answer a = new Answer(acc, true, "details");
|
Answer a = new Answer(acc, true, "details");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteInSequence() {
|
public void testExecuteInSequence() {
|
||||||
boolean b = a.executeInSequence();
|
boolean b = a.executeInSequence();
|
||||||
assertFalse(b);
|
assertFalse(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetResult() {
|
public void testGetResult() {
|
||||||
boolean b = a.getResult();
|
boolean b = a.getResult();
|
||||||
assertTrue(b);
|
assertTrue(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDetails() {
|
public void testGetDetails() {
|
||||||
String d = a.getDetails();
|
String d = a.getDetails();
|
||||||
assertTrue(d.equals("details"));
|
assertTrue(d.equals("details"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateUnsupportedCommandAnswer() {
|
public void testCreateUnsupportedCommandAnswer() {
|
||||||
UnsupportedAnswer usa = Answer.createUnsupportedCommandAnswer(acc);
|
UnsupportedAnswer usa = Answer.createUnsupportedCommandAnswer(acc);
|
||||||
boolean b = usa.executeInSequence();
|
boolean b = usa.executeInSequence();
|
||||||
assertFalse(b);
|
assertFalse(b);
|
||||||
|
|
||||||
b = usa.getResult();
|
|
||||||
assertFalse(b);
|
|
||||||
|
|
||||||
String d = usa.getDetails();
|
b = usa.getResult();
|
||||||
assertTrue(d.equals("Unsupported command issued:" + acc.toString() + ". Are you sure you got the right type of server?"));
|
assertFalse(b);
|
||||||
|
|
||||||
usa = Answer.createUnsupportedVersionAnswer(acc);
|
String d = usa.getDetails();
|
||||||
b = usa.executeInSequence();
|
assertTrue(d.equals("Unsupported command issued:" + acc.toString()
|
||||||
assertFalse(b);
|
+ ". Are you sure you got the right type of server?"));
|
||||||
|
|
||||||
b = usa.getResult();
|
|
||||||
assertFalse(b);
|
|
||||||
|
|
||||||
d = usa.getDetails();
|
usa = Answer.createUnsupportedVersionAnswer(acc);
|
||||||
assertTrue(d.equals("Unsuppored Version."));
|
b = usa.executeInSequence();
|
||||||
}
|
assertFalse(b);
|
||||||
|
|
||||||
|
b = usa.getResult();
|
||||||
|
assertFalse(b);
|
||||||
|
|
||||||
|
d = usa.getDetails();
|
||||||
|
assertTrue(d.equals("Unsuppored Version."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,62 +16,65 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import com.cloud.agent.api.AttachIsoCommand;
|
||||||
|
|
||||||
public class AttachIsoCommandTest {
|
public class AttachIsoCommandTest {
|
||||||
AttachIsoCommand aic = new AttachIsoCommand("vmname", "isopath", false);
|
AttachIsoCommand aic = new AttachIsoCommand("vmname", "isopath", false);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetVmName() {
|
public void testGetVmName() {
|
||||||
String vmName = aic.getVmName();
|
String vmName = aic.getVmName();
|
||||||
assertTrue(vmName.equals("vmname"));
|
assertTrue(vmName.equals("vmname"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetIsoPath() {
|
public void testGetIsoPath() {
|
||||||
String isoPath = aic.getIsoPath();
|
String isoPath = aic.getIsoPath();
|
||||||
assertTrue(isoPath.equals("isopath"));
|
assertTrue(isoPath.equals("isopath"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testIsAttach() {
|
|
||||||
boolean b = aic.isAttach();
|
|
||||||
assertFalse(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetStoreUrl() {
|
public void testIsAttach() {
|
||||||
aic.setStoreUrl("http://incubator.apache.org/cloudstack/");
|
boolean b = aic.isAttach();
|
||||||
String url = aic.getStoreUrl();
|
assertFalse(b);
|
||||||
assertTrue(url.equals("http://incubator.apache.org/cloudstack/"));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetStoreUrl() {
|
||||||
public void testExecuteInSequence() {
|
aic.setStoreUrl("http://incubator.apache.org/cloudstack/");
|
||||||
boolean b = aic.executeInSequence();
|
String url = aic.getStoreUrl();
|
||||||
assertTrue(b);
|
assertTrue(url.equals("http://incubator.apache.org/cloudstack/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAllowCaching() {
|
public void testExecuteInSequence() {
|
||||||
boolean b = aic.allowCaching();
|
boolean b = aic.executeInSequence();
|
||||||
assertTrue(b);
|
assertTrue(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetWait() {
|
public void testAllowCaching() {
|
||||||
int b;
|
boolean b = aic.allowCaching();
|
||||||
aic.setWait(5);
|
assertTrue(b);
|
||||||
b = aic.getWait();
|
}
|
||||||
assertEquals(b, 5);
|
|
||||||
aic.setWait(-3);
|
@Test
|
||||||
b = aic.getWait();
|
public void testGetWait() {
|
||||||
assertEquals(b, -3);
|
int b;
|
||||||
aic.setWait(0);
|
aic.setWait(5);
|
||||||
b = aic.getWait();
|
b = aic.getWait();
|
||||||
assertEquals(b, 0);
|
assertEquals(b, 5);
|
||||||
}
|
aic.setWait(-3);
|
||||||
|
b = aic.getWait();
|
||||||
|
assertEquals(b, -3);
|
||||||
|
aic.setWait(0);
|
||||||
|
b = aic.getWait();
|
||||||
|
assertEquals(b, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,44 +16,50 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
import com.cloud.storage.Storage.StoragePoolType;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.cloud.agent.api.AttachVolumeAnswer;
|
||||||
|
import com.cloud.agent.api.AttachVolumeCommand;
|
||||||
|
import com.cloud.storage.Storage.StoragePoolType;
|
||||||
|
|
||||||
public class AttachVolumeAnswerTest {
|
public class AttachVolumeAnswerTest {
|
||||||
AttachVolumeCommand avc = new AttachVolumeCommand(true, "vmname", StoragePoolType.Filesystem, "vFolder", "vPath", "vName", 123456789L, "chainInfo");
|
AttachVolumeCommand avc = new AttachVolumeCommand(true, "vmname",
|
||||||
AttachVolumeAnswer ava1 = new AttachVolumeAnswer(avc);
|
StoragePoolType.Filesystem, "vFolder", "vPath", "vName",
|
||||||
String results = "";
|
123456789L, "chainInfo");
|
||||||
AttachVolumeAnswer ava2 = new AttachVolumeAnswer(avc, results);
|
AttachVolumeAnswer ava1 = new AttachVolumeAnswer(avc);
|
||||||
Long deviceId = 10L;
|
String results = "";
|
||||||
AttachVolumeAnswer ava3 = new AttachVolumeAnswer(avc, deviceId);
|
AttachVolumeAnswer ava2 = new AttachVolumeAnswer(avc, results);
|
||||||
|
Long deviceId = 10L;
|
||||||
|
AttachVolumeAnswer ava3 = new AttachVolumeAnswer(avc, deviceId);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDeviceId() {
|
public void testGetDeviceId() {
|
||||||
Long dId = ava1.getDeviceId();
|
Long dId = ava1.getDeviceId();
|
||||||
assertTrue(dId == null);
|
assertTrue(dId == null);
|
||||||
|
|
||||||
dId = ava2.getDeviceId();
|
dId = ava2.getDeviceId();
|
||||||
assertTrue(dId == null);
|
assertTrue(dId == null);
|
||||||
|
|
||||||
dId = ava3.getDeviceId();
|
dId = ava3.getDeviceId();
|
||||||
Long expected = 10L;
|
Long expected = 10L;
|
||||||
assertEquals(expected, dId);
|
assertEquals(expected, dId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetChainInfo() {
|
public void testGetChainInfo() {
|
||||||
ava1.setChainInfo("chainInfo");
|
ava1.setChainInfo("chainInfo");
|
||||||
String chainInfo = ava1.getChainInfo();
|
String chainInfo = ava1.getChainInfo();
|
||||||
assertTrue(chainInfo.equals("chainInfo"));
|
assertTrue(chainInfo.equals("chainInfo"));
|
||||||
|
|
||||||
ava2.setChainInfo("chainInfo");
|
ava2.setChainInfo("chainInfo");
|
||||||
chainInfo = ava2.getChainInfo();
|
chainInfo = ava2.getChainInfo();
|
||||||
assertTrue(chainInfo.equals("chainInfo"));
|
assertTrue(chainInfo.equals("chainInfo"));
|
||||||
|
|
||||||
ava3.setChainInfo("chainInfo");
|
ava3.setChainInfo("chainInfo");
|
||||||
chainInfo = ava3.getChainInfo();
|
chainInfo = ava3.getChainInfo();
|
||||||
assertTrue(chainInfo.equals("chainInfo"));
|
assertTrue(chainInfo.equals("chainInfo"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,101 +16,105 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.storage.Storage.StoragePoolType;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import com.cloud.agent.api.AttachVolumeCommand;
|
||||||
|
import com.cloud.storage.Storage.StoragePoolType;
|
||||||
|
|
||||||
public class AttachVolumeCommandTest {
|
public class AttachVolumeCommandTest {
|
||||||
AttachVolumeCommand avc = new AttachVolumeCommand(true, "vmname", StoragePoolType.Filesystem, "vFolder", "vPath", "vName", 123456789L, "chainInfo");
|
AttachVolumeCommand avc = new AttachVolumeCommand(true, "vmname",
|
||||||
|
StoragePoolType.Filesystem, "vFolder", "vPath", "vName",
|
||||||
|
123456789L, "chainInfo");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteInSequence() {
|
public void testExecuteInSequence() {
|
||||||
boolean b = avc.executeInSequence();
|
boolean b = avc.executeInSequence();
|
||||||
assertTrue(b);
|
assertTrue(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetAttach() {
|
|
||||||
boolean b = avc.getAttach();
|
|
||||||
assertTrue(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetVmName() {
|
|
||||||
String vmName = avc.getVmName();
|
|
||||||
assertTrue(vmName.equals("vmname"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPooltype() {
|
public void testGetAttach() {
|
||||||
StoragePoolType pt = avc.getPooltype();
|
boolean b = avc.getAttach();
|
||||||
assertTrue(pt.equals(StoragePoolType.Filesystem));
|
assertTrue(b);
|
||||||
|
}
|
||||||
avc.setPooltype(StoragePoolType.NetworkFilesystem);
|
|
||||||
pt = avc.getPooltype();
|
|
||||||
assertTrue(pt.equals(StoragePoolType.NetworkFilesystem));
|
|
||||||
|
|
||||||
avc.setPooltype(StoragePoolType.IscsiLUN);
|
|
||||||
pt = avc.getPooltype();
|
|
||||||
assertTrue(pt.equals(StoragePoolType.IscsiLUN));
|
|
||||||
|
|
||||||
avc.setPooltype(StoragePoolType.Iscsi);
|
|
||||||
pt = avc.getPooltype();
|
|
||||||
assertTrue(pt.equals(StoragePoolType.Iscsi));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetVolumeFolder() {
|
public void testGetVmName() {
|
||||||
String vFolder = avc.getVolumeFolder();
|
String vmName = avc.getVmName();
|
||||||
assertTrue(vFolder.equals("vFolder"));
|
assertTrue(vmName.equals("vmname"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetVolumePath() {
|
|
||||||
String vPath = avc.getVolumePath();
|
|
||||||
assertTrue(vPath.equals("vPath"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetVolumeName() {
|
public void testGetPooltype() {
|
||||||
String vName = avc.getVolumeName();
|
StoragePoolType pt = avc.getPooltype();
|
||||||
assertTrue(vName.equals("vName"));
|
assertTrue(pt.equals(StoragePoolType.Filesystem));
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
avc.setPooltype(StoragePoolType.NetworkFilesystem);
|
||||||
public void testGetDeviceId() {
|
pt = avc.getPooltype();
|
||||||
Long dId = avc.getDeviceId();
|
assertTrue(pt.equals(StoragePoolType.NetworkFilesystem));
|
||||||
Long expected = 123456789L;
|
|
||||||
assertEquals(expected, dId);
|
avc.setPooltype(StoragePoolType.IscsiLUN);
|
||||||
|
pt = avc.getPooltype();
|
||||||
avc.setDeviceId(5L);
|
assertTrue(pt.equals(StoragePoolType.IscsiLUN));
|
||||||
dId = avc.getDeviceId();
|
|
||||||
expected = 5L;
|
avc.setPooltype(StoragePoolType.Iscsi);
|
||||||
assertEquals(expected, dId);
|
pt = avc.getPooltype();
|
||||||
|
assertTrue(pt.equals(StoragePoolType.Iscsi));
|
||||||
avc.setDeviceId(0L);
|
}
|
||||||
dId = avc.getDeviceId();
|
|
||||||
expected = 0L;
|
@Test
|
||||||
assertEquals(expected, dId);
|
public void testGetVolumeFolder() {
|
||||||
|
String vFolder = avc.getVolumeFolder();
|
||||||
avc.setDeviceId(-5L);
|
assertTrue(vFolder.equals("vFolder"));
|
||||||
dId = avc.getDeviceId();
|
}
|
||||||
expected = -5L;
|
|
||||||
assertEquals(expected, dId);
|
@Test
|
||||||
}
|
public void testGetVolumePath() {
|
||||||
|
String vPath = avc.getVolumePath();
|
||||||
@Test
|
assertTrue(vPath.equals("vPath"));
|
||||||
public void testGetPoolUuid() {
|
}
|
||||||
avc.setPoolUuid("420fa39c-4ef1-a83c-fd93-46dc1ff515ae");
|
|
||||||
String pUuid = avc.getPoolUuid();
|
@Test
|
||||||
assertTrue(pUuid.equals("420fa39c-4ef1-a83c-fd93-46dc1ff515ae"));
|
public void testGetVolumeName() {
|
||||||
}
|
String vName = avc.getVolumeName();
|
||||||
|
assertTrue(vName.equals("vName"));
|
||||||
@Test
|
}
|
||||||
public void testGetWait() {
|
|
||||||
String cInfo = avc.getChainInfo();
|
@Test
|
||||||
assertTrue(cInfo.equals("chainInfo"));
|
public void testGetDeviceId() {
|
||||||
}
|
Long dId = avc.getDeviceId();
|
||||||
|
Long expected = 123456789L;
|
||||||
|
assertEquals(expected, dId);
|
||||||
|
|
||||||
|
avc.setDeviceId(5L);
|
||||||
|
dId = avc.getDeviceId();
|
||||||
|
expected = 5L;
|
||||||
|
assertEquals(expected, dId);
|
||||||
|
|
||||||
|
avc.setDeviceId(0L);
|
||||||
|
dId = avc.getDeviceId();
|
||||||
|
expected = 0L;
|
||||||
|
assertEquals(expected, dId);
|
||||||
|
|
||||||
|
avc.setDeviceId(-5L);
|
||||||
|
dId = avc.getDeviceId();
|
||||||
|
expected = -5L;
|
||||||
|
assertEquals(expected, dId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPoolUuid() {
|
||||||
|
avc.setPoolUuid("420fa39c-4ef1-a83c-fd93-46dc1ff515ae");
|
||||||
|
String pUuid = avc.getPoolUuid();
|
||||||
|
assertTrue(pUuid.equals("420fa39c-4ef1-a83c-fd93-46dc1ff515ae"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetWait() {
|
||||||
|
String cInfo = avc.getChainInfo();
|
||||||
|
assertTrue(cInfo.equals("chainInfo"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,41 +16,60 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import com.cloud.agent.api.BackupSnapshotAnswer;
|
||||||
|
import com.cloud.agent.api.BackupSnapshotCommand;
|
||||||
|
import com.cloud.storage.StoragePool;
|
||||||
|
|
||||||
public class BackupSnapshotAnswerTest {
|
public class BackupSnapshotAnswerTest {
|
||||||
BackupSnapshotCommand bsc = new BackupSnapshotCommand();
|
private BackupSnapshotCommand bsc;
|
||||||
BackupSnapshotAnswer bsa = new BackupSnapshotAnswer(bsc, true, "results", "bussname", false);
|
private BackupSnapshotAnswer bsa;
|
||||||
|
|
||||||
@Test
|
@Before
|
||||||
public void testExecuteInSequence() {
|
public void setUp() {
|
||||||
boolean b = bsa.executeInSequence();
|
|
||||||
assertFalse(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
StoragePool pool = Mockito.mock(StoragePool.class);
|
||||||
public void testIsFull() {
|
|
||||||
boolean b = bsa.isFull();
|
|
||||||
assertFalse(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
bsc = new BackupSnapshotCommand("primaryStoragePoolNameLabel",
|
||||||
public void testGetBackupSnapshotName() {
|
"secondaryStoragePoolURL", 101L, 102L, 103L, 104L,
|
||||||
String name = bsa.getBackupSnapshotName();
|
"volumePath", pool, "snapshotUuid", "snapshotName",
|
||||||
assertTrue(name.equals("bussname"));
|
"prevSnapshotUuid", "prevBackupUuid", false, "vmName", 5);
|
||||||
}
|
bsa = new BackupSnapshotAnswer(bsc, true, "results", "bussname", false);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testGetResult() {
|
|
||||||
boolean b = bsa.getResult();
|
|
||||||
assertTrue(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDetails() {
|
public void testExecuteInSequence() {
|
||||||
String details = bsa.getDetails();
|
boolean b = bsa.executeInSequence();
|
||||||
assertTrue(details.equals("results"));
|
assertFalse(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsFull() {
|
||||||
|
boolean b = bsa.isFull();
|
||||||
|
assertFalse(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetBackupSnapshotName() {
|
||||||
|
String name = bsa.getBackupSnapshotName();
|
||||||
|
assertTrue(name.equals("bussname"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetResult() {
|
||||||
|
boolean b = bsa.getResult();
|
||||||
|
assertTrue(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDetails() {
|
||||||
|
String details = bsa.getDetails();
|
||||||
|
assertTrue(details.equals("results"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,205 +16,256 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.cloud.agent.api.BackupSnapshotCommand;
|
||||||
import com.cloud.agent.api.to.StorageFilerTO;
|
import com.cloud.agent.api.to.StorageFilerTO;
|
||||||
import com.cloud.agent.api.to.SwiftTO;
|
import com.cloud.agent.api.to.SwiftTO;
|
||||||
import com.cloud.storage.StoragePool;
|
|
||||||
import com.cloud.storage.Storage.StoragePoolType;
|
import com.cloud.storage.Storage.StoragePoolType;
|
||||||
|
import com.cloud.storage.StoragePool;
|
||||||
import com.cloud.storage.StoragePoolStatus;
|
import com.cloud.storage.StoragePoolStatus;
|
||||||
import java.util.Date;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.text.ParseException;
|
|
||||||
|
|
||||||
public class BackupSnapshotCommandTest {
|
public class BackupSnapshotCommandTest {
|
||||||
public StoragePool pool = new StoragePool() {
|
public StoragePool pool = new StoragePool() {
|
||||||
public long getId() {return 1L;};
|
public long getId() {
|
||||||
public String getName() {return "name";};
|
return 1L;
|
||||||
public String getUuid() {return "bed9f83e-cac3-11e1-ac8a-0050568b007e";};
|
};
|
||||||
public StoragePoolType getPoolType() {return StoragePoolType.Filesystem;};
|
|
||||||
public Date getCreated() {
|
|
||||||
Date date = null;
|
|
||||||
try{
|
|
||||||
date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("01/01/1970 12:12:12");
|
|
||||||
}
|
|
||||||
catch (ParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
public Date getUpdateTime() {return new Date();};
|
|
||||||
public long getDataCenterId() {return 0L;};
|
|
||||||
public long getCapacityBytes() {return 0L;};
|
|
||||||
public long getAvailableBytes() {return 0L;};
|
|
||||||
public Long getClusterId() {return 0L;};
|
|
||||||
public String getHostAddress() {return "hostAddress";};
|
|
||||||
public String getPath() {return "path";};
|
|
||||||
public String getUserInfo() {return "userInfo";};
|
|
||||||
public boolean isShared() {return false;};
|
|
||||||
public boolean isLocal() {return false;};
|
|
||||||
public StoragePoolStatus getStatus() {return StoragePoolStatus.Up;};
|
|
||||||
public int getPort() {return 25;};
|
|
||||||
public Long getPodId() {return 0L;};
|
|
||||||
};
|
|
||||||
|
|
||||||
BackupSnapshotCommand bsc = new BackupSnapshotCommand(
|
|
||||||
"primaryStoragePoolNameLabel",
|
|
||||||
"http://secondary.Storage.Url",
|
|
||||||
101L,
|
|
||||||
102L,
|
|
||||||
103L,
|
|
||||||
104L,
|
|
||||||
"vPath",
|
|
||||||
pool,
|
|
||||||
"420fa39c-4ef1-a83c-fd93-46dc1ff515ae",
|
|
||||||
"sName",
|
|
||||||
"9012793e-0657-11e2-bebc-0050568b0057",
|
|
||||||
"7167e0b2-f5b0-11e1-8414-0050568b0057",
|
|
||||||
false,
|
|
||||||
"vmName",
|
|
||||||
5
|
|
||||||
);
|
|
||||||
|
|
||||||
BackupSnapshotCommand bsc1 = new BackupSnapshotCommand();
|
|
||||||
|
|
||||||
@Test
|
public String getName() {
|
||||||
public void testGetPrimaryStoragePoolNameLabel() {
|
return "name";
|
||||||
String label = bsc.getPrimaryStoragePoolNameLabel();
|
};
|
||||||
assertTrue(label.equals("primaryStoragePoolNameLabel"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
public String getUuid() {
|
||||||
public void testGetSecondaryStorageUrl() {
|
return "bed9f83e-cac3-11e1-ac8a-0050568b007e";
|
||||||
String url = bsc.getSecondaryStorageUrl();
|
};
|
||||||
assertTrue(url.equals("http://secondary.Storage.Url"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
public StoragePoolType getPoolType() {
|
||||||
public void testGetDataCenterId() {
|
return StoragePoolType.Filesystem;
|
||||||
Long dcId = bsc.getDataCenterId();
|
};
|
||||||
Long expected = 101L;
|
|
||||||
assertEquals(expected, dcId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
public Date getCreated() {
|
||||||
public void testGetAccountId() {
|
Date date = null;
|
||||||
Long aId = bsc.getAccountId();
|
try {
|
||||||
Long expected = 102L;
|
date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
|
||||||
assertEquals(expected, aId);
|
.parse("01/01/1970 12:12:12");
|
||||||
}
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
public Date getUpdateTime() {
|
||||||
public void testGetVolumeId() {
|
return new Date();
|
||||||
Long vId = bsc.getVolumeId();
|
};
|
||||||
Long expected = 103L;
|
|
||||||
assertEquals(expected, vId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
public long getDataCenterId() {
|
||||||
public void testGetSnapshotId() {
|
return 0L;
|
||||||
Long ssId = bsc.getSnapshotId();
|
};
|
||||||
Long expected = 104L;
|
|
||||||
assertEquals(expected, ssId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
public long getCapacityBytes() {
|
||||||
public void testGetPool() {
|
return 0L;
|
||||||
StorageFilerTO pool = bsc.getPool();
|
};
|
||||||
|
|
||||||
Long id = pool.getId();
|
|
||||||
Long expectedL = 1L;
|
|
||||||
assertEquals(expectedL, id);
|
|
||||||
|
|
||||||
String uuid = pool.getUuid();
|
|
||||||
assertTrue(uuid.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e"));
|
|
||||||
|
|
||||||
String host = pool.getHost();
|
|
||||||
assertTrue(host.equals("hostAddress"));
|
|
||||||
|
|
||||||
String path = pool.getPath();
|
|
||||||
assertTrue(path.equals("path"));
|
|
||||||
|
|
||||||
String userInfo = pool.getUserInfo();
|
|
||||||
assertTrue(userInfo.equals("userInfo"));
|
|
||||||
|
|
||||||
Integer port = pool.getPort();
|
|
||||||
Integer expectedI = 25;
|
|
||||||
assertEquals(expectedI, port);
|
|
||||||
|
|
||||||
StoragePoolType type = pool.getType();
|
|
||||||
assertEquals(StoragePoolType.Filesystem, type);
|
|
||||||
|
|
||||||
String str = pool.toString();
|
|
||||||
assertTrue(str.equals("Pool[" + id.toString() + "|" + host + ":" + port.toString() + "|" + path + "]"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
public long getAvailableBytes() {
|
||||||
public void testGetCreated() {
|
return 0L;
|
||||||
try{
|
};
|
||||||
Date date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("01/01/1970 12:12:12");
|
|
||||||
Date d = pool.getCreated();
|
|
||||||
assertTrue(d.compareTo(date) == 0);
|
|
||||||
}
|
|
||||||
catch (ParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetSwift() {
|
|
||||||
SwiftTO s1 = new SwiftTO();
|
|
||||||
bsc.setSwift(s1);
|
|
||||||
SwiftTO s2 = bsc.getSwift();
|
|
||||||
assertEquals(s1, s2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
public Long getClusterId() {
|
||||||
public void testGetSnapshotName() {
|
return 0L;
|
||||||
String ssName = bsc.getSnapshotName();
|
};
|
||||||
assertTrue(ssName.equals("sName"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
public String getHostAddress() {
|
||||||
public void testGetSnapshotUuid() {
|
return "hostAddress";
|
||||||
String uuid = bsc.getSnapshotUuid();
|
};
|
||||||
assertTrue(uuid.equals("420fa39c-4ef1-a83c-fd93-46dc1ff515ae"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
public String getPath() {
|
||||||
public void testGetPrevSnapshotUuid() {
|
return "path";
|
||||||
String uuid = bsc.getPrevSnapshotUuid();
|
};
|
||||||
assertTrue(uuid.equals("9012793e-0657-11e2-bebc-0050568b0057"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
public String getUserInfo() {
|
||||||
public void testGetPrevBackupUuid() {
|
return "userInfo";
|
||||||
String uuid = bsc.getPrevBackupUuid();
|
};
|
||||||
assertTrue(uuid.equals("7167e0b2-f5b0-11e1-8414-0050568b0057"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
public boolean isShared() {
|
||||||
public void testGetVolumePath() {
|
return false;
|
||||||
String path = bsc.getVolumePath();
|
};
|
||||||
assertTrue(path.equals("vPath"));
|
|
||||||
|
|
||||||
bsc.setVolumePath("vPath1");
|
|
||||||
path = bsc.getVolumePath();
|
|
||||||
assertTrue(path.equals("vPath1"));
|
|
||||||
|
|
||||||
bsc1.setVolumePath("vPath2");
|
|
||||||
path = bsc1.getVolumePath();
|
|
||||||
assertTrue(path.equals("vPath2"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
public boolean isLocal() {
|
||||||
public void testExecuteInSequence() {
|
return false;
|
||||||
boolean b = bsc.executeInSequence();
|
};
|
||||||
assertFalse(b);
|
|
||||||
|
|
||||||
b = bsc1.executeInSequence();
|
public StoragePoolStatus getStatus() {
|
||||||
assertFalse(b);
|
return StoragePoolStatus.Up;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
public int getPort() {
|
||||||
|
return 25;
|
||||||
|
};
|
||||||
|
|
||||||
|
public Long getPodId() {
|
||||||
|
return 0L;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
BackupSnapshotCommand bsc = new BackupSnapshotCommand(
|
||||||
|
"primaryStoragePoolNameLabel", "http://secondary.Storage.Url",
|
||||||
|
101L, 102L, 103L, 104L, "vPath", pool,
|
||||||
|
"420fa39c-4ef1-a83c-fd93-46dc1ff515ae", "sName",
|
||||||
|
"9012793e-0657-11e2-bebc-0050568b0057",
|
||||||
|
"7167e0b2-f5b0-11e1-8414-0050568b0057", false, "vmName", 5);
|
||||||
|
|
||||||
|
BackupSnapshotCommand bsc1 = new BackupSnapshotCommand(
|
||||||
|
"primaryStoragePoolNameLabel", "http://secondary.Storage.Url",
|
||||||
|
101L, 102L, 103L, 104L, "vPath", pool,
|
||||||
|
"420fa39c-4ef1-a83c-fd93-46dc1ff515ae", "sName",
|
||||||
|
"9012793e-0657-11e2-bebc-0050568b0057",
|
||||||
|
"7167e0b2-f5b0-11e1-8414-0050568b0057", false, "vmName", 5);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPrimaryStoragePoolNameLabel() {
|
||||||
|
String label = bsc.getPrimaryStoragePoolNameLabel();
|
||||||
|
assertTrue(label.equals("primaryStoragePoolNameLabel"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSecondaryStorageUrl() {
|
||||||
|
String url = bsc.getSecondaryStorageUrl();
|
||||||
|
assertTrue(url.equals("http://secondary.Storage.Url"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetDataCenterId() {
|
||||||
|
Long dcId = bsc.getDataCenterId();
|
||||||
|
Long expected = 101L;
|
||||||
|
assertEquals(expected, dcId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAccountId() {
|
||||||
|
Long aId = bsc.getAccountId();
|
||||||
|
Long expected = 102L;
|
||||||
|
assertEquals(expected, aId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetVolumeId() {
|
||||||
|
Long vId = bsc.getVolumeId();
|
||||||
|
Long expected = 103L;
|
||||||
|
assertEquals(expected, vId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSnapshotId() {
|
||||||
|
Long ssId = bsc.getSnapshotId();
|
||||||
|
Long expected = 104L;
|
||||||
|
assertEquals(expected, ssId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPool() {
|
||||||
|
StorageFilerTO pool = bsc.getPool();
|
||||||
|
|
||||||
|
Long id = pool.getId();
|
||||||
|
Long expectedL = 1L;
|
||||||
|
assertEquals(expectedL, id);
|
||||||
|
|
||||||
|
String uuid = pool.getUuid();
|
||||||
|
assertTrue(uuid.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e"));
|
||||||
|
|
||||||
|
String host = pool.getHost();
|
||||||
|
assertTrue(host.equals("hostAddress"));
|
||||||
|
|
||||||
|
String path = pool.getPath();
|
||||||
|
assertTrue(path.equals("path"));
|
||||||
|
|
||||||
|
String userInfo = pool.getUserInfo();
|
||||||
|
assertTrue(userInfo.equals("userInfo"));
|
||||||
|
|
||||||
|
Integer port = pool.getPort();
|
||||||
|
Integer expectedI = 25;
|
||||||
|
assertEquals(expectedI, port);
|
||||||
|
|
||||||
|
StoragePoolType type = pool.getType();
|
||||||
|
assertEquals(StoragePoolType.Filesystem, type);
|
||||||
|
|
||||||
|
String str = pool.toString();
|
||||||
|
assertTrue(str.equals("Pool[" + id.toString() + "|" + host + ":"
|
||||||
|
+ port.toString() + "|" + path + "]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetCreated() {
|
||||||
|
try {
|
||||||
|
Date date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
|
||||||
|
.parse("01/01/1970 12:12:12");
|
||||||
|
Date d = pool.getCreated();
|
||||||
|
assertTrue(d.compareTo(date) == 0);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSwift() {
|
||||||
|
SwiftTO s1 = new SwiftTO();
|
||||||
|
bsc.setSwift(s1);
|
||||||
|
SwiftTO s2 = bsc.getSwift();
|
||||||
|
assertEquals(s1, s2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSnapshotName() {
|
||||||
|
String ssName = bsc.getSnapshotName();
|
||||||
|
assertTrue(ssName.equals("sName"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSnapshotUuid() {
|
||||||
|
String uuid = bsc.getSnapshotUuid();
|
||||||
|
assertTrue(uuid.equals("420fa39c-4ef1-a83c-fd93-46dc1ff515ae"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPrevSnapshotUuid() {
|
||||||
|
String uuid = bsc.getPrevSnapshotUuid();
|
||||||
|
assertTrue(uuid.equals("9012793e-0657-11e2-bebc-0050568b0057"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPrevBackupUuid() {
|
||||||
|
String uuid = bsc.getPrevBackupUuid();
|
||||||
|
assertTrue(uuid.equals("7167e0b2-f5b0-11e1-8414-0050568b0057"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetVolumePath() {
|
||||||
|
String path = bsc.getVolumePath();
|
||||||
|
assertTrue(path.equals("vPath"));
|
||||||
|
|
||||||
|
bsc.setVolumePath("vPath1");
|
||||||
|
path = bsc.getVolumePath();
|
||||||
|
assertTrue(path.equals("vPath1"));
|
||||||
|
|
||||||
|
bsc1.setVolumePath("vPath2");
|
||||||
|
path = bsc1.getVolumePath();
|
||||||
|
assertTrue(path.equals("vPath2"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExecuteInSequence() {
|
||||||
|
boolean b = bsc.executeInSequence();
|
||||||
|
assertFalse(b);
|
||||||
|
|
||||||
|
b = bsc1.executeInSequence();
|
||||||
|
assertFalse(b);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,58 +16,68 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
import com.cloud.agent.api.routing.*;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.cloud.agent.api.BumpUpPriorityCommand;
|
||||||
|
import com.cloud.agent.api.routing.NetworkElementCommand;
|
||||||
|
|
||||||
public class BumpUpPriorityCommandTest {
|
public class BumpUpPriorityCommandTest {
|
||||||
BumpUpPriorityCommand bupc = new BumpUpPriorityCommand();
|
|
||||||
|
BumpUpPriorityCommand bupc = new BumpUpPriorityCommand();
|
||||||
// test super class
|
|
||||||
@Test
|
// test super class
|
||||||
public void testSuperGetAccessDetail() {
|
@Test
|
||||||
String value;
|
public void testSuperGetAccessDetail() {
|
||||||
bupc.setAccessDetail(NetworkElementCommand.ACCOUNT_ID, "accountID");
|
String value;
|
||||||
value = bupc.getAccessDetail(NetworkElementCommand.ACCOUNT_ID);
|
bupc.setAccessDetail(NetworkElementCommand.ACCOUNT_ID, "accountID");
|
||||||
assertTrue(value.equals("accountID"));
|
value = bupc.getAccessDetail(NetworkElementCommand.ACCOUNT_ID);
|
||||||
|
assertTrue(value.equals("accountID"));
|
||||||
bupc.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR, "GuestNetworkCIDR");
|
|
||||||
value = bupc.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR);
|
bupc.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR,
|
||||||
assertTrue(value.equals("GuestNetworkCIDR"));
|
"GuestNetworkCIDR");
|
||||||
|
value = bupc.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR);
|
||||||
bupc.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY, "GuestNetworkGateway");
|
assertTrue(value.equals("GuestNetworkCIDR"));
|
||||||
value = bupc.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY);
|
|
||||||
assertTrue(value.equals("GuestNetworkGateway"));
|
bupc.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY,
|
||||||
|
"GuestNetworkGateway");
|
||||||
bupc.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, "GuestVlanTag");
|
value = bupc
|
||||||
value = bupc.getAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG);
|
.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY);
|
||||||
assertTrue(value.equals("GuestVlanTag"));
|
assertTrue(value.equals("GuestNetworkGateway"));
|
||||||
|
|
||||||
bupc.setAccessDetail(NetworkElementCommand.ROUTER_NAME, "RouterName");
|
bupc.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG,
|
||||||
value = bupc.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
|
"GuestVlanTag");
|
||||||
assertTrue(value.equals("RouterName"));
|
value = bupc.getAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG);
|
||||||
|
assertTrue(value.equals("GuestVlanTag"));
|
||||||
bupc.setAccessDetail(NetworkElementCommand.ROUTER_IP, "RouterIP");
|
|
||||||
value = bupc.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
bupc.setAccessDetail(NetworkElementCommand.ROUTER_NAME, "RouterName");
|
||||||
assertTrue(value.equals("RouterIP"));
|
value = bupc.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
|
||||||
|
assertTrue(value.equals("RouterName"));
|
||||||
bupc.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, "RouterGuestIP");
|
|
||||||
value = bupc.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP);
|
bupc.setAccessDetail(NetworkElementCommand.ROUTER_IP, "RouterIP");
|
||||||
assertTrue(value.equals("RouterGuestIP"));
|
value = bupc.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||||
|
assertTrue(value.equals("RouterIP"));
|
||||||
bupc.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, "ZoneNetworkType");
|
|
||||||
value = bupc.getAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE);
|
bupc.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP,
|
||||||
assertTrue(value.equals("ZoneNetworkType"));
|
"RouterGuestIP");
|
||||||
|
value = bupc.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP);
|
||||||
bupc.setAccessDetail(NetworkElementCommand.GUEST_BRIDGE, "GuestBridge");
|
assertTrue(value.equals("RouterGuestIP"));
|
||||||
value = bupc.getAccessDetail(NetworkElementCommand.GUEST_BRIDGE);
|
|
||||||
assertTrue(value.equals("GuestBridge"));
|
bupc.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE,
|
||||||
}
|
"ZoneNetworkType");
|
||||||
|
value = bupc.getAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE);
|
||||||
@Test
|
assertTrue(value.equals("ZoneNetworkType"));
|
||||||
public void testExecuteInSequence() {
|
|
||||||
boolean b = bupc.executeInSequence();
|
bupc.setAccessDetail(NetworkElementCommand.GUEST_BRIDGE, "GuestBridge");
|
||||||
assertFalse(b);
|
value = bupc.getAccessDetail(NetworkElementCommand.GUEST_BRIDGE);
|
||||||
}
|
assertTrue(value.equals("GuestBridge"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExecuteInSequence() {
|
||||||
|
boolean b = bupc.executeInSequence();
|
||||||
|
assertFalse(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,28 +16,31 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.cloud.agent.api.CancelCommand;
|
||||||
|
|
||||||
public class CancelCommandTest {
|
public class CancelCommandTest {
|
||||||
CancelCommand cc = new CancelCommand(123456789L, "goodreason");
|
CancelCommand cc = new CancelCommand(123456789L, "goodreason");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSequence() {
|
public void testGetSequence() {
|
||||||
Long s = cc.getSequence();
|
Long s = cc.getSequence();
|
||||||
assertTrue(123456789L == s);
|
assertTrue(123456789L == s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetReason() {
|
public void testGetReason() {
|
||||||
String r = cc.getReason();
|
String r = cc.getReason();
|
||||||
assertTrue(r.equals("goodreason"));
|
assertTrue(r.equals("goodreason"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteInSequence() {
|
public void testExecuteInSequence() {
|
||||||
boolean b = cc.executeInSequence();
|
boolean b = cc.executeInSequence();
|
||||||
assertFalse(b);
|
assertFalse(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,24 +16,29 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
import com.cloud.host.Status.Event;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ChangeAgentAnswerTest {
|
import com.cloud.agent.api.ChangeAgentAnswer;
|
||||||
ChangeAgentCommand cac = new ChangeAgentCommand(123456789L, Event.AgentConnected);
|
import com.cloud.agent.api.ChangeAgentCommand;
|
||||||
ChangeAgentAnswer caa = new ChangeAgentAnswer(cac, true);
|
import com.cloud.host.Status.Event;
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetResult() {
|
|
||||||
boolean b = caa.getResult();
|
|
||||||
assertTrue(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
public class ChangeAgentAnswerTest {
|
||||||
public void testExecuteInSequence() {
|
ChangeAgentCommand cac = new ChangeAgentCommand(123456789L,
|
||||||
boolean b = caa.executeInSequence();
|
Event.AgentConnected);
|
||||||
assertFalse(b);
|
ChangeAgentAnswer caa = new ChangeAgentAnswer(cac, true);
|
||||||
}
|
|
||||||
|
@Test
|
||||||
|
public void testGetResult() {
|
||||||
|
boolean b = caa.getResult();
|
||||||
|
assertTrue(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExecuteInSequence() {
|
||||||
|
boolean b = caa.executeInSequence();
|
||||||
|
assertFalse(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,29 +16,35 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
import com.cloud.host.Status.Event;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.cloud.agent.api.ChangeAgentCommand;
|
||||||
|
import com.cloud.host.Status.Event;
|
||||||
|
|
||||||
public class ChangeAgentCommandTest {
|
public class ChangeAgentCommandTest {
|
||||||
ChangeAgentCommand cac = new ChangeAgentCommand(123456789L, Event.AgentConnected);
|
|
||||||
|
ChangeAgentCommand cac = new ChangeAgentCommand(123456789L,
|
||||||
@Test
|
Event.AgentConnected);
|
||||||
public void testGetAgentId() {
|
|
||||||
Long aid = cac.getAgentId();
|
@Test
|
||||||
assertTrue(123456789L == aid);
|
public void testGetAgentId() {
|
||||||
}
|
Long aid = cac.getAgentId();
|
||||||
|
assertTrue(123456789L == aid);
|
||||||
@Test
|
}
|
||||||
public void testGetEvent() {
|
|
||||||
Event e = cac.getEvent();
|
@Test
|
||||||
assertEquals(Event.AgentConnected, e);
|
public void testGetEvent() {
|
||||||
}
|
Event e = cac.getEvent();
|
||||||
|
assertEquals(Event.AgentConnected, e);
|
||||||
@Test
|
}
|
||||||
public void testExecuteInSequence() {
|
|
||||||
boolean b = cac.executeInSequence();
|
@Test
|
||||||
assertFalse(b);
|
public void testExecuteInSequence() {
|
||||||
}
|
boolean b = cac.executeInSequence();
|
||||||
|
assertFalse(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,30 +16,34 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.cloud.agent.api.CheckHealthAnswer;
|
||||||
|
import com.cloud.agent.api.CheckHealthCommand;
|
||||||
|
|
||||||
public class CheckHealthAnswerTest {
|
public class CheckHealthAnswerTest {
|
||||||
CheckHealthCommand chc = new CheckHealthCommand();
|
CheckHealthCommand chc = new CheckHealthCommand();
|
||||||
CheckHealthAnswer cha = new CheckHealthAnswer(chc, true);
|
CheckHealthAnswer cha = new CheckHealthAnswer(chc, true);
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetResult() {
|
|
||||||
boolean r = cha.getResult();
|
|
||||||
assertTrue(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDetails() {
|
public void testGetResult() {
|
||||||
String d = cha.getDetails();
|
boolean r = cha.getResult();
|
||||||
boolean r = cha.getResult();
|
assertTrue(r);
|
||||||
assertTrue(d.equals("resource is " + (r? "alive" : "not alive")));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteInSequence() {
|
public void testGetDetails() {
|
||||||
boolean b = cha.executeInSequence();
|
String d = cha.getDetails();
|
||||||
assertFalse(b);
|
boolean r = cha.getResult();
|
||||||
}
|
assertTrue(d.equals("resource is " + (r ? "alive" : "not alive")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExecuteInSequence() {
|
||||||
|
boolean b = cha.executeInSequence();
|
||||||
|
assertFalse(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,22 +16,25 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.cloud.agent.api.CheckHealthCommand;
|
||||||
|
|
||||||
public class CheckHealthCommandTest {
|
public class CheckHealthCommandTest {
|
||||||
CheckHealthCommand chc = new CheckHealthCommand();
|
CheckHealthCommand chc = new CheckHealthCommand();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetWait() {
|
public void testGetWait() {
|
||||||
int wait = chc.getWait();
|
int wait = chc.getWait();
|
||||||
assertTrue(wait == 50);
|
assertTrue(wait == 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteInSequence() {
|
public void testExecuteInSequence() {
|
||||||
boolean b = chc.executeInSequence();
|
boolean b = chc.executeInSequence();
|
||||||
assertFalse(b);
|
assertFalse(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,36 +16,47 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
import com.cloud.host.Status.Event;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import com.cloud.agent.api.CheckNetworkAnswer;
|
||||||
|
import com.cloud.agent.api.CheckNetworkCommand;
|
||||||
|
|
||||||
public class CheckNetworkAnswerTest {
|
public class CheckNetworkAnswerTest {
|
||||||
CheckNetworkCommand cnc = new CheckNetworkCommand();
|
CheckNetworkCommand cnc;
|
||||||
CheckNetworkAnswer cna = new CheckNetworkAnswer(cnc, true, "details", true);
|
CheckNetworkAnswer cna;
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetResult() {
|
|
||||||
boolean b = cna.getResult();
|
|
||||||
assertTrue(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Before
|
||||||
public void testGetDetails() {
|
public void setUp() {
|
||||||
String d = cna.getDetails();
|
cnc = Mockito.mock(CheckNetworkCommand.class);
|
||||||
assertTrue(d.equals("details"));
|
cna = new CheckNetworkAnswer(cnc, true, "details", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNeedReconnect() {
|
public void testGetResult() {
|
||||||
boolean b = cna.needReconnect();
|
boolean b = cna.getResult();
|
||||||
assertTrue(b);
|
assertTrue(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteInSequence() {
|
public void testGetDetails() {
|
||||||
boolean b = cna.executeInSequence();
|
String d = cna.getDetails();
|
||||||
assertFalse(b);
|
assertTrue(d.equals("details"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNeedReconnect() {
|
||||||
|
boolean b = cna.needReconnect();
|
||||||
|
assertTrue(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExecuteInSequence() {
|
||||||
|
boolean b = cna.executeInSequence();
|
||||||
|
assertFalse(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,24 +16,38 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.cloud.agent.api.*;
|
|
||||||
import com.cloud.network.PhysicalNetworkSetupInfo;
|
import org.junit.Before;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import com.cloud.agent.api.CheckNetworkCommand;
|
||||||
|
import com.cloud.network.PhysicalNetworkSetupInfo;
|
||||||
|
|
||||||
public class CheckNetworkCommandTest {
|
public class CheckNetworkCommandTest {
|
||||||
CheckNetworkCommand cnc = new CheckNetworkCommand();
|
CheckNetworkCommand cnc;
|
||||||
|
|
||||||
@Test
|
@Before
|
||||||
public void testGetPhysicalNetworkInfoList() {
|
public void setUp() {
|
||||||
List<PhysicalNetworkSetupInfo> networkInfoList = cnc.getPhysicalNetworkInfoList();
|
@SuppressWarnings("unchecked")
|
||||||
assertNull(networkInfoList);
|
List<PhysicalNetworkSetupInfo> net = Mockito.mock(List.class);
|
||||||
}
|
cnc = new CheckNetworkCommand(net);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testExecuteInSequence() {
|
@Test
|
||||||
boolean b = cnc.executeInSequence();
|
public void testGetPhysicalNetworkInfoList() {
|
||||||
assertTrue(b);
|
List<PhysicalNetworkSetupInfo> networkInfoList = cnc
|
||||||
}
|
.getPhysicalNetworkInfoList();
|
||||||
|
assertEquals(0, networkInfoList.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExecuteInSequence() {
|
||||||
|
boolean b = cnc.executeInSequence();
|
||||||
|
assertTrue(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,351 +16,462 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import java.util.List;
|
import static org.junit.Assert.assertFalse;
|
||||||
import java.util.Date;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import java.text.SimpleDateFormat;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import com.cloud.agent.api.*;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.cloud.agent.api.CheckOnHostCommand;
|
||||||
import com.cloud.agent.api.to.HostTO;
|
import com.cloud.agent.api.to.HostTO;
|
||||||
import com.cloud.host.Host;
|
import com.cloud.host.Host;
|
||||||
import com.cloud.host.Status;
|
import com.cloud.host.Status;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.resource.ResourceState;
|
import com.cloud.resource.ResourceState;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class CheckOnHostCommandTest {
|
public class CheckOnHostCommandTest {
|
||||||
public Host host = new Host() {
|
public Host host = new Host() {
|
||||||
public Status getState() {return Status.Up;};
|
public Status getState() {
|
||||||
public long getId() {return 101L;};
|
return Status.Up;
|
||||||
public String getName() {return "hostName";};
|
};
|
||||||
public Type getType() {return Host.Type.Storage;};
|
|
||||||
public Date getCreated() {
|
public long getId() {
|
||||||
Date date = null;
|
return 101L;
|
||||||
try{
|
};
|
||||||
date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("01/01/1970 12:12:12");
|
|
||||||
}
|
public String getName() {
|
||||||
catch (ParseException e) {
|
return "hostName";
|
||||||
e.printStackTrace();
|
};
|
||||||
}
|
|
||||||
return date;
|
public Type getType() {
|
||||||
}
|
return Host.Type.Storage;
|
||||||
public Status getStatus() {return Status.Up;};
|
};
|
||||||
public String getPrivateIpAddress() {return "10.1.1.1";};
|
|
||||||
public String getStorageIpAddress() {return "10.1.1.2";};
|
public Date getCreated() {
|
||||||
public String getGuid() {return "bed9f83e-cac3-11e1-ac8a-0050568b007e";};
|
Date date = null;
|
||||||
public Long getTotalMemory() {return 100000000000L;};
|
try {
|
||||||
public Integer getCpus() {return 16;};
|
date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
|
||||||
public Long getSpeed() {return 2000000000L;};
|
.parse("01/01/1970 12:12:12");
|
||||||
public Integer getProxyPort() {return 22;};
|
} catch (ParseException e) {
|
||||||
public Long getPodId() {return 16L;};
|
e.printStackTrace();
|
||||||
public long getDataCenterId() {return 17L;};
|
}
|
||||||
public String getParent() {return "parent";};
|
return date;
|
||||||
public String getStorageIpAddressDeux() {return "10.1.1.3";};
|
}
|
||||||
public HypervisorType getHypervisorType() {return HypervisorType.XenServer;};
|
|
||||||
public Date getDisconnectedOn() {
|
public Status getStatus() {
|
||||||
Date date = null;
|
return Status.Up;
|
||||||
try{
|
};
|
||||||
date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("01/01/2012 12:12:12");
|
|
||||||
}
|
public String getPrivateIpAddress() {
|
||||||
catch (ParseException e) {
|
return "10.1.1.1";
|
||||||
e.printStackTrace();
|
};
|
||||||
}
|
|
||||||
return date;
|
public String getStorageIpAddress() {
|
||||||
}
|
return "10.1.1.2";
|
||||||
public String getVersion() {return "4.0.1";};
|
};
|
||||||
public long getTotalSize() {return 100000000000L;};
|
|
||||||
public String getCapabilities() {return "capabilities";};
|
public String getGuid() {
|
||||||
public long getLastPinged() {return 1L;};
|
return "bed9f83e-cac3-11e1-ac8a-0050568b007e";
|
||||||
public Long getManagementServerId() {return 2L;};
|
};
|
||||||
public Date getRemoved() {
|
|
||||||
Date date = null;
|
public Long getTotalMemory() {
|
||||||
try{
|
return 100000000000L;
|
||||||
date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("02/01/2012 12:12:12");
|
};
|
||||||
}
|
|
||||||
catch (ParseException e) {
|
public Integer getCpus() {
|
||||||
e.printStackTrace();
|
return 16;
|
||||||
}
|
};
|
||||||
return date;
|
|
||||||
};
|
public Long getSpeed() {
|
||||||
public Long getClusterId() {return 3L;};
|
return 2000000000L;
|
||||||
public String getPublicIpAddress() {return "10.1.1.4";};
|
};
|
||||||
public String getPublicNetmask() {return "255.255.255.8";};
|
|
||||||
public String getPrivateNetmask() {return "255.255.255.16";};
|
public Integer getProxyPort() {
|
||||||
public String getStorageNetmask() {return "255.255.255.24";};
|
return 22;
|
||||||
public String getStorageMacAddress() {return "01:f4:17:38:0e:26";};
|
};
|
||||||
public String getPublicMacAddress() {return "02:f4:17:38:0e:26";};
|
|
||||||
public String getPrivateMacAddress() {return "03:f4:17:38:0e:26";};
|
public Long getPodId() {
|
||||||
public String getStorageNetmaskDeux() {return "255.255.255.25";};
|
return 16L;
|
||||||
public String getStorageMacAddressDeux() {return "01:f4:17:38:0e:27";};
|
};
|
||||||
public String getHypervisorVersion() {return "1.2.3.0";};
|
|
||||||
public boolean isInMaintenanceStates() {return false;};
|
public long getDataCenterId() {
|
||||||
public ResourceState getResourceState() {return ResourceState.Enabled;};
|
return 17L;
|
||||||
};
|
};
|
||||||
|
|
||||||
CheckOnHostCommand cohc = new CheckOnHostCommand(host);
|
public String getParent() {
|
||||||
|
return "parent";
|
||||||
@Test
|
};
|
||||||
public void testGetHost() {
|
|
||||||
HostTO h = cohc.getHost();
|
public String getStorageIpAddressDeux() {
|
||||||
assertNotNull(h);
|
return "10.1.1.3";
|
||||||
}
|
};
|
||||||
|
|
||||||
@Test
|
public HypervisorType getHypervisorType() {
|
||||||
public void testGetState() {
|
return HypervisorType.XenServer;
|
||||||
Status s = host.getState();
|
};
|
||||||
assertTrue(s == Status.Up);
|
|
||||||
}
|
public Date getDisconnectedOn() {
|
||||||
|
Date date = null;
|
||||||
@Test
|
try {
|
||||||
public void testGetId() {
|
date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
|
||||||
Long id = host.getId();
|
.parse("01/01/2012 12:12:12");
|
||||||
assertTrue(101L == id);
|
} catch (ParseException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
|
}
|
||||||
@Test
|
return date;
|
||||||
public void testGetName() {
|
}
|
||||||
String name = host.getName();
|
|
||||||
assertTrue(name.equals("hostName"));
|
public String getVersion() {
|
||||||
}
|
return "4.0.1";
|
||||||
|
};
|
||||||
@Test
|
|
||||||
public void testGetType() {
|
public long getTotalSize() {
|
||||||
Host.Type t = host.getType();
|
return 100000000000L;
|
||||||
assertTrue(t == Host.Type.Storage);
|
};
|
||||||
}
|
|
||||||
|
public String getCapabilities() {
|
||||||
@Test
|
return "capabilities";
|
||||||
public void testGetCreated() {
|
};
|
||||||
try{
|
|
||||||
Date date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("01/01/1970 12:12:12");
|
public long getLastPinged() {
|
||||||
Date d = host.getCreated();
|
return 1L;
|
||||||
assertTrue(d.compareTo(date) == 0);
|
};
|
||||||
}
|
|
||||||
catch (ParseException e) {
|
public Long getManagementServerId() {
|
||||||
e.printStackTrace();
|
return 2L;
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
public Date getRemoved() {
|
||||||
@Test
|
Date date = null;
|
||||||
public void testGetStatus() {
|
try {
|
||||||
Status s = host.getStatus();
|
date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
|
||||||
assertTrue(s == Status.Up);
|
.parse("02/01/2012 12:12:12");
|
||||||
}
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
@Test
|
}
|
||||||
public void testGetPrivateIpAddress() {
|
return date;
|
||||||
String addr = host.getPrivateIpAddress();
|
};
|
||||||
assertTrue(addr.equals("10.1.1.1"));
|
|
||||||
}
|
public Long getClusterId() {
|
||||||
|
return 3L;
|
||||||
@Test
|
};
|
||||||
public void testGetStorageIpAddress() {
|
|
||||||
String addr = host.getStorageIpAddress();
|
public String getPublicIpAddress() {
|
||||||
assertTrue(addr.equals("10.1.1.2"));
|
return "10.1.1.4";
|
||||||
}
|
};
|
||||||
|
|
||||||
@Test
|
public String getPublicNetmask() {
|
||||||
public void testGetGuid() {
|
return "255.255.255.8";
|
||||||
String guid = host.getGuid();
|
};
|
||||||
assertTrue(guid.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e"));
|
|
||||||
}
|
public String getPrivateNetmask() {
|
||||||
|
return "255.255.255.16";
|
||||||
@Test
|
};
|
||||||
public void testGetTotalMemory() {
|
|
||||||
Long m = host.getTotalMemory();
|
public String getStorageNetmask() {
|
||||||
assertTrue(m == 100000000000L);
|
return "255.255.255.24";
|
||||||
}
|
};
|
||||||
|
|
||||||
@Test
|
public String getStorageMacAddress() {
|
||||||
public void testGetCpus() {
|
return "01:f4:17:38:0e:26";
|
||||||
int cpus = host.getCpus();
|
};
|
||||||
assertTrue(cpus == 16);
|
|
||||||
}
|
public String getPublicMacAddress() {
|
||||||
|
return "02:f4:17:38:0e:26";
|
||||||
@Test
|
};
|
||||||
public void testGetSpeed() {
|
|
||||||
Long spped = host.getSpeed();
|
public String getPrivateMacAddress() {
|
||||||
assertTrue(spped == 2000000000L);
|
return "03:f4:17:38:0e:26";
|
||||||
}
|
};
|
||||||
|
|
||||||
@Test
|
public String getStorageNetmaskDeux() {
|
||||||
public void testGetProxyPort() {
|
return "255.255.255.25";
|
||||||
Integer port = host.getProxyPort();
|
};
|
||||||
assertTrue(port == 22);
|
|
||||||
}
|
public String getStorageMacAddressDeux() {
|
||||||
|
return "01:f4:17:38:0e:27";
|
||||||
@Test
|
};
|
||||||
public void testGetPodId() {
|
|
||||||
Long pID = host.getPodId();
|
public String getHypervisorVersion() {
|
||||||
assertTrue(pID == 16L);
|
return "1.2.3.0";
|
||||||
}
|
};
|
||||||
|
|
||||||
@Test
|
public boolean isInMaintenanceStates() {
|
||||||
public void testGetDataCenterId() {
|
return false;
|
||||||
long dcID = host.getDataCenterId();
|
};
|
||||||
assertTrue(dcID == 17L);
|
|
||||||
}
|
public ResourceState getResourceState() {
|
||||||
|
return ResourceState.Enabled;
|
||||||
@Test
|
};
|
||||||
public void testGetParent() {
|
};
|
||||||
String p = host.getParent();
|
|
||||||
assertTrue(p.equals("parent"));
|
CheckOnHostCommand cohc = new CheckOnHostCommand(host);
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetHost() {
|
||||||
public void testGetStorageIpAddressDeux() {
|
HostTO h = cohc.getHost();
|
||||||
String addr = host.getStorageIpAddressDeux();
|
assertNotNull(h);
|
||||||
assertTrue(addr.equals("10.1.1.3"));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetState() {
|
||||||
public void testGetHypervisorType() {
|
Status s = host.getState();
|
||||||
HypervisorType type = host.getHypervisorType();
|
assertTrue(s == Status.Up);
|
||||||
assertTrue(type == HypervisorType.XenServer);
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetId() {
|
||||||
public void testGetDisconnectedOn() {
|
Long id = host.getId();
|
||||||
try{
|
assertTrue(101L == id);
|
||||||
Date date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("01/01/2012 12:12:12");
|
}
|
||||||
Date d = host.getDisconnectedOn();
|
|
||||||
assertTrue(d.compareTo(date) == 0);
|
@Test
|
||||||
}
|
public void testGetName() {
|
||||||
catch (ParseException e) {
|
String name = host.getName();
|
||||||
e.printStackTrace();
|
assertTrue(name.equals("hostName"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetType() {
|
||||||
public void testGetVersion() {
|
Host.Type t = host.getType();
|
||||||
String v = host.getVersion();
|
assertTrue(t == Host.Type.Storage);
|
||||||
assertTrue(v.equals("4.0.1"));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetCreated() {
|
||||||
public void testGetTotalSize() {
|
try {
|
||||||
long size = host.getTotalSize();
|
Date date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
|
||||||
assertTrue(size == 100000000000L);
|
.parse("01/01/1970 12:12:12");
|
||||||
}
|
Date d = host.getCreated();
|
||||||
|
assertTrue(d.compareTo(date) == 0);
|
||||||
@Test
|
} catch (ParseException e) {
|
||||||
public void testGetCapabilities() {
|
e.printStackTrace();
|
||||||
String c = host.getCapabilities();
|
}
|
||||||
assertTrue(c.equals("capabilities"));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetStatus() {
|
||||||
public void testGetLastPinged() {
|
Status s = host.getStatus();
|
||||||
long lp = host.getLastPinged();
|
assertTrue(s == Status.Up);
|
||||||
assertTrue(lp == 1L);
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetPrivateIpAddress() {
|
||||||
public void testGetManagementServerId() {
|
String addr = host.getPrivateIpAddress();
|
||||||
Long msID = host.getManagementServerId();
|
assertTrue(addr.equals("10.1.1.1"));
|
||||||
assertTrue(msID == 2L);
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetStorageIpAddress() {
|
||||||
public void testGetRemoved() {
|
String addr = host.getStorageIpAddress();
|
||||||
try{
|
assertTrue(addr.equals("10.1.1.2"));
|
||||||
Date date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("02/01/2012 12:12:12");
|
}
|
||||||
Date d = host.getRemoved();
|
|
||||||
assertTrue(d.compareTo(date) == 0);
|
@Test
|
||||||
}
|
public void testGetGuid() {
|
||||||
catch (ParseException e) {
|
String guid = host.getGuid();
|
||||||
e.printStackTrace();
|
assertTrue(guid.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetTotalMemory() {
|
||||||
public void testGetClusterId() {
|
Long m = host.getTotalMemory();
|
||||||
Long cID = host.getClusterId();
|
assertTrue(m == 100000000000L);
|
||||||
assertTrue(cID == 3L);
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetCpus() {
|
||||||
public void testGetPublicIpAddress() {
|
int cpus = host.getCpus();
|
||||||
String pipAddr = host.getPublicIpAddress();
|
assertTrue(cpus == 16);
|
||||||
assertTrue(pipAddr.equals("10.1.1.4"));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetSpeed() {
|
||||||
public void testGetPublicNetmask() {
|
Long spped = host.getSpeed();
|
||||||
String pMask = host.getPublicNetmask();
|
assertTrue(spped == 2000000000L);
|
||||||
assertTrue(pMask.equals("255.255.255.8"));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetProxyPort() {
|
||||||
public void testGetPrivateNetmask() {
|
Integer port = host.getProxyPort();
|
||||||
String pMask = host.getPrivateNetmask();
|
assertTrue(port == 22);
|
||||||
assertTrue(pMask.equals("255.255.255.16"));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetPodId() {
|
||||||
public void testGetStorageNetmask() {
|
Long pID = host.getPodId();
|
||||||
String sMask = host.getStorageNetmask();
|
assertTrue(pID == 16L);
|
||||||
assertTrue(sMask.equals("255.255.255.24"));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetDataCenterId() {
|
||||||
public void testGetStorageMacAddress() {
|
long dcID = host.getDataCenterId();
|
||||||
String sMac = host.getStorageMacAddress();
|
assertTrue(dcID == 17L);
|
||||||
assertTrue(sMac.equals("01:f4:17:38:0e:26"));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetParent() {
|
||||||
public void testGetPublicMacAddress() {
|
String p = host.getParent();
|
||||||
String pMac = host.getPublicMacAddress();
|
assertTrue(p.equals("parent"));
|
||||||
assertTrue(pMac.equals("02:f4:17:38:0e:26"));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetStorageIpAddressDeux() {
|
||||||
public void testGetPrivateMacAddress() {
|
String addr = host.getStorageIpAddressDeux();
|
||||||
String pMac = host.getPrivateMacAddress();
|
assertTrue(addr.equals("10.1.1.3"));
|
||||||
assertTrue(pMac.equals("03:f4:17:38:0e:26"));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetHypervisorType() {
|
||||||
public void testGetStorageNetmaskDeux() {
|
HypervisorType type = host.getHypervisorType();
|
||||||
String sMask = host.getStorageNetmaskDeux();
|
assertTrue(type == HypervisorType.XenServer);
|
||||||
assertTrue(sMask.equals("255.255.255.25"));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetDisconnectedOn() {
|
||||||
public void testGetStorageMacAddressDeux() {
|
try {
|
||||||
String sMac = host.getStorageMacAddressDeux();
|
Date date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
|
||||||
assertTrue(sMac.equals("01:f4:17:38:0e:27"));
|
.parse("01/01/2012 12:12:12");
|
||||||
}
|
Date d = host.getDisconnectedOn();
|
||||||
|
assertTrue(d.compareTo(date) == 0);
|
||||||
@Test
|
} catch (ParseException e) {
|
||||||
public void testGetHypervisorVersion() {
|
e.printStackTrace();
|
||||||
String v = host.getHypervisorVersion();
|
}
|
||||||
assertTrue(v.equals("1.2.3.0"));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetVersion() {
|
||||||
public void testIsInMaintenanceStates() {
|
String v = host.getVersion();
|
||||||
boolean b = host.isInMaintenanceStates();
|
assertTrue(v.equals("4.0.1"));
|
||||||
assertFalse(b);
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetTotalSize() {
|
||||||
public void testGetResourceState() {
|
long size = host.getTotalSize();
|
||||||
ResourceState r = host.getResourceState();
|
assertTrue(size == 100000000000L);
|
||||||
assertTrue(r == ResourceState.Enabled);
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetCapabilities() {
|
||||||
public void testGetWait() {
|
String c = host.getCapabilities();
|
||||||
int wait = cohc.getWait();
|
assertTrue(c.equals("capabilities"));
|
||||||
assertTrue(20 == wait);
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetLastPinged() {
|
||||||
public void testExecuteInSequence() {
|
long lp = host.getLastPinged();
|
||||||
boolean b = cohc.executeInSequence();
|
assertTrue(lp == 1L);
|
||||||
assertFalse(b);
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
|
public void testGetManagementServerId() {
|
||||||
|
Long msID = host.getManagementServerId();
|
||||||
|
assertTrue(msID == 2L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetRemoved() {
|
||||||
|
try {
|
||||||
|
Date date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
|
||||||
|
.parse("02/01/2012 12:12:12");
|
||||||
|
Date d = host.getRemoved();
|
||||||
|
assertTrue(d.compareTo(date) == 0);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetClusterId() {
|
||||||
|
Long cID = host.getClusterId();
|
||||||
|
assertTrue(cID == 3L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPublicIpAddress() {
|
||||||
|
String pipAddr = host.getPublicIpAddress();
|
||||||
|
assertTrue(pipAddr.equals("10.1.1.4"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPublicNetmask() {
|
||||||
|
String pMask = host.getPublicNetmask();
|
||||||
|
assertTrue(pMask.equals("255.255.255.8"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPrivateNetmask() {
|
||||||
|
String pMask = host.getPrivateNetmask();
|
||||||
|
assertTrue(pMask.equals("255.255.255.16"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetStorageNetmask() {
|
||||||
|
String sMask = host.getStorageNetmask();
|
||||||
|
assertTrue(sMask.equals("255.255.255.24"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetStorageMacAddress() {
|
||||||
|
String sMac = host.getStorageMacAddress();
|
||||||
|
assertTrue(sMac.equals("01:f4:17:38:0e:26"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPublicMacAddress() {
|
||||||
|
String pMac = host.getPublicMacAddress();
|
||||||
|
assertTrue(pMac.equals("02:f4:17:38:0e:26"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPrivateMacAddress() {
|
||||||
|
String pMac = host.getPrivateMacAddress();
|
||||||
|
assertTrue(pMac.equals("03:f4:17:38:0e:26"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetStorageNetmaskDeux() {
|
||||||
|
String sMask = host.getStorageNetmaskDeux();
|
||||||
|
assertTrue(sMask.equals("255.255.255.25"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetStorageMacAddressDeux() {
|
||||||
|
String sMac = host.getStorageMacAddressDeux();
|
||||||
|
assertTrue(sMac.equals("01:f4:17:38:0e:27"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetHypervisorVersion() {
|
||||||
|
String v = host.getHypervisorVersion();
|
||||||
|
assertTrue(v.equals("1.2.3.0"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsInMaintenanceStates() {
|
||||||
|
boolean b = host.isInMaintenanceStates();
|
||||||
|
assertFalse(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetResourceState() {
|
||||||
|
ResourceState r = host.getResourceState();
|
||||||
|
assertTrue(r == ResourceState.Enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetWait() {
|
||||||
|
int wait = cohc.getWait();
|
||||||
|
assertTrue(20 == wait);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExecuteInSequence() {
|
||||||
|
boolean b = cohc.executeInSequence();
|
||||||
|
assertFalse(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,83 +16,92 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.agent.api.test;
|
package src.com.cloud.agent.api.test;
|
||||||
|
|
||||||
import com.cloud.agent.api.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.cloud.agent.api.SnapshotCommand;
|
||||||
|
|
||||||
public class SnapshotCommandTest {
|
public class SnapshotCommandTest {
|
||||||
SnapshotCommand ssc = new SnapshotCommand("primaryStoragePoolNameLabel",
|
SnapshotCommand ssc = new SnapshotCommand("primaryStoragePoolNameLabel",
|
||||||
"http://secondary.Storage.Url",
|
"http://secondary.Storage.Url",
|
||||||
"420fa39c-4ef1-a83c-fd93-46dc1ff515ae",
|
"420fa39c-4ef1-a83c-fd93-46dc1ff515ae", "snapshotName", 101L, 102L,
|
||||||
"snapshotName",
|
103L);
|
||||||
101L,
|
|
||||||
102L,
|
|
||||||
103L);
|
|
||||||
|
|
||||||
SnapshotCommand ssc1 = new SnapshotCommand();
|
|
||||||
|
|
||||||
@Test
|
SnapshotCommand ssc1;
|
||||||
public void testGetPrimaryStoragePoolNameLabel() {
|
|
||||||
String label = ssc.getPrimaryStoragePoolNameLabel();
|
|
||||||
assertTrue(label.equals("primaryStoragePoolNameLabel"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Before
|
||||||
public void testGetSecondaryStorageUrl() {
|
public void setUp() {
|
||||||
String url = ssc.getSecondaryStorageUrl();
|
ssc1 = new SnapshotCommand("primaryStoragePoolNameLabel",
|
||||||
assertTrue(url.equals("http://secondary.Storage.Url"));
|
"secondaryStorageUrl", "snapshotUuid", "snapshotName", 101L,
|
||||||
}
|
102L, 103L);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSnapshotUuid() {
|
public void testGetPrimaryStoragePoolNameLabel() {
|
||||||
String uuid = ssc.getSnapshotUuid();
|
String label = ssc.getPrimaryStoragePoolNameLabel();
|
||||||
assertTrue(uuid.equals("420fa39c-4ef1-a83c-fd93-46dc1ff515ae"));
|
assertTrue(label.equals("primaryStoragePoolNameLabel"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSnapshotName() {
|
public void testGetSecondaryStorageUrl() {
|
||||||
String name = ssc.getSnapshotName();
|
String url = ssc.getSecondaryStorageUrl();
|
||||||
assertTrue(name.equals("snapshotName"));
|
assertTrue(url.equals("http://secondary.Storage.Url"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetVolumePath() {
|
public void testGetSnapshotUuid() {
|
||||||
ssc.setVolumePath("vPath");
|
String uuid = ssc.getSnapshotUuid();
|
||||||
String path = ssc.getVolumePath();
|
assertTrue(uuid.equals("420fa39c-4ef1-a83c-fd93-46dc1ff515ae"));
|
||||||
assertTrue(path.equals("vPath"));
|
}
|
||||||
|
|
||||||
ssc1.setVolumePath("vPath1");
|
|
||||||
path = ssc1.getVolumePath();
|
|
||||||
assertTrue(path.equals("vPath1"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteInSequence() {
|
public void testGetSnapshotName() {
|
||||||
boolean b = ssc.executeInSequence();
|
String name = ssc.getSnapshotName();
|
||||||
assertFalse(b);
|
assertTrue(name.equals("snapshotName"));
|
||||||
|
}
|
||||||
|
|
||||||
b = ssc1.executeInSequence();
|
@Test
|
||||||
assertFalse(b);
|
public void testGetVolumePath() {
|
||||||
}
|
ssc.setVolumePath("vPath");
|
||||||
|
String path = ssc.getVolumePath();
|
||||||
|
assertTrue(path.equals("vPath"));
|
||||||
|
|
||||||
@Test
|
ssc1.setVolumePath("vPath1");
|
||||||
public void testGetDataCenterId() {
|
path = ssc1.getVolumePath();
|
||||||
Long dcId = ssc.getDataCenterId();
|
assertTrue(path.equals("vPath1"));
|
||||||
Long expected = 101L;
|
}
|
||||||
assertEquals(expected, dcId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAccountId() {
|
public void testExecuteInSequence() {
|
||||||
Long aId = ssc.getAccountId();
|
boolean b = ssc.executeInSequence();
|
||||||
Long expected = 102L;
|
assertFalse(b);
|
||||||
assertEquals(expected, aId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
b = ssc1.executeInSequence();
|
||||||
public void testGetVolumeId() {
|
assertFalse(b);
|
||||||
Long vId = ssc.getVolumeId();
|
}
|
||||||
Long expected = 103L;
|
|
||||||
assertEquals(expected, vId);
|
@Test
|
||||||
}
|
public void testGetDataCenterId() {
|
||||||
|
Long dcId = ssc.getDataCenterId();
|
||||||
|
Long expected = 101L;
|
||||||
|
assertEquals(expected, dcId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAccountId() {
|
||||||
|
Long aId = ssc.getAccountId();
|
||||||
|
Long expected = 102L;
|
||||||
|
assertEquals(expected, aId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetVolumeId() {
|
||||||
|
Long vId = ssc.getVolumeId();
|
||||||
|
Long expected = 103L;
|
||||||
|
assertEquals(expected, vId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,62 +25,63 @@ import org.junit.Test;
|
|||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import com.cloud.api.ResponseGenerator;
|
import com.cloud.api.commands.ActivateProjectCmd;
|
||||||
import com.cloud.api.response.ProjectResponse;
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.projects.Project;
|
import com.cloud.projects.Project;
|
||||||
import com.cloud.projects.ProjectService;
|
import com.cloud.projects.ProjectService;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.user.UserContext;
|
|
||||||
|
|
||||||
public class ActivateProjectCmdTest extends TestCase {
|
public class ActivateProjectCmdTest extends TestCase {
|
||||||
|
|
||||||
private ActivateProjectCmd activateProjectCmd;
|
private ActivateProjectCmd activateProjectCmd;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
public ExpectedException expectedException = ExpectedException.none();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
|
||||||
activateProjectCmd = new ActivateProjectCmd(){
|
activateProjectCmd = new ActivateProjectCmd() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return 2L;
|
return 2L;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testGetEntityOwnerIdForNullProject() {
|
||||||
public void testGetEntityOwnerIdForNullProject() {
|
ProjectService projectService = Mockito.mock(ProjectService.class);
|
||||||
ProjectService projectService = Mockito.mock(ProjectService.class);
|
Mockito.when(projectService.getProject(Mockito.anyLong())).thenReturn(
|
||||||
Mockito.when(projectService.getProject(Mockito.anyLong())).thenReturn(null);
|
null);
|
||||||
activateProjectCmd._projectService = projectService;
|
activateProjectCmd._projectService = projectService;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
activateProjectCmd.getEntityOwnerId();
|
activateProjectCmd.getEntityOwnerId();
|
||||||
} catch(InvalidParameterValueException exception) {
|
} catch (InvalidParameterValueException exception) {
|
||||||
Assert.assertEquals("Unable to find project by id 2", exception.getLocalizedMessage());
|
Assert.assertEquals("Unable to find project by id 2",
|
||||||
}
|
exception.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testGetEntityOwnerIdForProject() {
|
@Test
|
||||||
Project project = Mockito.mock(Project.class);
|
public void testGetEntityOwnerIdForProject() {
|
||||||
Mockito.when(project.getId()).thenReturn(2L);
|
Project project = Mockito.mock(Project.class);
|
||||||
ProjectService projectService = Mockito.mock(ProjectService.class);
|
Mockito.when(project.getId()).thenReturn(2L);
|
||||||
Account account = Mockito.mock(Account.class);
|
ProjectService projectService = Mockito.mock(ProjectService.class);
|
||||||
Mockito.when(account.getId()).thenReturn(2L);
|
Account account = Mockito.mock(Account.class);
|
||||||
Mockito.when(projectService.getProject(Mockito.anyLong())).thenReturn(project);
|
Mockito.when(account.getId()).thenReturn(2L);
|
||||||
|
Mockito.when(projectService.getProject(Mockito.anyLong())).thenReturn(
|
||||||
Mockito.when(projectService.getProjectOwner(Mockito.anyLong())).thenReturn(account);
|
project);
|
||||||
activateProjectCmd._projectService = projectService;
|
|
||||||
|
Mockito.when(projectService.getProjectOwner(Mockito.anyLong()))
|
||||||
Assert.assertEquals(2L, activateProjectCmd.getEntityOwnerId());
|
.thenReturn(account);
|
||||||
|
activateProjectCmd._projectService = projectService;
|
||||||
}
|
|
||||||
|
Assert.assertEquals(2L, activateProjectCmd.getEntityOwnerId());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,147 +29,147 @@ import com.cloud.exception.InvalidParameterValueException;
|
|||||||
import com.cloud.projects.Project;
|
import com.cloud.projects.Project;
|
||||||
import com.cloud.projects.ProjectService;
|
import com.cloud.projects.ProjectService;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.api.commands.AddAccountToProjectCmd;
|
||||||
|
|
||||||
public class AddAccountToProjectCmdTest extends TestCase {
|
public class AddAccountToProjectCmdTest extends TestCase {
|
||||||
|
|
||||||
|
private AddAccountToProjectCmd addAccountToProjectCmd;
|
||||||
private AddAccountToProjectCmd addAccountToProjectCmd;
|
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
addAccountToProjectCmd = new AddAccountToProjectCmd(){
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getProjectId() {
|
|
||||||
return 2L;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getAccountName() {
|
|
||||||
|
|
||||||
// to run the test testGetEventDescriptionForAccount set the accountName
|
|
||||||
// return "accountName";
|
|
||||||
// to run the test the testGetEventDescriptionForNullAccount return accountname as null
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEmail() {
|
|
||||||
// return "customer@abc.com";
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
@Rule
|
||||||
}
|
public ExpectedException expectedException = ExpectedException.none();
|
||||||
|
|
||||||
|
|
||||||
/****
|
|
||||||
* Condition not handled in the code
|
|
||||||
*
|
|
||||||
*****/
|
|
||||||
|
|
||||||
/*@Test
|
|
||||||
public void testGetEntityOwnerIdForNullProject() {
|
|
||||||
|
|
||||||
ProjectService projectService = Mockito.mock(ProjectService.class);
|
|
||||||
Mockito.when(projectService.getProject(Mockito.anyLong())).thenReturn(null);
|
|
||||||
addAccountToProjectCmd._projectService = projectService;
|
|
||||||
|
|
||||||
try {
|
|
||||||
addAccountToProjectCmd.getEntityOwnerId();
|
|
||||||
} catch(InvalidParameterValueException exception) {
|
|
||||||
Assert.assertEquals("Unable to find project by id 2", exception.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetEntityOwnerIdForProject() {
|
|
||||||
|
|
||||||
Project project = Mockito.mock(Project.class);
|
@Before
|
||||||
Mockito.when(project.getId()).thenReturn(2L);
|
public void setUp() {
|
||||||
|
addAccountToProjectCmd = new AddAccountToProjectCmd() {
|
||||||
ProjectService projectService = Mockito.mock(ProjectService.class);
|
|
||||||
Account account = Mockito.mock(Account.class);
|
|
||||||
|
|
||||||
Mockito.when(account.getId()).thenReturn(2L);
|
|
||||||
Mockito.when(projectService.getProject(Mockito.anyLong())).thenReturn(
|
|
||||||
project);
|
|
||||||
|
|
||||||
Mockito.when(projectService.getProjectOwner(Mockito.anyLong()))
|
@Override
|
||||||
.thenReturn(account);
|
public Long getProjectId() {
|
||||||
addAccountToProjectCmd._projectService = projectService;
|
return 2L;
|
||||||
|
}
|
||||||
|
|
||||||
Assert.assertEquals(2L, addAccountToProjectCmd.getEntityOwnerId());
|
@Override
|
||||||
|
public String getAccountName() {
|
||||||
|
|
||||||
}
|
// to run the test testGetEventDescriptionForAccount set the
|
||||||
|
// accountName
|
||||||
/**
|
// return "accountName";
|
||||||
* To run the test uncomment the return statement for getAccountName() in setup() and return null
|
// to run the test the testGetEventDescriptionForNullAccount
|
||||||
*
|
// return accountname as null
|
||||||
* **/
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/*@Test
|
@Override
|
||||||
public void testGetEventDescriptionForNullAccount() {
|
public String getEmail() {
|
||||||
|
// return "customer@abc.com";
|
||||||
String result = addAccountToProjectCmd.getEventDescription();
|
return null;
|
||||||
String expected = "Sending invitation to email null to join project: 2";
|
}
|
||||||
Assert.assertEquals(expected, result);
|
|
||||||
|
};
|
||||||
}*/
|
}
|
||||||
|
|
||||||
/***
|
/****
|
||||||
|
* Condition not handled in the code
|
||||||
|
*
|
||||||
|
*****/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Test public void testGetEntityOwnerIdForNullProject() {
|
||||||
|
*
|
||||||
|
* ProjectService projectService = Mockito.mock(ProjectService.class);
|
||||||
|
* Mockito
|
||||||
|
* .when(projectService.getProject(Mockito.anyLong())).thenReturn(null);
|
||||||
|
* addAccountToProjectCmd._projectService = projectService;
|
||||||
|
*
|
||||||
|
* try { addAccountToProjectCmd.getEntityOwnerId(); }
|
||||||
|
* catch(InvalidParameterValueException exception) {
|
||||||
|
* Assert.assertEquals("Unable to find project by id 2",
|
||||||
|
* exception.getLocalizedMessage()); }
|
||||||
|
*
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetEntityOwnerIdForProject() {
|
||||||
|
|
||||||
|
Project project = Mockito.mock(Project.class);
|
||||||
|
Mockito.when(project.getId()).thenReturn(2L);
|
||||||
|
|
||||||
|
ProjectService projectService = Mockito.mock(ProjectService.class);
|
||||||
|
Account account = Mockito.mock(Account.class);
|
||||||
|
|
||||||
|
Mockito.when(account.getId()).thenReturn(2L);
|
||||||
|
Mockito.when(projectService.getProject(Mockito.anyLong())).thenReturn(
|
||||||
|
project);
|
||||||
|
|
||||||
|
Mockito.when(projectService.getProjectOwner(Mockito.anyLong()))
|
||||||
|
.thenReturn(account);
|
||||||
|
addAccountToProjectCmd._projectService = projectService;
|
||||||
|
|
||||||
|
Assert.assertEquals(2L, addAccountToProjectCmd.getEntityOwnerId());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To run the test uncomment the return statement for getAccountName() in
|
||||||
|
* setup() and return null
|
||||||
|
*
|
||||||
|
* **/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Test public void testGetEventDescriptionForNullAccount() {
|
||||||
|
*
|
||||||
|
* String result = addAccountToProjectCmd.getEventDescription(); String
|
||||||
|
* expected = "Sending invitation to email null to join project: 2";
|
||||||
|
* Assert.assertEquals(expected, result);
|
||||||
|
*
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
|
/***
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* ***/
|
* ***/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*@Test
|
|
||||||
public void testGetEventDescriptionForAccount() {
|
|
||||||
|
|
||||||
String result = addAccountToProjectCmd.getEventDescription();
|
|
||||||
String expected = "Adding account accountName to project: 2";
|
|
||||||
Assert.assertEquals(expected, result);
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@Test
|
/*
|
||||||
public void testExecuteForNullAccountNameEmail() {
|
* @Test public void testGetEventDescriptionForAccount() {
|
||||||
|
*
|
||||||
try {
|
* String result = addAccountToProjectCmd.getEventDescription(); String
|
||||||
addAccountToProjectCmd.execute();
|
* expected = "Adding account accountName to project: 2";
|
||||||
} catch(InvalidParameterValueException exception) {
|
* Assert.assertEquals(expected, result);
|
||||||
Assert.assertEquals("Either accountName or email is required", exception.getLocalizedMessage());
|
*
|
||||||
}
|
* }
|
||||||
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
|
@Test
|
||||||
/*@Test
|
public void testExecuteForNullAccountNameEmail() {
|
||||||
public void testExecuteForAccountNameEmail() {
|
|
||||||
|
try {
|
||||||
try {
|
addAccountToProjectCmd.execute();
|
||||||
|
} catch (InvalidParameterValueException exception) {
|
||||||
ComponentLocator c = Mockito.mock(ComponentLocator.class);
|
Assert.assertEquals("Either accountName or email is required",
|
||||||
UserContext userContext = Mockito.mock(UserContext.class);
|
exception.getLocalizedMessage());
|
||||||
|
}
|
||||||
// Mockito.when(userContext.current()).thenReturn(userContext);
|
|
||||||
|
}
|
||||||
|
|
||||||
addAccountToProjectCmd.execute();
|
/*
|
||||||
} catch(InvalidParameterValueException exception) {
|
* @Test public void testExecuteForAccountNameEmail() {
|
||||||
Assert.assertEquals("Either accountName or email is required", exception.getLocalizedMessage());
|
*
|
||||||
}
|
* try {
|
||||||
|
*
|
||||||
}*/
|
* ComponentLocator c = Mockito.mock(ComponentLocator.class); UserContext
|
||||||
|
* userContext = Mockito.mock(UserContext.class);
|
||||||
|
*
|
||||||
|
* // Mockito.when(userContext.current()).thenReturn(userContext);
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* addAccountToProjectCmd.execute(); } catch(InvalidParameterValueException
|
||||||
|
* exception) {
|
||||||
|
* Assert.assertEquals("Either accountName or email is required",
|
||||||
|
* exception.getLocalizedMessage()); }
|
||||||
|
*
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import org.mockito.Mockito;
|
|||||||
|
|
||||||
import com.cloud.api.ResponseGenerator;
|
import com.cloud.api.ResponseGenerator;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.api.response.ClusterResponse;
|
import com.cloud.api.commands.AddClusterCmd;
|
||||||
import com.cloud.exception.DiscoveryException;
|
import com.cloud.exception.DiscoveryException;
|
||||||
import com.cloud.exception.ResourceInUseException;
|
import com.cloud.exception.ResourceInUseException;
|
||||||
import com.cloud.org.Cluster;
|
import com.cloud.org.Cluster;
|
||||||
@ -36,88 +36,85 @@ import com.cloud.resource.ResourceService;
|
|||||||
import edu.emory.mathcs.backport.java.util.Arrays;
|
import edu.emory.mathcs.backport.java.util.Arrays;
|
||||||
|
|
||||||
public class AddClusterCmdTest extends TestCase {
|
public class AddClusterCmdTest extends TestCase {
|
||||||
|
|
||||||
private AddClusterCmd addClusterCmd;
|
|
||||||
private ResourceService resourceService;
|
|
||||||
private ResponseGenerator responseGenerator;
|
|
||||||
|
|
||||||
|
private AddClusterCmd addClusterCmd;
|
||||||
@Rule
|
private ResourceService resourceService;
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
private ResponseGenerator responseGenerator;
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setUp() {
|
public ExpectedException expectedException = ExpectedException.none();
|
||||||
/* resourceService = Mockito.mock(ResourceService.class);
|
|
||||||
responseGenerator = Mockito.mock(ResponseGenerator.class);
|
|
||||||
*/ addClusterCmd = new AddClusterCmd(){
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
@Test
|
/*
|
||||||
public void testExecuteForNullResult() {
|
* resourceService = Mockito.mock(ResourceService.class);
|
||||||
|
* responseGenerator = Mockito.mock(ResponseGenerator.class);
|
||||||
|
*/addClusterCmd = new AddClusterCmd() {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
@Test
|
||||||
|
public void testExecuteForNullResult() {
|
||||||
try {
|
|
||||||
Mockito.when(resourceService.discoverCluster(addClusterCmd)).thenReturn(null);
|
|
||||||
} catch (ResourceInUseException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (DiscoveryException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
addClusterCmd._resourceService = resourceService;
|
|
||||||
|
|
||||||
try {
|
|
||||||
addClusterCmd.execute();
|
|
||||||
} catch (ServerApiException exception) {
|
|
||||||
Assert.assertEquals("Failed to add cluster", exception.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExecuteForEmptyResult() {
|
|
||||||
|
|
||||||
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
||||||
addClusterCmd._resourceService = resourceService;
|
|
||||||
|
|
||||||
try {
|
|
||||||
addClusterCmd.execute();
|
|
||||||
} catch (ServerApiException exception) {
|
|
||||||
Assert.assertEquals("Failed to add cluster", exception.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
try {
|
||||||
public void testExecuteForResult() throws Exception {
|
Mockito.when(resourceService.discoverCluster(addClusterCmd))
|
||||||
|
.thenReturn(null);
|
||||||
resourceService = Mockito.mock(ResourceService.class);
|
} catch (ResourceInUseException e) {
|
||||||
responseGenerator = Mockito.mock(ResponseGenerator.class);
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (DiscoveryException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
addClusterCmd._resourceService = resourceService;
|
||||||
|
|
||||||
|
try {
|
||||||
|
addClusterCmd.execute();
|
||||||
|
} catch (ServerApiException exception) {
|
||||||
|
Assert.assertEquals("Failed to add cluster",
|
||||||
|
exception.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExecuteForEmptyResult() {
|
||||||
|
|
||||||
|
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
||||||
|
addClusterCmd._resourceService = resourceService;
|
||||||
|
|
||||||
|
try {
|
||||||
|
addClusterCmd.execute();
|
||||||
|
} catch (ServerApiException exception) {
|
||||||
|
Assert.assertEquals("Failed to add cluster",
|
||||||
|
exception.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExecuteForResult() throws Exception {
|
||||||
|
|
||||||
|
resourceService = Mockito.mock(ResourceService.class);
|
||||||
|
responseGenerator = Mockito.mock(ResponseGenerator.class);
|
||||||
|
|
||||||
|
addClusterCmd._resourceService = resourceService;
|
||||||
|
addClusterCmd._responseGenerator = responseGenerator;
|
||||||
|
|
||||||
|
Cluster cluster = Mockito.mock(Cluster.class);
|
||||||
|
Cluster[] clusterArray = new Cluster[] { cluster };
|
||||||
|
|
||||||
|
Mockito.when(resourceService.discoverCluster(addClusterCmd))
|
||||||
|
.thenReturn(Arrays.asList(clusterArray));
|
||||||
|
|
||||||
|
addClusterCmd.execute();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
addClusterCmd._resourceService = resourceService;
|
|
||||||
addClusterCmd._responseGenerator = responseGenerator;
|
|
||||||
|
|
||||||
Cluster cluster = Mockito.mock(Cluster.class);
|
|
||||||
Cluster[] clusterArray = new Cluster[]{cluster};
|
|
||||||
|
|
||||||
Mockito.when(resourceService.discoverCluster(addClusterCmd)).thenReturn(Arrays.asList(clusterArray));
|
|
||||||
|
|
||||||
addClusterCmd.execute();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -16,11 +16,6 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.api.commands.test;
|
package src.com.cloud.api.commands.test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
@ -32,138 +27,139 @@ import org.mockito.Mockito;
|
|||||||
|
|
||||||
import com.cloud.api.ResponseGenerator;
|
import com.cloud.api.ResponseGenerator;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
|
import com.cloud.api.commands.AddHostCmd;
|
||||||
import com.cloud.api.response.HostResponse;
|
import com.cloud.api.response.HostResponse;
|
||||||
import com.cloud.api.response.ListResponse;
|
import com.cloud.api.response.ListResponse;
|
||||||
import com.cloud.exception.DiscoveryException;
|
import com.cloud.exception.DiscoveryException;
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.host.Host;
|
import com.cloud.host.Host;
|
||||||
import com.cloud.host.Status;
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|
||||||
import com.cloud.resource.ResourceService;
|
import com.cloud.resource.ResourceService;
|
||||||
import com.cloud.resource.ResourceState;
|
|
||||||
|
|
||||||
import edu.emory.mathcs.backport.java.util.Arrays;
|
import edu.emory.mathcs.backport.java.util.Arrays;
|
||||||
|
|
||||||
public class AddHostCmdTest extends TestCase {
|
public class AddHostCmdTest extends TestCase {
|
||||||
|
|
||||||
private AddHostCmd addHostCmd;
|
|
||||||
private ResourceService resourceService;
|
|
||||||
private ResponseGenerator responseGenerator;
|
|
||||||
|
|
||||||
@Rule
|
private AddHostCmd addHostCmd;
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
private ResourceService resourceService;
|
||||||
|
private ResponseGenerator responseGenerator;
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setUp() {
|
public ExpectedException expectedException = ExpectedException.none();
|
||||||
resourceService = Mockito.mock(ResourceService.class);
|
|
||||||
responseGenerator = Mockito.mock(ResponseGenerator.class);
|
|
||||||
addHostCmd = new AddHostCmd(){
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Before
|
||||||
public void testExecuteForEmptyResult() {
|
public void setUp() {
|
||||||
addHostCmd._resourceService = resourceService;
|
resourceService = Mockito.mock(ResourceService.class);
|
||||||
|
responseGenerator = Mockito.mock(ResponseGenerator.class);
|
||||||
try {
|
addHostCmd = new AddHostCmd() {
|
||||||
addHostCmd.execute();
|
};
|
||||||
} catch(ServerApiException exception) {
|
}
|
||||||
Assert.assertEquals("Failed to add host", exception.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExecuteForNullResult() {
|
|
||||||
|
|
||||||
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
@Test
|
||||||
addHostCmd._resourceService = resourceService;
|
public void testExecuteForEmptyResult() {
|
||||||
|
addHostCmd._resourceService = resourceService;
|
||||||
try {
|
|
||||||
Mockito.when(resourceService.discoverHosts(addHostCmd)).thenReturn(null);
|
|
||||||
} catch (InvalidParameterValueException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (DiscoveryException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
addHostCmd.execute();
|
|
||||||
} catch(ServerApiException exception) {
|
|
||||||
Assert.assertEquals("Failed to add host", exception.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* @Test
|
|
||||||
public void testExecuteForResult() throws Exception {
|
|
||||||
|
|
||||||
addHostCmd._resourceService = resourceService;
|
|
||||||
addHostCmd._responseGenerator = responseGenerator;
|
|
||||||
MockHost mockInstance = new MockHost();
|
|
||||||
MockHost[] mockArray = new MockHost[]{mockInstance};
|
|
||||||
HostResponse responseHost = new HostResponse();
|
|
||||||
responseHost.setName("Test");
|
|
||||||
Mockito.when(resourceService.discoverHosts(addHostCmd)).thenReturn(Arrays.asList(mockArray));
|
|
||||||
Mockito.when(responseGenerator.createHostResponse(mockInstance)).thenReturn(responseHost);
|
|
||||||
addHostCmd.execute();
|
|
||||||
Mockito.verify(responseGenerator).createHostResponse(mockInstance);
|
|
||||||
ListResponse<HostResponse> actualResponse = ((ListResponse<HostResponse>)addHostCmd.getResponseObject());
|
|
||||||
Assert.assertEquals(responseHost, actualResponse.getResponses().get(0));
|
|
||||||
Assert.assertEquals("addhostresponse", actualResponse.getResponseName());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testExecuteForResult() throws Exception {
|
|
||||||
|
|
||||||
addHostCmd._resourceService = resourceService;
|
try {
|
||||||
addHostCmd._responseGenerator = responseGenerator;
|
addHostCmd.execute();
|
||||||
|
} catch (ServerApiException exception) {
|
||||||
|
Assert.assertEquals("Failed to add host",
|
||||||
|
exception.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExecuteForNullResult() {
|
||||||
|
|
||||||
|
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
||||||
|
addHostCmd._resourceService = resourceService;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Mockito.when(resourceService.discoverHosts(addHostCmd)).thenReturn(
|
||||||
|
null);
|
||||||
|
} catch (InvalidParameterValueException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (DiscoveryException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
addHostCmd.execute();
|
||||||
|
} catch (ServerApiException exception) {
|
||||||
|
Assert.assertEquals("Failed to add host",
|
||||||
|
exception.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Test public void testExecuteForResult() throws Exception {
|
||||||
|
*
|
||||||
|
* addHostCmd._resourceService = resourceService;
|
||||||
|
* addHostCmd._responseGenerator = responseGenerator; MockHost mockInstance
|
||||||
|
* = new MockHost(); MockHost[] mockArray = new MockHost[]{mockInstance};
|
||||||
|
* HostResponse responseHost = new HostResponse();
|
||||||
|
* responseHost.setName("Test");
|
||||||
|
* Mockito.when(resourceService.discoverHosts(addHostCmd
|
||||||
|
* )).thenReturn(Arrays.asList(mockArray));
|
||||||
|
* Mockito.when(responseGenerator.createHostResponse
|
||||||
|
* (mockInstance)).thenReturn(responseHost); addHostCmd.execute();
|
||||||
|
* Mockito.verify(responseGenerator).createHostResponse(mockInstance);
|
||||||
|
* ListResponse<HostResponse> actualResponse =
|
||||||
|
* ((ListResponse<HostResponse>)addHostCmd.getResponseObject());
|
||||||
|
* Assert.assertEquals(responseHost, actualResponse.getResponses().get(0));
|
||||||
|
* Assert.assertEquals("addhostresponse", actualResponse.getResponseName());
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testExecuteForResult() throws Exception {
|
||||||
|
|
||||||
|
addHostCmd._resourceService = resourceService;
|
||||||
|
addHostCmd._responseGenerator = responseGenerator;
|
||||||
Host host = Mockito.mock(Host.class);
|
Host host = Mockito.mock(Host.class);
|
||||||
Host[] mockArray = new Host[]{host};
|
Host[] mockArray = new Host[] { host };
|
||||||
|
|
||||||
HostResponse responseHost = new HostResponse();
|
HostResponse responseHost = new HostResponse();
|
||||||
responseHost.setName("Test");
|
responseHost.setName("Test");
|
||||||
Mockito.when(resourceService.discoverHosts(addHostCmd)).thenReturn(Arrays.asList(mockArray));
|
Mockito.when(resourceService.discoverHosts(addHostCmd)).thenReturn(
|
||||||
Mockito.when(responseGenerator.createHostResponse(host)).thenReturn(responseHost);
|
Arrays.asList(mockArray));
|
||||||
addHostCmd.execute();
|
Mockito.when(responseGenerator.createHostResponse(host)).thenReturn(
|
||||||
Mockito.verify(responseGenerator).createHostResponse(host);
|
responseHost);
|
||||||
ListResponse<HostResponse> actualResponse = ((ListResponse<HostResponse>)addHostCmd.getResponseObject());
|
addHostCmd.execute();
|
||||||
Assert.assertEquals(responseHost, actualResponse.getResponses().get(0));
|
Mockito.verify(responseGenerator).createHostResponse(host);
|
||||||
Assert.assertEquals("addhostresponse", actualResponse.getResponseName());
|
ListResponse<HostResponse> actualResponse = ((ListResponse<HostResponse>) addHostCmd
|
||||||
|
.getResponseObject());
|
||||||
|
Assert.assertEquals(responseHost, actualResponse.getResponses().get(0));
|
||||||
|
Assert.assertEquals("addhostresponse", actualResponse.getResponseName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testExecuteForDiscoveryException() {
|
||||||
public void testExecuteForDiscoveryException() {
|
|
||||||
|
addHostCmd._resourceService = resourceService;
|
||||||
addHostCmd._resourceService = resourceService;
|
|
||||||
|
try {
|
||||||
try {
|
Mockito.when(resourceService.discoverHosts(addHostCmd)).thenThrow(
|
||||||
Mockito.when(resourceService.discoverHosts(addHostCmd)).thenThrow(DiscoveryException.class);
|
DiscoveryException.class);
|
||||||
} catch (InvalidParameterValueException e) {
|
} catch (InvalidParameterValueException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (DiscoveryException e) {
|
} catch (DiscoveryException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
addHostCmd.execute();
|
addHostCmd.execute();
|
||||||
} catch(ServerApiException exception) {
|
} catch (ServerApiException exception) {
|
||||||
Assert.assertNull(exception.getDescription());
|
Assert.assertNull(exception.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,90 +29,94 @@ import org.junit.rules.ExpectedException;
|
|||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
|
import com.cloud.api.commands.AddNetworkServiceProviderCmd;
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
import com.cloud.exception.ResourceAllocationException;
|
||||||
import com.cloud.network.NetworkService;
|
import com.cloud.network.NetworkService;
|
||||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||||
|
|
||||||
public class AddNetworkServiceProviderCmdTest extends TestCase {
|
public class AddNetworkServiceProviderCmdTest extends TestCase {
|
||||||
|
|
||||||
private AddNetworkServiceProviderCmd addNetworkServiceProviderCmd;
|
private AddNetworkServiceProviderCmd addNetworkServiceProviderCmd;
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setUp() {
|
public ExpectedException expectedException = ExpectedException.none();
|
||||||
addNetworkServiceProviderCmd = new AddNetworkServiceProviderCmd() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getPhysicalNetworkId() {
|
|
||||||
return 2L;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getProviderName() {
|
|
||||||
return "ProviderName";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getDestinationPhysicalNetworkId() {
|
|
||||||
return 2L;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Before
|
||||||
public List<String> getEnabledServices() {
|
public void setUp() {
|
||||||
List<String> lOfEnabledServices = new ArrayList<String>();
|
addNetworkServiceProviderCmd = new AddNetworkServiceProviderCmd() {
|
||||||
lOfEnabledServices.add("Enabled Services");
|
|
||||||
return lOfEnabledServices;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getEntityId() {
|
|
||||||
return 2L;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
public void testCreateProviderToPhysicalNetworkSuccess() {
|
public Long getPhysicalNetworkId() {
|
||||||
|
return 2L;
|
||||||
NetworkService networkService = Mockito.mock(NetworkService.class);
|
}
|
||||||
addNetworkServiceProviderCmd._networkService = networkService;
|
|
||||||
|
|
||||||
PhysicalNetworkServiceProvider physicalNetworkServiceProvider = Mockito.mock(PhysicalNetworkServiceProvider.class);
|
@Override
|
||||||
Mockito.when(networkService.addProviderToPhysicalNetwork(Mockito.anyLong(),
|
public String getProviderName() {
|
||||||
Mockito.anyString(), Mockito.anyLong(),
|
return "ProviderName";
|
||||||
Mockito.anyList())).thenReturn(
|
}
|
||||||
physicalNetworkServiceProvider);
|
|
||||||
|
|
||||||
try {
|
@Override
|
||||||
addNetworkServiceProviderCmd.create();
|
public Long getDestinationPhysicalNetworkId() {
|
||||||
} catch (ResourceAllocationException e) {
|
return 2L;
|
||||||
e.printStackTrace();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreateProviderToPhysicalNetworkFailure() throws ResourceAllocationException {
|
|
||||||
|
|
||||||
NetworkService networkService = Mockito.mock(NetworkService.class);
|
|
||||||
addNetworkServiceProviderCmd._networkService = networkService;
|
|
||||||
|
|
||||||
Mockito.when(networkService.addProviderToPhysicalNetwork(Mockito.anyLong(),
|
@Override
|
||||||
Mockito.anyString(), Mockito.anyLong(),
|
public List<String> getEnabledServices() {
|
||||||
Mockito.anyList())).thenReturn(null);
|
List<String> lOfEnabledServices = new ArrayList<String>();
|
||||||
|
lOfEnabledServices.add("Enabled Services");
|
||||||
|
return lOfEnabledServices;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getEntityId() {
|
||||||
|
return 2L;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateProviderToPhysicalNetworkSuccess() {
|
||||||
|
|
||||||
|
NetworkService networkService = Mockito.mock(NetworkService.class);
|
||||||
|
addNetworkServiceProviderCmd._networkService = networkService;
|
||||||
|
|
||||||
|
PhysicalNetworkServiceProvider physicalNetworkServiceProvider = Mockito
|
||||||
|
.mock(PhysicalNetworkServiceProvider.class);
|
||||||
|
Mockito.when(
|
||||||
|
networkService.addProviderToPhysicalNetwork(Mockito.anyLong(),
|
||||||
|
Mockito.anyString(), Mockito.anyLong(),
|
||||||
|
Mockito.anyList())).thenReturn(
|
||||||
|
physicalNetworkServiceProvider);
|
||||||
|
|
||||||
|
try {
|
||||||
|
addNetworkServiceProviderCmd.create();
|
||||||
|
} catch (ResourceAllocationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateProviderToPhysicalNetworkFailure()
|
||||||
|
throws ResourceAllocationException {
|
||||||
|
|
||||||
|
NetworkService networkService = Mockito.mock(NetworkService.class);
|
||||||
|
addNetworkServiceProviderCmd._networkService = networkService;
|
||||||
|
|
||||||
|
Mockito.when(
|
||||||
|
networkService.addProviderToPhysicalNetwork(Mockito.anyLong(),
|
||||||
|
Mockito.anyString(), Mockito.anyLong(),
|
||||||
|
Mockito.anyList())).thenReturn(null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
addNetworkServiceProviderCmd.create();
|
||||||
|
} catch (ServerApiException exception) {
|
||||||
|
Assert.assertEquals(
|
||||||
|
"Failed to add service provider entity to physical network",
|
||||||
|
exception.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
addNetworkServiceProviderCmd.create();
|
|
||||||
} catch (ServerApiException exception) {
|
|
||||||
Assert.assertEquals("Failed to add service provider entity to physical network", exception.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,10 +27,8 @@ import org.mockito.Mockito;
|
|||||||
|
|
||||||
import com.cloud.api.ResponseGenerator;
|
import com.cloud.api.ResponseGenerator;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
|
import com.cloud.api.commands.AddSecondaryStorageCmd;
|
||||||
import com.cloud.api.response.HostResponse;
|
import com.cloud.api.response.HostResponse;
|
||||||
import com.cloud.api.response.ListResponse;
|
|
||||||
import com.cloud.exception.DiscoveryException;
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
|
||||||
import com.cloud.host.Host;
|
import com.cloud.host.Host;
|
||||||
import com.cloud.resource.ResourceService;
|
import com.cloud.resource.ResourceService;
|
||||||
|
|
||||||
@ -38,83 +36,89 @@ import edu.emory.mathcs.backport.java.util.Arrays;
|
|||||||
|
|
||||||
public class AddSecondaryStorageCmdTest extends TestCase {
|
public class AddSecondaryStorageCmdTest extends TestCase {
|
||||||
|
|
||||||
private AddSecondaryStorageCmd addSecondaryStorageCmd;
|
private AddSecondaryStorageCmd addSecondaryStorageCmd;
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setUp() {
|
public ExpectedException expectedException = ExpectedException.none();
|
||||||
addSecondaryStorageCmd = new AddSecondaryStorageCmd() {
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Before
|
||||||
@Test
|
public void setUp() {
|
||||||
public void testExecuteForResult() throws Exception {
|
addSecondaryStorageCmd = new AddSecondaryStorageCmd() {
|
||||||
|
};
|
||||||
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
|
||||||
addSecondaryStorageCmd._resourceService = resourceService;
|
|
||||||
|
|
||||||
Host host = Mockito.mock(Host.class);
|
|
||||||
Host[] mockHosts = new Host[] {host};
|
|
||||||
|
|
||||||
Mockito.when(resourceService.discoverHosts(addSecondaryStorageCmd)).thenReturn(Arrays.asList(mockHosts));
|
|
||||||
|
|
||||||
ResponseGenerator responseGenerator = Mockito.mock(ResponseGenerator.class);
|
|
||||||
addSecondaryStorageCmd._responseGenerator = responseGenerator;
|
|
||||||
|
|
||||||
HostResponse responseHost = new HostResponse();
|
|
||||||
responseHost.setName("Test");
|
|
||||||
|
|
||||||
Mockito.when(responseGenerator.createHostResponse(host)).thenReturn(responseHost);
|
}
|
||||||
|
|
||||||
addSecondaryStorageCmd.execute();
|
|
||||||
|
|
||||||
Mockito.verify(responseGenerator).createHostResponse(host);
|
@Test
|
||||||
|
public void testExecuteForResult() throws Exception {
|
||||||
HostResponse actualResponse = (HostResponse)addSecondaryStorageCmd.getResponseObject();
|
|
||||||
|
|
||||||
Assert.assertEquals(responseHost, actualResponse);
|
|
||||||
Assert.assertEquals("addsecondarystorageresponse", actualResponse.getResponseName());
|
|
||||||
|
|
||||||
|
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
||||||
}
|
addSecondaryStorageCmd._resourceService = resourceService;
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExecuteForEmptyResult() throws Exception {
|
|
||||||
|
|
||||||
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
|
||||||
addSecondaryStorageCmd._resourceService = resourceService;
|
|
||||||
|
|
||||||
Host[] mockHosts = new Host[] {};
|
|
||||||
|
|
||||||
Mockito.when(resourceService.discoverHosts(addSecondaryStorageCmd)).thenReturn(Arrays.asList(mockHosts));
|
|
||||||
|
|
||||||
try {
|
|
||||||
addSecondaryStorageCmd.execute();
|
|
||||||
} catch(ServerApiException exception) {
|
|
||||||
Assert.assertEquals("Failed to add secondary storage", exception.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExecuteForNullResult() throws Exception {
|
|
||||||
|
|
||||||
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
Host host = Mockito.mock(Host.class);
|
||||||
addSecondaryStorageCmd._resourceService = resourceService;
|
Host[] mockHosts = new Host[] { host };
|
||||||
|
|
||||||
Mockito.when(resourceService.discoverHosts(addSecondaryStorageCmd)).thenReturn(null);
|
Mockito.when(resourceService.discoverHosts(addSecondaryStorageCmd))
|
||||||
|
.thenReturn(Arrays.asList(mockHosts));
|
||||||
|
|
||||||
|
ResponseGenerator responseGenerator = Mockito
|
||||||
|
.mock(ResponseGenerator.class);
|
||||||
|
addSecondaryStorageCmd._responseGenerator = responseGenerator;
|
||||||
|
|
||||||
|
HostResponse responseHost = new HostResponse();
|
||||||
|
responseHost.setName("Test");
|
||||||
|
|
||||||
|
Mockito.when(responseGenerator.createHostResponse(host)).thenReturn(
|
||||||
|
responseHost);
|
||||||
|
|
||||||
|
addSecondaryStorageCmd.execute();
|
||||||
|
|
||||||
|
Mockito.verify(responseGenerator).createHostResponse(host);
|
||||||
|
|
||||||
|
HostResponse actualResponse = (HostResponse) addSecondaryStorageCmd
|
||||||
|
.getResponseObject();
|
||||||
|
|
||||||
|
Assert.assertEquals(responseHost, actualResponse);
|
||||||
|
Assert.assertEquals("addsecondarystorageresponse",
|
||||||
|
actualResponse.getResponseName());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExecuteForEmptyResult() throws Exception {
|
||||||
|
|
||||||
|
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
||||||
|
addSecondaryStorageCmd._resourceService = resourceService;
|
||||||
|
|
||||||
|
Host[] mockHosts = new Host[] {};
|
||||||
|
|
||||||
|
Mockito.when(resourceService.discoverHosts(addSecondaryStorageCmd))
|
||||||
|
.thenReturn(Arrays.asList(mockHosts));
|
||||||
|
|
||||||
|
try {
|
||||||
|
addSecondaryStorageCmd.execute();
|
||||||
|
} catch (ServerApiException exception) {
|
||||||
|
Assert.assertEquals("Failed to add secondary storage",
|
||||||
|
exception.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExecuteForNullResult() throws Exception {
|
||||||
|
|
||||||
|
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
||||||
|
addSecondaryStorageCmd._resourceService = resourceService;
|
||||||
|
|
||||||
|
Mockito.when(resourceService.discoverHosts(addSecondaryStorageCmd))
|
||||||
|
.thenReturn(null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
addSecondaryStorageCmd.execute();
|
||||||
|
} catch (ServerApiException exception) {
|
||||||
|
Assert.assertEquals("Failed to add secondary storage",
|
||||||
|
exception.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
addSecondaryStorageCmd.execute();
|
|
||||||
} catch(ServerApiException exception) {
|
|
||||||
Assert.assertEquals("Failed to add secondary storage", exception.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,9 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package src.com.cloud.api.commands.test;
|
package src.com.cloud.api.commands.test;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -24,69 +27,71 @@ import org.mockito.Mockito;
|
|||||||
|
|
||||||
import com.cloud.api.ResponseGenerator;
|
import com.cloud.api.ResponseGenerator;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
|
import com.cloud.api.commands.AddSwiftCmd;
|
||||||
import com.cloud.api.response.SwiftResponse;
|
import com.cloud.api.response.SwiftResponse;
|
||||||
import com.cloud.exception.DiscoveryException;
|
import com.cloud.exception.DiscoveryException;
|
||||||
import com.cloud.resource.ResourceService;
|
import com.cloud.resource.ResourceService;
|
||||||
import com.cloud.storage.Swift;
|
import com.cloud.storage.Swift;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
public class AddSwiftCmdTest extends TestCase {
|
public class AddSwiftCmdTest extends TestCase {
|
||||||
|
|
||||||
private AddSwiftCmd addSwiftCmd;
|
private AddSwiftCmd addSwiftCmd;
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setUp() {
|
public ExpectedException expectedException = ExpectedException.none();
|
||||||
addSwiftCmd = new AddSwiftCmd();
|
|
||||||
}
|
@Before
|
||||||
|
public void setUp() {
|
||||||
@Test
|
addSwiftCmd = new AddSwiftCmd();
|
||||||
public void testExecuteSuccess() {
|
}
|
||||||
|
|
||||||
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
@Test
|
||||||
addSwiftCmd._resourceService = resourceService;
|
public void testExecuteSuccess() {
|
||||||
|
|
||||||
Swift swift = Mockito.mock(Swift.class);
|
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
||||||
|
addSwiftCmd._resourceService = resourceService;
|
||||||
try {
|
|
||||||
Mockito.when(resourceService.discoverSwift(addSwiftCmd)).thenReturn(swift);
|
Swift swift = Mockito.mock(Swift.class);
|
||||||
} catch (DiscoveryException e) {
|
|
||||||
e.printStackTrace();
|
try {
|
||||||
}
|
Mockito.when(resourceService.discoverSwift(addSwiftCmd))
|
||||||
|
.thenReturn(swift);
|
||||||
ResponseGenerator responseGenerator = Mockito.mock(ResponseGenerator.class);
|
} catch (DiscoveryException e) {
|
||||||
addSwiftCmd._responseGenerator = responseGenerator;
|
e.printStackTrace();
|
||||||
|
}
|
||||||
SwiftResponse swiftResponse = Mockito.mock(SwiftResponse.class);
|
|
||||||
|
ResponseGenerator responseGenerator = Mockito
|
||||||
Mockito.when(responseGenerator.createSwiftResponse(swift)).thenReturn(swiftResponse);
|
.mock(ResponseGenerator.class);
|
||||||
|
addSwiftCmd._responseGenerator = responseGenerator;
|
||||||
addSwiftCmd.execute();
|
|
||||||
|
SwiftResponse swiftResponse = Mockito.mock(SwiftResponse.class);
|
||||||
}
|
|
||||||
|
Mockito.when(responseGenerator.createSwiftResponse(swift)).thenReturn(
|
||||||
|
swiftResponse);
|
||||||
@Test
|
|
||||||
public void testExecuteFailure() {
|
addSwiftCmd.execute();
|
||||||
|
|
||||||
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
}
|
||||||
addSwiftCmd._resourceService = resourceService;
|
|
||||||
try {
|
@Test
|
||||||
Mockito.when(resourceService.discoverSwift(addSwiftCmd)).thenReturn(null);
|
public void testExecuteFailure() {
|
||||||
} catch (DiscoveryException e) {
|
|
||||||
e.printStackTrace();
|
ResourceService resourceService = Mockito.mock(ResourceService.class);
|
||||||
}
|
addSwiftCmd._resourceService = resourceService;
|
||||||
|
try {
|
||||||
|
Mockito.when(resourceService.discoverSwift(addSwiftCmd))
|
||||||
|
.thenReturn(null);
|
||||||
|
} catch (DiscoveryException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
addSwiftCmd.execute();
|
||||||
|
} catch (ServerApiException exception) {
|
||||||
|
Assert.assertEquals("Failed to add Swift",
|
||||||
|
exception.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
addSwiftCmd.execute();
|
|
||||||
} catch(ServerApiException exception) {
|
|
||||||
Assert.assertEquals("Failed to add Swift", exception.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import org.junit.rules.ExpectedException;
|
|||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
|
import com.cloud.api.commands.AddVpnUserCmd;
|
||||||
import com.cloud.network.VpnUser;
|
import com.cloud.network.VpnUser;
|
||||||
import com.cloud.network.vpn.RemoteAccessVpnService;
|
import com.cloud.network.vpn.RemoteAccessVpnService;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
@ -33,111 +34,115 @@ import com.cloud.user.AccountService;
|
|||||||
|
|
||||||
public class AddVpnUserCmdTest extends TestCase {
|
public class AddVpnUserCmdTest extends TestCase {
|
||||||
|
|
||||||
|
private AddVpnUserCmd addVpnUserCmd;
|
||||||
private AddVpnUserCmd addVpnUserCmd;
|
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setUp() {
|
public ExpectedException expectedException = ExpectedException.none();
|
||||||
|
|
||||||
addVpnUserCmd = new AddVpnUserCmd() {
|
@Before
|
||||||
|
public void setUp() {
|
||||||
@Override
|
|
||||||
public Long getEntityId() {
|
addVpnUserCmd = new AddVpnUserCmd() {
|
||||||
return 2L;
|
|
||||||
}
|
@Override
|
||||||
|
public Long getEntityId() {
|
||||||
@Override
|
return 2L;
|
||||||
public long getEntityOwnerId() {
|
}
|
||||||
return 2L;
|
|
||||||
}
|
@Override
|
||||||
|
public long getEntityOwnerId() {
|
||||||
@Override
|
return 2L;
|
||||||
public String getUserName() {
|
}
|
||||||
return "User Name";
|
|
||||||
}
|
@Override
|
||||||
|
public String getUserName() {
|
||||||
@Override
|
return "User Name";
|
||||||
public String getPassword() {
|
}
|
||||||
return "password";
|
|
||||||
}
|
@Override
|
||||||
|
public String getPassword() {
|
||||||
};
|
return "password";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Test
|
};
|
||||||
public void testExecuteVpnUserNotFound() {
|
}
|
||||||
|
|
||||||
EntityManager entityManager = Mockito.mock(EntityManager.class);
|
/*
|
||||||
|
* @Test public void testExecuteVpnUserNotFound() {
|
||||||
Mockito.when(entityManager.findById(VpnUser.class, Mockito.anyLong())).thenReturn(null);
|
*
|
||||||
|
* EntityManager entityManager = Mockito.mock(EntityManager.class);
|
||||||
addVpnUserCmd._entityMgr = entityManager;
|
*
|
||||||
try {
|
* Mockito.when(entityManager.findById(VpnUser.class,
|
||||||
addVpnUserCmd.execute();
|
* Mockito.anyLong())).thenReturn(null);
|
||||||
} catch (Exception e) {
|
*
|
||||||
}
|
* addVpnUserCmd._entityMgr = entityManager; try { addVpnUserCmd.execute();
|
||||||
|
* } catch (Exception e) { }
|
||||||
}
|
*
|
||||||
|
* }
|
||||||
|
*
|
||||||
@Test
|
*
|
||||||
public void testExecuteVpnUserFound() {
|
* @Test public void testExecuteVpnUserFound() {
|
||||||
|
*
|
||||||
EntityManager entityManager = Mockito.mock(EntityManager.class);
|
* EntityManager entityManager = Mockito.mock(EntityManager.class);
|
||||||
addVpnUserCmd._entityMgr = entityManager;
|
* addVpnUserCmd._entityMgr = entityManager;
|
||||||
|
*
|
||||||
VpnUser vpnUser = Mockito.mock(VpnUser.class);
|
* VpnUser vpnUser = Mockito.mock(VpnUser.class);
|
||||||
Mockito.when(entityManager.findById(VpnUser.class, Mockito.anyLong())).thenReturn(vpnUser);
|
* Mockito.when(entityManager.findById(VpnUser.class,
|
||||||
addVpnUserCmd.execute();
|
* Mockito.anyLong())).thenReturn(vpnUser); addVpnUserCmd.execute();
|
||||||
|
*
|
||||||
}*/
|
* }
|
||||||
|
*/
|
||||||
@Test
|
|
||||||
public void testCreateSuccess() {
|
@Test
|
||||||
|
public void testCreateSuccess() {
|
||||||
|
|
||||||
AccountService accountService = Mockito.mock(AccountService.class);
|
AccountService accountService = Mockito.mock(AccountService.class);
|
||||||
|
|
||||||
Account account = Mockito.mock(Account.class);
|
Account account = Mockito.mock(Account.class);
|
||||||
Mockito.when(accountService.getAccount(Mockito.anyLong())).thenReturn(account);
|
Mockito.when(accountService.getAccount(Mockito.anyLong())).thenReturn(
|
||||||
|
account);
|
||||||
addVpnUserCmd._accountService = accountService;
|
|
||||||
|
addVpnUserCmd._accountService = accountService;
|
||||||
RemoteAccessVpnService ravService = Mockito.mock(RemoteAccessVpnService.class);
|
|
||||||
|
RemoteAccessVpnService ravService = Mockito
|
||||||
VpnUser vpnUser = Mockito.mock(VpnUser.class);
|
.mock(RemoteAccessVpnService.class);
|
||||||
Mockito.when(ravService.addVpnUser(Mockito.anyLong(), Mockito.anyString(), Mockito.anyString())).thenReturn(vpnUser);
|
|
||||||
|
VpnUser vpnUser = Mockito.mock(VpnUser.class);
|
||||||
addVpnUserCmd._ravService = ravService;
|
Mockito.when(
|
||||||
|
ravService.addVpnUser(Mockito.anyLong(), Mockito.anyString(),
|
||||||
addVpnUserCmd.create();
|
Mockito.anyString())).thenReturn(vpnUser);
|
||||||
|
|
||||||
}
|
addVpnUserCmd._ravService = ravService;
|
||||||
|
|
||||||
|
addVpnUserCmd.create();
|
||||||
@Test
|
|
||||||
public void testCreateFailure() {
|
}
|
||||||
|
|
||||||
AccountService accountService = Mockito.mock(AccountService.class);
|
@Test
|
||||||
Account account = Mockito.mock(Account.class);
|
public void testCreateFailure() {
|
||||||
Mockito.when(accountService.getAccount(Mockito.anyLong())).thenReturn(account);
|
|
||||||
|
AccountService accountService = Mockito.mock(AccountService.class);
|
||||||
|
Account account = Mockito.mock(Account.class);
|
||||||
|
Mockito.when(accountService.getAccount(Mockito.anyLong())).thenReturn(
|
||||||
|
account);
|
||||||
|
|
||||||
|
addVpnUserCmd._accountService = accountService;
|
||||||
|
|
||||||
|
RemoteAccessVpnService ravService = Mockito
|
||||||
|
.mock(RemoteAccessVpnService.class);
|
||||||
|
Mockito.when(
|
||||||
|
ravService.addVpnUser(Mockito.anyLong(), Mockito.anyString(),
|
||||||
|
Mockito.anyString())).thenReturn(null);
|
||||||
|
|
||||||
|
addVpnUserCmd._ravService = ravService;
|
||||||
|
|
||||||
|
try {
|
||||||
|
addVpnUserCmd.create();
|
||||||
|
} catch (ServerApiException exception) {
|
||||||
|
Assert.assertEquals("Failed to add vpn user",
|
||||||
|
exception.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
addVpnUserCmd._accountService = accountService;
|
|
||||||
|
|
||||||
RemoteAccessVpnService ravService = Mockito.mock(RemoteAccessVpnService.class);
|
|
||||||
Mockito.when(ravService.addVpnUser(Mockito.anyLong(), Mockito.anyString(), Mockito.anyString())).thenReturn(null);
|
|
||||||
|
|
||||||
addVpnUserCmd._ravService = ravService;
|
|
||||||
|
|
||||||
try {
|
|
||||||
addVpnUserCmd.create();
|
|
||||||
} catch (ServerApiException exception) {
|
|
||||||
Assert.assertEquals("Failed to add vpn user", exception.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user