EMBJOPR SVN: r384 - trunk/core/src/main/webapp/secure.
by embjopr-commits@lists.jboss.org
Author: ips
Date: 2009-05-06 09:15:27 -0400 (Wed, 06 May 2009)
New Revision: 384
Modified:
trunk/core/src/main/webapp/secure/resourceInstanceOperation.xhtml
Log:
uncomment the a4j:poll to get auto-refresh working (https://jira.jboss.org/jira/browse/EMBJOPR-56)
Modified: trunk/core/src/main/webapp/secure/resourceInstanceOperation.xhtml
===================================================================
--- trunk/core/src/main/webapp/secure/resourceInstanceOperation.xhtml 2009-05-06 04:30:57 UTC (rev 383)
+++ trunk/core/src/main/webapp/secure/resourceInstanceOperation.xhtml 2009-05-06 13:15:27 UTC (rev 384)
@@ -93,9 +93,7 @@
<h:outputText value="#{messages['control.resourceInstance.error.noPrevious']}" rendered="#{empty operationHistories}"/>
<h:form id="historiesForm" rendered="#{!empty operationHistories}">
- <ui:remove>
- <a4j:poll id="poller" reRender="poller, historiesForm, historyDetailsPanel" interval="10000" limitToList="true"/>
- </ui:remove>
+ <a4j:poll id="poller" reRender="poller, historiesForm, historyDetailsPanel" interval="10000" limitToList="true"/>
<rich:dataTable
styleClass="properties-table"
15 years, 7 months
EMBJOPR SVN: r383 - in trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit: as5 and 1 other directory.
by embjopr-commits@lists.jboss.org
Author: smcgowan(a)redhat.com
Date: 2009-05-06 00:30:57 -0400 (Wed, 06 May 2009)
New Revision: 383
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java
Log:
minor edits to EjbTest
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-05-06 01:41:01 UTC (rev 382)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-05-06 04:30:57 UTC (rev 383)
@@ -179,4 +179,8 @@
"sqlexception-service.xml", "transaction-service.xml", "uuid-key-generator.sar"
};
+ // Status Messages
+ public static final String EJB2_DEL_MSG = "Successfully deleted EJB 2.x Application (EJB JAR)";
+ public static final String EJB3_DEL_MSG = "Successfully deleted EJB 3.x Application (EJB JAR)";
+
}
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java 2009-05-06 01:41:01 UTC (rev 382)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java 2009-05-06 04:30:57 UTC (rev 383)
@@ -109,7 +109,6 @@
assertTrue(successMessage.getDetail().contains("Resource " + BASIC_JAR + " created successfully!"));
- // TODO: Check if listed. See EMBJOPR-74.
assertFalse("Page contains 'Total: 0', EJBs probably not listed.", client.getPageAsText().contains("Total: 0"));
@@ -120,9 +119,9 @@
HtmlButtonInput deleteButton = getAppDeleteButton(BASIC_JAR);
deleteButton.click();
- assertTrue(client.getPageAsText().contains("Successfully deleted " + NAV_EJB2 + " '" + BASIC_JAR +"'."));
+ assertTrue(client.getPageAsText().contains(EJB2_DEL_MSG + " '" + BASIC_JAR +"'."));
- //assertFalse(isEJBDeployed(BASIC_JAR);
+ assertFalse(isEJBDeployed(BASIC_JAR));
}
}
15 years, 8 months
EMBJOPR SVN: r382 - trunk/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-05-05 21:41:01 -0400 (Tue, 05 May 2009)
New Revision: 382
Modified:
trunk/jsfunit/pom.xml
Log:
JSFUnit POM: Removed RMI setting for cargo, added <failIfNoTests>true</failIfNoTests> and <testFailureIgnore>true</testFailureIgnore> for Surefire. The latter is for better maven integration.
Modified: trunk/jsfunit/pom.xml
===================================================================
--- trunk/jsfunit/pom.xml 2009-05-05 23:09:25 UTC (rev 381)
+++ trunk/jsfunit/pom.xml 2009-05-06 01:41:01 UTC (rev 382)
@@ -346,7 +346,7 @@
<!-- JBoss configuration - default, all, standard -->
<cargo.jboss.configuration>${cargo.jboss.configuration}</cargo.jboss.configuration>
<!-- Prevent Hudson RMI port collision -->
- <cargo.rmi.port>11098</cargo.rmi.port>
+ <!--<cargo.rmi.port>11098</cargo.rmi.port>-->
</properties>
<!-- Override Cargo's default files (some taken from cargo's .jar, some from 'default') -->
<configfiles>
@@ -423,6 +423,8 @@
</goals>
<configuration>
<skip>false</skip>
+ <failIfNoTests>true</failIfNoTests>
+ <testFailureIgnore>true</testFailureIgnore>
<includes>
<include>**/as5/*Test.java</include>
<include>**/as5/jmsDestinations/*Test.java</include>
15 years, 8 months
EMBJOPR SVN: r381 - trunk/jsfunit/testdata.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-05-05 19:09:25 -0400 (Tue, 05 May 2009)
New Revision: 381
Added:
trunk/jsfunit/testdata/hudson_shell_script.sh
Log:
Added hudson shell script
Added: trunk/jsfunit/testdata/hudson_shell_script.sh
===================================================================
--- trunk/jsfunit/testdata/hudson_shell_script.sh (rev 0)
+++ trunk/jsfunit/testdata/hudson_shell_script.sh 2009-05-05 23:09:25 UTC (rev 381)
@@ -0,0 +1,33 @@
+echo `pwd`
+rm -rf embjopr/target
+rm -rf embjopr/jsfunit/target
+
+### Build JBoss AS, checked out / updated by Hudson
+cd jbossas-5.x/build
+./build.sh clean
+./build.sh -Dbuild.unsecured=true
+cd ../..
+
+### Set JBoss AS home dir
+# We don't want to stick with specific version, so get the home dynamically.
+# Get only the last dir. Hopefully versions will be named alphabetically.
+export JBOSS_HOME=`pwd`/`ls -d -1 jbossas-5.x/build/output/* | tail -n 1`
+echo "JBOSS_HOME: $JBOSS_HOME"
+# Remove bundled AS console
+# Name of war changed on 04/24 - smcgowan
+rm -rf $JBOSS_HOME/server/default/deploy/admin-console.war
+
+### List currently used port - why is RMI port in collision?
+/usr/sbin/lsof -i
+### List JVMs
+jps -l
+
+cd embjopr
+mvn install -Dmaven.test.skip=true --fail-never --update-snapshots
+cd jsfunit
+rm -rf target
+echo "Launching tests; binding JBoss AS to MYTESTIP_1 == $MYTESTIP_1"
+mvn -Pjboss5x install --fail-never --update-snapshots -DJBOSS_HOME=$JBOSS_HOME -Dcargo.jboss.bind.address=$MYTESTIP_1
+sleep 5
+
+
15 years, 8 months
EMBJOPR SVN: r380 - trunk/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-05-05 12:40:47 -0400 (Tue, 05 May 2009)
New Revision: 380
Modified:
trunk/jsfunit/pom.xml
Log:
JSFUnit POM: jboss.bind.address removed, trying <cargo.rmi.port>11098</cargo.rmi.port>
Modified: trunk/jsfunit/pom.xml
===================================================================
--- trunk/jsfunit/pom.xml 2009-05-04 23:12:38 UTC (rev 379)
+++ trunk/jsfunit/pom.xml 2009-05-05 16:40:47 UTC (rev 380)
@@ -171,7 +171,7 @@
<jsfunit.tempdir>${basedir}/target/jboss42x/tmp</jsfunit.tempdir>
<jsfunit.deploy.dir>${basedir}/target/jboss42x/deploy</jsfunit.deploy.dir>
<jboss.configuration>${cargo.jboss.configuration}</jboss.configuration>
- <jboss.bind.address>${cargo.jboss.bind.address}</jboss.bind.address>
+ <!--<jboss.bind.address>${cargo.jboss.bind.address}</jboss.bind.address>-->
<jsfunit.jboss.home.dir>${basedir}/target/jboss42x</jsfunit.jboss.home.dir>
</systemProperties>
</container>
@@ -324,7 +324,7 @@
<jsfunit.tempdir>${basedir}/target/jboss5x/tmp</jsfunit.tempdir>
<jsfunit.deploy.dir>${basedir}/target/jboss5x/deploy</jsfunit.deploy.dir>
<jboss.configuration>${cargo.jboss.configuration}</jboss.configuration>
- <jboss.bind.address>${cargo.jboss.bind.address}</jboss.bind.address>
+ <!--<jboss.bind.address>${cargo.jboss.bind.address}</jboss.bind.address>-->
<!-- Home dir for Cargo's JBoss instance. -->
<jsfunit.jboss.home.dir>${basedir}/target/jboss5x</jsfunit.jboss.home.dir>
</systemProperties>
@@ -345,6 +345,8 @@
<!-- -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -->
<!-- JBoss configuration - default, all, standard -->
<cargo.jboss.configuration>${cargo.jboss.configuration}</cargo.jboss.configuration>
+ <!-- Prevent Hudson RMI port collision -->
+ <cargo.rmi.port>11098</cargo.rmi.port>
</properties>
<!-- Override Cargo's default files (some taken from cargo's .jar, some from 'default') -->
<configfiles>
15 years, 8 months
EMBJOPR SVN: r379 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-05-04 19:12:38 -0400 (Mon, 04 May 2009)
New Revision: 379
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java
Log:
JBossASNodeTest updated.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java 2009-05-04 22:37:46 UTC (rev 378)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java 2009-05-04 23:12:38 UTC (rev 379)
@@ -139,7 +139,7 @@
for( int i = 0; i < threads1; i++ ) {
log.debug("Starting thread 'Dummy thread "+i+"'");
Thread thread = new Thread(threadGroup, new MyRunnable(), "Dummy thread "+i);
- thread.run();
+ thread.start();
}
15 years, 8 months
EMBJOPR SVN: r378 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-05-04 18:37:46 -0400 (Mon, 04 May 2009)
New Revision: 378
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java
Log:
JBossASNodeTest updated.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java 2009-05-04 21:51:57 UTC (rev 377)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java 2009-05-04 22:37:46 UTC (rev 378)
@@ -134,8 +134,10 @@
*/
// Launch as much threads as the current number to get higher number.
+ log.info("Starting "+threads1+" threads.");
ThreadGroup threadGroup = new ThreadGroup("Dummy threads");
for( int i = 0; i < threads1; i++ ) {
+ log.debug("Starting thread 'Dummy thread "+i+"'");
Thread thread = new Thread(threadGroup, new MyRunnable(), "Dummy thread "+i);
thread.run();
}
@@ -143,7 +145,10 @@
// Allocate some memory to decrease free mem.
+ log.info("Allocating 100 MB of ram.");
byte tmp[] = new byte[100 * 1024 * 1024]; // Few MB.
+ tmp[0] = 1;
+ tmp[tmp.length-1] = 1;
15 years, 8 months
EMBJOPR SVN: r377 - trunk/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-05-04 17:51:57 -0400 (Mon, 04 May 2009)
New Revision: 377
Modified:
trunk/jsfunit/pom.xml
Log:
JSFUnit POM: Cargo plugin version 1.0 -> 1.0.1-SNAPSHOT
Modified: trunk/jsfunit/pom.xml
===================================================================
--- trunk/jsfunit/pom.xml 2009-05-04 19:29:05 UTC (rev 376)
+++ trunk/jsfunit/pom.xml 2009-05-04 21:51:57 UTC (rev 377)
@@ -5,7 +5,7 @@
<jopr.version>1.2.0-SNAPSHOT</jopr.version>
<cargo.jboss.configuration>default</cargo.jboss.configuration>
<cargo.jboss.bind.address>localhost</cargo.jboss.bind.address>
- <cargo.plugin.version>1.0</cargo.plugin.version><!-- Was: 1.0-SNAPSHOT -->
+ <cargo.plugin.version>1.0.1-SNAPSHOT</cargo.plugin.version><!-- Was: 1.0-SNAPSHOT -->
</properties>
<parent>
@@ -339,9 +339,11 @@
<properties>
<cargo.java.home>${JAVA_HOME}</cargo.java.home>
<!-- Raise permgen size, allow classes unloading and permgen sweep -->
+ <!-- xb.builder.useUnorderedSequence=true is the same what run.sh does. -->
+ <!-- See http://www.nabble.com/changes-in-parsing-with-xb-td22478176.html -->
<cargo.jvmargs>-Dcom.sun.management.jmxremote -Xmx1024m -Dxb.builder.useUnorderedSequence=true -XX:PermSize=256m -XX:MaxPermSize=512m</cargo.jvmargs>
<!-- -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -->
- <!-- JBoss configuration - default, all, minimal, ... -->
+ <!-- JBoss configuration - default, all, standard -->
<cargo.jboss.configuration>${cargo.jboss.configuration}</cargo.jboss.configuration>
</properties>
<!-- Override Cargo's default files (some taken from cargo's .jar, some from 'default') -->
15 years, 8 months
EMBJOPR SVN: r376 - in trunk/jsfunit: src/test/java/org/jboss/jopr/jsfunit/as4 and 4 other directories.
by embjopr-commits@lists.jboss.org
Author: fjuma
Date: 2009-05-04 15:29:05 -0400 (Mon, 04 May 2009)
New Revision: 376
Added:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSSecurityTest.java
trunk/jsfunit/testdata/destinations/ExistingQueueWithSecurityRoleInvalidUserSpecified-service.xml
trunk/jsfunit/testdata/destinations/ExistingQueueWithSecurityRoleNoUserSpecified-service.xml
trunk/jsfunit/testdata/destinations/ExistingQueueWithSecurityRoleUserSpecified-service.xml
trunk/jsfunit/testdata/destinations/ExistingTopicWithSecurityRoleInvalidUserSpecified-service.xml
trunk/jsfunit/testdata/destinations/ExistingTopicWithSecurityRoleNoUserSpecified-service.xml
trunk/jsfunit/testdata/destinations/ExistingTopicWithSecurityRoleUserSpecified-service.xml
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ResourceTestBase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/datasources/DatasourceConfigurationTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/datasources/DatasourceTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSMetricsTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSTest.java
Log:
Adding tests for secure JMS destinations.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-05-04 17:43:37 UTC (rev 375)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-05-04 19:29:05 UTC (rev 376)
@@ -80,6 +80,8 @@
public static final String CONFIGURATION_TAB = "configurationTab";
public static final String CONTROL_TAB = "controlTab";
public static final String CONTENT_TAB = "contentTab";
+
+ public static final String RESOURCE_CONFIGURATION_FORM = "resourceConfigurationForm";
public JSFClientSession getClient() { return client; }
public JSFServerSession getServer() { return server; }
@@ -290,7 +292,7 @@
* @param properties maps property names (eg. "jndi-name",
* "min-pool-size", etc.) to property values
*/
- public void fillOutForm(Map<String, String> properties) {
+ public void fillOutForm(Map<String, String> properties, String formName) {
Iterator itr = properties.keySet().iterator();
// Set each property
@@ -299,7 +301,8 @@
// Make sure the input is enabled
HtmlInput input = enableOrDisableFormInput(propertyName,
- Boolean.TRUE);
+ Boolean.TRUE,
+ formName);
assertFalse("Could not enable: " + propertyName, input.isDisabled());
@@ -313,7 +316,7 @@
for( String propName : EmbJoprTestToolkit.stringPropertyNames(props) ) {
map.put(propName, props.getProperty(propName));
}
- fillOutForm(map);
+ fillOutForm(map, RESOURCE_CONFIGURATION_FORM);
}
/** Check if the form is filled according to given Properties. */
@@ -372,14 +375,15 @@
* If the input box/radio button does not have an enable/disable checkbox,
* return the input element as is.
*/
- public HtmlInput enableOrDisableFormInput(String propertyName, Boolean enableInput) {
+ public HtmlInput enableOrDisableFormInput(String propertyName, Boolean enableInput, String formName) {
- HtmlForm form = (HtmlForm)client.getElement("resourceConfigurationForm");
- if( null == form ){
- // Wrapped. Don't want to add "throws Html..." all over the project.
- throw new RuntimeException(new HtmlElementNotFoundException(
- "Element #resourceConfigurationForm not found. Page dumped.", this));
- }
+ HtmlForm form = (HtmlForm)client.getElement(formName);
+
+ if( null == form ){
+ // Wrapped. Don't want to add "throws Html..." all over the project.
+ throw new RuntimeException(new HtmlElementNotFoundException(
+ "Element " + formName + " not found. Page dumped.", this));
+ }
HtmlInput input = (HtmlInput)form.getFirstByXPath(".//input[@ondblclick='//"
+ propertyName + "']");
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java 2009-05-04 17:43:37 UTC (rev 375)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java 2009-05-04 19:29:05 UTC (rev 376)
@@ -85,7 +85,7 @@
// Configure the properties associated with this datasource
propertiesMap.put("type", DatasourceType.LOCAL_TX_DATASOURCE.getHtmlRadioValue() );
- fillOutForm(propertiesMap);
+ fillOutForm(propertiesMap, RESOURCE_CONFIGURATION_FORM);
// Remove the type property not to be treated later as regular properties.
propertiesMap.remove("type");
}
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ResourceTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ResourceTestBase.java 2009-05-04 17:43:37 UTC (rev 375)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ResourceTestBase.java 2009-05-04 19:29:05 UTC (rev 376)
@@ -68,6 +68,8 @@
public static final String PARAMETERS_FORM_OK_BUTTON = "parametersForm:okButton";
public static final String ADD_NEW_RESOURCE_BUTTON = "actionHeaderForm:addNewNotContent";
public static final String CONTINUE_AFTER_TEMPLATE_SELECTION_BUTTON = "resourceCreateForm:addButton";
+ public static final String EDIT_RESOURCE_CONFIGURATION_FORM_OK_BUTTON = "editResourceConfigurationForm:okButton";
+ public static final String ADD_NEW_CONFIG_BUTTON = "Add New";
// Template selection
public static final String SELECT_TEMPLATE = "selectedTemplate";
@@ -92,6 +94,7 @@
public static final String OPERATION_RESULTS = "operationResults";
public static final String REFRESH_OPERATIONS_TABLE = "refreshLink";
public static final String RESOURCE_SUMMARY_FORM = "resourceSummaryForm";
+ public static final String EDIT_RESOURCE_CONFIGURATION_FORM = "editResourceConfigurationForm";
// Pagination constants
public static final String MAX_ITEMS_PER_PAGE="50";
@@ -137,7 +140,7 @@
*/
protected void setResourceProperties(Map<String, MetaValue> propertiesMap) {
Map<String, String> formattedPropertiesMap = formatPropertiesMap(propertiesMap);
- fillOutForm(formattedPropertiesMap);
+ fillOutForm(formattedPropertiesMap, RESOURCE_CONFIGURATION_FORM);
}
/**
@@ -188,7 +191,7 @@
// Unset the given properties
for(int i = 0; i < propertiesToUnset.length; i++) {
String propertyName = propertiesToUnset[i];
- enableOrDisableFormInput(propertyName, Boolean.FALSE);
+ enableOrDisableFormInput(propertyName, Boolean.FALSE, RESOURCE_CONFIGURATION_FORM);
}
client.click(SAVE_BUTTON);
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/datasources/DatasourceConfigurationTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/datasources/DatasourceConfigurationTest.java 2009-05-04 17:43:37 UTC (rev 375)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/datasources/DatasourceConfigurationTest.java 2009-05-04 19:29:05 UTC (rev 376)
@@ -63,7 +63,7 @@
client.getPageAsText().contains("There was an error retrieving the configuration for this resource"));
Map<String, String> propertiesMapChanges = formatPropertiesMap(propertiesMapChangesAsMetaValues);
- fillOutForm(propertiesMapChanges);
+ fillOutForm(propertiesMapChanges, RESOURCE_CONFIGURATION_FORM);
client.click(SAVE_BUTTON);
// Check for the appropriate success messages
@@ -105,7 +105,7 @@
client.getPageAsText().contains("There was an error retrieving the configuration for this resource"));
Map<String, String> propertiesMapChanges = formatPropertiesMap(propertiesMapChangesAsMetaValues);
- fillOutForm(propertiesMapChanges);
+ fillOutForm(propertiesMapChanges, RESOURCE_CONFIGURATION_FORM);
client.click(SAVE_BUTTON);
// Check for the appropriate success messages
@@ -137,11 +137,11 @@
assertFalse("The configuration page could not be displayed",
client.getPageAsText().contains("There was an error retrieving the configuration for this resource"));
- enableOrDisableFormInput("user-name", Boolean.FALSE);
- enableOrDisableFormInput("idle-timeout-minutes", Boolean.FALSE);
- enableOrDisableFormInput("track-connection-by-tx", Boolean.FALSE);
- enableOrDisableFormInput("domain", Boolean.FALSE);
- enableOrDisableFormInput("no-tx-separate-pools", Boolean.FALSE);
+ enableOrDisableFormInput("user-name", Boolean.FALSE, RESOURCE_CONFIGURATION_FORM);
+ enableOrDisableFormInput("idle-timeout-minutes", Boolean.FALSE, RESOURCE_CONFIGURATION_FORM);
+ enableOrDisableFormInput("track-connection-by-tx", Boolean.FALSE, RESOURCE_CONFIGURATION_FORM);
+ enableOrDisableFormInput("domain", Boolean.FALSE, RESOURCE_CONFIGURATION_FORM);
+ enableOrDisableFormInput("no-tx-separate-pools", Boolean.FALSE, RESOURCE_CONFIGURATION_FORM);
client.click(SAVE_BUTTON);
// Check for the appropriate success messages
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/datasources/DatasourceTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/datasources/DatasourceTest.java 2009-05-04 17:43:37 UTC (rev 375)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/datasources/DatasourceTest.java 2009-05-04 19:29:05 UTC (rev 376)
@@ -83,7 +83,7 @@
client.click(CONTINUE_AFTER_TEMPLATE_SELECTION_BUTTON);
// Configure the properties associated with this datasource
- fillOutForm(propertiesMap);
+ fillOutForm(propertiesMap, RESOURCE_CONFIGURATION_FORM);
}
/**
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSMetricsTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSMetricsTest.java 2009-05-04 17:43:37 UTC (rev 375)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSMetricsTest.java 2009-05-04 19:29:05 UTC (rev 376)
@@ -647,19 +647,4 @@
disconnect();
deleteDestination(DestinationType.QUEUE, jndiName);
}
-
- /**
- * Common code for the metrics tests.
- */
- private void checkDestinationMetrics(String jndiName,
- Map<String, String> expectedMetrics,
- ArrayList<String> summaryMetrics,
- DestinationType destinationType) throws Exception {
- checkResourceMetrics(JMS_NAV_LABEL, destinationType.getNavLabel(),
- jndiName, expectedMetrics, summaryMetrics);
-
- // Clean up
- disconnect();
- deleteDestination(destinationType, jndiName);
- }
}
Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSSecurityTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSSecurityTest.java (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSSecurityTest.java 2009-05-04 19:29:05 UTC (rev 376)
@@ -0,0 +1,349 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.jmsDestinations;
+
+import com.gargoylesoftware.htmlunit.html.*;
+import junit.framework.Test;
+import org.jboss.jopr.jsfunit.*;
+import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
+import javax.jms.Topic;
+import javax.jms.TopicSession;
+import javax.jms.Queue;
+import javax.jms.QueueSession;
+import javax.jms.JMSSecurityException;
+import java.util.Map;
+import java.util.LinkedHashMap;
+
+/**
+ * This class tests topics and queues that have security roles configured.
+ * This class should be run against JBAS 5.x.
+ *
+ * @author Farah Juma
+ */
+public class JMSSecurityTest extends JMSTest {
+
+ // A pre-defined JMS user from messaging/hsqldb-persistence-service.xml
+ private static final String JMS_USER = "dynsub";
+
+ // A pre-defined security role name from messaging/hsqldb-persistence-service.xml
+ private static final String ROLE_NAME = "publisher";
+
+ /**
+ * Test Name: testSendMessageToSecureTopicAndSpecifyUser
+ * Assertion: Verify the ability to send a message to a topic that has
+ * a security role configured.
+ */
+ public void testSendMessageToSecureTopicAndSpecifyUser() throws Exception {
+ String jndiName = "TopicWithSecurityRoleSpecifyUser";
+ String expectedMessage = ADD_MESSAGE + DestinationType.TOPIC.getName();
+
+ createDestinationWithSecurityRole(DestinationType.TOPIC, TOPIC_DEFAULT_TEMPLATE,
+ jndiName, expectedMessage, TOPIC_COMPONENT_TYPE,
+ ROLE_NAME, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE);
+ sendMessageToSecureTopicAndSpecifyUser(jndiName, JMS_USER, JMS_USER);
+ }
+
+ /**
+ * Test Name: testSendMessageToSecureTopicAndSpecifyUserUsingExistingServiceFile
+ * Assertion: Verify the ability to send a message to a topic that has
+ * a security role defined. Use a topic that already exists.
+ */
+ public void testSendMessageToSecureTopicAndSpecifyUserUsingExistingServiceFile() throws Exception {
+ String jndiName = "ExistingTopicWithSecurityRoleUserSpecified";
+
+ expandNavTreeArrow(JMS_NAV_LABEL);
+ sendMessageToSecureTopicAndSpecifyUser(jndiName, JMS_USER, JMS_USER);
+ }
+
+ /**
+ * Test Name: testSendMessageToSecureTopicAndSpecifyInvalidUser
+ * Assertion: Attempt to send a message to a secure topic, specifying an
+ * invalid username. Make sure a JMSSecurityException occurs.
+ */
+ public void testSendMessageToSecureTopicAndSpecifyInvalidUser() throws Exception {
+ String jndiName = "TopicWithSecurityRoleSpecifyInvalidUser";
+ String expectedMessage = ADD_MESSAGE + DestinationType.TOPIC.getName();
+ Exception jmsSecurityException = null;
+
+ createDestinationWithSecurityRole(DestinationType.TOPIC, TOPIC_DEFAULT_TEMPLATE,
+ jndiName, expectedMessage, TOPIC_COMPONENT_TYPE,
+ ROLE_NAME, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE);
+
+ // Specify an invalid user when creating the topic connection
+ try {
+ sendMessageToSecureTopicAndSpecifyUser(jndiName, "fakeUser", "fakePassword");
+ } catch (JMSSecurityException e) {
+ jmsSecurityException = e;
+ } finally {
+ assertNotNull("Expected a JMSSecurityException to be thrown", jmsSecurityException);
+ deleteDestination(DestinationType.TOPIC, jndiName);
+ }
+ }
+
+ /**
+ * Test Name: testSendMessageToSecureTopicAndSpecifyInvalidUserUsingExistingServiceFile
+ * Assertion: Attempt to send a message to a secure topic, specifying an
+ * invalid username. Make sure a JMSSecurityException occurs. Use a topic
+ * that already exists.
+ */
+ public void testSendMessageToSecureTopicAndSpecifyInvalidUserUsingExistingServiceFile() throws Exception {
+ String jndiName = "ExistingTopicWithSecurityRoleInvalidUserSpecified";
+ Exception jmsSecurityException = null;
+
+ expandNavTreeArrow(JMS_NAV_LABEL);
+
+ // Specify an invalid user when creating the topic connection
+ try {
+ sendMessageToSecureTopicAndSpecifyUser(jndiName, "fakeUser", "fakePassword");
+ } catch (JMSSecurityException e) {
+ jmsSecurityException = e;
+ } finally {
+ assertNotNull("Expected a JMSSecurityException to be thrown", jmsSecurityException);
+ deleteDestination(DestinationType.TOPIC, jndiName);
+ }
+ }
+
+ /**
+ * Attempt to send a message to the topic given by jndiName,
+ * specifying the given username and password when creating the
+ * topic connection. If the username and password are not valid,
+ * a JMSSecurityException will be thrown.
+ */
+ private void sendMessageToSecureTopicAndSpecifyUser(String jndiName,
+ String username,
+ String password) throws Exception {
+
+ TopicSession session = createTopicSessionAndSpecifyUser(username, password);
+ Topic topic = getTopic(jndiName);
+
+ createDurableTopicSubscriber(session, topic, jndiName + "Subscriber");
+ publishMessages(session, topic, 1);
+
+ Map<String, String> expectedMetrics = new LinkedHashMap<String, String>();
+ expectedMetrics.put(ALL_MSG_COUNT, "1.0");
+
+ checkDestinationMetrics(jndiName, expectedMetrics, getTopicSummaryMetrics(),
+ DestinationType.TOPIC);
+ }
+
+ /**
+ * Test Name: testSendMessageToSecureTopicWithoutSpecifyingUser
+ * Assertion: Make sure an error occurs when trying to send a message, without
+ * specifying a user, to a topic that has a security role configured.
+ *
+ * This test should pass if a JMSSecurityException is thrown.
+ */
+ public void testSendMessageToSecureTopicWithoutSpecifyingUser() throws Exception {
+ String jndiName = "TopicWithSecurityRoleNoUserSpecified";
+ String expectedMessage = ADD_MESSAGE + DestinationType.TOPIC.getName();
+
+ createDestinationWithSecurityRole(DestinationType.TOPIC, TOPIC_DEFAULT_TEMPLATE,
+ jndiName, expectedMessage, TOPIC_COMPONENT_TYPE,
+ ROLE_NAME, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE);
+
+ sendMessageToSecureTopicWithoutSpecifyingUser(jndiName);
+ }
+
+ /**
+ * Test Name: testSendMessageToSecureTopicWithoutSpecifyingUserUsingExistingServiceFile
+ * Assertion: Make sure an error occurs when trying to send a message, without
+ * specifying a user, to a topic that has a security role configured.
+ * Use a topic that already exists.
+ *
+ * This test should pass if a JMSSecurityException is thrown.
+ */
+ public void testSendMessageToSecureTopicWithoutSpecifyingUserUsingExistingServiceFile() throws Exception {
+ String jndiName = "ExistingTopicWithSecurityRoleNoUserSpecified";
+
+ expandNavTreeArrow(JMS_NAV_LABEL);
+ sendMessageToSecureTopicWithoutSpecifyingUser(jndiName);
+ }
+
+ /**
+ * Common code for the testSendMessageToSecureTopicWithoutSpecifyingUser* tests.
+ */
+ private void sendMessageToSecureTopicWithoutSpecifyingUser(String jndiName) throws Exception {
+
+ Exception jmsSecurityException = null;
+
+ // We should not be able to send a message since no user was specified when
+ // creating the topic connection
+ try {
+ createTopicSessionAndSendMessages(1, jndiName);
+ } catch (JMSSecurityException e) {
+ jmsSecurityException = e;
+ } finally {
+ assertNotNull("Expected a JMSSecurityException to be thrown", jmsSecurityException);
+ deleteDestination(DestinationType.TOPIC, jndiName);
+ }
+ }
+
+ /**
+ * Test Name: testSendMessageToSecureQueueAndSpecifyUser
+ * Assertion: Verify the ability to send a message to a queue that has
+ * a security role configured.
+ */
+ public void testSendMessageToSecureQueueAndSpecifyUser() throws Exception {
+ String jndiName = "QueueWithSecurityRoleSpecifyUser";
+ String expectedMessage = ADD_MESSAGE + DestinationType.QUEUE.getName();
+
+ createDestinationWithSecurityRole(DestinationType.QUEUE, QUEUE_DEFAULT_TEMPLATE,
+ jndiName, expectedMessage, QUEUE_COMPONENT_TYPE,
+ ROLE_NAME, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE);
+ sendMessageToSecureQueueAndSpecifyUser(jndiName, JMS_USER, JMS_USER);
+ }
+
+ /**
+ * Test Name: testSendMessageToSecureQueueAndSpecifyUserUsingExistingServiceFile
+ * Assertion: Verify the ability to send a message to a queue that has
+ * a security role defined. Use a queue that already exists.
+ */
+ public void testSendMessageToSecureQueueAndSpecifyUserUsingExistingServiceFile() throws Exception {
+ String jndiName = "ExistingQueueWithSecurityRoleUserSpecified";
+
+ expandNavTreeArrow(JMS_NAV_LABEL);
+ sendMessageToSecureQueueAndSpecifyUser(jndiName, JMS_USER, JMS_USER);
+ }
+
+ /**
+ * Test Name: testSendMessageToSecureQueueAndSpecifyInvalidUser
+ * Assertion: Attempt to send a message to a secure queue, specifying an
+ * invalid username. Make sure a JMSSecurityException occurs.
+ */
+ public void testSendMessageToSecureQueueAndSpecifyInvalidUser() throws Exception {
+ String jndiName = "QueueWithSecurityRoleSpecifyInvalidUser";
+ String expectedMessage = ADD_MESSAGE + DestinationType.QUEUE.getName();
+ Exception jmsSecurityException = null;
+
+ createDestinationWithSecurityRole(DestinationType.QUEUE, QUEUE_DEFAULT_TEMPLATE,
+ jndiName, expectedMessage, QUEUE_COMPONENT_TYPE,
+ ROLE_NAME, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE);
+
+ // Specify an invalid username when creating the queue connection
+ try {
+ sendMessageToSecureQueueAndSpecifyUser(jndiName, "fakeUser", "fakePassword");
+ } catch (JMSSecurityException e) {
+ jmsSecurityException = e;
+ } finally {
+ assertNotNull("Expected a JMSSecurityException to be thrown", jmsSecurityException);
+ deleteDestination(DestinationType.QUEUE, jndiName);
+ }
+ }
+
+ /**
+ * Test Name: testSendMessageToSecureQueueAndSpecifyInvalidUserUsingExistingServiceFile
+ * Assertion: Attempt to send a message to a secure queue, specifying an
+ * invalid username. Make sure a JMSSecurityException occurs. Use a queue
+ * that already exists.
+ */
+ public void testSendMessageToSecureQueueAndSpecifyInvalidUserUsingExistingServiceFile() throws Exception {
+ String jndiName = "ExistingQueueWithSecurityRoleInvalidUserSpecified";
+ Exception jmsSecurityException = null;
+
+ expandNavTreeArrow(JMS_NAV_LABEL);
+
+ // Specify an invalid username when creating the queue connection
+ try {
+ sendMessageToSecureQueueAndSpecifyUser(jndiName, "fakeUser", "fakePassword");
+ } catch (JMSSecurityException e) {
+ jmsSecurityException = e;
+ } finally {
+ assertNotNull("Expected a JMSSecurityException to be thrown", jmsSecurityException);
+ deleteDestination(DestinationType.QUEUE, jndiName);
+ }
+ }
+
+ /**
+ * Attempt to send a message to the queue given by jndiName,
+ * specifying the given username and password when creating the
+ * queue connection. If the username and password are not valid,
+ * a JMSSecurityException will be thrown.
+ */
+ private void sendMessageToSecureQueueAndSpecifyUser(String jndiName,
+ String username,
+ String password) throws Exception {
+
+ QueueSession session = createQueueSessionAndSpecifyUser(username, password);
+ Queue queue = getQueue(jndiName);
+
+ sendMessages(session, queue, 1);
+
+ Map<String, String> expectedMetrics = new LinkedHashMap<String, String>();
+ expectedMetrics.put(MSG_COUNT, "1.0");
+
+ checkDestinationMetrics(jndiName, expectedMetrics, getQueueSummaryMetrics(),
+ DestinationType.QUEUE);
+ }
+
+ /**
+ * Test Name: testSendMessageToSecureQueueWithoutSpecifyingUser
+ * Assertion: Make sure an error occurs when trying to send a message, without
+ * specifying a user, to a queue that has a security role configured.
+ *
+ * This test should pass if a JMSSecurityException is thrown.
+ */
+ public void testSendMessageToSecureQueueWithoutSpecifyingUser() throws Exception {
+ String jndiName = "QueueWithSecurityRoleNoUserSpecified";
+ String expectedMessage = ADD_MESSAGE + DestinationType.QUEUE.getName();
+
+ createDestinationWithSecurityRole(DestinationType.QUEUE, QUEUE_DEFAULT_TEMPLATE,
+ jndiName, expectedMessage, QUEUE_COMPONENT_TYPE,
+ ROLE_NAME, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE);
+
+ sendMessageToSecureQueueWithoutSpecifyingUser(jndiName);
+ }
+
+ /**
+ * Test Name: testSendMessageToSecureQueueWithoutSpecifyingUserUsingExistingServiceFile
+ * Assertion: Make sure an error occurs when trying to send a message, without
+ * specifying a user, to a queue that has a security role configured.
+ * Use a queue that already exists.
+ *
+ * This test should pass if a JMSSecurityException is thrown.
+ */
+ public void testSendMessageToSecureQueueWithoutSpecifyingUserUsingExistingServiceFile() throws Exception {
+ String jndiName = "ExistingQueueWithSecurityRoleNoUserSpecified";
+
+ expandNavTreeArrow(JMS_NAV_LABEL);
+ sendMessageToSecureQueueWithoutSpecifyingUser(jndiName);
+ }
+
+ /**
+ * Common code for the testSendMessageToSecureQueueWithoutSpecifyingUser* tests.
+ */
+ private void sendMessageToSecureQueueWithoutSpecifyingUser(String jndiName) throws Exception {
+
+ Exception jmsSecurityException = null;
+
+ // We should not be able to send a message since no user is specified when
+ // creating the queue connection
+ try {
+ createQueueSessionAndSendMessages(1, jndiName);
+ } catch (JMSSecurityException e) {
+ jmsSecurityException = e;
+ } finally {
+ assertNotNull("Expected a JMSSecurityException to be thrown", jmsSecurityException);
+ deleteDestination(DestinationType.QUEUE, jndiName);
+ }
+ }
+}
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSTest.java 2009-05-04 17:43:37 UTC (rev 375)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSTest.java 2009-05-04 19:29:05 UTC (rev 376)
@@ -53,6 +53,12 @@
import javax.jms.TextMessage;
import javax.jms.JMSException;
import javax.naming.NamingException;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
/**
* This is the base test class for JMS tests. This class
@@ -162,6 +168,25 @@
public TopicConnection topicConnection = null;
public QueueConnection queueConnection = null;
+ /** The following variables are needed for tests that use secure topics/queues. **/
+
+ // The meta type
+ protected static final MapCompositeMetaType securityConfType;
+
+ // The composite meta type.
+ public static MutableCompositeMetaType composite;
+
+ static
+ {
+ // Create the meta type
+ composite = new MutableCompositeMetaType("SecurityConfig", "The security config");
+ composite.addItem("read", "read permission", SimpleMetaType.BOOLEAN);
+ composite.addItem("write", "write permission", SimpleMetaType.BOOLEAN);
+ composite.addItem("create", "create permission", SimpleMetaType.BOOLEAN);
+ composite.freeze();
+ securityConfType = new MapCompositeMetaType(composite);
+ }
+
/**
* Create a new topic or queue using the given destination type and properties.
*/
@@ -232,6 +257,101 @@
}
/**
+ * Create a new topic or queue with a security role configured.
+ */
+ protected void createDestinationWithSecurityRole(DestinationType destinationType,
+ String destinationTemplate,
+ String jndiName,
+ String expectedMessage,
+ ComponentType componentType,
+ String roleName,
+ boolean canRead,
+ boolean canWrite,
+ boolean canCreate) throws Exception {
+
+ Map<String, MetaValue> propertiesMap = new LinkedHashMap<String, MetaValue>();
+ propertiesMap.put("name", SimpleValueSupport.wrap(jndiName));
+ propertiesMap.put("JNDIName", SimpleValueSupport.wrap(jndiName));
+
+ // Fill in the property values
+ createDestination(destinationType, destinationTemplate, propertiesMap);
+
+ // Add a security role
+ createSecurityRole(roleName, canRead, canWrite, canCreate);
+
+ checkClientAndServerMessages(expectedMessage, expectedMessage, false);
+
+ // Make sure the destination is deployed and that the securityConfig property
+ // was set correctly
+ assertTrue("The destination is not deployed ",
+ isDeployed(jndiName + "-service.xml"));
+
+ Map<String, MetaValue> actualProperties = getComponentProperties(jndiName, componentType);
+
+ Map<String, MetaValue> values = new HashMap<String, MetaValue>();
+ values.put(roleName, createCompositeValue(true, true, true));
+ CompositeValue expectedSecurityConfigProp = new MapCompositeValueSupport(values, securityConfType);
+
+ assertEquals("The 'securityConfig' property was not set correctly: ",
+ expectedSecurityConfigProp,
+ actualProperties.get("securityConfig"));
+ }
+
+ /**
+ * Create a security role.
+ */
+ protected void createSecurityRole(String roleName, boolean canRead,
+ boolean canWrite, boolean canCreate) throws IOException {
+
+ HtmlForm form = (HtmlForm)client.getElement(RESOURCE_CONFIGURATION_FORM);
+ String xpath = ".//a[@title=\"" + ADD_NEW_CONFIG_BUTTON + "\"]";
+
+ HtmlAnchor addSecurityRoleButton = (HtmlAnchor)form.getFirstByXPath(xpath);
+ addSecurityRoleButton.click();
+
+ // Create the new role
+ Map<String, MetaValue> securityRoleMap = new LinkedHashMap<String, MetaValue>();
+ securityRoleMap.put("name", SimpleValueSupport.wrap(roleName));
+ securityRoleMap.put("read", SimpleValueSupport.wrap(canRead));
+ securityRoleMap.put("write", SimpleValueSupport.wrap(canWrite));
+ securityRoleMap.put("create", SimpleValueSupport.wrap(canCreate));
+
+ Map<String, String> formattedPropertiesMap = formatPropertiesMap(securityRoleMap);
+ fillOutForm(formattedPropertiesMap, EDIT_RESOURCE_CONFIGURATION_FORM);
+
+ client.click(EDIT_RESOURCE_CONFIGURATION_FORM_OK_BUTTON);
+ client.click(SAVE_BUTTON);
+ }
+
+ /**
+ * Set up a security role.
+ */
+ protected CompositeValue createCompositeValue(Boolean read, Boolean write, Boolean create) {
+ Map<String, MetaValue> map = new HashMap<String, MetaValue>();
+
+ map.put("read", new SimpleValueSupport(SimpleMetaType.BOOLEAN, read));
+ map.put("write", new SimpleValueSupport(SimpleMetaType.BOOLEAN, write));
+ map.put("create", new SimpleValueSupport(SimpleMetaType.BOOLEAN, create));
+
+ return new CompositeValueSupport(composite, map);
+ }
+
+ /**
+ * Check that the metrics for the given destination are correct.
+ */
+ protected void checkDestinationMetrics(String jndiName,
+ Map<String, String> expectedMetrics,
+ ArrayList<String> summaryMetrics,
+ DestinationType destinationType) throws Exception {
+ checkResourceMetrics(JMS_NAV_LABEL, destinationType.getNavLabel(),
+ jndiName, expectedMetrics, summaryMetrics);
+
+ // Clean up
+ disconnect();
+ deleteDestination(destinationType, jndiName);
+ }
+
+ /**
* Create a map of property names to property values for a particular
* destination. The desired property names are given by specificProperties.
* (This is useful when we need to check the values of some specific properties
@@ -511,4 +631,43 @@
createDurableTopicSubscriber(session, topic, jndiName + "Subscriber" + i);
}
}
+
+ /**
+ * Create a topic session and specify the given username and password
+ * when creating the TopicConnection.
+ */
+ protected TopicSession createTopicSessionAndSpecifyUser(String username,
+ String password) throws Exception {
+ InitialContext context = new InitialContext();
+ Object tmp = context.lookup(TOPIC_FACTORY);
+
+ TopicConnectionFactory tcf = (TopicConnectionFactory)tmp;
+ topicConnection = tcf.createTopicConnection(username, password);
+ topicConnection.setClientID(CLIENT_ID);
+
+ TopicSession topicSession = topicConnection.createTopicSession(Boolean.FALSE,
+ TopicSession.AUTO_ACKNOWLEDGE);
+ topicConnection.start();
+
+ return topicSession;
+ }
+
+ /**
+ * Create a queue session and specify the given username and password
+ * when creating the QueueConnection.
+ */
+ protected QueueSession createQueueSessionAndSpecifyUser(String username,
+ String password) throws Exception {
+ InitialContext context = new InitialContext();
+ Object tmp = context.lookup(QUEUE_FACTORY);
+
+ QueueConnectionFactory qcf = (QueueConnectionFactory)tmp;
+ queueConnection = qcf.createQueueConnection(username, password);
+
+ QueueSession queueSession = queueConnection.createQueueSession(Boolean.FALSE,
+ QueueSession.AUTO_ACKNOWLEDGE);
+ queueConnection.start();
+
+ return queueSession;
+ }
}
Added: trunk/jsfunit/testdata/destinations/ExistingQueueWithSecurityRoleInvalidUserSpecified-service.xml
===================================================================
--- trunk/jsfunit/testdata/destinations/ExistingQueueWithSecurityRoleInvalidUserSpecified-service.xml (rev 0)
+++ trunk/jsfunit/testdata/destinations/ExistingQueueWithSecurityRoleInvalidUserSpecified-service.xml 2009-05-04 19:29:05 UTC (rev 376)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<server>
+ <mbean xmbean-dd="xmdesc/Queue-xmbean.xml" name="jboss.messaging.destination:service=Queue,name=ExistingQueueWithSecurityRoleInvalidUserSpecified" code="org.jboss.jms.server.destination.QueueService">
+ <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>
+ <attribute name="JNDIName">ExistingQueueWithSecurityRoleInvalidUserSpecified</attribute>
+ <attribute name="SecurityConfig">
+ <security>
+ <role create="true" name="publisher" read="true" write="true"/>
+ </security>
+ </attribute>
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>
Added: trunk/jsfunit/testdata/destinations/ExistingQueueWithSecurityRoleNoUserSpecified-service.xml
===================================================================
--- trunk/jsfunit/testdata/destinations/ExistingQueueWithSecurityRoleNoUserSpecified-service.xml (rev 0)
+++ trunk/jsfunit/testdata/destinations/ExistingQueueWithSecurityRoleNoUserSpecified-service.xml 2009-05-04 19:29:05 UTC (rev 376)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<server>
+ <mbean xmbean-dd="xmdesc/Queue-xmbean.xml" name="jboss.messaging.destination:service=Queue,name=ExistingQueueWithSecurityRoleNoUserSpecified" code="org.jboss.jms.server.destination.QueueService">
+ <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>
+ <attribute name="JNDIName">ExistingQueueWithSecurityRoleNoUserSpecified</attribute>
+ <attribute name="SecurityConfig">
+ <security>
+ <role create="true" name="publisher" read="true" write="true"/>
+ </security>
+ </attribute>
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>
Added: trunk/jsfunit/testdata/destinations/ExistingQueueWithSecurityRoleUserSpecified-service.xml
===================================================================
--- trunk/jsfunit/testdata/destinations/ExistingQueueWithSecurityRoleUserSpecified-service.xml (rev 0)
+++ trunk/jsfunit/testdata/destinations/ExistingQueueWithSecurityRoleUserSpecified-service.xml 2009-05-04 19:29:05 UTC (rev 376)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<server>
+ <mbean xmbean-dd="xmdesc/Queue-xmbean.xml" name="jboss.messaging.destination:service=Queue,name=ExistingQueueWithSecurityRoleUserSpecified" code="org.jboss.jms.server.destination.QueueService">
+ <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>
+ <attribute name="JNDIName">ExistingQueueWithSecurityRoleUserSpecified</attribute>
+ <attribute name="SecurityConfig">
+ <security>
+ <role create="true" name="publisher" read="true" write="true"/>
+ </security>
+ </attribute>
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>
Added: trunk/jsfunit/testdata/destinations/ExistingTopicWithSecurityRoleInvalidUserSpecified-service.xml
===================================================================
--- trunk/jsfunit/testdata/destinations/ExistingTopicWithSecurityRoleInvalidUserSpecified-service.xml (rev 0)
+++ trunk/jsfunit/testdata/destinations/ExistingTopicWithSecurityRoleInvalidUserSpecified-service.xml 2009-05-04 19:29:05 UTC (rev 376)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<server>
+ <mbean xmbean-dd="xmdesc/Topic-xmbean.xml" name="jboss.messaging.destination:service=Topic,name=ExistingTopicWithSecurityRoleInvalidUserSpecified" code="org.jboss.jms.server.destination.TopicService">
+ <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.TopicServiceMO)</annotation>
+ <attribute name="JNDIName">ExistingTopicWithSecurityRoleInvalidUserSpecified</attribute>
+ <attribute name="SecurityConfig">
+ <security>
+ <role create="true" name="publisher" read="true" write="true"/>
+ </security>
+ </attribute>
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>
Added: trunk/jsfunit/testdata/destinations/ExistingTopicWithSecurityRoleNoUserSpecified-service.xml
===================================================================
--- trunk/jsfunit/testdata/destinations/ExistingTopicWithSecurityRoleNoUserSpecified-service.xml (rev 0)
+++ trunk/jsfunit/testdata/destinations/ExistingTopicWithSecurityRoleNoUserSpecified-service.xml 2009-05-04 19:29:05 UTC (rev 376)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<server>
+ <mbean xmbean-dd="xmdesc/Topic-xmbean.xml" name="jboss.messaging.destination:service=Topic,name=ExistingTopicWithSecurityRoleNoUserSpecified" code="org.jboss.jms.server.destination.TopicService">
+ <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.TopicServiceMO)</annotation>
+ <attribute name="JNDIName">ExistingTopicWithSecurityRoleNoUserSpecified</attribute>
+ <attribute name="SecurityConfig">
+ <security>
+ <role create="true" name="publisher" read="true" write="true"/>
+ </security>
+ </attribute>
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>
Added: trunk/jsfunit/testdata/destinations/ExistingTopicWithSecurityRoleUserSpecified-service.xml
===================================================================
--- trunk/jsfunit/testdata/destinations/ExistingTopicWithSecurityRoleUserSpecified-service.xml (rev 0)
+++ trunk/jsfunit/testdata/destinations/ExistingTopicWithSecurityRoleUserSpecified-service.xml 2009-05-04 19:29:05 UTC (rev 376)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<server>
+ <mbean xmbean-dd="xmdesc/Topic-xmbean.xml" name="jboss.messaging.destination:service=Topic,name=ExistingTopicWithSecurityRoleUserSpecified" code="org.jboss.jms.server.destination.TopicService">
+ <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.TopicServiceMO)</annotation>
+ <attribute name="JNDIName">ExistingTopicWithSecurityRoleUserSpecified</attribute>
+ <attribute name="SecurityConfig">
+ <security>
+ <role create="true" name="publisher" read="true" write="true"/>
+ </security>
+ </attribute>
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>
15 years, 8 months
EMBJOPR SVN: r375 - in trunk/jsfunit: src/test/java/org/jboss/jopr/jsfunit and 3 other directories.
by embjopr-commits@lists.jboss.org
Author: smcgowan(a)redhat.com
Date: 2009-05-04 13:43:37 -0400 (Mon, 04 May 2009)
New Revision: 375
Added:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/RarTest.java
trunk/jsfunit/testdata/rar/
trunk/jsfunit/testdata/rar/jbosstestadapter.rar
Modified:
trunk/jsfunit/pom.xml
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
Log:
Basic Resource Adapter Tests, pom version updates
Modified: trunk/jsfunit/pom.xml
===================================================================
--- trunk/jsfunit/pom.xml 2009-05-04 17:12:38 UTC (rev 374)
+++ trunk/jsfunit/pom.xml 2009-05-04 17:43:37 UTC (rev 375)
@@ -110,13 +110,13 @@
<dependency>
<groupId>org.jboss.integration</groupId>
<artifactId>jboss-profileservice-spi</artifactId>
- <version>5.1.0.CR2</version>
+ <version>5.1.0.CR3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.man</groupId>
<artifactId>jboss-metatype</artifactId>
- <version>2.1.0.CR4</version>
+ <version>2.1.0.CR8</version>
<scope>provided</scope>
</dependency>
<dependency>
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-05-04 17:12:38 UTC (rev 374)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-05-04 17:43:37 UTC (rev 375)
@@ -153,10 +153,11 @@
public static final String WAR_UNPACKED_ZIP = "unpacked-web1.war.zip";
+ // RAR
+ public static final String BASIC_RAR = "jbosstestadapter.rar";
-
// Defaults
public static final String[] WAR_DEFAULTS = new String[]{
"ROOT.war", "invoker.war",
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java 2009-05-04 17:12:38 UTC (rev 374)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java 2009-05-04 17:43:37 UTC (rev 375)
@@ -154,7 +154,23 @@
}
}
+ public boolean isRarDeployed(String rarName) throws RuntimeException
+ {
+ try {
+ String query = "jboss.deployment:id=\"vfszip:" +
+ System.getProperty("jsfunit.deploy.dir") + "/" + rarName + "/\",*";
+ //String query = String.format("jboss.deployment:id=\"vfszip:%s/%s/\",*",
+ // System.getProperty("jsfunit.deploy.dir"), rarName );
+ return isMBeanStateDeployedByQuery(query);
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+
}// ApplicationTestBaseAS5
Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/RarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/RarTest.java (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/RarTest.java 2009-05-04 17:43:37 UTC (rev 375)
@@ -0,0 +1,583 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.Page;
+import com.gargoylesoftware.htmlunit.WebClient;
+import org.jboss.jopr.jsfunit.util.DescribedCondition;
+import org.jboss.jopr.jsfunit.util.ActiveConditionChecker;
+import org.jboss.jopr.jsfunit.*;
+import com.gargoylesoftware.htmlunit.html.*;
+import java.io.*;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.lang.math.RandomUtils;
+import org.jboss.jopr.jsfunit.AppConstants.DeployableTypes;
+import org.jboss.jopr.jsfunit.exceptions.*;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.*;
+import org.w3c.dom.Node;
+
+
+
+/**
+ * This class contains tests for testing the EmbJopr Application
+ * Management Functions for Resource Adapters with JBoss AS 5.
+ *
+ * @author Shelly McGowan
+ *
+ */
+public class RarTest extends ApplicationTestBaseAS5 {
+
+ public static final DeployableTypes APP_TYPE = DeployableTypes.RAR;
+
+
+
+ /**
+ * @return the suite of tests being tested
+ */
+ public static Test suite()
+ {
+ String testToRun = System.getProperty("jsfunit.test.single");
+ if( null == testToRun ){
+ return new TestSuite(RarTest.class);
+ }
+ else{
+ // TODO: Try running single test set in system property.
+ // http://members.pingnet.ch/gamma/junit.htm
+ TestSuite suite = new TestSuite();
+ //suite.addTest(this.getClass().getConstructor(String.class).newInstance(testToRun));
+ suite.addTest( new RarTest(testToRun) );
+ return suite;
+ }
+ }
+
+ public RarTest() {
+ }
+ private RarTest(String testToRun) {
+ super(testToRun);
+ }
+
+
+ /*
+ * testName: testBasicRarDeployment
+ * assertion: verify basic deployment of a standalone resource adapter
+ * test Strategy: Navigate to Resource Adapter.
+ * Add a new resource. Verify the resource was successfully
+ * deployed. Undeploy the archive for test clean up purposes.
+ *
+ */
+ public void testBasicRarDeployment() throws IOException, EmbJoprTestException
+ {
+
+ final String DEPLOYABLE_NAME = BASIC_RAR;
+
+ try {
+ // Deploy the RAR.
+ String rarFilePath = ejtt.getTestDataDir() + "/rar/"+DEPLOYABLE_NAME;
+ deployRar( rarFilePath );
+
+ String expectedMessage = DEPLOYABLE_NAME + " created successfully";
+
+ checkClientAndServerMessages(expectedMessage, expectedMessage, false);
+
+ assertTrue("JMX doesn't report RAR, jbosstestadapter.rar as deployed.", isRarDeployed(BASIC_RAR));
+ }
+ finally {
+ ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
+ }
+
+ assertFalse(isRarDeployed(BASIC_RAR));
+
+ }
+
+
+ /**
+ * assertion: Verify the navigation sequence to Resource Adapters.
+ *
+ * test Strategy:
+ *
+ * From the root of the navigation tree:i
+ * Click JBossAS Servers ==> JBoss App Server:${config}
+ * ==> Applications ==> Resource Adapters
+ *
+ */
+ public void testNavigationToRar() throws IOException, HtmlElementNotFoundException,
+ ActionOutOfSyncException, ActionNotAvailableException, EmbJoprTestException, InterruptedException
+ {
+
+ // JBossAS Servers node
+ NavTreeNode nodeServers = ejtt.getNavTree().getNodeByLabel("JBossAS Servers");
+ nodeServers.click();
+
+ {
+ String headerText = "JBossAS Server";
+ String jbossConfig = ejtt.getJBossConfig();
+
+ assertTrue("Page doesn't contain the header: "+headerText,
+ client.getPageAsText().contains(headerText));
+
+ assertTrue("EmbJopr should list at least one server (the one it is running on)" +
+ " and that should be in the UP sate.",
+ client.getPageAsText().contains("UP"));
+ // Check whether the server is listed. If not, Exception is thrown.
+ ContentTableRow row =
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("JBoss Application Server")
+ .getFirstRowContainingLink("JBoss AS 5 ("+jbossConfig+")");
+ // Click the server link
+ //HtmlAnchor link row.getLinkByLabel("JBAS (default)");
+ Node firstLink = row.getCellByColumnName("Name").getElementsByTagName("a").item(0);
+ if( null == firstLink || !(firstLink instanceof HtmlAnchor) )
+ throw new HtmlElementNotFoundException("Can't find the server link.");
+
+ ((HtmlAnchor)firstLink).click();
+ }
+
+ // JBoss App Server:${config} node
+ {
+ String pageText = client.getPageAsText();
+
+ String jbossConfig = ejtt.getJBossConfig();
+ String headerText = "JBoss AS 5 ("+jbossConfig+")";
+ assertTrue("Page doesn't contain the header: "+headerText,
+ pageText.contains(headerText));
+
+ headerText = "General Properties";
+ assertTrue("Page doesn't contain the header: "+headerText,
+ pageText.contains(headerText));
+
+ ejtt.getNavTree().getNodeByLabel("Applications").click();
+
+ }
+
+ // Applications node
+ {
+
+ ejtt.getTabMenu().clickTab("Summary");
+
+ HtmlTable tableElement = (HtmlTable)client.getElement("categorySummaryForm:dataTable");
+ ContentTable table = ejtt.getTabMenu().getTabContentBox().getTable(tableElement);
+ ContentTableRow row = table.getFirstRowContainingText("UP");
+
+ // Go further - try to click on any Application that is up.
+ HtmlAnchor link = row.getFirstLinkFromColumn("Name");
+ link.click();
+ }
+
+
+ {
+ // Go back to applications Sumary screen.
+ ejtt.getNavTree().getNodeByLabel("Applications").click();
+ }
+
+
+ // Concrete appliction node.
+ {
+ // Deploy the RAR.
+ String rarFilePath = System.getProperty(SYSPROP_TESTDATA_DIR) + "/rar/"+BASIC_RAR;
+ deployRar( rarFilePath );
+
+ ejtt.getNavTree().getNodeByLabel(NAV_RAR).click();
+
+ ContentTableRow rarRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_RAR);
+ assertTrue("Page doesn't list "+BASIC_RAR+" in Summary tab.", rarRow != null );
+
+ // Go to the summary through listed item.
+ rarRow.getLinkByLabel(BASIC_RAR).click();
+ // Check that we have the summary tab for the selected RAR.
+ assertTrue( "RAR name ("+BASIC_RAR+" not found in the content box.",
+ ejtt.getTabMenu().getTabContentBox().getElement().getTextContent().contains(BASIC_RAR) );
+
+ // Go to the summary through nav tree node.
+ NavTreeNode rarNode = ejtt.getNavTree().getNodeByLabel(NAV_RAR);
+ if( !rarNode.isExpanded() ){
+ log.info("Expanding.");
+ rarNode.getArrowLink().click();
+ Thread.sleep(2000);
+ }
+ ejtt.getNavTree().getNodeByLabel(BASIC_RAR).click();
+ // Check that we have the summary tab for the selected RAR.
+ ejtt.getTabMenu().getTabContentBox().getElement().getTextContent().contains(BASIC_RAR);
+
+ undeployRar(BASIC_RAR);
+
+ }
+
+
+ }// testNavigationToRar()
+
+
+
+
+
+
+ /**
+ * Assertion: Verify the content of the Resource Adapter Summary tab
+ *
+ *
+ */
+ public void testRarSummaryTab() throws EmbJoprTestException, IOException, Exception {
+
+ final int DEPLOY_TIMEOUT_SEC = 20;
+
+ // Deploy the RAR
+ String rarFilePath = System.getProperty(SYSPROP_TESTDATA_DIR) + "/rar/"+BASIC_RAR;
+ deployRar( rarFilePath );
+
+ try {
+
+ // Wait until the RAR appears...
+ new ActiveConditionChecker(new DescribedCondition("RAR appears in Summary tab list") {
+ public boolean isTrue() throws Exception {
+ // Refresh, then check.
+ ejtt.getNavTree().getNodeByLabel(NAV_RAR).click();
+ ContentTableRow rarRow = ejtt.getDefaultContentTable().findFirstRowContainingLink(BASIC_RAR);
+ return null != rarRow;
+ }
+ }).dumpPageOnTimeout(this).throwOnTimeout().waitWithTimeout(2000, 5);
+
+
+ ContentTableRow rarRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_RAR);
+
+ // Wait until the Status is "UP".
+ // TODO: Replace with ActiveConditionChecker.
+ int maxLoops = DEPLOY_TIMEOUT_SEC;
+ do {
+ String statusText = rarRow.getCellTextByColumnName("Status");
+ log.debug("RAR Status: "+statusText);
+ if( "UP".equals(statusText) )
+ break;
+
+ // Refresh page after 1 second.
+ ejtt.getNavTree().getNodeByLabel(NAV_RAR).click();
+ rarRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_RAR);
+
+ // We don't want an infinite loop by mistake.
+ if( maxLoops-- <= 0 ){
+ throw new EmbJoprTestException("RAR "+BASIC_RAR+" not UP after "+DEPLOY_TIMEOUT_SEC+" seconds.");
+ }
+ } while( true );
+
+ // FAILS because of EMBJOPR-80.
+ rarRow.getLinkByLabel(BASIC_RAR).click();
+
+
+ // Check the values in info table(s)
+
+ // General Properties
+ HtmlTable genpropTable = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("General Properties").getElement();
+ ContentInfoTable infoTable = ejtt.getContentInfoTable( genpropTable );
+ Properties props = infoTable.getProperties();
+
+ assertEquals(BASIC_RAR, props.getProperty("Name").trim());
+
+ // Resource Traits
+ infoTable = ejtt.getContentInfoTable(
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Resource Traits").getElement() );
+ props = infoTable.getProperties();
+
+
+ String path = ejtt.getDeployDir()+"/"+BASIC_RAR;
+ assertEquals(path, props.getProperty("Path").trim());
+
+ assertEquals("no", props.getProperty("Exploded?").trim());
+
+ // Metrics Summary
+ HtmlTable summaryTable = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Metrics Summary").getElement();
+ infoTable = ejtt.getContentInfoTable(summaryTable);
+ // (nothing here yet)
+
+
+ }
+ finally {
+ try {
+ undeployRar(BASIC_RAR);
+ }catch( Exception ex ){
+ log.error("Caught exception when undeploying: "+ex, ex);
+ }
+ }
+
+ }// testRarSummary()
+
+
+
+ /**
+ * Changes RAR configuration, and checks whether the changes were saved.
+ *
+ */
+ public void testRarConfigurationTab() throws IOException, EmbJoprTestException {
+
+ // Deploy the RAR.
+ String rarFilePath = ejtt.getTestDataDir() +"/rar/"+ BASIC_RAR;
+ deployRar( rarFilePath );
+
+ try {
+
+ ejtt.getNavTree().getNodeByLabel(NAV_RAR).click();
+ ejtt.deployment.waitActivelyForDeployment(DeployableTypes.RAR, BASIC_RAR, 3000, 15);
+
+ // Navigate to the Configuration tab
+ ContentTableRow rarRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_RAR);
+ rarRow.getLinkByLabel(BASIC_RAR).click();
+
+ Page prevPage = client.getContentPage();
+ ejtt.tabMenu.clickConfigurationTab();
+ assertNotSame("We should move to other page after clicking the Config tab.",
+ prevPage, client.getContentPage());
+
+ // Read properties.
+ Properties props = new Properties();
+ String filePath = ejtt.getTestDataDir()+"/rar/"+"rar-conf-basic.properties";
+ props.load(new FileInputStream( filePath ));
+
+
+ // Set the configuration options and Save
+ fillOutForm(props);
+ //ejtt.getTabMenu().getTabContentBox().getButtonByLabel("Save");
+ ejtt.getClickableByID("resourceConfigurationForm:saveButton").click();
+
+
+ // Check whether the properties were saved.
+ ejtt.tabMenu.clickConfigurationTab();
+
+ // TODO: We don't see the success message! EMBJOPR-89
+ checkClientAndServerMessages("successfully", "successfully", false);
+
+ // FAILS because some of the values are read-only. EMBJOPR-96
+ checkForm(props);
+
+ // TODO: Finish when the properties are marked read-only.
+
+ }
+ finally {
+ try {
+ undeployRar(BASIC_RAR);
+ }catch( Exception ex ){
+ log.error("Caught exception when undeploying: "+ex, ex);
+ }
+ }
+
+ }
+
+
+
+ /**
+ * Redeploys RAR.
+ *
+ */
+
+ public void testRarRedeployment() throws IOException, EmbJoprTestException {
+
+ final String DEPLOYABLE_NAME = BASIC_RAR;
+
+ // Deploy the RAR.
+ String appFilePath = ejtt.getTestDataDir() + "/"+DeployableTypes.RAR.getDataDir()+"/"+DEPLOYABLE_NAME;
+ deployRar( appFilePath );
+
+ try {
+
+ ejtt.getNavTree().getNodeByLabel(NAV_RAR).click();
+ ejtt.deployment.waitActivelyForDeployment(DeployableTypes.RAR, DEPLOYABLE_NAME, 3000, 15);
+
+ // Navigate to the Configuration tab
+ ContentTableRow rarRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
+ rarRow.getLinkByLabel(DEPLOYABLE_NAME).click();
+ ejtt.tabMenu.clickContentTab();
+
+ String xPath = ".//table//input[@type='file']";
+ HtmlFileInput fileInput = ejtt.tabMenu.getTabContentBox().getElement().getFirstByXPath(xPath);
+ fileInput.setValueAttribute(appFilePath);
+ xPath = ".//table//input[@type='submit']";
+ HtmlSubmitInput submit = ejtt.tabMenu.getTabContentBox().getElement().getFirstByXPath(xPath);
+ submit.click();
+
+
+
+ }
+ finally {
+ try {
+ undeployRar(DEPLOYABLE_NAME);
+ }catch( Exception ex ){
+ log.error("Caught exception when undeploying: "+ex, ex);
+ }
+ }
+
+ }
+
+ /**
+ * Utilities for performing and checking deployment.
+ * In the future, it should be general interface like
+ * boolean isDeployed( DeployableType type, String name ).
+ */
+ protected class DeploymentUtils {
+
+ /**
+ * Returns true if EmbJopr lists a deployable of given type and name,
+ * and it's State is UP; false otherwise.
+ */
+ private boolean isDeployedAccordingToEmbJopr( DeployableTypes type, String deployableName )
+ throws HtmlElementNotFoundException, IOException
+ {
+ // Refresh / go to the appropriate page.
+ ejtt.getNavTree().getNodeByLabel( type.getNavTreeLabel() ).click();
+ ContentTableRow rarRow = ejtt.getDefaultContentTable().findFirstRowContainingLink(deployableName);
+ if( null == rarRow ){
+ log.debug("Row with "+deployableName+" not present.");
+ return false;
+ }
+
+ String statusText = rarRow.getCellTextByColumnName("Status");
+ if( "UP".equals(statusText) ){
+ return true;
+ }else{
+ log.debug("Row with "+deployableName+" has Status == '"+statusText+"' != UP.");
+ return false;
+ }
+ }
+
+
+ /**
+ * Returns true if there's a file of the given name in server's deploy dir;
+ * false otherwise.
+ */
+ private boolean isDeployedAccordingToFileSystem( DeployableTypes type, String name )
+ {
+ String deployPath = System.getProperty(SYSPROP_DEPLOY_DIR);
+ String fileName = deployPath+"/"+name;
+ return (new File(fileName)).exists();
+ }
+
+ private void undeployViaFileSystem( String name ) throws EmbJoprTestException{
+ String deployPath = System.getProperty(SYSPROP_DEPLOY_DIR);
+ String fileName = deployPath+"/"+name;
+ File fileToDelete = new File(fileName);
+
+ if( !fileToDelete.exists() )
+ throw new EmbJoprTestException("Deployable doesn't exist: "+fileName);
+
+ if(fileToDelete.isFile()){
+ if( !fileToDelete.delete() ){
+ throw new EmbJoprTestException("Unable to delete: "+fileName);
+ }
+ }else if(fileToDelete.isDirectory()){
+ deleteDirectory(fileToDelete);
+ }
+
+ }// isDeployedAccordingToFileSystem()
+
+
+ }// class DeploymentUtils
+
+
+
+ private void deployRar( String rarFilePath ) throws IOException, HtmlElementNotFoundException
+ {
+ if( !(new File(rarFilePath)).exists())
+ throw new FileNotFoundException(rarFilePath);
+
+ log.info("Deploying: "+rarFilePath);
+
+ // Navigate to Enterprise Archives
+ ejtt.getNavTree().getNodeLink(NAV_RAR).click();
+
+ // click on the "Add new resource" button
+ client.click("actionHeaderForm:addNewContent"); // 404 if setThrowExceptionOnFailingStatusCode(true) above
+
+ // Upload the file
+ HtmlFileInput fileInput = (HtmlFileInput)client.getElement("createContentForm:file");
+ fileInput.setContentType("application/rar");
+ fileInput.setValueAttribute(rarFilePath);
+ client.click("createContentForm:addButton");
+ ejtt.sleep( 2000 );
+
+ // Log the message
+ ejtt.logServerMessage("Something went wrong with deploy: ");
+ }
+
+ private void undeployRar( String rarFileName ) throws IOException,
+ HtmlElementNotFoundException, ActionNotAvailableException
+ {
+
+ // Navigate to Enterprise Archives
+ ejtt.getNavTree().getNodeLink(NAV_RAR).click();
+
+ ejtt.getTabMenu().clickSummaryTab();
+
+ /// Debug log - we're getting HTTP 500 here :/
+ String dumpFile = "target/"+this.getName()+"-undeployRar-"+(1000+RandomUtils.nextInt(1000))+".html";
+ log.debug("Dumping page to "+dumpFile);
+ DebugUtils.writeFile( dumpFile, client.getPageAsText());
+ int httpStatusCode = client.getContentPage().getWebResponse().getStatusCode();
+ if( 200 != httpStatusCode )
+ log.warn("Status code before undeployment is: "+httpStatusCode);
+
+ HtmlButtonInput deleteButton = getAppDeleteButton( rarFileName );
+ deleteButton.click();
+
+ // Log the message (with prefix of potential warning)
+ ejtt.logServerMessage("Something went wrong with undeploy: ");
+
+ // Sleep for 3 sec. TODO: write some waitForUndeployed()
+ ejtt.sleep( 3000 );
+
+ }
+
+ public static void deleteDirectory(File path) throws EmbJoprTestException
+ {
+ List<String> undeletableFiles = new ArrayList();
+ deleteDirectory(path, undeletableFiles);
+ if( !undeletableFiles.isEmpty() ){
+ throw new EmbJoprTestException("Couldn't delete following files: \n "+
+ StringUtils.join(undeletableFiles, "\n ") + "\n");
+ }
+ }
+
+ public static void deleteDirectory(File path, List<String> undeletableFiles)
+ {
+ if( path.exists() ) {
+ File[] files = path.listFiles();
+ for(int i=0; i<files.length; i++) {
+ if(files[i].isDirectory()) {
+ deleteDirectory(files[i], undeletableFiles );
+ } else {
+ if( !files[i].delete() ){
+ undeletableFiles.add(files[i].getAbsolutePath());
+ }
+ }
+ }
+ }
+
+ if( ! path.delete() )
+ undeletableFiles.add( path.getAbsolutePath() );
+ }
+
+
+}// class RarTest
Added: trunk/jsfunit/testdata/rar/jbosstestadapter.rar
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/rar/jbosstestadapter.rar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
15 years, 8 months