use of com.sun.enterprise.config.serverbeans.HttpService in project Payara by payara.
the class DuplicateKeyedElementTest method duplicateKeyTest.
@Test(expected = TransactionFailure.class)
public void duplicateKeyTest() throws TransactionFailure {
HttpService httpService = getHabitat().getService(HttpService.class);
assertNotNull(httpService);
// let's find a acceptable target.
VirtualServer target = null;
for (VirtualServer vs : httpService.getVirtualServer()) {
if (!vs.getProperty().isEmpty()) {
target = vs;
break;
}
}
assertNotNull(target);
final Property prop = target.getProperty().get(0);
Property newProp = (Property) ConfigSupport.apply(new SingleConfigCode<VirtualServer>() {
public Object run(VirtualServer param) throws PropertyVetoException, TransactionFailure {
// first one is fine...
Property dupProp = param.createChild(Property.class);
dupProp.setName(prop.getName());
dupProp.setValue(prop.getValue().toUpperCase());
// this should fail...
param.getProperty().add(dupProp);
return dupProp;
}
}, target);
// if we arrive here, this is an error, we succeeded adding a property with
// the same key name.
assertTrue(false);
}
Aggregations