本文整理汇总了Java中org.apache.commons.configuration2.XMLConfiguration.addProperty方法的典型用法代码示例。如果您正苦于以下问题:Java XMLConfiguration.addProperty方法的具体用法?Java XMLConfiguration.addProperty怎么用?Java XMLConfiguration.addProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.configuration2.XMLConfiguration
的用法示例。
在下文中一共展示了XMLConfiguration.addProperty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBalancerStorageSequentialSingle
import org.apache.commons.configuration2.XMLConfiguration; //导入方法依赖的package包/类
@Test
public void testBalancerStorageSequentialSingle() throws Exception {
SequentialHostBalancer balancer = new SequentialHostBalancer();
XMLConfiguration xmlConfiguration = new XMLConfiguration();
xmlConfiguration.addProperty("[@balancer]","elm1");
balancer.setConfiguration(xmlConfiguration);
VMwareDatacenterInventory inventory = new VMwareDatacenterInventory();
VMwareHost elm = inventory.addHostSystem((VMwareDatacenterInventoryTest
.createHostSystemProperties("elm1", "128", "1")));
elm.setEnabled(true);
balancer.setInventory(inventory);
elm = balancer.next(properties);
assertNotNull(elm);
assertEquals("elm1", elm.getName());
elm = balancer.next(properties);
assertNotNull(elm);
assertEquals("elm1", elm.getName());
}
示例2: testBalancer_wrongConfig
import org.apache.commons.configuration2.XMLConfiguration; //导入方法依赖的package包/类
@Test
public void testBalancer_wrongConfig() throws Exception {
// wrong configuration values should simply be ignored
EquipartitionHostBalancer balancer = new EquipartitionHostBalancer();
XMLConfiguration xmlConfiguration = new XMLConfiguration();
xmlConfiguration.addProperty("[@hosts]", "host1,host2,host3,host4,host5");
xmlConfiguration.addProperty("[@memoryWeight]", "wrong");
xmlConfiguration.addProperty("[@cpuWeight]", "wrong");
xmlConfiguration.addProperty("[@vmWeight]", "");
balancer.setConfiguration(xmlConfiguration);
}
示例3: getBalancer
import org.apache.commons.configuration2.XMLConfiguration; //导入方法依赖的package包/类
private EquipartitionHostBalancer getBalancer(double memWeight,
double cpuWeight, double vmWeight) throws IOException, ConfigurationException {
EquipartitionHostBalancer balancer = new EquipartitionHostBalancer();
XMLConfiguration xmlConfiguration = new XMLConfiguration();
xmlConfiguration.addProperty("[@hosts]", "host1,host2,host3,host4,host5");
xmlConfiguration.addProperty("[@memoryWeight]", memWeight);
xmlConfiguration.addProperty("[@cpuWeight]", cpuWeight);
xmlConfiguration.addProperty("[@vmWeight]", vmWeight);
balancer.setConfiguration(xmlConfiguration);
return balancer;
}
示例4: getBalancer
import org.apache.commons.configuration2.XMLConfiguration; //导入方法依赖的package包/类
private EquipartitionStorageBalancer getBalancer(String storages)
throws ConfigurationException, IOException {
EquipartitionStorageBalancer balancer = new EquipartitionStorageBalancer();
XMLConfiguration xmlConfiguration = new XMLConfiguration();
xmlConfiguration.addProperty("[@storage]", storages);
balancer.setConfiguration(xmlConfiguration);
return balancer;
}
示例5: testSingle
import org.apache.commons.configuration2.XMLConfiguration; //导入方法依赖的package包/类
@Test
public void testSingle() throws Exception {
SequentialStorageBalancer balancer = new SequentialStorageBalancer();
XMLConfiguration xmlConfiguration = new XMLConfiguration();
xmlConfiguration.addProperty("[@storage]", "elm1");
balancer.setConfiguration(xmlConfiguration);
VMwareDatacenterInventory inventory = new VMwareDatacenterInventory();
VMwareStorage elm = inventory.addStorage("host",
VMwareDatacenterInventoryTest.createDataStoreProperties("elm1",
"100", "100"));
elm.setEnabled(true);
elm.setLimit(VMwareValue.parse("90%"));
balancer.setInventory(inventory);
elm = balancer.next(properties);
assertNotNull(elm);
assertEquals("elm1", elm.getName());
elm = balancer.next(properties);
assertNotNull(elm);
assertEquals("elm1", elm.getName());
}
示例6: testBalancerStorageSequentialMultiple
import org.apache.commons.configuration2.XMLConfiguration; //导入方法依赖的package包/类
@Test
public void testBalancerStorageSequentialMultiple() throws Exception {
SequentialHostBalancer balancer = new SequentialHostBalancer();
XMLConfiguration xmlConfiguration = new XMLConfiguration();
xmlConfiguration.addProperty("[@hosts]", "elm3,elm2,elm1,elm4");
balancer.setConfiguration(xmlConfiguration);
VMwareDatacenterInventory inventory = new VMwareDatacenterInventory();
VMwareHost elm = inventory.addHostSystem((VMwareDatacenterInventoryTest
.createHostSystemProperties("elm1", "128", "1")));
elm.setEnabled(true);
elm = inventory.addHostSystem((VMwareDatacenterInventoryTest
.createHostSystemProperties("elm2", "128", "1")));
elm.setEnabled(true);
elm = inventory.addHostSystem((VMwareDatacenterInventoryTest
.createHostSystemProperties("elm3", "128", "1")));
elm.setEnabled(false);
elm = inventory.addHostSystem((VMwareDatacenterInventoryTest
.createHostSystemProperties("elm4", "128", "1")));
elm.setEnabled(true);
balancer.setInventory(inventory);
elm = balancer.next(properties);
assertNotNull(elm);
assertEquals("elm2", elm.getName());
elm = balancer.next(properties);
assertNotNull(elm);
assertEquals("elm2", elm.getName());
elm = balancer.next(properties);
assertNotNull(elm);
assertEquals("elm2", elm.getName());
}
示例7: testMultiple
import org.apache.commons.configuration2.XMLConfiguration; //导入方法依赖的package包/类
@Test
public void testMultiple() throws Exception {
SequentialStorageBalancer balancer = new SequentialStorageBalancer();
XMLConfiguration xmlConfiguration = new XMLConfiguration();
xmlConfiguration.addProperty("[@storage]", "elm1,elm2,elm3,elm4");
balancer.setConfiguration(xmlConfiguration);
VMwareDatacenterInventory inventory = new VMwareDatacenterInventory();
// elm1 does not provide enough resources with respect to configured
// limit
VMwareStorage elm = inventory.addStorage("host",
VMwareDatacenterInventoryTest.createDataStoreProperties("elm1",
"100", "40"));
elm.setEnabled(true);
elm.setLimit(VMwareValue.parse("50%"));
elm = inventory.addStorage("host", VMwareDatacenterInventoryTest
.createDataStoreProperties("elm2", "100", "100"));
elm.setEnabled(true);
elm.setLimit(VMwareValue.parse("90%"));
elm = inventory.addStorage("host", VMwareDatacenterInventoryTest
.createDataStoreProperties("elm3", "100", "100"));
elm.setEnabled(false);
elm.setLimit(VMwareValue.parse("90%"));
elm = inventory.addStorage("host", VMwareDatacenterInventoryTest
.createDataStoreProperties("elm4", "100", "100"));
elm.setEnabled(true);
elm.setLimit(VMwareValue.parse("90%"));
balancer.setInventory(inventory);
// getting elm2 since elm1 is not applicable
elm = balancer.next(properties);
assertNotNull(elm);
assertEquals("elm2", elm.getName());
elm = balancer.next(properties);
assertNotNull(elm);
assertEquals("elm2", elm.getName());
elm = balancer.next(properties);
assertNotNull(elm);
assertEquals("elm2", elm.getName());
}
示例8: testMultipleReduce
import org.apache.commons.configuration2.XMLConfiguration; //导入方法依赖的package包/类
@Test
public void testMultipleReduce() throws Exception {
SequentialStorageBalancer balancer = new SequentialStorageBalancer();
String balancerConfig = "<host><balancer storage=\"elm1,elm2,elm3\" /></host>";
XMLConfiguration xmlConfiguration = new XMLConfiguration();
xmlConfiguration.addProperty("[@storage]", "elm1,elm2,elm3");
balancer.setConfiguration(xmlConfiguration);
VMwareDatacenterInventory inventory = new VMwareDatacenterInventory();
VMwareStorage elm = inventory.addStorage("host",
VMwareDatacenterInventoryTest.createDataStoreProperties("elm1",
"100", "100"));
elm.setEnabled(true);
elm.setLimit(VMwareValue.parse("90%"));
elm = inventory.addStorage("host", VMwareDatacenterInventoryTest
.createDataStoreProperties("elm2", "100", "100"));
elm.setEnabled(true);
elm.setLimit(VMwareValue.parse("90%"));
balancer.setInventory(inventory);
elm = balancer.next(properties);
assertNotNull(elm);
assertEquals("elm1", elm.getName());
// Now shorten list, so "elm2" is not longer next element
inventory = new VMwareDatacenterInventory();
elm = inventory.addStorage("host", VMwareDatacenterInventoryTest
.createDataStoreProperties("elm3", "100", "100"));
elm.setEnabled(true);
elm.setLimit(VMwareValue.parse("90%"));
balancer.setInventory(inventory);
elm = balancer.next(properties);
assertNotNull(elm);
assertEquals("elm3", elm.getName());
}