EMBJOPR SVN: r600 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-07-28 12:14:40 -0400 (Tue, 28 Jul 2009)
New Revision: 600
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
Log:
* Connfactory test - set secured to true by default for few more methods.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-07-28 16:14:17 UTC (rev 599)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-07-28 16:14:40 UTC (rev 600)
@@ -969,7 +969,7 @@
protected Map<String, MetaValue> getSpecificComponentProperties(String componentName,
ComponentType type,
String specificProperties[]) throws Exception {
- return getSpecificComponentProperties(componentName, type, specificProperties, false);
+ return getSpecificComponentProperties(componentName, type, specificProperties, true);
}
/**
15 years, 5 months
EMBJOPR SVN: r599 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-07-28 12:14:17 -0400 (Tue, 28 Jul 2009)
New Revision: 599
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
Log:
* Connfactory test - set secured to true by default for few more methods.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-07-28 16:07:49 UTC (rev 598)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-07-28 16:14:17 UTC (rev 599)
@@ -904,7 +904,7 @@
*/
protected void checkComponentProperties(Map<String, MetaValue> expectedProperties, String componentName,
ComponentType type) throws Exception {
- checkComponentProperties(expectedProperties, componentName, type, false);
+ checkComponentProperties(expectedProperties, componentName, type, true);
}
/**
@@ -933,7 +933,7 @@
*/
protected Map<String, MetaValue> getComponentProperties(String componentName,
ComponentType type) throws Exception {
- return getComponentProperties(componentName, type, false);
+ return getComponentProperties(componentName, type, true);
}
/**
15 years, 5 months
EMBJOPR SVN: r598 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-07-28 12:07:49 -0400 (Tue, 28 Jul 2009)
New Revision: 598
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryCreationTest.java
Log:
* Connfactory test - track-connection-by-tx replaced with interleaving.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryCreationTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryCreationTest.java 2009-07-28 15:50:44 UTC (rev 597)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryCreationTest.java 2009-07-28 16:07:49 UTC (rev 598)
@@ -60,7 +60,9 @@
Map<String, MetaValue> propertiesMapAsMetaValues = createConnFactoryPropertiesAsMetaValues(jndiName);
// Add an additional property
- propertiesMapAsMetaValues.put("track-connection-by-tx", SimpleValueSupport.wrap(Boolean.TRUE));
+ //propertiesMapAsMetaValues.put("track-connection-by-tx", SimpleValueSupport.wrap(Boolean.TRUE));
+ //This property supercedes the "track-connection-by-tx" property from earlier versions of JBoss AS.
+ propertiesMapAsMetaValues.put("interleaving", SimpleValueSupport.wrap(Boolean.FALSE));
createConnFactoryCommon(jndiName, CFType.LOCAL_TX_CF,
LOCAL_TX_COMPONENT_TYPE, propertiesMapAsMetaValues);
15 years, 5 months
EMBJOPR SVN: r597 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-07-28 11:50:44 -0400 (Tue, 28 Jul 2009)
New Revision: 597
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
Log:
* DS test - removed propertiesMap.put("track-connection-by-tx", "false") for No-TX.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-07-28 02:31:32 UTC (rev 596)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-07-28 15:50:44 UTC (rev 597)
@@ -444,7 +444,7 @@
Map<String, String> propertiesMap = new HashMap<String, String>();
propertiesMap.put("jndi-name", datasourceName);
propertiesMap.put("prefill", "false");
- propertiesMap.put("track-connection-by-tx", "false");
+ //propertiesMap.put("track-connection-by-tx", "false"); // 1) Property metamorfed to "interleaving" 2) No use for No-TX.
propertiesMap.put("max-pool-size", "20");
propertiesMap.put("min-pool-size", "5");
propertiesMap.put("blocking-timeout-millis", "55000");
15 years, 5 months
EMBJOPR SVN: r596 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-07-27 22:31:32 -0400 (Mon, 27 Jul 2009)
New Revision: 596
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/RootNodeTest.java
Log:
* RootNodeTest - Control tab test disabled (Control tab is currently disabled)
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/RootNodeTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/RootNodeTest.java 2009-07-28 02:10:21 UTC (rev 595)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/RootNodeTest.java 2009-07-28 02:31:32 UTC (rev 596)
@@ -116,8 +116,10 @@
/**
* Checks the Manual Autorediscovery feature of the Control tab.
+ *
+ * DISABLED: (04:19:44) ips-out: ozizka: you can assume it will remain disabled for now
*/
- public void XtestRootNodeControlViewProcessList() throws EmbJoprTestException {
+ public void DISABLEDtestRootNodeControlViewProcessList() throws EmbJoprTestException {
try{
15 years, 5 months
EMBJOPR SVN: r595 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-07-27 22:10:21 -0400 (Mon, 27 Jul 2009)
New Revision: 595
Added:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/RootNodeTest.java
Removed:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ServerNodeSummaryTest.java
Log:
* RootNodeTest - Control tab test disabled (Control tab is currently disabled)
Copied: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/RootNodeTest.java (from rev 592, trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ServerNodeSummaryTest.java)
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/RootNodeTest.java (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/RootNodeTest.java 2009-07-28 02:10:21 UTC (rev 595)
@@ -0,0 +1,380 @@
+package org.jboss.jopr.jsfunit.as5;
+
+import org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException;
+import org.jboss.jopr.jsfunit.exceptions.ActionOutOfSyncException;
+import com.gargoylesoftware.htmlunit.html.*;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.InetAddress;
+import java.net.URL;
+import java.net.UnknownHostException;
+import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
+import org.jboss.jopr.jsfunit.EmbjoprTestCase;
+
+
+/**
+ * Tests the initial screen - the root node's Summary, Metrics and Control tab.
+ *
+ * @author ondra
+ */
+public class RootNodeTest extends EmbjoprTestCase {
+
+ /**
+ * Checks the summary tab contents.
+ */
+ public void testRootNodeSummary() throws EmbJoprTestException {
+
+ try{
+
+ new NavTree().clickRootNode();
+
+ //if( !tabMenu.isTabActive("Summary")) // we can click either
+ tabMenu.clickTab("Summary");
+
+
+ //HtmlElement box = tabMenu.getTabContentBox().getElement();
+
+ helpers.checkSummaryValue( "Name", helpers.getLocalHostName() );
+ // System.getProperty("os.name") // Gives the computer name.
+ //helpers.checkSummaryValue( "OS Name", System.getProperty("os.name") );
+ helpers.checkSummaryValue( "OS Name", executeProcessAndGetOutput("uname") );
+ helpers.checkSummaryValue( "OS Version", System.getProperty("os.version") );
+ helpers.checkSummaryValue( "Architecture", System.getProperty("os.arch") );
+
+
+ // $ cat /proc/version
+ // Linux version 2.6.18-92.1.18.el5xen (brewbuilder(a)hs20-bc2-4.build.redhat.com) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Wed Nov 5 09:15:48 EST 2009
+
+
+ // $ cat /etc/redhat-release
+ // Red Hat Enterprise Linux Server release 5.2 (Tikanga)
+
+ // Commented out - this would only work on Red Hat.
+ // TODO: How to get these values universally?
+ /*try{
+ String rhRelease = executeProcessAndGetOutput("cat /etc/redhat-release");
+ String distName = helpers.getSummaryValue("Distribution Name").trim();
+ String distVersion = helpers.getSummaryValue("Distribution Version").trim();
+ assertEquals( rhRelease, distName + " " + distVersion );
+ }
+ catch( IOException ex ){
+ // cat not found or similar.
+ // When file not found, just returns emty string.
+ }*/
+
+
+ }
+ catch( IOException ex ){
+ throw new EmbJoprTestException(ex);
+ }
+
+ }// testSummary()
+
+
+
+ /**
+ * Checks the Metrics tab contents.
+ * Not much to do here - same values as in Summary.
+ */
+ /*public void testMetrics() throws AssertException {
+
+ }/**/
+
+
+
+ /**
+ * Checks the Manual Autorediscovery feature of the Control tab.
+ */
+ public void testRootNodeControlManualAutodiscovery() throws EmbJoprTestException {
+
+ try{
+
+ navTree.clickRootNode();
+
+ if( tabMenu.isTabDisabled("Control") )
+ fail("Root (server) node's Control tab is disabled.");
+
+ tabMenu.clickTab("Control");
+ TabContentBox box = tabMenu.getTabContentBox();
+
+ HtmlButtonInput button = box.getButtonByLabel("Manual Autodiscovery");
+ button.click();
+
+ // TODO: check the result.
+
+ }
+ catch( IOException ex ){
+ throw new EmbJoprTestException(ex);
+ }
+
+ }
+
+
+
+
+ /**
+ * Checks the Manual Autorediscovery feature of the Control tab.
+ */
+ public void XtestRootNodeControlViewProcessList() throws EmbJoprTestException {
+
+ try{
+
+ navTree.clickRootNode();
+
+ if( tabMenu.isTabDisabled("Control") )
+ fail("Root (server) node's Control tab is disabled.");
+
+ tabMenu.clickTab("Control");
+ TabContentBox box = tabMenu.getTabContentBox();
+
+ HtmlButtonInput button = box.getButtonByLabel("View Process List");
+ button.click();
+
+ // TODO: check the result.
+
+ }
+ catch( IOException ex ){
+ throw new EmbJoprTestException(ex);
+ }
+
+ }
+
+
+
+
+
+
+
+
+
+ Helpers helpers = new Helpers();
+
+ /**
+ * Helper mathods for this test.
+ */
+ class Helpers {
+
+
+ /**
+ * Gets the string value from the summary table.
+ * @param name
+ * @return
+ * @throws org.jboss.jopr.jsfunit.AssertException
+ */
+ private String getSummaryValue(String name) throws EmbJoprTestException{
+
+ HtmlElement box = tabMenu.getTabContentBox().getElement();
+ String xPath = "//td//strong[contains(string(), '"+name+":')]/ancestor::td[1]";
+ HtmlElement tableCell = (HtmlElement) box.getFirstByXPath(xPath);
+ if( null == tableCell )
+ throw new EmbJoprTestException("Value for '"+name+"' not found using XPath: "+xPath);
+
+ String actualValue = tableCell.getLastChild().getTextContent().trim();
+ return actualValue;
+
+ }
+
+ private void checkSummaryValue(String name, String expectedValue ) throws EmbJoprTestException {
+ String actualValue = getSummaryValue(name);
+ assertTrue( String.format("Summary property '%s' doesn't fit - expected: '%s'; actual: '%s'",
+ name, expectedValue, actualValue),
+ actualValue.trim().endsWith(expectedValue) );
+ }
+
+
+ private String getLocalHostName() throws UnknownHostException {
+ InetAddress addr = InetAddress.getLocalHost();
+ return addr.getHostName();
+ }
+
+ }
+
+
+
+ /**
+ * Intended to read files like "cat /proc/version" etc.
+ * Returns the content of whole file.
+ *
+ * @returns the content of whole file.
+ */
+ private static String executeProcessAndGetOutput( String command ) throws IOException {
+
+ Process exec = Runtime.getRuntime().exec( command );
+ InputStream inputStream = exec.getInputStream();
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+ StringBuilder sb = new StringBuilder();
+
+ do{
+ String s = bufferedReader.readLine();
+ if( null == s )
+ break;
+ sb.append(s);
+ } while( false );
+
+ return sb.toString();
+
+ }
+
+
+
+
+
+
+
+
+ // TODO: Move to EmbJopr base class? Or make some order there?
+
+
+ private NavTree navTree = new NavTree();
+
+ /**
+ * Inner class to encapsulate navigation tree operations.
+ */
+ class NavTree {
+
+ private void clickRootNode() throws IOException, EmbJoprTestException {
+ DomElement element = (DomElement)client.getElement("navTreeForm");
+ if( null == element )
+ throw new HtmlElementNotFoundException("Can't find #navTreeForm.");
+
+ // ID changes upon core build?
+ //HtmlAnchor rootNodeLink = element.getFirstByXPath("//a[@id='navTreeForm:navTree:2::homeLink']");
+
+ // javax.xml.transform.TransformerException: Can't find function: matches
+ //HtmlAnchor rootNodeLink = element.getFirstByXPath(
+ // "//a[matches(@id,'^navTreeForm:navTree:.+::homeLink$')]");
+
+
+ String xPath = "//a[ starts-with( @id, 'navTreeForm:navTree:' ) " +
+ " and contains( @id, '::homeLink' ) ]"; // XPath 2.0: ends-with( @id, '::homeLink' )
+ HtmlAnchor rootNodeLink = element.getFirstByXPath(xPath);
+
+ if( null == rootNodeLink )
+ throw new HtmlElementNotFoundException("Root node not found using XPath: "+xPath);
+
+ rootNodeLink.click();
+ }
+
+ }
+
+
+
+
+
+ private final TabMenu tabMenu = new TabMenu();
+
+ /**
+ * Inner class to encapsulate tab menu operations.
+ */
+ class TabMenu {
+
+ public TabContentBox getTabContentBox() throws EmbJoprTestException {
+
+ HtmlElement contentElement = (HtmlElement) client.getElement("content");
+ HtmlElement tabContentBox = (HtmlElement) contentElement.getFirstByXPath("div[@class='tabmenubox']");
+ if( null == tabContentBox )
+ throw new EmbJoprTestException("Tab content box not found using div[@class='tabmenubox'] XPath");
+
+ return new TabContentBox(tabContentBox);
+ }
+
+ public StyledElement getTab( String label ) throws EmbJoprTestException {
+
+ DomElement element = (DomElement)client.getElement("tabmenu");
+ String xPath = "ul/li/span[normalize-space(string())='"+label+"'] | ul/li/a[normalize-space(string())='"+label+"']";
+ StyledElement tabContent = element.getFirstByXPath(xPath);
+
+ if( null == tabContent )
+ throw new EmbJoprTestException("Tab '"+label+" not found using XPath '"+xPath+"'");
+
+ return tabContent;
+
+ }
+
+ public boolean isTabActive( String label ) throws IOException, EmbJoprTestException {
+
+ StyledElement tabContent = getTab(label);
+ return "span".equals( tabContent.getTagName() )
+ && tabContent.getClassAttribute().contains("active");
+ }
+
+
+ public boolean isTabDisabled( String label ) throws EmbJoprTestException {
+ StyledElement tabContent = getTab(label);
+ return "span".equals( tabContent.getTagName() )
+ && tabContent.getClassAttribute().contains("disabled");
+ }
+
+ public void clickTab( String label ) throws IOException, EmbJoprTestException {
+
+ StyledElement tabContent = getTab(label);
+
+ //if( !"a".equals( tabContent.getTagName() ) )
+ //if( !( tabContent instanceof HtmlAnchor ) )
+ // throw new AssertException("Tab is not an anchor: "+label);
+
+ if( !( tabContent instanceof ClickableElement ) )
+ throw new EmbJoprTestException("Tab element <"+tabContent.getTagName()+"> is not clickable: "+label);
+
+ ((ClickableElement)tabContent).click();
+
+ }
+
+ }
+
+
+ /**
+ * Inner class for manipulation with tab content box.
+ */
+ class TabContentBox {
+
+ private HtmlElement box;
+ private URL validForURL;
+ private String validForDate;
+
+ public HtmlElement getElement() { return box; }
+
+
+
+ public TabContentBox(HtmlElement box) {
+ this.box = box;
+
+ // TODO: Check whether the page changed;
+ this.validForDate = client.getContentPage().getWebResponse().getResponseHeaderValue("Date");
+ this.validForURL = client.getContentPage().getWebResponse().getUrl();
+ }
+
+
+ public void checkIfStillValid() throws ActionOutOfSyncException {
+
+ String validForDate = client.getContentPage().getWebResponse().getResponseHeaderValue("Date");
+ URL validForURL = client.getContentPage().getWebResponse().getUrl();
+
+ if( !validForDate.equals(this.validForDate) ||
+ !validForURL.equals(this.validForURL) )
+ {
+ throw new ActionOutOfSyncException(
+ "This tab content box was created from another page and is not valid now.");
+ }
+ }
+
+ public HtmlButtonInput getButtonByLabel( String label )
+ throws HtmlElementNotFoundException, ActionOutOfSyncException {
+
+ checkIfStillValid();
+
+ HtmlButtonInput button = this.box.getFirstByXPath("//input[@value='"+label+"']");
+ if( null == button )
+ throw new HtmlElementNotFoundException("Button labelled '"+label+"' not found.");
+
+ return button;
+
+ }
+
+ }
+
+
+
+}
Deleted: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ServerNodeSummaryTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ServerNodeSummaryTest.java 2009-07-28 01:02:37 UTC (rev 594)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ServerNodeSummaryTest.java 2009-07-28 02:10:21 UTC (rev 595)
@@ -1,380 +0,0 @@
-package org.jboss.jopr.jsfunit.as5;
-
-import org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException;
-import org.jboss.jopr.jsfunit.exceptions.ActionOutOfSyncException;
-import com.gargoylesoftware.htmlunit.html.*;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.InetAddress;
-import java.net.URL;
-import java.net.UnknownHostException;
-import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
-import org.jboss.jopr.jsfunit.EmbjoprTestCase;
-
-
-/**
- * Tests the initial screen - the root node's Summary, Metrics and Control tab.
- *
- * @author ondra
- */
-public class ServerNodeSummaryTest extends EmbjoprTestCase {
-
- /**
- * Checks the summary tab contents.
- */
- public void testRootNodeSummary() throws EmbJoprTestException {
-
- try{
-
- new NavTree().clickRootNode();
-
- //if( !tabMenu.isTabActive("Summary")) // we can click either
- tabMenu.clickTab("Summary");
-
-
- //HtmlElement box = tabMenu.getTabContentBox().getElement();
-
- helpers.checkSummaryValue( "Name", helpers.getLocalHostName() );
- // System.getProperty("os.name") // Gives the computer name.
- //helpers.checkSummaryValue( "OS Name", System.getProperty("os.name") );
- helpers.checkSummaryValue( "OS Name", executeProcessAndGetOutput("uname") );
- helpers.checkSummaryValue( "OS Version", System.getProperty("os.version") );
- helpers.checkSummaryValue( "Architecture", System.getProperty("os.arch") );
-
-
- // $ cat /proc/version
- // Linux version 2.6.18-92.1.18.el5xen (brewbuilder(a)hs20-bc2-4.build.redhat.com) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Wed Nov 5 09:15:48 EST 2009
-
-
- // $ cat /etc/redhat-release
- // Red Hat Enterprise Linux Server release 5.2 (Tikanga)
-
- // Commented out - this would only work on Red Hat.
- // TODO: How to get these values universally?
- /*try{
- String rhRelease = executeProcessAndGetOutput("cat /etc/redhat-release");
- String distName = helpers.getSummaryValue("Distribution Name").trim();
- String distVersion = helpers.getSummaryValue("Distribution Version").trim();
- assertEquals( rhRelease, distName + " " + distVersion );
- }
- catch( IOException ex ){
- // cat not found or similar.
- // When file not found, just returns emty string.
- }*/
-
-
- }
- catch( IOException ex ){
- throw new EmbJoprTestException(ex);
- }
-
- }// testSummary()
-
-
-
- /**
- * Checks the Metrics tab contents.
- * Not much to do here - same values as in Summary.
- */
- /*public void testMetrics() throws AssertException {
-
- }/**/
-
-
-
- /**
- * Checks the Manual Autorediscovery feature of the Control tab.
- */
- public void testRootNodeControlManualAutodiscovery() throws EmbJoprTestException {
-
- try{
-
- navTree.clickRootNode();
-
- if( tabMenu.isTabDisabled("Control") )
- fail("Root (server) node's Control tab is disabled.");
-
- tabMenu.clickTab("Control");
- TabContentBox box = tabMenu.getTabContentBox();
-
- HtmlButtonInput button = box.getButtonByLabel("Manual Autodiscovery");
- button.click();
-
- // TODO: check the result.
-
- }
- catch( IOException ex ){
- throw new EmbJoprTestException(ex);
- }
-
- }
-
-
-
-
- /**
- * Checks the Manual Autorediscovery feature of the Control tab.
- */
- public void testRootNodeControlViewProcessList() throws EmbJoprTestException {
-
- try{
-
- navTree.clickRootNode();
-
- if( tabMenu.isTabDisabled("Control") )
- fail("Root (server) node's Control tab is disabled.");
-
- tabMenu.clickTab("Control");
- TabContentBox box = tabMenu.getTabContentBox();
-
- HtmlButtonInput button = box.getButtonByLabel("View Process List");
- button.click();
-
- // TODO: check the result.
-
- }
- catch( IOException ex ){
- throw new EmbJoprTestException(ex);
- }
-
- }
-
-
-
-
-
-
-
-
-
- Helpers helpers = new Helpers();
-
- /**
- * Helper mathods for this test.
- */
- class Helpers {
-
-
- /**
- * Gets the string value from the summary table.
- * @param name
- * @return
- * @throws org.jboss.jopr.jsfunit.AssertException
- */
- private String getSummaryValue(String name) throws EmbJoprTestException{
-
- HtmlElement box = tabMenu.getTabContentBox().getElement();
- String xPath = "//td//strong[contains(string(), '"+name+":')]/ancestor::td[1]";
- HtmlElement tableCell = (HtmlElement) box.getFirstByXPath(xPath);
- if( null == tableCell )
- throw new EmbJoprTestException("Value for '"+name+"' not found using XPath: "+xPath);
-
- String actualValue = tableCell.getLastChild().getTextContent().trim();
- return actualValue;
-
- }
-
- private void checkSummaryValue(String name, String expectedValue ) throws EmbJoprTestException {
- String actualValue = getSummaryValue(name);
- assertTrue( String.format("Summary property '%s' doesn't fit - expected: '%s'; actual: '%s'",
- name, expectedValue, actualValue),
- actualValue.trim().endsWith(expectedValue) );
- }
-
-
- private String getLocalHostName() throws UnknownHostException {
- InetAddress addr = InetAddress.getLocalHost();
- return addr.getHostName();
- }
-
- }
-
-
-
- /**
- * Intended to read files like "cat /proc/version" etc.
- * Returns the content of whole file.
- *
- * @returns the content of whole file.
- */
- private static String executeProcessAndGetOutput( String command ) throws IOException {
-
- Process exec = Runtime.getRuntime().exec( command );
- InputStream inputStream = exec.getInputStream();
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
- StringBuilder sb = new StringBuilder();
-
- do{
- String s = bufferedReader.readLine();
- if( null == s )
- break;
- sb.append(s);
- } while( false );
-
- return sb.toString();
-
- }
-
-
-
-
-
-
-
-
- // TODO: Move to EmbJopr base class? Or make some order there?
-
-
- private NavTree navTree = new NavTree();
-
- /**
- * Inner class to encapsulate navigation tree operations.
- */
- class NavTree {
-
- private void clickRootNode() throws IOException, EmbJoprTestException {
- DomElement element = (DomElement)client.getElement("navTreeForm");
- if( null == element )
- throw new HtmlElementNotFoundException("Can't find #navTreeForm.");
-
- // ID changes upon core build?
- //HtmlAnchor rootNodeLink = element.getFirstByXPath("//a[@id='navTreeForm:navTree:2::homeLink']");
-
- // javax.xml.transform.TransformerException: Can't find function: matches
- //HtmlAnchor rootNodeLink = element.getFirstByXPath(
- // "//a[matches(@id,'^navTreeForm:navTree:.+::homeLink$')]");
-
-
- String xPath = "//a[ starts-with( @id, 'navTreeForm:navTree:' ) " +
- " and contains( @id, '::homeLink' ) ]"; // XPath 2.0: ends-with( @id, '::homeLink' )
- HtmlAnchor rootNodeLink = element.getFirstByXPath(xPath);
-
- if( null == rootNodeLink )
- throw new HtmlElementNotFoundException("Root node not found using XPath: "+xPath);
-
- rootNodeLink.click();
- }
-
- }
-
-
-
-
-
- private final TabMenu tabMenu = new TabMenu();
-
- /**
- * Inner class to encapsulate tab menu operations.
- */
- class TabMenu {
-
- public TabContentBox getTabContentBox() throws EmbJoprTestException {
-
- HtmlElement contentElement = (HtmlElement) client.getElement("content");
- HtmlElement tabContentBox = (HtmlElement) contentElement.getFirstByXPath("div[@class='tabmenubox']");
- if( null == tabContentBox )
- throw new EmbJoprTestException("Tab content box not found using div[@class='tabmenubox'] XPath");
-
- return new TabContentBox(tabContentBox);
- }
-
- public StyledElement getTab( String label ) throws EmbJoprTestException {
-
- DomElement element = (DomElement)client.getElement("tabmenu");
- String xPath = "ul/li/span[normalize-space(string())='"+label+"'] | ul/li/a[normalize-space(string())='"+label+"']";
- StyledElement tabContent = element.getFirstByXPath(xPath);
-
- if( null == tabContent )
- throw new EmbJoprTestException("Tab '"+label+" not found using XPath '"+xPath+"'");
-
- return tabContent;
-
- }
-
- public boolean isTabActive( String label ) throws IOException, EmbJoprTestException {
-
- StyledElement tabContent = getTab(label);
- return "span".equals( tabContent.getTagName() )
- && tabContent.getClassAttribute().contains("active");
- }
-
-
- public boolean isTabDisabled( String label ) throws EmbJoprTestException {
- StyledElement tabContent = getTab(label);
- return "span".equals( tabContent.getTagName() )
- && tabContent.getClassAttribute().contains("disabled");
- }
-
- public void clickTab( String label ) throws IOException, EmbJoprTestException {
-
- StyledElement tabContent = getTab(label);
-
- //if( !"a".equals( tabContent.getTagName() ) )
- //if( !( tabContent instanceof HtmlAnchor ) )
- // throw new AssertException("Tab is not an anchor: "+label);
-
- if( !( tabContent instanceof ClickableElement ) )
- throw new EmbJoprTestException("Tab element <"+tabContent.getTagName()+"> is not clickable: "+label);
-
- ((ClickableElement)tabContent).click();
-
- }
-
- }
-
-
- /**
- * Inner class for manipulation with tab content box.
- */
- class TabContentBox {
-
- private HtmlElement box;
- private URL validForURL;
- private String validForDate;
-
- public HtmlElement getElement() { return box; }
-
-
-
- public TabContentBox(HtmlElement box) {
- this.box = box;
-
- // TODO: Check whether the page changed;
- this.validForDate = client.getContentPage().getWebResponse().getResponseHeaderValue("Date");
- this.validForURL = client.getContentPage().getWebResponse().getUrl();
- }
-
-
- public void checkIfStillValid() throws ActionOutOfSyncException {
-
- String validForDate = client.getContentPage().getWebResponse().getResponseHeaderValue("Date");
- URL validForURL = client.getContentPage().getWebResponse().getUrl();
-
- if( !validForDate.equals(this.validForDate) ||
- !validForURL.equals(this.validForURL) )
- {
- throw new ActionOutOfSyncException(
- "This tab content box was created from another page and is not valid now.");
- }
- }
-
- public HtmlButtonInput getButtonByLabel( String label )
- throws HtmlElementNotFoundException, ActionOutOfSyncException {
-
- checkIfStillValid();
-
- HtmlButtonInput button = this.box.getFirstByXPath("//input[@value='"+label+"']");
- if( null == button )
- throw new HtmlElementNotFoundException("Button labelled '"+label+"' not found.");
-
- return button;
-
- }
-
- }
-
-
-
-}
15 years, 5 months
EMBJOPR SVN: r594 - trunk/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-07-27 21:02:37 -0400 (Mon, 27 Jul 2009)
New Revision: 594
Modified:
trunk/jsfunit/pom.xml
Log:
* Hibernate test stubs removed
Modified: trunk/jsfunit/pom.xml
===================================================================
--- trunk/jsfunit/pom.xml 2009-07-28 00:59:26 UTC (rev 593)
+++ trunk/jsfunit/pom.xml 2009-07-28 01:02:37 UTC (rev 594)
@@ -484,7 +484,7 @@
<include>**/as5/connectors/*Test.java</include>
<include>**/as5/sbm/*Test.java</include>
<include>**/as5/scripts/*Test.java</include>
- <include>**/as5/hbn/*Test.java</include>
+ <!--<include>**/as5/hbn/*Test.java</include>-->
<include>**/as5/jbcache/*Test.java</include>
<!--
15 years, 5 months
EMBJOPR SVN: r593 - in trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit: as5/jbcache and 1 other directory.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-07-27 20:59:26 -0400 (Mon, 27 Jul 2009)
New Revision: 593
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheInterceptorTest.java
Log:
* JBCache Interceptor test 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-28 00:53:07 UTC (rev 592)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-07-28 00:59:26 UTC (rev 593)
@@ -38,19 +38,19 @@
public enum DeployableTypes {
// Nav tree link label, EmbJopr display name, testdata/$dir, extension, suffix, mime type.
- EAR(AppConstants.NAV_EAR, "EAR", "ear", ".ear", null, "application/ear"),
- WAR(AppConstants.NAV_WAR, "WAR", "war", ".war", null, "application/war"),
- EJB2(AppConstants.NAV_EJB2, "EJB2 JAR", "ejb2", ".jar", null, "application/java-archive"),
- EJB3(AppConstants.NAV_EJB3, "EJB3 JAR", "ejb3", ".jar", null, "application/java-archive"),
- SAR(AppConstants.NAV_SAR, "SAR", "sar", ".sar", "-service.xml", "application/sar"),
- RAR(AppConstants.NAV_RAR, "RAR", "rar", ".rar", null, "application/rar"),
- EMB_RAR(AppConstants.NAV_EMB_RAR,"Embedded RAR", "", ".rar", null, "application/rar"),
- MC_BEAN(AppConstants.NAV_MC, "?", "mc", "", null, "application/java-archive"),
- EMB_WAR(AppConstants.NAV_EMB_WAR,"Embbedded WAR", "", ".war", null, "application/war"),
-
+ EAR(AppConstants.NAV_EAR, "EAR", "ear", ".ear", null, "application/ear"),
+ WAR(AppConstants.NAV_WAR, "WAR", "war", ".war", null, "application/war"),
+ EJB2(AppConstants.NAV_EJB2, "EJB2 JAR", "ejb2", ".jar", null, "application/java-archive"),
+ EJB3(AppConstants.NAV_EJB3, "EJB3 JAR", "ejb3", ".jar", null, "application/java-archive"),
+ SAR(AppConstants.NAV_SAR, "SAR", "sar", ".sar", "-service.xml", "application/sar"),
+ RAR(AppConstants.NAV_RAR, "RAR", "rar", ".rar", null, "application/rar"),
+ EMB_RAR(AppConstants.NAV_EMB_RAR, "Embedded RAR", "", ".rar", null, "application/rar"),
+ MC_BEAN(AppConstants.NAV_MC, "?", "mc", "", null, "application/java-archive"),
+ 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
- HBN(AppConstants.NAV_HBN, "Hibernate", null, null, null, null);
+ JBCACHE(AppConstants.NAV_JBCACHE, "JBoss Cache", "jbcache", null, null, null),
+ HBN(AppConstants.NAV_HBN, "Hibernate", "hbn", null, null, null);
static{
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-07-28 00:53:07 UTC (rev 592)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheInterceptorTest.java 2009-07-28 00:59:26 UTC (rev 593)
@@ -56,7 +56,6 @@
ejtt.deployment.undeployViaEmbJopr( DeployableTypes.EAR, JBCACHE_TEST_EAR );
-
}
@@ -71,6 +70,9 @@
if( isJBossConfigWithoutCache() ) return;
+ ejtt.deployment.deployViaEmbJopr( DeployableTypes.EAR, ejtt.getTestFilePath(this.APP_TYPE, JBCACHE_TEST_EAR));
+
+
final String BEAN_JNDI = "TestOperationBean/remote";
// Query the bean.
@@ -109,6 +111,8 @@
props.setProperty("Average Read Time", "0.0ms");
ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(props);
+ ejtt.deployment.undeployViaEmbJopr( DeployableTypes.EAR, JBCACHE_TEST_EAR );
+
}
15 years, 5 months
EMBJOPR SVN: r592 - in trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit: as5/app/ear and 3 other directories.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-07-27 20:53:07 -0400 (Mon, 27 Jul 2009)
New Revision: 592
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbJoprTestConstants.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/war/WarTest.java
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/util/EmbJoprTestToolkit.java
Log:
* Fixed NavTreeNode#expand() - was not refreshing underlying HTML element.
* Ear and War tests prepared for HTMLUnit 2.4+
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-27 21:33:27 UTC (rev 591)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbJoprTestConstants.java 2009-07-28 00:53:07 UTC (rev 592)
@@ -49,6 +49,10 @@
// Operations
public static final String OPERATION_OUTPUT_PROPERTY = "Output";
+
+ // Test files - EARs, JARs, WARs, etc...
+ public static final String JBCACHE_TEST_EAR = "JBossCacheTest-by-fdrabek.ear";
+
}// interface
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java 2009-07-27 21:33:27 UTC (rev 591)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java 2009-07-28 00:53:07 UTC (rev 592)
@@ -876,7 +876,7 @@
page = (HtmlPage) page.refresh();
// Get the counter number.
- Integer count1 = NumberUtils.createInteger(page.getBody().getHtmlElementById("count").getTextContent());
+ Integer count1 = NumberUtils.createInteger(( (HtmlElement)page.getBody().getHtmlElementById("count") ).getTextContent());
@@ -913,7 +913,7 @@
assertTrue(page.asText().contains("HELLO WORLD"));
// Get the counter number.
- Integer count2 = NumberUtils.createInteger(page.getBody().getHtmlElementById("count").getTextContent());
+ Integer count2 = NumberUtils.createInteger(( (HtmlElement)page.getBody().getHtmlElementById("count") ).getTextContent());
assertTrue( "Counter is reset upon app restart, thus should be lower after.", count1 > count2 );
@@ -971,7 +971,7 @@
page = (HtmlPage) page.refresh();
// Get the counter number.
- Integer count1 = NumberUtils.createInteger(page.getBody().getHtmlElementById("count").getTextContent());
+ Integer count1 = NumberUtils.createInteger(( (HtmlElement) page.getBody().getHtmlElementById("count") ).getTextContent());
@@ -995,7 +995,7 @@
assertTrue(page.asText().contains("HELLO WORLD"));
// Get the counter number.
- Integer count2 = NumberUtils.createInteger(page.getBody().getHtmlElementById("count").getTextContent());
+ Integer count2 = NumberUtils.createInteger(( (HtmlElement) page.getBody().getHtmlElementById("count") ).getTextContent());
assertTrue( "Counter is reset upon app restart, thus should be lower after.", count1 > count2 );
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/war/WarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/war/WarTest.java 2009-07-27 21:33:27 UTC (rev 591)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/war/WarTest.java 2009-07-28 00:53:07 UTC (rev 592)
@@ -1007,7 +1007,7 @@
page = (HtmlPage) page.refresh();
// Get the counter number.
- String count1text = page.getBody().getHtmlElementById("count").getTextContent();
+ String count1text = ( (HtmlElement) page.getBody().getHtmlElementById("count") ).getTextContent();
Integer count1 = NumberUtils.createInteger( count1text );
@@ -1045,7 +1045,7 @@
assertTrue(page.asText().contains("HELLO WORLD"));
// Get the counter number.
- String count2text = page.getBody().getHtmlElementById("count").getTextContent();
+ String count2text = ( (HtmlElement) page.getBody().getHtmlElementById("count") ).getTextContent();
Integer count2 = NumberUtils.createInteger( count2text );
assertTrue( "Counter is reset upon app restart, thus should be lower after. " +
@@ -1102,7 +1102,7 @@
page = (HtmlPage) page.refresh();
// Get the counter number.
- String count1text = page.getBody().getHtmlElementById("count").getTextContent();
+ String count1text = ( (HtmlElement) page.getBody().getHtmlElementById("count") ).getTextContent();
Integer count1 = NumberUtils.createInteger( count1text );
@@ -1126,7 +1126,7 @@
assertTrue(page.asText().contains("HELLO WORLD"));
// Get the counter number.
- String count2text = page.getBody().getHtmlElementById("count").getTextContent();
+ String count2text = ( (HtmlElement) page.getBody().getHtmlElementById("count") ).getTextContent();
Integer count2 = NumberUtils.createInteger( count2text );
assertTrue( "Counter is reset upon app restart, thus should be lower after. " +
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-07-27 21:33:27 UTC (rev 591)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheCacheTest.java 2009-07-28 00:53:07 UTC (rev 592)
@@ -1,5 +1,6 @@
package org.jboss.jopr.jsfunit.as5.jbcache;
+import com.gargoylesoftware.htmlunit.html.HtmlTable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -8,16 +9,19 @@
import java.util.Properties;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit;
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.DebugUtils;
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;
import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.ContentTableRow;
import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.NavTreeNode;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.NodeFinder;
/**
*
@@ -98,13 +102,21 @@
CollectionUtils.addAll(names, subnodesNames);
// Remove the names which we find.
- List<NavTreeNode> children = haparNode.getChildren();
+ haparNode = ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION);
+ List<NavTreeNode> children = haparNode.getChildren( /*new NodeFinder() {
+ public HtmlTable getNodeElem(EmbJoprTestToolkit ejtt) throws HtmlElementNotFoundException {
+ return (HtmlTable) ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION).getElement();
+ }
+ }*/);
+
+ haparNode = ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION);
for( NavTreeNode node : children ){
+ log.info("Found node: "+node.getName());
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, ", "));
+ throw new EmbJoprTestException("These cache nodes are not present: "+StringUtils.join(names, ", "), this);
}
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-07-27 21:33:27 UTC (rev 591)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheInterceptorTest.java 2009-07-28 00:53:07 UTC (rev 592)
@@ -23,6 +23,11 @@
public void testJBossCacheInterceptorSummary() throws IOException, EmbJoprTestException {
if( isJBossConfigWithoutCache() ) return;
+
+
+ ejtt.deployment.deployViaEmbJopr( DeployableTypes.EAR, ejtt.getTestFilePath(this.APP_TYPE, JBCACHE_TEST_EAR));
+
+
ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION).expand();
ejtt.navTree.getNodeByLabel(SUBNODE_INTERCEPTOR).click();
@@ -48,6 +53,10 @@
props.setProperty("Average Read Time", "0.0ms");
ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(props);
+
+ ejtt.deployment.undeployViaEmbJopr( DeployableTypes.EAR, JBCACHE_TEST_EAR );
+
+
}
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 21:33:27 UTC (rev 591)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-07-28 00:53:07 UTC (rev 592)
@@ -29,6 +29,10 @@
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.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.jboss.jopr.jsfunit.AppConstants;
@@ -85,6 +89,11 @@
private EmbjoprTestCase currentTest = null;
+
+
+
+
+
/**
* ProfileService references.
*/
@@ -121,6 +130,10 @@
return System.getProperty(AppConstants.SYSPROP_TESTDATA_DIR);
}
+ public String getTestFilePath( DeployableTypes location, String fileName ){
+ return this.getTestDataDir()+"/"+location.getDataDir()+"/"+fileName;
+ }
+
public String getTempDir() {
return System.getProperty(AppConstants.SYSPROP_TEMP_DIR);
}
@@ -180,9 +193,15 @@
}
+ /** Dumps the page to target directory as a HTML file. */
+ public void dumpPage( String fileName ) throws IOException {
+ DebugUtils.writeFile("target/"+fileName, this.client.getPageAsText());
+ }
+
+
/**
* Inner class to encapsulate navigation tree operations.
*
@@ -444,12 +463,36 @@
/**
* If the node is collapsed, expand it.
+ * Calls #expand( NodeFinder ) using a finder which looks for a node with the same name as this one.
+ *
* @returns true if the node already was expanded.
*/
- public boolean expand() throws EmbJoprTestException, IOException{
+ public boolean expand() throws EmbJoprTestException, IOException {
+ final String nodeName = this.getName();
+ return expand( new NodeFinder() {
+ public HtmlTable getNodeElem(EmbJoprTestToolkit ejtt) throws HtmlElementNotFoundException {
+ return (HtmlTable) ejtt.navTree.getNodeByLabel( nodeName ).getElement();
+ }
+ });
+ }
+
+ /**
+ * If the node is collapsed, expand it.
+ * Expanding a node causes AJAX call which renders old HTML element stale.
+ * Thus, upon expanding, element must be re-bound. That's what the NodeFinder is for.
+ *
+ * @returns true if the node already was expanded.
+ */
+ public boolean expand( NodeFinder finder ) throws EmbJoprTestException, IOException{
+
+ // null finder -> use default finder.
+ if( null == finder)
+ return expand();
+
boolean isExpanded = isExpanded();
if( !isExpanded ){
this.getArrowLink().click();
+ this.elem = finder.getNodeElem(selfEjtt);
}
return isExpanded;
}
@@ -503,11 +546,27 @@
private final String XPATH_CHILD_NODES = "./following-sibling::div[contains(@id, ':childs') and position()=1]/table";
public List<NavTreeNode> getChildren() throws EmbJoprTestException, IOException{
+ return getChildren(null);
+ }
+
+ public List<NavTreeNode> getChildren( NodeFinder finder ) throws EmbJoprTestException, IOException{
if( ! this.isExpandable() )
return Collections.EMPTY_LIST;
- this.expand();
+ this.expand( finder );
- List<NavTreeNode> childNodes = (List<NavTreeNode>) this.elem.getByXPath(XPATH_CHILD_NODES);
+ List<HtmlTable> tables = (List<HtmlTable>) this.elem.getByXPath(XPATH_CHILD_NODES);
+
+ /*List<NavTreeNode> childNodes = (List<NavTreeNode>) CollectionUtils.collect(tables, new Transformer() {
+ public Object transform(Object input) {
+ return new NavTreeNode( (HtmlTable)input );
+ }
+ });/**/
+
+ List<NavTreeNode> childNodes = new ArrayList<NavTreeNode>();
+ for (HtmlTable htmlTable : tables) {
+ childNodes.add( new NavTreeNode(htmlTable) );
+ }
+
return childNodes;
}
@@ -515,12 +574,15 @@
}// class NavTreeNode()
+ /** Interface to reload a nav tree node after reloading operation (including AJAX calls). */
+ public interface NodeFinder {
+ public HtmlTable getNodeElem( EmbJoprTestToolkit ejtt ) throws HtmlElementNotFoundException;
+ }
-
/**
* Inner class to encapsulate tab menu operations.
*/
15 years, 5 months
EMBJOPR SVN: r591 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-07-27 17:33:27 -0400 (Mon, 27 Jul 2009)
New Revision: 591
Added:
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
Removed:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTest.java
Log:
* JBossCacheTest split to testcases by subnode.
Copied: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheCacheTest.java (from rev 590, trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTest.java)
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheCacheTest.java (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheCacheTest.java 2009-07-27 21:33:27 UTC (rev 591)
@@ -0,0 +1,259 @@
+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;
+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.
+ */
+public class JBossCacheCacheTest extends JBossCacheTestBase {
+
+
+
+ /**
+ * Test the navigation to JBoss Cache nodes.
+ */
+ public void testJBossCacheParentNode() throws HtmlElementNotFoundException, IOException, EmbJoprTestException {
+ if( isJBossConfigWithoutCache() ) return;
+
+ 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 );
+
+ // 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();
+ 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( JBCACHE_HA_PARTITION.equals(name) )
+ haparPresent = true;
+ }
+ 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();
+
+ // 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));
+
+ }
+
+
+
+ /**
+ * 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(JBCACHE_HA_PARTITION).expand();
+ ejtt.navTree.getNodeByLabel(SUBNODE_CACHE).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", "Cache");
+ 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);
+
+
+ }
+
+
+
+ /**
+ * JBoss Cache Metrics tab.
+ */
+ public void testJBossCacheMetrics() throws HtmlElementNotFoundException, IOException, EmbJoprTestException {
+ if( isJBossConfigWithoutCache() ) return;
+
+ 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) );
+
+ 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 - 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(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) );
+
+
+ // 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.");
+
+ 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) );
+ }
+
+ }
+
+
+
+}// class
Added: 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 (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheInterceptorTest.java 2009-07-27 21:33:27 UTC (rev 591)
@@ -0,0 +1,113 @@
+package org.jboss.jopr.jsfunit.as5.jbcache;
+
+import java.io.IOException;
+import java.util.Properties;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.jboss.qa.jbcache.testear.*;
+import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
+
+/**
+ *
+ * @author Ondrej Zizka
+ *
+ * JBoss Cache is only present in 'all' JBoss AS profile.
+ */
+public class JBossCacheInterceptorTest extends JBossCacheTestBase {
+
+
+
+ /**
+ * 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);
+
+
+ /*
+ 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
Deleted: 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 20:40:38 UTC (rev 590)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTest.java 2009-07-27 21:33:27 UTC (rev 591)
@@ -1,383 +0,0 @@
-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;
-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.
- */
-public class JBossCacheTest extends ApplicationTestBaseAS5 {
-
-
- public final DeployableTypes APP_TYPE = DeployableTypes.JBCACHE;
-
- // Cache which is active by default.
- 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 )
- 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.
- */
- public void testJBossCacheParentNode() throws HtmlElementNotFoundException, IOException, EmbJoprTestException {
- if( isJBossConfigWithoutCache() ) return;
-
- 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 );
-
- // 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();
- 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( JBCACHE_HA_PARTITION.equals(name) )
- haparPresent = true;
- }
- 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();
-
- // 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));
-
- }
-
-
-
- /**
- * 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(JBCACHE_HA_PARTITION).expand();
- ejtt.navTree.getNodeByLabel(SUBNODE_CACHE).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", "Cache");
- 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);
-
-
- }
-
-
-
- /**
- * JBoss Cache Metrics tab.
- */
- public void testJBossCacheMetrics() throws HtmlElementNotFoundException, IOException, EmbJoprTestException {
- if( isJBossConfigWithoutCache() ) return;
-
- 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) );
-
- 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 - 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(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) );
-
-
- // 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.");
-
- 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);
-
-
- /*
- 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
Added: 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 (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheTestBase.java 2009-07-27 21:33:27 UTC (rev 591)
@@ -0,0 +1,51 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.jboss.jopr.jsfunit.as5.jbcache;
+
+import org.jboss.jopr.jsfunit.AppConstants.DeployableTypes;
+import org.jboss.jopr.jsfunit.ApplicationTestBaseAS5;
+
+/**
+ *
+ * @author Ondrej Zizka
+ */
+public class JBossCacheTestBase extends ApplicationTestBaseAS5 {
+
+ public final DeployableTypes APP_TYPE = DeployableTypes.JBCACHE;
+
+
+ // Cache which is active by default.
+ protected static final String JBCACHE_HA_PARTITION = "jboss.cache:config=ha-partition,service=Cache";
+ protected static final String JBCACHE_MVCC_ENTITY = "jboss.cache:config=mvcc-entity,service=Cache";
+ protected static final String JBCACHE_PESSIMISTIC_SHARED = "jboss.cache:config=pessimistic-shared,service=Cache";
+ protected static final String JBCACHE_TIMESTAMPS = "jboss.cache:config=timestamps-cache,service=Cache";
+
+
+ // Subnodes
+ protected static final String SUBNODE_CACHE = "Cache";
+ protected static final String SUBNODE_INTERCEPTOR = "Interceptor";
+ protected static final String SUBNODE_DATA_CONTAINER = "Data Container";
+ 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 boolean isJBossConfigWithoutCache(){
+ boolean isJBossConfigWithoutCache = ! ejtt.getJBossConfig().equals("all");
+ if( isJBossConfigWithoutCache )
+ 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;
+ }
+
+
+
+
+
+
+}// class
15 years, 5 months