modules/enterprise/server/container/src/main/resources/etc/RHQ-mib.txt
| 17 +
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/test/ResourceManagerBeanTest.java
| 93 +++++++++-
modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java
| 16 +
modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpTrapSender.java
| 4
modules/plugins/jboss-as-7/pom.xml
| 2
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
| 2
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java
| 27 ++
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java
| 45 ++++
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java
| 61 +++++-
modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml
| 15 +
modules/plugins/jboss-as-7/src/test/resources/web.json
| 62 ++++++
11 files changed, 328 insertions(+), 16 deletions(-)
New commits:
commit 47086c02a2ed841262811c5a9ac1b92e22e7368d
Author: Mohamed Hamza Ben Mansour <>
Date: Wed Dec 21 18:19:37 2011 +0100
BZ 744262 - add resource lineage to SNMP traps.
diff --git a/modules/enterprise/server/container/src/main/resources/etc/RHQ-mib.txt
b/modules/enterprise/server/container/src/main/resources/etc/RHQ-mib.txt
index 61fdb09..20bb110 100644
--- a/modules/enterprise/server/container/src/main/resources/etc/RHQ-mib.txt
+++ b/modules/enterprise/server/container/src/main/resources/etc/RHQ-mib.txt
@@ -11,14 +11,14 @@ IMPORTS
FROM SNMPv2-TC;
rhqMIB MODULE-IDENTITY
- LAST-UPDATED "201010180000Z"
+ LAST-UPDATED "201112200000Z"
ORGANIZATION "RHQ-Project"
CONTACT-INFO "http://www.rhq-project.org/"
DESCRIPTION
"The MIB module for RHQ alerts.
This file is part of the RHQ management platform
- Copyright (C) 2005-2010 Red Hat, Inc.
+ Copyright (C) 2005-2011 Red Hat, Inc.
All rights reserved.
"
@@ -26,6 +26,8 @@ rhqMIB MODULE-IDENTITY
DESCRIPTION "Initial version"
REVISION "201010180000Z"
DESCRIPTION "Better trap support"
+ REVISION "201112200000Z"
+ DESCRIPTION "Also emit resource lineage"
::= { snmpModules 1 }
jboss OBJECT IDENTIFIER ::= {enterprises 18016 }
@@ -85,6 +87,14 @@ alertUrl OBJECT-TYPE
"The url of the individual alert"
::= { alert 6 }
+alertHierarchy OBJECT-TYPE
+ SYNTAX DisplayString (SIZE (0..1024))
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The hierarchy of the resource that triggered the alert"
+ ::= { alert 6 }
+
-- conformance information
snmpMIBConformance
@@ -110,7 +120,8 @@ alertGroup OBJECT-GROUP
alertPlatformName,
alertCondition,
alertSeverity,
- alertUrl }
+ alertUrl,
+ alertHierarchy }
STATUS current
DESCRIPTION "A collection of objects providing information about an alert"
::= { snmpMIBGroups 1 }
diff --git
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/test/ResourceManagerBeanTest.java
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/test/ResourceManagerBeanTest.java
index 664be6d..3e753f0 100644
---
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/test/ResourceManagerBeanTest.java
+++
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/test/ResourceManagerBeanTest.java
@@ -22,6 +22,8 @@ import java.util.List;
import java.util.Random;
import javax.persistence.EntityManager;
+import javax.transaction.NotSupportedException;
+import javax.transaction.SystemException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -110,6 +112,95 @@ public class ResourceManagerBeanTest extends
UpdatePluginMetadataTestBase {
assert errors.size() == 0;
}
+
+ public void testResourceLineage() throws Exception {
+ // given a resource id for the leaf resource in a resource hierachy
+ int leafResourceId = givenASampleResourceHierarchy();
+
+ // when
+ List<Resource> resourceLineage =
resourceManager.getResourceLineage(leafResourceId);
+
+ // then
+ StringBuilder stringBuilder = new StringBuilder();
+ for (Resource resource : resourceLineage) {
+ stringBuilder.append(resource.getName());
+ if (resourceLineage.indexOf(resource) != resourceLineage.size() - 1) {
+ stringBuilder.append("::");
+ }
+ }
+ System.err.println(stringBuilder.toString());
+
+ }
+
+ private int givenASampleResourceHierarchy() throws NotSupportedException,
+ SystemException {
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ int leafResoureId = 0;
+ try {
+ ResourceType platformType = createResourceType(em, "platform"
+ + System.currentTimeMillis(), "test", null,
+ ResourceCategory.PLATFORM);
+ ResourceType appserverType = createResourceType(em, "jboss AS 5"
+ + System.currentTimeMillis(), "jbossas5", platformType,
+ ResourceCategory.SERVER);
+ ResourceType jvmType = createResourceType(em,
+ "JVM" + System.currentTimeMillis(), "jbossas5",
+ appserverType, ResourceCategory.SERVICE);
+ ResourceType memType = createResourceType(em, "Memory Subsystem"
+ + System.currentTimeMillis(), "jbossas5", jvmType,
+ ResourceCategory.SERVICE);
+ Agent agent = new Agent("hamza007", "hamzahost", 1, "",
"hamzatoken");
+ em.persist(agent);
+ em.flush();
+
+ Resource platform = createResource(em, platformType, agent,
+ "platformKey" + System.currentTimeMillis(),
+ "host.dev.corp", null);
+ Resource appserver = createResource(em, appserverType, agent,
+ "JEAP" + System.currentTimeMillis(), "JBOSS EAP 5.1.1",
+ platform);
+ Resource jvm = createResource(em, memType, agent, "jvm"
+ + System.currentTimeMillis(), "JBoss AS JVM", appserver);
+ Resource memSubystem = createResource(em, appserverType, agent,
+ "mem" + System.currentTimeMillis(), "Memory Subsystem", jvm);
+ leafResoureId = memSubystem.getId();
+ getTransactionManager().commit();
+ } catch (Exception e) {
+ try {
+ System.out.println("CANNOT Prepare TEST: Cause: " + e);
+ getTransactionManager().rollback();
+ } catch (Exception ignore) {
+ }
+ } finally {
+ em.close();
+ }
+ return leafResoureId;
+ }
+
+ private Resource createResource(EntityManager em, ResourceType platformType,
+ Agent agent, String resourceKey, String resourceName,
+ Resource parent) {
+ Resource resource = new Resource(resourceKey, resourceName, platformType);
+ resource.setUuid("" + new Random().nextInt());
+ resource.setAgent(agent);
+ resource.setParentResource(parent);
+ em.persist(resource);
+ return resource;
+ }
+
+
+ private ResourceType createResourceType(EntityManager em, String name,
+ String pluginName, ResourceType parentResourceType,
+ ResourceCategory resourceCategory) {
+ ResourceType platformType = new ResourceType(name, pluginName,
+ resourceCategory, parentResourceType);
+ ResourceType resourceType = platformType;
+ em.persist(resourceType);
+ return resourceType;
+ }
+
+
private Resource createNewResourceWithNewType() throws Exception {
getTransactionManager().begin();
EntityManager em = getEntityManager();
@@ -173,4 +264,4 @@ public class ResourceManagerBeanTest extends
UpdatePluginMetadataTestBase {
}
}
}
-}
\ No newline at end of file
+}
diff --git
a/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java
b/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java
index 627e23d..1ea5e0b 100644
---
a/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java
+++
b/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java
@@ -60,16 +60,30 @@ public class SnmpSender extends AlertSender {
String platformName = lineage.get(0).getName();
String conditions = alertManager.prettyPrintAlertConditions(alert, false);
String alertUrl = alertManager.prettyPrintAlertURL(alert);
+
+
+ String hierarchy = getResourceHierarchyAsString(lineage);
Date bootTime = new Date(); // TODO: want to use
LookupUtil.getCoreServer().getBootTime() but ServiceMBean is not visible
String result = snmpTrapSender.sendSnmpTrap(alert, alertParameters,
platformName, conditions, bootTime,
- alertUrl);
+ alertUrl, hierarchy);
return SenderResult.getSimpleSuccess(result);
} catch (Throwable t) {
return SenderResult.getSimpleFailure("failed - cause: " + t);
}
}
+ private String getResourceHierarchyAsString(List<Resource> lineage) {
+ StringBuilder stringBuilder = new StringBuilder();
+ for (Resource resource : lineage) {
+ stringBuilder.append(resource.getName());
+ if (lineage.indexOf(resource) != lineage.size() - 1) {
+ stringBuilder.append("::");
+ }
+ }
+ return stringBuilder.toString();
+ }
+
@Override
public String previewConfiguration() {
SnmpInfo info = SnmpInfo.load(alertParameters);
diff --git
a/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpTrapSender.java
b/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpTrapSender.java
index ba4bf84..53bfd85 100644
---
a/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpTrapSender.java
+++
b/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpTrapSender.java
@@ -464,7 +464,7 @@ public class SnmpTrapSender implements PDUFactory {
* @return 'Error code' of the operation
*/
public String sendSnmpTrap(Alert alert, Configuration alertParameters, String
platformName, String conditions,
- Date bootTime, String alertUrl) {
+ Date bootTime, String alertUrl, String hierarchy) {
if (!this.snmpEnabled) {
return "SNMP is not enabled.";
}
@@ -486,6 +486,8 @@ public class SnmpTrapSender implements PDUFactory {
getVariableBindings(baseOid + ".5" + "={s}" +
alert.getAlertDefinition().getPriority().toString().toLowerCase());
// url of the alert detail
getVariableBindings(baseOid + ".6" + "={s}" + alertUrl);
+ // hierarchy of the resource on alert
+ getVariableBindings(baseOid + ".7" + "={s}" + hierarchy);
setSysUpTimeFromBootTime(bootTime); // needs to be called before
checkTrapVariables();
checkTrapVariables(this.vbs);
commit 470dc5a6f40012d3632fef4f07c3b3c6f5951016
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Dec 21 12:10:54 2011 +0100
Add tests for child:key=value groups in config. Also update Jackson.
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index 8220355..f39c296 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -16,7 +16,7 @@
<properties>
<json.version>${project.json.version}</json.version>
- <jackson.version>1.7.4</jackson.version>
+ <jackson.version>1.9.3</jackson.version>
<jboss.sasl.version>1.0.0.Beta9</jboss.sasl.version>
</properties>
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index ee6b902..7e88906 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -765,7 +765,7 @@
<c:simple-property name="mapped-file"
required="false" type="boolean" defaultValue="true"
description="Map to the JSP
source."/>
<c:simple-property name="check-interval"
required="false" type="integer" defaultValue="60"
- description="Check interval for JSP updates
using a background thread."/> <!-- TODO revisit default when
https://issues.jboss.org/browse/AS7-3098 is fixed -->
+ description="Check interval in seconds for
JSP updates using a background thread."/> <!-- TODO revisit default when
https://issues.jboss.org/browse/AS7-3098 is fixed -->
<c:simple-property name="modification-test-interval"
required="false" type="integer" defaultValue="4"
description="Minimum amount of time between
two tests for updates, in seconds."/>
<c:simple-property name="recompile-on-fail"
required="false" type="boolean" defaultValue="false"
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java
index 0266071..e1627e3 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java
@@ -28,6 +28,8 @@ import javax.xml.bind.util.ValidationEventCollector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.node.ObjectNode;
import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
import org.rhq.core.clientapi.agent.metadata.InvalidPluginDescriptorException;
@@ -35,6 +37,7 @@ import org.rhq.core.clientapi.descriptor.DescriptorPackages;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.modules.plugins.jbossas7.json.Address;
import org.rhq.modules.plugins.jbossas7.json.Operation;
/**
@@ -107,6 +110,30 @@ public class AbstractConfigurationHandlingTest {
public JsonNode executeRaw(Operation operation) {
if (content==null)
throw new IllegalStateException("Content not yet set");
+
+ Address address = operation.getAddress();
+ if (address!=null && !address.isEmpty()) {
+ // we need to clone the content and then for the result find the right
sub-content to put into result and
+ // return this one.
+
+ // find the sub-content we want
+ String[] parts = address.getPath().split("=");
+ String key = parts[0];
+ String val = parts[1];
+ JsonNode result = content.get("result");
+ JsonNode keyNode = result.get(key);
+ JsonNode valNode = keyNode.get(val);
+
+ // clone the original content
+ ObjectMapper tmpMapper = new ObjectMapper();
+ JsonNode tmp = tmpMapper.createObjectNode();
+ ((ObjectNode)tmp).putAll(((ObjectNode)content));
+
+ // replace the result with the sub-content
+ ((ObjectNode)tmp).put("result",valNode);
+
+ return tmp;
+ }
return content;
}
}
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java
index 0a46516..ef58967 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java
@@ -416,6 +416,51 @@ public class ConfigurationLoadingTest extends
AbstractConfigurationHandlingTest
}
+ public void test9() throws Exception {
+ String resultString = loadJsonFromFile("web.json");
+ ConfigurationDefinition definition = loadDescriptor("test9");
+
+ ObjectMapper mapper = new ObjectMapper();
+ ComplexResult result = mapper.readValue(resultString,ComplexResult.class);
+ JsonNode json = mapper.valueToTree(result);
+
+ FakeConnection connection = new FakeConnection();
+ connection.setContent(json);
+
+ ConfigurationLoadDelegate delegate = new
ConfigurationLoadDelegate(definition,connection,null);
+ Configuration config = delegate.loadResourceConfiguration();
+ assert config!=null;
+ assert config.getProperties().size()==5 : "Got " +
config.getProperties().size() + " props instead of 5";
+ PropertySimple simple = config.getSimple("check-interval");
+ assert simple !=null;
+ Integer integerValue = simple.getIntegerValue();
+ assert integerValue !=null : "check-interval was null";
+ assert integerValue ==17 : "check-interval was not 17 but " +
integerValue;
+ PropertySimple disabled = config.getSimple("disabled");
+ assert disabled !=null : "disabled was null";
+ Boolean booleanValue = disabled.getBooleanValue();
+ assert booleanValue !=null;
+ assert booleanValue;
+ PropertySimple listings = config.getSimple("listings");
+ assert listings !=null;
+ Boolean booleanValue1 = listings.getBooleanValue();
+ assert booleanValue1 !=null;
+ assert !booleanValue1;
+ PropertySimple simple1 = config.getSimple("max-depth");
+ assert simple1 !=null;
+ Integer integerValue1 = simple1.getIntegerValue();
+ assert integerValue1 !=null;
+ assert integerValue1 ==3;
+ PropertySimple simple2 = config.getSimple("default-virtual-server");
+ assert simple2 !=null;
+ String stringValue = simple2.getStringValue();
+ assert stringValue !=null;
+ assert stringValue.equals("default-host");
+
+
+
+ }
+
private String loadJsonFromFile(String fileName) throws Exception {
InputStream inputStream =
this.getClass().getClassLoader().getResourceAsStream(fileName);
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java
index a512133..09439f3 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java
@@ -31,6 +31,7 @@ import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.modules.plugins.jbossas7.json.Address;
import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
import org.rhq.modules.plugins.jbossas7.json.Operation;
@@ -62,7 +63,7 @@ public class ConfigurationUpdatingTest extends
AbstractConfigurationHandlingTest
conf.put(new PropertySimple("needed","test"));
conf.put(new PropertySimple("optional",null));
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf,
null);
+ CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new
Address());
assert cop.numberOfSteps() == 1;
Operation step1 = cop.step(0);
@@ -89,7 +90,7 @@ public class ConfigurationUpdatingTest extends
AbstractConfigurationHandlingTest
conf.put(propertyList);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf,
null);
+ CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new
Address());
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " +
cop.numberOfSteps();
Operation step1 = cop.step(0);
@@ -120,7 +121,7 @@ public class ConfigurationUpdatingTest extends
AbstractConfigurationHandlingTest
conf.put(propertyMap);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf,
null);
+ CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new
Address());
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " +
cop.numberOfSteps();
Operation step1 = cop.step(0);
@@ -148,7 +149,7 @@ public class ConfigurationUpdatingTest extends
AbstractConfigurationHandlingTest
conf.put(propertyMap);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf,
null);
+ CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new
Address());
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " +
cop.numberOfSteps();
Operation step1 = cop.step(0);
@@ -176,7 +177,7 @@ public class ConfigurationUpdatingTest extends
AbstractConfigurationHandlingTest
conf.put(propertyMap);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf,
null);
+ CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new
Address());
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " +
cop.numberOfSteps();
Operation step1 = cop.step(0);
@@ -207,7 +208,7 @@ public class ConfigurationUpdatingTest extends
AbstractConfigurationHandlingTest
conf.put(propertyList);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf,
null);
+ CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new
Address());
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " +
cop.numberOfSteps();
Operation step1 = cop.step(0);
@@ -240,7 +241,7 @@ public class ConfigurationUpdatingTest extends
AbstractConfigurationHandlingTest
conf.put(propertyList);
conf.put(new PropertySimple("port-offset",0));
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf,
null);
+ CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new
Address());
assert cop.numberOfSteps() == 3 : "#Steps should be 3 but were " +
cop.numberOfSteps();
Operation step1 = cop.step(0);
@@ -289,7 +290,7 @@ public class ConfigurationUpdatingTest extends
AbstractConfigurationHandlingTest
conf.put(propertyList);
conf.put(new PropertySimple("port-offset",0));
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf,
null);
+ CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new
Address());
assert cop.numberOfSteps() == 5 : "#Steps should be 5 but were " +
cop.numberOfSteps();
Operation step1 = cop.step(0);
@@ -317,4 +318,48 @@ public class ConfigurationUpdatingTest extends
AbstractConfigurationHandlingTest
assert step4.getAddress().get(0).equals("socket-binding=https");
assert step5.getAddress().get(0).equals("socket-binding=https");
}
+
+ public void test9() throws Exception {
+
+ ConfigurationDefinition definition = loadDescriptor("test9");
+
+ FakeConnection connection = new FakeConnection();
+
+ ConfigurationWriteDelegate delegate = new
ConfigurationWriteDelegate(definition,connection,null);
+
+ Configuration conf = new Configuration();
+
+ conf.put(new
PropertySimple("default-virtual-server","hulla")); // this is
read-only and must not show up in result
+ conf.put(new PropertySimple("test-prop","Heiko"));
+ conf.put(new PropertySimple("check-interval",23));
+ conf.put(new PropertySimple("disabled",true));
+ conf.put(new PropertySimple("listings",false));
+ conf.put(new PropertySimple("max-depth",17));
+
+ CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new
Address());
+
+ assert cop.numberOfSteps() == 5 : "#Steps should be 5 but were " +
cop.numberOfSteps();
+
+ Operation step1 = cop.step(0);
+ Operation step2 = cop.step(1);
+ Operation step3 = cop.step(2);
+ Operation step4 = cop.step(3);
+ Operation step5 = cop.step(4);
+
+ assert step1.getAddress().isEmpty();
+ assert step2.getAddress().size()==1;
+ assert step3.getAddress().size()==1;
+ assert step4.getAddress().size()==1;
+ assert step5.getAddress().size()==1;
+ assert
step2.getAddress().get(0).equals("configuration=jsp-configuration");
+ assert
step3.getAddress().get(0).equals("configuration=jsp-configuration");
+ assert
step4.getAddress().get(0).equals("configuration=static-resources");
+ assert
step5.getAddress().get(0).equals("configuration=static-resources");
+
+ assert
step1.getAdditionalProperties().get("name").equals("test-prop");
+ assert
step1.getAdditionalProperties().get("value").equals("Heiko");
+ assert
step2.getAdditionalProperties().get("name").equals("check-interval");
+ assert
step2.getAdditionalProperties().get("value").equals("23");
+
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml
b/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml
index 69201e2..53f351a 100644
--- a/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml
@@ -89,6 +89,21 @@
</server>
+ <server class="foo" discovery="foo"
name="test9">
+ <resource-configuration>
+ <c:simple-property name="default-virtual-server"
type="string" readOnly="true"/>
+ <c:simple-property name="test-prop" type="string"
required="true" defaultValue="Hello"/>
+ <c:group name="child:configuration=jsp-configuration">
+ <c:simple-property name="check-interval"
type="integer" units="seconds" readOnly="false"
default="1"/>
+ <c:simple-property name="disabled" type="boolean"
default="false"/>
+ </c:group>
+ <c:group name="child:configuration=static-resources">
+ <c:simple-property name="listings" default="true"
type="boolean"/>
+ <c:simple-property name="max-depth" default="9"
type="integer" />
+ </c:group>
+ </resource-configuration>
+ </server>
+
<server class="foo" discovery="foo"
name="simple1">
<resource-configuration>
diff --git a/modules/plugins/jboss-as-7/src/test/resources/web.json
b/modules/plugins/jboss-as-7/src/test/resources/web.json
new file mode 100644
index 0000000..96f0565
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/resources/web.json
@@ -0,0 +1,62 @@
+{
+ "outcome" : "success",
+ "result" :
+
+
+ {"default-virtual-server" : "default-host",
+ "native" : true,
+ "configuration" : {
+ "container" : {},
+ "static-resources" : {
+ "disabled" : false,
+ "listings" : false,
+ "max-depth" : 3,
+ "read-only" : true,
+ "sendfile" : 49152,
+ "webdav" : false},
+ "jsp-configuration" : {
+ "check-interval" : 17,
+ "development" : false,
+ "disabled" : true,
+ "display-source-fragment" : true,
+ "dump-smap" : false,
+ "error-on-use-bean-invalid-class-attribute" : false,
+ "generate-strings-as-char-arrays" : false,
+ "java-encoding" : "UTF-8",
+ "keep-generated" : true,
+ "mapped-file" : true,
+ "modification-test-interval" : "7",
+ "recompile-on-fail" : false,
+ "smap" : false,
+ "source-vm" : "1.5",
+ "tag-pooling" : true,
+ "target-vm" : "1.5",
+ "trim-spaces" : true,
+ "x-powered-by" : true}
+ },
+ "connector" : {
+ "http" : {
+ "enable-lookups" : true,
+ "enabled" : true,
+ "max-post-size" : 2097152,
+ "max-save-post-size" : 4096,
+ "protocol" : "HTTP/1.1",
+ "redirect-port" : 8443,
+ "scheme" : "http",
+ "secure" : false,
+ "socket-binding" : "http",
+ "ssl" : null,
+ "virtual-server" : null}
+ },
+
+ "virtual-server" : {
+ "default-host" : {
+ "access-log" : null,
+ "alias" : ["localhost","example.com"],
+ "default-web-module" : "ROOT.war",
+ "enable-welcome-root" : true,
+ "rewrite" : null,
+ "sso" : null}
+ }
+ }
+}