Author: ozizka(a)redhat.com
Date: 2009-07-27 16:40:38 -0400 (Mon, 27 Jul 2009)
New Revision: 590
Added:
trunk/jsfunit/testdata/jbcache/JBossCacheTest-by-fdrabek-client.jar
trunk/jsfunit/testdata/jbcache/JBossCacheTest-by-fdrabek.ear
Removed:
trunk/jsfunit/testdata/jbcache/JBossCacheTest-by-fdrabek-java15-B.ear
Modified:
trunk/jsfunit/pom.xml
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
trunk/jsfunit/testdata/jbcache/info.txt
Log:
* Updated JBossCacheTest
* Added client jar for JBossCacheTest (as a system dependency)
* JBossCacheTest EAR renamed
Modified: trunk/jsfunit/pom.xml
===================================================================
--- trunk/jsfunit/pom.xml 2009-07-27 17:13:05 UTC (rev 589)
+++ trunk/jsfunit/pom.xml 2009-07-27 20:40:38 UTC (rev 590)
@@ -32,6 +32,16 @@
</pluginRepositories>
<dependencies>
+
+ <!-- Test cases deps. -->
+ <dependency>
+ <groupId>org.jboss.qa.jbcache</groupId>
+ <artifactId>jboss-cache-testop-client</artifactId>
+ <version>1.0</version>
+ <scope>system</scope>
+
<systemPath>${basedir}/testdata/jbcache/JBossCacheTest-by-fdrabek-client.jar</systemPath>
+ </dependency>
+
<!-- Dropping back to HtmlUnit 2.3 with Rhino until bug can be addressed -->
<dependency>
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-27
17:13:05 UTC (rev 589)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTest.java 2009-07-27
20:40:38 UTC (rev 590)
@@ -1,10 +1,16 @@
package org.jboss.jopr.jsfunit.as5.jbcache;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.jboss.qa.jbcache.testear.*;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
import org.jboss.jopr.jsfunit.ApplicationTestBaseAS5;
import org.jboss.jopr.jsfunit.exceptions.ActionOutOfSyncException;
import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
@@ -25,11 +31,23 @@
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";
+ private static final String JBCACHE_HA_PARTITION =
"jboss.cache:config=ha-partition,service=Cache";
+ private static final String JBCACHE_MVCC_ENTITY =
"jboss.cache:config=mvcc-entity,service=Cache";
+ private static final String JBCACHE_PESSIMISTIC_SHARED =
"jboss.cache:config=pessimistic-shared,service=Cache";
+ private static final String JBCACHE_TIMESTAMPS =
"jboss.cache:config=timestamps-cache,service=Cache";
+ // Subnodes
+ private static final String SUBNODE_CACHE = "Cache";
+ private static final String SUBNODE_INTERCEPTOR = "Interceptor";
+ private static final String SUBNODE_DATA_CONTAINER = "Data Container";
+ private static final String SUBNODE_RPC_MANAGER = "RPC Manager";
+ private static final String SUBNODE_REGION_MANAGER = "RegionManager";
+ private static final String SUBNODE_TRANSACTION_TABLE = "Transaction Table";
+
+
private boolean isJBossConfigWithoutCache(){
boolean isJBossConfigWithoutCache = ! ejtt.getJBossConfig().equals("all");
if( isJBossConfigWithoutCache )
@@ -60,8 +78,9 @@
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;
+ // The ha-partition cache is active by default.
+ // Check that it's present.
+ boolean haparPresent = false;
// Check that all caches are UP.
for( ContentTableRow row : rows ){
String name = row.getCellByColumnName(COL_RESOURCE_NAME).getTextContent().trim();
@@ -69,11 +88,11 @@
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( JBCACHE_HA_PARTITION.equals(name) )
+ haparPresent = true;
}
- if( !defaultPresent)
- throw new EmbJoprTestException("The default cache,
'"+DEFAULT_JBCACHE+"', is not present.");
+ if( !haparPresent)
+ throw new EmbJoprTestException("The '"+JBCACHE_HA_PARTITION+"'
cache is not present.");
// Click on the first row link.
rows.get(0).getFirstLinkFromColumn(COL_RESOURCE_NAME).click();
@@ -85,15 +104,60 @@
+ /**
+ * Test the navigation to JBoss Cache nodes.
+ */
+ public void testJBossCacheNavigation() throws HtmlElementNotFoundException, IOException,
EmbJoprTestException {
+ if( isJBossConfigWithoutCache() ) return;
+ NavTreeNode haparNode = ejtt.getNavTree().getNodeByLabel(JBCACHE_HA_PARTITION);
+
+ // All expected subnodes:
+ String[] subnodesNames = new String[]{
+ SUBNODE_CACHE,
+ SUBNODE_INTERCEPTOR,
+ SUBNODE_DATA_CONTAINER,
+ SUBNODE_RPC_MANAGER,
+ SUBNODE_REGION_MANAGER,
+ SUBNODE_TRANSACTION_TABLE
+ };
+
+
+ // Check whether all expected child nodes are present.
+ List<String> names = new ArrayList();
+ CollectionUtils.addAll(names, subnodesNames);
+
+ // Remove the names which we find.
+ List<NavTreeNode> children = haparNode.getChildren();
+ for( NavTreeNode node : children ){
+ names.remove( node.getName() );
+ }
+ // The remaining names are missing.
+ if( names.size() > 0 ){
+ throw new EmbJoprTestException("These cache nodes are not present:
"+StringUtils.join(names, ", "));
+ }
+
+
+ // Click through all the subnodes (exception could occur).
+ for( String name : subnodesNames ){
+ ejtt.getNavTree().getNodeByLabel(name).click();
+ }
+
+ }
+
+
+
+
/**
* JBoss Cache Summary tab.
*/
public void testJBossCacheSummary() throws EmbJoprTestException, IOException {
if( isJBossConfigWithoutCache() ) return;
- ejtt.navTree.getNodeByLabel(DEFAULT_JBCACHE).click();
+ ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION).expand();
+ ejtt.navTree.getNodeByLabel(SUBNODE_CACHE).click();
+
/*
General Properties
Name:jboss.cache:config=ha-partition,service=Cache
@@ -108,7 +172,7 @@
assertEquals("Traits - Name", DEFAULT_JBCACHE,
props.getProperty("Name"));/**/
Properties props = new Properties();
- props.setProperty("Name", DEFAULT_JBCACHE);
+ props.setProperty("Name", "Cache");
ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_GENERAL_PROPERTIES).checkValues(props);
@@ -133,7 +197,8 @@
public void testJBossCacheMetrics() throws HtmlElementNotFoundException, IOException,
EmbJoprTestException {
if( isJBossConfigWithoutCache() ) return;
- ejtt.navTree.getNodeByLabel(DEFAULT_JBCACHE).click();
+ ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION).expand();
+ ejtt.navTree.getNodeByLabel(SUBNODE_CACHE).click();
ejtt.tabMenu.clickMetricsTab();
assertTrue( "Metrics tab is not active",
ejtt.tabMenu.isTabActive(TAB_NAME_METRICS) );
@@ -171,18 +236,18 @@
}
+
/**
- * JBoss Cache Control tab.
- *
- * Destroy this cache.
- * Print lock info as HTML.
- *
+ * JBoss Cache Control tab - test operations.
+ * Currently only testing whether the operations fails, because the print operations
don't return usable information.
+ * @see JOPR-319.
*/
public void testJBossCacheControl() throws HtmlElementNotFoundException, IOException,
ActionOutOfSyncException, EmbJoprTestException {
if( isJBossConfigWithoutCache() ) return;
- ejtt.navTree.getNodeByLabel(DEFAULT_JBCACHE).click();
+ ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION).expand();
+ ejtt.navTree.getNodeByLabel(SUBNODE_CACHE).click();
ejtt.tabMenu.clickControlTab();
assertTrue( "Control tab is not active",
ejtt.tabMenu.isTabActive(TAB_NAME_CONTROL) );
@@ -201,18 +266,118 @@
// Now test the operations, one by one.
Map<String, String> operationsToTest = new HashMap();
- operationsToTest.put("Print cache details.", "See JOPR-319.");
+ //operationsToTest.put("Print cache details.", "See JOPR-319.");
+
+ operationsToTest.put("Print cache details.", null);
+ operationsToTest.put("Print cache details as HTML.", null);
+ operationsToTest.put("Print lock information.", null);
+ operationsToTest.put("Print lock info as HTML.", null);
+ operationsToTest.put("Print configuration as plain text.", null);
+ operationsToTest.put("Print configuration as HTML.", null);
+
+
for( String opName : operationsToTest.keySet() ){
ejtt.operations.testOperation( opName, operationsToTest.get(opName) );
}
-
+ }
+
+
+
+
+
+ /**
+ * Interceptor Summary tab.
+ */
+ public void testJBossCacheInterceptorSummary() throws IOException, EmbJoprTestException
{
+ if( isJBossConfigWithoutCache() ) return;
+
+ ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION).expand();
+ ejtt.navTree.getNodeByLabel(SUBNODE_INTERCEPTOR).click();
+
+ // Gen Props - nothing useful.
+ Properties props = new Properties();
+ props.setProperty("Name", "Interceptor");
+ ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_GENERAL_PROPERTIES).checkValues(props);
+
+
/*
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Create this
cache.").click();
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Destroy this
cache.").click();
- */
+ Numeric Metrics
+ Hit/Miss Ratio 0 Hit/Miss Ratio
+ Read/Write Ratio 0 Read/Write Ratio
+ Number Of Attributes 0 the number of cache attributes
+ Average Write Time 0.0ms the average amount of time per write operation
+ Average Read Time 0.0ms the average amount of time per read operation
+ */
+ props = new Properties();
+ props.setProperty("Hit/Miss Ratio", "0");
+ props.setProperty("Read/Write Ratio", "0");
+ props.setProperty("Number Of Attributes", "0.0ms");
+ props.setProperty("Average Write Time", "0.0ms");
+ props.setProperty("Average Read Time", "0.0ms");
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(props);
}
+
+
+
+
+
+ /**
+ * Interceptor Summary tab after querying Hibernate.
+ */
+ public void testJBossCacheInterceptorSummary_AfterQuery() throws IOException,
EmbJoprTestException, NamingException {
+ if( isJBossConfigWithoutCache() ) return;
+
+
+ final String BEAN_JNDI = "TestOperationBean/remote";
+
+ // Query the bean.
+ log.info("Looking up "+BEAN_JNDI+"...");
+ InitialContext ctx = new InitialContext();
+ TestOperation bean = (TestOperation) ctx.lookup(BEAN_JNDI);
+
+ log.info("Sending request...");
+ bean.test();
+
+
+
+
+ ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION).expand();
+ ejtt.navTree.getNodeByLabel(SUBNODE_INTERCEPTOR).click();
+
+ // Gen Props - nothing useful.
+ Properties props = new Properties();
+ props.setProperty("Name", "Interceptor");
+ ejtt.getTabMenu().getTabContentBox().getTableUnformatted(LABEL_GENERAL_PROPERTIES).checkValues(props);
+
+
+ /*
+ Numeric Metrics
+ Hit/Miss Ratio 0 Hit/Miss Ratio
+ Read/Write Ratio 0 Read/Write Ratio
+ Number Of Attributes 0 the number of cache attributes
+ Average Write Time 0.0ms the average amount of time per write operation
+ Average Read Time 0.0ms the average amount of time per read operation
+ */
+ props = new Properties();
+ props.setProperty("Hit/Miss Ratio", "0");
+ props.setProperty("Read/Write Ratio", "0");
+ props.setProperty("Number Of Attributes", "0.0ms");
+ props.setProperty("Average Write Time", "0.0ms");
+ props.setProperty("Average Read Time", "0.0ms");
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(props);
+
+ }
+
+
+
+
+
+
+
+
+
}// 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-27
17:13:05 UTC (rev 589)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-07-27
20:40:38 UTC (rev 590)
@@ -422,6 +422,11 @@
this.elem = nodeTable;
}
+ /** Returns the display name of the node. */
+ public String getName(){
+ return this.elem.getTextContent().trim();
+ }
+
/** Returns true if this node is expanded. */
public boolean isExpanded() throws EmbJoprTestException
{
@@ -1220,6 +1225,9 @@
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;
@@ -1233,8 +1241,13 @@
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) );
+ failures.add( String.format(msgFormat, this.getTableName(), propName, exp, act) );
}
+
+ // If some did not match, throw an exception with their list.
+ if( failures.size() != 0 ){
+ throw new EmbJoprTestException( String.format("Non-matching properties: (%d of
%d expected):\n", failures.size(), propsExpected.size()) + StringUtils.join(failures,
"\n") );
+ }
}
}
@@ -1852,7 +1865,7 @@
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) ){
+ if( expectedOutput != null && ! StringUtils.equals(expectedOutput, output)
){
throw new EmbJoprTestException( String.format("Operation %s: Expected:
'%s', actual: '%s'", operationName, expectedOutput, output) );
}
}
Added: trunk/jsfunit/testdata/jbcache/JBossCacheTest-by-fdrabek-client.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/jbcache/JBossCacheTest-by-fdrabek-client.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/jsfunit/testdata/jbcache/JBossCacheTest-by-fdrabek-java15-B.ear
===================================================================
(Binary files differ)
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
Modified: trunk/jsfunit/testdata/jbcache/info.txt
===================================================================
--- trunk/jsfunit/testdata/jbcache/info.txt 2009-07-27 17:13:05 UTC (rev 589)
+++ trunk/jsfunit/testdata/jbcache/info.txt 2009-07-27 20:40:38 UTC (rev 590)
@@ -1,9 +1,13 @@
-JBossCacheTest-by-fdrabek-java15-B.ear :
+JBossCacheTest-by-fdrabek.ear :
- Deploy to all config to activate caches to make them appear in EmbJopr.
- URL:
https://svn.devel.redhat.com/repos/jboss-qa/jbcache/JBossCacheTestEar
+JBossCacheTest-by-fdrabek-client.jar :
+- Client interfaces / entities to work with the EAR.
+
JBossCacheTest-service.xml :
- Deploy to the all config.
-- Using descriptor, the cache can have any name. This -service.xml is used to test this
feature.
\ No newline at end of file
+- Using descriptor, the cache can have any name. This -service.xml is used to test this
feature.
+