JBoss Rich Faces SVN: r16323 - branches/sandbox.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-01-18 11:45:48 -0500 (Mon, 18 Jan 2010)
New Revision: 16323
Removed:
branches/sandbox/rf-demo-ftest-iexplore/
Log:
Deleting branch of functional-test for richfaces-demo for purposes of Internet Explorer expansive changes to tests
14 years, 3 months
JBoss Rich Faces SVN: r16322 - in branches/community/3.3.X/samples/richfaces-demo/functional-test: src/test/java/org/jboss/richfaces/integrationTest and 69 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-01-18 11:36:28 -0500 (Mon, 18 Jan 2010)
New Revision: 16322
Added:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/AbstractDataIterationTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/AbstractSeleniumRichfacesTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/SeleniumLoggingTestListener.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/actionParameter/ActionParameterTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxForm/AjaxFormTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxRegion/AjaxRegionTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxSupport/AjaxSupportTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AbstractAjaxValidatorTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/beanValidator/BeanValidatorTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/calendar/CalendarStylingTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/calendar/CalendarTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/calendar/OrganizerTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/colorPicker/ColorPickerTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/columns/ColumnsTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/comboBox/ComboBoxTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/commandButton/CommandButtonTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/commandLink/CommandLinkTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/contextMenu/ContextMenuImageTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/contextMenu/ContextMenuTableTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataFilterSlider/DataFilterSliderTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataGrid/DataGridTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataList/DataListTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataScroller/DataScrollerTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/DataTableTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/EditTableWithModalPanelTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/ExtendedDataModelTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/ModifiableDataModelTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dragSupport/DragSupportTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dropDownMenu/HorizontalMenuTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/editor/AdvancedEditorTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/editor/SimpleEditorTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/extendedDataTable/AbstractExtendedDataTableTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/extendedDataTable/FilteringTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/extendedDataTable/GroupingTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/fileUpload/FileUploadTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorAfterModelUpdateTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/include/IncludeTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inplaceInput/InplaceInputTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inplaceSelect/InplaceSelectTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inputNumberSlider/InputNumberSliderTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/jsFunction/JSFunctionTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/keepAlive/KeepAliveTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/listShuttle/ListShuttleTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/log/LogTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/mediaOutput/MediaOutputTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/modalPanel/ModalPanelTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/orderingList/OrderingListTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/outputPanel/OutputPanelTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/paint2d/Paint2DTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panel/PanelCustomizationTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panel/PanelTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panelBar/PanelBarTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panelMenu/PanelMenuTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/pickList/PickListTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/poll/PollTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/progressBar/ProgressBarTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/push/PushTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/queue/QueueSettingsTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/queue/QueueTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/repeat/RepeatTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/script/ScriptTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/separator/SeparatorTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/simpleTogglePanel/SimpleTogglePanelTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/spacer/SpacerTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/spinner/SpinnerTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/stateManager/StateManagerTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/status/StatusTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/style/StyleTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/suggestionBox/SuggestionBoxTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tabPanel/TabPanelTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tableFiltering/TableFilteringTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tableSorting/TableSortingTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/togglePanel/TogglePanelTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/toolBar/ToolBarTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tooltip/TooltipDataTableTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tooltip/TooltipTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeNodesAdaptorTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/comboBox/messages.properties
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/dataTable/messages-DataTableTestCase.properties
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/graphValidator/locators.properties
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/panelMenu/locators.properties
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/suggestionBox/locators.properties
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/tabPanel/locators.properties
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/testng.xml
Log:
- Merge IE tests branch back to 3.3.X branch (RFPL-334, RFPL-69)
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml 2010-01-18 16:36:28 UTC (rev 16322)
@@ -549,7 +549,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.8</version>
+ <version>5.9</version>
<scope>test</scope>
<classifier>jdk15</classifier>
</dependency>
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/AbstractDataIterationTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/AbstractDataIterationTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/AbstractDataIterationTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -30,7 +30,7 @@
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class AbstractDataIterationTestCase extends AbstractSeleniumRichfacesTestCase {
+public abstract class AbstractDataIterationTestCase extends AbstractSeleniumRichfacesTestCase {
protected final String LOC_TABLE_COMMON = getLoc("data-table-common--table");
protected final String LOC_BUTTON_FIRST_PAGE = getLoc("data-scroller--button--first-page");
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/AbstractSeleniumRichfacesTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/AbstractSeleniumRichfacesTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/AbstractSeleniumRichfacesTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -29,21 +29,22 @@
import java.util.Properties;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
import org.jboss.test.selenium.AbstractSeleniumTestCase;
import org.jboss.test.selenium.waiting.Condition;
import org.jboss.test.selenium.waiting.Wait;
import org.jboss.test.selenium.waiting.Wait.Waiting;
import org.testng.ITestContext;
+import org.testng.SkipException;
import org.testng.TestRunner;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
-import com.thoughtworks.selenium.DefaultSelenium;
-
/**
*
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>, <a
@@ -52,7 +53,7 @@
*
*/
-public class AbstractSeleniumRichfacesTestCase extends AbstractSeleniumTestCase {
+public abstract class AbstractSeleniumRichfacesTestCase extends AbstractSeleniumTestCase {
/**
* context root can be used to obtaining full URL paths, is set to actual
@@ -72,6 +73,7 @@
protected String mavenProjectBuildDirectory; // usually ${project}/target
protected String mavenResourcesDir; // usually ${project}/target/test-classes
protected boolean seleniumDebug; // if used specified debug mode of selenium testing
+ protected String browser;
/**
* predefined waitings to use in inheritors
@@ -96,6 +98,19 @@
runner.addTestListener(loggingTestListener);
}
+ @BeforeClass
+ @Parameters( { "context.root", "context.path", "browser", "selenium.host", "selenium.port", "selenium.debug",
+ "selenium.maximize", "maven.resources.dir", "maven.project.build.directory" })
+ public void initializeParameters(String contextRoot, String contextPath, String browser, String seleniumDebug,
+ String mavenResourcesDir, String mavenProjectBuildDirectory) {
+ this.contextRoot = contextRoot;
+ this.contextPath = contextPath;
+ this.mavenResourcesDir = mavenResourcesDir;
+ this.mavenProjectBuildDirectory = mavenProjectBuildDirectory;
+ this.seleniumDebug = Boolean.valueOf(seleniumDebug);
+ this.browser = browser;
+ }
+
/**
* Initializes context before each class run.
*
@@ -111,19 +126,10 @@
* @param seleniumPort
* specifies on which port should selenium server run
*/
- @BeforeClass
- @Parameters( { "context.root", "context.path", "browser", "selenium.host", "selenium.port", "selenium.debug",
- "selenium.maximize", "maven.resources.dir", "maven.project.build.directory" })
- public void initializeContext(String contextRoot, String contextPath, String browser, String seleniumHost,
- String seleniumPort, String seleniumDebug, String seleniumMaximize, String mavenResourcesDir,
- String mavenProjectBuildDirectory) {
- this.contextRoot = contextRoot;
- this.contextPath = contextPath;
- this.mavenResourcesDir = mavenResourcesDir;
- this.mavenProjectBuildDirectory = mavenProjectBuildDirectory;
- this.seleniumDebug = Boolean.valueOf(seleniumDebug);
-
- selenium = new DefaultSelenium(seleniumHost, Integer.valueOf(seleniumPort), browser, contextRoot);
+ @BeforeClass(dependsOnMethods = { "initializeParameters", "isTestBrowserEnabled" })
+ @Parameters( { "selenium.host", "selenium.port", "selenium.maximize" })
+ public void initializeBrowser(String seleniumHost, String seleniumPort, String seleniumMaximize) {
+ selenium = RichfacesSelenium.getInstance(seleniumHost, Integer.valueOf(seleniumPort), browser, contextRoot);
selenium.start();
allowInitialXpath();
loadCustomLocationStrategies();
@@ -164,14 +170,58 @@
* Finalize context after each class run.
*/
@AfterClass
- public void finalizeContext() {
+ public void finalizeBrowser() {
loggingTestListener.setSelenium(null);
selenium.close();
selenium.stop();
selenium = null;
- contextPath = null;
}
+ @Parameters( { "internet-explorer-enabled", "firefox-enabled" })
+ @BeforeClass(dependsOnMethods="initializeParameters")
+ public void isTestBrowserEnabled(@Optional("true") String internetExplorerEnabled, @Optional("true") String firefoxEnabled) {
+ boolean isTestBrowserEnabled = false;
+
+ if (Boolean.valueOf(internetExplorerEnabled) && browserIsInternetExplorer()) {
+ isTestBrowserEnabled = true;
+ }
+
+ if (Boolean.valueOf(firefoxEnabled) && browserIsFirefox()) {
+ isTestBrowserEnabled = true;
+ }
+
+ if (!isTestBrowserEnabled) {
+ throw new SkipException("The test isn't enabled for current browser");
+ }
+ }
+
+ @BeforeMethod(alwaysRun = true)
+ public void callLoadPage() {
+ loadPage();
+ }
+
+ protected abstract void loadPage();
+
+ private final String[] INTERNET_EXPLORER_PREFIXES = new String[] { "*iexplore", "*piiexplore", "*iehta" };
+ private final String[] FIREFOX_PREFIXES = new String[] { "*firefox", "*pifirefox", "*chrome" };
+
+ public boolean browserIsInternetExplorer() {
+ return containsBrowserOneOfPrefixes(browser, INTERNET_EXPLORER_PREFIXES);
+ }
+
+ public boolean browserIsFirefox() {
+ return containsBrowserOneOfPrefixes(browser, FIREFOX_PREFIXES);
+ }
+
+ private boolean containsBrowserOneOfPrefixes(String browser, String[] prefixes) {
+ for (String prefix : prefixes) {
+ if (StringUtils.defaultString(browser).startsWith(prefix)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Default implementation of obtaining properties for each class.
*
@@ -181,7 +231,7 @@
protected Properties getLocatorsProperties() {
return getNamedPropertiesForClass(this.getClass(), "locators");
}
-
+
/**
* Default implementation of obtaining properties for each class.
*
@@ -254,37 +304,37 @@
* name of component given from components' menu on the left of
* RF Live Demo application
*/
- protected void openComponent(final String componentName) {
+ protected void openComponent(final String componentName) {
final String LOC_MENU_ITEM = format("jquery=table.left_menu td.text a > span:textEquals('{0}')", componentName);
// TODO needs to open clean page, see {@link
- // https://jira.jboss.org/jira/browse/RF-7640}
- selenium.getEval("selenium.doDeleteAllVisibleCookies()");
+ // https://jira.jboss.org/jira/browse/RF-7640}
+ selenium.getEval("selenium.doDeleteAllVisibleCookies()");
- // open context path of application
+ // open context path of application
selenium.open(contextPath);
- // wait for new page is opened
- selenium.waitForPageToLoad("5000");
+ // wait for new page is opened
+ selenium.waitForPageToLoad("5000");
- Wait.until(new Condition() {
- public boolean isTrue() {
- return selenium.isElementPresent(LOC_MENU_ITEM);
- }
- });
-
- // click the menu item
- selenium.click(LOC_MENU_ITEM);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return selenium.isElementPresent(LOC_MENU_ITEM);
+ }
+ });
- // wait for component's page opened
- waitModelUpdate.until(new Condition() {
- public boolean isTrue() {
- return isComponentPageActive(componentName);
- }
- });
- }
+ // click the menu item
+ selenium.click(LOC_MENU_ITEM);
+ // wait for component's page opened
+ waitModelUpdate.until(new Condition() {
+ public boolean isTrue() {
+ return isComponentPageActive(componentName);
+ }
+ });
+ }
+
private boolean isComponentPageActive(String componentName) {
final String LOC_OUTPUT_COMPONENT_NAME = "jquery=body table.left_menu *.panel_documents strong";
return componentName.equals(getTextOrNull(LOC_OUTPUT_COMPONENT_NAME));
Copied: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java (from rev 16320, branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java)
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java (rev 0)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -0,0 +1,88 @@
+package org.jboss.richfaces.integrationTest;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.jboss.test.selenium.waiting.Retrieve;
+import org.jboss.test.selenium.waiting.Wait;
+
+import com.thoughtworks.selenium.CommandProcessor;
+import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.HttpCommandProcessor;
+import com.thoughtworks.selenium.SeleniumException;
+
+public class RichfacesSelenium extends DefaultSelenium {
+
+ public RichfacesSelenium(CommandProcessor processor) {
+ super(processor);
+ }
+
+ public static RichfacesSelenium getInstance(String serverHost, int serverPort, String browserStartCommand,
+ String browserURL) {
+ return new RichfacesSelenium(new RichfacesCommandProcessor(serverHost, serverPort, browserStartCommand,
+ browserURL));
+ }
+
+ public static class RichfacesCommandProcessor extends HttpCommandProcessor {
+ public RichfacesCommandProcessor(String serverHost, int serverPort, String browserStartCommand,
+ String browserURL) {
+ super(serverHost, serverPort, browserStartCommand, browserURL);
+ }
+
+ private abstract class AjaxCommand<T> {
+ public abstract T command();
+ }
+
+ private static String[] PERMISSION_DENIED = new String[] {
+ "ERROR: Threw an exception: Error executing strategy function jquery: Permission denied",
+ "ERROR: Threw an exception: Permission denied",
+ "ERROR: Threw an exception: Object doesn't support this property or method",
+ "ERROR: Command execution failure. Please search the forum at http://clearspace.openqa.org for error details from the log window. The error message is: Permission denied",
+ "ERROR: Threw an exception: null property value" };
+
+ private <T> T doAjax(final AjaxCommand<T> ajaxCommand) {
+ final AssertionError fail = new AssertionError("Fails with Permission denied when trying to execute jQuery");
+
+ final T start = null;
+ return Wait.noDelay().timeout(Wait.DEFAULT_TIMEOUT).interval(1000).failWith(fail).waitForChangeAndReturn(start,
+ new Retrieve<T>() {
+ boolean exceptionLogged = false;
+
+ public T retrieve() {
+ try {
+ return ajaxCommand.command();
+ } catch (SeleniumException e) {
+ final String message = StringUtils.defaultString(e.getMessage());
+ if (ArrayUtils.contains(PERMISSION_DENIED, message)) {
+ System.err.println(message);
+ if (!exceptionLogged) {
+ exceptionLogged = true;
+ System.err.println(ajaxCommand);
+ e.printStackTrace();
+ } else {
+ }
+ return null;
+ }
+
+ throw e;
+ }
+ }
+ });
+ }
+
+ @Override
+ public String doCommand(final String commandName, final String[] args) {
+ return doAjax(new AjaxCommand<String>() {
+ @Override
+ public String command() {
+ return RichfacesCommandProcessor.super.doCommand(commandName, args);
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("commandName", commandName).append("args", args).toString();
+ }
+ });
+ }
+ }
+}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/SeleniumLoggingTestListener.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/SeleniumLoggingTestListener.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/SeleniumLoggingTestListener.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -97,7 +97,12 @@
if (selenium != null) {
String eval = String.format("/*\n%s\n%s\n%s\n*/", line, message, line);
- selenium.getEval(eval);
+ try {
+ selenium.selectFrame("relative=top");
+ selenium.getEval(eval);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/actionParameter/ActionParameterTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/actionParameter/ActionParameterTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/actionParameter/ActionParameterTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -137,9 +137,7 @@
/**
* Loads a specific component's page
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Action Parameter");
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxForm/AjaxFormTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxForm/AjaxFormTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxForm/AjaxFormTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -100,9 +100,7 @@
/**
* Opens specific component's page
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Ajax Form");
scrollIntoView(LOC_LEGEND_HEADER, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxRegion/AjaxRegionTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxRegion/AjaxRegionTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxRegion/AjaxRegionTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -223,9 +223,7 @@
/**
* Opens specific component's page
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Ajax Region");
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxSupport/AjaxSupportTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxSupport/AjaxSupportTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxSupport/AjaxSupportTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -81,9 +81,7 @@
waitForTextEquals(LOC_INPUT_TEXT, "");
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Ajax Support");
scrollIntoView(LOC_INPUT_TEXT, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AbstractAjaxValidatorTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AbstractAjaxValidatorTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/ajaxValidator/AbstractAjaxValidatorTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -36,7 +36,6 @@
/**
* Opens specified component's page before each test method
*/
- @BeforeMethod
protected void loadPage() {
openComponent("Ajax Validator");
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/beanValidator/BeanValidatorTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/beanValidator/BeanValidatorTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/beanValidator/BeanValidatorTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -227,9 +227,7 @@
return format(LOC_VALIDATION_MESSAGE_RELATIVE, locator);
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Bean Validator");
scrollIntoView(LOC_FIELDSET_HEADER, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/calendar/CalendarStylingTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/calendar/CalendarStylingTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/calendar/CalendarStylingTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -87,9 +87,7 @@
/**
* Loads the page containing the calendar component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Calendar");
openTab("Client Side Disable/Styling");
scrollIntoView(LOC_STYLING_FIELDSET, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/calendar/CalendarTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/calendar/CalendarTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/calendar/CalendarTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -360,9 +360,7 @@
/**
* Loads the page containing the calendar component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Calendar");
scrollIntoView(LOC_CALENDAR_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/calendar/OrganizerTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/calendar/OrganizerTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/calendar/OrganizerTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -270,9 +270,7 @@
/**
* Loads the page containing the calendar component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Calendar");
openTab("Organizer Creation");
scrollIntoView(LOC_FIELDSET, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/colorPicker/ColorPickerTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/colorPicker/ColorPickerTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/colorPicker/ColorPickerTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -39,6 +39,8 @@
import javax.imageio.ImageIO;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
+import static org.jboss.test.selenium.utils.ColorUtils.convertToAWTColor;
+import org.jboss.test.selenium.utils.URLUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -128,22 +130,16 @@
@Test
public void testInitialState() {
// get color from the input field
- Color inputColor = createColor(selenium.getValue(LOC_COLOR_INPUT).substring(1));
+ Color inputColor = convertToAWTColor(selenium.getValue(LOC_COLOR_INPUT));
Map<Color, Integer> histogram = getHistogram();
assertTrue(histogram.containsKey(inputColor),
"Image should have the same color as the one defined in input field.");
// get color of the button
- String attr = getStyle(LOC_COLOR_BUTTON, "background-color").replace("rgb(", "").replace(")", "");
+ Color colorButton = convertToAWTColor(getStyle(LOC_COLOR_BUTTON, "background-color"));
- int[] values = new int[3];
- for (int i = 0; i < 3; i++) {
- values[i] = Integer.parseInt(attr.split(",")[i].trim());
- }
-
- assertTrue(histogram.containsKey(new Color(values[0], values[1], values[2])),
- "Image should have the same color as the button.");
+ assertTrue(histogram.containsKey(colorButton), "Image should have the same color as the button.");
}
/**
@@ -158,7 +154,7 @@
waitFor(1500);
Map<Color, Integer> histogram = getHistogram();
- Color inputColor = createColor(selenium.getValue(LOC_COLOR_INPUT).substring(1));
+ Color inputColor = convertToAWTColor(selenium.getValue(LOC_COLOR_INPUT));
assertTrue(histogram.containsKey(inputColor),
"Image should have the same color as the one defined in input field.");
@@ -358,7 +354,7 @@
*/
@Test
public void testCancelButton() {
- Color original = createColor(selenium.getValue(LOC_COLOR_INPUT).substring(1));
+ Color original = convertToAWTColor(selenium.getValue(LOC_COLOR_INPUT));
selenium.click(LOC_COLOR_BUTTON);
selenium.type(LOC_RED_VALUE, "100");
@@ -366,7 +362,7 @@
selenium.type(LOC_BLUE_VALUE, "100");
selenium.click(LOC_CANCEL_BUTTON);
- Color newColor = createColor(selenium.getValue(LOC_COLOR_INPUT).substring(1));
+ Color newColor = convertToAWTColor(selenium.getValue(LOC_COLOR_INPUT));
assertEquals(newColor, original, "Color in input should not change after clicking on \"Cancel\"");
Map<Color, Integer> histogram = getHistogram();
@@ -444,30 +440,18 @@
*/
@Test
public void testLeftColorBox() {
- String attr = getStyle(LOC_CURRENT_COLOR_BOX, "background-color").replace("rgb(", "").replace(")", "");
+ Color leftBoxColor = convertToAWTColor(getStyle(LOC_CURRENT_COLOR_BOX, "background-color"));
+ Color expectedColor = convertToAWTColor("#" + selenium.getValue(LOC_HEX_COLOR));
- int red = Integer.parseInt(attr.split(",")[0].trim());
- int green = Integer.parseInt(attr.split(",")[1].trim());
- int blue = Integer.parseInt(attr.split(",")[2].trim());
-
- Color leftBoxColor = new Color(red, green, blue);
- Color expectedColor = createColor(selenium.getValue(LOC_HEX_COLOR));
-
assertEquals(leftBoxColor, expectedColor, "At the beginning box should be of color from input field.");
selenium.type(LOC_RED_VALUE, "100");
selenium.type(LOC_GREEN_VALUE, "100");
selenium.type(LOC_BLUE_VALUE, "100");
- attr = getStyle(LOC_CURRENT_COLOR_BOX, "background-color").replace("rgb(", "").replace(")", "");
+ leftBoxColor = convertToAWTColor(getStyle(LOC_CURRENT_COLOR_BOX, "background-color"));
+ expectedColor = convertToAWTColor("#" + selenium.getValue(LOC_HEX_COLOR));
- red = Integer.parseInt(attr.split(",")[0].trim());
- green = Integer.parseInt(attr.split(",")[1].trim());
- blue = Integer.parseInt(attr.split(",")[2].trim());
-
- leftBoxColor = new Color(red, green, blue);
- expectedColor = createColor(selenium.getValue(LOC_HEX_COLOR));
-
assertEquals(leftBoxColor, expectedColor, "Color of the box should change afted a color was chosen.");
}
@@ -477,30 +461,18 @@
*/
@Test
public void testRightColorBox() {
- String attr = getStyle(LOC_ORIGINAL_COLOR_BOX, "background-color").replace("rgb(", "").replace(")", "");
+ Color rightBoxColor = convertToAWTColor(getStyle(LOC_ORIGINAL_COLOR_BOX, "background-color"));
+ Color expectedColor = convertToAWTColor("#" + selenium.getValue(LOC_HEX_COLOR));
- int red = Integer.parseInt(attr.split(",")[0].trim());
- int green = Integer.parseInt(attr.split(",")[1].trim());
- int blue = Integer.parseInt(attr.split(",")[2].trim());
-
- Color rightBoxColor = new Color(red, green, blue);
- Color expectedColor = createColor(selenium.getValue(LOC_HEX_COLOR));
-
assertEquals(rightBoxColor, expectedColor, "At the beginning box should be of color from input field.");
selenium.type(LOC_RED_VALUE, "100");
selenium.type(LOC_GREEN_VALUE, "100");
selenium.type(LOC_BLUE_VALUE, "100");
- attr = getStyle(LOC_ORIGINAL_COLOR_BOX, "background-color").replace("rgb(", "").replace(")", "");
+ rightBoxColor = convertToAWTColor(getStyle(LOC_ORIGINAL_COLOR_BOX, "background-color"));
+ expectedColor = convertToAWTColor("#" + selenium.getValue(LOC_HEX_COLOR));
- red = Integer.parseInt(attr.split(",")[0].trim());
- green = Integer.parseInt(attr.split(",")[1].trim());
- blue = Integer.parseInt(attr.split(",")[2].trim());
-
- rightBoxColor = new Color(red, green, blue);
- expectedColor = createColor(selenium.getValue(LOC_HEX_COLOR));
-
assertNotSame(rightBoxColor, expectedColor, "Color of the box should change afted a color was chosen.");
}
@@ -527,10 +499,15 @@
* that color
*/
private Map<Color, Integer> getHistogram() {
- String url = selenium.getAttribute(LOC_IMAGE + "@src");
- // the index of first '/' not counting http://
- int index = selenium.getLocation().indexOf('/', 7);
- url = selenium.getLocation().substring(0, index) + url;
+ final String src = selenium.getAttribute(LOC_IMAGE + "@src");
+ final String location = selenium.getLocation();
+ String url = null;
+ try {
+ url = URLUtils.buildUrl(location, src);
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ fail(format("Could not build an URL from location '{0}' and src '{1}'", location, src));
+ }
BufferedImage image = null;
try {
@@ -571,32 +548,9 @@
}
/**
- * Creates a Color object from the string. The string has to contain
- * hexadecimal representation of an RGB color without leading hash
- * character, e.g. ffffff, 0ab3c4.
- *
- * @param color
- * hexadecimal representation of an RGB color
- * @return a Color object
- */
- private Color createColor(String color) {
- if (color.length() != 6) {
- throw new IllegalArgumentException("color");
- }
-
- int red = Integer.parseInt(color.substring(0, 2), 16);
- int green = Integer.parseInt(color.substring(2, 4), 16);
- int blue = Integer.parseInt(color.substring(4, 6), 16);
-
- return new Color(red, green, blue);
- }
-
- /**
* Loads the page containing the color picker component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Color Picker");
scrollIntoView(LOC_COMPONENT_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/columns/ColumnsTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/columns/ColumnsTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/columns/ColumnsTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -149,9 +149,7 @@
});
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Columns");
scrollIntoView(LOC_TABLE, true);
selenium.allowNativeXpath("true");
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/comboBox/ComboBoxTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/comboBox/ComboBoxTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/comboBox/ComboBoxTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -27,6 +27,7 @@
import static org.testng.Assert.assertEqualsNoOrder;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
+import org.jboss.test.selenium.dom.Event;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -105,32 +106,39 @@
selenium.click(LOC_FIRST_COMBO_BUTTON);
waitForElement(format(LOC_FIRST_COMBO_SUGGESTIONS, 0));
int count = getJQueryCount(format(LOC_FIRST_COMBO_SUGGESTIONS,-1));
- assertEquals(count, MSG_SUGGESTIONS_FIRST_COMBO_COUNT_1, "Number of suggestions after after clicking on button.");
+ assertEquals(count, MSG_SUGGESTIONS_FIRST_COMBO_COUNT_1, "Number of suggestions after clicking on button.");
- selenium.click(LOC_FIRST_COMBO_INPUT);
- selenium.typeKeys(LOC_FIRST_COMBO_INPUT, "su");
- selenium.typeKeys(LOC_FIRST_COMBO_INPUT, " ");
+ // verify selecting item by mouse
+ try {
+ selenium.clickAt(format(LOC_FIRST_COMBO_SUGGESTIONS, 2), "");
+ } catch (Exception ex) {
+ // TODO: why the exception is thrown?
+ }
+ waitFor(1000);
+ String text = selenium.getValue(LOC_FIRST_COMBO_INPUT);
+ assertEquals(text, MSG_SUGGESTIONS_FIRST_COMBO_INPUT, "Third suggestion was chosen.");
+
+ // verify filtering
+ selenium.type(LOC_FIRST_COMBO_INPUT, "suggestion ");
+ selenium.fireEvent(LOC_FIRST_COMBO_INPUT, Event.KEYUP);
count = getJQueryCount(format(LOC_FIRST_COMBO_SUGGESTIONS, -1));
- assertEquals(count, MSG_SUGGESTIONS_FIRST_COMBO_COUNT_2, "Number of suggestions after typing 'su'.");
+ assertEquals(count, MSG_SUGGESTIONS_FIRST_COMBO_COUNT_1, "Number of suggestions after typing 'sugestion '.");
+
+ selenium.type(LOC_FIRST_COMBO_INPUT, "suggestion 1");
+ selenium.fireEvent(LOC_FIRST_COMBO_INPUT, Event.KEYUP);
- String[] suggestions = new String[5];
- for (int i = 0; i < 5; i++) {
+ count = getJQueryCount(format(LOC_FIRST_COMBO_SUGGESTIONS, -1));
+ assertEquals(count, MSG_SUGGESTIONS_FIRST_COMBO_COUNT_2, "Number of suggestions after typing 'suggestion 1'.");
+
+ String[] suggestions = new String[count];
+ for (int i = 0; i < count; i++) {
suggestions[i] = selenium.getText(format(LOC_FIRST_COMBO_SUGGESTIONS, i));
}
- String[] expected = new String[] { "suggestion 1", "suggestion 2", "suggestion 3", "suggestion 4", "suggestion 5", };
+ String[] expected = new String[] { "suggestion 1" };
- assertEqualsNoOrder(suggestions, expected, "Suggestions after typing 'sa'.");
-
- try {
- selenium.clickAt(format(LOC_FIRST_COMBO_SUGGESTIONS, 2), "");
- } catch (Exception ex) {
- // why the exception is thrown?
- }
- waitFor(1000);
- String text = selenium.getValue(LOC_FIRST_COMBO_INPUT);
- assertEquals(text, MSG_SUGGESTIONS_FIRST_COMBO_INPUT, "Third suggestion was chosen.");
+ assertEqualsNoOrder(suggestions, expected, "Suggestions after typing 'suggestion 1'.");
}
/**
@@ -149,8 +157,8 @@
assertEquals(count, MSG_SUGGESTIONS_SECOND_COMBO_COUNT_1, "Number of suggestions after after clicking on button.");
selenium.click(LOC_SECOND_COMBO_INPUT);
- selenium.typeKeys(LOC_SECOND_COMBO_INPUT, "sa");
- selenium.typeKeys(LOC_SECOND_COMBO_INPUT, " ");
+ selenium.type(LOC_SECOND_COMBO_INPUT, "sa");
+ selenium.fireEvent(LOC_SECOND_COMBO_INPUT, Event.KEYUP);
count = getJQueryCount(format(LOC_SECOND_COMBO_SUGGESTIONS, -1));
assertEquals(count, MSG_SUGGESTIONS_SECOND_COMBO_COUNT_2, "Number of suggestions after typing 'sa'.");
@@ -167,7 +175,7 @@
try {
selenium.clickAt(format(LOC_SECOND_COMBO_SUGGESTIONS, 2), "");
} catch (Exception ex) {
- // why the exception is thrown?
+ // TODO: why the exception is thrown?
}
waitFor(1000);
@@ -190,8 +198,8 @@
assertEquals(count, MSG_SUGGESTIONS_THIRD_COMBO_COUNT_1, "Number of suggestions after after clicking on button.");
selenium.click(LOC_THIRD_COMBO_INPUT);
- selenium.typeKeys(LOC_THIRD_COMBO_INPUT, "sa");
- selenium.typeKeys(LOC_THIRD_COMBO_INPUT, " ");
+ selenium.type(LOC_THIRD_COMBO_INPUT, "sa");
+ selenium.fireEvent(LOC_THIRD_COMBO_INPUT, Event.KEYUP);
count = getJQueryCount(format(LOC_THIRD_COMBO_SUGGESTIONS, -1));
assertEquals(count, MSG_SUGGESTIONS_THIRD_COMBO_COUNT_2, "Number of suggestions after typing 'sa'.");
@@ -208,7 +216,7 @@
try {
selenium.clickAt(format(LOC_THIRD_COMBO_SUGGESTIONS, 3), "");
} catch (Exception ex) {
- // why the exception is thrown?
+ // TODO: why the exception is thrown?
}
waitFor(1000);
@@ -268,9 +276,7 @@
/**
* Loads the page containing the calendar component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Combo Box");
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/commandButton/CommandButtonTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/commandButton/CommandButtonTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/commandButton/CommandButtonTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -87,9 +87,7 @@
waitForTextEquals(LOC_OUTPUT_TEXT, expectedOutputText);
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Command Button");
scrollIntoView(LOC_BUTTON_SAY_HELLO, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/commandLink/CommandLinkTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/commandLink/CommandLinkTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/commandLink/CommandLinkTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -87,9 +87,7 @@
waitForTextEquals(LOC_OUTPUT_TEXT, expectedOutputText);
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Command Link");
scrollIntoView(LOC_LINK_SAY_HELLO, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/contextMenu/ContextMenuImageTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/contextMenu/ContextMenuImageTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/contextMenu/ContextMenuImageTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -171,9 +171,7 @@
/**
* Loads the needed page.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Context Menu");
// XXX: context menu opens in top left corner so it isn't visible if it
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/contextMenu/ContextMenuTableTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/contextMenu/ContextMenuTableTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/contextMenu/ContextMenuTableTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -205,9 +205,7 @@
/**
* Loads the needed page.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Context Menu");
scrollIntoView(LOC_SECOND_EXAMPLE_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataFilterSlider/DataFilterSliderTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataFilterSlider/DataFilterSliderTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataFilterSlider/DataFilterSliderTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -179,7 +179,7 @@
waitTableTextStabilizes.until(conditionTableTextStabilizes);
}
- private Waiting waitTableTextStabilizes = Wait.interval(100).timeout(10000).failWith("Table text never got stabilized");
+ private Waiting waitTableTextStabilizes = Wait.interval(1000).timeout(15000).failWith("Table text never got stabilized");
private Condition conditionTableTextStabilizes = new Condition() {
String memory;
@@ -199,7 +199,7 @@
count = 0;
}
- if (count >= 10) {
+ if (count >= 3) {
return true;
}
@@ -209,9 +209,7 @@
}
};
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Data Filter Slider");
scrollIntoView(LOC_FIELDSET_HEADER, true);
selenium.allowNativeXpath("true");
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataGrid/DataGridTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataGrid/DataGridTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataGrid/DataGridTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -84,9 +84,7 @@
}
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Data Grid");
scrollIntoView(LOC_TABLE_COMMON, true);
selenium.allowNativeXpath("true");
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataList/DataListTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataList/DataListTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataList/DataListTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -48,9 +48,7 @@
MSG_OUTPUT_PRESENT_TEXT_2));
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Data List");
scrollIntoView(LOC_FIELDSET_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataScroller/DataScrollerTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataScroller/DataScrollerTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataScroller/DataScrollerTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -215,9 +215,7 @@
return tableText;
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Data Scroller");
scrollIntoView(LOC_FIELDSET_HEADER, true);
selenium.allowNativeXpath("true");
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/DataTableTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/DataTableTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/DataTableTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -23,6 +23,7 @@
import static org.testng.Assert.*;
+import org.apache.commons.lang.StringUtils;
import org.jboss.richfaces.integrationTest.AbstractDataIterationTestCase;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -47,12 +48,12 @@
openTab(MSG_TAB_TO_OPEN);
scrollIntoView(LOC_FIELDSET_HEADER, true);
- assertEquals(selenium.getText(LOC_TABLE), MSG_TABLE_TEXT_CONTENT, "Table doesn't contain expected text");
+ String tableText = selenium.getText(LOC_TABLE);
+ tableText = StringUtils.deleteWhitespace(tableText);
+ assertEquals(tableText, MSG_TABLE_TEXT_CONTENT, "Table doesn't contain expected text");
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Data Table");
openTab("Usage");
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/EditTableWithModalPanelTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/EditTableWithModalPanelTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/EditTableWithModalPanelTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -188,9 +188,7 @@
});
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Data Table");
openTab(MSG_TAB_TO_OPEN);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/ExtendedDataModelTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/ExtendedDataModelTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/ExtendedDataModelTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -116,9 +116,7 @@
assertEquals(yourBid, highestBidString);
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Data Table");
openTab(MSG_TAB_TO_OPEN);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/ModifiableDataModelTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/ModifiableDataModelTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dataTable/ModifiableDataModelTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -125,9 +125,7 @@
assertTrue(assigneeName.contains(MSG_INPUT_ASSIGNEE));
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Data Table");
openTab(MSG_TAB_TO_OPEN);
scrollIntoView(LOC_TABLE_COMMON, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dragSupport/DragSupportTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dragSupport/DragSupportTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dragSupport/DragSupportTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -227,9 +227,7 @@
}
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Drag Support");
scrollIntoView(LOC_FIELDSET_HEADER, true);
selenium.allowNativeXpath("true");
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dropDownMenu/HorizontalMenuTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dropDownMenu/HorizontalMenuTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/dropDownMenu/HorizontalMenuTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -158,9 +158,7 @@
/**
* Loads the page containing needed component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Drop Down Menu");
scrollIntoView(LOC_FIRST_EXAMPLE_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/editor/AdvancedEditorTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/editor/AdvancedEditorTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/editor/AdvancedEditorTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -840,9 +840,7 @@
/**
* Loads the page containing the calendar component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Editor");
// wait for iframe to load
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/editor/SimpleEditorTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/editor/SimpleEditorTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/editor/SimpleEditorTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -348,9 +348,7 @@
/**
* Loads the page containing needed component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Editor");
// wait for iframe to load
waitFor(1000);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/extendedDataTable/AbstractExtendedDataTableTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/extendedDataTable/AbstractExtendedDataTableTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/extendedDataTable/AbstractExtendedDataTableTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -21,9 +21,12 @@
*******************************************************************************/
package org.jboss.richfaces.integrationTest.extendedDataTable;
+import org.apache.commons.lang.StringUtils;
import org.jboss.richfaces.integrationTest.AbstractDataIterationTestCase;
import org.jboss.test.selenium.waiting.Condition;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Parameters;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
@@ -47,7 +50,6 @@
private final String MSG_OPTION_SELECTION_MODE_PREFORMATTED = getMsg("OPTION_SELECTION_MODE_PREFORMATTED");
- @BeforeMethod
protected void loadPage() {
openComponent("Extended Data Table");
openTab("Usage");
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/extendedDataTable/FilteringTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/extendedDataTable/FilteringTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/extendedDataTable/FilteringTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -21,7 +21,7 @@
*******************************************************************************/
package org.jboss.richfaces.integrationTest.extendedDataTable;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertTrue;
import org.apache.commons.lang.StringUtils;
import org.jboss.test.selenium.dom.Event;
@@ -79,6 +79,10 @@
int rows = getJQueryCount(format(cellsState, 0));
for (int row = 1; row <= rows; row++) {
+ if (row == 1 && browserIsInternetExplorer()) {
+ continue;
+ }
+
if (statePrefix.length() > 0) {
String state = selenium.getText(format(cellsState, row));
assertTrue(state.startsWith(statePrefix), format("'{0}' doesn't start with prefix '{1}'", state,
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/extendedDataTable/GroupingTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/extendedDataTable/GroupingTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/extendedDataTable/GroupingTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -58,6 +58,10 @@
String expectedGroup = null;
for (int row = 1; row <= rows; row++) {
+ if (row == 1 && browserIsInternetExplorer()) {
+ continue;
+ }
+
if (belongsClass(MSG_TR_CLASS, format(LOC_TR_PREFORMATTED, row))) {
// table row is type group
expectedGroup = selenium.getText(format(LOC_TD_GROUP_PREFORMATTED, row)).replace("State Name: ", "").replace("(1)", "");
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/fileUpload/FileUploadTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/fileUpload/FileUploadTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/fileUpload/FileUploadTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -523,16 +523,16 @@
return new Color(red, green, blue);
}
- @SuppressWarnings("unused")
- @BeforeClass
- private void createImages() {
- createImage(Color.RED, 128, 128);
- createImage(Color.BLUE, 128, 128);
- createImage(Color.CYAN, 128, 128);
- createImage(Color.YELLOW, 128, 128);
- createImage(Color.ORANGE, 128, 128);
- createImage(Color.GREEN, 2000, 3500);
- }
+ @SuppressWarnings("unused")
+ @BeforeClass(dependsOnMethods = "initializeBrowser")
+ private void createImages() {
+ createImage(Color.RED, 128, 128);
+ createImage(Color.BLUE, 128, 128);
+ createImage(Color.CYAN, 128, 128);
+ createImage(Color.YELLOW, 128, 128);
+ createImage(Color.ORANGE, 128, 128);
+ createImage(Color.GREEN, 2000, 3500);
+ }
@SuppressWarnings("unused")
@AfterClass
@@ -547,9 +547,7 @@
/**
* Loads the page containing the component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("File Upload");
openTab("Usage");
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorAfterModelUpdateTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorAfterModelUpdateTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorAfterModelUpdateTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -117,9 +117,7 @@
assertEquals(selenium.getText(LOC_OUTPUT_VALIDATION_MESSAGE), text, "Given validation message isn't expected");
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Graph Validator");
scrollIntoView(LOC_FIELDSET_HEADER_ACTIVITIES, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/graphValidator/GraphValidatorTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -227,9 +227,7 @@
return format(LOC_VALIDATION_MESSAGE_RELATIVE, locator);
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Graph Validator");
scrollIntoView(LOC_FIELDSET_HEADER_USEF_INFO, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/include/IncludeTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/include/IncludeTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/include/IncludeTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -207,9 +207,7 @@
&& (nextPresent == selenium.isElementPresent(LOC_BUTTON_NEXT));
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Include");
scrollIntoView(LOC_FIELDSET_HEADER, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inplaceInput/InplaceInputTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inplaceInput/InplaceInputTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inplaceInput/InplaceInputTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -289,9 +289,7 @@
/**
* Loads the page containing needed component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Inplace Input");
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inplaceSelect/InplaceSelectTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inplaceSelect/InplaceSelectTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inplaceSelect/InplaceSelectTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -260,9 +260,7 @@
/**
* Loads the page containing the calendar component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Inplace Select");
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inputNumberSlider/InputNumberSliderTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inputNumberSlider/InputNumberSliderTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inputNumberSlider/InputNumberSliderTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -79,16 +79,16 @@
*/
@Test
public void testFirstSliderMouse() {
- assertTrue(Math.abs(getOffset(LOC_FIRST_HANDLE + "@style") - 75) < DELTA, format(MSG_HANDLE_N_PX, 75));
- assertTrue(Math.abs(getOffset(LOC_FIRST_TIP + "@style") - 75) < DELTA, format(MSG_TIP_N_PX, 75));
+ assertTrue(Math.abs(getOffset(LOC_FIRST_HANDLE) - 75) < DELTA, format(MSG_HANDLE_N_PX, 75));
+ assertTrue(Math.abs(getOffset(LOC_FIRST_TIP) - 75) < DELTA, format(MSG_TIP_N_PX, 75));
assertFalse(isDisplayed(LOC_FIRST_TIP), MSG_TIP_SHOULD_NOT_BE_VISIBLE);
selenium.mouseDownAt(LOC_FIRST, "20,3");
assertTrue(isDisplayed(LOC_FIRST_TIP), MSG_TIP_SHOULD_BE_VISIBLE);
selenium.mouseUp(LOC_FIRST);
- int tipOffset = getOffset(LOC_FIRST_TIP + "@style");
- int handleOffset = getOffset(LOC_FIRST_HANDLE + "@style");
+ int tipOffset = getOffset(LOC_FIRST_TIP);
+ int handleOffset = getOffset(LOC_FIRST_HANDLE);
int value = Integer.parseInt(selenium.getValue(LOC_FIRST_INPUT));
assertEquals(tipOffset, handleOffset, MSG_OFFSETS_SHOULD_BE_THE_SAME);
@@ -107,16 +107,16 @@
@Test
public void testFirstSliderKeyboard() {
selenium.type(LOC_FIRST_INPUT, "10");
- int tipOffset = getOffset(LOC_FIRST_TIP + "@style");
- int handleOffset = getOffset(LOC_FIRST_HANDLE + "@style");
+ int tipOffset = getOffset(LOC_FIRST_TIP);
+ int handleOffset = getOffset(LOC_FIRST_HANDLE);
assertEquals(tipOffset, handleOffset, MSG_OFFSETS_SHOULD_BE_THE_SAME);
assertTrue(Math.abs(tipOffset - 10 * 1.5) < DELTA, MSG_TIP_FIRST_HALF);
assertTrue(handleOffset < 75, MSG_HANDLE_FIRST_HALF);
selenium.type(LOC_FIRST_INPUT, "90");
- tipOffset = getOffset(LOC_FIRST_TIP + "@style");
- handleOffset = getOffset(LOC_FIRST_HANDLE + "@style");
+ tipOffset = getOffset(LOC_FIRST_TIP);
+ handleOffset = getOffset(LOC_FIRST_HANDLE);
assertEquals(tipOffset, handleOffset, MSG_OFFSETS_SHOULD_BE_THE_SAME);
assertTrue(Math.abs(tipOffset - 90 * 1.5) < DELTA, MSG_TIP_SECOND_HALF);
@@ -151,8 +151,8 @@
*/
@Test
public void testSecondSlider() {
- assertTrue(Math.abs(getOffset(LOC_SECOND_HANDLE + "@style") - 96) < DELTA, format(MSG_HANDLE_N_PX, 96));
- assertTrue(Math.abs(getOffset(LOC_SECOND_TIP + "@style") - 96) < DELTA, format(MSG_TIP_N_PX, 96));
+ assertTrue(Math.abs(getOffset(LOC_SECOND_HANDLE) - 96) < DELTA, format(MSG_HANDLE_N_PX, 96));
+ assertTrue(Math.abs(getOffset(LOC_SECOND_TIP) - 96) < DELTA, format(MSG_TIP_N_PX, 96));
assertFalse(isDisplayed(LOC_SECOND_TIP), MSG_TIP_SHOULD_NOT_BE_VISIBLE);
selenium.mouseDownAt(LOC_SECOND, "20,3");
@@ -160,8 +160,8 @@
assertFalse(isDisplayed(LOC_SECOND_TIP), MSG_TIP_SHOULD_NOT_BE_VISIBLE);
selenium.mouseUp(LOC_SECOND);
- int tipOffset = getOffset(LOC_SECOND_TIP + "@style");
- int handleOffset = getOffset(LOC_SECOND_HANDLE + "@style");
+ int tipOffset = getOffset(LOC_SECOND_TIP);
+ int handleOffset = getOffset(LOC_SECOND_HANDLE);
int value = Integer.parseInt(selenium.getValue(LOC_SECOND_INPUT));
assertEquals(tipOffset, handleOffset, MSG_OFFSETS_SHOULD_BE_THE_SAME);
@@ -177,8 +177,8 @@
*/
@Test
public void testThirdSliderMouse() {
- assertTrue(Math.abs(getOffset(LOC_THIRD_HANDLE + "@style") - 225) < DELTA, format(MSG_HANDLE_N_PX, 225));
- assertTrue(Math.abs(getOffset(LOC_THIRD_TIP + "@style") - 225) < DELTA, format(MSG_TIP_N_PX, 225));
+ assertTrue(Math.abs(getOffset(LOC_THIRD_HANDLE) - 225) < DELTA, format(MSG_HANDLE_N_PX, 225));
+ assertTrue(Math.abs(getOffset(LOC_THIRD_TIP) - 225) < DELTA, format(MSG_TIP_N_PX, 225));
assertFalse(isDisplayed(LOC_THIRD_TIP), MSG_TIP_SHOULD_NOT_BE_VISIBLE);
selenium.mouseDownAt(LOC_THIRD, "20,3");
@@ -186,8 +186,8 @@
assertFalse(isDisplayed(LOC_THIRD_TIP), MSG_TIP_SHOULD_NOT_BE_VISIBLE);
selenium.mouseUp(LOC_THIRD);
- int tipOffset = getOffset(LOC_THIRD_TIP + "@style");
- int handleOffset = getOffset(LOC_THIRD_HANDLE + "@style");
+ int tipOffset = getOffset(LOC_THIRD_TIP);
+ int handleOffset = getOffset(LOC_THIRD_HANDLE);
int value = Integer.parseInt(selenium.getValue(LOC_THIRD_INPUT));
assertEquals(tipOffset, handleOffset, MSG_OFFSETS_SHOULD_BE_THE_SAME);
@@ -207,16 +207,16 @@
@Test
public void testThirdSliderKeyboard() {
selenium.type(LOC_THIRD_INPUT, "10"); // 10 -> 0
- int tipOffset = getOffset(LOC_THIRD_TIP + "@style");
- int handleOffset = getOffset(LOC_THIRD_HANDLE + "@style");
+ int tipOffset = getOffset(LOC_THIRD_TIP);
+ int handleOffset = getOffset(LOC_THIRD_HANDLE);
assertEquals(tipOffset, handleOffset, MSG_OFFSETS_SHOULD_BE_THE_SAME);
assertTrue(tipOffset < 5, MSG_TIP_FIRST_HALF);
assertTrue(handleOffset < 75, MSG_HANDLE_FIRST_HALF);
selenium.type(LOC_THIRD_INPUT, "690"); // 690 -> 700
- tipOffset = getOffset(LOC_THIRD_TIP + "@style");
- handleOffset = getOffset(LOC_THIRD_HANDLE + "@style");
+ tipOffset = getOffset(LOC_THIRD_TIP);
+ handleOffset = getOffset(LOC_THIRD_HANDLE);
assertEquals(tipOffset, handleOffset, MSG_OFFSETS_SHOULD_BE_THE_SAME);
assertTrue(Math.abs(tipOffset - 0.69 * 450) < DELTA, MSG_TIP_SECOND_HALF);
@@ -269,27 +269,25 @@
};
abstractTestSource(1, "View Source", strings);
- }
-
+ }
+
/**
- * Returns the offset of the element. It requires a locator for an
- * attribute, e.g. //div@style. It returns the 'left' attribute, e.g. for
- * style="visibility: visible; left: 51px;" would return 51.
+ * Returns the offset of the element for given locator. It returns the
+ * 'left' attribute.
*/
private int getOffset(String locator) {
- StringBuilder attr = new StringBuilder(selenium.getAttribute(locator));
- attr = attr.delete(0, attr.indexOf("left: "));
- attr = attr.delete(0, 6);
- attr = attr.delete(attr.indexOf("px;"), attr.length());
- return Integer.parseInt(attr.toString());
+ String jquery = locator.replaceAll("^jquery=", "");
+ String eval = "var inDocument = this.browserbot.getCurrentWindow().document;"
+ + "var handle = $('{0}', inDocument); var hidden = handle.css('display') === 'none';"
+ + "hidden ? handle.css('display', '') : true;" + "var result = handle.position().left;"
+ + "hidden ? handle.css('display','none') : true;" + "result";
+ return Integer.parseInt(selenium.getEval(format(eval, jquery)));
}
/**
- * Loads the page containing needed component.
- */
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ * Loads the page containing needed component.
+ */
+ protected void loadPage() {
openComponent("Input Number Slider");
scrollIntoView(LOC_EXAMPLE_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/jsFunction/JSFunctionTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/jsFunction/JSFunctionTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/jsFunction/JSFunctionTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -70,9 +70,7 @@
}
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("JS Function");
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/keepAlive/KeepAliveTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/keepAlive/KeepAliveTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/keepAlive/KeepAliveTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -66,13 +66,8 @@
selenium.fireEvent(LOC_INPUT_INCORRECT2, Event.KEYUP);
// wait for "equal sign" button became enabled (lost disabled status)
- Wait.failWith("Button \"=\" never became enabled").until(new Condition() {
- public boolean isTrue() {
- return !selenium.isElementPresent(format("{0}/@disabled", LOC_BUTTON_INCORRECT));
+ Wait.failWith("Button \"=\" never became enabled").until(new ButtonDisabled(LOC_BUTTON_INCORRECT));
- }
- });
-
// try to count result
selenium.click(LOC_BUTTON_INCORRECT);
@@ -101,11 +96,7 @@
selenium.fireEvent(LOC_INPUT_CORRECT2, Event.KEYUP);
// wait for "equal sign" button became enabled (lost disabled status)
- Wait.failWith("Button \"=\" never became enabled").until(new Condition() {
- public boolean isTrue() {
- return !selenium.isElementPresent(format("{0}/@disabled", LOC_BUTTON_CORRECT));
- }
- });
+ Wait.failWith("Button \"=\" never became enabled").until(new ButtonDisabled(LOC_BUTTON_CORRECT));
// try to count result
selenium.click(LOC_BUTTON_CORRECT);
@@ -119,10 +110,27 @@
}
});
}
+
+ private class ButtonDisabled implements Condition {
+ private String locButton;
+
+ public ButtonDisabled(String locButton) {
+ this.locButton = locButton;
+ }
+
+ public boolean isTrue() {
+ final String attrDisabled = format("{0} @disabled", locButton);
+
+ if (!selenium.isElementPresent(attrDisabled)) {
+ return true;
+ }
+
+ return "false".equals(selenium.getValue(attrDisabled));
+ }
+
+ }
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Keep Alive");
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/listShuttle/ListShuttleTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/listShuttle/ListShuttleTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/listShuttle/ListShuttleTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -458,9 +458,7 @@
/**
* Loads the needed page.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("List Shuttle");
scrollIntoView(LOC_EXAMPLE_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/log/LogTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/log/LogTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/log/LogTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -125,9 +125,7 @@
});
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Log");
scrollIntoView(LOC_FIELDSET_HEADER, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/mediaOutput/MediaOutputTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/mediaOutput/MediaOutputTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/mediaOutput/MediaOutputTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -85,9 +85,7 @@
}
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Media Output");
scrollIntoView(LOC_FIELDSET_HEADER, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/modalPanel/ModalPanelTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/modalPanel/ModalPanelTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/modalPanel/ModalPanelTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -219,9 +219,7 @@
/**
* Loads the page containing the calendar component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Modal Panel");
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/orderingList/OrderingListTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/orderingList/OrderingListTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/orderingList/OrderingListTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -549,9 +549,7 @@
/**
* Loads the page containing needed component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Ordering List");
scrollIntoView(LOC_EXAMPLE_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/outputPanel/OutputPanelTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/outputPanel/OutputPanelTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/outputPanel/OutputPanelTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -104,9 +104,7 @@
errorMessageShouldAppear ? "Error message should appear" : "No error message should appear");
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Output Panel");
scrollIntoView(LOC_FIELDSET_HEADER, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/paint2d/Paint2DTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/paint2d/Paint2DTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/paint2d/Paint2DTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -331,9 +331,7 @@
/**
* Loads the page containing the component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Paint2D");
scrollIntoView(LOC_EXAMPLE_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panel/PanelCustomizationTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panel/PanelCustomizationTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panel/PanelCustomizationTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -116,9 +116,7 @@
/**
* Loads the page containing the component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Panel");
openTab("Look Customization");
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panel/PanelTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panel/PanelTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panel/PanelTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -150,9 +150,7 @@
/**
* Loads the page containing the component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Panel");
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panelBar/PanelBarTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panelBar/PanelBarTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panelBar/PanelBarTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -111,9 +111,7 @@
/**
* Loads the page containing the component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Panel Bar");
scrollIntoView(LOC_EXAMPLE_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panelMenu/PanelMenuTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panelMenu/PanelMenuTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panelMenu/PanelMenuTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -264,9 +264,7 @@
/**
* Loads the page containing the component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Panel Menu");
scrollIntoView(LOC_EXAMPLE_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/pickList/PickListTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/pickList/PickListTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/pickList/PickListTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -368,9 +368,7 @@
/**
* Loads the needed page.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Pick List");
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/poll/PollTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/poll/PollTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/poll/PollTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -125,9 +125,7 @@
}
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Poll");
scrollIntoView(LOC_OUTPUT_POLL_STATUS, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/progressBar/ProgressBarTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/progressBar/ProgressBarTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/progressBar/ProgressBarTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -64,7 +64,7 @@
}
public boolean isTrue() {
- newValue = (int) Double.parseDouble(getStyle(locator, "width").replace("px", ""));
+ newValue = (int) Double.parseDouble(getStyle(locator, "width").replaceAll("(px|%)$", ""));
return newValue > oldValue;
}
}
@@ -187,9 +187,7 @@
/**
* Loads the page containing the component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Progress Bar");
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/push/PushTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/push/PushTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/push/PushTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -145,9 +145,7 @@
return !MSG_OUTPUT_PUSH_INACTIVE.equals(selenium.getText(LOC_OUTPUT_TEXT));
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Push");
scrollIntoView(LOC_BUTTON_POLL_CONTROL, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/queue/QueueSettingsTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/queue/QueueSettingsTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/queue/QueueSettingsTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -201,9 +201,7 @@
}
};
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Queue");
openTab("Queue Settings");
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/queue/QueueTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/queue/QueueTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/queue/QueueTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -60,9 +60,7 @@
}
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Queue");
openTab("Usage");
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/repeat/RepeatTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/repeat/RepeatTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/repeat/RepeatTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -118,9 +118,7 @@
return Double.parseDouble(string);
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Repeat");
scrollIntoView(LOC_FIELDSET_HEADER, true);
selenium.allowNativeXpath("true");
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/script/ScriptTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/script/ScriptTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/script/ScriptTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -148,9 +148,7 @@
});
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Script");
scrollIntoView(LOC_FIELDSET_HEADER, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/separator/SeparatorTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/separator/SeparatorTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/separator/SeparatorTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -23,9 +23,12 @@
package org.jboss.richfaces.integrationTest.separator;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
import org.jboss.test.selenium.utils.URLUtils;
@@ -80,10 +83,10 @@
String text = getStyle(format(LOC_SEPARATOR_N, 1), "height");
assertEquals(text, MSG_SECOND_HEIGHT, "Height of the separator.");
- double widthFull = Double.parseDouble(getStyle(format(LOC_SEPARATOR_N, 0), "width").replace("px", ""));
- double width75 = Double.parseDouble(getStyle(format(LOC_SEPARATOR_N, 1), "width").replace("px", ""));
+ long widthFull = selenium.getElementWidth(format(LOC_SEPARATOR_N, 0)).longValue();
+ long width75 = selenium.getElementWidth(format(LOC_SEPARATOR_N, 1)).longValue();
- assertEquals(width75, widthFull * 0.75, "Width of the separator.");
+ assertTrue(Math.abs(width75 - widthFull * 0.75) < 1, "Width of the second separator isn't 75% of first");
text = getSeparatorHash(format(LOC_SEPARATOR_N, 1));
assertEquals(text, MSG_SECOND_HASH, "Hash code of the image that makes the separator.");
@@ -167,7 +170,12 @@
private String getSeparatorHash(String locator) {
// create URL of the image
String url = getStyle(locator, "background-image");
- url = url.replace("url(", "").replace(")", "");
+ Matcher matcher = Pattern.compile("url\\(\"?([^\"\\)]+)\"?\\)").matcher(url);
+ if (matcher.matches()) {
+ url = matcher.group(1);
+ } else {
+ fail("Url '" + url + "' doesn't match url pattern");
+ }
String hash = null;
try {
@@ -183,9 +191,7 @@
/**
* Loads the page containing the component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Separator");
scrollIntoView(LOC_EXAMPLE_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/simpleTogglePanel/SimpleTogglePanelTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/simpleTogglePanel/SimpleTogglePanelTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/simpleTogglePanel/SimpleTogglePanelTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -184,9 +184,7 @@
/**
* Loads the page containing the component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Simple Toggle Panel");
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/spacer/SpacerTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/spacer/SpacerTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/spacer/SpacerTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -92,9 +92,7 @@
/**
* Loads the page containing the component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Spacer");
scrollIntoView(LOC_EXAMPLE_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/spinner/SpinnerTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/spinner/SpinnerTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/spinner/SpinnerTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -301,9 +301,7 @@
/**
* Loads the page containing needed component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Input Number Spinner");
scrollIntoView(LOC_EXAMPLE_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/stateManager/StateManagerTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/stateManager/StateManagerTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/stateManager/StateManagerTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -123,9 +123,7 @@
/**
* Loads the needed page.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("State Manager API");
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/status/StatusTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/status/StatusTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/status/StatusTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -185,9 +185,7 @@
}
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Status");
openTab("Usage");
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/style/StyleTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/style/StyleTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/style/StyleTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -21,12 +21,14 @@
*******************************************************************************/
package org.jboss.richfaces.integrationTest.style;
+import java.awt.Color;
import java.util.LinkedHashMap;
import java.util.Map;
import static org.testng.Assert.*;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
+import org.jboss.test.selenium.utils.ColorUtils;
import org.jboss.test.selenium.waiting.Wait;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -69,14 +71,14 @@
selenium.waitForPageToLoad(Long.toString(Wait.DEFAULT_TIMEOUT));
scrollIntoView(LOC_FIELDSET_HEADER, true);
- assertEquals(msgColor, getStyle(LOC_PANEL, "background-color"), format(
- "background-color for '{0}' skin does not match", selenium.getText(locLink)));
+ Color expected = ColorUtils.convertToAWTColor(msgColor);
+ Color actual = ColorUtils.convertToAWTColor(getStyle(LOC_PANEL, "background-color"));
+ assertEquals(actual, expected, format("background-color for '{0}' skin does not match", selenium
+ .getText(locLink)));
}
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Style");
scrollIntoView(LOC_FIELDSET_HEADER, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/suggestionBox/SuggestionBoxTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/suggestionBox/SuggestionBoxTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/suggestionBox/SuggestionBoxTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -24,7 +24,9 @@
import static org.testng.Assert.assertEquals;
+import org.apache.commons.lang.math.Range;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
+import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.waiting.Condition;
import org.jboss.test.selenium.waiting.Wait;
import org.testng.annotations.BeforeMethod;
@@ -33,7 +35,8 @@
/**
* Test case that tests the suggestion box.
*
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>, <a
+ * href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
public class SuggestionBoxTestCase extends AbstractSeleniumRichfacesTestCase {
@@ -85,15 +88,18 @@
scrollIntoView(LOC_FIRST_INPUT, true);
// select Atlanta
- selenium.typeKeys(LOC_FIRST_INPUT, "at");
+ selenium.type(LOC_FIRST_INPUT, "at");
+ selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN);
+
waitForElement(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0));
selenium.click(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0));
// select Madison
- selenium.typeKeys(LOC_FIRST_INPUT, ",ma");
+ selenium.type(LOC_FIRST_INPUT, selenium.getValue(LOC_FIRST_INPUT) + ",ma");
+ selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN);
- waitForTextEquals(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0), "MadisonWisconsin");
+ waitForTextEquals(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0), "Wisconsin");
selenium.click(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0));
String text = selenium.getText(format(LOC_FIRST_TOWN_TABLE_PREFORMATTED, 1, 0));
@@ -130,17 +136,23 @@
scrollIntoView(LOC_FIRST_INPUT, true);
// select Atlanta
- selenium.typeKeys(LOC_FIRST_INPUT, "[at");
+ selenium.type(LOC_FIRST_INPUT, "[at");
+ selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN);
+
waitForElement(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0));
selenium.click(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0));
- selenium.typeKeys(LOC_FIRST_INPUT, "]");
+ selenium.type(LOC_FIRST_INPUT, selenium.getValue(LOC_FIRST_INPUT) + "]");
+ selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN);
// select Madison
- selenium.typeKeys(LOC_FIRST_INPUT, "[ma");
- waitForTextEquals(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0), "MadisonWisconsin");
+ selenium.type(LOC_FIRST_INPUT, selenium.getValue(LOC_FIRST_INPUT) + "[ma");
+ selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN);
+
+ waitForTextEquals(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0), "Wisconsin");
selenium.click(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0));
- selenium.typeKeys(LOC_FIRST_INPUT, "]");
+ selenium.type(LOC_FIRST_INPUT, selenium.getValue(LOC_FIRST_INPUT) + "]");
+ selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN);
String text = selenium.getText(format(LOC_FIRST_TOWN_TABLE_PREFORMATTED, 1, 0));
assertEquals(text, "Georgia", format(MSG_TABLE_PREFORMATTED, 1, 0));
@@ -176,7 +188,8 @@
scrollIntoView(LOC_FIRST_INPUT, true);
// select aaa
- selenium.typeKeys(LOC_FIRST_INPUT, "aaa");
+ selenium.type(LOC_FIRST_INPUT, "aaa");
+ selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN);
waitForElement(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0));
String text = selenium.getText(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0));
@@ -184,242 +197,106 @@
}
/**
- * Tests the "Border" slider. It tests values 3, 5, and 7.
+ * Tests the "Border" slider. It tests values 5, 0, 3, 7, 1
*/
- @Test
- public void testBorder() {
- scrollIntoView(LOC_FIRST_INPUT, true);
+ @Test
+ public void testBorder() {
+ scrollIntoView(LOC_FIRST_INPUT, true);
- selenium.type(LOC_FIRST_BORDER_INPUT, "3");
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_BORDER_STYLE, "border-width") == 3;
- }
- });
+ StepRange range = new StepRange(1, 5, 1);
+ for (int i : new int[] { 5, 0, 3, 7, 1 }) {
+ selenium.type(LOC_FIRST_BORDER_INPUT, String.valueOf(i));
+ selenium.fireEvent(LOC_FIRST_BORDER_INPUT, Event.BLUR);
+ String result = range.getRoundedValue(i).toString();
+ Wait.failWith(format(MSG_SUGGESTION_BOX_BORDER_PREFORMATTED, String.valueOf(i))).until(
+ new StyleCondition(LOC_FIRST_BORDER_STYLE, "border-top-width", result));
+ assertEquals(getStyleValue(LOC_FIRST_BORDER_STYLE, "border-right-width"), result);
+ assertEquals(getStyleValue(LOC_FIRST_BORDER_STYLE, "border-bottom-width"), result);
+ assertEquals(getStyleValue(LOC_FIRST_BORDER_STYLE, "border-left-width"), result);
+ assertEquals(selenium.getValue(LOC_FIRST_BORDER_INPUT), result);
+ }
+ }
- int width = getValue(LOC_FIRST_BORDER_STYLE, "border-width");
- assertEquals(width, 3, format(MSG_SUGGESTION_BOX_BORDER_PREFORMATTED, 3));
-
- selenium.type(LOC_FIRST_BORDER_INPUT, "5");
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_BORDER_STYLE, "border-width") == 5;
- }
- });
-
- width = getValue(LOC_FIRST_BORDER_STYLE, "border-width");
- assertEquals(width, 5, format(MSG_SUGGESTION_BOX_BORDER_PREFORMATTED, 5));
-
- selenium.type(LOC_FIRST_BORDER_INPUT, "7"); // 7 -> 5
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_BORDER_STYLE, "border-width") == 5;
- }
- });
-
- width = getValue(LOC_FIRST_BORDER_STYLE, "border-width");
- assertEquals(width, 5, format(MSG_SUGGESTION_BOX_BORDER_PREFORMATTED, 7));
- }
-
/**
- * Tests the "Width" slider. It tests values 150, 350, 400, and 176.
+ * Tests the "Width" slider. It tests values 350, 149, 176, 351, 200, 150, 500
*/
@Test
public void testWidth() {
scrollIntoView(LOC_FIRST_INPUT, true);
- selenium.type(LOC_FIRST_WIDTH_INPUT, "150");
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_WIDTH_STYLE, "width") == 150;
- }
- });
-
- int width = getValue(LOC_FIRST_WIDTH_STYLE, "width");
- assertEquals(width, 150, format(MSG_SUGGESTION_BOX_WIDTH_PREFORMATTED, 150));
-
- selenium.type(LOC_FIRST_WIDTH_INPUT, "350");
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_WIDTH_STYLE, "width") == 350;
- }
- });
-
- width = getValue(LOC_FIRST_WIDTH_STYLE, "width");
- assertEquals(width, 350, format(MSG_SUGGESTION_BOX_WIDTH_PREFORMATTED, 350));
-
- selenium.type(LOC_FIRST_WIDTH_INPUT, "400"); // 400 -> 350
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_WIDTH_STYLE, "width") == 350;
- }
- });
-
- width = getValue(LOC_FIRST_WIDTH_STYLE, "width");
- assertEquals(width, 350, format(MSG_SUGGESTION_BOX_WIDTH_PREFORMATTED, 400));
-
- selenium.type(LOC_FIRST_WIDTH_INPUT, "176"); // 176 -> 200
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_WIDTH_STYLE, "width") == 200;
- }
- });
-
- width = getValue(LOC_FIRST_WIDTH_STYLE, "width");
- assertEquals(width, 200, format(MSG_SUGGESTION_BOX_WIDTH_PREFORMATTED, 176));
+ StepRange range = new StepRange(150, 350, 50);
+ final String locInput = LOC_FIRST_WIDTH_INPUT;
+ for (int i : new int[] { 350, 149, 176, 351, 200, 150, 500 }) {
+ selenium.type(locInput, String.valueOf(i));
+ selenium.fireEvent(locInput, Event.BLUR);
+ String result = range.getRoundedValue(i).toString();
+ Wait.failWith(format(MSG_SUGGESTION_BOX_WIDTH_PREFORMATTED, String.valueOf(i))).until(
+ new StyleCondition(LOC_FIRST_WIDTH_STYLE, "width", result));
+ assertEquals(selenium.getValue(locInput), result);
+ }
}
/**
- * Tests the "Height" slider. It tests values 100, 300, 400, and 176.
+ * Tests the "Height" slider. It tests values 300, 99, 176, 301, 200, 100, 400
*/
@Test
public void testHeight() {
scrollIntoView(LOC_FIRST_INPUT, true);
- selenium.type(LOC_FIRST_HEIGHT_INPUT, "100");
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_HEIGHT_STYLE, "height") == 100;
- }
- });
-
- int height = getValue(LOC_FIRST_HEIGHT_STYLE, "height");
- assertEquals(height, 100, format(MSG_SUGGESTION_BOX_HEIGHT_PREFORMATTED, 100));
-
- selenium.type(LOC_FIRST_HEIGHT_INPUT, "300");
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_HEIGHT_STYLE, "height") == 300;
- }
- });
-
- height = getValue(LOC_FIRST_HEIGHT_STYLE, "height");
- assertEquals(height, 300, format(MSG_SUGGESTION_BOX_HEIGHT_PREFORMATTED, 300));
-
- selenium.type(LOC_FIRST_HEIGHT_INPUT, "400"); // 400 -> 300
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_HEIGHT_STYLE, "height") == 300;
- }
- });
-
- height = getValue(LOC_FIRST_HEIGHT_STYLE, "height");
- assertEquals(height, 300, format(MSG_SUGGESTION_BOX_HEIGHT_PREFORMATTED, 400));
-
- selenium.type(LOC_FIRST_HEIGHT_INPUT, "176"); // 176 -> 200
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_HEIGHT_STYLE, "height") == 200;
- }
- });
-
- height = getValue(LOC_FIRST_HEIGHT_STYLE, "height");
- assertEquals(height, 200, format(MSG_SUGGESTION_BOX_HEIGHT_PREFORMATTED, 176));
+ StepRange range = new StepRange(100, 300, 50);
+ final String locInput = LOC_FIRST_HEIGHT_INPUT;
+ for (int i : new int[] { 300, 99, 176, 301, 200, 100, 400 }) {
+ selenium.type(locInput, String.valueOf(i));
+ selenium.fireEvent(locInput, Event.BLUR);
+ String result = range.getRoundedValue(i).toString();
+ Wait.failWith(format(MSG_SUGGESTION_BOX_HEIGHT_PREFORMATTED, String.valueOf(i))).until(
+ new StyleCondition(LOC_FIRST_HEIGHT_STYLE, "height", result));
+ assertEquals(selenium.getValue(locInput), result);
+ }
}
/**
- * Tests the "Shadow Depth" slider. It tests values 3, 5, 6, and 7. It test
+ * Tests the "Shadow Depth" slider. It tests values 7, 4, 2, 6, 3, 0, 8. It test
* both top and left offset.
*/
- @Test
- public void testShadowDepth() {
- scrollIntoView(LOC_FIRST_INPUT, true);
+ @Test
+ public void testShadowDepth() {
+ scrollIntoView(LOC_FIRST_INPUT, true);
- selenium.type(LOC_FIRST_SHADOW_DEPTH_INPUT, "3");
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top") == 3;
- }
- });
-
- int top = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top");
- assertEquals(top, 3, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 3));
- int left = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "left");
- assertEquals(left, 3, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 3));
-
- selenium.type(LOC_FIRST_SHADOW_DEPTH_INPUT, "5");
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top") == 5;
- }
- });
-
- top = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top");
- assertEquals(top, 5, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 5));
- left = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "left");
- assertEquals(left, 5, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 5));
-
- selenium.type(LOC_FIRST_SHADOW_DEPTH_INPUT, "6");
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top") == 6;
- }
- });
-
- top = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top");
- assertEquals(top, 6, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 6));
- left = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "left");
- assertEquals(left, 6, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 6));
-
- selenium.type(LOC_FIRST_SHADOW_DEPTH_INPUT, "7"); // 7 -> 6
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top") == 6;
- }
- });
-
- top = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top");
- assertEquals(top, 6, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 7));
- left = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "left");
- assertEquals(left, 6, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 7));
+ StepRange range = new StepRange(3, 6, 1);
+ final String locInput = LOC_FIRST_SHADOW_DEPTH_INPUT;
+ for (int i : new int[] { 7, 4, 2, 6, 3, 0, 8 }) {
+ selenium.type(locInput, String.valueOf(i));
+ selenium.fireEvent(locInput, Event.BLUR);
+ selenium.type(LOC_FIRST_INPUT, String.valueOf(i));
+ selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN);
+ String result = range.getRoundedValue(i).toString();
+ Wait.failWith(format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, String.valueOf(i))).until(
+ new StyleCondition(LOC_FIRST_SHADOW_DEPTH_STYLE, "top", result));
+ assertEquals(getStyleValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "left"), result);
+ assertEquals(selenium.getValue(locInput), result);
+ }
}
/**
- * Tests the "Shadow Opacity" slider. It tests values 1, 5, 9, and 11.
+ * Tests the "Shadow Opacity" slider. It tests values 10, 5, 0, 9, 1, -1, 12.
*/
@Test
public void testShadowOpacity() {
scrollIntoView(LOC_FIRST_INPUT, true);
-
- selenium.type(LOC_FIRST_SHADOW_OPACITY_INPUT, "1");
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE) == 0.1;
- }
- });
-
- double opacity = getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE);
- assertEquals(opacity, 0.1, format(MSG_SUGGESTION_BOX_SHADOW_OPACITY_PREFORMATTED, 1));
-
- selenium.type(LOC_FIRST_SHADOW_OPACITY_INPUT, "5");
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE) == 0.5;
- }
- });
-
- opacity = getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE);
- assertEquals(opacity, 0.5, format(MSG_SUGGESTION_BOX_SHADOW_OPACITY_PREFORMATTED, 5));
-
- selenium.type(LOC_FIRST_SHADOW_OPACITY_INPUT, "9");
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE) == 0.9;
- }
- });
-
- opacity = getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE);
- assertEquals(opacity, 0.9, format(MSG_SUGGESTION_BOX_SHADOW_OPACITY_PREFORMATTED, 9));
-
- selenium.type(LOC_FIRST_SHADOW_OPACITY_INPUT, "11"); // 11 -> 9
- Wait.until(new Condition() {
- public boolean isTrue() {
- return getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE) == 0.9;
- }
- });
-
- opacity = getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE);
- assertEquals(opacity, 0.9, format(MSG_SUGGESTION_BOX_SHADOW_OPACITY_PREFORMATTED, 11));
+
+ StepRange range = new StepRange(1, 9, 1);
+ final String locInput = LOC_FIRST_SHADOW_OPACITY_INPUT;
+ for (int i : new int[] { 10, 5, 0, 9, 1, -1, 12 }) {
+ selenium.type(locInput, String.valueOf(i));
+ selenium.fireEvent(locInput, Event.BLUR);
+ selenium.type(LOC_FIRST_INPUT, String.valueOf(i));
+ selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN);
+ String result = range.getRoundedValue(i).toString();
+ Wait.failWith(format(MSG_SUGGESTION_BOX_SHADOW_OPACITY_PREFORMATTED, String.valueOf(i))).until(
+ new StyleCondition(LOC_FIRST_SHADOW_OPACITY_STYLE, "opacity", format("0.{0}", result)));
+ assertEquals(selenium.getValue(locInput), result);
+ }
}
/**
@@ -494,7 +371,9 @@
public void testSecondExampleOneCity() {
scrollIntoView(LOC_SECOND_INPUT, true);
- selenium.typeKeys(LOC_SECOND_INPUT, "a");
+ selenium.type(LOC_SECOND_INPUT, "a");
+ selenium.fireEvent(LOC_SECOND_INPUT, Event.KEYDOWN);
+
waitForElement(format(LOC_SECOND_SUGGESTION_BOX_PREFORMATTED, 1));
selenium.click(format(LOC_SECOND_SUGGESTION_BOX_PREFORMATTED, 1)); // Augusta
@@ -512,11 +391,15 @@
public void testSecondExampleMoreCities() {
scrollIntoView(LOC_SECOND_INPUT, true);
- selenium.typeKeys(LOC_SECOND_INPUT, "a");
+ selenium.type(LOC_SECOND_INPUT, "a");
+ selenium.fireEvent(LOC_SECOND_INPUT, Event.KEYDOWN);
+
waitForElement(format(LOC_SECOND_SUGGESTION_BOX_PREFORMATTED, 1));
selenium.click(format(LOC_SECOND_SUGGESTION_BOX_PREFORMATTED, 1)); // Augusta
- selenium.typeKeys(LOC_SECOND_INPUT, ",m");
+ selenium.type(LOC_SECOND_INPUT, selenium.getValue(LOC_SECOND_INPUT) + ",m");
+ selenium.fireEvent(LOC_SECOND_INPUT, Event.KEYDOWN);
+
waitForTextEquals(format(LOC_SECOND_SUGGESTION_BOX_PREFORMATTED, 2), "Madison");
selenium.click(format(LOC_SECOND_SUGGESTION_BOX_PREFORMATTED, 2)); // Madison
@@ -587,44 +470,107 @@
abstractTestSource(2, "View Source", strings);
}
- /**
- * Pulls out the value of the specified attribute from the specified
- * location.
- *
- * @param loc
- * an attribute locator
- * @param attr
- * an 'subattribute' whose value we want (e.g. <div
- * style="left: 4px;"/>, then loc=//div@style and attr=left
- * @return the value of the subattribute
- */
- private int getValue(String loc, String attr) {
- String tmp = selenium.getAttribute(loc);
- int firstIdx = tmp.indexOf(attr) + 2 + attr.length();
- int secondIdx = tmp.indexOf("px;", firstIdx);
- return Integer.parseInt(tmp.substring(firstIdx, secondIdx));
- }
+
+ /**
+ * Condition for Wait.until(Condition) which waits for the item specified by
+ * locator becomes in given style given value
+ */
+ private class StyleCondition implements Condition {
+ private String locator;
+ private String style;
+ private String value;
- /**
- * Pulls out opacity from the specified attribute.
- *
- * @param loc
- * an attribute locator
- * @return the value of opacity
- */
- private double getOpacity(String loc) {
- String tmp = selenium.getAttribute(loc);
- int firstIdx = tmp.indexOf("opacity") + 9;
- int secondIdx = tmp.indexOf(";", firstIdx);
- return Double.parseDouble(tmp.substring(firstIdx, secondIdx));
- }
+ /**
+ * @param locator
+ * locator of item which we will be testing for becoming
+ * given style in given value
+ * @param style
+ * tested on item given by locator to equality with given
+ * value
+ * @param value
+ * of given style which we are testing on item specified by
+ * locator
+ */
+ public StyleCondition(String locator, String style, String value) {
+ this.locator = locator;
+ this.style = style;
+ this.value = value;
+ }
- /**
- * Loads the page containing the calendar component.
- */
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ public boolean isTrue() {
+ return getStyleValue(locator, style).equals(value);
+ }
+ }
+
+ /**
+ * Pulls out the value of the specified attribute from the specified
+ * location.
+ *
+ * @param loc
+ * an attribute locator
+ * @param attr
+ * an style value what we want to pull out
+ * @return the value of the subattribute
+ */
+ private String getStyleValue(String loc, String attr) {
+ return getStyle(loc, attr).replaceFirst("px", "");
+ }
+
+ /**
+ * Class representing Range of numbers with defined offset between them (step)
+ *
+ * Can test the number for presence in range and round the number into number, which is in the range.
+ */
+ private class StepRange extends Range {
+
+ private int minimum;
+ private int maximum;
+ private int step;
+
+ public StepRange(int minimum, int maximum, int step) {
+ this.minimum = minimum;
+ this.maximum = maximum;
+ this.step = step;
+ }
+
+ @Override
+ public boolean containsNumber(Number number) {
+ return number.intValue() == getRoundedValue(number).intValue();
+ }
+
+ @Override
+ public Number getMaximumNumber() {
+ return maximum;
+ }
+
+ @Override
+ public Number getMinimumNumber() {
+ return minimum;
+ }
+
+ public Number getRoundedValue(Number number) {
+ if (number.intValue() < minimum)
+ return minimum;
+ if (number.intValue() > maximum)
+ return maximum;
+ int delta = number.intValue() % step;
+ if (delta != 0) {
+ if (delta > (step / 2)) {
+ return number.intValue() - delta + step;
+ } else {
+ return number.intValue() - delta;
+ }
+ }
+ return number;
+ }
+ }
+
+ /**
+ * Loads the page containing the calendar component.
+ */
+ protected void loadPage() {
openComponent("Suggestion Box");
}
+
+
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tabPanel/TabPanelTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tabPanel/TabPanelTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tabPanel/TabPanelTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -192,9 +192,7 @@
/**
* Loads the page containing the calendar component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Tab Panel");
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tableFiltering/TableFilteringTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tableFiltering/TableFilteringTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tableFiltering/TableFilteringTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -177,9 +177,7 @@
}
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Table Filtering");
selenium.allowNativeXpath("true");
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tableSorting/TableSortingTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tableSorting/TableSortingTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tableSorting/TableSortingTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -144,9 +144,7 @@
checkSortingForColumnOrder(LOC_LIST_OF_TD_PREFORMATTED);
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Table Sorting");
selenium.allowNativeXpath("true");
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/togglePanel/TogglePanelTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/togglePanel/TogglePanelTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/togglePanel/TogglePanelTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -158,9 +158,7 @@
/**
* Loads the page containing the component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Toggle Panel");
scrollIntoView(LOC_EXAMPLE_HEADER, true);
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/toolBar/ToolBarTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/toolBar/ToolBarTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/toolBar/ToolBarTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -287,9 +287,7 @@
/**
* Loads the page containing the component.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Tool Bar");
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tooltip/TooltipDataTableTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tooltip/TooltipDataTableTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tooltip/TooltipDataTableTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -96,9 +96,7 @@
return !"0".equals(selenium.getEval(format("jqFind('{0}:visible').size()", locator.replaceFirst("^jquery=", "").trim())));
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("ToolTip");
openTab("Use ToolTip with DataTable");
scrollIntoView(LOC_FIELDSET_HEADER_2, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tooltip/TooltipTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tooltip/TooltipTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tooltip/TooltipTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -196,9 +196,7 @@
});
}
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("ToolTip");
openTab("Usage");
scrollIntoView(LOC_FIELDSET_HEADER_1, true);
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeNodesAdaptorTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeNodesAdaptorTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeNodesAdaptorTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -178,9 +178,7 @@
/**
* Loads the needed page.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Tree Adaptor");
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeTestCase.java 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/tree/TreeTestCase.java 2010-01-18 16:36:28 UTC (rev 16322)
@@ -206,9 +206,7 @@
/**
* Loads the needed page.
*/
- @SuppressWarnings("unused")
- @BeforeMethod
- private void loadPage() {
+ protected void loadPage() {
openComponent("Tree");
}
}
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/comboBox/messages.properties
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/comboBox/messages.properties 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/comboBox/messages.properties 2010-01-18 16:36:28 UTC (rev 16322)
@@ -3,7 +3,7 @@
INITIAL_STATE_INITIAL_VALUE_3=Enter some value
SUGGESTIONS_FIRST_COMBO_COUNT_1=5
-SUGGESTIONS_FIRST_COMBO_COUNT_2=5
+SUGGESTIONS_FIRST_COMBO_COUNT_2=1
SUGGESTIONS_FIRST_COMBO_INPUT=suggestion 3
SUGGESTIONS_SECOND_COMBO_COUNT_1=50
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/dataTable/messages-DataTableTestCase.properties
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/dataTable/messages-DataTableTestCase.properties 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/dataTable/messages-DataTableTestCase.properties 2010-01-18 16:36:28 UTC (rev 16322)
@@ -1,2 +1,2 @@
TAB_TO_OPEN=Usage
-TABLE_TEXT_CONTENT=ExpensessubtotalsMealsHotelsTransportTotals$196.27$442.00$162.00$800.27San Jose25-Aug-97$37.74$112.00$45.0026-Aug-97$27.28$112.00$45.00$65.02$224.00$90.00$379.02Seattle27-Aug-97$96.25$109.00$36.0028-Aug-97$35.00$109.00$36.00$131.25$218.00$72.00$421.25
+TABLE_TEXT_CONTENT=ExpensessubtotalsMealsHotelsTransportTotals$196.27$442.00$162.00$800.27SanJose25-Aug-97$37.74$112.00$45.0026-Aug-97$27.28$112.00$45.00$65.02$224.00$90.00$379.02Seattle27-Aug-97$96.25$109.00$36.0028-Aug-97$35.00$109.00$36.00$131.25$218.00$72.00$421.25
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/graphValidator/locators.properties
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/graphValidator/locators.properties 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/graphValidator/locators.properties 2010-01-18 16:36:28 UTC (rev 16322)
@@ -8,4 +8,4 @@
BUTTON_SUBMIT_ACTIVITIES=jquery=input[value=Store my details]
OUTPUT_VALIDATION_MESSAGE=jquery=form#graphValidatorForm2 span.rich-messages-label
CLASS_VALIDATION_MESSAGE=jquery=form#graphValidatorForm2 dt@class
-INPUT_ACTIVITY_HOURS_PREFORMATTED=jquery=form#graphValidatorForm2 > table > tbody > tr:nth-child({0}) input.rich-spinner-input
+INPUT_ACTIVITY_HOURS_PREFORMATTED=jquery\=form\#graphValidatorForm2 tr\:nth-child({0}) input.rich-spinner-input
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/panelMenu/locators.properties
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/panelMenu/locators.properties 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/panelMenu/locators.properties 2010-01-18 16:36:28 UTC (rev 16322)
@@ -1,5 +1,5 @@
EXAMPLE_HEADER=jquery=fieldset > legend
-PANEL=jquery=fieldset span[id=form\\:current]
+PANEL=jquery\=fieldset span[id\=form\:current]
GROUP_N_IMAGE_BEFORE=jquery=fieldset table.rich-pmenu-top-group:eq({0}) td:eq(0) img@src
GROUP_N_IMAGE_AFTER=jquery=fieldset table.rich-pmenu-top-group:eq({0}) td:eq(2) img@src
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/suggestionBox/locators.properties
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/suggestionBox/locators.properties 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/suggestionBox/locators.properties 2010-01-18 16:36:28 UTC (rev 16322)
@@ -1,4 +1,4 @@
-FIRST_SUGGESTION_BOX_PREFORMATTED=jquery=table[id$=suggest].rich-sb-int-decor-table tr:eq({0})
+FIRST_SUGGESTION_BOX_PREFORMATTED=jquery\=table[id$\=suggest].rich-sb-int-decor-table tr\:eq({0}) td\:last
FIRST_INPUT=jquery=fieldset:eq(0) input[id$=text]
FIRST_BORDER_INPUT=jquery=fieldset:eq(0) td.sb_test_column1 > table > tbody > tr:eq(0) > td:eq(1) input
@@ -10,15 +10,15 @@
FIRST_TOWN_TABLE_PREFORMATTED=jquery=fieldset:eq(0) td.sb_test_column2 div#myDiv tr:eq({0}) > td:eq({1})
-FIRST_BORDER_STYLE=jquery=div[id$=suggestionBoxId] div.rich-sb-ext-decor-2@style
-FIRST_WIDTH_STYLE=jquery=div[id$=suggestionBoxId]@style
-FIRST_HEIGHT_STYLE=jquery=div[id$=suggestionBoxId]@style
-FIRST_SHADOW_DEPTH_STYLE=jquery=div[id$=suggestionBoxId] > div:eq(1)@style
-FIRST_SHADOW_OPACITY_STYLE=jquery=div[id$=suggestionBoxId] > div:eq(1)@style
+FIRST_BORDER_STYLE=jquery\=div[id$\=suggestionBoxId] div.rich-sb-ext-decor-2
+FIRST_WIDTH_STYLE=jquery\=div[id$\=suggestionBoxId]
+FIRST_HEIGHT_STYLE=jquery\=div[id$\=suggestionBoxId]
+FIRST_SHADOW_DEPTH_STYLE=jquery\=div[id$\=suggestionBoxId] > div\:eq(1)
+FIRST_SHADOW_OPACITY_STYLE=jquery\=div[id$\=suggestionBoxId] > div\:eq(1)
FIRST_CELLPADDING=jquery=div[id$=suggestionBoxId] table[id$=suggest]@cellpadding
SECOND_INPUT=jquery=fieldset:eq(1) input[id$=statesinput]
SECOND_BUTTON=jquery=fieldset:eq(1) img[src*=arrow.png]
SECOND_SUGGESTION_LINES=jquery=div[id$=suggestion] table[id$=suggest] tr
-SECOND_SUGGESTION_BOX_PREFORMATTED=jquery=div[id$=suggestion] table[id$=suggest] tr:eq({0})
+SECOND_SUGGESTION_BOX_PREFORMATTED=jquery\=div[id$\=suggestion] table[id$\=suggest] tr\:eq({0}) td\:last
SECOND_STATE=jquery=fieldset:eq(1) span[id$=objects]
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/tabPanel/locators.properties
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/tabPanel/locators.properties 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/tabPanel/locators.properties 2010-01-18 16:36:28 UTC (rev 16322)
@@ -6,12 +6,12 @@
# second tab
CUST_EXAMPLE_HEADER=jquery=div#itme > p
-CUST_TABS_ALIGN=jquery=div#itme > table.rich-tabpanel td.rich-tab-bottom-line@align
-CUST_PANEL_TEXT_PREFORMATTED=jquery=div#itme > table.rich-tabpanel > tbody > tr:eq(1) > td:eq({0})
-CUST_PANEL_TAB_PREFORMATTED=jquery=div#itme > table.rich-tabpanel > tbody form td[id$=cell]:eq({0}) > table
+CUST_TABS_ALIGN=jquery\=div\#itme table.rich-tabpanel td.rich-tab-bottom-line@align
+CUST_PANEL_TEXT_PREFORMATTED=jquery\=div\#itme table.rich-tabpanel tbody > tr\:eq(1) > td\:eq({0})
+CUST_PANEL_TAB_PREFORMATTED=jquery\=div\#itme table.rich-tabpanel form td[id$\=cell]\:eq({0}) > table
# third tab
DELET_EXAMPLE_HEADER=jquery=td.content_tab
DELET_PANEL_TABS=jquery=table[id$=RemoveAbleTabPanel] td[id$=cell]
-DELET_PANEL_TAB_CLOSE_PREFORMATTED=jquery=img[id=tabs_form\:hidelink{0}]
+DELET_PANEL_TAB_CLOSE_PREFORMATTED=jquery\=img[id\=tabs_form\:hidelink{0}]
DELET_RESET_BUTTON=jquery=input[value=Reset Tabs]
\ No newline at end of file
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/testng.xml
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/testng.xml 2010-01-18 14:30:05 UTC (rev 16321)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/testng.xml 2010-01-18 16:36:28 UTC (rev 16322)
@@ -80,6 +80,7 @@
<test
name="org.jboss.richfaces.integrationTest.colorPicker.ColorPickerTestCase">
+ <parameter name="internet-explorer-enabled" value="false"></parameter>
<classes>
<class
name="org.jboss.richfaces.integrationTest.colorPicker.ColorPickerTestCase" />
@@ -194,6 +195,7 @@
<test
name="org.jboss.richfaces.integrationTest.dragSupport.DragSupportTestCase">
+ <parameter name="internet-explorer-enabled" value="false"></parameter>
<classes>
<class
name="org.jboss.richfaces.integrationTest.dragSupport.DragSupportTestCase" />
@@ -210,6 +212,7 @@
<test
name="org.jboss.richfaces.integrationTest.editor.AdvancedEditorTestCase">
+ <parameter name="internet-explorer-enabled" value="false"></parameter>
<classes>
<class
name="org.jboss.richfaces.integrationTest.editor.AdvancedEditorTestCase" />
@@ -217,6 +220,7 @@
</test>
<test name="org.jboss.richfaces.integrationTest.editor.SimpleEditorTestCase">
+ <parameter name="internet-explorer-enabled" value="false"></parameter>
<classes>
<class
name="org.jboss.richfaces.integrationTest.editor.SimpleEditorTestCase" />
@@ -225,6 +229,7 @@
<test
name="org.jboss.richfaces.integrationTest.extendedDataTable.DraggingTestCase">
+ <parameter name="internet-explorer-enabled" value="false"></parameter>
<classes>
<class
name="org.jboss.richfaces.integrationTest.extendedDataTable.DraggingTestCase" />
@@ -249,6 +254,7 @@
<test
name="org.jboss.richfaces.integrationTest.extendedDataTable.SelectingTestCase">
+ <parameter name="internet-explorer-enabled" value="false"></parameter>
<classes>
<class
name="org.jboss.richfaces.integrationTest.extendedDataTable.SelectingTestCase" />
@@ -265,6 +271,7 @@
<test
name="org.jboss.richfaces.integrationTest.fileUpload.FileUploadTestCase">
+ <parameter name="internet-explorer-enabled" value="false"></parameter>
<classes>
<class
name="org.jboss.richfaces.integrationTest.fileUpload.FileUploadTestCase" />
@@ -303,6 +310,7 @@
<test
name="org.jboss.richfaces.integrationTest.inplaceSelect.InplaceSelectTestCase">
+ <parameter name="internet-explorer-enabled" value="false"></parameter>
<classes>
<class
name="org.jboss.richfaces.integrationTest.inplaceSelect.InplaceSelectTestCase" />
@@ -372,6 +380,7 @@
<test
name="org.jboss.richfaces.integrationTest.orderingList.OrderingListTestCase">
+ <parameter name="internet-explorer-enabled" value="false"></parameter>
<classes>
<class
name="org.jboss.richfaces.integrationTest.orderingList.OrderingListTestCase" />
@@ -560,6 +569,7 @@
<test
name="org.jboss.richfaces.integrationTest.tooltip.TooltipDataTableTestCase">
+ <parameter name="internet-explorer-enabled" value="false"></parameter>
<classes>
<class
name="org.jboss.richfaces.integrationTest.tooltip.TooltipDataTableTestCase" />
@@ -567,6 +577,7 @@
</test>
<test name="org.jboss.richfaces.integrationTest.tooltip.TooltipTestCase">
+ <parameter name="internet-explorer-enabled" value="false"></parameter>
<classes>
<class name="org.jboss.richfaces.integrationTest.tooltip.TooltipTestCase" />
</classes>
14 years, 3 months
JBoss Rich Faces SVN: r16321 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/freemarker and 11 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-01-18 09:30:05 -0500 (Mon, 18 Jan 2010)
New Revision: 16321
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTemplateModel.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taglib/
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taglib/validator.ftl
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/freemarker/
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.xml
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/UIBar.java
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java
Log:
https://jira.jboss.org/jira/browse/RF-8232
Tags support
- taglib generator for validator
- remove jaxb annotation from model classes
- check result for java code generators (ComponentClassGenerator...)
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java 2010-01-18 12:10:45 UTC (rev 16320)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -36,6 +36,7 @@
import org.richfaces.cdk.templatecompiler.RendererTemplateParser;
import org.richfaces.cdk.xmlconfig.FacesConfigGenerator;
import org.richfaces.cdk.xmlconfig.FacesConfigParser;
+import org.richfaces.cdk.freemarker.ValidatorTaglibGenerator;
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.ImmutableMap;
@@ -56,6 +57,7 @@
static final ImmutableMap<OutputType, Class<? extends CdkWriter>> WRITERS =
ImmutableMap.<OutputType, Class<? extends CdkWriter>>builder()
.put(StandardOutputs.COMPONENT_CLASSES, ComponentClassGenerator.class)
+ .put(StandardOutputs.TAG_LIBRARY, ValidatorTaglibGenerator.class)
.put(StandardOutputs.RENDERER_CLASSES, RendererClassGenerator.class)
.put(StandardOutputs.FACES_CONFIG, FacesConfigGenerator.class)
.build();
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2010-01-18 12:10:45 UTC (rev 16320)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -26,6 +26,7 @@
package org.richfaces.cdk.freemarker;
import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.ValidatorModel;
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.ObjectWrapper;
@@ -55,6 +56,8 @@
if (obj instanceof ComponentModel) {
templateModel = new ComponentTemplateModel((ComponentModel) obj, this);
+ } else if (obj instanceof ValidatorModel) {
+ templateModel = new ValidatorTemplateModel((ValidatorModel) obj, this);
} else {
templateModel = super.wrap(obj);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2010-01-18 12:10:45 UTC (rev 16320)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -72,6 +72,8 @@
value = getSetterName();
} else if ("name".equals(key)) {
value = getName();
+ } else if ("required".equals(key)) {
+ value = String.valueOf(this.property.isRequired());
} else {
return super.get(key);
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.freemarker;
+
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.StandardOutputs;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ValidatorModel;
+import org.richfaces.cdk.model.Visitable;
+
+import java.io.File;
+
+/**
+ * @author akolonitsky
+ * @since Jan 18, 2010
+ */
+public class ValidatorTaglibGenerator extends FreeMarkerRenderer<ValidatorModel, ComponentLibrary>{
+
+ @Override
+ protected String getOutputFile(ValidatorModel validatorModel) throws CdkException {
+ return validatorModel.getValidatorClass().getName().replace('.', File.separatorChar) + "-taglib.xml";
+ }
+
+ @Override
+ protected boolean isMyComponent(Visitable visitable) {
+ return visitable instanceof ValidatorModel;
+ }
+
+ @Override
+ protected String getTemplateName() {
+ return "taglib/validator.ftl";
+ }
+
+ @Override
+ protected CdkContext.OutputType getOutputType() {
+ return StandardOutputs.TAG_LIBRARY;
+ }
+}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTemplateModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTemplateModel.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTemplateModel.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.freemarker;
+
+import freemarker.ext.beans.BeanModel;
+import freemarker.ext.beans.BeansWrapper;
+import freemarker.template.TemplateModel;
+import freemarker.template.TemplateModelException;
+import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.model.ValidatorModel;
+
+import java.util.Set;
+import java.util.NoSuchElementException;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.List;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+import com.google.common.base.Predicate;
+
+/**
+ * @author akolonitsky
+ * @since Jan 18, 2010
+ */
+public class ValidatorTemplateModel extends BeanModel implements TemplateModel {
+ private final ValidatorModel component;
+ private Set<EventName> eventNames;
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param object
+ * @param wrapper
+ */
+ public ValidatorTemplateModel(ValidatorModel object, BeansWrapper wrapper) {
+ super(object, wrapper);
+ component = object;
+ }
+
+ @Override
+ public TemplateModel get(String key) throws TemplateModelException {
+ if ("attributes".equals(key)) {
+ return new PropertyMapModel(component.getAttributes(),wrapper);
+ } else if ("generatedAttributes".equals(key)) {
+ return generatedAttributes();
+ } else if ("eventNames".equals(key)) {
+ return eventNames();
+ } else if ("defaultEvent".equals(key)) {
+ return defaultEvent();
+ }
+
+ return super.get(key);
+ }
+
+ private TemplateModel eventNames() throws TemplateModelException {
+ Set<EventName> eventNames = getEventNames();
+
+ return wrapper.wrap(eventNames);
+ }
+
+ private TemplateModel defaultEvent() throws TemplateModelException {
+ Set<EventName> names = getEventNames();
+
+ try {
+ EventName defaultEvent = Iterables.find(names, new Predicate<EventName>() {
+ @Override
+ public boolean apply(EventName event) {
+ return event.isDefaultEvent();
+ }
+ });
+
+ return wrapper.wrap(defaultEvent);
+ } catch (NoSuchElementException e) {
+ return wrapper.wrap(null);
+ }
+ }
+
+ private Set<EventName> getEventNames() {
+ if (null == eventNames) {
+ eventNames = Sets.newHashSet();
+
+ for (Property property : component.getAttributes().values()) {
+ eventNames.addAll(property.getEventNames());
+ }
+ }
+
+ return eventNames;
+ }
+
+ private TemplateModel generatedAttributes() throws TemplateModelException {
+ List<PropertyModel> models = new ArrayList<PropertyModel>(component.getAttributes().size());
+ for (Map.Entry<String, Property> entry : component.getAttributes().entrySet()) {
+ if(entry.getValue().isGenerate()){
+ models.add(new PropertyModel(entry.getKey(), entry.getValue(), wrapper));
+ }
+ }
+ return wrapper.wrap(models);
+ }
+ private TemplateModel attributes() throws TemplateModelException {
+ List<PropertyModel> models = new ArrayList<PropertyModel>(component.getAttributes().size());
+ for (Map.Entry<String, Property> entry : component.getAttributes().entrySet()) {
+ models.add(new PropertyModel(entry.getKey(), entry.getValue(), wrapper));
+ }
+ return wrapper.wrap(models);
+ }
+
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-01-18 12:10:45 UTC (rev 16320)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -25,6 +25,9 @@
package org.richfaces.cdk.model;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.model.RenderKitModel.Id;
+
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
@@ -35,13 +38,6 @@
import java.util.Map;
import java.util.NoSuchElementException;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.model.RenderKitModel.Id;
-
/**
* <p class="changed_added_4_0">
* That class contains model of all JSF components asscoiated with that project
@@ -54,13 +50,13 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlRootElement(name = "faces-config", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
-@XmlType(namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE, name = "faces-configType")
public class ComponentLibrary implements Serializable, Extensible<ConfigExtension>, Trackable {
public static final String CDK_EXTENSIONS_NAMESPACE = "http://richfaces.org/cdk/extensions";
public static final String FACES_CONFIG_NAMESPACE = "http://java.sun.com/xml/ns/javaee";
public static final String FACES_CONFIG_SCHEMA_LOCATION =
"http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd";
+ public static final String TAGLIB_SCHEMA_LOCATION =
+ "http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd";
/**
* <p class="changed_added_4_0">
@@ -147,7 +143,6 @@
*
* @return the components
*/
- @XmlElement
public Collection<ComponentModel> getComponents() {
return components;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-01-18 12:10:45 UTC (rev 16320)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -1,27 +1,20 @@
package org.richfaces.cdk.model;
+import org.richfaces.cdk.CdkException;
+
import java.util.Collection;
import java.util.Map;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElements;
-import javax.xml.bind.annotation.XmlType;
-
-import org.richfaces.cdk.CdkException;
-
/**
* That class represents JSF component in the CDK.
* That is mapped to faces-config "component" element.
* @author asmirnov(a)exadel.com
*
*/
-@SuppressWarnings("serial")
-@XmlType(name = "faces-config-componentType")
-(a)XmlAccessorType(XmlAccessType.NONE)
public final class ComponentModel extends ModelElementBase implements ModelElement<ComponentModel> {
+ private static final long serialVersionUID = 2297349356280370771L;
+
/**
* <p class="changed_added_4_0">Is that component c</p>
*/
@@ -108,12 +101,10 @@
if(null != getType() && null != other.getType()){
// Both types not null, compare them.
return getType().equals(other.getType());
- }
- // one or both types are null, compare classes.
- if(null != getComponentClass() && getComponentClass().equals(other.getComponentClass())){
- return true;
}
- return false;
+
+ // one or both types are null, compare classes.
+ return null != getComponentClass() && getComponentClass().equals(other.getComponentClass());
}
/**
* <p class="changed_added_4_0"></p>
@@ -123,7 +114,6 @@
this.type = type;
}
- @XmlElement(name = "component-type", required = true)
public Type getType() {
return type;
}
@@ -170,7 +160,6 @@
* @param componentClass
* the componentClass to set
*/
- @XmlElement(name = "component-class")
public void setComponentClass(ClassDescription componentClass) {
this.componentClass = componentClass;
}
@@ -221,16 +210,12 @@
*
* @return the attributes
*/
- @XmlElements({@XmlElement(name = "property", type = Property.class) ,
- @XmlElement(name = "attribute", type = AttributeModel.class) })
public Map<String,Property> getAttributes() {
return attributes;
}
public Property addAttribute(String attributeName) {
- Property attribute;
-
- attribute = attributes.get(attributeName);
+ Property attribute = attributes.get(attributeName);
if(null == attribute){
attribute = new Property();
attributes.put(attributeName, attribute);
@@ -283,6 +268,8 @@
}
public static class Type extends Key {
+ private static final long serialVersionUID = -6968199073379187423L;
+
public Type(String type) {
super(type);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java 2010-01-18 12:10:45 UTC (rev 16320)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -25,8 +25,6 @@
import org.richfaces.cdk.CdkException;
-import javax.xml.bind.annotation.XmlElements;
-import javax.xml.bind.annotation.XmlElement;
import java.util.Map;
/**
@@ -88,8 +86,6 @@
*
* @return the attributes
*/
- @XmlElements({@XmlElement(name = "property", type = Property.class) ,
- @XmlElement(name = "attribute", type = AttributeModel.class) })
public Map<String,Property> getAttributes() {
return attributes;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2010-01-18 12:10:45 UTC (rev 16320)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -1,7 +1,5 @@
package org.richfaces.cdk.model;
-import javax.xml.bind.annotation.XmlElement;
-
/**
* <p class="changed_added_4_0">Base class for the most JSF components taht have description
* attributes and support extensions in faces-config.</p>
@@ -36,7 +34,6 @@
super();
}
- @XmlElement
public final String getDescription() {
return description;
}
@@ -45,7 +42,6 @@
this.description = description;
}
- @XmlElement(name = "display-name")
public final String getDisplayname() {
return displayname;
}
@@ -54,7 +50,6 @@
this.displayname = displayname;
}
- @XmlElement
public final Icon getIcon() {
return icon;
}
@@ -68,7 +63,6 @@
*
* @return the extension
*/
- @XmlElement(name = "component-extensions")
public final ConfigExtension getExtension() {
return extension;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2010-01-18 12:10:45 UTC (rev 16320)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -36,9 +36,10 @@
* @author asmirnov(a)exadel.com
*
*/
-@SuppressWarnings("serial")
public class Property extends ModelElementBase implements ModelElement<Property> {
+ private static final long serialVersionUID = 3483864006602184580L;
+
/**
* <p class="changed_added_4_0">Is that bean property generate in the class or should be generated ?</p>
*/
@@ -58,7 +59,6 @@
/**
* <p class="changed_added_4_0"></p>
- * @param name
*/
public Property() {
}
@@ -91,7 +91,7 @@
/**
* <p class="changed_added_4_0"></p>
- * @param defaultValue the defaultValue to set
+ * @param dafaultValue - the defaultValue to set
*/
public void setDefaultValue(String dafaultValue) {
this.defaultValue = dafaultValue;
@@ -125,7 +125,7 @@
/**
* <p class="changed_added_4_0"></p>
- * @param generate the generate to set
+ * @param exists - the generate to set
*/
public void setGenerate(boolean exists) {
this.generate = exists;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java 2010-01-18 12:10:45 UTC (rev 16320)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -78,12 +78,6 @@
this.converterClass = converterClass;
}
- @XmlElement(name = "converter-extension", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @Override
- public ConverterExtension getExtension() {
- return super.getExtension();
- }
-
/**
* <p class="changed_added_4_0"></p>
*
@@ -98,7 +92,6 @@
namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
type = AttributeBean.class
)})
-
public List<PropertyBase> getAttributes() {
return attributes;
}
@@ -117,8 +110,11 @@
super.setExtension(extension);
}
- public static class ConverterExtension extends ConfigExtension {
-
+ @XmlElement(name = "converter-extension", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE, nillable = true)
+ @Override
+ public ConverterExtension getExtension() {
+ return super.getExtension();
}
+ public static class ConverterExtension extends ConfigExtension { }
}
Added: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taglib/validator.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taglib/validator.ftl (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taglib/validator.ftl 2010-01-18 14:30:05 UTC (rev 16321)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd" version="2.0">
+ <tag>
+ <validator>
+ <validator-id>${validatorId}</validator-id>
+ <handler-class>${validatorClass}</handler-class>
+ </validator>
+
+ <#list generatedAttributes as attribute>
+ <attribute>
+ <#if attribute.description?exists>
+ <description>${attribute.description}</description>
+ </#if>
+ <name>${attribute.name}</name>
+ <type>${attribute.type}</type>
+ <required>${attribute.required}</required>
+ </attribute>
+ </#list>
+ </tag>
+</facelet-taglib>
\ No newline at end of file
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -0,0 +1,149 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.freemarker;
+
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.Validator;
+import static org.easymock.EasyMock.*;
+import org.junit.Assert;
+import org.junit.Test;
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.model.ValidatorModel;
+import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import javax.faces.component.UIOutput;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Set;
+
+/**
+ * @author akolonitsky
+ * @since Jan 18, 2010
+ */
+public class ValidatorTaglibGeneratorTest extends CdkTestBase {
+
+ /**
+ * Test method for {@link org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}.
+ * @throws Exception
+ */
+ @Test
+ public void testGetOutputFileComponent() throws Exception {
+ final StringWriter output = new StringWriter();
+ ValidatorTaglibGenerator generator = new ValidatorTaglibGenerator() {
+ @Override
+ protected Writer getOutput(ValidatorModel c) throws CdkException {
+ return output;
+ }
+ };
+
+ CdkContext mockContext = createMockContext();
+ generator.init(mockContext);
+
+ ValidatorModel validator = new ValidatorModel("foo.bar", new ClassDescription(UIOutput.class));
+ validator.setGenerate(true);
+
+ addAttribute(validator, "testValue", Object.class, true);
+ addAttribute(validator, "testFlag", boolean.class, true);
+ Property attribute = addAttribute(validator, "id", String.class, false);
+
+ Set<EventName> eventNames = attribute.getEventNames();
+ eventNames.add(getEvent("id", false));
+ eventNames.add(getEvent("action", true));
+
+ ComponentLibrary library = new ComponentLibrary();
+ library.getValidators().add(validator);
+ generator.visit(validator, library);
+
+ System.out.println(output);
+ verify(mockContext);
+
+ checkXmlStructure(output);
+
+ // TODO validate xml by xsd
+// validateXml(output);
+ }
+
+ private EventName getEvent(String name, boolean defaultEvent) {
+ EventName event = new EventName();
+ event.setName(name);
+ event.setDefaultEvent(defaultEvent);
+ return event;
+ }
+
+ private Property addAttribute(ValidatorModel validator, String attributeName, Class<?> type, boolean generate) {
+ Property attribute = validator.addAttribute(attributeName);
+ attribute.setType(new ClassDescription(type));
+ attribute.setGenerate(generate);
+ return attribute;
+ }
+
+ private CdkContext createMockContext() throws Exception {
+ CdkContext cdkContext = createMock(CdkContext.class);
+
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((org.richfaces.cdk.CdkContext.OutputType) anyObject())).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
+ replay(cdkContext);
+
+ return cdkContext;
+ }
+
+ // TODO move it in other class
+ protected void validateXml(StringWriter facesConfig) throws SAXException, IOException {
+ InputSource is = new InputSource(new StringReader(facesConfig.toString()));
+ Validator validator = new Validator(is);
+ validator.useXMLSchema(true);
+ InputSource source = new CdkEntityResolver(null)
+ .resolveEntity(null, ComponentLibrary.TAGLIB_SCHEMA_LOCATION);
+ validator.setJAXP12SchemaSource(source);
+
+ validator.assertIsValid();
+ }
+
+ protected void checkXmlStructure(StringWriter writer) throws SAXException, IOException {
+ Class<?> testClass = this.getClass();
+ InputStream expectedFacesConfigFile = testClass.getResourceAsStream(testClass.getSimpleName() + ".xml");
+ if (expectedFacesConfigFile == null) {
+ return;
+ }
+
+ Diff xmlDiff = new Diff(
+ new StringReader(writer.toString()),
+ new InputStreamReader(expectedFacesConfigFile));
+
+ Assert.assertTrue("XML was not similar", xmlDiff.similar());
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-01-18 12:10:45 UTC (rev 16320)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -29,11 +29,18 @@
import java.io.StringWriter;
import java.io.Writer;
+import java.io.Reader;
+import java.io.LineNumberReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.InputStreamReader;
import java.util.Set;
import javax.faces.component.UIOutput;
import org.junit.Test;
+import org.junit.Assert;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkTestBase;
@@ -43,6 +50,8 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.Property;
+import org.xml.sax.SAXException;
+import org.custommonkey.xmlunit.Diff;
/**
* <p class="changed_added_4_0"></p>
@@ -80,7 +89,7 @@
attribute.setType(new ClassDescription(Object.class));
attribute.setGenerate(true);
attribute = component.addAttribute("testFlag");
- attribute.setType(new ClassDescription(boolean.class));
+ attribute.setType(new ClassDescription(Boolean.class));
attribute.setGenerate(true);
attribute = component.addAttribute("id");
attribute.setType(new ClassDescription(String.class));
@@ -96,10 +105,10 @@
eventNames.add(event);
attribute.setGenerate(false);
generator.visit(component, library);
- System.out.println(output);
+// System.out.println(output);
verify(mockContext);
- // TODO - check generated file.
+ compare(output, "UIBar.java");
}
private CdkContext createMockContext() throws Exception {
@@ -112,4 +121,35 @@
return cdkContext;
}
+
+ private void compare(StringWriter writer, String fileName) throws IOException {
+ InputStream expectedFacesConfigFile = this.getClass().getResourceAsStream(fileName);
+ Assert.assertNotNull("File ("+fileName+") with expected result wasn't found.", expectedFacesConfigFile);
+
+ compareTextFiles(
+ new StringReader(writer.toString()),
+ new InputStreamReader(expectedFacesConfigFile));
+ }
+
+ public static void compareTextFiles(Reader reference, Reader output) throws IOException {
+ LineNumberReader ref = new LineNumberReader(reference);
+ LineNumberReader out = new LineNumberReader(output);
+ String refLine = "", outLine = "";
+ while (refLine != null || outLine != null) {
+ if (refLine == null) {
+ Assert.fail("Output text is longer than reference text");
+ }
+ if (outLine == null) {
+ Assert.fail("Output text is shorter than reference text");
+ }
+
+ refLine = ref.readLine();
+ outLine = out.readLine();
+
+ if (refLine != null && outLine != null && !refLine.trim().equals(outLine.trim())) {
+ Assert.fail("Difference found on line " + ref.getLineNumber()
+ + ".\nReference text is: " + refLine + "\nOutput text is: " + outLine);
+ }
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java 2010-01-18 12:10:45 UTC (rev 16320)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -38,7 +38,7 @@
public class ConverterBeanTest extends ModelBeanTest {
@Test
- public void testMarshalResultStringT() throws Exception {
+ public void testMarshal() throws Exception {
ComponentLibrary library = new ComponentLibrary();
ConverterModel converterModel = new ConverterModel("my_converter", new ClassDescription(Object.class));
Added: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.xml
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.xml (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.xml 2010-01-18 14:30:05 UTC (rev 16321)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd" version="2.0">
+ <tag>
+ <validator>
+ <validator-id>foo.bar</validator-id>
+ <handler-class>javax.faces.component.UIOutput</handler-class>
+ </validator>
+
+ <attribute>
+ <name>testValue</name>
+ <type>java.lang.Object</type>
+ <required>false</required>
+ </attribute>
+ <attribute>
+ <name>testFlag</name>
+ <type>boolean</type>
+ <required>false</required>
+ </attribute>
+ </tag>
+</facelet-taglib>
Added: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/UIBar.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/UIBar.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/UIBar.java 2010-01-18 14:30:05 UTC (rev 16321)
@@ -0,0 +1,95 @@
+/*
+ * $Id: component.ftl 16229 2009-12-29 21:36:27Z alexsmirnov $
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package foo.bar;
+
+// Import declarations
+import javax.annotation.Generated;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
+/**
+ *
+ **/
+@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
+public class UIBar extends javax.faces.component.UIOutput implements ClientBehaviorHolder {
+
+
+ public static final String COMPONENT_TYPE="foo.bar";
+
+
+ private static final Collection<String> EVENT_NAMES = Collections.unmodifiableCollection(Arrays.asList(
+ "id",
+ "action"
+
+ ));
+ public Collection<String> getEventNames() {
+ return EVENT_NAMES; }
+
+
+ public String getDefaultEventName() {
+ return "action";
+ }
+ protected enum Properties {
+ testValue,
+ testFlag
+
+ ;
+ }
+
+ /**
+ *
+ **/
+ public java.lang.Object getTestValue(){
+ return (java.lang.Object)getStateHelper().eval(Properties.testValue);
+ }
+
+ /**
+ * Setter for testValue
+ **/
+ public void setTestValue(java.lang.Object testValue){
+ getStateHelper().put(Properties.testValue,testValue);
+ }
+ /**
+ *
+ **/
+ public java.lang.Boolean isTestFlag(){
+ return (java.lang.Boolean)getStateHelper().eval(Properties.testFlag);
+ }
+
+ /**
+ * Setter for testFlag
+ **/
+ public void setTestFlag(java.lang.Boolean testFlag){
+ getStateHelper().put(Properties.testFlag,testFlag);
+ }
+
+}
14 years, 3 months
JBoss Rich Faces SVN: r16320 - branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-01-18 07:10:45 -0500 (Mon, 18 Jan 2010)
New Revision: 16320
Modified:
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java
Log:
- added one more PERMISSION_DENIED type of error message
Modified: branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java
===================================================================
--- branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java 2010-01-18 12:08:37 UTC (rev 16319)
+++ branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java 2010-01-18 12:10:45 UTC (rev 16320)
@@ -37,7 +37,8 @@
"ERROR: Threw an exception: Error executing strategy function jquery: Permission denied",
"ERROR: Threw an exception: Permission denied",
"ERROR: Threw an exception: Object doesn't support this property or method",
- "ERROR: Command execution failure. Please search the forum at http://clearspace.openqa.org for error details from the log window. The error message is: Permission denied" };
+ "ERROR: Command execution failure. Please search the forum at http://clearspace.openqa.org for error details from the log window. The error message is: Permission denied",
+ "ERROR: Threw an exception: null property value" };
private <T> T doAjax(final AjaxCommand<T> ajaxCommand) {
final AssertionError fail = new AssertionError("Fails with Permission denied when trying to execute jQuery");
14 years, 3 months
JBoss Rich Faces SVN: r16319 - in branches/sandbox/rf-demo-ftest-iexplore/src/test: java/org/jboss/richfaces/integrationTest/status and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-01-18 07:08:37 -0500 (Mon, 18 Jan 2010)
New Revision: 16319
Modified:
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/SeleniumLoggingTestListener.java
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/status/StatusTestCase.java
branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/org/jboss/richfaces/integrationTest/status/messages.properties
branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/testng.xml
Log:
- merge of changes in branch community/3.3.X to locally - r16305 through r16318
Modified: branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/SeleniumLoggingTestListener.java
===================================================================
--- branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/SeleniumLoggingTestListener.java 2010-01-18 12:00:58 UTC (rev 16318)
+++ branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/SeleniumLoggingTestListener.java 2010-01-18 12:08:37 UTC (rev 16319)
@@ -29,14 +29,14 @@
import org.testng.ITestResult;
import org.testng.TestListenerAdapter;
-import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.Selenium;
/**
* Class determined to logging into Selenium Server's logs server.log via the
- * DefaultSelenium.getEval(String) method which will evaluate JavaScript
+ * Selenium.getEval(String) method which will evaluate JavaScript
* comment.
*
- * You must rewrite the DefaultSelenium selenium property to allow logging
+ * You must rewrite the Selenium selenium property to allow logging
* facility.
*
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
@@ -48,13 +48,13 @@
/**
* Must be specified to allow the logging facility
*/
- private DefaultSelenium selenium;
+ private Selenium selenium;
- public void setSelenium(DefaultSelenium selenium) {
+ public void setSelenium(Selenium selenium) {
this.selenium = selenium;
}
- public DefaultSelenium getSelenium() {
+ public Selenium getSelenium() {
return selenium;
}
@@ -80,7 +80,7 @@
/**
* This method will output method name and status into Selenium Server's log
- * server.log via the DefaultSelenium.getEval(String) method which will
+ * server.log via the Selenium.getEval(String) method which will
* evaluate JavaScript comment
*
* @param result
Modified: branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/status/StatusTestCase.java
===================================================================
--- branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/status/StatusTestCase.java 2010-01-18 12:00:58 UTC (rev 16318)
+++ branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/status/StatusTestCase.java 2010-01-18 12:08:37 UTC (rev 16319)
@@ -21,17 +21,20 @@
*******************************************************************************/
package org.jboss.richfaces.integrationTest.status;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.fail;
+
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
import org.jboss.test.selenium.dom.Event;
-import org.jboss.test.selenium.waiting.Condition;
-import static org.testng.Assert.*;
-
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import com.thoughtworks.selenium.SeleniumException;
+
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
@@ -45,7 +48,6 @@
private final String LOC_INPUT_JOB = getLoc("INPUT_JOB");
private final String LOC_OUTPUT_TEXT = getLoc("OUTPUT_TEXT");
- private final String MSG_STYLE_DISPLAY = getMsg("STYLE_DISPLAY");
private final String MSG_PATTERN_NAME_JOB = getMsg("PATTERN_NAME_JOB");
/**
@@ -59,8 +61,6 @@
* This version using text like a status message for user.
* </p>
*/
- // TODO investigate JavaScript injecting to fix this, see
- // https://jira.jboss.org/jira/browse/JBQA-2606
@Test
public void testTextStatus() {
doStatusTesting(0);
@@ -75,8 +75,6 @@
* This version using image like a status message for user.
* </p>
*/
- // TODO investigate JavaScript injecting to fix this, see
- // https://jira.jboss.org/jira/browse/JBQA-2606
@Test
public void testImageStatus() {
doStatusTesting(1);
@@ -98,29 +96,21 @@
final String locButtonRequest = format(LOC_BUTTON_REQUEST_PREFORMATTED, testNumber);
assertFalse(isDisplayed(locOutputStatusMessage), "Status message should not be visible at start.");
-
- // prepare both needed conditions for waiting so that it will be faster
- Condition styleCondition = new Condition() {
- public boolean isTrue() {
- return isDisplayed(locOutputStatusMessage);
- }
- };
-
- Condition styleConditionNot = new Condition() {
- public boolean isTrue() {
- return !isDisplayed(locOutputStatusMessage);
- }
- };
-
- selenium.click(locButtonRequest);
-
- // wait for style is changed to "processing" state indicates that
- // request is in progress
- waitModelUpdate.interval(0).failWith("Test timeouted when waiting for request moves to processing state.").until(styleCondition);
- // wait for style is changed back to initial state after request is
- // complete
- waitModelUpdate.interval(0).failWith("Timeout when waiting for request moves to complete state.").until(styleConditionNot);
+ for (int i = 0; i < 20; i++) {
+ selenium.click(locButtonRequest);
+ try {
+ selenium.waitForCondition(format("jqFind('{0}').is(':visible')", locOutputStatusMessage.replaceFirst(
+ "^jquery=", "")), "500");
+ } catch (SeleniumException e) {
+ if (e.getMessage().startsWith("Timed out")) {
+ continue;
+ }
+ throw e;
+ }
+ selenium.waitForCondition(format("jqFind('{0}').is(':hidden')", locOutputStatusMessage.replaceFirst("^jquery=", "")), "5000");
+ break;
+ }
}
/**
@@ -133,8 +123,6 @@
* Watches the correct output value.
* </p>
*/
- // TODO investigate JavaScript injecting to fix testInputsStatus, see
- // https://jira.jboss.org/jira/browse/JBQA-2606
@Test
public void testInputsStatus() {
scrollIntoView(format(LOC_FIELDSET_PAGE_PART_PREFORMATTED, 2), true);
@@ -151,19 +139,6 @@
assertFalse(isDisplayed(locOutputStatusMessage), "Status message should not be visible at start.");
- // prepare both needed conditions for waiting so that it will be faster
- Condition styleCondition = new Condition() {
- public boolean isTrue() {
- return isDisplayed(locOutputStatusMessage);
- }
- };
-
- Condition styleConditionNot = new Condition() {
- public boolean isTrue() {
- return !isDisplayed(locOutputStatusMessage);
- }
- };
-
// cycle over 30 chars and alternating between two inputs
for (int counter = 1; counter <= 15; counter++) {
// select input and it's buffered text by state of counter
@@ -175,15 +150,24 @@
selenium.type(selectedInput, selectedText.toString());
selenium.fireEvent(selectedInput, Event.KEYUP);
-
- // wait for style is changed to "processing" state indicates that
- // request is in progress
- waitModelUpdate.interval(0).failWith("Test timeouted when waiting for request moves to processing state.").until(styleCondition);
- // wait for style is changed back to initial state after request is
- // complete
- waitModelUpdate.interval(0).failWith("Timeout when waiting for request moves to complete state.").until(styleConditionNot);
-
+ try {
+ // wait for style is changed to "processing" state indicates
+ // that request is in progress
+ selenium.waitForCondition(format("jqFind('{0}').is(':visible')", locOutputStatusMessage.replaceFirst(
+ "^jquery=", "")), "500");
+ } catch (SeleniumException e) {
+ // we can found that the request is so fast we cannot catch the
+ // element in visible state
+ if (!e.getMessage().startsWith("Timed out")) {
+ throw e;
+ }
+ }
+ // wait for element is back to hidden state after request is
+ // complete
+ selenium.waitForCondition(format("jqFind('{0}').is(':hidden')", locOutputStatusMessage.replaceFirst(
+ "^jquery=", "")), "5000");
+
String outputText = selenium.getText(LOC_OUTPUT_TEXT);
// matches output to pattern declared above?
@@ -201,29 +185,6 @@
}
}
- /**
- * Wait for display-style changes to specified initial (resp. other than
- * initial) value depending on what we want.
- *
- * @param locator
- * of element we want watch
- * @param initialStyle
- * initial display-style value
- * @param shouldEqualOldValue
- * if true, wait for element's display-style became initialStyle;
- * if false, wait for element's display-style became other than
- * initialStyle
- */
- private void waitForDisplayChanges(final String locator, final String initialStyle,
- final boolean shouldEqualOldValue) {
- waitModelUpdate.interval(0).until(new Condition() {
- public boolean isTrue() {
- String actualStyle = getStyle(locator, MSG_STYLE_DISPLAY);
- return !shouldEqualOldValue ^ initialStyle.equals(actualStyle);
- }
- });
- }
-
protected void loadPage() {
openComponent("Status");
openTab("Usage");
Modified: branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/org/jboss/richfaces/integrationTest/status/messages.properties
===================================================================
--- branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/org/jboss/richfaces/integrationTest/status/messages.properties 2010-01-18 12:00:58 UTC (rev 16318)
+++ branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/org/jboss/richfaces/integrationTest/status/messages.properties 2010-01-18 12:08:37 UTC (rev 16319)
@@ -1,2 +1 @@
-STYLE_DISPLAY=display
-PATTERN_NAME_JOB=^Name: (\\w*), Job: (\\w*)\\s*$
\ No newline at end of file
+PATTERN_NAME_JOB=^Name\: (\\w*), Job\: (\\w*)\\s*$
\ No newline at end of file
Modified: branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/testng.xml
===================================================================
--- branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/testng.xml 2010-01-18 12:00:58 UTC (rev 16318)
+++ branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/testng.xml 2010-01-18 12:08:37 UTC (rev 16319)
@@ -510,11 +510,11 @@
</classes>
</test>
-<!-- <test name="org.jboss.richfaces.integrationTest.status.StatusTestCase">-->
-<!-- <classes>-->
-<!-- <class name="org.jboss.richfaces.integrationTest.status.StatusTestCase" />-->
-<!-- </classes>-->
-<!-- </test>-->
+ <test name="org.jboss.richfaces.integrationTest.status.StatusTestCase">
+ <classes>
+ <class name="org.jboss.richfaces.integrationTest.status.StatusTestCase" />
+ </classes>
+ </test>
<test name="org.jboss.richfaces.integrationTest.style.StyleTestCase">
<classes>
14 years, 3 months
JBoss Rich Faces SVN: r16318 - in branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test: resources and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-01-18 07:00:58 -0500 (Mon, 18 Jan 2010)
New Revision: 16318
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/status/StatusTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/status/messages.properties
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/testng.xml
Log:
- StatusTestCase - use JavaScript implementation of waiting to change of status message's visibility (JBQA-2606)
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/status/StatusTestCase.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/status/StatusTestCase.java 2010-01-18 11:58:09 UTC (rev 16317)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/status/StatusTestCase.java 2010-01-18 12:00:58 UTC (rev 16318)
@@ -21,17 +21,20 @@
*******************************************************************************/
package org.jboss.richfaces.integrationTest.status;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.fail;
+
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
import org.jboss.test.selenium.dom.Event;
-import org.jboss.test.selenium.waiting.Condition;
-import static org.testng.Assert.*;
-
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import com.thoughtworks.selenium.SeleniumException;
+
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
@@ -45,7 +48,6 @@
private final String LOC_INPUT_JOB = getLoc("INPUT_JOB");
private final String LOC_OUTPUT_TEXT = getLoc("OUTPUT_TEXT");
- private final String MSG_STYLE_DISPLAY = getMsg("STYLE_DISPLAY");
private final String MSG_PATTERN_NAME_JOB = getMsg("PATTERN_NAME_JOB");
/**
@@ -59,8 +61,6 @@
* This version using text like a status message for user.
* </p>
*/
- // TODO investigate JavaScript injecting to fix this, see
- // https://jira.jboss.org/jira/browse/JBQA-2606
@Test
public void testTextStatus() {
doStatusTesting(0);
@@ -75,8 +75,6 @@
* This version using image like a status message for user.
* </p>
*/
- // TODO investigate JavaScript injecting to fix this, see
- // https://jira.jboss.org/jira/browse/JBQA-2606
@Test
public void testImageStatus() {
doStatusTesting(1);
@@ -98,29 +96,21 @@
final String locButtonRequest = format(LOC_BUTTON_REQUEST_PREFORMATTED, testNumber);
assertFalse(isDisplayed(locOutputStatusMessage), "Status message should not be visible at start.");
-
- // prepare both needed conditions for waiting so that it will be faster
- Condition styleCondition = new Condition() {
- public boolean isTrue() {
- return isDisplayed(locOutputStatusMessage);
- }
- };
-
- Condition styleConditionNot = new Condition() {
- public boolean isTrue() {
- return !isDisplayed(locOutputStatusMessage);
- }
- };
-
- selenium.click(locButtonRequest);
-
- // wait for style is changed to "processing" state indicates that
- // request is in progress
- waitModelUpdate.interval(0).failWith("Test timeouted when waiting for request moves to processing state.").until(styleCondition);
- // wait for style is changed back to initial state after request is
- // complete
- waitModelUpdate.interval(0).failWith("Timeout when waiting for request moves to complete state.").until(styleConditionNot);
+ for (int i = 0; i < 20; i++) {
+ selenium.click(locButtonRequest);
+ try {
+ selenium.waitForCondition(format("jqFind('{0}').is(':visible')", locOutputStatusMessage.replaceFirst(
+ "^jquery=", "")), "500");
+ } catch (SeleniumException e) {
+ if (e.getMessage().startsWith("Timed out")) {
+ continue;
+ }
+ throw e;
+ }
+ selenium.waitForCondition(format("jqFind('{0}').is(':hidden')", locOutputStatusMessage.replaceFirst("^jquery=", "")), "5000");
+ break;
+ }
}
/**
@@ -133,8 +123,6 @@
* Watches the correct output value.
* </p>
*/
- // TODO investigate JavaScript injecting to fix testInputsStatus, see
- // https://jira.jboss.org/jira/browse/JBQA-2606
@Test
public void testInputsStatus() {
scrollIntoView(format(LOC_FIELDSET_PAGE_PART_PREFORMATTED, 2), true);
@@ -151,19 +139,6 @@
assertFalse(isDisplayed(locOutputStatusMessage), "Status message should not be visible at start.");
- // prepare both needed conditions for waiting so that it will be faster
- Condition styleCondition = new Condition() {
- public boolean isTrue() {
- return isDisplayed(locOutputStatusMessage);
- }
- };
-
- Condition styleConditionNot = new Condition() {
- public boolean isTrue() {
- return !isDisplayed(locOutputStatusMessage);
- }
- };
-
// cycle over 30 chars and alternating between two inputs
for (int counter = 1; counter <= 15; counter++) {
// select input and it's buffered text by state of counter
@@ -175,15 +150,24 @@
selenium.type(selectedInput, selectedText.toString());
selenium.fireEvent(selectedInput, Event.KEYUP);
-
- // wait for style is changed to "processing" state indicates that
- // request is in progress
- waitModelUpdate.interval(0).failWith("Test timeouted when waiting for request moves to processing state.").until(styleCondition);
- // wait for style is changed back to initial state after request is
- // complete
- waitModelUpdate.interval(0).failWith("Timeout when waiting for request moves to complete state.").until(styleConditionNot);
-
+ try {
+ // wait for style is changed to "processing" state indicates
+ // that request is in progress
+ selenium.waitForCondition(format("jqFind('{0}').is(':visible')", locOutputStatusMessage.replaceFirst(
+ "^jquery=", "")), "500");
+ } catch (SeleniumException e) {
+ // we can found that the request is so fast we cannot catch the
+ // element in visible state
+ if (!e.getMessage().startsWith("Timed out")) {
+ throw e;
+ }
+ }
+ // wait for element is back to hidden state after request is
+ // complete
+ selenium.waitForCondition(format("jqFind('{0}').is(':hidden')", locOutputStatusMessage.replaceFirst(
+ "^jquery=", "")), "5000");
+
String outputText = selenium.getText(LOC_OUTPUT_TEXT);
// matches output to pattern declared above?
@@ -201,29 +185,6 @@
}
}
- /**
- * Wait for display-style changes to specified initial (resp. other than
- * initial) value depending on what we want.
- *
- * @param locator
- * of element we want watch
- * @param initialStyle
- * initial display-style value
- * @param shouldEqualOldValue
- * if true, wait for element's display-style became initialStyle;
- * if false, wait for element's display-style became other than
- * initialStyle
- */
- private void waitForDisplayChanges(final String locator, final String initialStyle,
- final boolean shouldEqualOldValue) {
- waitModelUpdate.interval(0).until(new Condition() {
- public boolean isTrue() {
- String actualStyle = getStyle(locator, MSG_STYLE_DISPLAY);
- return !shouldEqualOldValue ^ initialStyle.equals(actualStyle);
- }
- });
- }
-
@SuppressWarnings("unused")
@BeforeMethod
private void loadPage() {
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/status/messages.properties
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/status/messages.properties 2010-01-18 11:58:09 UTC (rev 16317)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/status/messages.properties 2010-01-18 12:00:58 UTC (rev 16318)
@@ -1,2 +1 @@
-STYLE_DISPLAY=display
-PATTERN_NAME_JOB=^Name: (\\w*), Job: (\\w*)\\s*$
\ No newline at end of file
+PATTERN_NAME_JOB=^Name\: (\\w*), Job\: (\\w*)\\s*$
\ No newline at end of file
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/testng.xml
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/testng.xml 2010-01-18 11:58:09 UTC (rev 16317)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/testng.xml 2010-01-18 12:00:58 UTC (rev 16318)
@@ -501,13 +501,11 @@
</classes>
</test>
- <!--
- <test
- name="org.jboss.richfaces.integrationTest.status.StatusTestCase">
- <classes> <class
- name="org.jboss.richfaces.integrationTest.status.StatusTestCase" />
- </classes> </test>
- -->
+ <test name="org.jboss.richfaces.integrationTest.status.StatusTestCase">
+ <classes>
+ <class name="org.jboss.richfaces.integrationTest.status.StatusTestCase" />
+ </classes>
+ </test>
<test name="org.jboss.richfaces.integrationTest.style.StyleTestCase">
<classes>
14 years, 3 months
JBoss Rich Faces SVN: r16317 - branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-01-18 06:58:09 -0500 (Mon, 18 Jan 2010)
New Revision: 16317
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/SeleniumLoggingTestListener.java
Log:
- follow changes in richfaces-selenium (RFPL-333)
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/SeleniumLoggingTestListener.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/SeleniumLoggingTestListener.java 2010-01-18 11:56:43 UTC (rev 16316)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/SeleniumLoggingTestListener.java 2010-01-18 11:58:09 UTC (rev 16317)
@@ -29,14 +29,14 @@
import org.testng.ITestResult;
import org.testng.TestListenerAdapter;
-import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.Selenium;
/**
* Class determined to logging into Selenium Server's logs server.log via the
- * DefaultSelenium.getEval(String) method which will evaluate JavaScript
+ * Selenium.getEval(String) method which will evaluate JavaScript
* comment.
*
- * You must rewrite the DefaultSelenium selenium property to allow logging
+ * You must rewrite the Selenium selenium property to allow logging
* facility.
*
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
@@ -48,13 +48,13 @@
/**
* Must be specified to allow the logging facility
*/
- private DefaultSelenium selenium;
+ private Selenium selenium;
- public void setSelenium(DefaultSelenium selenium) {
+ public void setSelenium(Selenium selenium) {
this.selenium = selenium;
}
- public DefaultSelenium getSelenium() {
+ public Selenium getSelenium() {
return selenium;
}
@@ -80,7 +80,7 @@
/**
* This method will output method name and status into Selenium Server's log
- * server.log via the DefaultSelenium.getEval(String) method which will
+ * server.log via the Selenium.getEval(String) method which will
* evaluate JavaScript comment
*
* @param result
14 years, 3 months
JBoss Rich Faces SVN: r16316 - branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-01-18 06:56:43 -0500 (Mon, 18 Jan 2010)
New Revision: 16316
Modified:
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/AbstractSeleniumTestCase.java
Log:
- richfaces-selenium: change selenium object from class to interface which implements (RFPL-333)
Modified: branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/AbstractSeleniumTestCase.java
===================================================================
--- branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/AbstractSeleniumTestCase.java 2010-01-18 09:57:23 UTC (rev 16315)
+++ branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/AbstractSeleniumTestCase.java 2010-01-18 11:56:43 UTC (rev 16316)
@@ -37,7 +37,7 @@
import org.jboss.test.selenium.waiting.Wait;
import org.testng.Assert;
-import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.Selenium;
import com.thoughtworks.selenium.SeleniumException;
/**
@@ -51,7 +51,7 @@
protected Properties locatorsProperties;
protected Properties messagesProperties;
- protected DefaultSelenium selenium;
+ protected Selenium selenium;
/**
* Generic timeout in miliseconds used in every selenium function
* waitForPageToLoad()
14 years, 3 months
JBoss Rich Faces SVN: r16315 - in root/cdk/trunk/plugins: generator/src/main/java/org/richfaces/cdk/apt and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-01-18 04:57:23 -0500 (Mon, 18 Jan 2010)
New Revision: 16315
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Converter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.xml
Log:
https://jira.jboss.org/jira/browse/RF-8232
Tags support - Attributs for convertor & validator, validate tests results by xsd
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Converter.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Converter.java 2010-01-17 18:49:35 UTC (rev 16314)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Converter.java 2010-01-18 09:57:23 UTC (rev 16315)
@@ -42,13 +42,6 @@
public static final String NAME = "org.richfaces.cdk.annotations.Converter";
- /**
- * <p class="changed_added_4_0">
- * Type of the renderer. If this value an empty, component type will be inferred from class name.
- * </p>
- *
- * @return converter type.
- */
public String id() default "";
public Class<?> forClass() default Object.class;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java 2010-01-17 18:49:35 UTC (rev 16314)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java 2010-01-18 09:57:23 UTC (rev 16315)
@@ -28,6 +28,7 @@
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.Modifier;
import java.lang.annotation.Annotation;
/**
@@ -42,6 +43,9 @@
Validator validator = element.getAnnotation(Validator.class);
ValidatorModel validatorModel = new ValidatorModel(validator.id(), new ClassDescription(element.getQualifiedName().toString()));
+ if (element.getModifiers().contains(Modifier.ABSTRACT)) {
+ validatorModel.setGenerate(true);
+ }
setDescription(element, validatorModel);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2010-01-17 18:49:35 UTC (rev 16314)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2010-01-18 09:57:23 UTC (rev 16315)
@@ -40,16 +40,19 @@
* <p class="changed_added_4_0"></p>
*/
private static final long serialVersionUID = -846623207703750456L;
+
private static final ImmutableMap<String, String> PRIMITIVE_TYPES =
- ImmutableMap.<String, String>builder().put(boolean.class.getName(),
- Boolean.class.getName()).put(byte.class.getName(),
- Byte.class.getName()).put(char.class.getName(),
- Character.class.getName()).put(short.class.getName(),
- Short.class.getName()).put(int.class.getName(),
- Integer.class.getName()).put(long.class.getName(),
- Long.class.getName()).put(float.class.getName(),
- Float.class.getName()).put(double.class.getName(),
- Double.class.getName()).build();
+ ImmutableMap.<String, String>builder()
+ .put(boolean.class.getName(), Boolean.class.getName())
+ .put(byte.class.getName(), Byte.class.getName())
+ .put(char.class.getName(), Character.class.getName())
+ .put(short.class.getName(), Short.class.getName())
+ .put(int.class.getName(), Integer.class.getName())
+ .put(long.class.getName(), Long.class.getName())
+ .put(float.class.getName(), Float.class.getName())
+ .put(double.class.getName(), Double.class.getName())
+ .build();
+
private final String boxingClassName;
private final String fullName;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java 2010-01-17 18:49:35 UTC (rev 16314)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java 2010-01-18 09:57:23 UTC (rev 16315)
@@ -25,6 +25,10 @@
import org.richfaces.cdk.CdkException;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlElement;
+import java.util.Map;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -40,6 +44,8 @@
private ClassDescription converterForClass;
+ private final ModelMap<String,Property> attributes = ModelMap.<String,Property>create();
+
public ConverterModel() {
}
@@ -74,6 +80,30 @@
this.converterClass = converterClass;
}
+
+ /**
+ * <p class="changed_added_4_0">
+ * Represents JSF component attributes and properties.
+ * </p>
+ *
+ * @return the attributes
+ */
+ @XmlElements({@XmlElement(name = "property", type = Property.class) ,
+ @XmlElement(name = "attribute", type = AttributeModel.class) })
+ public Map<String,Property> getAttributes() {
+ return attributes;
+ }
+
+ public Property addAttribute(String attributeName) {
+ Property attribute = attributes.get(attributeName);
+ if (null == attribute) {
+ attribute = new Property();
+ attributes.put(attributeName, attribute);
+ }
+
+ return attribute;
+ }
+
@Override
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
return visitor.visit(this, param);
@@ -82,6 +112,8 @@
@Override
public void merge(ConverterModel other) {
ComponentLibrary.merge(this, other);
+
+ attributes.putAll(other.getAttributes());
}
@Override
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java 2010-01-17 18:49:35 UTC (rev 16314)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java 2010-01-18 09:57:23 UTC (rev 16315)
@@ -25,6 +25,8 @@
import org.richfaces.cdk.CdkException;
+import java.util.Map;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -33,10 +35,14 @@
public class ValidatorModel extends ModelElementBase implements ModelElement<ValidatorModel> {
private static final long serialVersionUID = -6097027070372673266L;
+ private boolean generate = false;
+
private String validatorId;
private ClassDescription validatorClass;
+ private final ModelMap<String,Property> attributes = ModelMap.<String,Property>create();
+
public ValidatorModel() {
}
@@ -45,6 +51,14 @@
setValidatorClass(validatorClass);
}
+ public boolean isGenerate() {
+ return generate;
+ }
+
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
+ }
+
public String getValidatorId() {
return validatorId;
}
@@ -62,6 +76,23 @@
this.validatorClass = validatorClass;
}
+ public Map<String,Property> getAttributes() {
+ return attributes;
+ }
+
+ public Property addAttribute(String attributeName) {
+ Property attribute;
+
+ attribute = attributes.get(attributeName);
+ if(null == attribute){
+ attribute = new Property();
+ attributes.put(attributeName, attribute);
+ }
+
+ return attribute;
+ }
+
+
@Override
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
return visitor.visit(this, param);
@@ -70,6 +101,8 @@
@Override
public void merge(ValidatorModel other) {
ComponentLibrary.merge(this, other);
+
+ attributes.putAll(other.getAttributes());
}
@Override
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java 2010-01-17 18:49:35 UTC (rev 16314)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java 2010-01-18 09:57:23 UTC (rev 16315)
@@ -41,11 +41,6 @@
public void testMarshalResultStringT() throws Exception {
ComponentLibrary library = new ComponentLibrary();
- ComponentModel component = new ComponentModel(new ComponentModel.Type("foo.bar"));
- library.getComponents().add(component);
- RenderKitModel renderKit = library.addRenderKit("HTML");
- RendererModel renderer = new RendererModel(new RendererModel.Type("foo.Renderer"));
- renderKit.getRenderers().add(renderer);
ConverterModel converterModel = new ConverterModel("my_converter", new ClassDescription(Object.class));
library.getConverters().add(converterModel);
@@ -54,6 +49,6 @@
// Checks
checkXmlStructure(facesConfig);
-// validateXml(facesConfig);
+ validateXml(facesConfig);
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java 2010-01-17 18:49:35 UTC (rev 16314)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java 2010-01-18 09:57:23 UTC (rev 16315)
@@ -24,22 +24,23 @@
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.Validator;
import org.junit.Assert;
+import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkContextBase;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
import org.richfaces.cdk.xmlconfig.FacesConfigGenerator;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
import org.richfaces.cdk.xmlconfig.JaxbTestBase;
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
-import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import org.xml.sax.InputSource;
import javax.xml.transform.stream.StreamResult;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
import java.io.StringWriter;
+import java.io.StringReader;
+import java.io.InputStreamReader;
/**
* @author akolonitsky
@@ -47,19 +48,12 @@
*/
public abstract class ModelBeanTest extends JaxbTestBase {
- protected void validateXml(StringWriter facesConfig) throws SAXException {
- InputSource is = new InputSource(facesConfig.toString());
+ protected void validateXml(StringWriter facesConfig) throws SAXException, IOException {
+ InputSource is = new InputSource(new StringReader(facesConfig.toString()));
Validator validator = new Validator(is);
validator.useXMLSchema(true);
- File source = null;
-// try {
-// source = null; //new InputStream(new URL(ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION));
-// } catch (MalformedURLException e) {
-// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
-// }
- if (source == null) {
- return;
- }
+ InputSource source = new CdkEntityResolver(null)
+ .resolveEntity(null, ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION);
validator.setJAXP12SchemaSource(source);
validator.assertIsValid();
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java 2010-01-17 18:49:35 UTC (rev 16314)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java 2010-01-18 09:57:23 UTC (rev 16315)
@@ -46,8 +46,6 @@
// Checks
checkXmlStructure(facesConfig);
-// validateXml(facesConfig);
+ validateXml(facesConfig);
}
-
-
-}
+}
\ No newline at end of file
Modified: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.xml
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.xml 2010-01-17 18:49:35 UTC (rev 16314)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.xml 2010-01-18 09:57:23 UTC (rev 16315)
@@ -1,25 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<faces-config metadata-complete="false" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:cdk="http://richfaces.org/cdk/extensions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <component>
- <component-type>foo.bar</component-type>
- <component-extension>
- <cdk:generate>false</cdk:generate>
- </component-extension>
- </component>
+<faces-config version="2.0" metadata-complete="false" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:cdk="http://richfaces.org/cdk/extensions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<converter>
<converter-id>my_converter</converter-id>
<converter-class>java.lang.Object</converter-class>
<converter-extension/>
</converter>
<faces-config-extension/>
- <render-kit>
- <render-kit-id>HTML</render-kit-id>
- <renderer>
- <renderer-type>foo.Renderer</renderer-type>
- <renderer-extension>
- <cdk:renders-children>false</cdk:renders-children>
- </renderer-extension>
- </renderer>
- <render-kit-extension/>
- </render-kit>
</faces-config>
\ No newline at end of file
14 years, 3 months
JBoss Rich Faces SVN: r16314 - branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-01-17 13:49:35 -0500 (Sun, 17 Jan 2010)
New Revision: 16314
Added:
branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/ByteSequenceMatcher.java
branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/FileParam.java
branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/Param.java
branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/ValueParam.java
Modified:
branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/MultipartRequest.java
Log:
https://jira.jboss.org/jira/browse/RFPL-226
https://jira.jboss.org/jira/browse/RF-7927
Copied: branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/ByteSequenceMatcher.java (from rev 15785, branches/community/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/ByteSequenceMatcher.java)
===================================================================
--- branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/ByteSequenceMatcher.java (rev 0)
+++ branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/ByteSequenceMatcher.java 2010-01-17 18:49:35 UTC (rev 16314)
@@ -0,0 +1,185 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.ajax4jsf.request;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class ByteSequenceMatcher {
+
+ public interface BytesHandler {
+
+ public void handle(byte[] bytes, int length) throws IOException;
+
+ }
+
+ private static final int ZERO_READS_NUMBER = 20;
+
+ private byte[] buffer;
+
+ private int readLength = 0;
+
+ private int zeroReadCounter = ZERO_READS_NUMBER;
+
+ private boolean bufferEOF = false;
+
+ private boolean isEOF = false;
+
+ private boolean isMatched = false;
+
+ private InputStream inputStream;
+
+ private BytesHandler bytesHandler;
+
+ public ByteSequenceMatcher(InputStream inputStream, int bufferSize) {
+ this.inputStream = inputStream;
+ this.buffer = new byte[bufferSize];
+ }
+
+ public BytesHandler getBytesHandler() {
+ return bytesHandler;
+ }
+
+ public void setBytesHandler(BytesHandler bytesHandler) {
+ this.bytesHandler = bytesHandler;
+ }
+
+ protected void prefillBuffer(int usedLength) throws IOException {
+ if (usedLength > readLength) {
+ throw new IllegalArgumentException();
+ }
+
+ if (usedLength != readLength && usedLength != 0) {
+ System.arraycopy(buffer, usedLength, buffer, 0, readLength - usedLength);
+ }
+
+ readLength -= usedLength;
+
+ int remaining;
+
+ while (!bufferEOF && (remaining = (buffer.length - readLength)) > 0) {
+ int read = inputStream.read(buffer, readLength, remaining);
+
+ if (read > 0) {
+ readLength += read;
+ } else if (read == 0) {
+ --zeroReadCounter;
+
+ if (zeroReadCounter == 0) {
+ throw new IllegalStateException("Maximum number of zero reads reached");
+ }
+ } else if (read < 0) {
+ bufferEOF = true;
+ }
+ }
+ }
+
+ private boolean match(int startOffset, byte[]...sequences) {
+ int index = startOffset;
+
+ for (byte[] bs : sequences) {
+ for (byte b : bs) {
+
+ if (index >= readLength) {
+ return false;
+ }
+
+ if (buffer[index] != b) {
+ return false;
+ }
+
+ index++;
+ }
+ }
+
+ return true;
+ }
+
+ public void findSequence(int limit, byte[]... sequences) throws IOException {
+ isMatched = false;
+
+ int userLimit = limit;
+ if (userLimit <= 0) {
+ userLimit = Integer.MAX_VALUE;
+ }
+
+ prefillBuffer(0);
+
+ int sequencesLength = 0;
+ for (byte[] bs : sequences) {
+ sequencesLength += bs.length;
+ }
+
+ int i = 0;
+
+ while (!isMatched && i <= readLength - sequencesLength) {
+ if (match(i, sequences)) {
+ isMatched = true;
+ bytesHandler.handle(buffer, i);
+ prefillBuffer(i + sequencesLength);
+ } else {
+ int sequenceLimit = readLength - sequencesLength + 1;
+ int realLimit;
+
+ if (sequenceLimit < userLimit) {
+ realLimit = sequenceLimit;
+ } else {
+ realLimit = userLimit;
+ }
+
+ if (realLimit > 0 && i == realLimit - 1) {
+ //report limit
+ bytesHandler.handle(buffer, realLimit);
+ prefillBuffer(realLimit);
+
+ i = 0;
+ } else {
+ i++;
+ }
+ }
+ }
+
+ if (!isMatched) {
+ if (readLength > 0) {
+ bytesHandler.handle(buffer, readLength);
+ prefillBuffer(readLength);
+ }
+ }
+
+ if (this.readLength == 0) {
+ this.isEOF = true;
+ }
+ }
+
+ public boolean isEOF() {
+ return isEOF;
+ }
+
+ public boolean isMatched() {
+ return isMatched;
+ }
+
+ public boolean isMatchedAndNotEOF() {
+ return isMatched() && !isEOF();
+ }
+}
Copied: branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/FileParam.java (from rev 15785, branches/community/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/FileParam.java)
===================================================================
--- branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/FileParam.java (rev 0)
+++ branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/FileParam.java 2010-01-17 18:49:35 UTC (rev 16314)
@@ -0,0 +1,205 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.ajax4jsf.request;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.rmi.server.UID;
+
+import org.ajax4jsf.exception.FileUploadException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+class FileParam extends Param {
+
+ private static final Log logger = LogFactory.getLog(FileParam.class);
+
+ private String filename;
+ private String contentType;
+ private int fileSize;
+
+ private ByteArrayOutputStream bOut = null;
+ private FileOutputStream fOut = null;
+ private File tempFile = null;
+
+ public FileParam(String name) {
+ super(name);
+ }
+
+ public Object getFile() {
+ if (null != tempFile) {
+ return tempFile;
+ } else if (null != bOut) {
+ return bOut.toByteArray();
+ }
+ return null;
+ }
+
+ public String getFilename() {
+ return filename;
+ }
+
+ public void setFilename(String filename) {
+ this.filename = filename;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+ public int getFileSize() {
+ return fileSize;
+ }
+
+ public File createTempFile() {
+ try {
+ tempFile = File.createTempFile(new UID().toString().replace(
+ ":", "-"), ".upload");
+ fOut = new FileOutputStream(tempFile);
+ } catch (IOException ex) {
+ if (fOut != null) {
+ try {
+ fOut.close();
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+
+ throw new FileUploadException("Could not create temporary file");
+ }
+ return tempFile;
+ }
+
+ public void deleteFile() {
+ try {
+ if (fOut != null) {
+ fOut.close();
+ }
+ if (tempFile != null) {
+ tempFile.delete();
+ }
+ } catch (Exception e) {
+ throw new FileUploadException("Could not delete temporary file");
+ }
+ }
+
+ public byte[] getData() {
+ if (bOut != null) {
+ return bOut.toByteArray();
+ } else if (tempFile != null) {
+ if (tempFile.exists()) {
+ FileInputStream fIn = null;
+ try {
+ long fileLength = tempFile.length();
+ if (fileLength > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("File content is too long to be allocated as byte[]");
+ }
+
+ fIn = new FileInputStream(tempFile);
+
+ byte[] fileData = new byte[(int)fileLength];
+ int totalRead = 0;
+ int read = 0;
+ do {
+ read = fIn.read(fileData, totalRead, fileData.length - totalRead);
+ if (read > 0) {
+ totalRead += read;
+ }
+ } while (read > 0);
+
+ return fileData;
+ } catch (IOException ex) { /* too bad? */
+ logger.error(ex.getMessage(), ex);
+ } finally {
+ if (fIn != null) {
+ try {
+ fIn.close();
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public InputStream getInputStream() {
+ if (bOut != null) {
+ return new ByteArrayInputStream(bOut.toByteArray());
+ } else if (tempFile != null) {
+ try {
+ return new FileInputStream(tempFile) {
+ @Override
+ public void close() throws IOException {
+ super.close();
+ tempFile.delete();
+ }
+ };
+ } catch (FileNotFoundException ex) {
+ logger.error(ex.getMessage(), ex);
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public void complete() throws IOException {
+ if (fOut != null) {
+ try {
+ fOut.close();
+ } catch (IOException ex) {
+ logger.error(ex.getMessage(), ex);
+ }
+ fOut = null;
+ }
+ }
+
+ public void handle(byte[] bytes, int length)
+ throws IOException {
+ // read += length;
+ if (fOut != null) {
+ fOut.write(bytes, 0, length);
+ fOut.flush();
+ } else {
+ if (bOut == null) {
+ bOut = new ByteArrayOutputStream();
+ }
+ bOut.write(bytes, 0, length);
+ }
+
+ fileSize += length;
+ }
+}
\ No newline at end of file
Modified: branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/MultipartRequest.java
===================================================================
--- branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/MultipartRequest.java 2010-01-16 01:20:39 UTC (rev 16313)
+++ branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/MultipartRequest.java 2010-01-17 18:49:35 UTC (rev 16314)
@@ -21,17 +21,13 @@
package org.ajax4jsf.request;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
+import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
-import java.rmi.server.UID;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -48,7 +44,10 @@
import javax.servlet.http.HttpServletRequestWrapper;
import org.ajax4jsf.exception.FileUploadException;
+import org.ajax4jsf.request.ByteSequenceMatcher.BytesHandler;
import org.ajax4jsf.webapp.BaseXMLFilter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.richfaces.component.FileUploadConstants;
import org.richfaces.model.UploadItem;
@@ -63,8 +62,11 @@
private static final String PARAM_CONTENT_TYPE = "Content-Type";
private static final int BUFFER_SIZE = 2048;
- private static final int CHUNK_SIZE = 512;
+ private static final int CHUNK_SIZE = 1024;
+ private static final int MAX_HEADER_SIZE = 32768;
+ private static final Log logger = LogFactory.getLog(MultipartRequest.class);
+
private boolean createTempFiles;
private String uid;
@@ -74,242 +76,33 @@
private Integer contentLength = 0;
private int bytesRead = 0;
-
- private int read = 0;
//we shouldn't allow to stop until request reaches PhaseListener because of portlets
private boolean canStop = false;
-
+
private Map<String, Param> parameters = null;
private Map<String, Object> percentMap = null;
-
+
private Map<String, Integer> requestSizeMap = null;
-
+
private Map<String, String> requestKeysMap = null;
-
+
private String requestKey = null;
-
+
private MultipartRequestRegistry requestRegistry;
-
+
private List<String> keys = new ArrayList<String>();
- private enum ReadState {
- BOUNDARY, HEADERS, DATA
- }
+ private byte[] boundaryMarker;
+ private ByteSequenceMatcher sequenceMatcher;
+
private static final byte CR = 0x0d;
private static final byte LF = 0x0a;
private static final byte[] CR_LF = { CR, LF };
+ private static final byte[] HYPHENS = { 0x2d, 0x2d }; //'--'
- private abstract class Param {
- private String name;
-
- public Param(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public abstract void appendData(byte[] data, int start, int length)
- throws IOException;
-
- }
-
- private class ValueParam extends Param {
- private Object value = null;
- private ByteArrayOutputStream buf = new ByteArrayOutputStream();
-
- public ValueParam(String name) {
- super(name);
- }
-
- @Override
- public void appendData(byte[] data, int start, int length)
- throws IOException {
- // read += length;
- buf.write(data, start, length);
- }
-
- public void complete() throws UnsupportedEncodingException {
- String val = encoding == null ? new String(buf.toByteArray())
- : new String(buf.toByteArray(), encoding);
- if (value == null) {
- value = val;
- } else {
- if (!(value instanceof List)) {
- List<String> v = new ArrayList<String>();
- v.add((String) value);
- value = v;
- }
-
- ((List) value).add(val);
- }
- buf.reset();
- }
-
- public Object getValue() {
- return value;
- }
- }
-
- private class FileParam extends Param {
- private String filename;
- private String contentType;
- private int fileSize;
-
- private ByteArrayOutputStream bOut = null;
- private FileOutputStream fOut = null;
- private File tempFile = null;
-
- public FileParam(String name) {
- super(name);
- keys.add(name);
- }
-
- public Object getFile() {
- if (null != tempFile) {
- if (fOut != null) {
- try {
- fOut.close();
- } catch (IOException ex) {
- }
- fOut = null;
- }
- return tempFile;
- } else if (null != bOut) {
- return bOut.toByteArray();
- }
- return null;
- }
-
- public String getFilename() {
- return filename;
- }
-
- public void setFilename(String filename) {
- this.filename = filename;
- }
-
- public String getContentType() {
- return contentType;
- }
-
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
-
- public int getFileSize() {
- return fileSize;
- }
-
- public File createTempFile() {
- try {
-
- tempFile = File.createTempFile(new UID().toString().replace(
- ":", "-"), ".upload");
- // tempFile.deleteOnExit();
- fOut = new FileOutputStream(tempFile);
- } catch (IOException ex) {
- throw new FileUploadException("Could not create temporary file");
- }
- return tempFile;
- }
-
- public void deleteFile() {
- try {
- if (fOut != null) {
- fOut.close();
- if (tempFile != null) {
- tempFile.delete();
- }
- }
- } catch (Exception e) {
- throw new FileUploadException("Could not delete temporary file");
- }
- }
-
- @Override
- public void appendData(byte[] data, int start, int length)
- throws IOException {
- // read += length;
- if (fOut != null) {
- fOut.write(data, start, length);
- fOut.flush();
- } else {
- if (bOut == null)
- bOut = new ByteArrayOutputStream();
- bOut.write(data, start, length);
- }
-
- fileSize += length;
- }
-
- public byte[] getData() {
- if (fOut != null) {
- try {
- fOut.close();
- } catch (IOException ex) {
- }
- fOut = null;
- }
-
- if (bOut != null) {
- return bOut.toByteArray();
- } else if (tempFile != null) {
- if (tempFile.exists()) {
- try {
- FileInputStream fIn = new FileInputStream(tempFile);
- ByteArrayOutputStream bOut = new ByteArrayOutputStream();
- byte[] buf = new byte[512];
- int read = fIn.read(buf);
- while (read != -1) {
- bOut.write(buf, 0, read);
- read = fIn.read(buf);
- }
- bOut.flush();
-
- fIn.close();
- tempFile.delete();
- return bOut.toByteArray();
- } catch (IOException ex) { /* too bad? */
- }
- }
- }
-
- return null;
- }
-
- public InputStream getInputStream() {
- if (fOut != null) {
- try {
- fOut.close();
- } catch (IOException ex) {
- }
- fOut = null;
- }
-
- if (bOut != null) {
- return new ByteArrayInputStream(bOut.toByteArray());
- } else if (tempFile != null) {
- try {
- return new FileInputStream(tempFile) {
- @Override
- public void close() throws IOException {
- super.close();
- tempFile.delete();
- }
- };
- } catch (FileNotFoundException ex) {
- }
- }
-
- return null;
- }
- }
-
private boolean shouldStop = false;
private boolean canceled;
@@ -330,6 +123,43 @@
}
}
+ private class ControlledProgressInputStream extends FilterInputStream {
+
+ protected ControlledProgressInputStream(InputStream in) {
+ super(in);
+ }
+
+ @Override
+ public int read() throws IOException {
+ int read = super.read();
+ if (read >= 0) {
+ bytesRead++;
+ fillProgressInfo();
+ }
+ return read;
+ }
+
+ @Override
+ public int read(byte[] b) throws IOException {
+ int read = super.read(b);
+ if (read > 0) {
+ bytesRead += read;
+ fillProgressInfo();
+ }
+ return read;
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ int read = super.read(b, off, len);
+ if (read > 0) {
+ bytesRead += read;
+ fillProgressInfo();
+ }
+ return read;
+ }
+ }
+
private String decodeFileName(String name) {
String fileName = null;
@@ -361,7 +191,7 @@
public void cancel() {
this.canceled = true;
-
+
if (parameters != null) {
Iterator<Param> it = parameters.values().iterator();
while (it.hasNext()) {
@@ -373,191 +203,145 @@
}
}
- private byte[] boundaryMarker;
-
- private byte[] buffer;
-
- private ReadState readState;
-
- private InputStream input;
-
- private int pos = 0;
+ private void readNext() throws IOException {
+ Param p = readHeader();
+ if (p != null) {
+ try {
+ readData(p);
+ } finally {
+ try {
+ p.complete();
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+ }
+ }
- private int zeroReadAttempts = 20; // 20 attempts to read not-readable data
-
- private void fillBuffer() throws IOException {
- if (pos < read) {
- // move the bytes that weren't read to the start of
- // the
- // buffer
- int bytesNotRead = read - pos;
-
- if (bytesNotRead != buffer.length) {
- System.arraycopy(buffer, pos, buffer, 0,
- bytesNotRead);
- read = input.read(buffer, bytesNotRead,
- buffer.length - bytesNotRead);
-
- if (read != 0 || --zeroReadAttempts != 0) {
- if (read > 0) {
- bytesRead += read;
- }
+ private Param createParam(Map<String, String> headers) {
+ Param param = null;
+ String paramName = headers.get(PARAM_NAME);
+ if (paramName != null) {
+ if (headers.containsKey(PARAM_FILENAME)) {
+ FileParam fp = new FileParam(paramName);
+ this.keys.add(paramName);
- read += bytesNotRead;
- } else {
- //read is already zero
- //read = 0;
+ if (createTempFiles) {
+ fp.createTempFile();
}
+ fp.setContentType(headers.get(PARAM_CONTENT_TYPE));
+ fp.setFilename(decodeFileName(headers.get(PARAM_FILENAME)));
+ param = fp;
} else {
- read = bytesNotRead;
+ if (parameters.containsKey(paramName)) {
+ param = parameters.get(paramName);
+ } else {
+ param = new ValueParam(paramName, encoding);
+ }
}
- } else {
- read = input.read(buffer);
- if (read > 0) {
- bytesRead += read;
+ if (!parameters.containsKey(paramName)) {
+ parameters.put(paramName, param);
}
}
-
- fillProgressInfo();
- pos = 0;
+
+ return param;
}
-
- private void readNext() throws IOException {
- Param p = readHeader();
- readData(p);
- }
- private void readData(Param p) throws IOException {
- int localRead = this.read;
-
- while (localRead > 0) {
- for (int i = this.pos; i < localRead; i++) {
- // If we've encountered another boundary...
- if (checkSequence(buffer, i - boundaryMarker.length
- - CR_LF.length, CR_LF)
- && checkSequence(buffer, i, boundaryMarker)) {
- // Write any data before the boundary (that
- // hasn't
- // already been written) to the param
- if (pos < i - boundaryMarker.length
- - CR_LF.length - 1) {
- p.appendData(buffer, pos, i - pos
- - boundaryMarker.length
- - CR_LF.length - 1);
- }
+ private boolean initialized = false;
- if (p instanceof ValueParam)
- ((ValueParam) p).complete();
+ private static final BytesHandler NOOP_HANDLER = new BytesHandler() {
+ public void handle(byte[] bytes, int length) {
+ //do nothing
+ }
+ };
- if (checkSequence(buffer, i + CR_LF.length,
- CR_LF)) {
- i += CR_LF.length;
- pos = i + 1;
- } else {
- pos = i;
- }
+ private class HeadersHandler implements BytesHandler {
- readState = ReadState.HEADERS;
- break;
- }
- // Otherwise write whatever data we have to the
- // param
- else if (i > (pos + boundaryMarker.length
- + CHUNK_SIZE + CR_LF.length)) {
- p.appendData(buffer, pos, CHUNK_SIZE);
- pos += CHUNK_SIZE;
+ private ByteArrayOutputStream baos = new ByteArrayOutputStream(BUFFER_SIZE);
+ public void handle(byte[] bytes, int length) throws IOException {
+ if (length != 0) {
+ if (baos.size() + length > MAX_HEADER_SIZE) {
+ throw new IOException("Header section is too big");
}
+
+ baos.write(bytes, 0, length);
}
-
- if (ReadState.DATA.equals(readState)) {
- fillBuffer();
- localRead = this.read;
+ }
+
+ public boolean dataEquals(byte[] bytes) {
+ return (baos.size() == bytes.length) && Arrays.equals(HYPHENS, baos.toByteArray());
+ }
+
+ public String asString() throws UnsupportedEncodingException {
+ if (encoding != null) {
+ return baos.toString(encoding);
} else {
- break;
+ return baos.toString();
}
}
+
+ public void reset() {
+ baos.reset();
+ }
+
}
-
+
+ private HeadersHandler headersHandler = null;
+
private Param readHeader() throws IOException {
- Param p = null;
+ if (sequenceMatcher.isEOF()) {
+ return null;
+ }
- Map<String, String> headers = new HashMap<String, String>();
+ if (headersHandler == null) {
+ headersHandler = new HeadersHandler();
+ } else {
+ headersHandler.reset();
+ }
- int localRead = this.read;
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
-
- while (localRead > 0) {
- for (int i = this.pos; i < localRead; i++) {
- if (checkSequence(buffer, i, CR_LF)) {
- baos.write(buffer, pos, i - pos - 1);
+ sequenceMatcher.setBytesHandler(headersHandler);
+ sequenceMatcher.findSequence(-1, CR_LF);
- String param = (encoding == null) ?
- new String(baos.toByteArray()) :
- new String(baos.toByteArray(), encoding);
+ if (sequenceMatcher.isMatchedAndNotEOF() && !headersHandler.dataEquals(HYPHENS)) {
+ headersHandler.reset();
+
+ sequenceMatcher.findSequence(-1, CR_LF, CR_LF);
+
+ if (!sequenceMatcher.isMatchedAndNotEOF()) {
+ throw new IOException("Request header cannot be read");
+ }
- parseParams(param, "; ", headers);
-
- if (checkSequence(buffer, i + CR_LF.length,
- CR_LF)) {
- readState = ReadState.DATA;
- i += CR_LF.length;
- pos = i + 1;
-
- String paramName = headers.get(PARAM_NAME);
- if (paramName != null) {
- if (headers.containsKey(PARAM_FILENAME)) {
- FileParam fp = new FileParam(
- paramName);
- if (createTempFiles)
- fp.createTempFile();
- fp.setContentType(headers
- .get(PARAM_CONTENT_TYPE));
- fp
- .setFilename(decodeFileName(headers
- .get(PARAM_FILENAME)));
- p = fp;
- } else {
- if (parameters
- .containsKey(paramName)) {
- p = parameters.get(paramName);
- } else {
- p = new ValueParam(paramName);
- }
- }
-
- if (!parameters.containsKey(paramName)) {
- parameters.put(paramName, p);
- }
- }
-
- headers.clear();
- baos.reset();
-
- break;
- } else {
- pos = i + 1;
- baos.reset();
- }
- }
+ String headersString = headersHandler.asString();
+ Map<String, String> headers = new HashMap<String, String>();
+ String[] split = headersString.split("\r\n");
+ for (String headerString : split) {
+ parseParams(headerString, "; ", headers);
}
- if (ReadState.HEADERS.equals(readState)) {
- baos.write(buffer, pos, read - pos);
- pos = read;
- fillBuffer();
- localRead = this.read;
- } else {
- break;
- }
+ return createParam(headers);
}
- return p;
+
+ return null;
}
- boolean initialized = false;
-
+ private void readProlog() throws IOException {
+ sequenceMatcher.setBytesHandler(NOOP_HANDLER);
+ sequenceMatcher.findSequence(-1, HYPHENS, boundaryMarker);
+ if (!sequenceMatcher.isMatchedAndNotEOF()) {
+ throw new IOException("Request prolog cannot be read");
+ }
+ }
+
+ private void readData(final Param param) throws IOException {
+ sequenceMatcher.setBytesHandler(param);
+ sequenceMatcher.findSequence(CHUNK_SIZE, CR_LF, HYPHENS, boundaryMarker);
+ if (!this.sequenceMatcher.isMatchedAndNotEOF()) {
+ throw new IOException("Request data cannot be read");
+ }
+ }
+
private void initialize() throws IOException {
if (!initialized) {
initialized = true;
@@ -567,69 +351,48 @@
throw new FileUploadException("The request was rejected because "
+ "no multipart boundary was found");
}
-
+
+ if (HYPHENS.length + boundaryMarker.length + CHUNK_SIZE + CR_LF.length > BUFFER_SIZE) {
+ throw new FileUploadException("Boundary marker is too long");
+ }
+
this.encoding = getCharacterEncoding();
this.parameters = new HashMap<String, Param>();
- this.buffer = new byte[BUFFER_SIZE];
+ InputStream input = new ControlledProgressInputStream(getInputStream());
- this.readState = ReadState.BOUNDARY;
+ this.sequenceMatcher = new ByteSequenceMatcher(input, BUFFER_SIZE);
- this.input = getInputStream();
-
setupProgressData();
-
- fillBuffer();
- int localRead = this.read;
-
- while (localRead > 0) {
- for (int i = 0; i < localRead; i++) {
- if (checkSequence(buffer, i, boundaryMarker)
- && checkSequence(buffer, i + 2, CR_LF)) {
- readState = ReadState.HEADERS;
- i += 2;
- pos = i + 1;
-
- break;
- }
- }
-
- if (ReadState.BOUNDARY.equals(readState)) {
- pos = read - (boundaryMarker.length + CR_LF.length) + 1;
- fillBuffer();
- localRead = this.read;
- } else {
- break;
- }
- }
-
+
+ readProlog();
}
}
-
+
public void parseRequest() {
canStop = true;
-
+
setupProgressData();
-
+
try {
initialize();
-
- while (read > 0) {
+
+ while (!sequenceMatcher.isEOF()) {
readNext();
}
-
} catch (IOException e) {
this.cancel();
-
+
if (!this.shouldStop) {
throw new FileUploadException("IO Error parsing multipart request", e);
}
}
}
-
+
public static MultipartRequest lookupRequest(FacesContext context, String uploadId) {
Map<String, Object> sessionMap = context.getExternalContext().getSessionMap();
+ @SuppressWarnings("unchecked")
Map<String, String> requestKeys = (Map<String, String>) sessionMap.get(FileUploadConstants.REQUEST_KEYS_BEAN_NAME);
if (requestKeys != null) {
String requestKey = requestKeys.get(uploadId);
@@ -643,10 +406,10 @@
}
}
}
-
+
return null;
}
-
+
@SuppressWarnings("unchecked")
private void setupProgressData() {
if (percentMap == null || requestSizeMap == null || requestKeysMap == null) {
@@ -674,17 +437,17 @@
sessionMap.put(FileUploadConstants.REQUEST_SIZE_BEAN_NAME, requestSizeMap);
}
}
-
+
if (requestKeysMap == null) {
requestKeysMap = (Map<String, String>) sessionMap.get(FileUploadConstants.REQUEST_KEYS_BEAN_NAME);
if (requestKeysMap == null) {
requestKeysMap = new ConcurrentHashMap<String, String>();
sessionMap.put(FileUploadConstants.REQUEST_KEYS_BEAN_NAME, requestKeysMap);
}
-
+
}
}
-
+
percentMap.put(uploadId, Double.valueOf(0));
requestSizeMap.put(uploadId, getSize());
@@ -701,7 +464,7 @@
private void fillProgressInfo() {
setupProgressData();
-
+
if (percentMap != null) {
Double percent = (Double) (100.0 * this.bytesRead / this.contentLength);
percentMap.put(uid, percent);
@@ -713,8 +476,9 @@
Map<String, String> params = parseParams(contentType, ";");
String boundaryStr = (String) params.get("boundary");
- if (boundaryStr == null)
+ if (boundaryStr == null) {
return null;
+ }
try {
return boundaryStr.getBytes("ISO-8859-1");
@@ -723,33 +487,11 @@
}
}
- /**
- * Checks if a specified sequence of bytes ends at a specific position
- * within a byte array.
- *
- * @param data
- * @param pos
- * @param seq
- * @return boolean indicating if the sequence was found at the specified
- * position
- */
- private boolean checkSequence(byte[] data, int pos, byte[] seq) {
- if (pos - seq.length < -1 || pos >= data.length)
- return false;
-
- for (int i = 0; i < seq.length; i++) {
- if (data[(pos - seq.length) + i + 1] != seq[i])
- return false;
- }
-
- return true;
- }
-
private static final Pattern PARAM_VALUE_PATTERN = Pattern
- .compile("^\\s*([^\\s=]+)\\s*[=:]\\s*(.+)\\s*$");
+ .compile("^\\s*([^\\s=]+)\\s*[=:]\\s*(.+)\\s*$");
private static final Pattern FILE_NAME_PATTERN = Pattern
- .compile(".*filename=\"(.*)\"");
+ .compile(".*filename=\"(.*)\"");
private Map<String, String> parseParams(String paramStr, String separator) {
Map<String, String> paramMap = new HashMap<String, String>();
@@ -797,13 +539,13 @@
if (parameters != null) {
param = parameters.get(name);
}
-
+
if (param == null) {
if (!canceled) {
try {
initialize();
- while (param == null && read > 0) {
+ while (param == null && !sequenceMatcher.isEOF()) {
readNext();
param = parameters.get(name);
}
@@ -813,7 +555,7 @@
}
}
}
-
+
return param;
}
@@ -822,9 +564,11 @@
}
@Override
+ @SuppressWarnings("unchecked")
public Enumeration getParameterNames() {
- if (parameters == null)
+ if (parameters == null) {
parseRequest();
+ }
return Collections.enumeration(parameters.keySet());
}
@@ -870,8 +614,9 @@
Param p = getParam(name);
if (p != null && p instanceof ValueParam) {
ValueParam vp = (ValueParam) p;
- if (vp.getValue() instanceof String)
+ if (vp.getValue() instanceof String) {
return (String) vp.getValue();
+ }
} else if (p != null && p instanceof FileParam) {
return "---BINARY DATA---";
} else {
@@ -884,12 +629,13 @@
@Override
public String[] getParameterValues(String name) {
parseRequest();
-
+
Param p = getParam(name);
if (p != null && p instanceof ValueParam) {
ValueParam vp = (ValueParam) p;
- if (vp.getValue() instanceof List) {
- List vals = (List) vp.getValue();
+ if (vp.getValue() instanceof List<?>) {
+ @SuppressWarnings("unchecked")
+ List<String> vals = (List<String>) vp.getValue();
String[] values = new String[vals.size()];
vals.toArray(values);
return values;
@@ -902,12 +648,13 @@
}
@Override
+ @SuppressWarnings("unchecked")
public Map getParameterMap() {
- if (parameters == null)
+ if (parameters == null) {
parseRequest();
+ }
- Map<String, Object> params = new HashMap<String, Object>(super
- .getParameterMap());
+ Map<String, Object> params = new HashMap<String, Object>(super.getParameterMap());
for (String name : parameters.keySet()) {
Param p = parameters.get(name);
@@ -923,7 +670,7 @@
return params;
}
-
+
public List<UploadItem> getUploadItems () {
List <UploadItem> uploadItems = new ArrayList<UploadItem>();
for (String k : keys) {
@@ -931,16 +678,16 @@
}
return uploadItems;
}
-
+
public boolean isFormUpload() {
return "_richfaces_form_upload".equals(uid);
}
-
+
@Override
public String getHeader(String name) {
if (!"Accept".equals(name)) {
return super.getHeader(name);
- }else {
+ } else {
return BaseXMLFilter.TEXT_HTML;
}
}
@@ -950,16 +697,16 @@
shouldStop = true;
}
}
-
+
public boolean isStopped() {
return this.shouldStop;
}
-
+
public boolean isDone() {
return !(this.shouldStop && (this.canceled ||
this.contentLength != null && this.contentLength.intValue() != this.bytesRead));
}
-
+
@Override
public String getContentType() {
return "application/x-www-form-urlencoded";
@@ -968,18 +715,18 @@
protected String getUploadId() {
return uid;
}
-
+
public void clearRequestData() {
String uploadId = getUploadId();
-
+
if (percentMap != null) {
percentMap.remove(uploadId);
}
-
+
if (requestSizeMap != null) {
requestSizeMap.remove(uploadId);
}
-
+
if (requestKeysMap != null) {
requestKeysMap.remove(uploadId);
}
Copied: branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/Param.java (from rev 15785, branches/community/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/Param.java)
===================================================================
--- branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/Param.java (rev 0)
+++ branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/Param.java 2010-01-17 18:49:35 UTC (rev 16314)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.ajax4jsf.request;
+
+import java.io.IOException;
+
+import org.ajax4jsf.request.ByteSequenceMatcher.BytesHandler;
+
+abstract class Param implements BytesHandler {
+ private String name;
+
+ public Param(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public abstract void complete() throws IOException;
+}
\ No newline at end of file
Copied: branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/ValueParam.java (from rev 15785, branches/community/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/ValueParam.java)
===================================================================
--- branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/ValueParam.java (rev 0)
+++ branches/enterprise/3.3.X/framework/impl/src/main/java/org/ajax4jsf/request/ValueParam.java 2010-01-17 18:49:35 UTC (rev 16314)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.ajax4jsf.request;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+class ValueParam extends Param {
+
+ private Object value = null;
+ private ByteArrayOutputStream buf = new ByteArrayOutputStream();
+ private String encoding;
+
+ public ValueParam(String name, String encoding) {
+ super(name);
+ this.encoding = encoding;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void complete() throws IOException {
+ String val = this.encoding == null ? new String(buf.toByteArray())
+ : new String(buf.toByteArray(), this.encoding);
+ if (value == null) {
+ value = val;
+ } else {
+ if (!(value instanceof List<?>)) {
+ List<String> v = new ArrayList<String>();
+ v.add((String) value);
+ value = v;
+ }
+
+ ((List<String>) value).add(val);
+ }
+ buf.reset();
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public void handle(byte[] bytes, int length)
+ throws IOException {
+ // read += length;
+ buf.write(bytes, 0, length);
+ }
+}
\ No newline at end of file
14 years, 3 months