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);
}
}
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");
}
}
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);
}
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);
}
}
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);
}
}
Aggregations