Author: lzoubek(a)redhat.com
Date: 2011-07-18 08:11:16 -0400 (Mon, 18 Jul 2011)
New Revision: 33009
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/Booking22EAR.java
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/DVDStore22EAR.java
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/SeamExample.java
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/META-INF/MANIFEST.MF
Log:
seam bot tests: added booking and dvdstore project example tests
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/META-INF/MANIFEST.MF 2011-07-18
11:53:03 UTC (rev 33008)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/META-INF/MANIFEST.MF 2011-07-18
12:11:16 UTC (rev 33009)
@@ -18,3 +18,4 @@
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: JBoss by Red Hat
+Export-Package: org.jboss.tools.seam.ui.bot.test.examples
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/Booking22EAR.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/Booking22EAR.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/Booking22EAR.java 2011-07-18
12:11:16 UTC (rev 33009)
@@ -0,0 +1,26 @@
+package org.jboss.tools.seam.ui.bot.test.examples;
+
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Seam;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
+
+@SWTBotTestRequires(server=@Server(state=ServerState.Running),seam=(a)Seam(version="2.2"))
+public class Booking22EAR extends SeamExample {
+
+ @Override
+ public String[] getProjectNames() {
+ return new String[]
{"booking22","booking22-ear","booking22-ejb","booking22-test"};
+ }
+
+ @Override
+ public String getExampleName() {
+ return "Seam 2.2 Booking Example - EAR (including a tutorial)";
+ }
+ @Override
+ protected void executeExample() {
+ runExample();
+ checkDeployment("http://localhost:8080/booking22/home.seam","About this
example application");
+ execSeamTestNG(getProjectNames()[getProjectNames().length-1],
"testngjdk6.launch", "testngjdk6");
+ }
+}
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/DVDStore22EAR.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/DVDStore22EAR.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/DVDStore22EAR.java 2011-07-18
12:11:16 UTC (rev 33009)
@@ -0,0 +1,30 @@
+package org.jboss.tools.seam.ui.bot.test.examples;
+
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Seam;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
+import org.junit.AfterClass;
+
+@SWTBotTestRequires(server=@Server(state=ServerState.Running),seam=(a)Seam(version="2.2"))
+public class DVDStore22EAR extends SeamExample {
+
+ @AfterClass
+ public static void time() {
+ bot.sleep(Long.MAX_VALUE);
+ }
+ @Override
+ public String[] getProjectNames() {
+ return new String[]
{"dvdstore22","dvdstore22-ear","dvdstore22-ejb","dvdstore22-test"};
+ }
+ @Override
+ public String getExampleName() {
+ return "Seam 2.2 DVD Store Example - EAR (including a test project)";
+ }
+ @Override
+ protected void executeExample() {
+ runExample();
+ checkDeployment("http://localhost:8080/dvdstore22/home","Welcome to the
DVD Store");
+ execSeamTestNG(getProjectNames()[getProjectNames().length-1],
"testngjdk6.launch", "testngjdk6");
+ }
+}
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/SeamExample.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/SeamExample.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.bot.test/src/org/jboss/tools/seam/ui/bot/test/examples/SeamExample.java 2011-07-18
12:11:16 UTC (rev 33009)
@@ -0,0 +1,98 @@
+package org.jboss.tools.seam.ui.bot.test.examples;
+
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.WidgetResult;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotBrowser;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCLabel;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.ExampleTest;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+
+public class SeamExample extends ExampleTest {
+
+ @Override
+ public String getExampleCategory() {
+ return "Seam";
+ }
+ protected void runExample() {
+ util.waitForNonIgnoredJobs(Timing.time100S());// for project build
+ packageExplorer.runOnServer(getProjectNames()[0]);
+ util.waitForNonIgnoredJobs();//wait for publishing
+ bot.sleep(Timing.time20S());//wait for deployment
+ }
+ protected void checkDeployment(String url, String searchString) {
+ long delay = SWTBotPreferences.TIMEOUT;
+ SWTBotPreferences.TIMEOUT = delay * 4;
+ SWTBotBrowser b = bot.browser();
+ b.setUrl(url);
+ String page = b.getText();
+ SWTBotPreferences.TIMEOUT = delay;
+ assertTrue("Example was not successfully deployed, server returned
:"+page,page.contains(searchString));
+ }
+
+ protected void execSeamTestNG(String project, String launchFile, String launchName){
+ runTestNG(project, launchFile, launchName);
+ SWTTestExt.util.waitForNonIgnoredJobs(Timing.time100S());
+ bot.sleep(Timing.time(30*1000));
+ SWTBot ngBot = bot.viewByTitle("Results of running suite").bot();
+ int k = 0;
+ 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);
+ }
+
+ private void runTestNG(String project, String launchFile, final String launchName) {
+ SWTBot viewBot = packageExplorer.bot();
+ packageExplorer.selectProject(project);
+ SWTBotTreeItem item = packageExplorer.selectTreeItem(launchFile, new String[]
{project});
+ ContextMenuHelper.prepareTreeItemForContextMenu(viewBot.tree(), item);
+ final SWTBotMenu menuRunAs =
viewBot.menu(IDELabel.Menu.RUN).menu(IDELabel.Menu.RUN_AS);
+ final MenuItem menuItem = UIThreadRunnable
+ .syncExec(new WidgetResult<MenuItem>() {
+ public MenuItem run() {
+ int menuItemIndex = 0;
+ MenuItem menuItem = null;
+ final MenuItem[] menuItems = menuRunAs.widget.getMenu().getItems();
+ while (menuItem == null && menuItemIndex < menuItems.length){
+ log.info("Found item" +menuItems[menuItemIndex].getText());
+ if (menuItems[menuItemIndex].getText().indexOf(launchName) > - 1){
+ menuItem = menuItems[menuItemIndex];
+ }
+ else{
+ menuItemIndex++;
+ }
+ }
+ return menuItem;
+ }
+ });
+ if (menuItem != null){
+ new SWTBotMenu(menuItem).click();
+ }
+ else{
+ throw new WidgetNotFoundException(String.format("Unable to find Menu Item
with Label '%s'",launchName));
+ }
+
+ }
+}
Show replies by date