Author: dpospisi(a)redhat.com
Date: 2010-12-14 14:20:57 -0500 (Tue, 14 Dec 2010)
New Revision: 27478
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/AbstractSeamTestBase.java
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/EARTests.java
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/WARTests.java
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/validate/ELExprValidator.java
Log:
Fixed Seam bot tests.
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/AbstractSeamTestBase.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/AbstractSeamTestBase.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/AbstractSeamTestBase.java 2010-12-14
19:20:57 UTC (rev 27478)
@@ -0,0 +1,90 @@
+package org.jboss.tools.seam.ui.bot.test;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCLabel;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotLabel;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
+import org.jboss.tools.ui.bot.test.JBTSWTBotTestCase;
+import org.jboss.tools.ui.bot.test.SWTJBTBot;
+import org.junit.BeforeClass;
+
+public abstract class AbstractSeamTestBase extends SWTTestExt {
+
+ public static final String testProjectName = "SeamPrj";
+ public static final String seamConfigPrefix = "Dynamic Web Project with Seam
";
+ public static final String testDomainName = "org.domain";
+
+ public AbstractSeamTestBase() {
+ }
+
+ private String getTestPackageName(String type) {
+ return type == TestControl.TYPE_WAR ?
+ testDomainName + ".seamprjwar.test" :
+ testDomainName + ".seamprjear.test" ;
+ }
+
+
+ /**Creates any Seam Action, Form etc. */
+ public void createSeamUnit(String unitType, String type){
+ bot.menu("File").menu("New").menu("Seam "
+unitType).click();
+ SWTBotShell shell = bot.activeShell();
+ bot.textWithLabel("Seam Project:").setText(testProjectName + type);
+ if ("Entity".equals(unitType)) {
+ bot.textWithLabel("Seam entity class
name:").setText("seam"+unitType);
+ } else {
+ bot.textWithLabel("Seam component
name:").setText("seam"+unitType);
+ }
+ bot.button("Finish").click();
+ bot.waitUntil(Conditions.shellCloses(shell),15000);
+ }
+
+ /**Executes test of any Seam Action , Form etc. */
+ public void checkSeamUnit(String unitType, String type){
+ projectExplorer.selectProject(testProjectName + type + "-test");
+
+ SWTBot viewBot = bot.activeView().bot();
+
+ SWTBotTreeItem suiteItem = projectExplorer.selectTreeItem("Seam" + unitType +
"Test.java", new String[] {
+ testProjectName + type + "-test",
+ "test-src",
+ getTestPackageName(type)
+ });
+
+ ContextMenuHelper.clickContextMenu(viewBot.tree(), "Run As", "2 TestNG
Test");
+ SWTTestExt.util.waitForNonIgnoredJobs(120000);
+
+ SWTBotView ngView = bot.viewByTitle("Results of running test class");
+ SWTBot ngBot = ngView.bot();
+ int k = 0;
+ util.displayAllBotWidgets(ngBot);
+ SWTBotCLabel l = ngBot.clabel(k);
+
+ int passed = -1;
+ int failed = -1;
+ int skipped = -1;
+
+ while ( (passed < 0) || (failed < 0) || (skipped < 0) ) {
+ String txt = l.getText();
+ if (txt.startsWith("Passed")) passed =
Integer.valueOf(txt.split(":")[1].trim());
+ if (txt.startsWith("Failed")) failed =
Integer.valueOf(txt.split(":")[1].trim());
+ if (txt.startsWith("Skipped")) skipped =
Integer.valueOf(txt.split(":")[1].trim());
+ k++;
+ l = ngBot.clabel(k);
+ }
+ assertTrue("Failed test(s).", failed == 0);
+ assertTrue("Skipped test(s).", skipped == 0);
+ assertTrue("No passing tests.", passed > 0);
+
+ }
+
+
+}
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/EARTests.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/EARTests.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/EARTests.java 2010-12-14
19:20:57 UTC (rev 27478)
@@ -0,0 +1,5 @@
+package org.jboss.tools.seam.ui.bot.test;
+
+public interface EARTests {
+
+}
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/WARTests.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/WARTests.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/WARTests.java 2010-12-14
19:20:57 UTC (rev 27478)
@@ -0,0 +1,5 @@
+package org.jboss.tools.seam.ui.bot.test;
+
+public interface WARTests {
+
+}
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/validate/ELExprValidator.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/validate/ELExprValidator.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/validate/ELExprValidator.java 2010-12-14
19:20:57 UTC (rev 27478)
@@ -0,0 +1,69 @@
+package org.jboss.tools.seam.ui.bot.test.validate;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.seam.ui.bot.test.AbstractSeamTestBase;
+import org.jboss.tools.seam.ui.bot.test.EARTests;
+import org.jboss.tools.seam.ui.bot.test.TestControl;
+import org.jboss.tools.seam.ui.bot.test.WARTests;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+public class ELExprValidator extends AbstractSeamTestBase {
+
+ public static String NL = System.getProperty("line.separator");
+
+ @Test
+ @Category(WARTests.class)
+ public void testELExprWar() {
+ testELExpr(TestControl.TYPE_WAR);
+ }
+
+ @Test
+ @Category(EARTests.class)
+ public void testELExprEar() {
+ testELExpr(TestControl.TYPE_EAR);
+ }
+
+ private void testELExpr(String type) {
+
+ SWTBotEclipseEditor editor = projectExplorer.openFile(testProjectName + type,
+ "Web Resources : WebContent", "home.xhtml").toTextEditor();
+
+ // add correct expression
+ int idx = 0;
+ for(String line : editor.getLines()) {
+ if (line.contains("Welcome to Seam")) {
+ editor.insertText(idx, 0, "#{identity.hasRole('admin')}" + NL);
+ break;
+ }
+ idx++;
+ }
+ editor.save();
+ SWTTestExt.util.waitForNonIgnoredJobs(60000);
+
+ // check that there is no problem
+ SWTBotView pBotView = problems.show();
+ SWTBotTreeItem[] sProblems = problems.getFilteredErrorsTreeItems(bot, "hasR",
+ "/" + testProjectName, "home.xhtml", "JSF EL
Problem");
+ assertTrue("JSF-EL problem found.", ( (sProblems == null) ||
(sProblems.length == 0) ));
+
+ // add incorrect expression
+ editor.insertText(idx, 0, "#{identity.hasR('admin')}" + NL);
+ editor.save();
+ SWTTestExt.util.waitForNonIgnoredJobs(60000);
+
+ // check that JSF EL Problem exists
+ pBotView = problems.show();
+ sProblems = problems.getFilteredErrorsTreeItems(bot, "hasR",
+ "/" + testProjectName, "home.xhtml", "JSF EL
Problem");
+ assertTrue("No JSF-EL problem found.", ( (sProblems != null) &&
(sProblems.length > 0) ));
+ assertTrue("More than oneJSF-EL problem found.", sProblems.length <= 1);
+
+
+ editor.close();
+ }
+
+}
Show replies by date