Author: fjuma
Date: 2009-02-23 11:08:15 -0500 (Mon, 23 Feb 2009)
New Revision: 164
Added:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JMSTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ResourceTestBase.java
trunk/jsfunit/testdata/destinations/
trunk/jsfunit/testdata/destinations/TestQueue-service.xml
trunk/jsfunit/testdata/destinations/TestTopic-service.xml
Modified:
trunk/core/src/main/webapp/include/resourceDataScroller.xhtml
trunk/jsfunit/pom.xml
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
Log:
Added creation tests for topics and queues.
Added methods to EmbjoprTestCase.java to check the properties of managed components.
Modified: trunk/core/src/main/webapp/include/resourceDataScroller.xhtml
===================================================================
--- trunk/core/src/main/webapp/include/resourceDataScroller.xhtml 2009-02-23 16:00:38 UTC
(rev 163)
+++ trunk/core/src/main/webapp/include/resourceDataScroller.xhtml 2009-02-23 16:08:15 UTC
(rev 164)
@@ -67,7 +67,7 @@
<f:facet name="next">
<h:panelGroup>
<h:graphicImage value="images/ArrowNextNorm.gif"
style="padding: 0px 5px 0px 7px;"/>
- <h:outputText
value="#{messages['component.dataPaginator.nextpage']}"
+ <h:outputText id="nextPage"
value="#{messages['component.dataPaginator.nextpage']}"
styleClass="rich-datascr-textlinks"/>
</h:panelGroup>
</f:facet>
Modified: trunk/jsfunit/pom.xml
===================================================================
--- trunk/jsfunit/pom.xml 2009-02-23 16:00:38 UTC (rev 163)
+++ trunk/jsfunit/pom.xml 2009-02-23 16:08:15 UTC (rev 164)
@@ -95,19 +95,28 @@
<scope>provided</scope>
<version>2.8.1</version>
</dependency>
-
<dependency>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.0</version>
</dependency>
-
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
-
+ <dependency>
+ <groupId>org.jboss.integration</groupId>
+ <artifactId>jboss-profileservice-spi</artifactId>
+ <version>5.0.3.GA</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-metatype</artifactId>
+ <version>2.0.0.GA</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
@@ -291,6 +300,12 @@
<toFile>deploy/MultipleDatasources-ds.xml</toFile>
</configfile>
</configfiles>
+ <files>
+ <copy>
+ <file>${basedir}/testdata/destinations</file>
+ <toDir>deploy</toDir>
+ </copy>
+ </files>
</configuration>
<!-- /Container configuration -->
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-02-23
16:00:38 UTC (rev 163)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-02-23
16:08:15 UTC (rev 164)
@@ -556,8 +556,7 @@
client.click("resourceConfigurationForm:saveButton");
// Check for the appropriate error messages
- String expectedMessage = "Failed to add Resource (see app server log for
"
- + "additional details): A Local TX Datasource
named "
+ String expectedMessage = "A Local TX Datasource named "
+ "'DefaultDS' already exists";
checkClientAndServerMessages(expectedMessage, expectedMessage, true);
}
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-02-23
16:00:38 UTC (rev 163)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-02-23
16:08:15 UTC (rev 164)
@@ -37,9 +37,20 @@
//import org.jboss.jmx.adaptor.rmi.RMIAdaptor; // Needs dependency: jmx-adaptor-plugin
import java.util.regex.Pattern;
import javax.xml.xpath.XPathException;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.profileservice.spi.ProfileKey;
+import javax.naming.InitialContext;
+import org.jboss.deployers.spi.management.ManagementView;
+import javax.naming.NamingException;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.metatype.api.values.SimpleValueSupport;
-
/**
* This is the base test class for Embedded Jopr test cases.
* It supplies access to a JSFClientSession object and a JSFServerSession
@@ -566,41 +577,160 @@
}
}
+
+ /**
+ * Checks whether given string looks like a double in terms of Java's Double,
+ * i.e. /<digit>+(\.<digit>+)?/
+ * @param value The string to check.
+ * @returns true if the
+ */
+ protected boolean looksLikeDouble(String value) {
+ try{
+ Double.parseDouble(value);
+ }catch(NumberFormatException ex){
+ return false;
+ }
+ return true;
+ }
+ /**
+ * If both expected and actual string look like a double,
+ * returns normalized double (with a decimal dot);
+ * Otherwise, returns original actual value.
+ * @param expected
+ * @param actual
+ */
+ protected String normalizeIfDoubleExpected(String expected, String actual) {
+ //return looksLikeDouble(expected) ? actual.replace(',', '.') :
actual;
- /**
- * Checks whether given string looks like a double in terms of Java's Double,
- * i.e. /<digit>+(\.<digit>+)?/
- * @param value The string to check.
- * @returns true if the
- */
- protected boolean looksLikeDouble(String value) {
- try{
- Double.parseDouble(value);
- }catch(NumberFormatException ex){
- return false;
- }
- return true;
- }
+ if( !looksLikeDouble(expected) )
+ return actual;
- /**
- * If both expected and actual string look like a double,
- * returns normalized double (with a decimal dot);
- * Otherwise, returns original actual value.
- * @param expected
- * @param actual
- */
- protected String normalizeIfDoubleExpected(String expected, String actual) {
- //return looksLikeDouble(expected) ? actual.replace(',', '.') :
actual;
+ String converted = actual.replace(',', '.');
+ return looksLikeDouble(converted) ? converted : actual;
+ }
+
+ /**
+ * Transform the given map of Strings to MetaValues into a
+ * map of Strings to Strings.
+ */
+ protected Map<String, String> formatPropertiesMap(Map<String, MetaValue>
propertiesMap) {
+ Map<String, String> formattedPropertiesMap = new HashMap<String,
String>();
+
+ for(String propertyName : propertiesMap.keySet()) {
+ SimpleValueSupport propertyMetaValue =
(SimpleValueSupport)propertiesMap.get(propertyName);
+ String propertyStringValue = propertyMetaValue.getValue().toString();
+ formattedPropertiesMap.put(propertyName, propertyStringValue);
+ }
+
+ return formattedPropertiesMap;
+ }
+
+ /**
+ * Check the properties for a particular managed component.
+ *
+ * @param expectedProperties maps property names to expected values
+ * @param componentName - the name of the ManagedComponent
+ * @param type - the component type
+ */
+ protected void checkComponentProperties(Map<String, MetaValue>
expectedProperties,
+ String componentName,
+ ComponentType type) throws Exception {
+
+ ManagedComponent component = getManagedComponent(componentName, type);
+ assertNotNull("The returned component was null", component);
+ assertEquals(componentName, component.getName());
+
+ Map<String, ManagedProperty> actualProperties = component.getProperties();
+ ManagedProperty prop;
+
+ // Verify that the property values are correct
+ for(String propertyName : expectedProperties.keySet()) {
+ prop = actualProperties.get(propertyName);
+
+ assertEquals("Incorrect value for '" + propertyName +
"'",
+ expectedProperties.get(propertyName),
+ prop.getValue());
+ }
+ }
+
+ /**
+ * Return a ManagedComponent, given the component name and type.
+ */
+ protected ManagedComponent getManagedComponent(String componentName,
+ ComponentType type) throws Exception
{
+
+ // Get the ManagedComponent
+ ManagementView mgtView = getCurrentProfileView();
+ ManagedComponent component = mgtView.getComponent(componentName, type);
+
+ return component;
+ }
+
+ /**
+ * Return whether or not the given deployment is deployed.
+ *
+ * @param deployment - the deployment we are interested in
+ */
+ protected boolean isDeployed(String deployment) throws Exception {
+ ManagementView currentProfileView = getCurrentProfileView();
+ ManagedDeployment managedDeployment = null;
+
+ try {
+ managedDeployment = currentProfileView.getDeployment(deployment,
+
ManagedDeployment.DeploymentPhase.APPLICATION);
+ } catch (NoSuchDeploymentException e) {
+ return false;
+ }
+
+ return managedDeployment != null;
+ }
+
+ /**
+ * Get the profile service.
+ */
+ protected ProfileService getProfileService()
+ {
+ ProfileService profileService = null;
+ InitialContext initialContext;
+
+ try {
+ initialContext = new InitialContext();
+ } catch (NamingException e) {
+ log.error("Unable to get an InitialContext to JBoss AS 5", e);
+ return null;
+ }
- if( !looksLikeDouble(expected) )
- return actual;
+ try {
+ profileService = (ProfileService)
initialContext.lookup("ProfileService");
+ } catch (NamingException e) {
+ log.error("Could not find ProfileService Name on JBoss AS 5", e);
+ } catch (Exception e) {
+ log.error("Exception thrown when looking up ProfileService on JBoss AS
5", e);
+ }
+
+ return profileService;
+ }
- String converted = actual.replace(',', '.');
- return looksLikeDouble(converted) ? converted : actual;
- }
+ /**
+ * Get the current profile view.
+ */
+ protected ManagementView getCurrentProfileView()
+ {
+ ProfileService profileService = getProfileService();
+ ManagementView currentProfileView = profileService.getViewManager();
+ String[] domains = profileService.getDomains();
-
+ ProfileKey defaultKey = new ProfileKey(domains[0]);
+
+ try {
+ currentProfileView.loadProfile(defaultKey);
+ } catch (Exception e) {
+ log.error("Could not find default Profile in Current Profile View",
e);
+ }
+
+ return currentProfileView;
+ }
}
Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JMSTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JMSTest.java
(rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JMSTest.java 2009-02-23
16:08:15 UTC (rev 164)
@@ -0,0 +1,377 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.jopr.jsfunit.as5;
+
+import com.gargoylesoftware.htmlunit.html.*;
+import java.io.IOException;
+import junit.framework.Test;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.input.SAXBuilder;
+import java.io.File;
+import org.jboss.jopr.jsfunit.*;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.deployers.spi.management.KnownComponentTypes;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.managed.api.ComponentType;
+
+/**
+ * This class contains tests for managing JMS topics and queues
+ * using Embedded Jopr. This test class should be run against
+ * JBAS 5.x.
+ *
+ * @author Farah Juma
+ *
+ */
+
+public class JMSTest extends ResourceTestBase {
+
+ public enum DestinationType {
+ QUEUE("Queues", "Queue"),
+ TOPIC("Topics", "Topic");
+
+ private final String navLabel;
+ private final String name;
+
+ DestinationType(String navLabel, String name) {
+ this.navLabel = navLabel;
+ this.name = name;
+ }
+
+ private String getNavLabel() {
+ return this.navLabel;
+ }
+
+ private String getName() {
+ return this.name;
+ }
+ }
+
+ private static final String QUEUE_DEFAULT_TEMPLATE="default__Queue";
+ private static final String TOPIC_DEFAULT_TEMPLATE="default__Topic";
+ private static final String JMS_NAV_LABEL="JMS Destinations";
+ private static final ComponentType QUEUE_COMPONENT_TYPE =
KnownComponentTypes.JMSDestination.Queue.getType();
+ private static final ComponentType TOPIC_COMPONENT_TYPE =
KnownComponentTypes.JMSDestination.Topic.getType();
+
+ /**
+ * Create a new topic or queue using the given destination type and properties.
+ */
+ protected void createDestination(DestinationType destinationType,
+ String templateName,
+ Map<String, MetaValue> propertiesMap) throws
IOException {
+
+ // Expand the "JMS Destinations" tree node
+ ClickableElement datasourcesArrow = getNavTreeArrow(JMS_NAV_LABEL);
+ datasourcesArrow.click();
+
+ createResource(destinationType.getNavLabel(), templateName, propertiesMap);
+ }
+
+ /**
+ * Delete the given JMS destination.
+ *
+ * Assumes the JMS Destinations tree node is already expanded.
+ */
+ protected void deleteDestination(DestinationType destinationType,
+ String destinationName) throws IOException {
+ HtmlAnchor datasourceLink = getNavTreeLink(destinationType.getNavLabel());
+ datasourceLink.click();
+
+ deleteResource("resourceSummaryForm", destinationName);
+ }
+
+ /**
+ * Create a basic queue. Return the mapping of property names to property
+ * values.
+ */
+ protected Map<String, MetaValue> createQueue(String queueName) throws
IOException {
+
+ Map<String, MetaValue> propertiesMap = new HashMap<String,
MetaValue>();
+ propertiesMap.put("JNDIName", SimpleValueSupport.wrap(queueName));
+ propertiesMap.put("clustered",
SimpleValueSupport.wrap(Boolean.FALSE));
+ propertiesMap.put("downCacheSize", SimpleValueSupport.wrap(new
Integer(1500)));
+ propertiesMap.put("fullSize", SimpleValueSupport.wrap(new
Integer(76000)));
+ propertiesMap.put("maxSize", SimpleValueSupport.wrap(new
Integer(76000)));
+ propertiesMap.put("messageCounterHistoryDayLimit",
SimpleValueSupport.wrap(new Integer(5)));
+ propertiesMap.put("pageSize", SimpleValueSupport.wrap(new
Integer(1500)));
+
+ createDestination(DestinationType.QUEUE, QUEUE_DEFAULT_TEMPLATE, propertiesMap);
+ client.click("resourceConfigurationForm:saveButton");
+
+ return propertiesMap;
+ }
+
+ /**
+ * Create a basic topic. Return the mapping of property names to property
+ * values.
+ */
+ protected Map<String, MetaValue> createTopic(String topicName) throws
IOException {
+ Map<String, MetaValue> propertiesMap = new HashMap<String,
MetaValue>();
+ propertiesMap.put("JNDIName", SimpleValueSupport.wrap(topicName));
+ propertiesMap.put("clustered", SimpleValueSupport.wrap(Boolean.TRUE));
+ propertiesMap.put("fullSize", SimpleValueSupport.wrap(new
Integer(70000)));
+ propertiesMap.put("maxSize", SimpleValueSupport.wrap(new
Integer(70000)));
+ propertiesMap.put("redeliveryDelay", SimpleValueSupport.wrap(new
Long(60000)));
+
+ createDestination(DestinationType.TOPIC, TOPIC_DEFAULT_TEMPLATE, propertiesMap);
+ client.click("resourceConfigurationForm:saveButton");
+
+ return propertiesMap;
+ }
+
+ /*
+ * CREATION TESTS
+ */
+
+ /**
+ * Create a new queue.
+ */
+ public void testCreateQueue() throws Exception {
+
+ String jndiName = "CreateQueue";
+ String expectedMessage = SUCCESS_MESSAGE + DestinationType.QUEUE.getName();
+
+ createDestinationCommon(DestinationType.QUEUE, QUEUE_DEFAULT_TEMPLATE,
+ jndiName, expectedMessage, QUEUE_COMPONENT_TYPE);
+ }
+
+ /**
+ * Create a new topic.
+ */
+ public void testCreateTopic() throws Exception {
+
+ String jndiName = "CreateTopic";
+ String expectedMessage = SUCCESS_MESSAGE + DestinationType.TOPIC.getName();
+
+ createDestinationCommon(DestinationType.TOPIC, TOPIC_DEFAULT_TEMPLATE,
+ jndiName, expectedMessage, TOPIC_COMPONENT_TYPE);
+ }
+
+ /**
+ * Common code for the testCreateQueue() and testCreateTopic() tests.
+ */
+ private void createDestinationCommon(DestinationType destinationType,
+ String destinationTemplate,
+ String jndiName,
+ String expectedMessage,
+ ComponentType componentType) throws Exception {
+
+ // The properties we want to configure
+ Map<String, MetaValue> propertiesMap = new HashMap<String,
MetaValue>();
+ propertiesMap.put("JNDIName", SimpleValueSupport.wrap(jndiName));
+ propertiesMap.put("clustered", SimpleValueSupport.wrap(Boolean.TRUE));
+ propertiesMap.put("downCacheSize", SimpleValueSupport.wrap(new
Integer(2500)));
+ propertiesMap.put("fullSize", SimpleValueSupport.wrap(new
Integer(80000)));
+ propertiesMap.put("maxDeliveryAttempts", SimpleValueSupport.wrap(new
Integer(15)));
+ propertiesMap.put("maxSize", SimpleValueSupport.wrap(new
Integer(80000)));
+ propertiesMap.put("messageCounterHistoryDayLimit",
SimpleValueSupport.wrap(new Integer(0)));
+ propertiesMap.put("pageSize", SimpleValueSupport.wrap(new
Integer(2500)));
+ propertiesMap.put("redeliveryDelay", SimpleValueSupport.wrap(new
Long(50000)));
+
+ createDestination(destinationType, destinationTemplate, propertiesMap);
+ client.click("resourceConfigurationForm:saveButton");
+
+ // Check for the appropriate success messages
+ checkClientAndServerMessages(expectedMessage, expectedMessage, false);
+
+ // Make sure the ManagedComponent was created
+ assertNotNull("The returned component was null",
+ getManagedComponent(jndiName, componentType));
+ assertTrue("The destination is not deployed ",
+ isDeployed(jndiName + "-service.xml"));
+
+ // Verify that the properties were set correctly
+ checkComponentProperties(propertiesMap, jndiName, componentType);
+
+ // Clean up
+ deleteDestination(destinationType, jndiName);
+ }
+
+ /**
+ * Attempt to create a new queue but leave a required value unset.
+ * Make sure the appropriate error message occurs.
+ */
+ public void testCreateQueueMissingRequiredValue() throws IOException {
+ createDestinationMissingRequiredValue(DestinationType.QUEUE,
QUEUE_DEFAULT_TEMPLATE);
+ }
+
+ /**
+ * Attempt to create a new topic but leave a required value unset.
+ * Make sure the appropriate error message occurs.
+ */
+ public void testCreateTopicMissingRequiredValue() throws IOException {
+ createDestinationMissingRequiredValue(DestinationType.TOPIC,
TOPIC_DEFAULT_TEMPLATE);
+ }
+
+ /**
+ * Common code for the testCreate*MissingRequiredValue() tests.
+ */
+ private void createDestinationMissingRequiredValue(DestinationType destinationType,
+ String destinationTemplate) throws
IOException {
+ // Leave the JNDI name unset
+ Map<String, MetaValue> propertiesMap = new HashMap<String,
MetaValue>();
+ propertiesMap.put("clustered", SimpleValueSupport.wrap(Boolean.TRUE));
+ propertiesMap.put("fullSize", SimpleValueSupport.wrap(new
Integer(80000)));
+
+ createDestination(destinationType, destinationTemplate, propertiesMap);
+ client.click("resourceConfigurationForm:saveButton");
+
+ // Check for the appropriate error messages
+ checkClientAndServerMessages(INVALID_VALUE_MESSAGE,
+ MISSING_VALUE_MESSAGE, true);
+ }
+
+ /**
+ * Attempt to create a new queue but set a property value beyond
+ * its expected range of values. Make sure the appropriate error message
+ * occurs.
+ */
+ public void testCreateQueuePropertyOutOfRange() throws IOException {
+ createDestinationPropertyOutOfRange(DestinationType.QUEUE,
+ QUEUE_DEFAULT_TEMPLATE,
+ "PropertyOutOfRangeQueue");
+ }
+
+ /**
+ * Attempt to create a new topic but set a property value beyond
+ * its expected range of values. Make sure the appropriate error message
+ * occurs.
+ */
+ public void testCreateTopicPropertyOutOfRange() throws IOException {
+ createDestinationPropertyOutOfRange(DestinationType.TOPIC,
+ TOPIC_DEFAULT_TEMPLATE,
+ "PropertyOutOfRangeTopic");
+ }
+
+
+ /**
+ * Common code for the testCreate*PropertyOutOfRange() tests.
+ */
+ private void createDestinationPropertyOutOfRange(DestinationType destinationType,
+ String destinationTemplate,
+ String jndiName) throws IOException
{
+ // The properties we want to configure
+ Map<String, MetaValue> propertiesMap = new HashMap<String,
MetaValue>();
+ propertiesMap.put("JNDIName", SimpleValueSupport.wrap(jndiName));
+ propertiesMap.put("clustered", SimpleValueSupport.wrap(Boolean.TRUE));
+ propertiesMap.put("downCacheSize", SimpleValueSupport.wrap(new
Integer(2500)));
+ propertiesMap.put("fullSize", SimpleValueSupport.wrap(new
Integer(80000)));
+
+ // This number is too large
+ propertiesMap.put("maxDeliveryAttempts", SimpleValueSupport.wrap(new
Long(Long.MAX_VALUE)));
+
+ createDestination(destinationType, destinationTemplate, propertiesMap);
+ client.click("resourceConfigurationForm:saveButton");
+
+ // Check for the appropriate error messages
+ checkClientAndServerMessages(INVALID_VALUE_MESSAGE,
+ OUT_OF_RANGE_MESSAGE, true);
+ }
+
+ /**
+ * Attempt to create a new queue but set a property value to an invalid
+ * type. Make sure the appropriate error message occurs.
+ */
+ public void testCreateQueueInvalidPropertyType() throws IOException {
+ createDestinationInvalidPropertyType(DestinationType.QUEUE,
+ QUEUE_DEFAULT_TEMPLATE,
+ "InvalidPropertyTypeQueue");
+ }
+
+ /**
+ * Attempt to create a new topic but set a property value to an invalid
+ * type. Make sure the appropriate error message occurs.
+ */
+ public void testCreateTopicInvalidPropertyType() throws IOException {
+ createDestinationInvalidPropertyType(DestinationType.TOPIC,
+ TOPIC_DEFAULT_TEMPLATE,
+ "InvalidPropertyTypeTopic");
+ }
+
+ /**
+ * Common code for the testCreate*InvalidPropertyType() tests.
+ */
+ private void createDestinationInvalidPropertyType(DestinationType destinationType,
+ String destinationTemplate,
+ String jndiName) throws
IOException {
+ // The properties we want to configure
+ Map<String, MetaValue> propertiesMap = new HashMap<String,
MetaValue>();
+ propertiesMap.put("JNDIName", SimpleValueSupport.wrap(jndiName));
+ propertiesMap.put("clustered",
SimpleValueSupport.wrap(Boolean.TRUE));
+ propertiesMap.put("messageCounterHistoryDayLimit",
SimpleValueSupport.wrap(new Integer(0)));
+ propertiesMap.put("redeliveryDelay", SimpleValueSupport.wrap(new
Long(50000)));
+
+ // This property value is supposed to be an integer
+ propertiesMap.put("maxDeliveryAttempts",
SimpleValueSupport.wrap("fifteen"));
+
+ createDestination(destinationType, destinationTemplate, propertiesMap);
+ client.click("resourceConfigurationForm:saveButton");
+
+ // Check for the appropriate error messages
+ checkClientAndServerMessages(INVALID_VALUE_MESSAGE,
+ INVALID_INTEGER_MESSAGE, true);
+ }
+
+ /**
+ * Attempt to create a new queue using a JNDI name that
+ * already exists. Make sure the appropriate error message occurs.
+ */
+ public void testCreateQueueDuplicateJNDIName() throws IOException {
+ createDestinationDuplicateJNDIName(DestinationType.QUEUE,
QUEUE_DEFAULT_TEMPLATE,
+ "TestQueue");
+ }
+
+ /**
+ * Attempt to create a new topic using a JNDI name that
+ * already exists. Make sure the appropriate error message occurs.
+ */
+ public void testCreateTopicDuplicateJNDIName() throws IOException {
+ createDestinationDuplicateJNDIName(DestinationType.TOPIC,
TOPIC_DEFAULT_TEMPLATE,
+ "TestTopic");
+ }
+
+ /**
+ * Common code for the testCreate*DuplicateJNDIName() tests.
+ */
+ public void createDestinationDuplicateJNDIName(DestinationType destinationType,
+ String destinationTemplate,
+ String jndiName) throws IOException
{
+ // The properties we want to configure
+ Map<String, MetaValue> propertiesMap = new HashMap<String,
MetaValue>();
+ propertiesMap.put("JNDIName", SimpleValueSupport.wrap(jndiName));
+
+ createDestination(destinationType, destinationTemplate, propertiesMap);
+ client.click("resourceConfigurationForm:saveButton");
+
+ // Check for the appropriate error messages
+ String expectedMessage = "A " + destinationType.getName() + "
named '" + jndiName + "' already exists";
+ checkClientAndServerMessages(expectedMessage, expectedMessage, true);
+ }
+}
Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ResourceTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ResourceTestBase.java
(rev 0)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ResourceTestBase.java 2009-02-23
16:08:15 UTC (rev 164)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.jopr.jsfunit.as5;
+
+import com.gargoylesoftware.htmlunit.html.*;
+import java.io.IOException;
+import junit.framework.Test;
+import org.jboss.jopr.jsfunit.*;
+import java.util.Map;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * This class contains basic methods for creating and deleting
+ * resources (eg. Topics, Queues, etc.).
+ *
+ * @author Farah Juma
+ *
+ */
+
+public abstract class ResourceTestBase extends EmbjoprTestCase {
+
+ private final String MAX_ITEMS_PER_PAGE="20";
+
+ // Error messages
+ public static final String INVALID_VALUE_MESSAGE="An invalid value was specified
for one or more properties";
+ public static final String MISSING_VALUE_MESSAGE="Value is required";
+ public static final String OUT_OF_RANGE_MESSAGE="Specified attribute is not
between the expected values";
+ public static final String INVALID_INTEGER_MESSAGE="Value is not a valid
integer";
+
+ // Success message
+ public static final String SUCCESS_MESSAGE = "Successfully added new ";
+ public static final String DELETE_MESSAGE = "Successfully deleted ";
+
+ /**
+ * Create a new resource using the given type, template, and properties.
+ *
+ * @param propertiesMap is a map of property names to property meta values
+ * @param resourceType must be the type of datasource, connection factory,
+ * or JMS destination, as it appears in the left nav (eg. "Local TX
Datasources",
+ * "Queues", "Topics", etc").
+ *
+ */
+ public void createResource(String resourceType,
+ String resourceTemplate,
+ Map<String, MetaValue> propertiesMap) throws
IOException {
+ HtmlAnchor resourceLink = getNavTreeLink(resourceType);
+ resourceLink.click();
+
+ // Add a new resource
+ client.click("actionHeaderForm:addNewNotContent");
+ HtmlSelect menu = (HtmlSelect)client.getElement("selectedTemplate");
+ menu.setSelectedAttribute(resourceTemplate, Boolean.TRUE);
+ client.click("resourceCreateForm:addButton");
+
+ // Configure the properties associated with this resource
+ Map<String, String> formattedPropertiesMap =
formatPropertiesMap(propertiesMap);
+ fillOutForm(formattedPropertiesMap);
+ }
+
+ /**
+ * Delete the given resource.
+ *
+ * @param resourceFormName The name of the form that contains the delete button.
+ */
+ public void deleteResource(String resourceFormName, String resourceName) throws
IOException {
+
+ HtmlSelect menu = (HtmlSelect)client.getElement("currentPageSize");
+ if(menu != null) {
+ menu.setSelectedAttribute(MAX_ITEMS_PER_PAGE, Boolean.TRUE);
+ }
+
+ HtmlButtonInput deleteButton;
+ try {
+ deleteButton = getDeleteButton(resourceFormName, resourceName);
+ deleteButton.click();
+ } catch (IllegalStateException e) {
+
+ // The delete button was not found on this page
+ client.click("nextPage");
+ deleteButton = getDeleteButton(resourceFormName, resourceName);
+ deleteButton.click();
+ }
+ }
+}
Added: trunk/jsfunit/testdata/destinations/TestQueue-service.xml
===================================================================
--- trunk/jsfunit/testdata/destinations/TestQueue-service.xml (rev
0)
+++ trunk/jsfunit/testdata/destinations/TestQueue-service.xml 2009-02-23 16:08:15 UTC (rev
164)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<server>
+ <mbean xmbean-dd="xmdesc/Queue-xmbean.xml"
name="jboss.messaging.destination:service=Queue,name=TestQueue"
code="org.jboss.jms.server.destination.QueueService">
+
<annotation>(a)org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>
+ <attribute name="JNDIName">TestQueue</attribute>
+ <depends
optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>
Added: trunk/jsfunit/testdata/destinations/TestTopic-service.xml
===================================================================
--- trunk/jsfunit/testdata/destinations/TestTopic-service.xml (rev
0)
+++ trunk/jsfunit/testdata/destinations/TestTopic-service.xml 2009-02-23 16:08:15 UTC (rev
164)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<server>
+ <mbean xmbean-dd="xmdesc/Topic-xmbean.xml"
name="jboss.messaging.destination:service=Topic,name=TestTopic"
code="org.jboss.jms.server.destination.TopicService">
+
<annotation>(a)org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.TopicServiceMO)</annotation>
+ <attribute name="JNDIName">TestTopic</attribute>
+ <depends
optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>