modules/plugins/mod-cluster/pom.xml | 78 +++++++++ modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml | 15 - modules/plugins/pom.xml | 3 modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java | 22 ++ modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java | 82 ++++++++++ 5 files changed, 191 insertions(+), 9 deletions(-)
New commits: commit 93ac1b5c3ba6032e3c726f32e01d73e16d73e076 Author: Stefan Negrea snegrea@redhat.com Date: Wed Jul 6 15:28:48 2011 -0500
A couple more tweaks to make the user interface for mod_cluster display correct and proper text.
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml index cdfa7fb..b2179c3 100644 --- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml @@ -24,7 +24,7 @@
<plugin-configuration> <c:simple-property name="objectName" readOnly="true" default="Catalina:type=ModClusterListener,*"/> - <c:simple-property name="nameTemplate" default="{application}"/> + <c:simple-property name="nameTemplate" default="mod_cluster"/> </plugin-configuration>
<operation name="reset" displayName="Reset the node" description="Move the node out of an error state" /> @@ -50,22 +50,22 @@ <c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/> </resource-configuration>
- <service name="mod_cluster_context" + <service name="mod_cluster Webapp Context" discovery="ContextDiscoveryComponent" class="ContextComponent" description="A mod_cluster context">
- <operation name="enableContext" displayName="Enable webapp" description="Enable a single webapp"> + <operation name="enableContext" displayName="Enable webapp" description="Enable the webapp"> <results> <c:simple-property name="result" type="boolean" description="The result of the operation" /> </results> </operation> - <operation name="disableContext" displayName="Disable webpapp" description="Disable a single webapp"> + <operation name="disableContext" displayName="Disable webpapp" description="Disable the webapp"> <results> <c:simple-property name="result" type="boolean" description="The result of the operation" /> </results> </operation> - <operation name="stopContext" displayName="Stop webpapp" description="Gracefully stops a single webapp"> + <operation name="stopContext" displayName="Stop webpapp" description="Gracefully stops the webapp"> <results> <c:simple-property name="result" type="boolean" description="The result of the operation" /> </results>
commit bed08a054ca397b313d97022c29ad61f1b7e6a81 Author: Stefan Negrea snegrea@redhat.com Date: Wed Jul 6 13:19:07 2011 -0500
Fine tuning the plugin configuration based other plugin configuration and test deployment issues.
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml index 74defeb..4536125 100644 --- a/modules/plugins/mod-cluster/pom.xml +++ b/modules/plugins/mod-cluster/pom.xml @@ -12,7 +12,7 @@ <artifactId>modcluster-plugin</artifactId> <packaging>jar</packaging>
- <name>mod_cluster RHQ Plugin</name> + <name>RHQ mod_cluster Plugin</name> <description>mod_cluster RHQ Agent plugin</description>
<dependencies> diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml index be4b25b..cdfa7fb 100644 --- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml @@ -14,11 +14,12 @@ discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent" class="ModclusterServerComponent" supportsManualAdd="true" - description="mod_cluster plugin"> + description="mod_cluster plugin" + singleton="true">
<runs-inside> <parent-resource-type name="JBossAS Server" plugin="JBossAS"/> - <parent-resource-type name="JBossAS Server" plugin="JBossAS5"/> + <parent-resource-type name="JBossAS5 Server" plugin="JBossAS5"/> </runs-inside>
<plugin-configuration> diff --git a/modules/plugins/pom.xml b/modules/plugins/pom.xml index 02f6584..f32159e 100644 --- a/modules/plugins/pom.xml +++ b/modules/plugins/pom.xml @@ -125,10 +125,11 @@ <module>augeas</module> <module>apache</module> <module>tomcat</module> - <module>jboss-as</module> <module>hibernate</module> + <module>mod-cluster</module> <module>rhq-server</module> <module>jboss-cache</module> + <module>jboss-as</module> <module>jboss-as-5</module> <module>jboss-as-7</module> <module>jboss-cache-v3</module>
commit af18d25dc8b66f9d95477e90356f6aecccf6077c Merge: 7f4c0a9 67e6127 Author: Stefan Negrea snegrea@redhat.com Date: Wed Jul 6 10:01:46 2011 -0500
Merge branch 'master' into mod_cluster_plugin
commit 7f4c0a99bb2121fd3496d3bc1af3079f4e922c3a Author: Stefan Negrea snegrea@redhat.com Date: Wed Jul 6 10:00:21 2011 -0500
Added dev profile for plugin deployment in the local plugin repo.
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml index a19dfc0..74defeb 100644 --- a/modules/plugins/mod-cluster/pom.xml +++ b/modules/plugins/mod-cluster/pom.xml @@ -190,6 +190,82 @@ </plugins> </build> </profile> + + + <profile> + <id>dev</id> + + <properties> + <rhq.rootDir>../../..</rhq.rootDir> + <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir> + <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins</rhq.deploymentDir> + </properties> + + <build> + <plugins> + + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.1</version> + <executions> + + <execution> + <id>deploy</id> + <phase>compile</phase> + <configuration> + <tasks> + <mkdir dir="${rhq.deploymentDir}" /> + <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> + <echo>*** Updating ${deployment.file}...</echo> + <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" /> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + + <execution> + <id>deploy-jar-meta-inf</id> + <phase>package</phase> + <configuration> + <tasks> + <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> + <echo>*** Updating META-INF dir in ${deployment.file}...</echo> + <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}"> + <patternset><include name="META-INF/**" /></patternset> + </unjar> + <jar destfile="${deployment.file}" manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF" update="true"> + </jar> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + + <execution> + <id>undeploy</id> + <phase>clean</phase> + <configuration> + <tasks> + <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> + <echo>*** Deleting ${deployment.file}...</echo> + <delete file="${deployment.file}" /> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + + </executions> + </plugin> + + </plugins> + </build> + </profile> + </profiles>
</project>
commit 67e6127f6ec3fb8a2186f1a583bda88d76ef2696 Author: John Sanda jsanda@redhat.com Date: Fri Jul 1 21:07:04 2011 -0400
Initial commit for CollectionMatchersChecker
Adding a new assert in AssertUtils that verifies whether two collections match. assertCollectionMatchesNoOrder compares the elements of two collections, doing a property-wise comparison similar to how assertPropertiesMatch does.
diff --git a/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java b/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java index c86114e..fc41623 100644 --- a/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java +++ b/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java @@ -101,4 +101,26 @@ public class AssertUtils { assertTrue(result.isEqual(), msg + " -- " + result.getDetails()); }
+ /** + * Verifies that the two collections contain the same number of matching elements as is + * done in {@link #assertPropertiesMatch(String, Object, Object, String...)}. If the + * collections differ in size, an assertion error will be thrown; otherwise, elements + * are compared, ignoring order. Note that all element properties are are compared in + * this method. + * + * @param expected The expected collection to compare against + * @param actual The actual collection under test + * @param msg An error message + * @param <T> The type of the elements in the collections + */ + public static <T> void assertCollectionMatchesNoOrder(Collection<T> expected, Collection<T> actual, String msg) { + CollectionMatchesChecker<T> checker = new CollectionMatchesChecker<T>(); + checker.setExpected(expected); + checker.setActual(actual); + + MatchResult result = checker.execute(); + + assertTrue(result.isMatch(), msg + " -- " + result.getDetails()); + } + } diff --git a/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java b/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java new file mode 100644 index 0000000..b4b5fcc --- /dev/null +++ b/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java @@ -0,0 +1,82 @@ +package org.rhq.test; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class CollectionMatchesChecker<T> { + + private Collection<T> expected; + + private Collection<T> actual; + + public void setExpected(Collection<T> expected) { + this.expected = expected; + } + + public void setActual(Collection<T> actual) { + this.actual = actual; + } + + public MatchResult execute() { + boolean isMatch = true; + StringBuilder details = new StringBuilder(); + + if (expected.size() != actual.size()) { + isMatch = false; + details.append("Expected " + expected.size() + " elements but found " + actual.size() + " elements\n"); + } + + List<T> elementsThatShouldBePresent = findMissingElements(expected, actual); + if (!elementsThatShouldBePresent.isEmpty()) { + isMatch = false; + details.append("Expected to find the following elements:\n\t" + + toString(elementsThatShouldBePresent) + "\n\n"); + } + + List<T> elementsThatShouldNotBePresent = findMissingElements(actual, expected); + if (!elementsThatShouldNotBePresent.isEmpty()) { + isMatch = false; + details.append("Did not expect to find the following elements:\n\t" + + toString(elementsThatShouldNotBePresent) + "\n\n"); + } + + return new MatchResult(isMatch, details.toString()); + } + + private List<T> findMissingElements(Collection<T> elementsToSearchFor, Collection<T> elementsToSearch) { + List<T> missingElements = new ArrayList<T>(); + for (T element : elementsToSearchFor) { + if (!containsMatch(elementsToSearch, element)) { + missingElements.add(element); + } + } + return missingElements; + } + + private boolean containsMatch(Collection<T> elementsToSearch, T elementToSearchFor) { + for (T actual : elementsToSearch) { + PropertyMatcher<T> matcher = new PropertyMatcher<T>(); + matcher.setExpected(elementToSearchFor); + matcher.setActual(actual); + MatchResult result = matcher.execute(); + + if (result.isMatch()) { + return true; + } + } + return false; + } + + private String toString(List<T> list) { + StringBuilder buffer = new StringBuilder("["); + for (T element : list) { + buffer.append(element.toString() + ", "); + } + buffer.delete(buffer.length() - 2, buffer.length()); + buffer.append("]"); + + return buffer.toString(); + } + +}