[embjopr-commits] EMBJOPR SVN: r581 - in trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit: as5/jbcache and 2 other directories.
embjopr-commits at lists.jboss.org
embjopr-commits at lists.jboss.org
Thu Jul 23 21:21:21 EDT 2009
Author: ozizka at redhat.com
Date: 2009-07-23 21:21:21 -0400 (Thu, 23 Jul 2009)
New Revision: 581
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/jbcache/JBossCacheTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/EmbJoprTestException.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
Log:
* JBossCacheTest updated
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 21:21:07 UTC (rev 580)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-07-24 01:21:21 UTC (rev 581)
@@ -49,7 +49,7 @@
EMB_WAR(AppConstants.NAV_EMB_WAR,"Embbedded WAR", "", ".war", null, "application/war"),
// TODO: Create a superclass for non-app resource types - ResourceTypes.
- JBCACHE(AppConstants.NAV_JBCACHE, "Jboss Cache", null, null, null, null), // TODO: Should be JBoss
+ JBCACHE(AppConstants.NAV_JBCACHE, "JBoss Cache", null, null, null, null), // TODO: Should be JBoss
HBN(AppConstants.NAV_HBN, "Hibernate", null, null, null, null);
@@ -141,7 +141,7 @@
public static final String NAV_SBMS = "Service Binding Managers";
public static final String NAV_SBM = "ServiceBindingManager";
public static final String NAV_JBCACHE = "JBoss Cache";
- public static final String NAV_JBCACHES = "Jboss Caches";
+ public static final String NAV_JBCACHES = "JBoss Caches";
public static final String NAV_HBN = "Hibernate";
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 21:21:07 UTC (rev 580)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbJoprTestConstants.java 2009-07-24 01:21:21 UTC (rev 581)
@@ -45,6 +45,10 @@
public static final String TAB_NAME_CONTROL = "Control";
public static final String TAB_NAME_CONTENT = "Content";
+
+ // Operations
+ public static final String OPERATION_OUTPUT_PROPERTY = "Output";
+
}// interface
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 21:21:07 UTC (rev 580)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTest.java 2009-07-24 01:21:21 UTC (rev 581)
@@ -1,9 +1,12 @@
package org.jboss.jopr.jsfunit.as5.jbcache;
import java.io.IOException;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.jboss.jopr.jsfunit.ApplicationTestBaseAS5;
+import org.jboss.jopr.jsfunit.exceptions.ActionOutOfSyncException;
import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
import org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException;
import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.ContentTable;
@@ -15,8 +18,6 @@
* @author Ondrej Zizka
*
* JBoss Cache is only present in 'all' JBoss AS profile.
- *
- * TODO: Implement when JBoss Cache support comes to EmbJopr.
*/
public class JBossCacheTest extends ApplicationTestBaseAS5 {
@@ -27,13 +28,19 @@
private static final String DEFAULT_JBCACHE = "jboss.cache:config=ha-partition,service=Cache";
+
+
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.");
+ log.warn("JBoss instance is not running the 'all' configuration ('"+ejtt.getJBossConfig()+"' instead) - " +
+ "thus, has no JBoss Cache. Set -Dcargo.jboss.configuration=all for maven.");
return isJBossConfigWithoutCache;
}
+
+
+
/**
* Test the navigation to JBoss Cache nodes.
*/
@@ -57,15 +64,16 @@
boolean defaultPresent = false;
// Check that all caches are UP.
for( ContentTableRow row : rows ){
- String name = row.getCellByColumnName(COL_RESOURCE_NAME).getTextContent();
+ String name = row.getCellByColumnName(COL_RESOURCE_NAME).getTextContent().trim();
String status = row.getCellByColumnName(COL_RESOURCE_STATUS).getTextContent().trim();
+ log.info("Cache '"+name+" - status '"+status+"'.");
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.");
+ throw new EmbJoprTestException("The default cache, '"+DEFAULT_JBCACHE+"', is not present.");
// Click on the first row link.
rows.get(0).getFirstLinkFromColumn(COL_RESOURCE_NAME).click();
@@ -76,6 +84,8 @@
}
+
+
/**
* JBoss Cache Summary tab.
*/
@@ -126,24 +136,24 @@
ejtt.navTree.getNodeByLabel(DEFAULT_JBCACHE).click();
ejtt.tabMenu.clickMetricsTab();
- assertTrue( ejtt.tabMenu.isTabActive(TAB_NAME_METRICS) );
+ assertTrue( "Metrics tab is not active", 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");
+ 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);
@@ -164,15 +174,45 @@
/**
* JBoss Cache Control tab.
+ *
+ * Destroy this cache.
+ * Print lock info as HTML.
+ *
*/
- public void testJBossCacheControl() throws HtmlElementNotFoundException, IOException {
+ public void testJBossCacheControl() throws HtmlElementNotFoundException, IOException, ActionOutOfSyncException, EmbJoprTestException {
if( isJBossConfigWithoutCache() ) return;
ejtt.navTree.getNodeByLabel(DEFAULT_JBCACHE).click();
ejtt.tabMenu.clickControlTab();
- assertTrue( ejtt.tabMenu.isTabActive(TAB_NAME_CONTROL) );
+ assertTrue( "Control tab is not active", ejtt.tabMenu.isTabActive(TAB_NAME_CONTROL) );
+
+ // Click some buttons - should not harm.
+ ejtt.tabMenu.getTabContentBox().getButtonByLabel("Print cache details as HTML.").click();
+ ejtt.tabMenu.getTabContentBox().getButtonByLabel("Print lock information.").click();
+ ejtt.tabMenu.getTabContentBox().getButtonByLabel("Print lock info as HTML.").click();
+ ejtt.tabMenu.getTabContentBox().getButtonByLabel("Print configuration as plain text.").click();
+ ejtt.tabMenu.getTabContentBox().getButtonByLabel("Print configuration as HTML.").click();
+
+ ejtt.tabMenu.getTabContentBox().getButtonByLabel("Stop this cache.").click();
+ ejtt.tabMenu.getTabContentBox().getButtonByLabel("Start this cache.").click();
+
+
+ // Now test the operations, one by one.
+ Map<String, String> operationsToTest = new HashMap();
+ operationsToTest.put("Print cache details.", "See JOPR-319.");
+
+ for( String opName : operationsToTest.keySet() ){
+ ejtt.operations.testOperation( opName, operationsToTest.get(opName) );
+ }
+
+
+ /*
+ ejtt.tabMenu.getTabContentBox().getButtonByLabel("Create this cache.").click();
+ ejtt.tabMenu.getTabContentBox().getButtonByLabel("Destroy this cache.").click();
+ */
+
}
}// class
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/EmbJoprTestException.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/EmbJoprTestException.java 2009-07-23 21:21:07 UTC (rev 580)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/EmbJoprTestException.java 2009-07-24 01:21:21 UTC (rev 581)
@@ -46,10 +46,11 @@
if( null == test ) return;
+ String path = "target/"+test.getName() + getDumpSuffix()+".html";
try {
- DebugUtils.writeFile("target/"+test.getName() + "-ElmNotFoundEx.html", test.getClient().getPageAsText());
+ DebugUtils.writeFile(path, test.getClient().getPageAsText());
} catch (Throwable ex) {
- // ...
+ System.out.println("ERROR dumping to "+path);
}
}
@@ -63,5 +64,10 @@
public EmbJoprTestException() {
}
+
+ private String getDumpSuffix() {
+ //return "-ElmNotFoundEx";
+ return "-EmbJoprTestEx";
+ }
}
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 21:21:07 UTC (rev 580)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-07-24 01:21:21 UTC (rev 581)
@@ -797,7 +797,7 @@
}
/**
- * Returns the operation history table from the Content tab.
+ * Returns the operation history table from the Control tab.
*/
public OperationsHistoryTable getOperationsHistoryTable() throws HtmlElementNotFoundException {
@@ -809,13 +809,27 @@
throw new HtmlElementNotFoundException(
"Can't find the ops history table element, searched ID: " + elemID, currentTest);
}
-
return new OperationsHistoryTable( (HtmlTable)elem );
}
+ /**
+ * Returns the operation results table from the Control tab.
+ */
+ public ContentTable getOperationResultsTable() throws HtmlElementNotFoundException {
+ String elemID = "operationResults";
+ HtmlElement elem = (HtmlElement) client.getElement(elemID);
+ if( null == elem ){
+ throw new HtmlElementNotFoundException(
+ "Can't find the op results table element, searched ID: " + elemID, currentTest);
+ }
+ HtmlTable tableElm = elem.getFirstByXPath(".//table[@class='properties-table']");
+ return new ContentTable( (HtmlTable)tableElm );
+ }
+
+
/**
* Finds first button with given label inside this tab box.
*/
@@ -1057,11 +1071,15 @@
return new ContentTableRow(elm, this);
}
+
+ /**
+ * Returns a collection of wrapped rows of this table.
+ */
public List<ContentTableRow> getRows(){
if( 0 == element.getRowCount() )
return Collections.EMPTY_LIST;
- String xPath = "./tbody/tr";
+ String xPath = "./tbody/tr[not contains( @class , 'categoryRow')]";
List<HtmlTableRow> trList = (List) element.getByXPath(xPath);
List<ContentTableRow> rows = new ArrayList(trList.size());
for (HtmlTableRow tr : trList) {
@@ -1164,13 +1182,16 @@
public Properties getProperties( String keyColName, String valueColName ) throws HtmlElementNotFoundException
{
int keyColIndex = this.getColumnIndexByName(keyColName);
- int valColindex = this.getColumnIndexByName(valueColName);
+ int valColIndex = this.getColumnIndexByName(valueColName);
+
+ log.debug("keyColIndex: "+keyColIndex+", valColIndex: "+valColIndex);
Properties props = new Properties();
for( ContentTableRow row : this.getRows() ){
- String key = row.getCell( keyColIndex ).getTextContent();
- String value = row.getCell( valColindex ).getTextContent();
+ 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();
props.setProperty(key, value);
}
@@ -1192,9 +1213,16 @@
// Get this tables properties. Different table types can override this.
Properties propsActual = this.getProperties();
+ // List the actual properties.
+ for( Object key : propsActual.keySet() ){
+ String propName = (String)key;
+ log.info("Actual property: '"+propName+"': '"+propsActual.getProperty(propName)+"'");
+ }
+
// 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);
if( !StringUtils.equals( exp, act ) ){
@@ -1796,6 +1824,47 @@
}
+
+ /**
+ * Performs the operation, waits until it finishes, and checks whether the result was as expected.
+ * @param name
+ * @param expectedResult
+ */
+ public Properties performOperation( String operationName ) throws EmbJoprTestException, IOException {
+ getEjtt().tabMenu.getTabContentBox().getButtonByLabel(operationName).click();
+ getEjtt().operations.waitActivelyForOperationToFinish(operationName, 500, 5);
+ if( ! getEjtt().tabMenu.getTabContentBox().getOperationsHistoryTable().wasLastOperationSuccesful() ){
+ OperationStatusType status = getEjtt().tabMenu.getTabContentBox().getOperationsHistoryTable().getLastOperationStatus();
+ throw new EmbJoprTestException("Operation was not succesfull: "+operationName+" Status: "+status.getStatusText());
+ }
+ return getEjtt().operations.getLastOperationResults();
+ }
+
+ /**
+ * Performs the operation and checks whether the Output result property matches given expected output.
+ */
+ public void testOperation( String operationName, String expectedOutput ) throws EmbJoprTestException, IOException {
+ Properties results = performOperation(operationName);
+ String output = results.getProperty(EmbJoprTestConstants.OPERATION_OUTPUT_PROPERTY);
+ if( ! StringUtils.equals(expectedOutput, output) ){
+ throw new EmbJoprTestException( String.format("Operation %s: Expected: '%s', actual: '%s'", operationName, expectedOutput, output) );
+ }
+ }
+
+
+ /**
+ * Returns a Properties with the result of last performed operation.
+ * Assumes that we're on the Control tab.
+ */
+ public Properties getLastOperationResults() throws HtmlElementNotFoundException{
+ Properties props = new Properties();
+
+ ContentTable resultsTable = getEjtt().tabMenu.getTabContentBox().getOperationResultsTable();
+ props = resultsTable.getProperties();
+
+ return props;
+ }
+
}// class Operations
More information about the embjopr-commits
mailing list