modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/ServerGroupTest.java
| 89 ++++++++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
| 1
2 files changed, 90 insertions(+)
New commits:
commit 72eb1f263b479f2f79754daf4a31479c5a5af2b1
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Jul 29 17:25:38 2011 +0200
Add a test for server group creation via createResources.
diff --git
a/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/ServerGroupTest.java
b/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/ServerGroupTest.java
new file mode 100644
index 0000000..c170211
--- /dev/null
+++
b/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/ServerGroupTest.java
@@ -0,0 +1,89 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.integrationTests.jbossas7plugin;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.modules.plugins.jbossas7.ASConnection;
+import org.rhq.modules.plugins.jbossas7.HostControllerComponent;
+import org.rhq.modules.plugins.jbossas7.json.Remove;
+
+/**
+ * Tests around server groups
+ * @author Heiko W. Rupp
+ */
+@Test
+public class ServerGroupTest extends AbstractIntegrationTest {
+
+ public void createServerGroupViaApi() throws Exception {
+
+ ASConnection connection = getASConnection();
+ HostControllerComponent hcc = new HostControllerComponent();
+ hcc.setConnection(connection);
+
+ Configuration rc = new Configuration();
+ rc.put(new PropertySimple("profile","default"));
+ rc.put(new
PropertySimple("socket-binding-group","standard-sockets"));
+ ResourceType rt = new ResourceType();
+
+ String serverGroupName = "_test-sg";
+ try {
+ CreateResourceReport report = new CreateResourceReport(serverGroupName,rt,new
Configuration(),rc,null);
+ report = hcc.createResource(report);
+
+ assert report != null;
+ assert report.getStatus()== CreateResourceStatus.SUCCESS : "Create was a
failure : " + report.getErrorMessage();
+ } finally {
+ Remove r = new Remove("server-group", serverGroupName);
+ connection.execute(r);
+ }
+
+ }
+
+ public void badCreateServerGroupViaApi() throws Exception {
+
+ ASConnection connection = getASConnection();
+ HostControllerComponent hcc = new HostControllerComponent();
+ hcc.setConnection(connection);
+
+ Configuration rc = new Configuration();
+ rc.put(new PropertySimple("profile","luzibumpf")); // Does
not exist op should fail
+ rc.put(new
PropertySimple("socket-binding-group","standard-sockets"));
+ ResourceType rt = new ResourceType();
+
+ String serverGroupName = "_test-sg";
+ try {
+ CreateResourceReport report = new CreateResourceReport(serverGroupName,rt,new
Configuration(),rc,null);
+ report = hcc.createResource(report);
+
+ assert report != null;
+ assert report.getStatus()== CreateResourceStatus.FAILURE : "Is AS7-1430
solved ? ";
+ assert report.getException()== null;
+ } finally {
+ Remove r = new Remove("server-group", serverGroupName);
+ connection.execute(r);
+ }
+
+ }
+}
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
index d28d078..c35f9fe 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
@@ -106,6 +106,7 @@ public class HostControllerComponent extends BaseServerComponent
implements Oper
else {
report.setErrorMessage(res.getFailureDescription());
report.setStatus(CreateResourceStatus.FAILURE);
+ report.setException(res.getThrowable());
}
return report;
}
Show replies by date