Search in sources :

Example 11 with ConfigSupport

use of org.jvnet.hk2.config.ConfigSupport in project Payara by payara.

the class ReferenceConstrainClusterTest method clusterConfigRefValid.

@Test
public void clusterConfigRefValid() throws TransactionFailure {
    Cluster cluster = habitat.getService(Cluster.class, "clusterA");
    assertNotNull(cluster);
    ConfigBean serverConfig = (ConfigBean) ConfigBean.unwrap(cluster);
    Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
    Map<String, String> configChanges = new HashMap<String, String>();
    configChanges.put("config-ref", "server-config");
    changes.put(serverConfig, configChanges);
    try {
        ConfigSupport cs = getHabitat().getService(ConfigSupport.class);
        cs.apply(changes);
    } catch (TransactionFailure tf) {
        fail("Can not reach this point");
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ConfigSupport(org.jvnet.hk2.config.ConfigSupport) HashMap(java.util.HashMap) Cluster(com.sun.enterprise.config.serverbeans.Cluster) ConfigBean(org.jvnet.hk2.config.ConfigBean) HashMap(java.util.HashMap) Map(java.util.Map) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 12 with ConfigSupport

use of org.jvnet.hk2.config.ConfigSupport in project Payara by payara.

the class ReferenceConstrainClusterTest method clusterConfigRefInvalid.

@Test
public void clusterConfigRefInvalid() throws TransactionFailure {
    Cluster cluster = habitat.getService(Cluster.class, "clusterA");
    assertNotNull(cluster);
    ConfigBean serverConfig = (ConfigBean) ConfigBean.unwrap(cluster);
    Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
    Map<String, String> configChanges = new HashMap<String, String>();
    configChanges.put("config-ref", "server-config-nonexist");
    changes.put(serverConfig, configChanges);
    try {
        ConfigSupport cs = getHabitat().getService(ConfigSupport.class);
        cs.apply(changes);
        fail("Can not reach this point");
    } catch (TransactionFailure tf) {
        ConstraintViolationException cv = findConstrViolation(tf);
        assertNotNull(cv);
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ConfigSupport(org.jvnet.hk2.config.ConfigSupport) HashMap(java.util.HashMap) Cluster(com.sun.enterprise.config.serverbeans.Cluster) ConstraintViolationException(javax.validation.ConstraintViolationException) ConfigBean(org.jvnet.hk2.config.ConfigBean) HashMap(java.util.HashMap) Map(java.util.Map) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)12 ConfigBean (org.jvnet.hk2.config.ConfigBean)12 ConfigSupport (org.jvnet.hk2.config.ConfigSupport)12 Map (java.util.Map)11 Test (org.junit.Test)10 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)10 ConfigApiTest (com.sun.enterprise.configapi.tests.ConfigApiTest)8 ConstraintViolationException (javax.validation.ConstraintViolationException)5 Cluster (com.sun.enterprise.config.serverbeans.Cluster)4 Domain (com.sun.enterprise.config.serverbeans.Domain)2 JavaConfig (com.sun.enterprise.config.serverbeans.JavaConfig)2 JmxConnector (com.sun.enterprise.config.serverbeans.JmxConnector)2 Server (com.sun.enterprise.config.serverbeans.Server)2 ServerRef (com.sun.enterprise.config.serverbeans.ServerRef)2 JdbcResource (org.glassfish.jdbc.config.JdbcResource)2 ConfigApiTest (org.glassfish.jdbcruntime.config.ConfigApiTest)2 AdminService (com.sun.enterprise.config.serverbeans.AdminService)1 ArrayList (java.util.ArrayList)1 Http (org.glassfish.grizzly.config.dom.Http)1 NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)1