use of org.wildfly.extras.config.ConfigContext in project wildfly-camel by wildfly-extras.
the class LayerConfigTest method testApplyLayerConfigChange.
@Test
public void testApplyLayerConfigChange() throws Exception {
ConfigPlugin plugin = new ConfigPlugin() {
@Override
public String getConfigName() {
return "foo";
}
@Override
public List<LayerConfig> getLayerConfigs() {
return Arrays.asList(new LayerConfig("fuse_6.2.1", Type.INSTALLING, -10), new LayerConfig("soa_6.2.1", Type.INSTALLING, -10), new LayerConfig("brms_6.2.1", Type.OPTIONAL, -11));
}
@Override
public boolean applyStandaloneConfigChange(ConfigContext context, boolean enable) {
return false;
}
@Override
public boolean applyDomainConfigChange(ConfigContext context, boolean enable) {
return false;
}
};
// Install/Uninstall scenario.
List<String> layers;
layers = ConfigSupport.applyLayerChanges(plugin, list("foo", "example"), true);
Assert.assertEquals(list("fuse_6.2.1", "soa_6.2.1", "foo", "example"), layers);
layers = ConfigSupport.applyLayerChanges(plugin, layers, false);
Assert.assertEquals(list("foo", "example"), layers);
// Upgrade/Uninstall scenario.
layers = list("foo", "fuse_6.1", "soa", "example");
layers = ConfigSupport.applyLayerChanges(plugin, layers, true);
Assert.assertEquals(list("fuse_6.2.1", "soa_6.2.1", "foo", "example"), layers);
layers = ConfigSupport.applyLayerChanges(plugin, layers, false);
Assert.assertEquals(list("foo", "example"), layers);
// Another Upgrade/Uninstall scenario.
layers = list("foo", "fuse", "example");
layers = ConfigSupport.applyLayerChanges(plugin, layers, true);
Assert.assertEquals(list("fuse_6.2.1", "soa_6.2.1", "foo", "example"), layers);
layers = ConfigSupport.applyLayerChanges(plugin, layers, false);
Assert.assertEquals(list("foo", "example"), layers);
}
use of org.wildfly.extras.config.ConfigContext in project wildfly-camel by wildfly-extras.
the class StandaloneConfigTest method testStandaloneConfig.
@Test
public void testStandaloneConfig() throws Exception {
URL resurl = StandaloneConfigTest.class.getResource("/standalone.xml");
SAXBuilder jdom = new SAXBuilder();
Document doc = jdom.build(resurl);
ConfigPlugin plugin = new WildFlyCamelConfigPlugin();
ConfigContext context = ConfigSupport.createContext(null, Paths.get(resurl.toURI()), doc);
plugin.applyStandaloneConfigChange(context, true);
// Verify extension
assertElementWithAttributeValueNotNull(doc.getRootElement(), "extension", "module", "org.wildfly.extension.camel", NS_DOMAINS);
// Verify system-properties
Element element = ConfigSupport.findChildElement(doc.getRootElement(), "system-properties", NS_DOMAINS);
Assert.assertNotNull("system-properties not null", element);
assertElementWithAttributeValueNotNull(element, "property", "name", "hawtio.realm", NS_DOMAINS);
assertElementWithAttributeValueNotNull(element, "property", "name", "ee8.preview.mode", NS_DOMAINS);
// Verify camel
List<Element> profiles = ConfigSupport.findProfileElements(doc, NS_DOMAINS);
Assert.assertEquals("One profile", 1, profiles.size());
assertElementNotNull(profiles.get(0), "subsystem", NS_CAMEL);
// Verify hawtio-domain
assertElementWithAttributeValueNotNull(doc.getRootElement(), "security-domain", "name", "hawtio-domain", NS_SECURITY);
// outputDocumentContent(doc, System.out);
}
use of org.wildfly.extras.config.ConfigContext in project wildfly-camel by wildfly-extras.
the class StandaloneConfigTest method testUnsupportedNamespaceVersion.
@Test
public void testUnsupportedNamespaceVersion() throws Exception {
URL resurl = StandaloneConfigTest.class.getResource("/standalone.xml");
SAXBuilder jdom = new SAXBuilder();
Document doc = jdom.build(resurl);
doc.getRootElement().getChild("extensions", NS_DOMAIN_60).setNamespace(Namespace.getNamespace("urn:jboss:domain:99.99"));
File modifiedConfig = new File("target/standalone-modified.xml");
outputDocumentContent(doc, new FileOutputStream(modifiedConfig));
jdom = new SAXBuilder();
doc = jdom.build(modifiedConfig);
ConfigContext context = ConfigSupport.createContext(null, modifiedConfig.toPath(), doc);
ConfigPlugin plugin = new WildFlyCamelConfigPlugin();
expectedException.expect(ConfigException.class);
plugin.applyStandaloneConfigChange(context, true);
}
use of org.wildfly.extras.config.ConfigContext in project wildfly-camel by wildfly-extras.
the class StandaloneConfigTest method testRemoveConfig.
@Test
public void testRemoveConfig() throws Exception {
URL resurl = StandaloneConfigTest.class.getResource("/standalone.xml");
SAXBuilder jdom = new SAXBuilder();
Document doc = jdom.build(resurl);
File modifiedConfig = new File("target/standalone-modified.xml");
outputDocumentContent(doc, new FileOutputStream(modifiedConfig));
jdom = new SAXBuilder();
doc = jdom.build(modifiedConfig);
ConfigPlugin plugin = new WildFlyCamelConfigPlugin();
ConfigContext context = ConfigSupport.createContext(null, Paths.get(resurl.toURI()), doc);
plugin.applyStandaloneConfigChange(context, false);
// Verify extension removed
assertElementWithAttributeValueNull(doc.getRootElement(), "extension", "module", "org.wildfly.extension.camel", NS_DOMAINS);
// Verify system-properties removed
Element element = ConfigSupport.findChildElement(doc.getRootElement(), "system-properties", NS_DOMAINS);
Assert.assertNotNull("system-properties not null", element);
assertElementWithAttributeValueNull(element, "property", "name", "hawtio.realm", NS_DOMAINS);
assertElementWithAttributeValueNull(element, "property", "name", "hawtio.offline", NS_DOMAINS);
assertElementWithAttributeValueNull(element, "property", "name", "hawtio.authenticationEnabled", NS_DOMAINS);
assertElementWithAttributeValueNull(element, "property", "name", "ee8.preview.mode", NS_DOMAINS);
List<Element> profiles = ConfigSupport.findProfileElements(doc, NS_DOMAINS);
// Verify camel removed
assertElementNull(profiles.get(0), "subsystem", NS_CAMEL);
// Verify hawtio-domain removed
assertElementWithAttributeValueNull(doc.getRootElement(), "security-domain", "name", "hawtio-domain", NS_SECURITY);
}
use of org.wildfly.extras.config.ConfigContext in project wildfly-camel by wildfly-extras.
the class StandaloneConfigTest method testApplyConfigMultipleTimes.
@Test
public void testApplyConfigMultipleTimes() throws Exception {
URL resurl = StandaloneConfigTest.class.getResource("/standalone.xml");
SAXBuilder jdom = new SAXBuilder();
Document doc = jdom.build(resurl);
ConfigPlugin plugin = new WildFlyCamelConfigPlugin();
ConfigContext context = ConfigSupport.createContext(null, Paths.get(resurl.toURI()), doc);
for (int i = 0; i < 5; i++) {
plugin.applyStandaloneConfigChange(context, true);
}
Assert.assertEquals(1, getElementCount(doc, "extension", null, new Attribute("module", "org.wildfly.extension.camel")));
Assert.assertEquals(1, getElementCount(doc, "system-properties", null, null));
Assert.assertEquals(1, getElementCount(doc, "security-domain", null, new Attribute("name", "hawtio-domain")));
Assert.assertEquals(1, getElementCount(doc, "subsystem", NS_CAMEL, null));
}
Aggregations