Author: ozizka(a)redhat.com
Date: 2009-06-17 16:37:08 -0400 (Wed, 17 Jun 2009)
New Revision: 539
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/scripts/ScriptsTest.java
Log:
2 scripts tests added.
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-06-17
17:11:02 UTC (rev 538)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/scripts/ScriptsTest.java 2009-06-17
20:37:08 UTC (rev 539)
@@ -1,7 +1,11 @@
package org.jboss.jopr.jsfunit.as5.scripts;
import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
import com.gargoylesoftware.htmlunit.html.HtmlDivision;
+import com.gargoylesoftware.htmlunit.html.HtmlTable;
+import com.gargoylesoftware.htmlunit.html.HtmlTextArea;
+import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
import java.io.File;
import java.io.FileWriter;
import java.io.FilenameFilter;
@@ -13,13 +17,11 @@
import org.apache.commons.io.filefilter.SuffixFileFilter;
import org.jboss.jopr.jsfunit.ApplicationTestBaseAS5;
import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
+import org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException;
import org.jboss.jopr.jsfunit.util.ActiveConditionChecker;
import org.jboss.jopr.jsfunit.util.DescribedCondition;
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.util.file.FilenamePrefixFilter;
-import org.jboss.util.file.FilenameSuffixFilter;
/**
*
@@ -36,6 +38,7 @@
return new TestSuite(ScriptsTest.class);
}
+ final String EXECUTE_OP_NAME = "Execute Script";
/**
* Tests whether the scripts node exists and that all the scripts are listed.
@@ -122,11 +125,11 @@
// Create the script in JBOSS_HOME/bin/
String shFilePath = ejtt.getJBossHomeDir()+"/"+SCRIPT_FILE_NAME;
- final File file = new File(shFilePath);
+ final File scriptFile = new File(shFilePath);
try {
- if( file.exists() ){
+ if( scriptFile.exists() ){
log.warn(shFilePath+" already exists, thus is already visible in
EmbJopr.");
}
new FileWriter(shFilePath, false).append("echo 'Test
script.'").close();
@@ -153,15 +156,139 @@
}
finally {
// Delete the test script file if it exists.
- if( file.exists() )
- file.delete();
+ if( scriptFile.exists() )
+ scriptFile.delete();
}
}
+ /**
+ * Runs the classpath.sh script, without parameters.
+ */
+ public void testScriptsRunClasspathshTest() throws IOException, EmbJoprTestException {
+ final String SCRIPT_FILE_NAME = "classpath.sh";
+
+ try {
+ // Go to the Scripts node.
+ ejtt.navTree.getNodeByLabel(NAV_SCRIPTS).click();
+ // Go to the ClassPath script.
+ 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();
+ // Command Line Arguments - none
+ ejtt.tabMenu.getTabContentBox().getSubmitButtonByLabel("OK").click();
+ // Wait for the operation to succesfuly finish.
+ ejtt.operations.waitActivelyForOperationToFinish(EXECUTE_OP_NAME, 5000, 5);
+ assertTrue(EXECUTE_OP_NAME+" operation wasn't successful.",
ejtt.tabMenu.getTabContentBox().getOperationsHistoryTable().wasLastOperationSuccesful()
);
+
+ // Get the results table.
+ //client.getElement("historyDetailsPanel_body");
+ HtmlDivision resultsDiv = (HtmlDivision)
client.getElement("operationResults");
+ if( null == resultsDiv )
+ throw new HtmlElementNotFoundException("#operationResults - a div around a
results table.");
+
+ HtmlTable resultsTableElm =
resultsDiv.getFirstByXPath(".//table[@class='properties-table']");
+ if( null == resultsTableElm )
+ throw new
HtmlElementNotFoundException(".//table[@class='properties-table'] - a results
table.");
+ ContentTable resultsTable =
ejtt.getTabMenu().getTabContentBox().getTable(resultsTableElm);
+
+ // Process the results table.
+
+ // Exit Code
+ HtmlTextInput exitCodeInput = resultsTable.getFirstRowContainingText("Exit
Code").getCellByColumnName("Value").getFirstByXPath(".//input");
+ assertEquals("Exit Code should be 0", "0",
exitCodeInput.getTextContent().trim() );
+
+ String expectedOutputPart = "usage";
+ HtmlTextArea outputTA =
resultsTable.getFirstRowContainingText("Output").getCellByColumnName("Value").getFirstByXPath(".//textarea");
+ assertTrue("classpath.sh parameter-less run output should contain
'"+expectedOutputPart+"'",
outputTA.getText().toLowerCase().contains(expectedOutputPart));
+
+ }
+ finally {
+ }
+
+ }
+
+
+ /*
+ usage: classpath.sh [options] <classpath>
+
+ options:
+ -h, --help Print this help message.
+ -- Stop processing options.
+ -r, --relative Use relative paths.
+
+ classpath:
+ -c, --client Client classpath (client/*).
+ -s, --server Server classpath (lib/*).
+ -b, --both Both the client and server classpaths.
+ */
+
+
+
+ /**
+ * Runs the classpath.sh script, without parameters.
+ */
+ public void testScriptsRunClasspathshWithParamTest() throws IOException,
EmbJoprTestException {
+
+ final String SCRIPT_FILE_NAME = "classpath.sh";
+
+ try {
+ // Go to the Scripts node.
+ ejtt.navTree.getNodeByLabel(NAV_SCRIPTS).click();
+ // Go to the ClassPath script.
+ 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();
+
+ // Command Line Arguments: "-c"
+ ContentTableRow row =
ejtt.tabMenu.getTabContentBox().getFirstTable().getFirstRowContainingText("Command
Line Arguments");
+ assertNotNull("'Command Line Arguments' row not found.", row);
+ HtmlCheckBoxInput unsetCheckbox = row./*getCellByColumnName("Unset").*/
getElement().getFirstByXPath(".//input[@type='checkbox']");
+ unsetCheckbox.setChecked(false);
+ HtmlTextArea argsTA = row./*getCellByColumnName("Value").*/
getElement().getFirstByXPath(".//textarea"); //
[@ondblclick='commandLineArguments']
+ argsTA.setText("-c");
+
+ // Run.
+ ejtt.tabMenu.getTabContentBox().getSubmitButtonByLabel("OK").click();
+ // Wait for the operation to succesfuly finish.
+ ejtt.operations.waitActivelyForOperationToFinish(EXECUTE_OP_NAME, 5000, 5);
+ assertTrue(EXECUTE_OP_NAME+" operation wasn't successful.",
ejtt.tabMenu.getTabContentBox().getOperationsHistoryTable().wasLastOperationSuccesful()
);
+
+ // Get the results table.
+ //client.getElement("historyDetailsPanel_body");
+ HtmlDivision resultsDiv = (HtmlDivision)
client.getElement("operationResults");
+ if( null == resultsDiv )
+ throw new HtmlElementNotFoundException("#operationResults - a div around a
results table.");
+
+ HtmlTable resultsTableElm =
resultsDiv.getFirstByXPath(".//table[@class='properties-table']");
+ if( null == resultsTableElm )
+ throw new
HtmlElementNotFoundException(".//table[@class='properties-table'] - a results
table.");
+ ContentTable resultsTable =
ejtt.getTabMenu().getTabContentBox().getTable(resultsTableElm);
+
+ // Process the results table.
+
+ // Exit Code
+ HtmlTextInput exitCodeInput = resultsTable.getFirstRowContainingText("Exit
Code").getCellByColumnName("Value").getFirstByXPath(".//input");
+ assertEquals("Exit Code should be 0", "0",
exitCodeInput.getTextContent().trim() );
+
+ String expectedOutputPart = "/client";
+ HtmlTextArea outputTA =
resultsTable.getFirstRowContainingText("Output").getCellByColumnName("Value").getFirstByXPath(".//textarea");
+ assertTrue("classpath.sh parameter-less run output should contain
'"+expectedOutputPart+"'",
outputTA.getText().toLowerCase().contains(expectedOutputPart));
+
+ }
+ finally {
+ }
+
+
+ }
+
+
+
}// class
Show replies by date