Search in sources :

Example 1 with ConfigSupport

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

the class ReferenceConstrainClusterTest method clusterServerRefInvalid.

@Test
public void clusterServerRefInvalid() throws TransactionFailure {
    Cluster cluster = habitat.getService(Cluster.class, "clusterA");
    assertNotNull(cluster);
    ServerRef sref = cluster.getServerRef().get(0);
    ConfigBean serverConfig = (ConfigBean) ConfigBean.unwrap(sref);
    Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
    Map<String, String> configChanges = new HashMap<String, String>();
    configChanges.put("ref", "server-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) ServerRef(com.sun.enterprise.config.serverbeans.ServerRef) HashMap(java.util.HashMap) Map(java.util.Map) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 2 with ConfigSupport

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

the class ReferenceConstrainClusterTest method clusterServerRefValid.

@Test
public void clusterServerRefValid() throws TransactionFailure {
    Cluster cluster = habitat.getService(Cluster.class, "clusterA");
    assertNotNull(cluster);
    ServerRef sref = cluster.getServerRef().get(0);
    ConfigBean serverConfig = (ConfigBean) ConfigBean.unwrap(sref);
    Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
    Map<String, String> configChanges = new HashMap<String, String>();
    configChanges.put("ref", "server");
    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) ServerRef(com.sun.enterprise.config.serverbeans.ServerRef) HashMap(java.util.HashMap) Map(java.util.Map) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 3 with ConfigSupport

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

the class DirectCreationTest method doTest.

public void doTest() throws TransactionFailure {
    AdminService service = habitat.getService(AdminService.class);
    ConfigBean serviceBean = (ConfigBean) ConfigBean.unwrap(service);
    Class<?>[] subTypes = null;
    try {
        subTypes = ConfigSupport.getSubElementsTypes(serviceBean);
    } catch (ClassNotFoundException e) {
        // To change body of catch statement use File | Settings | File Templates.
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    ConfigSupport support = getBaseServiceLocator().getService(ConfigSupport.class);
    assertNotNull("ConfigSupport not found", support);
    for (Class<?> subType : subTypes) {
        // TODO:  JL force compilation error to mark this probably edit point for grizzly config
        if (subType.getName().endsWith("DasConfig")) {
            Map<String, String> configChanges = new HashMap<String, String>();
            configChanges.put("dynamic-reload-enabled", "true");
            configChanges.put("autodeploy-dir", "funky-dir");
            support.createAndSet(serviceBean, (Class<? extends ConfigBeanProxy>) subType, configChanges);
            break;
        }
    }
    support.createAndSet(serviceBean, DasConfig.class, (List) null);
    List<AttributeChanges> profilerChanges = new ArrayList<AttributeChanges>();
    String[] values = { "-Xmx512m", "-RFtrq", "-Xmw24" };
    ConfigSupport.MultipleAttributeChanges multipleChanges = new ConfigSupport.MultipleAttributeChanges("jvm-options", values);
    String[] values1 = { "profile" };
    ConfigSupport.MultipleAttributeChanges multipleChanges1 = new ConfigSupport.MultipleAttributeChanges("name", values1);
    profilerChanges.add(multipleChanges);
    profilerChanges.add(multipleChanges1);
    support.createAndSet((ConfigBean) ConfigBean.unwrap(habitat.<JavaConfig>getService(JavaConfig.class)), Profiler.class, profilerChanges);
}
Also used : AdminService(com.sun.enterprise.config.serverbeans.AdminService) ConfigSupport(org.jvnet.hk2.config.ConfigSupport) AttributeChanges(org.jvnet.hk2.config.AttributeChanges) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ConfigBean(org.jvnet.hk2.config.ConfigBean) JavaConfig(com.sun.enterprise.config.serverbeans.JavaConfig)

Example 4 with ConfigSupport

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

the class ReferenceConstrainTest method jmxConnectorAuthRealmRefInvalid.

@Test
public void jmxConnectorAuthRealmRefInvalid() throws TransactionFailure {
    JmxConnector jmxConnector = habitat.getService(JmxConnector.class, "system");
    assertNotNull(jmxConnector);
    ConfigBean serverConfig = (ConfigBean) ConfigBean.unwrap(jmxConnector);
    Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
    Map<String, String> configChanges = new HashMap<String, String>();
    configChanges.put("auth-realm-name", "realm-not-exist");
    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) ConstraintViolationException(javax.validation.ConstraintViolationException) JmxConnector(com.sun.enterprise.config.serverbeans.JmxConnector) 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 5 with ConfigSupport

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

the class ReferenceConstrainTest method serverConfigRefInvalid.

@Test
public void serverConfigRefInvalid() throws TransactionFailure {
    Server server = habitat.getService(Server.class, "server");
    assertNotNull(server);
    ConfigBean serverConfig = (ConfigBean) ConfigBean.unwrap(server);
    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) Server(com.sun.enterprise.config.serverbeans.Server) HashMap(java.util.HashMap) 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