use of org.wildfly.extension.camel.config.WildFlyCamelConfigPlugin 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.extension.camel.config.WildFlyCamelConfigPlugin 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.extension.camel.config.WildFlyCamelConfigPlugin 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.extension.camel.config.WildFlyCamelConfigPlugin 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