Search in sources :

Example 16 with HttpService

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);
}
Also used : SingleConfigCode(org.jvnet.hk2.config.SingleConfigCode) HttpService(com.sun.enterprise.config.serverbeans.HttpService) Property(org.jvnet.hk2.config.types.Property) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer) Test(org.junit.Test)

Aggregations

HttpService (com.sun.enterprise.config.serverbeans.HttpService)16 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)10 Property (org.jvnet.hk2.config.types.Property)8 PropertyVetoException (java.beans.PropertyVetoException)5 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)5 Test (org.junit.Test)5 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)4 Config (com.sun.enterprise.config.serverbeans.Config)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 LifecycleException (org.apache.catalina.LifecycleException)3 ActionReport (org.glassfish.api.ActionReport)3 NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)3 SystemProperty (com.sun.enterprise.config.serverbeans.SystemProperty)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 MalformedURLException (java.net.MalformedURLException)2 CommandTarget (org.glassfish.config.support.CommandTarget)2 NetworkListeners (org.glassfish.grizzly.config.dom.NetworkListeners)2 Target (org.glassfish.internal.api.Target)2 SingleConfigCode (org.jvnet.hk2.config.SingleConfigCode)2