Author: ozizka(a)redhat.com
Date: 2009-07-23 17:21:07 -0400 (Thu, 23 Jul 2009)
New Revision: 580
Added:
trunk/jsfunit/testdata/jbcache/
trunk/jsfunit/testdata/jbcache/JBossCacheTest-by-fdrabek.ear
trunk/jsfunit/testdata/jbcache/JBossCacheTest-service.xml
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbJoprTestConstants.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/ProfileServiceTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
Log:
* JBossCacheTest - default cache tests implemented.
* EJTT - added convenience methods for tables.
* Added test EAR file for JBoss Cache .
* Added JBossCacheTest-service.xml
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-07-23
18:24:30 UTC (rev 579)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-07-23
21:21:07 UTC (rev 580)
@@ -22,16 +22,10 @@
package org.jboss.jopr.jsfunit;
-public interface AppConstants {
+public interface AppConstants extends EmbJoprTestConstants {
- public static final String SYSPROP_DEPLOY_DIR = "jsfunit.deploy.dir";
- public static final String SYSPROP_TESTDATA_DIR = "jsfunit.testdata";
- public static final String SYSPROP_TEMP_DIR = "jsfunit.tempdir";
- public static String SYSPROP_JBOSS_CONFIG = "jboss.configuration";
- public static String SYSPROP_CARGO_JBOSS_HOME_DIR =
"jsfunit.jboss.home.dir";
-
-
+
public enum ResourceTypes {
}
@@ -156,13 +150,9 @@
public static final String EAR_NOT_MALFORMED_APP_FILENAME =
"not-malformed-application-xml.ear";
public static final String WAR_FILENAME_MALFORMED_APP =
"malformed-web-xml.war";
- // Info table headers
- public static final String LABEL_TRAITS = "Traits";
- public static final String LABEL_NUMERIC_METRICS = "Numeric Metrics";
-
// Test Archives
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbJoprTestConstants.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbJoprTestConstants.java 2009-07-23
18:24:30 UTC (rev 579)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbJoprTestConstants.java 2009-07-23
21:21:07 UTC (rev 580)
@@ -11,11 +11,40 @@
*/
public interface EmbJoprTestConstants {
+ // System properties to configure this testsuite.
+ public static final String SYSPROP_DEPLOY_DIR = "jsfunit.deploy.dir";
+ public static final String SYSPROP_TESTDATA_DIR = "jsfunit.testdata";
+ public static final String SYSPROP_TEMP_DIR = "jsfunit.tempdir";
+ public static String SYSPROP_JBOSS_CONFIG = "jboss.configuration";
+ public static String SYSPROP_CARGO_JBOSS_HOME_DIR = "jsfunit.jboss.home.dir";
+
+
//public static final String AS_NODE_NAME_FORMAT = "JBoss AS 5 (%s)";
public static final String AS_NODE_NAME_FORMAT = "JBoss EAP 5 (%s)";
public static final String LABEL_AS_SERVERS_SUMMARY = "JBoss Application
Server";
+
+ // Info table headers.
+ public static final String LABEL_GENERAL_PROPERTIES = "General Properties";
+ public static final String LABEL_TRAITS = "Traits";
+ public static final String LABEL_NUMERIC_METRICS = "Numeric Metrics";
+
+ // Table column headers.
+ public static final String COL_PROP_NAME = "Name";
+ public static final String COL_PROP_VALUE = "Value";
+
+ public static final String COL_RESOURCE_NAME = "Name";
+ public static final String COL_RESOURCE_STATUS = "Status";
+
+
+ // Tabs.
+ public static final String TAB_NAME_SUMMARY = "Summary";
+ public static final String TAB_NAME_CONFIG = "Configuration";
+ public static final String TAB_NAME_METRICS = "Metrics";
+ public static final String TAB_NAME_CONTROL = "Control";
+ public static final String TAB_NAME_CONTENT = "Content";
+
}// interface
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/ProfileServiceTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/ProfileServiceTest.java 2009-07-23
18:24:30 UTC (rev 579)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/ProfileServiceTest.java 2009-07-23
21:21:07 UTC (rev 580)
@@ -70,7 +70,7 @@
public static Test suite(){
- return new TestSuite(EarStressTest.class);
+ return new TestSuite(ProfileServiceTest.class);
}
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTest.java 2009-07-23
18:24:30 UTC (rev 579)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTest.java 2009-07-23
21:21:07 UTC (rev 580)
@@ -1,12 +1,20 @@
package org.jboss.jopr.jsfunit.as5.jbcache;
import java.io.IOException;
+import java.util.List;
+import java.util.Properties;
import org.jboss.jopr.jsfunit.ApplicationTestBaseAS5;
+import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
import org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.ContentTable;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.ContentTableRow;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.NavTreeNode;
/**
*
* @author Ondrej Zizka
+ *
+ * JBoss Cache is only present in 'all' JBoss AS profile.
*
* TODO: Implement when JBoss Cache support comes to EmbJopr.
*/
@@ -15,28 +23,156 @@
public final DeployableTypes APP_TYPE = DeployableTypes.JBCACHE;
+ // Cache which is active by default.
+ private static final String DEFAULT_JBCACHE =
"jboss.cache:config=ha-partition,service=Cache";
-
- public void testJBossCacheParentNode() throws HtmlElementNotFoundException {
- ejtt.navTree.getNodeByLabel(APP_TYPE.getNavTreeLabel());
- fail("JBoss Cache not present yet.");
+
+ private boolean isJBossConfigWithoutCache(){
+ boolean isJBossConfigWithoutCache = ! ejtt.getJBossConfig().equals("all");
+ if( isJBossConfigWithoutCache )
+ log.warn("JBoss instance is not running the 'all' configuration - has no
JBoss Cache. Skipping this test.");
+ return isJBossConfigWithoutCache;
}
+ /**
+ * Test the navigation to JBoss Cache nodes.
+ */
+ public void testJBossCacheParentNode() throws HtmlElementNotFoundException, IOException,
EmbJoprTestException {
+ if( isJBossConfigWithoutCache() ) return;
- public void testHibernateSummary() throws HtmlElementNotFoundException {
- ejtt.navTree.getNodeByLabel(APP_TYPE.getNavTreeLabel());
- fail("JBoss Cache not present yet.");
+ NavTreeNode cachesNode = ejtt.navTree.getNodeByLabel(NAV_JBCACHES);
+ assertTrue( "JBoss Caches node has no children.", cachesNode.hasChildren()
);
+ cachesNode.click();
+
+ final String HA_PARTITION = "ha-partition";
+ assertTrue("JBoss Caches should list '"+HA_PARTITION+"'",
client.getPageAsText().contains(HA_PARTITION) );
+
+ ContentTable table = ejtt.getTabMenu().getTabContentBox().getFirstTable();
+
+ // Rows 1+
+ List<ContentTableRow> rows = table.getRows();
+ assertTrue( "Caches list should contain at least one cache.", rows.size()
> 0 );
+
+ // Check that default cache is present.
+ boolean defaultPresent = false;
+ // Check that all caches are UP.
+ for( ContentTableRow row : rows ){
+ String name = row.getCellByColumnName(COL_RESOURCE_NAME).getTextContent();
+ String status = row.getCellByColumnName(COL_RESOURCE_STATUS).getTextContent().trim();
+ if( ! "UP".equals( status ) )
+ fail("Cache '"+name+"' is not UP, but
'"+status+"'.");
+ if( DEFAULT_JBCACHE.equals(name) )
+ defaultPresent = true;
+ }
+ if( !defaultPresent)
+ fail("The default cache, '"+DEFAULT_JBCACHE+"', is not
present.");
+
+ // Click on the first row link.
+ rows.get(0).getFirstLinkFromColumn(COL_RESOURCE_NAME).click();
+
+ // Check that we got to the Summary page.
+ assertTrue("JB Cache's Summary doesn't contain
'"+LABEL_GENERAL_PROPERTIES+"' - is the Summary page ok?",
client.getPageAsText().contains(LABEL_GENERAL_PROPERTIES));
+
}
+ /**
+ * JBoss Cache Summary tab.
+ */
+ public void testJBossCacheSummary() throws EmbJoprTestException, IOException {
+ if( isJBossConfigWithoutCache() ) return;
+
+ ejtt.navTree.getNodeByLabel(DEFAULT_JBCACHE).click();
+
+ /*
+ General Properties
+ Name:jboss.cache:config=ha-partition,service=Cache
+ Version:--
+ Description:JBoss Cache
+ */
+
+ /*ContentTable table =
ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_GENERAL_PROPERTIES);
+ ContentInfoTable traitsTable =
ejtt.getTabMenu().getTabContentBox().getContentInfoTable( table.getElement() );
+ Properties props = traitsTable.getProperties();
+
+ assertEquals("Traits - Name", DEFAULT_JBCACHE,
props.getProperty("Name"));/**/
+
+ Properties props = new Properties();
+ props.setProperty("Name", DEFAULT_JBCACHE);
+ ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_GENERAL_PROPERTIES).checkValues(props);
+
+
+
+ /*
+ Numeric Metrics
+ Name Value Description
+ Number of Nodes 1 Number of Nodes
+ */
+ props = new Properties();
+ props.setProperty("Number of Nodes", "1");
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(props);
+
+
+ }
+
+
- public void testHibernateMetrics() throws HtmlElementNotFoundException, IOException {
- fail("JBoss Cache not present yet.");
+ /**
+ * JBoss Cache Metrics tab.
+ */
+ public void testJBossCacheMetrics() throws HtmlElementNotFoundException, IOException,
EmbJoprTestException {
+ if( isJBossConfigWithoutCache() ) return;
- ejtt.navTree.getNodeByLabel(APP_TYPE.getNavTreeLabel());
+ ejtt.navTree.getNodeByLabel(DEFAULT_JBCACHE).click();
ejtt.tabMenu.clickMetricsTab();
+ assertTrue( ejtt.tabMenu.isTabActive(TAB_NAME_METRICS) );
+ Properties props = new Properties();
+ props.setProperty("Node Locking Scheme:", "PESSIMISTIC");
+ props.setProperty("Expose Management Statistics?:", "true");
+ props.setProperty("Register JMX Resource?:", "true");
+ props.setProperty("Multiplexer Stack:", "udp");
+ props.setProperty("Cluster Name:",
"DefaultPartition-HAPartitionCache");
+ props.setProperty("Inactive on Startup?:", "false");
+ props.setProperty("Cache Mode:", "REPL_SYNC");
+ props.setProperty("Isolation Level:", "REPEATABLE_READ");
+ props.setProperty("Replication Version:", "3.1.0");
+ props.setProperty("Fetch In-Memory State?:", "true");
+ props.setProperty("Use Replication Queue?:", "false");
+ props.setProperty("Use Region-Based Marshalling?:", "false");
+ props.setProperty("Sync Commit Phase?:", "false");
+ props.setProperty("State:", "3");
+ props.setProperty("Transaction Manager Lookup Class:",
"org.jboss.cache.transaction.BatchModeTransactionManagerLookup");
+ ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_TRAITS).checkValues(props);
+
+
+ // Numeric metrics
+ props = new Properties();
+ props.setProperty("Replication Queue Max Elements", "1,000");
+ props.setProperty("Number of Attributes", "0");
+ props.setProperty("Initial State Retrieval Timeout", "60,000");
+ props.setProperty("Replication Queue Interval", "5,000");
+ props.setProperty("Lock Acquisition Timeout", "15,000");
+ props.setProperty("Number of Nodes", "1");
+ props.setProperty("Sync Replication Timeout", "17,500");
+ props.setProperty("State Retrieval Timeout", "60,000");
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(props);
+
}
+
+ /**
+ * JBoss Cache Control tab.
+ */
+ public void testJBossCacheControl() throws HtmlElementNotFoundException, IOException {
+ if( isJBossConfigWithoutCache() ) return;
+
+ ejtt.navTree.getNodeByLabel(DEFAULT_JBCACHE).click();
+
+ ejtt.tabMenu.clickControlTab();
+ assertTrue( ejtt.tabMenu.isTabActive(TAB_NAME_CONTROL) );
+
+ }
+
}// class
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-07-23
18:24:30 UTC (rev 579)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-07-23
21:21:07 UTC (rev 580)
@@ -30,11 +30,13 @@
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.servlet.http.HttpServletRequest;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.jboss.jopr.jsfunit.AppConstants;
import org.jboss.jopr.jsfunit.AppConstants.DeployableTypes;
import org.jboss.jopr.jsfunit.DebugUtils;
+import org.jboss.jopr.jsfunit.EmbJoprTestConstants;
import org.jboss.jopr.jsfunit.EmbjoprTestCase;
import org.jboss.jsfunit.jsfsession.*;
import org.jboss.logging.Logger;
@@ -677,6 +679,7 @@
+
/**
* Inner class for manipulation with tab content box.
*/
@@ -727,8 +730,8 @@
return null;
}
}
-
- return new ContentTable(tableElement);
+
+ return new ContentTable(tableElement, headerText);
}
/**
@@ -899,29 +902,60 @@
}
+
+ /**
+ * Returns the unformatted table (eg. General Properties and Traits).
+ */
+ public ContentInfoTable getTableUnformatted(String tableHeader) throws
EmbJoprTestException {
+ ContentTable table =
getTabMenu().getTabContentBox().getTableUnderHeader(tableHeader);
+ ContentInfoTable traitsTable = getTabMenu().getTabContentBox().getContentInfoTable(
table.getElement() );
+ return traitsTable;
+ }
+
+
}// inner class TabContentBox
+
+
+
+
/**
- * Contains convenience methods for accessing content tables in EmbJopr.
+ * Contains convenience methods for accessing tables in EmbJopr.
+ * Works with any HTML table.
*/
public class ContentTable {
public static final String ID_CATEGORY_DATA_TABLE =
"categorySummaryForm:dataTable";
public static final String ID_RESOURCE_DATA_TABLE =
"resourceSummaryForm:dataTable";
-
+
+ /** HTML element of this table. */
+ public HtmlTable getElement() { return this.element; }
protected HtmlTable element;
- public HtmlTable getElement() { return element; }
+ /** Name of the table. Usualy header above the table is used. */
+ public String getTableName() { return this.name; }
+ protected String name;
+
+
/**
* Creates a data table wrapper for the given table element.
*/
- public ContentTable( HtmlTable element ) {
+ public ContentTable( HtmlTable element ) { init(element, null); }
+
+ /**
+ * Creates a data table wrapper for the given table element and stores it's name.
+ */
+ public ContentTable( HtmlTable element, String tableName ) { init(element,
tableName); }
+
+ private void init( HtmlTable element, String tableName ){
if( null == element )
throw new IllegalArgumentException("null given as element for
ContentTable.");
this.element = element;
+ this.name = tableName;
}
+
/**
* Creates a data table wrapper for first found element with one of these IDs:
* ID_CATEGORY_DATA_TABLE, ID_RESOURCE_DATA_TABLE
@@ -1056,8 +1090,9 @@
}
/**
- * Creates a list of columns headers
- * and a label => col index map.
+ * Creates a list of columns headers and a label => col index map.
+ * Works for tables which have column headers,
+ * ie. they have TH elements in the first row.
*/
public void analyzeColumns() throws HtmlElementNotFoundException
{
@@ -1098,6 +1133,9 @@
* 1) Table does not have column headers
* 2) No header with such name was found.
*
+ * Works for tables which have column headers,
+ * ie. they have TH elements in the first row.
+ *
* @param colName
* @return
* @throws org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException
@@ -1116,6 +1154,10 @@
/**
* Creates a properties using values from this table.
+ *
+ * Works for tables which have column headers,
+ * ie. they have TH elements in the first row.
+ *
* @param keyColName Name of column containing the key (e.g. "Name").
* @param valueColName Name of column containing the value (e.g. "Value").
*/
@@ -1135,14 +1177,40 @@
return props;
}
+ public Properties getProperties() throws HtmlElementNotFoundException {
+ return this.getProperties(EmbJoprTestConstants.COL_PROP_NAME,
EmbJoprTestConstants.COL_PROP_VALUE);
+ }
+
+ /**
+ * Checks that name/value pairs in this table mach the given values.
+ * @throws EmbJoprTestException if any of given values does not match with the value
in this table.
+ */
+ public void checkValues( Properties propsExpected ) throws EmbJoprTestException {
+
+ // Get this tables properties. Different table types can override this.
+ Properties propsActual = this.getProperties();
+
+ // Check all the properties.
+ for( Object key : propsExpected.keySet() ){
+ String propName = (String)key;
+ String exp = propsExpected.getProperty(propName);
+ String act = propsActual.getProperty(propName);
+ if( !StringUtils.equals( exp, act ) ){
+ // If this table has a name, use it in the exception message.
+ String msgFormat = (null == this.getTableName() ? "%2$s: expected
'%3$s', actual '%4$s'." : "%s - %s: expected '%s',
actual '%s'.");
+ throw new EmbJoprTestException( String.format(msgFormat, this.getTableName(),
propName, exp, act) );
+ }
+ }
+ }
+
+
}// inner class ContentTable
-
/**
* Creates a data table wrapper for first found element with one of these IDs:
* ID_CATEGORY_DATA_TABLE, ID_RESOURCE_DATA_TABLE
@@ -1160,7 +1228,8 @@
/**
- * Provides extra method that parses text-like info table (with one column).
+ * Provides extra method that parses text-like info table (with one column) -
+ * usualy Traits tables have this structure.
*/
public class ContentInfoTable extends ContentTable {
@@ -1169,7 +1238,10 @@
}
/**
- * Parses the content of the table properties.
+ * Parses the content of the table.
+ * Works with text-like info table (with one column) -
+ * usualy Traits tables have this structure.
+ *
* @returns Set of properties extracted from rows
* whose plain text has the 'Name: Value' format.
*/
@@ -1193,6 +1265,7 @@
return props;
}
+
}// inner class ContentInfoTable
/**
Added: trunk/jsfunit/testdata/jbcache/JBossCacheTest-by-fdrabek.ear
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/jbcache/JBossCacheTest-by-fdrabek.ear
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsfunit/testdata/jbcache/JBossCacheTest-service.xml
===================================================================
--- trunk/jsfunit/testdata/jbcache/JBossCacheTest-service.xml (rev
0)
+++ trunk/jsfunit/testdata/jbcache/JBossCacheTest-service.xml 2009-07-23 21:21:07 UTC (rev
580)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+<mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+name="foo:config=test,testName=testValue,Dname=testName,service=ExampleCacheJmxWrapper">
+<attribute name="TransactionManagerLookupClass">
+org.jboss.cache.transaction.JBossTransactionManagerLookup
+</attribute>
+<attribute name="MuxChannelFactory"><inject
bean="JChannelFactory"/></attribute>
+<attribute name="MultiplexerStack">udp</attribute>
+<attribute name="ClusterName">Example-EntityCache</attribute>
+<attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+<attribute name="CacheMode">REPL_SYNC</attribute>
+<attribute name="InitialStateRetrievalTimeout">15000</attribute>
+<attribute name="SyncReplTimeout">20000</attribute>
+<attribute name="LockAcquisitionTimeout">15000</attribute>
+<attribute name="ExposeManagementStatistics">true</attribute>
+</mbean>
+
+</server>
+