modules/core/client-api-test-utils/pom.xml
| 44 ---
modules/core/client-api-test-utils/src/main/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java
| 144 ----------
modules/core/client-api/pom.xml
| 32 +-
modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy
| 10
modules/core/client-api/src/test/java/org/rhq/core/clientapi/shared/PluginDescriptorUtil.java
| 144 ++++++++++
modules/core/pom.xml
| 1
modules/enterprise/server/jar/pom.xml
| 3
modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
| 43 ++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
| 5
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java
| 70 ----
10 files changed, 205 insertions(+), 291 deletions(-)
New commits:
commit c06974d2297ded0d3bcafe99e5d4a254aca6e55e
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Oct 28 10:13:19 2010 -0400
Removing circular dependency that was caused by client-api-test-utils
client-api-test-utils was introduced as a shared, test helper module
that is used both by client-api and by server/jar (so far). The problem
is that client-api-test-utils also depends on client-api, creating a
circular dependency. I have moved the single class in
client-api-test-utils into client-api. We are now generating a test jar
that other modules can consume.
diff --git a/modules/core/client-api-test-utils/pom.xml
b/modules/core/client-api-test-utils/pom.xml
deleted file mode 100644
index a7ba0a3..0000000
--- a/modules/core/client-api-test-utils/pom.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-client-api-test-utils</artifactId>
-
- <name>RHQ Client API Test Utils</name>
- <description>Provides a test utility library for client API
classes</description>
-
- <dependencies>
- <dependency>
- <groupId>${rhq.groupId}</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${rhq.groupId}</groupId>
- <artifactId>rhq-core-client-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-jxpath</groupId>
- <artifactId>commons-jxpath</artifactId>
- <version>1.3</version>
- </dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>jboss.jboss-embeddable-ejb3</groupId>
- <artifactId>hibernate-all</artifactId>
- <version>1.0.0.Alpha9</version>
- </dependency>
- </dependencies>
-</project>
diff --git
a/modules/core/client-api-test-utils/src/main/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java
b/modules/core/client-api-test-utils/src/main/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java
deleted file mode 100644
index b67d904..0000000
---
a/modules/core/client-api-test-utils/src/main/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package org.rhq.enterprise.server.configuration.metadata;
-
-import java.io.FileNotFoundException;
-import java.io.StringReader;
-import java.net.URL;
-
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.util.ValidationEventCollector;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
-import org.apache.commons.jxpath.JXPathContext;
-
-import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
-import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser;
-import org.rhq.core.clientapi.descriptor.DescriptorPackages;
-import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
-import org.rhq.core.clientapi.descriptor.plugin.ResourceDescriptor;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-
-public class PluginDescriptorUtil {
-
- /**
- * Loads the plugin descriptor from the specified file. The file path specified
should
- * be a class path relative path. For example, if the descriptor file is located at
- * org.rhq.enterprise.server.configuration.my-descriptor.xml, then you should
specify
- * /org/rhq/enterprise/server/configuration/my-descriptor.xml.
- *
- * @param file The class path relative path of the descriptor file
- * @return The {@link PluginDescriptor}
- */
- public static PluginDescriptor loadPluginDescriptor(String file) {
- try {
- URL pluginDescriptorURL = PluginDescriptorUtil.class.getResource(file);
- if (pluginDescriptorURL == null) {
- throw new FileNotFoundException("File " + file + " not
found");
- }
-
- JAXBContext jaxbContext =
JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
- URL pluginSchemaURL =
PluginDescriptorUtil.class.getClassLoader().getResource("rhq-plugin.xsd");
- Schema pluginSchema =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(
- pluginSchemaURL);
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- ValidationEventCollector vec = new ValidationEventCollector();
- unmarshaller.setEventHandler(vec);
- unmarshaller.setSchema(pluginSchema);
-
- return (PluginDescriptor)
unmarshaller.unmarshal(pluginDescriptorURL.openStream());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Transforms the given string into a plugin descriptor object.
- *
- * @param string The plugin descriptor specified as a string
- * @return The {@link PluginDescriptor}
- */
- public static PluginDescriptor toPluginDescriptor(String string) {
- try {
- JAXBContext jaxbContext =
JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
- URL pluginSchemaURL =
PluginMetadataParser.class.getClassLoader().getResource("rhq-plugin.xsd");
- Schema pluginSchema =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(pluginSchemaURL);
-
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- ValidationEventCollector vec = new ValidationEventCollector();
- unmarshaller.setEventHandler(vec);
- unmarshaller.setSchema(pluginSchema);
-
- StringReader reader = new StringReader(string);
-
- return (PluginDescriptor) unmarshaller.unmarshal(reader);
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Searches for and returns the matching descriptor element (or elements) from the
plugin
- * descriptor. <code>path</code> should be an XPath-like expression. See
- *
http://commons.apache.org/jxpath/users-guide.html for more information on
supported syntax.
- *
- * @param descriptor The plugin descriptor
- * @param path The XPath-ish search expression
- * @return The matching element or elements from the descriptor
- */
- public static Object find(PluginDescriptor descriptor, String path) {
- JXPathContext context = JXPathContext.newContext(descriptor);
- return context.getValue(path);
- }
-
- /**
- * This method does a few things. It first searches the descriptor with the
specified
- * <code>path</code>. When a matching element is found, which is
presumably either a
- * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor} or a
- * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor}, its plugin
- * configuration is retrieved. It then gets parsed and the resulting
- * {@link ConfigurationDefinition} is returned.
- *
- * @param descriptor The plugin descriptor
- * @param path The XPath-ish expression that specifies the path to the element from
which
- * the plugin configuration should be loaded
- * @param configName A name to give the configuration definition
- * @return The parsed {@link ConfigurationDefinition}
- */
- public static ConfigurationDefinition loadPluginConfigDefFor(PluginDescriptor
descriptor, String path,
- String configName) {
- try {
- ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor,
path);
- return ConfigurationMetadataParser.parse(configName,
resourceDescriptor.getPluginConfiguration());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * This method does a few things. It first searches the descriptor with the
specified
- * <code>path</code>. When a matching element is found, which is
presumably either a
- * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor} or a
- * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor}, its resource
- * configuration is retrieved. It then gets parsed and the resulting
- * {@link ConfigurationDefinition} is returned.
- *
- * @param descriptor The plugin descriptor
- * @param path The XPath-ish expression that specifies the path to the element from
which
- * the resource configuration should be loaded
- * @param configName A name to give the configuration definition
- * @return The parsed {@link ConfigurationDefinition}
- */
- public static ConfigurationDefinition loadResourceConfigDefFor(PluginDescriptor
descriptor, String path,
- String configName) {
- try {
- ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor,
path);
- return ConfigurationMetadataParser.parse(configName,
resourceDescriptor.getResourceConfiguration());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
-}
diff --git a/modules/core/client-api/pom.xml b/modules/core/client-api/pom.xml
index 80dda55..568f98b 100644
--- a/modules/core/client-api/pom.xml
+++ b/modules/core/client-api/pom.xml
@@ -63,18 +63,17 @@
</dependency>
<dependency>
- <groupId>${groupId}</groupId>
- <artifactId>rhq-core-client-api-test-utils</artifactId>
- <version>${version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<scope>test</scope>
</dependency>
-
+
+ <dependency>
+ <groupId>commons-jxpath</groupId>
+ <artifactId>commons-jxpath</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -116,6 +115,23 @@
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ <configuration>
+ <includes>
+ <include>org/rhq/core/clientapi/shared/**</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
diff --git
a/modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy
b/modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy
index 2b28537..6b76a78 100644
---
a/modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy
+++
b/modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy
@@ -20,18 +20,10 @@ package org.rhq.core.clientapi.agent.metadata
import static org.testng.Assert.*
-import javax.xml.XMLConstants
-import javax.xml.bind.JAXBContext
-import javax.xml.bind.Unmarshaller
-import javax.xml.bind.util.ValidationEventCollector
-import javax.xml.validation.Schema
-import javax.xml.validation.SchemaFactory
-import org.rhq.core.clientapi.descriptor.DescriptorPackages
-import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor
import org.testng.annotations.Test
import org.rhq.core.domain.configuration.definition.ConfigurationFormat
-import static
org.rhq.enterprise.server.configuration.metadata.PluginDescriptorUtil.toPluginDescriptor
+import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.toPluginDescriptor
class PluginMetadataParserTest {
diff --git
a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/shared/PluginDescriptorUtil.java
b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/shared/PluginDescriptorUtil.java
new file mode 100644
index 0000000..279ff34
--- /dev/null
+++
b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/shared/PluginDescriptorUtil.java
@@ -0,0 +1,144 @@
+package org.rhq.core.clientapi.shared;
+
+import java.io.FileNotFoundException;
+import java.io.StringReader;
+import java.net.URL;
+
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.util.ValidationEventCollector;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.apache.commons.jxpath.JXPathContext;
+
+import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
+import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser;
+import org.rhq.core.clientapi.descriptor.DescriptorPackages;
+import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
+import org.rhq.core.clientapi.descriptor.plugin.ResourceDescriptor;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+
+public class PluginDescriptorUtil {
+
+ /**
+ * Loads the plugin descriptor from the specified file. The file path specified
should
+ * be a class path relative path. For example, if the descriptor file is located at
+ * org.rhq.enterprise.server.configuration.my-descriptor.xml, then you should
specify
+ * /org/rhq/enterprise/server/configuration/my-descriptor.xml.
+ *
+ * @param file The class path relative path of the descriptor file
+ * @return The {@link PluginDescriptor}
+ */
+ public static PluginDescriptor loadPluginDescriptor(String file) {
+ try {
+ URL pluginDescriptorURL = PluginDescriptorUtil.class.getResource(file);
+ if (pluginDescriptorURL == null) {
+ throw new FileNotFoundException("File " + file + " not
found");
+ }
+
+ JAXBContext jaxbContext =
JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
+ URL pluginSchemaURL =
PluginDescriptorUtil.class.getClassLoader().getResource("rhq-plugin.xsd");
+ Schema pluginSchema =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(
+ pluginSchemaURL);
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ ValidationEventCollector vec = new ValidationEventCollector();
+ unmarshaller.setEventHandler(vec);
+ unmarshaller.setSchema(pluginSchema);
+
+ return (PluginDescriptor)
unmarshaller.unmarshal(pluginDescriptorURL.openStream());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Transforms the given string into a plugin descriptor object.
+ *
+ * @param string The plugin descriptor specified as a string
+ * @return The {@link PluginDescriptor}
+ */
+ public static PluginDescriptor toPluginDescriptor(String string) {
+ try {
+ JAXBContext jaxbContext =
JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
+ URL pluginSchemaURL =
PluginMetadataParser.class.getClassLoader().getResource("rhq-plugin.xsd");
+ Schema pluginSchema =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(pluginSchemaURL);
+
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ ValidationEventCollector vec = new ValidationEventCollector();
+ unmarshaller.setEventHandler(vec);
+ unmarshaller.setSchema(pluginSchema);
+
+ StringReader reader = new StringReader(string);
+
+ return (PluginDescriptor) unmarshaller.unmarshal(reader);
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Searches for and returns the matching descriptor element (or elements) from the
plugin
+ * descriptor. <code>path</code> should be an XPath-like expression. See
+ *
http://commons.apache.org/jxpath/users-guide.html for more information on
supported syntax.
+ *
+ * @param descriptor The plugin descriptor
+ * @param path The XPath-ish search expression
+ * @return The matching element or elements from the descriptor
+ */
+ public static Object find(PluginDescriptor descriptor, String path) {
+ JXPathContext context = JXPathContext.newContext(descriptor);
+ return context.getValue(path);
+ }
+
+ /**
+ * This method does a few things. It first searches the descriptor with the
specified
+ * <code>path</code>. When a matching element is found, which is
presumably either a
+ * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor} or a
+ * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor}, its plugin
+ * configuration is retrieved. It then gets parsed and the resulting
+ * {@link ConfigurationDefinition} is returned.
+ *
+ * @param descriptor The plugin descriptor
+ * @param path The XPath-ish expression that specifies the path to the element from
which
+ * the plugin configuration should be loaded
+ * @param configName A name to give the configuration definition
+ * @return The parsed {@link ConfigurationDefinition}
+ */
+ public static ConfigurationDefinition loadPluginConfigDefFor(PluginDescriptor
descriptor, String path,
+ String configName) {
+ try {
+ ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor,
path);
+ return ConfigurationMetadataParser.parse(configName,
resourceDescriptor.getPluginConfiguration());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * This method does a few things. It first searches the descriptor with the
specified
+ * <code>path</code>. When a matching element is found, which is
presumably either a
+ * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor} or a
+ * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor}, its resource
+ * configuration is retrieved. It then gets parsed and the resulting
+ * {@link ConfigurationDefinition} is returned.
+ *
+ * @param descriptor The plugin descriptor
+ * @param path The XPath-ish expression that specifies the path to the element from
which
+ * the resource configuration should be loaded
+ * @param configName A name to give the configuration definition
+ * @return The parsed {@link ConfigurationDefinition}
+ */
+ public static ConfigurationDefinition loadResourceConfigDefFor(PluginDescriptor
descriptor, String path,
+ String configName) {
+ try {
+ ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor,
path);
+ return ConfigurationMetadataParser.parse(configName,
resourceDescriptor.getResourceConfiguration());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index 8797e32..b936f26 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -50,7 +50,6 @@
<module>domain-test-utils</module>
<module>plugin-api</module>
<module>client-api</module>
- <module>client-api-test-utils</module>
<module>plugin-container</module>
<module>gui</module>
<module>plugindoc</module>
diff --git a/modules/enterprise/server/jar/pom.xml
b/modules/enterprise/server/jar/pom.xml
index 123d42e..ac041f1 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -353,8 +353,9 @@
<dependency>
<groupId>${groupId}</groupId>
- <artifactId>rhq-core-client-api-test-utils</artifactId>
+ <artifactId>rhq-core-client-api</artifactId>
<version>${version}</version>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
diff --git
a/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
b/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
index f7ea824..dd0ef01 100644
---
a/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
+++
b/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
@@ -3,7 +3,7 @@ package org.rhq.enterprise.server.resource.metadata
import org.testng.annotations.Test
import org.testng.Assert
-import static
org.rhq.enterprise.server.configuration.metadata.PluginDescriptorUtil.toPluginDescriptor
+import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.toPluginDescriptor
import org.rhq.core.domain.plugin.Plugin
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor
import org.apache.maven.artifact.versioning.ComparableVersion
@@ -97,6 +97,12 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
<event name="serverCEvent" description="an entry was appended
to a log file"/>
</server>
+
+ <server name="ServerD">
+ <service name="ServerD.Child1">
+ <service name="ServerD.GrandChild1"/>
+ </service>
+ </server>
</plugin>
"""
@@ -252,7 +258,11 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
description="Child 2 description"
class="org.rhq.plugins.test.Child2"
discovery="org.rhq.plugins.test.Child2ServiceDiscoveryComponent"/>
- </server>
+ </server>
+
+ <server name="ServerD">
+ <service name="ServerD.GrandChild1"/>
+ </server>
</plugin>
"""
@@ -286,7 +296,7 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
}
@Test(dependsOnMethods = ['upgradePlugin'], groups =
['UpgradePlugin'])
- void upgradeParentType() {
+ void upgradeParentTypeWhenTypeChangesParents() {
assertAssociationEquals(
'ServerB',
'childResourceTypes',
@@ -337,16 +347,27 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
assertEquals "The event definition(s) should have been deleted", 0,
results.size()
}
- def buildPlugin(String pluginFileName, String version, String descriptor) {
- def args = createPlugin("test-plugin", pluginDescriptor, "2.0")
- Assert.assertNotNull args.plugin
- Assert.assertNotNull args.pluginFile
- Assert.assertNotNull args.pluginDescriptor
-
+ @Test(dependsOnMethods = ['upgradePlugin'], groups =
['UpgradePlugin'])
+ void deleteParent() {
def subjectMgr = LookupUtil.subjectManager
- def resourceMetadataMgr = LookupUtil.resourceMetadataManager
+ def resourceTypeMgr = LookupUtil.resourceTypeManager
- resourceMetadataMgr.registerPlugin(subjectMgr.overlord, args.plugin,
args.pluginDescriptor, args.pluginFile, true)
+ def criteria = new ResourceTypeCriteria()
+ criteria.addFilterName "GrandChild1"
+ criteria.addFilterPluginName "TestPlugin"
+ criteria.fetchParentResourceTypes true
+
+ def types = resourceTypeMgr.findResourceTypesByCriteria(subjectMgr.overlord,
criteria)
+
+ assertEquals "Expected to get back one resource type", 1, types.size()
+
+ def type = types[0]
+
+ assertEquals "Expected to find one parent type", 1,
type.parentResourceTypes.size()
+
+ def parentType = type.parentResourceTypes.find { it.name == "ServerD" }
+
+ assertNotNull "Expected to find 'ServerD' as the parent, but found,
$type.parentResourceTypes", parentType
}
/**
diff --git
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
index 1f72c06..3b1d3e7 100644
---
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
+++
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
@@ -32,7 +32,6 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
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.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionEnumeration;
@@ -44,8 +43,8 @@ import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.test.AssertUtils;
-import static
org.rhq.enterprise.server.configuration.metadata.PluginDescriptorUtil.loadPluginConfigDefFor;
-import static
org.rhq.enterprise.server.configuration.metadata.PluginDescriptorUtil.loadPluginDescriptor;
+import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.loadPluginConfigDefFor;
+import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.loadPluginDescriptor;
import static java.util.Arrays.asList;
/**
diff --git
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java
deleted file mode 100644
index 8eb4632..0000000
---
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.rhq.enterprise.server.configuration.metadata;
-
-import java.io.FileNotFoundException;
-import java.net.URL;
-
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.util.ValidationEventCollector;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
-import org.apache.commons.jxpath.JXPathContext;
-
-import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
-import org.rhq.core.clientapi.descriptor.DescriptorPackages;
-import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
-import org.rhq.core.clientapi.descriptor.plugin.ResourceDescriptor;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-
-public class PluginDescriptorUtil {
-
- public static PluginDescriptor loadPluginDescriptor(String file) {
- try {
- URL pluginDescriptorURL = PluginDescriptorUtil.class.getResource(file);
- if (pluginDescriptorURL == null) {
- throw new FileNotFoundException("File " + file + " not
found");
- }
-
- JAXBContext jaxbContext =
JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
- URL pluginSchemaURL =
PluginDescriptorUtil.class.getClassLoader().getResource("rhq-plugin.xsd");
- Schema pluginSchema =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(
- pluginSchemaURL);
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- ValidationEventCollector vec = new ValidationEventCollector();
- unmarshaller.setEventHandler(vec);
- unmarshaller.setSchema(pluginSchema);
-
- return (PluginDescriptor)
unmarshaller.unmarshal(pluginDescriptorURL.openStream());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public static Object find(PluginDescriptor descriptor, String path) {
- JXPathContext context = JXPathContext.newContext(descriptor);
- return context.getValue(path);
- }
-
- public static ConfigurationDefinition loadPluginConfigDefFor(PluginDescriptor
descriptor, String path,
- String configName) {
- try {
- ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor,
path);
- return ConfigurationMetadataParser.parse(configName,
resourceDescriptor.getPluginConfiguration());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public static ConfigurationDefinition loadResourceConfigDefFor(PluginDescriptor
descriptor, String path,
- String configName) {
- try {
- ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor,
path);
- return ConfigurationMetadataParser.parse(configName,
resourceDescriptor.getResourceConfiguration());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
-}