本文整理汇总了Java中org.oscm.app.iaas.data.Network类的典型用法代码示例。如果您正苦于以下问题:Java Network类的具体用法?Java Network怎么用?Java Network使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Network类属于org.oscm.app.iaas.data包,在下文中一共展示了Network类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNetworks
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
public List<Network> getNetworks() {
List<Network> result = new LinkedList<Network>();
if (configuration != null) {
List<HierarchicalConfiguration> networks = configuration
.configurationsAt("networks.network");
for (HierarchicalConfiguration networkEntry : networks) {
int maxVm = 0;
try {
maxVm = Integer.parseInt(networkEntry
.getString("numOfMaxVm"));
} catch (NumberFormatException e) {
maxVm = Integer.MAX_VALUE;
}
Network network = new Network(networkEntry.getString("name"),
networkEntry.getString("networkCategory"),
networkEntry.getString("networkId"), maxVm);
result.add(network);
}
}
return result;
}
示例2: resolveValidNetworkId_null_deterministic
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
@Test
public void resolveValidNetworkId_null_deterministic() throws Exception {
LPlatformClient lPlatformClient = mock(LPlatformClient.class);
LPlatformConfiguration lPlatformConfiguration = mock(LPlatformConfiguration.class);
VSystemConfiguration vSystemConfiguration = null;
paramHandler.getIaasContext().add(vSystemConfiguration);
List<Network> networks = new ArrayList<>();
networks.add(new Network(NETWORKID1, "net", NETWORKID1, 2));
doReturn(lPlatformClient).when(rorVServerCommunication)
.getLPlatformClient(paramHandler);
doReturn(lPlatformConfiguration).when(lPlatformClient)
.getConfiguration();
doReturn(networks).when(lPlatformConfiguration).getNetworks();
// when
String resolvedId = rorVServerCommunication
.resolveValidNetworkId(paramHandler);
// then
assertEquals(NETWORKID1, resolvedId);
}
示例3: resolveValidNetworkId_empty_deterministic
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
@Test
public void resolveValidNetworkId_empty_deterministic() throws Exception {
LPlatformClient lPlatformClient = mock(LPlatformClient.class);
LPlatformConfiguration lPlatformConfiguration = mock(LPlatformConfiguration.class);
paramHandler.getIaasContext().add(lPlatformConfiguration);
parameters.put(PropertyHandler.NETWORK_ID, new Setting(
PropertyHandler.NETWORK_ID, ""));
List<Network> networks = new ArrayList<>();
networks.add(new Network(NETWORKID1, "net", NETWORKID1, 2));
doReturn(lPlatformClient).when(rorVServerCommunication)
.getLPlatformClient(paramHandler);
doReturn(lPlatformConfiguration).when(lPlatformClient)
.getConfiguration();
doReturn(networks).when(lPlatformConfiguration).getNetworks();
// when
String resolvedId = rorVServerCommunication
.resolveValidNetworkId(paramHandler);
// then
assertEquals(NETWORKID1, resolvedId);
}
示例4: resolveValidNetworkId_null_nondeterministic
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
@Test(expected = APPlatformException.class)
public void resolveValidNetworkId_null_nondeterministic() throws Exception {
LPlatformClient lPlatformClient = mock(LPlatformClient.class);
LPlatformConfiguration lPlatformConfiguration = mock(LPlatformConfiguration.class);
VSystemConfiguration vSystemConfiguration = null;
paramHandler.getIaasContext().add(vSystemConfiguration);
List<Network> networks = new ArrayList<>();
networks.add(new Network(NETWORKID1, "net", NETWORKID1, 2));
networks.add(new Network(NETWORKID2, "net", NETWORKID2, 2));
doReturn(lPlatformClient).when(rorVServerCommunication)
.getLPlatformClient(paramHandler);
doReturn(lPlatformConfiguration).when(lPlatformClient)
.getConfiguration();
doReturn(networks).when(lPlatformConfiguration).getNetworks();
// when
rorVServerCommunication.resolveValidNetworkId(paramHandler);
}
示例5: resolveValidNetworkId_name_deterministic
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
@Test
public void resolveValidNetworkId_name_deterministic() throws Exception {
LPlatformClient lPlatformClient = mock(LPlatformClient.class);
LPlatformConfiguration lPlatformConfiguration = mock(LPlatformConfiguration.class);
VSystemConfiguration vSystemConfiguration = null;
paramHandler.getIaasContext().add(vSystemConfiguration);
parameters.put(PropertyHandler.NETWORK_ID, new Setting(
PropertyHandler.NETWORK_ID, NETWORKID1 + "_name"));
List<Network> networks = new ArrayList<>();
networks.add(new Network(NETWORKID1 + "_name", "net", NETWORKID1, 2));
networks.add(new Network(NETWORKID2 + "_name", "net", NETWORKID2, 2));
doReturn(lPlatformClient).when(rorVServerCommunication)
.getLPlatformClient(paramHandler);
doReturn(lPlatformConfiguration).when(lPlatformClient)
.getConfiguration();
doReturn(networks).when(lPlatformConfiguration).getNetworks();
// when
String resolvedId = rorVServerCommunication
.resolveValidNetworkId(paramHandler);
// then
assertEquals(NETWORKID1, resolvedId);
}
示例6: resolveValidNetworkId_id_deterministic
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
@Test
public void resolveValidNetworkId_id_deterministic() throws Exception {
LPlatformClient lPlatformClient = mock(LPlatformClient.class);
LPlatformConfiguration lPlatformConfiguration = mock(LPlatformConfiguration.class);
VSystemConfiguration vSystemConfiguration = null;
paramHandler.getIaasContext().add(vSystemConfiguration);
parameters.put(PropertyHandler.NETWORK_ID, new Setting(
PropertyHandler.NETWORK_ID, NETWORKID1));
List<Network> networks = new ArrayList<>();
networks.add(new Network(NETWORKID1 + "_name", "net", NETWORKID1, 2));
networks.add(new Network(NETWORKID2 + "_name", "net", NETWORKID2, 2));
doReturn(lPlatformClient).when(rorVServerCommunication)
.getLPlatformClient(paramHandler);
doReturn(lPlatformConfiguration).when(lPlatformClient)
.getConfiguration();
doReturn(networks).when(lPlatformConfiguration).getNetworks();
// when
String resolvedId = rorVServerCommunication
.resolveValidNetworkId(paramHandler);
// then
assertEquals(NETWORKID1, resolvedId);
}
示例7: resolveValidNetworkId_name_nondeterministic
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
@Test(expected = APPlatformException.class)
public void resolveValidNetworkId_name_nondeterministic() throws Exception {
LPlatformClient lPlatformClient = mock(LPlatformClient.class);
LPlatformConfiguration lPlatformConfiguration = mock(LPlatformConfiguration.class);
VSystemConfiguration vSystemConfiguration = null;
paramHandler.getIaasContext().add(vSystemConfiguration);
parameters.put(PropertyHandler.NETWORK_ID, new Setting(
PropertyHandler.NETWORK_ID, NETWORKID1 + "_name"));
List<Network> networks = new ArrayList<>();
networks.add(new Network(NETWORKID1 + "_name", "net", NETWORKID1, 2));
networks.add(new Network(NETWORKID1 + "_name", "net", NETWORKID2, 2));
doReturn(lPlatformClient).when(rorVServerCommunication)
.getLPlatformClient(paramHandler);
doReturn(lPlatformConfiguration).when(lPlatformClient)
.getConfiguration();
doReturn(networks).when(lPlatformConfiguration).getNetworks();
// when
rorVServerCommunication.resolveValidNetworkId(paramHandler);
}
示例8: isNetworkIdValid_Valid
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
@Test
public void isNetworkIdValid_Valid() throws Exception {
// given
LPlatformClient lPlatformClient = mock(LPlatformClient.class);
LPlatformConfiguration lPlatformConfiguration = mock(LPlatformConfiguration.class);
VSystemConfiguration vSystemConfiguration = null;
paramHandler.getIaasContext().add(vSystemConfiguration);
parameters.put(PropertyHandler.NETWORK_ID, new Setting(
PropertyHandler.NETWORK_ID, NETWORKID1));
List<Network> networks = new ArrayList<>();
networks.add(new Network("NETWORKID1", "net", NETWORKID1, 2));
networks.add(new Network("NETWORKID2", "net", NETWORKID2, 2));
doReturn(lPlatformClient).when(rorVServerCommunication)
.getLPlatformClient(paramHandler);
doReturn(lPlatformConfiguration).when(lPlatformClient)
.getConfiguration();
doReturn(networks).when(lPlatformConfiguration).getNetworks();
// when
boolean isNetworkIdValid = rorVServerCommunication
.isNetworkIdValid(paramHandler);
// then
assertTrue(isNetworkIdValid);
}
示例9: isNetworkIdValid_NoNetworkIds
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
@Test
public void isNetworkIdValid_NoNetworkIds() throws Exception {
// given
LPlatformClient lPlatformClient = mock(LPlatformClient.class);
LPlatformConfiguration lPlatformConfiguration = mock(LPlatformConfiguration.class);
VSystemConfiguration vSystemConfiguration = null;
paramHandler.getIaasContext().add(vSystemConfiguration);
parameters.put(PropertyHandler.NETWORK_ID, new Setting(
PropertyHandler.NETWORK_ID, NETWORKID1));
doReturn(lPlatformClient).when(rorVServerCommunication)
.getLPlatformClient(paramHandler);
doReturn(lPlatformConfiguration).when(lPlatformClient)
.getConfiguration();
doReturn(new ArrayList<Network>()).when(lPlatformConfiguration)
.getNetworks();
// when
boolean isNetworkIdValid = rorVServerCommunication
.isNetworkIdValid(paramHandler);
// then
assertFalse(isNetworkIdValid);
}
示例10: getNetworkIds_ConfigurationIsNull
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
@Test
public void getNetworkIds_ConfigurationIsNull() {
// when
lPlatformConfiguration = new LPlatformConfiguration(null);
List<Network> result = lPlatformConfiguration.getNetworks();
// then
assertEquals(0, result.size());
}
示例11: getNetworkIds_NetworkIdIsNull
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
@Test
public void getNetworkIds_NetworkIdIsNull() {
// given
HierarchicalConfiguration configuration = prepareConfiguration(
NETWORKID, null);
// when
lPlatformConfiguration = new LPlatformConfiguration(configuration);
List<Network> result = lPlatformConfiguration.getNetworks();
// then
assertEquals(0, result.size());
}
示例12: getNetworkIds_NetworkIdTrimLengthIsZero
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
@Test
public void getNetworkIds_NetworkIdTrimLengthIsZero() {
// given
HierarchicalConfiguration configuration = prepareConfiguration(
NETWORKID, " ");
// when
lPlatformConfiguration = new LPlatformConfiguration(configuration);
List<Network> result = lPlatformConfiguration.getNetworks();
// then
assertEquals(0, result.size());
}
示例13: getNetworkIds
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
@Test
public void getNetworkIds() {
// given
HierarchicalConfiguration configuration = prepareConfiguration(
NETWORKID, NETWORKID);
prepareNetWorks(configuration, NETWORKS);
// when
lPlatformConfiguration = new LPlatformConfiguration(configuration);
List<Network> result = lPlatformConfiguration.getNetworks();
// then
assertEquals(1, result.size());
assertEquals(NETWORKID, result.get(0).getId());
}
示例14: validateClusterSize
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
@Test
public void validateClusterSize() throws Exception {
// given
VSystemTemplateConfiguration templateConfiguration = mock(VSystemTemplateConfiguration.class);
DiskImage masterImage = mock(DiskImage.class);
doReturn("masterId").when(masterImage).getDiskImageId();
doReturn("master").when(masterImage).getDiskImageName();
doReturn("4").when(masterImage).getMaxCpuCount();
diskImages.put(masterImage.getDiskImageId(), masterImage);
DiskImage slaveImage = mock(DiskImage.class);
doReturn("slaveId").when(slaveImage).getDiskImageId();
doReturn("slave").when(slaveImage).getDiskImageName();
doReturn("4").when(slaveImage).getMaxCpuCount();
diskImages.put(slaveImage.getDiskImageId(), slaveImage);
Network network = new Network("network", "networkCategory",
"networkId", 4);
ArrayList<Network> networkList = new ArrayList<>();
networkList.add(network);
doReturn(networkList).when(templateConfiguration).getNetworks();
VServerConfiguration vserverMaster = mock(VServerConfiguration.class);
doReturn("networkId").when(vserverMaster).getNetworkId();
doReturn(masterImage.getDiskImageId()).when(vserverMaster)
.getDiskImageId();
VServerConfiguration vserverSlave = mock(VServerConfiguration.class);
doReturn("networkId").when(vserverSlave).getNetworkId();
doReturn(slaveImage.getDiskImageId()).when(vserverSlave)
.getDiskImageId();
ArrayList<VServerConfiguration> vServerList = new ArrayList<>();
vServerList.add(vserverMaster);
vServerList.add(vserverSlave);
doReturn(vServerList).when(templateConfiguration).getVServers();
paramHandler.setState(FlowState.VSYSTEM_CREATION_REQUESTED);
parameters.put(PropertyHandler.COUNT_CPU, new Setting(
PropertyHandler.COUNT_CPU, "2"));
parameters.put(PropertyHandler.CLUSTER_SIZE, new Setting(
PropertyHandler.CLUSTER_SIZE, "2"));
parameters.put(
PropertyHandler.MASTER_TEMPLATE_ID,
new Setting(PropertyHandler.MASTER_TEMPLATE_ID, masterImage
.getDiskImageId()));
parameters
.put(PropertyHandler.SLAVE_TEMPLATE_ID,
new Setting(PropertyHandler.SLAVE_TEMPLATE_ID,
slaveImage.getDiskImageId()));
// when
vSystemProcessor.validateClusterSize(paramHandler, true, false,
templateConfiguration);
}
示例15: validateClusterSize_CreateLimitReached
import org.oscm.app.iaas.data.Network; //导入依赖的package包/类
@Test(expected = AbortException.class)
public void validateClusterSize_CreateLimitReached() throws Exception {
// given
VSystemTemplateConfiguration templateConfiguration = mock(VSystemTemplateConfiguration.class);
DiskImage masterImage = mock(DiskImage.class);
doReturn("masterId").when(masterImage).getDiskImageId();
doReturn("master").when(masterImage).getDiskImageName();
doReturn("4").when(masterImage).getMaxCpuCount();
diskImages.put(masterImage.getDiskImageId(), masterImage);
DiskImage slaveImage = mock(DiskImage.class);
doReturn("slaveId").when(slaveImage).getDiskImageId();
doReturn("slave").when(slaveImage).getDiskImageName();
doReturn("4").when(slaveImage).getMaxCpuCount();
diskImages.put(slaveImage.getDiskImageId(), slaveImage);
Network network = new Network("network", "networkCategory",
"networkId", 1);
ArrayList<Network> networkList = new ArrayList<>();
networkList.add(network);
doReturn(networkList).when(templateConfiguration).getNetworks();
VServerConfiguration vserverMaster = mock(VServerConfiguration.class);
doReturn("networkId").when(vserverMaster).getNetworkId();
doReturn(masterImage.getDiskImageId()).when(vserverMaster)
.getDiskImageId();
VServerConfiguration vserverSlave = mock(VServerConfiguration.class);
doReturn("networkId").when(vserverSlave).getNetworkId();
doReturn(slaveImage.getDiskImageId()).when(vserverSlave)
.getDiskImageId();
ArrayList<VServerConfiguration> vServerList = new ArrayList<>();
vServerList.add(vserverMaster);
vServerList.add(vserverSlave);
doReturn(vServerList).when(templateConfiguration).getVServers();
paramHandler.setState(FlowState.VSYSTEM_CREATION_REQUESTED);
parameters.put(PropertyHandler.COUNT_CPU, new Setting(
PropertyHandler.COUNT_CPU, "2"));
parameters.put(PropertyHandler.CLUSTER_SIZE, new Setting(
PropertyHandler.CLUSTER_SIZE, "2"));
parameters.put(
PropertyHandler.MASTER_TEMPLATE_ID,
new Setting(PropertyHandler.MASTER_TEMPLATE_ID, masterImage
.getDiskImageId()));
parameters
.put(PropertyHandler.SLAVE_TEMPLATE_ID,
new Setting(PropertyHandler.SLAVE_TEMPLATE_ID,
slaveImage.getDiskImageId()));
// when
vSystemProcessor.validateClusterSize(paramHandler, true, false,
templateConfiguration);
}