Author: vpakan(a)redhat.com
Date: 2010-01-22 09:36:31 -0500 (Fri, 22 Jan 2010)
New Revision: 19883
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/cssdialog/jbide/CssFileParser.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/cssdialog/jbide/CssFileParserException.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/cssdialog/jbide/JBIDE3148and4441Test.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/AddRemoveStrutsCapabilities.java
Log:
Changes needed to have SWTBot tests running on Hudson
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/cssdialog/jbide/CssFileParser.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/cssdialog/jbide/CssFileParser.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/cssdialog/jbide/CssFileParser.java 2010-01-22
14:36:31 UTC (rev 19883)
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.ui.bot.test.cssdialog.jbide;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Properties;
+/**
+ * Parse and Compare Css File Content
+ * @author Vladimir Pakan
+ */
+public class CssFileParser {
+ private LinkedList<Properties> cssClasses = new LinkedList<Properties>();
+
+ private LinkedList<String> fileLines = new LinkedList<String>();
+ private boolean parsed = false;
+ private enum ParserStatus {OUT_OF_CLASS_DEFINITION,
+ IN_CLASS_DEFINTION};
+
+ public CssFileParser(){
+
+ }
+
+ public CssFileParser(String... lines){
+ addLines(lines);
+ }
+
+ public boolean isParsed() {
+ return parsed;
+ }
+
+ public LinkedList<Properties> getCssClasses() {
+ return cssClasses;
+ }
+ /**
+ * Adds only non empty lines. Do not change it because parser doesn't
+ * check for empy lines
+ * @param line
+ */
+ public void addLine(String line){
+ if (line != null && line.trim().length() > 0){
+ fileLines.add(line);
+ parsed = false;
+ }
+ }
+
+ public void addLines(String... lines){
+ for (String line : lines){
+ addLine(line);
+ }
+ }
+
+ public void reset(){
+ cssClasses.clear();
+ fileLines.clear();
+ parsed = false;
+ }
+
+ public void parse(){
+ cssClasses.clear();
+ ParserStatus parserStatus = ParserStatus.OUT_OF_CLASS_DEFINITION;
+ Properties classProperties = null;
+ for (String line : fileLines){
+ line = line.trim();
+ // inside Css Class Definition
+ if (parserStatus.equals(ParserStatus.IN_CLASS_DEFINTION)){
+ if (line.equals("}")){
+ parserStatus = ParserStatus.OUT_OF_CLASS_DEFINITION;
+ cssClasses.add(classProperties);
+ classProperties = null;
+ }
+ else{
+ String[] styleLineParts = line.split(":");
+ if (styleLineParts.length == 2){
+ classProperties.put(styleLineParts[0],
+ (styleLineParts[1].endsWith(";")) ?
+ styleLineParts[1].substring(0 , styleLineParts[1].length() - 1) :
styleLineParts[1]);
+ }
+ else{
+ throw new CssFileParserException("Style Definition Line within CSS File
has wrong format: "
+ + line);
+ }
+ }
+ }// Waiting for css class definition
+ else if(parserStatus.equals(ParserStatus.OUT_OF_CLASS_DEFINITION)){
+ if (line.startsWith("cssclass")){
+ if (line.endsWith("{")){
+ parserStatus = ParserStatus.IN_CLASS_DEFINTION;
+ classProperties = new Properties();
+ }
+ else{
+ throw new CssFileParserException("Line should ends with '{'
string but is: "
+ + line);
+ }
+ }
+ else{
+ throw new CssFileParserException("Line should starts with
'cssclass' string but is: "
+ + line);
+ }
+ }
+ }
+ parsed = true;
+ }
+
+ public boolean compare (CssFileParser cssFileParser){
+ boolean result = false;
+
+ if (cssFileParser != null){
+ if (!cssFileParser.isParsed()){
+ cssFileParser.parse();
+ }
+ if (!this.isParsed()){
+ this.parse();
+ }
+ // Compare CSS Files Contents
+ boolean propertiesAreEqual = true;
+ if (this.getCssClasses().size() == cssFileParser.getCssClasses().size()){
+ Iterator<Properties> itThisProperties = this.getCssClasses().iterator();
+ Iterator<Properties> cssFileProperties =
cssFileParser.getCssClasses().iterator();
+ while (propertiesAreEqual && itThisProperties.hasNext()){
+ Properties propsThis = (Properties)itThisProperties.next().clone();
+ Properties propsCssFile = (Properties)cssFileProperties.next().clone();
+ boolean styleAttributesAreEqual = true;
+ Iterator<Object> itThisPropertyName = propsThis.keySet().iterator();
+ while (styleAttributesAreEqual && itThisPropertyName.hasNext()){
+ String propertyName = (String)itThisPropertyName.next();
+ if (propsCssFile.containsKey(propertyName)){
+ styleAttributesAreEqual = propsThis.getProperty(propertyName).trim()
+ .equals(propsCssFile.getProperty(propertyName).trim());
+ // Remove checked property from CSS file properties
+ propsCssFile.remove(propertyName);
+ }
+ else{
+ styleAttributesAreEqual = false;
+ }
+ }
+ // If there are left properties in CSS file then files are not equal
+ propertiesAreEqual = styleAttributesAreEqual && propsCssFile.size() ==
0;
+ }
+ result = propertiesAreEqual;
+ }
+ }
+
+ return result;
+ }
+ // TODO: Remove It
+ public static void main (String[] args){
+ CssFileParser parser1 = new CssFileParser(
+ "cssclass{",
+ "color: red;",
+ "background-color: green;",
+ "font-weight: bold;",
+ "text-decoration: underline",
+ "}",
+ "cssclass{",
+ "color: green;",
+ "background-color: red;",
+ "font-weight: lighter;",
+ "text-decoration: overline",
+ "}");
+
+ CssFileParser parser2 = new CssFileParser(
+ "cssclass{",
+ "color: red;",
+ "background-color: green;",
+ "text-decoration: underline",
+ "font-weight: bold;",
+ "}",
+ "cssclass{",
+ "color: green;",
+ "background-color: red;",
+ "text-decoration: overline",
+ "font-weight: lighter;",
+ "}");
+
+ System.out.println(parser1.compare(parser2));
+
+ }
+
+}
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/cssdialog/jbide/CssFileParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/cssdialog/jbide/CssFileParserException.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/cssdialog/jbide/CssFileParserException.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/cssdialog/jbide/CssFileParserException.java 2010-01-22
14:36:31 UTC (rev 19883)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.ui.bot.test.cssdialog.jbide;
+/**
+ * Exception thrown from CssFileParser class
+ * @author Vladimir Pakan
+ */
+public class CssFileParserException extends RuntimeException {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public CssFileParserException (String errorMessage){
+ super(errorMessage);
+ }
+}
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/cssdialog/jbide/CssFileParserException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/cssdialog/jbide/JBIDE3148and4441Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/cssdialog/jbide/JBIDE3148and4441Test.java 2010-01-22
14:12:31 UTC (rev 19882)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/cssdialog/jbide/JBIDE3148and4441Test.java 2010-01-22
14:36:31 UTC (rev 19883)
@@ -39,7 +39,6 @@
"background-color:green;\r}");
eclipseEditor.save();
eclipseEditor.contextMenu("Open CSS Dialog").click();
-
//Test edit attrs of the first Class
bot.shell("CSS Class").activate();
@@ -57,14 +56,22 @@
bot.comboBoxWithLabel("Font Weight:").setSelection("lighter");
bot.button("Apply").click();
bot.button("OK").click();
-
- //Test check css file content
-
- String fileContainer =
bot.editorByTitle(CSS_FILE_NAME+".css").toTextEditor().getText();
- assertEquals("cssclass{\r\tcolor: red;\r\tbackground-color: green;\r" +
- "\tfont-weight: bold;\r\ttext-decoration: underline\r}\rcssclass" +
- "{\r\tcolor: green;\r\tbackground-color: red;\r" +
- "\tfont-weight: lighter;\r\ttext-decoration: overline\r}", fileContainer);
+ //Test check CSS file content
+ assertTrue("Content of CSS file in Editor is not as expected.\n" +
+ "Content: " +
bot.editorByTitle(CSS_FILE_NAME+".css").toTextEditor().getText(),
+
JBIDE3148and4441Test.testCssFileEditorContent(bot.editorByTitle(CSS_FILE_NAME+".css").toTextEditor(),
+ "cssclass{",
+ "color: red;",
+ "background-color: green;",
+ "font-weight: bold;",
+ "text-decoration: underline",
+ "}",
+ "cssclass{",
+ "color: green;",
+ "background-color: red;",
+ "font-weight: lighter;",
+ "text-decoration: overline",
+ "}"));
bot.editorByTitle(CSS_FILE_NAME+".css").close();
}
@@ -88,4 +95,16 @@
return isOpened;
}
+ private static boolean testCssFileEditorContent (SWTBotEclipseEditor cssFileEditor,
String... lines){
+
+ CssFileParser parserCssFileEditor = new CssFileParser();
+ for (String line : cssFileEditor.getLines()){
+ parserCssFileEditor.addLine(line);
+ }
+ CssFileParser parserExceptedCssFile = new CssFileParser(lines);
+
+ return parserCssFileEditor.compare(parserExceptedCssFile);
+
+ }
+
}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java 2010-01-22
14:12:31 UTC (rev 19882)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java 2010-01-22
14:36:31 UTC (rev 19883)
@@ -37,8 +37,11 @@
public class AddRemoveJSFCapabilitiesTest extends JSFAutoTestCase {
private SWTJBTExt swtJbtExt = null;
+ private SWTUtilExt swtUtilExt = null;
+
public AddRemoveJSFCapabilitiesTest(){
swtJbtExt = new SWTJBTExt(bot);
+ swtUtilExt = new SWTUtilExt(bot);
}
public void testAddRemoveJSFCapabilities() {
boolean jbdsIsRunning = SWTJBTExt.isJBDSRun(bot);
@@ -146,16 +149,9 @@
ContextMenuHelper.prepareTreeItemForContextMenu(tree,
tree.getTreeItem(JBT_TEST_PROJECT_NAME));
- if (jbdsIsRunning){
- new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
- IDELabel.Menu.JBDS_REMOVE_JSF_CAPABILITIES, true)).click();
- }
- else{
- new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
IDELabel.Menu.WEB_PROJECT_JBT_JSF, false)).menu(
IDELabel.Menu.JBT_REMOVE_JSF_CAPABILITIES).click();
-
- }
bot.shell("Confirmation").activate();
bot.button(WidgetVariables.OK_BUTTON).click();
@@ -260,12 +256,12 @@
new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
IDELabel.Menu.CLOSE_PROJECT, false)).click();
- delay();
+ swtUtilExt.waitForNonIgnoredJobs(5*1000L);
new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
IDELabel.Menu.OPEN_PROJECT, false)).click();
- delay();
+ swtUtilExt.waitForNonIgnoredJobs(5*1000L);
}
/**
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java 2010-01-22
14:12:31 UTC (rev 19882)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java 2010-01-22
14:36:31 UTC (rev 19883)
@@ -13,8 +13,6 @@
import static org.jboss.tools.ui.bot.ext.SWTTestExt.eclipse;
-import java.io.IOException;
-
import org.apache.log4j.Logger;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
@@ -27,7 +25,6 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.jboss.tools.ui.bot.ext.types.JobName;
import org.jboss.tools.ui.bot.ext.types.ViewType;
/**
* Provides JBoss Tools common operations based on SWTBot element operations
@@ -104,7 +101,7 @@
* @param index - zero based Position of Server within Server Tree
*/
public static void startApplicationServer(SWTWorkbenchBot bot , int index){
- SWTJBTExt.chooseServerPopupMenu(bot,index, IDELabel.Menu.START,45*1000L);
+ SWTJBTExt.chooseServerPopupMenu(bot,index, IDELabel.Menu.START,120*1000L);
bot.sleep(10*1000L);
}
/**
@@ -121,7 +118,7 @@
* @param index - zero based Position of Server within Server Tree
*/
public static void stopApplicationServer(SWTWorkbenchBot bot , int index){
- SWTJBTExt.chooseServerPopupMenu(bot,index, IDELabel.Menu.STOP,10*1000L);
+ SWTJBTExt.chooseServerPopupMenu(bot,index, IDELabel.Menu.STOP,20*1000L);
}
/**
* Choose Server Popup Menu with specified label on Server with position specified by
index
@@ -238,7 +235,6 @@
final SWTBotMenu menuRunAs = bot.menu(IDELabel.Menu.RUN).menu(IDELabel.Menu.RUN_AS);
final MenuItem menuItem = UIThreadRunnable
.syncExec(new WidgetResult<MenuItem>() {
- @SuppressWarnings("unchecked")
public MenuItem run() {
int menuItemIndex = 0;
MenuItem menuItem = null;
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-01-22
14:12:31 UTC (rev 19882)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-01-22
14:36:31 UTC (rev 19883)
@@ -50,13 +50,11 @@
public static final String CLOSE_PROJECT = "Close Project";
public static final String OPEN_PROJECT = "Open Project";
public static final String DELETE = "Delete";
- public static final String JBDS_REMOVE_JSF_CAPABILITIES = "Remove Red Hat
Capabilities";
public static final String JBT_REMOVE_JSF_CAPABILITIES = "Remove JSF
Capabilities";
public static final String START = "Start";
public static final String STOP = "Stop";
public static final String STRUTS_PROJECT = "Struts Project";
public static final String PREFERENCES = "Preferences";
- public static final String JBDS_REMOVE_STRUTS_CAPABILITIES = "Remove Red Hat
Capabilities";
public static final String JBT_REMOVE_STRUTS_CAPABILITIES = "Remove Struts
Capabilities";
public static final String ADD_STRUTS_CAPABILITIES = "Add Struts
Capabilities...";
public static final String WEB_PROJECT_JBT_STRUTS = "JBoss Tools Struts";
Modified:
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/AddRemoveStrutsCapabilities.java
===================================================================
---
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/AddRemoveStrutsCapabilities.java 2010-01-22
14:12:31 UTC (rev 19882)
+++
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/AddRemoveStrutsCapabilities.java 2010-01-22
14:36:31 UTC (rev 19883)
@@ -56,15 +56,9 @@
ContextMenuHelper.prepareTreeItemForContextMenu(tree,
tree.getTreeItem(StrutsAllBotTests.STRUTS_PROJECT_NAME));
- if (jbdsIsRunning){
- new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
- IDELabel.Menu.JBDS_REMOVE_STRUTS_CAPABILITIES, true)).click();
- }
- else{
- new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
- IDELabel.Menu.WEB_PROJECT_JBT_STRUTS, false)).menu(
- IDELabel.Menu.JBT_REMOVE_STRUTS_CAPABILITIES).click();
- }
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
+ IDELabel.Menu.WEB_PROJECT_JBT_STRUTS, false)).menu(
+ IDELabel.Menu.JBT_REMOVE_STRUTS_CAPABILITIES).click();
bot.shell("Confirmation").activate();
bot.button(IDELabel.Button.OK).click();