Author: ozizka(a)redhat.com
Date: 2009-08-11 23:28:47 -0400 (Tue, 11 Aug 2009)
New Revision: 669
Added:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheDataContainerTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheRegionManagerTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheRpcManagerTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTransactionTableTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTxInterceptorTest.java
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheCacheTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheInterceptorTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTestBase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/ValuesValidator.java
Log:
* JBossCache tests added.
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheCacheTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheCacheTest.java 2009-08-11
23:49:51 UTC (rev 668)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheCacheTest.java 2009-08-12
03:28:47 UTC (rev 669)
@@ -14,6 +14,8 @@
import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.ContentTable;
import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.ContentTableRow;
import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.NavTreeNode;
+import org.jboss.jopr.jsfunit.util.SingleProperties;
+import org.jboss.jopr.jsfunit.util.ValuesValidator;
/**
*
@@ -186,7 +188,7 @@
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("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");
@@ -195,7 +197,12 @@
props.setProperty("Transaction Manager Lookup Class",
"org.jboss.cache.transaction.BatchModeTransactionManagerLookup");
ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_TRAITS).checkValuesEqual(props);
+ props = new SingleProperties("Replication Version",
"\\d+.\\d+.\\d+");
+ ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_TRAITS).checkValues(props,
ValuesValidator.MATCHES);
+
+
+
// Numeric metrics
props = new Properties();
props.setProperty("Replication Queue Max Elements", "1,000");
Added:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheDataContainerTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheDataContainerTest.java
(rev 0)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheDataContainerTest.java 2009-08-12
03:28:47 UTC (rev 669)
@@ -0,0 +1,99 @@
+package org.jboss.jopr.jsfunit.as5.jbcache;
+
+import java.io.IOException;
+import java.util.Properties;
+import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
+import org.jboss.jopr.jsfunit.util.SingleProperties;
+import org.jboss.jopr.jsfunit.util.ValuesValidator;
+
+/**
+ *
+ * @author Ondrej Zizka
+ *
+ * JBoss Cache is only present in 'all' JBoss AS profile.
+ */
+public class JBossCacheDataContainerTest extends JBossCacheTestBase {
+
+
+
+ /**
+ * Interceptor Summary tab.
+ */
+ public void testJBossCacheDataContainerSummary() throws IOException,
EmbJoprTestException {
+ if( isJBossConfigWithoutCache() ) return;
+
+ try {
+
+ ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION).expand();
+ ejtt.navTree.getNodeByLabel(SUBNODE_DATA_CONTAINER).click();
+
+ // Gen Props - nothing useful.
+ Properties props = new Properties();
+ props.setProperty("Name", "Data Container");
+ ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_GENERAL_PROPERTIES).checkValuesEqual(props);
+
+ }
+ finally {
+ }
+
+ }
+
+
+
+ // Operations
+ private static final String LABEL_NUMBER_OF_NODES = "Get the number of
nodes.";
+ private static final String LABEL_NUMBER_OF_ATTRIBUTES = "Get the number of
attributes.";
+ private static final String LABEL_DETAILS_TEXT = "Print details as plain
text.";
+ private static final String LABEL_DETAILS_HTML = "Print details as HTML.";
+
+
+
+ /** Helper method - performs an operation, collects the results and checks whether the
values are as expected. */
+ public void checkOperationResults( String opName, Properties expected, ValuesValidator
validator ) throws EmbJoprTestException, IOException
+ {
+ ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION).expand();
+ ejtt.navTree.getNodeByLabel(SUBNODE_DATA_CONTAINER).click();
+ ejtt.getTabMenu().clickControlTab();
+
+ // Perform the operation, get the values, and check them.
+ Properties actual = ejtt.operations.performOperation( opName );
+ ejtt.checkValues(expected, actual, validator);
+ }
+
+
+
+ /** Number of Nodes. */
+ public void testJBossCacheDataContainerNumNodes() throws EmbJoprTestException,
IOException
+ {
+ checkOperationResults(LABEL_NUMBER_OF_NODES, new SingleProperties("Output",
"1"), ValuesValidator.EQUAL );
+ }
+
+
+ /** Number of Attributes. */
+ public void testJBossCacheDataContainerNumAttributes() throws EmbJoprTestException,
IOException
+ {
+ checkOperationResults(LABEL_NUMBER_OF_ATTRIBUTES, new
SingleProperties("Output", "0"), ValuesValidator.EQUAL );
+ }
+
+
+ /** Print details as plain text. Just a check for currently returned value, can change
in future. */
+ public void testJBossCacheDataContainerDetailsAsText() throws EmbJoprTestException,
IOException
+ {
+ checkOperationResults(LABEL_DETAILS_TEXT, new SingleProperties("Output",
"/ {} /__HA_JNDI__ {}"), ValuesValidator.CONTAINS );
+ }
+
+
+ /** Print details as HTML. Just a check for currently returned value, can change in
future. */
+ public void testJBossCacheDataContainerDetailsAsHtml() throws EmbJoprTestException,
IOException
+ {
+ checkOperationResults(LABEL_DETAILS_HTML, new SingleProperties("Output",
"/ {}<br/> /__HA_JNDI__ {}"),
ValuesValidator.CONTAINS );
+ }
+
+
+
+
+
+
+
+
+}// class
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheInterceptorTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheInterceptorTest.java 2009-08-11
23:49:51 UTC (rev 668)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheInterceptorTest.java 2009-08-12
03:28:47 UTC (rev 669)
@@ -268,9 +268,10 @@
Properties propsSecond =
ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).getProperties();
ejtt.tabMenu.clickControlTab();
-
ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Reset Statistics");
+ ejtt.tabMenu.clickMetricsTab();
+
// Check that these metrics didn't stay at their previous values.
ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(propsSecond,
ValuesValidator.NOT_EQUAL);
Added:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheRegionManagerTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheRegionManagerTest.java
(rev 0)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheRegionManagerTest.java 2009-08-12
03:28:47 UTC (rev 669)
@@ -0,0 +1,90 @@
+package org.jboss.jopr.jsfunit.as5.jbcache;
+
+import java.io.IOException;
+import java.util.Properties;
+import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
+import org.jboss.jopr.jsfunit.util.SingleProperties;
+import org.jboss.jopr.jsfunit.util.ValuesValidator;
+
+/**
+ *
+ * @author Ondrej Zizka
+ *
+ * JBoss Cache is only present in 'all' JBoss AS profile.
+ */
+public class JBossCacheRegionManagerTest extends JBossCacheTestBase {
+
+
+ private static final String LABEL_DUMP_REGIONS = "Dump Regions";
+
+
+ /** Navigates to the node being tested. */
+ private void navigateToNode() throws EmbJoprTestException, IOException {
+ ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION).expand();
+ ejtt.navTree.getNodeByLabel(SUBNODE_REGION_MANAGER).click();
+ }
+
+ private void dumpRegions() throws EmbJoprTestException, IOException{
+ navigateToNode();
+ ejtt.getTabMenu().clickControlTab();
+ ejtt.operations.performOperation(LABEL_DUMP_REGIONS);
+ }
+
+
+ /**
+ * Region Manager Summary tab.
+ */
+ public void testJBossCacheRegionManagerSummary() throws IOException,
EmbJoprTestException {
+ if( isJBossConfigWithoutCache() ) return;
+
+ try {
+
+ navigateToNode();
+
+ // Gen Props - nothing useful.
+ Properties props = new Properties();
+ props.setProperty("Name", "RegionManager");
+ ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_GENERAL_PROPERTIES).checkValuesEqual(props);
+
+ }
+ finally {
+ }
+
+ }
+
+
+ /**
+ *
+ */
+ public void testJBossCacheRegionManagerMetrics() throws IOException,
EmbJoprTestException {
+
+ navigateToNode();
+ ejtt.getTabMenu().clickMetricsTab();
+
+
+ // Metrics.
+ Properties props = new SingleProperties("Number of Regions", "0");
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(props,
ValuesValidator.EQUAL);
+
+ }
+
+
+ /**
+ *
+ */
+ public void testJBossCacheRegionManagerControl() throws IOException,
EmbJoprTestException {
+
+ navigateToNode();
+ ejtt.getTabMenu().clickControlTab();
+ ejtt.operations.performOperation(LABEL_DUMP_REGIONS);
+
+ }
+
+
+
+
+
+
+
+
+}// class
Added:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheRpcManagerTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheRpcManagerTest.java
(rev 0)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheRpcManagerTest.java 2009-08-12
03:28:47 UTC (rev 669)
@@ -0,0 +1,105 @@
+package org.jboss.jopr.jsfunit.as5.jbcache;
+
+import java.io.IOException;
+import java.util.Properties;
+import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
+import org.jboss.jopr.jsfunit.util.SingleProperties;
+import org.jboss.jopr.jsfunit.util.ValuesValidator;
+
+/**
+ *
+ * @author Ondrej Zizka
+ *
+ * JBoss Cache is only present in 'all' JBoss AS profile.
+ */
+public class JBossCacheRpcManagerTest extends JBossCacheTestBase {
+
+
+ /** Navigates to the node being tested. */
+ private void navigateToNode() throws EmbJoprTestException, IOException {
+ ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION).expand();
+ ejtt.navTree.getNodeByLabel(SUBNODE_RPC_MANAGER).click();
+ }
+
+ private void resetStatistics() throws EmbJoprTestException, IOException{
+ navigateToNode();
+ ejtt.getTabMenu().clickControlTab();
+ ejtt.operations.performOperation("Reset Statistics");
+ }
+
+
+ /**
+ * RPC Manager Summary tab.
+ */
+ public void testJBossCacheRpcManagerSummary() throws IOException, EmbJoprTestException
{
+ if( isJBossConfigWithoutCache() ) return;
+
+ try {
+
+ resetStatistics();
+ navigateToNode();
+
+ // Gen Props - nothing useful.
+ Properties props = new Properties();
+ props.setProperty("Name", "RPC Manager");
+ ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_GENERAL_PROPERTIES).checkValuesEqual(props);
+
+ // Metrics.
+ props = new Properties();
+ props.setProperty("Failed Replications", "0");
+ props.setProperty("Successful Replications", "0");
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(props,
ValuesValidator.EQUAL);
+
+ }
+ finally {
+ }
+
+ }
+
+
+ /**
+ *
+ */
+ public void testJBossCacheRpcManagerMetrics() throws IOException, EmbJoprTestException
{
+
+ navigateToNode();
+ ejtt.getTabMenu().clickMetricsTab();
+
+ /*
+ Traits
+ RPC Enabled?: true
+ Local Address: 127.0.1.1:60357
+ Statistics Enabled: false
+ Success Ratio: N/A
+ Members: [127.0.1.1:60357]
+ */
+ Properties props = new Properties();
+ props.setProperty("RPC Enabled?", "true");
+ props.setProperty("Statistics Enabled", "false");
+ props.setProperty("Success Ratio", "N/A");
+ ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_TRAITS).checkValues(props,
ValuesValidator.EQUAL);
+
+ //props = new SingleProperties("Members",
"[127.0.\\d+.\\d+:\\d+]");
+ //ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_TRAITS).checkValues(props,
ValuesValidator.MATCHES);
+ props = new Properties();
+ props.setProperty("Members", "[127.0.");
+ props.setProperty("Local Address", "127.0.");
+ ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_TRAITS).checkValues(props,
ValuesValidator.CONTAINS);
+
+
+ // Metrics.
+ props = new Properties();
+ props.setProperty("Failed Replications", "0");
+ props.setProperty("Successful Replications", "0");
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(props,
ValuesValidator.EQUAL);
+
+ }
+
+
+
+
+
+
+
+
+}// class
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTestBase.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTestBase.java 2009-08-11
23:49:51 UTC (rev 668)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTestBase.java 2009-08-12
03:28:47 UTC (rev 669)
@@ -31,6 +31,7 @@
protected static final String SUBNODE_RPC_MANAGER = "RPC Manager";
protected static final String SUBNODE_REGION_MANAGER = "RegionManager";
protected static final String SUBNODE_TRANSACTION_TABLE = "Transaction
Table";
+ protected static final String SUBNODE_TX_INTERCEPTOR = "Tx Interceptor";
Added:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTransactionTableTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTransactionTableTest.java
(rev 0)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTransactionTableTest.java 2009-08-12
03:28:47 UTC (rev 669)
@@ -0,0 +1,98 @@
+package org.jboss.jopr.jsfunit.as5.jbcache;
+
+import java.io.IOException;
+import java.util.Properties;
+import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
+import org.jboss.jopr.jsfunit.util.SingleProperties;
+import org.jboss.jopr.jsfunit.util.ValuesValidator;
+
+/**
+ *
+ * @author Ondrej Zizka
+ *
+ * JBoss Cache is only present in 'all' JBoss AS profile.
+ */
+public class JBossCacheTransactionTableTest extends JBossCacheTestBase {
+
+
+ private static final String LABEL_RESET_STATISTICS = "Reset Statistics";
+
+
+ /** Navigates to the node being tested. */
+ private void navigateToNode() throws EmbJoprTestException, IOException {
+ ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION).expand();
+ ejtt.navTree.getNodeByLabel(SUBNODE_TRANSACTION_TABLE).click();
+ }
+
+ private void resetStatistics() throws EmbJoprTestException, IOException{
+ navigateToNode();
+ ejtt.getTabMenu().clickControlTab();
+ ejtt.operations.performOperation(LABEL_RESET_STATISTICS);
+ }
+
+
+ /**
+ * Transaction Table Summary tab.
+ */
+ public void testJBossCacheTransactionTableSummary() throws IOException,
EmbJoprTestException {
+ if( isJBossConfigWithoutCache() ) return;
+
+ try {
+
+ navigateToNode();
+
+ // Gen Props - nothing useful.
+ Properties props = new Properties();
+ props.setProperty("Name", "Transaction Table");
+ ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_GENERAL_PROPERTIES).checkValuesEqual(props);
+
+ // Metrics.
+ props = new SingleProperties("Number Of Registered Transactions",
"0");
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(props,
ValuesValidator.EQUAL);
+
+ }
+ finally {
+ }
+
+ }
+
+
+ /**
+ *
+ */
+ public void testJBossCacheTransactionTableMetrics() throws IOException,
EmbJoprTestException {
+
+ navigateToNode();
+ ejtt.getTabMenu().clickMetricsTab();
+
+
+ // Traits
+ Properties props = new SingleProperties("Transaction Map", "{}");
// null
+ ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_TRAITS).checkValues(props,
ValuesValidator.EQUAL);
+
+ // Metrics.
+ props = new SingleProperties("Number Of Registered Transactions",
"0");
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(props,
ValuesValidator.EQUAL);
+
+ }
+
+
+ /**
+ *
+ */
+ public void testJBossCacheTransactionTableControl() throws IOException,
EmbJoprTestException {
+
+ navigateToNode();
+ ejtt.getTabMenu().clickControlTab();
+ ejtt.operations.performOperation(LABEL_RESET_STATISTICS);
+
+ }
+
+
+
+
+
+
+
+
+}// class
Added:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTxInterceptorTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTxInterceptorTest.java
(rev 0)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTxInterceptorTest.java 2009-08-12
03:28:47 UTC (rev 669)
@@ -0,0 +1,96 @@
+package org.jboss.jopr.jsfunit.as5.jbcache;
+
+import java.io.IOException;
+import java.util.Properties;
+import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
+import org.jboss.jopr.jsfunit.util.SingleProperties;
+import org.jboss.jopr.jsfunit.util.ValuesValidator;
+
+/**
+ *
+ * @author Ondrej Zizka
+ *
+ * JBoss Cache is only present in 'all' JBoss AS profile.
+ */
+public class JBossCacheTxInterceptorTest extends JBossCacheTestBase {
+
+
+ private static final String LABEL_REFRESH = "Refresh";
+
+
+ /** Navigates to the node being tested. */
+ private void navigateToNode() throws EmbJoprTestException, IOException {
+ ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION).expand();
+ ejtt.navTree.getNodeByLabel(SUBNODE_TX_INTERCEPTOR).click();
+ }
+
+ private void refreshMetrics() throws EmbJoprTestException, IOException{
+ navigateToNode();
+ ejtt.getTabMenu().clickMetricsTab();
+ ejtt.getTabMenu().getTabContentBox().getButtonByLabel(LABEL_REFRESH).click();
+ }
+
+
+ /**
+ * TxInterceptor Summary tab.
+ */
+ public void testJBossCacheTxInterceptorSummary() throws IOException,
EmbJoprTestException {
+ if( isJBossConfigWithoutCache() ) return;
+
+ try {
+
+ navigateToNode();
+
+ // Gen Props - nothing useful.
+ Properties props = new Properties();
+ props.setProperty("Name", "Tx Interceptor");
+ ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_GENERAL_PROPERTIES).checkValuesEqual(props);
+
+ // Metrics.
+ props = new Properties();
+ props.setProperty("Commits", "0");
+ props.setProperty("Rollbacks", "0");
+ props.setProperty("Prepares", "0");
+ props.setProperty("Number Of Syncs Registered", "0");
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(props,
ValuesValidator.EQUAL);
+
+ }
+ finally {
+ }
+
+ }
+
+
+ /**
+ *
+ */
+ public void testJBossCacheTxInterceptorMetrics() throws IOException,
EmbJoprTestException {
+
+ navigateToNode();
+ ejtt.getTabMenu().clickMetricsTab();
+
+
+ // Traits
+ Properties props = new SingleProperties("Statistics Enabled?",
"true");
+ ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_TRAITS).checkValues(props,
ValuesValidator.EQUAL);
+
+ // Metrics.
+ props = new Properties();
+ props.setProperty("Commits", "0");
+ props.setProperty("Rollbacks", "0");
+ props.setProperty("Prepares", "0");
+ props.setProperty("Number Of Syncs Registered", "0");
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(props,
ValuesValidator.EQUAL);
+
+ }
+
+
+
+
+
+
+
+
+
+
+}// 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-08-11
23:49:51 UTC (rev 668)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-08-12
03:28:47 UTC (rev 669)
@@ -7,7 +7,6 @@
import java.net.UnknownHostException;
import java.util.*;
-import java.util.logging.Level;
import javax.management.MalformedObjectNameException;
import javax.naming.NamingException;
import org.jboss.jopr.jsfunit.exceptions.*;
@@ -30,11 +29,6 @@
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.collections.Closure;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.Transformer;
-import org.apache.commons.collections.functors.ClosureTransformer;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.jboss.jopr.jsfunit.AppConstants;
@@ -1361,7 +1355,22 @@
for( ContentTableRow row : this.getRows() ){
log.debug("Row ("+row.getElement().getCells().size()+" cells):
"+row.getElement().getTextContent());
String key = row.getCell( keyColIndex ).getTextContent().trim();
- String value = row.getCell( valColIndex ).getTextContent().trim();
+
+ // Get the cell.
+ HtmlTableCell cell = row.getCell(valColIndex);
+ String value;
+ // If it contains one input, get the value of the input.
+ List<HtmlTextInput> inputs = (List<HtmlTextInput>)
cell.getByXPath("./input[@type='text']");
+
+ log.debug("Value cell has "+inputs.size()+" <input>
elements.");
+ if( inputs.size() == 1 ){
+ value = ((HtmlTextInput)inputs.get(0)).asText(); //getValueAttribute();
+ }
+ // Otherwise, get the text content of the cell.
+ else{
+ value = cell.getTextContent().trim();
+ }
+
props.setProperty(key, value);
}
@@ -1427,6 +1436,9 @@
// Get this tables properties. Different table types can override this.
Properties propsActual = this.getProperties();
+ selfEjtt.checkValues(propsExpected, propsActual, validator, this.getTableName() );
+
+ /*
// List the actual properties.
for( Object key : propsActual.keySet() ){
String propName = (String)key;
@@ -1458,6 +1470,7 @@
throw new EmbJoprTestException( String.format("Non-matching properties: (%d of
%d expected):\n", failures.size(), propsExpected.size()) + StringUtils.join(failures,
"\n") );
}
}
+ */
}
@@ -2124,8 +2137,14 @@
*/
public Properties getLastOperationResults() throws HtmlElementNotFoundException{
Properties props = new Properties();
+
+ TabContentBox tabContentBox = getEjtt().tabMenu.getTabContentBox();
+
+ // Operation has no result (table not displayed).
+ if( tabContentBox.getElement().getTextContent().contains("The operation did not
return any results."))
+ return props;
- ContentTable resultsTable =
getEjtt().tabMenu.getTabContentBox().getOperationResultsTable();
+ ContentTable resultsTable = tabContentBox.getOperationResultsTable();
props = resultsTable.getProperties();
return props;
@@ -2609,5 +2628,49 @@
+ public final void checkValues( Properties propsExpected, Properties propsActual,
ValuesValidator validator ) throws EmbJoprTestException
+ {
+ checkValues(propsExpected, propsActual, validator, null);
+ }
+ public final void checkValues( Properties propsExpected, Properties propsActual,
ValuesValidator validator, String name ) throws EmbJoprTestException
+ {
+
+ // List the actual properties.
+ for( Object key : propsActual.keySet() ){
+ String propName = (String)key;
+ log.info("Actual property: '"+propName+"':
'"+propsActual.getProperty(propName)+"'");
+ }
+
+ // List of non-equal properties.
+ List<String> failures = new ArrayList<String>();
+
+ // Check all the properties.
+ for( Object key : propsExpected.keySet() ){
+ String propName = (String)key;
+ log.info("Checking '"+propName+"'...");
+ String exp = propsExpected.getProperty(propName);
+ String act = propsActual.getProperty(propName);
+
+ exp = EmbjoprTestCase.normalizeIfNumber(exp);
+ act = EmbjoprTestCase.normalizeIfNumber(act);
+
+ String validationError = validator.validate( exp, act );
+ if( null != validationError ){
+ failures.add( propName+": " + validationError );
+ }
+
+ // If some did not match, throw an exception with their list.
+ if( failures.size() != 0 ){
+ String realm = StringUtils.isBlank(name) ? "" : name+": ";
+ String exceptionMsg = String.format("%sNon-matching properties: (%d of %d
expected):\n",
+ realm, failures.size(), propsExpected.size()) + StringUtils.join(failures,
"\n");
+ throw new EmbJoprTestException( exceptionMsg, currentTest );
+ }
+ }
+
+ }
+
+
+
}// class EmbJoprTestToolkit
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/ValuesValidator.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/ValuesValidator.java 2009-08-11
23:49:51 UTC (rev 668)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/ValuesValidator.java 2009-08-12
03:28:47 UTC (rev 669)
@@ -34,5 +34,24 @@
}
};
+
+ public static final ValuesValidator CONTAINS = new ValuesValidator() {
+ public String validate( String exp, String act ){
+ if( ! StringUtils.contains( act, exp ) ){
+ return String.format( "String does not contain '%s': %s", exp, act
);
+ }
+ return null;
+ }
+ };
+
+ public static final ValuesValidator MATCHES = new ValuesValidator() {
+ public String validate( String exp, String act ){
+ if( ! act.matches(exp) ){
+ return String.format( "String does not match '%s': %s", exp, act
);
+ }
+ return null;
+ }
+ };
+
}