Author: ljelinko
Date: 2011-11-21 05:11:54 -0500 (Mon, 21 Nov 2011)
New Revision: 36471
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/.classpath
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/.project
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/build.properties
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/resources/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/resources/aaa
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/resources/log4j.xml
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/screenshots/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/screenshots/Default -
testcreate(org.jboss.tools.portlet.ui.bot.test.create.CreateJavaPortlet).jpeg
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/screenshots/screenshot-CreateJavaPortlet.testcreate.jpeg
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/Activator.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/AllTestsSuite.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/RequirementAwareUsageWindowClosingSuite.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/AbstractSWTMatcher.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/SWTMatcher.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/problems/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/problems/NumberOfErrorsMatcher.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/problems/ProblemViewMatchersFactory.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ExistingFileMatcher.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ExistingProjectMatcher.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ProjectFacetsMatcher.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/AbstractSWTTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/CompositeSWTTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/SWTBotAware.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/SWTTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/AssociatedPerspectiveDialogClosingTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/ProjectPropertyDialogCloseTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/ProjectPropertyDialogOpenTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/facet/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/facet/AbstractFacetTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/facet/FacetDefinition.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/facet/FacetsSelectionTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardFillingTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardOpeningTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardPageDefaultsFillingTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardPageFillingTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/DynamicWebProjectCreationTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/DynamicWebProjectWizardPageFillingTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/jboss/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/jboss/JBossPortletCapabilitiesWizardPageFillingTask.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/testcase/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/testcase/SWTTaskBasedTestCase.java
Log:
Initial import.
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/.classpath
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/.classpath
(rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/.classpath 2011-11-21 10:11:54
UTC (rev 36471)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="resources"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/.project
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/.project
(rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/.project 2011-11-21 10:11:54
UTC (rev 36471)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.portlet.ui.bot.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Portal Tests
+Bundle-SymbolicName: org.jboss.tools.portlet.ui.bot.test;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-ActivationPolicy: lazy
+Bundle-Vendor:
+ JBoss by Red Hat
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.jboss.tools.jst.ui.bot.test;bundle-version="1.0.0",
+ org.eclipse.swtbot.eclipse.core;bundle-version="2.0.0",
+ org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.0",
+ org.eclipse.swtbot.swt.finder;bundle-version="2.0.0",
+ org.apache.log4j;bundle-version="1.2.13",
+ org.junit4;bundle-version="4.8.1",
+ org.eclipse.datatools.connectivity;bundle-version="1.1.2",
+ org.jboss.tools.ui.bot.ext;bundle-version="1.0.0",
+ org.hamcrest;bundle-version="1.1.0"
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/build.properties
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/build.properties
(rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/build.properties 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,6 @@
+source.. = src/,\
+ resources/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ resources/
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/resources/aaa
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/resources/aaa
(rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/resources/aaa 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1 @@
+SERVER=EPP,5.1.0,default,/home/ljelinko/programs/jboss/jboss-epp-5.1/jboss-as
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/resources/log4j.xml
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/resources/log4j.xml
(rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/resources/log4j.xml 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration
xmlns:log4j="http://jakarta.apache.org/log4j/"
+ debug="false">
+
+ <appender name="consoleAppender"
class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) -
%m%n" />
+ </layout>
+ </appender>
+
+ <appender name="fileAppender"
class="org.apache.log4j.FileAppender">
+ <param name="File" value="/tmp/debug.log" />
+ <param name="Append" value="false" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) -
%m%n" />
+ </layout>
+ </appender>
+
+ <appender name="asyncAppender"
class="org.apache.log4j.AsyncAppender">
+ <!-- appender-ref ref="consoleAppender" / -->
+ <appender-ref ref="fileAppender" />
+ </appender>
+
+ <!-- don't log matchers, this is very high amount of chatter -->
+ <category name="org.eclipse.swtbot.swt.finder.matchers">
+ <priority value="OFF" />
+ </category>
+
+ <!--
+ don't log widget notification events, this is moderately high chatter
+ -->
+ <category name="org.eclipse.swtbot.swt.finder.widgets">
+ <priority value="OFF" />
+ </category>
+
+ <!-- don't log finders, this is moderate chatter -->
+ <category name="org.eclipse.swtbot.swt.finder.finders">
+ <priority value="DEBUG" />
+ </category>
+
+ <category name="org.eclipse.swtbot.swt.finder.keyboard">
+ <!-- set to a value higher than debug to turn on. -->
+ <priority value="DEBUG" />
+ </category>
+
+ <category name="org.eclipse.swtbot">
+ <priority value="ALL" />
+ </category>
+
+ <root>
+ <priority value="INFO" />
+ <appender-ref ref="consoleAppender" />
+ <appender-ref ref="fileAppender" />
+ </root>
+
+</log4j:configuration>
\ No newline at end of file
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/screenshots/Default -
testcreate(org.jboss.tools.portlet.ui.bot.test.create.CreateJavaPortlet).jpeg
===================================================================
(Binary files differ)
Property changes on:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/screenshots/Default -
testcreate(org.jboss.tools.portlet.ui.bot.test.create.CreateJavaPortlet).jpeg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/screenshots/screenshot-CreateJavaPortlet.testcreate.jpeg
===================================================================
(Binary files differ)
Property changes on:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/screenshots/screenshot-CreateJavaPortlet.testcreate.jpeg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/Activator.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/Activator.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/Activator.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,50 @@
+package org.jboss.tools.portlet.ui.bot.test;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.portlet.ui.bot.test";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/AllTestsSuite.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/AllTestsSuite.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/AllTestsSuite.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,13 @@
+package org.jboss.tools.portlet.ui.bot.test;
+
+import org.jboss.tools.portlet.ui.bot.test.create.CreateJavaPortletProject;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+(a)RunWith(RequirementAwareUsageWindowClosingSuite.class)
+(a)Suite.SuiteClasses({
+ CreateJavaPortletProject.class
+ })
+public class AllTestsSuite {
+
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/RequirementAwareUsageWindowClosingSuite.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/RequirementAwareUsageWindowClosingSuite.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/RequirementAwareUsageWindowClosingSuite.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,27 @@
+package org.jboss.tools.portlet.ui.bot.test;
+
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.jboss.tools.ui.bot.ext.SWTBotFactory;
+import org.junit.runners.model.Statement;
+
+/**
+ * Normal {@link RequirementAwareSuite} with the special added functionality of
+ * closing the usage window.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class RequirementAwareUsageWindowClosingSuite extends
+ RequirementAwareSuite {
+
+ public RequirementAwareUsageWindowClosingSuite(Class<?> klass)
+ throws Throwable {
+ super(klass);
+ }
+
+ @Override
+ protected Statement withBeforeClasses(Statement statement) {
+ SWTBotFactory.getJbt().closeReportUsageWindowIfOpened(false);
+ return super.withBeforeClasses(statement);
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,65 @@
+package org.jboss.tools.portlet.ui.bot.test.create;
+
+import static
org.jboss.tools.portlet.ui.bot.test.matcher.problems.ProblemViewMatchersFactory.isNumberOfErrors;
+import static
org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.existsInProject;
+import static
org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.hasFacets;
+import static
org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.isExistingProject;
+
+import org.jboss.tools.portlet.ui.bot.test.task.AbstractSWTTask;
+import org.jboss.tools.portlet.ui.bot.test.task.facet.FacetDefinition;
+import org.jboss.tools.portlet.ui.bot.test.task.facet.FacetsSelectionTask;
+import org.jboss.tools.portlet.ui.bot.test.task.wizard.WizardPageDefaultsFillingTask;
+import
org.jboss.tools.portlet.ui.bot.test.task.wizard.web.DynamicWebProjectCreationTask;
+import
org.jboss.tools.portlet.ui.bot.test.task.wizard.web.jboss.JBossPortletCapabilitiesWizardPageFillingTask;
+import org.jboss.tools.portlet.ui.bot.test.testcase.SWTTaskBasedTestCase;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerType;
+import org.junit.Test;
+
+/**
+ * Creates a new Dynamic Web Project with the specific JBoss Core Portlet facet.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+@Require(server=@Server(required=true, state=ServerState.Present, type=ServerType.EPP))
+public class CreateJavaPortletProject extends SWTTaskBasedTestCase{
+
+ private static final String PROJECT_NAME = "java-portlet";
+
+ private static final String FACET_CATEGORY = "JBoss Portlets";
+
+ private static final String FACET_NAME = "JBoss Core Portlet";
+
+ @Test
+ public void testcreate(){
+ doPerform(getCreateDynamicWebProjectTask());
+
+ doAssertThat(0, isNumberOfErrors());
+ doAssertThat(PROJECT_NAME, isExistingProject());
+ doAssertThat("WebContent/WEB-INF/portlet.xml",
existsInProject(PROJECT_NAME));
+ doAssertThat("JBoss Portlet Libraries", existsInProject(PROJECT_NAME));
+ doAssertThat(PROJECT_NAME, hasFacets(new FacetDefinition(FACET_NAME,
FACET_CATEGORY)));
+ }
+
+ private AbstractSWTTask getCreateDynamicWebProjectTask() {
+ DynamicWebProjectCreationTask task = new DynamicWebProjectCreationTask();
+ task.setProjectName(PROJECT_NAME);
+ task.setWebModuleVersion("2.5");
+ task.setServerName(SWTTestExt.configuredState.getServer().name);
+ task.setSelectFacetsTask(getSelectFacetsTask());
+ task.addWizardPage(new WizardPageDefaultsFillingTask());
+ task.addWizardPage(new WizardPageDefaultsFillingTask());
+ task.addWizardPage(new
JBossPortletCapabilitiesWizardPageFillingTask(JBossPortletCapabilitiesWizardPageFillingTask.Type.RUNTIME_PROVIDER));
+ return task;
+ }
+
+ private FacetsSelectionTask getSelectFacetsTask() {
+ FacetsSelectionTask task = new FacetsSelectionTask();
+ task.addFacet(new FacetDefinition(FACET_NAME, FACET_CATEGORY));
+ return task;
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/AbstractSWTMatcher.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/AbstractSWTMatcher.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/AbstractSWTMatcher.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,33 @@
+package org.jboss.tools.portlet.ui.bot.test.matcher;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.hamcrest.TypeSafeMatcher;
+import org.jboss.tools.portlet.ui.bot.test.task.SWTBotAware;
+import org.jboss.tools.portlet.ui.bot.test.task.SWTTask;
+
+/**
+ * Common ancestor of all SWT based matchers.
+ *
+ * @author Lucia Jelinkova
+ *
+ * @param <T>
+ */
+public abstract class AbstractSWTMatcher<T> extends TypeSafeMatcher<T>
implements SWTMatcher<T>, SWTBotAware {
+
+ private SWTBot bot;
+
+ protected void performInnerTask(SWTTask task){
+ if (task instanceof SWTBotAware){
+ ((SWTBotAware) task).setBot(getBot());
+ }
+ task.perform();
+ }
+
+ public SWTBot getBot() {
+ return bot;
+ }
+
+ public void setBot(SWTBot bot) {
+ this.bot = bot;
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/SWTMatcher.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/SWTMatcher.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/SWTMatcher.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,14 @@
+package org.jboss.tools.portlet.ui.bot.test.matcher;
+
+import org.hamcrest.Matcher;
+
+/**
+ * Matcher for SWT based tests.
+ *
+ * @author Lucia Jelinkova
+ *
+ * @param <T>
+ */
+public interface SWTMatcher<T> extends Matcher<T> {
+
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/problems/NumberOfErrorsMatcher.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/problems/NumberOfErrorsMatcher.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/problems/NumberOfErrorsMatcher.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,42 @@
+package org.jboss.tools.portlet.ui.bot.test.matcher.problems;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.hamcrest.Description;
+import org.jboss.tools.portlet.ui.bot.test.matcher.AbstractSWTMatcher;
+import org.jboss.tools.ui.bot.ext.SWTBotFactory;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+import org.jboss.tools.ui.bot.ext.view.ProblemsView;
+
+/**
+ * Checks the number of Errors on the Problems view.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class NumberOfErrorsMatcher extends AbstractSWTMatcher<Integer> {
+
+ private int numberOfErrors;
+
+ @Override
+ public boolean matchesSafely(Integer expectedNumber) {
+ SWTBotFactory.getOpen().perspective(ActionItem.Perspective.JAVA.LABEL);
+ SWTBotTreeItem errorItem = ProblemsView.getErrorsNode(SWTBotFactory.getBot());
+
+ if (errorItem == null){
+ if (expectedNumber.equals(0)){
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ numberOfErrors = errorItem.getNodes().size();
+
+ return expectedNumber.equals(numberOfErrors);
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText(numberOfErrors + " errors");
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/problems/ProblemViewMatchersFactory.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/problems/ProblemViewMatchersFactory.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/problems/ProblemViewMatchersFactory.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,20 @@
+package org.jboss.tools.portlet.ui.bot.test.matcher.problems;
+
+import org.jboss.tools.portlet.ui.bot.test.matcher.SWTMatcher;
+
+/**
+ * Factory of matchers for Problems View.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class ProblemViewMatchersFactory {
+
+ public ProblemViewMatchersFactory() {
+ // not to be instantiated
+ }
+
+ public static SWTMatcher<Integer> isNumberOfErrors(){
+ return new NumberOfErrorsMatcher();
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ExistingFileMatcher.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ExistingFileMatcher.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ExistingFileMatcher.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,40 @@
+package org.jboss.tools.portlet.ui.bot.test.matcher.workspace;
+
+import org.hamcrest.Description;
+import org.jboss.tools.portlet.ui.bot.test.matcher.AbstractSWTMatcher;
+import org.jboss.tools.ui.bot.ext.SWTBotFactory;
+import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+
+/**
+ * Checks if the file exists in the project.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class ExistingFileMatcher extends AbstractSWTMatcher<String> {
+
+ private static final String FILE_SEPARATOR = "/";
+
+ private String project;
+
+ public ExistingFileMatcher(String project) {
+ this.project = project;
+ }
+
+ @Override
+ public boolean matchesSafely(String path) {
+ SWTBotFactory.getOpen().perspective(ActionItem.Perspective.JAVA.LABEL);
+ try {
+ SWTEclipseExt.openFile(SWTBotFactory.getBot(), project, path.split(FILE_SEPARATOR));
+ return true;
+ } catch (Exception e){
+ return false;
+ }
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendValue("existing file");
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ExistingProjectMatcher.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ExistingProjectMatcher.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ExistingProjectMatcher.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,28 @@
+package org.jboss.tools.portlet.ui.bot.test.matcher.workspace;
+
+import org.hamcrest.Description;
+import org.jboss.tools.portlet.ui.bot.test.matcher.AbstractSWTMatcher;
+import org.jboss.tools.ui.bot.ext.SWTBotFactory;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+
+/**
+ * Checks if the project exists in the workspace.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class ExistingProjectMatcher extends AbstractSWTMatcher<String> {
+
+ @Override
+ public boolean matchesSafely(String project) {
+ SWTBotFactory.getOpen().perspective(ActionItem.Perspective.JAVA.LABEL);
+ return SWTBotFactory.getEclipse().isProjectInPackageExplorer(project);
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendValue("existing project");
+ }
+}
+
+
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ProjectFacetsMatcher.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ProjectFacetsMatcher.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/ProjectFacetsMatcher.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,65 @@
+package org.jboss.tools.portlet.ui.bot.test.matcher.workspace;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.hamcrest.Description;
+import org.jboss.tools.portlet.ui.bot.test.matcher.AbstractSWTMatcher;
+import org.jboss.tools.portlet.ui.bot.test.task.dialog.ProjectPropertyDialogCloseTask;
+import org.jboss.tools.portlet.ui.bot.test.task.dialog.ProjectPropertyDialogOpenTask;
+import org.jboss.tools.portlet.ui.bot.test.task.facet.AbstractFacetTask;
+import org.jboss.tools.portlet.ui.bot.test.task.facet.FacetDefinition;
+
+/**
+ * Checks if the project has the specified facets.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class ProjectFacetsMatcher extends AbstractSWTMatcher<String> {
+
+ private List<FacetDefinition> facets;
+
+ public ProjectFacetsMatcher(FacetDefinition... facets) {
+ this.facets = Arrays.asList(facets);
+ }
+
+ @Override
+ public boolean matchesSafely(String project) {
+ showPropertyDialog(project);
+ return checkFacets();
+ }
+
+ private void showPropertyDialog(String project) {
+ ProjectPropertyDialogOpenTask openTask = new ProjectPropertyDialogOpenTask();
+ openTask.setProject(project);
+ openTask.setPropertyPage("Project Facets");
+ performInnerTask(openTask);
+ }
+
+ private boolean checkFacets() {
+ ValueCheckedTask task = new ValueCheckedTask();
+ for (FacetDefinition facet : facets){
+ task.addFacet(facet);
+ }
+ performInnerTask(task);
+
+ performInnerTask(new ProjectPropertyDialogCloseTask());
+ return task.allChecked;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendValue("file containing facet");
+ }
+
+ class ValueCheckedTask extends AbstractFacetTask {
+ private boolean allChecked = true;
+
+ @Override
+ protected void processFacet(SWTBotTreeItem facetItem) {
+ allChecked = allChecked && facetItem.isChecked();
+ }
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,29 @@
+package org.jboss.tools.portlet.ui.bot.test.matcher.workspace;
+
+import org.jboss.tools.portlet.ui.bot.test.matcher.SWTMatcher;
+import org.jboss.tools.portlet.ui.bot.test.task.facet.FacetDefinition;
+
+/**
+ * Factory for workspace specific matchers (projects, files..)
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class WorkspaceMatchersFactory {
+
+ private WorkspaceMatchersFactory(){
+ // not to be instantiated
+ }
+
+ public static SWTMatcher<String> isExistingProject(){
+ return new ExistingProjectMatcher();
+ }
+
+ public static SWTMatcher<String> existsInProject(String project){
+ return new ExistingFileMatcher(project);
+ }
+
+ public static SWTMatcher<String> hasFacets(FacetDefinition... facets){
+ return new ProjectFacetsMatcher(facets);
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/AbstractSWTTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/AbstractSWTTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/AbstractSWTTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,29 @@
+package org.jboss.tools.portlet.ui.bot.test.task;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+
+/**
+ * Common ancestor of all UI tasks.
+ *
+ * @author ljelinko
+ *
+ */
+public abstract class AbstractSWTTask implements SWTTask, SWTBotAware {
+
+ private SWTBot bot;
+
+ protected void performInnerTask(SWTTask task){
+ if (task instanceof SWTBotAware){
+ ((SWTBotAware) task).setBot(getBot());
+ }
+ task.perform();
+ }
+
+ public SWTBot getBot() {
+ return bot;
+ }
+
+ public void setBot(SWTBot bot) {
+ this.bot = bot;
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/CompositeSWTTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/CompositeSWTTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/CompositeSWTTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,46 @@
+package org.jboss.tools.portlet.ui.bot.test.task;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Performs a set of tasks and enables subclasses to define actions before and after
+ * each of the tasks is performed.
+ *
+ * @author ljelinko
+ *
+ */
+public class CompositeSWTTask<T extends SWTTask> extends AbstractSWTTask {
+
+ private List<T> tasks;
+
+ public CompositeSWTTask() {
+ super();
+ tasks = new ArrayList<T>();
+ }
+
+ @Override
+ public void perform() {
+ for (T task : tasks){
+ beforeTask(task);
+ performInnerTask(task);
+ afterTask(task);
+ }
+ }
+
+ protected void beforeTask(T task) {
+ // hook up method
+ }
+
+ protected void afterTask(T task) {
+ // hook up method
+ }
+
+ public void addTask(T task){
+ tasks.add(task);
+ }
+
+ public List<T> getTasks() {
+ return tasks;
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/SWTBotAware.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/SWTBotAware.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/SWTBotAware.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,14 @@
+package org.jboss.tools.portlet.ui.bot.test.task;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+
+/**
+ * Marking that the class should be aware of SWT bot.
+ *
+ * @author ljelinko
+ *
+ */
+public interface SWTBotAware {
+
+ void setBot(SWTBot bot);
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/SWTTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/SWTTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/SWTTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,13 @@
+package org.jboss.tools.portlet.ui.bot.test.task;
+
+/**
+ * Encapsulates all the information needed to perform a task on the UI.
+ *
+ * @author ljelinko
+ *
+ */
+public interface SWTTask {
+
+ void perform();
+
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/AssociatedPerspectiveDialogClosingTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/AssociatedPerspectiveDialogClosingTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/AssociatedPerspectiveDialogClosingTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,41 @@
+package org.jboss.tools.portlet.ui.bot.test.task.dialog;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.jboss.tools.portlet.ui.bot.test.task.AbstractSWTTask;
+
+/**
+ * Checks if there is a dialog asking if the associated perspective
+ * should be open and if so, clicks Yes or No button depending on the
+ * constructor argument.
+ *
+ * @author ljelinko
+ *
+ */
+public class AssociatedPerspectiveDialogClosingTask extends AbstractSWTTask {
+
+ private boolean open;
+
+ public AssociatedPerspectiveDialogClosingTask(boolean open) {
+ this.open = open;
+ }
+
+ @Override
+ public void perform() {
+
+ SWTBot bot;
+
+ try {
+ bot = getBot().shell("Open Associated Perspective?").activate().bot();
+ } catch (WidgetNotFoundException e) {
+ // dialog is not open, skip the rest
+ return;
+ }
+
+ if (open){
+ bot.button("Yes").click();
+ } else {
+ bot.button("No").click();
+ }
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/ProjectPropertyDialogCloseTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/ProjectPropertyDialogCloseTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/ProjectPropertyDialogCloseTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,11 @@
+package org.jboss.tools.portlet.ui.bot.test.task.dialog;
+
+import org.jboss.tools.portlet.ui.bot.test.task.AbstractSWTTask;
+
+public class ProjectPropertyDialogCloseTask extends AbstractSWTTask {
+
+ @Override
+ public void perform() {
+ getBot().button("OK").click();
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/ProjectPropertyDialogOpenTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/ProjectPropertyDialogOpenTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/dialog/ProjectPropertyDialogOpenTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,36 @@
+package org.jboss.tools.portlet.ui.bot.test.task.dialog;
+
+import org.jboss.tools.portlet.ui.bot.test.task.AbstractSWTTask;
+import org.jboss.tools.ui.bot.ext.SWTBotFactory;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.view.PackageExplorer;
+
+public class ProjectPropertyDialogOpenTask extends AbstractSWTTask{
+
+ private String project;
+
+ private String propertyPage;
+
+ @Override
+ public void perform() {
+ SWTBotFactory.getOpen().viewOpen(ActionItem.View.JavaPackageExplorer.LABEL);
+
+ PackageExplorer projectExplorer = SWTBotFactory.getPackageexplorer();
+ projectExplorer.selectProject(project);
+
+ ContextMenuHelper.clickContextMenu(projectExplorer.bot().tree(),
+ "Properties");
+
+ SWTBotFactory.getEclipse().waitForShell("Properties for " + project);
+ getBot().tree().expandNode(propertyPage).select();
+ }
+
+ public void setProject(String project) {
+ this.project = project;
+ }
+
+ public void setPropertyPage(String propertyPage) {
+ this.propertyPage = propertyPage;
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/facet/AbstractFacetTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/facet/AbstractFacetTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/facet/AbstractFacetTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,86 @@
+package org.jboss.tools.portlet.ui.bot.test.task.facet;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.jboss.tools.portlet.ui.bot.test.task.AbstractSWTTask;
+
+/**
+ * Common ancestor for facet handling tasks that can locate the facet node
+ * in the tree (it can be simple facet of facet with category).
+ *
+ * It lets the subclasses to define the action upon the facet.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public abstract class AbstractFacetTask extends AbstractSWTTask {
+
+ private List<FacetDefinition> facets;
+
+ public AbstractFacetTask() {
+ facets = new ArrayList<FacetDefinition>();
+ }
+
+ protected abstract void processFacet(SWTBotTreeItem facetItem);
+
+ @Override
+ public void perform() {
+ SWTBotTree tree = getTree();
+ for (FacetDefinition facet : facets){
+ processFacet(getTreeItem(tree, facet));
+ }
+ }
+
+ protected SWTBotTree getTree(){
+ Tree tree = getBot().widget(new ProjectFacetsTableMatcher());
+ return new SWTBotTree(tree);
+ }
+
+ /**
+ *
+ * @param tree
+ * @param facet
+ * @return The facet node (single or located within category)
+ */
+ protected SWTBotTreeItem getTreeItem(SWTBotTree tree, FacetDefinition facet){
+ if (facet.getCategory() == null){
+ return tree.getTreeItem(facet.getName());
+ } else {
+ tree.expandNode(facet.getCategory());
+ return tree.getTreeItem(facet.getCategory()).getNode(facet.getName());
+ }
+ }
+
+ public void addFacet(FacetDefinition facet){
+ facets.add(facet);
+ }
+
+ /**
+ * Matcher for locating the facet selection tree on the screen.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+ private static class ProjectFacetsTableMatcher extends BaseMatcher<Tree> {
+
+ @Override
+ public boolean matches(Object item) {
+ if (!(item instanceof Tree)){
+ return false;
+ }
+ Tree tree = (Tree) item;
+
+ return tree.getColumnCount() > 0 && "Project
Facet".equals(tree.getColumn(0).getText());
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ }
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/facet/FacetDefinition.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/facet/FacetDefinition.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/facet/FacetDefinition.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,35 @@
+package org.jboss.tools.portlet.ui.bot.test.task.facet;
+
+public class FacetDefinition {
+
+ private String category;
+
+ private String name;
+
+ public FacetDefinition(String name) {
+ super();
+ this.name = name;
+ }
+
+ public FacetDefinition(String name, String category) {
+ super();
+ this.category = category;
+ this.name = name;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
\ No newline at end of file
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/facet/FacetsSelectionTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/facet/FacetsSelectionTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/facet/FacetsSelectionTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,17 @@
+package org.jboss.tools.portlet.ui.bot.test.task.facet;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+
+/**
+ * Selects the given facets in the Project facetss tree.
+ *
+ * @author ljelinko
+ *
+ */
+public class FacetsSelectionTask extends AbstractFacetTask {
+
+ @Override
+ protected void processFacet(SWTBotTreeItem facetItem) {
+ facetItem.check();
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardFillingTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardFillingTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardFillingTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,31 @@
+package org.jboss.tools.portlet.ui.bot.test.task.wizard;
+
+import org.jboss.tools.portlet.ui.bot.test.task.CompositeSWTTask;
+
+/**
+ *
+ * Provides the functionality of navigating between wizard pages. The data
+ * should fill every wizard page itself.
+ *
+ * @author ljelinko
+ *
+ */
+public class WizardFillingTask extends CompositeSWTTask<WizardPageFillingTask>{
+
+ @Override
+ public void perform() {
+ super.perform();
+ getBot().button("Finish").click();
+ }
+
+ @Override
+ protected void beforeTask(WizardPageFillingTask task) {
+ if (!isFirst(task)){
+ getBot().button("Next >").click();
+ }
+ }
+
+ private boolean isFirst(WizardPageFillingTask task){
+ return getTasks().indexOf(task) == 0;
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardOpeningTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardOpeningTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardOpeningTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,47 @@
+package org.jboss.tools.portlet.ui.bot.test.task.wizard;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.portlet.ui.bot.test.task.AbstractSWTTask;
+
+/**
+ * Opens a specified wizard.
+ *
+ * @author ljelinko
+ *
+ */
+public class WizardOpeningTask extends AbstractSWTTask {
+
+ private String category;
+
+ private String name;
+
+ public WizardOpeningTask(String name) {
+ super();
+ this.name = name;
+ }
+
+ public WizardOpeningTask(String name, String category) {
+ this(name);
+ this.category = category;
+ }
+
+ @Override
+ public void perform() {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotTree tree = getBot().tree();
+ getTreeItem(tree).select();
+
+ getBot().button("Next >").click();
+ }
+
+ private SWTBotTreeItem getTreeItem(SWTBotTree tree){
+ if (category == null){
+ return tree.getTreeItem(name);
+ } else {
+ tree.expandNode(category);
+ return tree.getTreeItem(category).getNode(name);
+ }
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardPageDefaultsFillingTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardPageDefaultsFillingTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardPageDefaultsFillingTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,18 @@
+package org.jboss.tools.portlet.ui.bot.test.task.wizard;
+
+import org.jboss.tools.portlet.ui.bot.test.task.AbstractSWTTask;
+
+/**
+ * Leaves the defaults on the wizard page.
+ *
+ * @author ljelinko
+ *
+ */
+public class WizardPageDefaultsFillingTask extends AbstractSWTTask implements
+ WizardPageFillingTask {
+
+ @Override
+ public void perform() {
+ // leave defaults
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardPageFillingTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardPageFillingTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/WizardPageFillingTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,14 @@
+package org.jboss.tools.portlet.ui.bot.test.task.wizard;
+
+import org.jboss.tools.portlet.ui.bot.test.task.SWTTask;
+
+/**
+ * Common ancestor for tasks filling in information into the wizard page.
+ * Currently just the marking interface.
+ *
+ * @author ljelinko
+ *
+ */
+public interface WizardPageFillingTask extends SWTTask {
+
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/DynamicWebProjectCreationTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/DynamicWebProjectCreationTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/DynamicWebProjectCreationTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,54 @@
+package org.jboss.tools.portlet.ui.bot.test.task.wizard.web;
+
+import
org.jboss.tools.portlet.ui.bot.test.task.dialog.AssociatedPerspectiveDialogClosingTask;
+import org.jboss.tools.portlet.ui.bot.test.task.facet.FacetsSelectionTask;
+import org.jboss.tools.portlet.ui.bot.test.task.wizard.WizardFillingTask;
+import org.jboss.tools.portlet.ui.bot.test.task.wizard.WizardOpeningTask;
+import org.jboss.tools.portlet.ui.bot.test.task.wizard.WizardPageFillingTask;
+
+/**
+ * Creates a new dynamic web project using the wizard.
+ *
+ * @author ljelinko
+ *
+ */
+public class DynamicWebProjectCreationTask extends WizardFillingTask {
+
+ private DynamicWebProjectWizardPageFillingTask firstPage;
+
+ private WizardFillingTask wizardFillingTask;
+
+ public DynamicWebProjectCreationTask() {
+ super();
+ firstPage = new DynamicWebProjectWizardPageFillingTask();
+ wizardFillingTask = new WizardFillingTask();
+ wizardFillingTask.addTask(firstPage);
+ }
+
+ @Override
+ public void perform() {
+ performInnerTask(new WizardOpeningTask("Dynamic Web Project",
"Web"));
+ performInnerTask(wizardFillingTask);
+ performInnerTask(new AssociatedPerspectiveDialogClosingTask(false));
+ }
+
+ public void addWizardPage(WizardPageFillingTask page){
+ wizardFillingTask.addTask(page);
+ }
+
+ public void setProjectName(String projectName) {
+ firstPage.setProjectName(projectName);
+ }
+
+ public void setWebModuleVersion(String webModuleVersion) {
+ firstPage.setWebModuleVersion(webModuleVersion);
+ }
+
+ public void setServerName(String serverName) {
+ firstPage.setServerName(serverName);
+ }
+
+ public void setSelectFacetsTask(FacetsSelectionTask selectFacetsTask) {
+ firstPage.setSelectFacetsTask(selectFacetsTask);
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/DynamicWebProjectWizardPageFillingTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/DynamicWebProjectWizardPageFillingTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/DynamicWebProjectWizardPageFillingTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,57 @@
+package org.jboss.tools.portlet.ui.bot.test.task.wizard.web;
+
+import org.jboss.tools.portlet.ui.bot.test.task.AbstractSWTTask;
+import org.jboss.tools.portlet.ui.bot.test.task.facet.FacetsSelectionTask;
+import org.jboss.tools.portlet.ui.bot.test.task.wizard.WizardPageFillingTask;
+
+/**
+ * Fills in the information of the first page of Dynamic Web Project Wizard.
+ * @author ljelinko
+ *
+ */
+public class DynamicWebProjectWizardPageFillingTask extends AbstractSWTTask
+ implements WizardPageFillingTask {
+
+ private String projectName;
+
+ private String webModuleVersion;
+
+ private String serverName;
+
+ private FacetsSelectionTask selectFacetsTask;
+
+ @Override
+ public void perform() {
+ getBot().textWithLabel("Project name:").typeText(projectName);
+
+ if (webModuleVersion != null){
+ getBot().comboBoxInGroup("Dynamic web module
version").setSelection(webModuleVersion);
+ }
+
+ if (serverName != null){
+ getBot().comboBoxInGroup("Target runtime").setSelection(serverName);
+ }
+
+ if (selectFacetsTask != null){
+ getBot().button("Modify...").click();
+ performInnerTask(selectFacetsTask);
+ getBot().button("OK").click();
+ }
+ }
+
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+ public void setWebModuleVersion(String webModuleVersion) {
+ this.webModuleVersion = webModuleVersion;
+ }
+
+ public void setServerName(String serverName) {
+ this.serverName = serverName;
+ }
+
+ public void setSelectFacetsTask(FacetsSelectionTask selectFacetsTask) {
+ this.selectFacetsTask = selectFacetsTask;
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/jboss/JBossPortletCapabilitiesWizardPageFillingTask.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/jboss/JBossPortletCapabilitiesWizardPageFillingTask.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/task/wizard/web/jboss/JBossPortletCapabilitiesWizardPageFillingTask.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,44 @@
+package org.jboss.tools.portlet.ui.bot.test.task.wizard.web.jboss;
+
+import org.jboss.tools.portlet.ui.bot.test.task.AbstractSWTTask;
+import org.jboss.tools.portlet.ui.bot.test.task.wizard.WizardPageFillingTask;
+
+/**
+ * Fills the JBoss portlet specific wizard page (for selection of
+ * how the portlet libraries should be configured)
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class JBossPortletCapabilitiesWizardPageFillingTask extends
+ AbstractSWTTask implements WizardPageFillingTask {
+
+ public enum Type {
+ DISABLED("Disable Library Configuration"),
+ USER("User library"),
+ RUNTIME_PROVIDER("Portlet Target Runtime Provider");
+
+ private String desc;
+
+ private Type(String s) {
+ desc = s;
+ }
+
+ @Override
+ public String toString() {
+ return desc;
+ }
+ }
+
+ private Type type;
+
+ public JBossPortletCapabilitiesWizardPageFillingTask(Type type) {
+ super();
+ this.type = type;
+ }
+
+ @Override
+ public void perform() {
+ getBot().comboBoxWithLabel("Type:").setSelection(type.toString());
+ }
+}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/testcase/SWTTaskBasedTestCase.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/testcase/SWTTaskBasedTestCase.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/testcase/SWTTaskBasedTestCase.java 2011-11-21
10:11:54 UTC (rev 36471)
@@ -0,0 +1,33 @@
+package org.jboss.tools.portlet.ui.bot.test.testcase;
+
+import static org.junit.Assert.assertThat;
+
+import org.eclipse.jface.viewers.deferred.SetModel;
+import org.jboss.tools.portlet.ui.bot.test.matcher.SWTMatcher;
+import org.jboss.tools.portlet.ui.bot.test.task.SWTBotAware;
+import org.jboss.tools.portlet.ui.bot.test.task.SWTTask;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+
+/**
+ * Common ancestor for SWT tests that wish to use {@link SWTTask} and {@link SWTMatcher}
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class SWTTaskBasedTestCase extends SWTTestExt {
+
+ protected void doPerform(SWTTask task){
+ if (task instanceof SWTBotAware){
+ ((SWTBotAware) task).setBot(bot);
+ }
+ task.perform();
+ }
+
+ protected <T> void doAssertThat(T actual, SWTMatcher<T> matcher){
+ if (matcher instanceof SWTBotAware){
+ ((SWTBotAware) matcher).setBot(bot);
+ }
+ assertThat(actual, matcher);
+ }
+
+}