Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 583917 Details for
Bug 818952
basic c:group support for BaseComponent and AS7 plugin is not currently working
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
itests for c:group checking.
BZ-818952-commit.txt (text/plain), 13.34 KB, created by
Simeon Pinder
on 2012-05-11 20:06:27 UTC
(
hide
)
Description:
itests for c:group checking.
Filename:
MIME Type:
Creator:
Simeon Pinder
Created:
2012-05-11 20:06:27 UTC
Size:
13.34 KB
patch
obsolete
>commit 5f9c79dc01e5dd8bf0beccd25d5ef6b35d8f19c8 >Author: Simeon Pinder <spinder@redhat.com> >Date: Fri May 11 16:06:36 2012 -0400 > > [BZ 818952] adding Config Load and Update itests for regular cgroups. > >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 554ce52..5eaa0e9 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 >@@ -42,6 +42,7 @@ import org.rhq.core.clientapi.agent.metadata.InvalidPluginDescriptorException; > 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.clientapi.descriptor.plugin.ServiceDescriptor; > import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; > import org.rhq.modules.plugins.jbossas7.json.Address; > import org.rhq.modules.plugins.jbossas7.json.Operation; >@@ -85,6 +86,23 @@ public abstract class AbstractConfigurationHandlingTest { > return ConfigurationMetadataParser.parse("null", serverDescriptor.getResourceConfiguration()); > } > >+ /* Attempts to load a service descriptor with name passed in. >+ */ >+ protected ConfigurationDefinition loadServiceDescriptorElement(String serviceName) >+ throws InvalidPluginDescriptorException { >+ >+ //locate the services >+ List<ServiceDescriptor> services = pluginDescriptor.getServices(); >+ >+ //locate the specific entry >+ ServiceDescriptor serviceDescriptor = findServiceEntry(serviceName, services); >+ >+ assert serviceDescriptor != null : "Service descriptor not found in test plugin descriptor"; >+ >+ //? Validate the returned value? >+ return ConfigurationMetadataParser.parse("null", serviceDescriptor.getResourceConfiguration()); >+ } >+ > private ServerDescriptor findServer(String name, List<ServerDescriptor> servers) { > for (ServerDescriptor server : servers) { > if (server.getName().equals(name)) { >@@ -95,6 +113,18 @@ public abstract class AbstractConfigurationHandlingTest { > return null; > } > >+ /* Search for Service entries by name specified. >+ */ >+ private ServiceDescriptor findServiceEntry(String name, List<ServiceDescriptor> services) { >+ for (ServiceDescriptor service : services) { >+ if (service.getName().equals(name)) { >+ return service; >+ } >+ } >+ >+ return null; >+ } >+ > protected 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/ConfigurationLoadingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java >index 9bfe370..f38a117 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 >@@ -19,6 +19,7 @@ > package org.rhq.modules.plugins.jbossas7; > > import java.util.Collection; >+import java.util.HashMap; > import java.util.Iterator; > import java.util.List; > import java.util.Map; >@@ -611,4 +612,61 @@ public class ConfigurationLoadingTest extends AbstractConfigurationHandlingTest > Assert.assertTrue(thirdPropFound); > } > } >+ >+ /** Tests that c:group entries are loaded correctly in addition to special c:group syntax handling. >+ * Ex. <c:group name="proxy" displayName="Proxy Options"> >+ * <c:simple-property name="proxy-list" required="false" type="string" readOnly="false" defaultValue="" description="List of proxies, Format (hostname:port) separated with comas."/> >+ * <c:simple-property name="proxy-url" required="false" type="string" readOnly="false" defaultValue="/" description="Base URL for MCMP requests."/> >+ * </c:group> >+ * >+ * @throws Exception >+ */ >+ public void testLoadGroupedConfiguration() throws Exception { >+ >+ //Fabricate the json string result. >+ String resultString = "{\n" + " \"outcome\" : \"success\", \"result\" : {\n" >+ + " \"advertise\" : \"true\",\n" + " \"advertise-socket\" : \"modcluster\",\n" >+ + " \"balancer\" : \"undefined\",\n" + " \"connector\" : \"ajp\",\n" >+ + " \"proxy-list\" : \"undefined\",\n" + " \"proxy-url\" : \"/\"\n" + " }\n" + "}\n"; >+ >+ ConfigurationDefinition definition = loadServiceDescriptorElement("simpleGroupNoSpecial"); >+ >+ //Formally construct the json response >+ ObjectMapper mapper = new ObjectMapper(); >+ ComplexResult result = mapper.readValue(resultString, ComplexResult.class); >+ JsonNode json = mapper.valueToTree(result); >+ >+ //Create fake connection and prepopulate the response. >+ FakeConnection connection = new FakeConnection(); >+ connection.setContent(json); >+ >+ //Test actual load using test-plugin.xml contents. >+ ConfigurationLoadDelegate delegate = new ConfigurationLoadDelegate(definition, connection, null); >+ Configuration config = delegate.loadResourceConfiguration(); >+ >+ //Validate loaded config. >+ assert config != null; >+ >+ //check boolean contents >+ PropertySimple advertise = (PropertySimple) config.get("advertise"); >+ assert advertise != null : "Boolean 'advertise' property embedded in c:group not found."; >+ boolean advertiseOn = advertise.getBooleanValue(); >+ assert advertiseOn != false : "Advertise value not set to true or not defaulting to true."; >+ >+ //Define properties and default values to check. >+ HashMap<String, String> properties = new HashMap<String, String>(); >+ properties.put("advertise-socket", "modcluster"); >+ properties.put("connector", "ajp"); >+ properties.put("proxy-list", "undefined"); >+ properties.put("proxy-url", "/"); >+ for (String prop : properties.keySet()) { >+ PropertySimple property = (PropertySimple) config.get(prop); >+ assert property != null : "Property '" + prop + "' could not be found."; >+ String value = property.getStringValue(); >+ assert value != null : "The value for property '" + prop + "' was not located."; >+ assert value.trim().equals(properties.get(prop)) : "Value for property '" + prop >+ + "' does not match. Found '" + value + "' instead of '" + properties.get(prop) + "'"; >+ } >+ >+ } > } >\ No newline at end of file >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 a1ee49e..ae35eae 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 >@@ -18,6 +18,7 @@ > */ > package org.rhq.modules.plugins.jbossas7; > >+import java.util.HashMap; > import java.util.List; > import java.util.Map; > >@@ -794,4 +795,52 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest > } > > } >+ >+ /** Tests that c:group entries are updated correctly in addition to special c:group syntax handling. >+ * Ex. <c:group name="proxy" displayName="Proxy Options"> >+ * <c:simple-property name="proxy-list" required="false" type="string" readOnly="false" defaultValue="" description="List of proxies, Format (hostname:port) separated with comas."/> >+ * <c:simple-property name="proxy-url" required="false" type="string" readOnly="false" defaultValue="/" description="Base URL for MCMP requests."/> >+ * </c:group> >+ * >+ * @throws Exception >+ */ >+ public void testUpdateGroupConfiguration() throws Exception { >+ >+ ConfigurationDefinition definition = loadServiceDescriptorElement("simpleGroupNoSpecialUpdate"); >+ >+ FakeConnection connection = new FakeConnection(); >+ >+ ConfigurationWriteDelegate delegate = new ConfigurationWriteDelegate(definition, connection, null); >+ >+ Configuration conf = new Configuration(); >+ HashMap<String, String> properties = new HashMap<String, String>(); >+ properties.put("proxy-list", "127.0.0.1:7777,test.localhost.com:6666"); >+ properties.put("proxy-url", "/rootWebappUrl"); >+ for (String name : properties.keySet()) {//load all properties for update. >+ conf.put(new PropertySimple(name, properties.get(name))); >+ } >+ >+ CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address()); >+ >+ assert cop.numberOfSteps() == properties.size() : "Composite operation steps incorrect. Expected '" >+ + properties.size() + "' but was '" + cop.numberOfSteps() + "'."; >+ //check property values >+ for (int i = 0; i < cop.numberOfSteps(); i++) { >+ //each property maps to a separate operation. >+ Operation step = cop.step(i); >+ assert step.getOperation().equals("write-attribute") : "Write attribute not set correctly."; >+ Map<String, Object> props = step.getAdditionalProperties(); >+ assert props.size() == 2 : "Property list not correct. Expected '2' property but there were '" >+ + props.size() + "'."; >+ //check that property was returned >+ String[] keys = new String[2]; >+ props.keySet().toArray(keys); >+ String name = (String) props.get("name"); >+ String value = (String) props.get("value"); >+ assert properties.containsKey(name) : "Property '" + name + "' was not found and should have been."; >+ //check the contents of returned response. >+ assert value.equals(properties.get(name)) : "Value for property '" + name >+ + "' was not updated correctly. Expected '" + properties.get(name) + "' but was '" + value + "'."; >+ } >+ } > } >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 4b3201c..8959b24 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 >@@ -281,6 +281,42 @@ > </c:group> > </resource-configuration> > </server> >+ >+ <!-- Simple c:group entries from descriptor with no special handling. --> >+ <service name="simpleGroupNoSpecial" >+ class="BaseComponent" >+ discovery="SubsystemDiscovery" >+ description="simple grouped properties. No special handling" >+ singleton="true"> >+ <resource-configuration> >+ <c:group name="proxy" displayName="Proxy Options"> >+ <c:simple-property name="proxy-list" required="false" type="string" readOnly="false" defaultValue="" description="List of proxies, Format (hostname:port) separated with comas."/> >+ <c:simple-property name="proxy-url" required="false" type="string" readOnly="false" defaultValue="/" description="Base URL for MCMP requests."/> >+ </c:group> >+ >+ <c:group name="advertise" displayName="Advertise Options"> >+ <c:simple-property name="advertise" required="false" type="boolean" readOnly="false" defaultValue="true" description="Use Advertise logic or not."/> >+ <c:simple-property name="advertise-socket" required="false" type="string" readOnly="false" defaultValue="224.0.1.105:23364" >+ description="Name of Socket binding to use for the Advertise socket."/> >+ <c:simple-property name="connector" required="true" type="string" readOnly="false" defaultValue="ajp" description="Name of the web connector used to communicate with the load balancer."> >+ <!--<c:option-source target="resource" expression="type=Connector plugin=&pluginName;"/>--> >+ </c:simple-property> >+ </c:group> >+ </resource-configuration> >+ </service> > >+ <!-- Same as previous but for update. --> >+ <service name="simpleGroupNoSpecialUpdate" >+ class="BaseComponent" >+ discovery="SubsystemDiscovery" >+ description="simple grouped properties. No special handling" >+ singleton="true"> >+ <resource-configuration> >+ <c:group name="proxy" displayName="Proxy Options"> >+ <c:simple-property name="proxy-list" required="false" type="string" readOnly="false" defaultValue="" description="List of proxies, Format (hostname:port) separated with comas."/> >+ <c:simple-property name="proxy-url" required="false" type="string" readOnly="false" defaultValue="/" description="Base URL for MCMP requests."/> >+ </c:group> >+ </resource-configuration> >+ </service> > > </plugin> >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 818952
:
582171
| 583917