Author: ozizka(a)redhat.com
Date: 2009-08-07 20:09:21 -0400 (Fri, 07 Aug 2009)
New Revision: 651
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.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/ejb/EjbTestBase.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/as5/scripts/ScriptsTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
Log:
* EAR test fixed
* JBossCacheInterceptorTest updated
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-08-07
01:28:29 UTC (rev 650)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-08-08
00:09:21 UTC (rev 651)
@@ -854,6 +854,13 @@
return true;
}
+ /**
+ * Returns true if the string looks like a double with unit, i.e. 123.45kg
+ */
+ public static boolean looksLikeDoubleWithUnit(String value) {
+ return value.matches("([0-9]+\\.[0-9]+)[a-zA-Z]{0,3}");
+ }
+
/**
* If both expected and actual string look like a double,
* returns normalized double (with a decimal dot);
@@ -877,16 +884,22 @@
public static String normalizeIfNumber( String val ){
if( null == val )
return null;
-
+
+ boolean isNumeric = val.matches("([0-9][0-9\\., ]+[0-9])[a-zA-Z]{0,3}");
+ if( !isNumeric )
+ return val;
+
+ // TODO: Normalize numbers with units (1.5m)
+
String val2 = val.replace(",", "");
// English notation - 1,322.51
- if( EmbjoprTestCase.looksLikeDouble(val2) )
+ if( EmbjoprTestCase.looksLikeDoubleWithUnit(val2) )
return val2;
// Still can be numbe: 1 358,84
val2 = val.replace(" ", "");
val2 = val.replace(" ", "").replace(',', '.');
- if( EmbjoprTestCase.looksLikeDouble(val2) )
+ if( EmbjoprTestCase.looksLikeDoubleWithUnit(val2) )
return val2;
return val;
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-08-07
01:28:29 UTC (rev 650)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java 2009-08-08
00:09:21 UTC (rev 651)
@@ -217,7 +217,7 @@
ejtt.getTabMenu().getTabContentBox().getFirstTable().getFirstLinkContaining(
DEPLOYABLE_NAME ).click();
ejtt.getTabMenu().clickContentTab();
ejtt.getTabMenu().getTabContentBox().getFirstFileInput().setValueAttribute(
earFilePath );
- ejtt.getTabMenu().getTabContentBox().getButtonByLabel("Update").click();
+ ejtt.getTabMenu().getTabContentBox().getSubmitButtonByLabel("Update").click();
// We should get an error message.
checkClientAndServerMessages("Failed to update", "Failed to
update", true);
@@ -727,7 +727,7 @@
// Click the Refresh button.
// Can this change to submit? Perhaps set an ID and use ejtt.getClickableById().
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Refresh").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Refresh").click();
// Check that we are still on the right tab.
assertTrue("Metrics tab is active",
ejtt.tabMenu.isTabActive("Metrics") );
@@ -900,7 +900,7 @@
ejtt.getTabMenu().clickControlTab();
// Click the Stop button.
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Stop").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Stop").click();
// Wait for the op to finish and check the final status.
ejtt.operations.waitActivelyForOperationToFinish("Stop", 1500, 5);
@@ -915,7 +915,7 @@
// Click the Start button.
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Start").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Start").click();
// Check the latest message.
ejtt.operations.waitActivelyForOperationToFinish("Start", 1500, 5);
@@ -995,7 +995,7 @@
ejtt.getTabMenu().clickControlTab();
// Click the Restart button.
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Restart").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Restart").click();
// Wait for the op to finish and check the final status.
ejtt.operations.waitActivelyForOperationToFinish("Restart", 1500, 5);
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java 2009-08-07
01:28:29 UTC (rev 650)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java 2009-08-08
00:09:21 UTC (rev 651)
@@ -366,7 +366,7 @@
ejtt.getTabMenu().clickControlTab();
// Click the Stop button.
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Stop").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Stop").click();
// Wait for the op to finish and check the final status.
ejtt.operations.waitActivelyForOperationToFinish("Stop", 1500, 5);
@@ -375,7 +375,7 @@
// Click the Start button.
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Start").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Start").click();
ejtt.operations.waitActivelyForOperationToFinish("Start", 1500, 5);
}
@@ -417,7 +417,7 @@
ejtt.getTabMenu().clickControlTab();
// Click the Restart button.
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Restart").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Restart").click();
// Wait for the op to finish and check the final status.
ejtt.operations.waitActivelyForOperationToFinish("Restart", 1500, 5);
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-08-07
01:28:29 UTC (rev 650)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/war/WarTest.java 2009-08-08
00:09:21 UTC (rev 651)
@@ -878,7 +878,7 @@
// Click the Refresh button.
// Can this change to submit? Perhaps set an ID and use ejtt.getClickableById().
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Refresh").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Refresh").click();
// Check that we are still on the right tab.
assertTrue("Metrics tab is active",
ejtt.tabMenu.isTabActive("Metrics") );
@@ -1016,7 +1016,7 @@
ejtt.getTabMenu().clickControlTab();
// Click the Stop button.
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Stop").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Stop").click();
// Check the latest message.
ejtt.operations.waitActivelyForOperationToFinish("Stop", 1500, 5);
@@ -1030,7 +1030,7 @@
// Click the Start button.
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Start").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Start").click();
// Wait for the op to finish and check the final status.
ejtt.operations.waitActivelyForOperationToFinish("Start", 1500, 5);
@@ -1111,7 +1111,7 @@
ejtt.getTabMenu().clickControlTab();
// Click the Restart button.
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Restart").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Restart").click();
// Wait for the op to finish and check the final status.
ejtt.operations.waitActivelyForOperationToFinish("Restart", 1500, 5);
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheCacheTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheCacheTest.java 2009-08-07
01:28:29 UTC (rev 650)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheCacheTest.java 2009-08-08
00:09:21 UTC (rev 651)
@@ -229,14 +229,14 @@
// 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().getButtonInputByLabel("Print cache details as
HTML.").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Print lock
information.").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Print lock info as
HTML.").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Print configuration as
plain text.").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Print configuration as
HTML.").click();
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Stop this
cache.").click();
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Start this
cache.").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Stop this
cache.").click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Start this
cache.").click();
// Now test the operations, one by one.
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheInterceptorTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheInterceptorTest.java 2009-08-07
01:28:29 UTC (rev 650)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jbcache/JBossCacheInterceptorTest.java 2009-08-08
00:09:21 UTC (rev 651)
@@ -269,7 +269,7 @@
ejtt.tabMenu.clickControlTab();
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Reset Statistics");
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Reset Statistics");
// Check that these metrics didn't stay at their previous values.
ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(LABEL_NUMERIC_METRICS).checkValues(propsSecond,
ValuesValidator.NOT_EQUAL);
@@ -362,7 +362,7 @@
ejtt.navTree.getNodeByLabel(JBCACHE_HA_PARTITION).expand();
ejtt.navTree.getNodeByLabel(SUBNODE_INTERCEPTOR).click();
ejtt.tabMenu.clickControlTab();
- ejtt.tabMenu.getTabContentBox().getButtonByLabel("Reset Statistics");
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel("Reset Statistics");
}
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/scripts/ScriptsTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/scripts/ScriptsTest.java 2009-08-07
01:28:29 UTC (rev 650)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/scripts/ScriptsTest.java 2009-08-08
00:09:21 UTC (rev 651)
@@ -185,7 +185,7 @@
ejtt.tabMenu.getTabContentBox().getFirstTable().getFirstRowContainingLink(SCRIPT_FILE_NAME).getLinkByLabel(SCRIPT_FILE_NAME).click();
ejtt.tabMenu.clickControlTab();
// Execute the script.
- ejtt.tabMenu.getTabContentBox().getButtonByLabel(EXECUTE_OP_NAME).click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel(EXECUTE_OP_NAME).click();
// Command Line Arguments - none
//ejtt.tabMenu.getTabContentBox().getSubmitButtonByLabel("OK").click();
@@ -271,7 +271,7 @@
ejtt.tabMenu.getTabContentBox().getFirstTable().getFirstRowContainingLink(SCRIPT_FILE_NAME).getLinkByLabel(SCRIPT_FILE_NAME).click();
ejtt.tabMenu.clickControlTab();
// Execute the script.
- ejtt.tabMenu.getTabContentBox().getButtonByLabel(EXECUTE_OP_NAME).click();
+ ejtt.tabMenu.getTabContentBox().getButtonInputByLabel(EXECUTE_OP_NAME).click();
// Command Line Arguments: "-c"
// No tab content box in this block.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-08-07
01:28:29 UTC (rev 650)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-08-08
00:09:21 UTC (rev 651)
@@ -940,19 +940,42 @@
/**
* Finds first button with given label inside this tab box.
*/
- public HtmlButtonInput getButtonByLabel( String label )
+ public ClickableElement getButtonByLabel( String label )
throws HtmlElementNotFoundException, ActionOutOfSyncException
{
checkIfStillValid();
- HtmlButtonInput button =
this.element.getFirstByXPath(".//input[normalize-space(@value)='"+label+"']");
+ ClickableElement button =
this.element.getFirstByXPath(".//input[normalize-space(@value)='"+label+"']");
if( null == button )
throw new HtmlElementNotFoundException("Button labelled
'"+label+"' not found.", currentTest);
+
+ if( ! (button instanceof HtmlButton) || ! (button instanceof HtmlButtonInput) || !
(button instanceof HtmlSubmitInput) )
+ throw new HtmlElementNotFoundException("Input with value
'"+label+"' is not a button input nor submit input.",
currentTest);
+
return button;
}
+
/**
* Finds first button with given label inside this tab box.
*/
+ public HtmlButtonInput getButtonInputByLabel( String label )
+ throws HtmlElementNotFoundException, ActionOutOfSyncException
+ {
+ checkIfStillValid();
+ HtmlInput button =
this.element.getFirstByXPath(".//input[normalize-space(@value)='"+label+"']");
+ if( null == button )
+ throw new HtmlElementNotFoundException("Button labelled
'"+label+"' not found.", currentTest);
+
+ if( !(button instanceof HtmlButtonInput) )
+ throw new HtmlElementNotFoundException("Input with value
'"+label+"' is not a button input nor submit input.",
currentTest);
+
+ return (HtmlButtonInput) button;
+ }
+
+
+ /**
+ * Finds first button with given label inside this tab box.
+ */
public HtmlSubmitInput getSubmitButtonByLabel( String label )
throws HtmlElementNotFoundException, ActionOutOfSyncException
{
@@ -2073,7 +2096,7 @@
* @param expectedResult
*/
public Properties performOperation( String operationName ) throws EmbJoprTestException,
IOException {
- getEjtt().tabMenu.getTabContentBox().getButtonByLabel(operationName).click();
+ getEjtt().tabMenu.getTabContentBox().getButtonInputByLabel(operationName).click();
getEjtt().operations.waitActivelyForOperationToFinish(operationName, 500, 5);
if( !
getEjtt().tabMenu.getTabContentBox().getOperationsHistoryTable().wasLastOperationSuccesful()
){
OperationStatusType status =
getEjtt().tabMenu.getTabContentBox().getOperationsHistoryTable().getLastOperationStatus();