Author: rawagner
Date: 2012-08-06 03:53:29 -0400 (Mon, 06 Aug 2012)
New Revision: 42856
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/utils/
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/utils/ProjectHasNature.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/utils/TableHasRows.java
Removed:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar1/target/
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar2/target/
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Utils.java
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.project
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/META-INF/MANIFEST.MF
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/pom.xml
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar1/.settings/org.eclipse.m2e.core.prefs
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar2/.settings/org.eclipse.m2e.core.prefs
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/AbstractMavenSWTBotTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/ConfiguratorsTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenProjectsTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedEARProjectTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JBossPerspectiveTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MaterializeLibraryTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenAllBotTests.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfileSelectionTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/usersettings/settings.xml
Log:
swtbot tests updated and refactored
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.project
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.project 2012-08-04 01:24:50 UTC
(rev 42855)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.project 2012-08-06 07:53:29 UTC
(rev 42856)
@@ -6,6 +6,11 @@
</projects>
<buildSpec>
<buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
@@ -30,6 +35,7 @@
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
<linkedResources>
<link>
@@ -53,6 +59,16 @@
<location>/home/eiden/Java/RedHat/Eclipses/jbds5m5a/studio/plugins/org.jboss.tools.jst.web.kb_3.3.0.v20111208-2115-H35-M5</location>
</link>
<link>
+ <name>lib-org.jboss.tools.jst.web.kb_3.3.0.v20120302-0221-H55-Beta1</name>
+ <type>2</type>
+ <location>/home/eiden/RedHat/Eclipses/JBDS/versions/5.0.0.Beta2/studio/plugins/org.jboss.tools.jst.web.kb_3.3.0.v20120302-0221-H55-Beta1</location>
+ </link>
+ <link>
+ <name>lib-org.jboss.tools.jst.web.kb_3.3.1.v20120706-1741-H89-CR1</name>
+ <type>2</type>
+ <location>/files/RedHat/JBoss/JBDS/versions/5.0.1/studio/plugins/org.jboss.tools.jst.web.kb_3.3.1.v20120706-1741-H89-CR1</location>
+ </link>
+ <link>
<name>lib-org.jboss.tools.tests_3.2.0.v20111108-2302-Beta1</name>
<type>2</type>
<location>/home/eiden/Java/RedHat/Eclipses/jbds5.0.0.M4b/studio/plugins/org.jboss.tools.tests_3.2.0.v20111108-2302-Beta1</location>
@@ -63,6 +79,11 @@
<location>/home/eiden/Java/RedHat/Eclipses/jbds5m5a/studio/plugins/org.jboss.tools.tests_3.2.0.v20111124-2026-H477-M5</location>
</link>
<link>
+ <name>lib-org.jboss.tools.tests_3.2.0.v20120320-2338-Beta3</name>
+ <type>2</type>
+ <location>/home/eiden/RedHat/Eclipses/JBDS/versions/5.0.0.Beta3/studio/plugins/org.jboss.tools.tests_3.2.0.v20120320-2338-Beta3</location>
+ </link>
+ <link>
<name>lib-org.jboss.tools.ui.bot.ext_3.2.0.v20111108-2302-Beta1</name>
<type>2</type>
<location>/home/eiden/Java/RedHat/Eclipses/jbds5.0.0.M4b/studio/plugins/org.jboss.tools.ui.bot.ext_3.2.0.v20111108-2302-Beta1</location>
@@ -72,5 +93,10 @@
<type>2</type>
<location>/home/eiden/Java/RedHat/Eclipses/jbds5m5a/studio/plugins/org.jboss.tools.ui.bot.ext_3.2.0.v20111124-2026-H477-M5</location>
</link>
+ <link>
+ <name>lib-org.jboss.tools.ui.bot.ext_3.2.0.v20120320-2338-Beta3</name>
+ <type>2</type>
+ <location>/home/eiden/RedHat/Eclipses/JBT/versions/3.3CR1/eclipse/plugins/org.jboss.tools.ui.bot.ext_3.2.0.v20120320-2338-Beta3</location>
+ </link>
</linkedResources>
</projectDescription>
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/META-INF/MANIFEST.MF 2012-08-04
01:24:50 UTC (rev 42855)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/META-INF/MANIFEST.MF 2012-08-06
07:53:29 UTC (rev 42856)
@@ -24,10 +24,9 @@
org.jboss.tools.seam.core,
org.eclipse.datatools.connectivity,
org.eclipse.datatools.connectivity.db.generic,
- org.eclipse.m2e.wtp;bundle-version="0.16.0"
+ org.hamcrest
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Eclipse-RegisterBuddy: org.apache.log4j
Import-Package: org.apache.maven.model
-Export-Package: org.jboss.tools.maven.ui.bot.test
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/pom.xml
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/pom.xml 2012-08-04 01:24:50 UTC
(rev 42855)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/pom.xml 2012-08-06 07:53:29 UTC
(rev 42856)
@@ -13,7 +13,7 @@
<packaging>eclipse-test-plugin</packaging>
<properties>
- <systemProperties>-Djbosstools.test.jboss.home.6.0=${requirementsDirectory}/jboss-6.0.0.Final
-Djbosstools.test.jboss.home.5.1=${requirementsDirectory}/jboss-5.1.0.GA
-Djbosstools.test.seam.2.0.1.GA.home=${requirementsDirectory}/jboss-seam-2.2.0.GA</systemProperties>
+ <systemProperties>-Djbosstools.test.jboss.home.7.1=${requirementsDirectory}/jboss-as-7.1.1.Final
-Djbosstools.test.seam.2.2.0.home=${requirementsDirectory}/jboss-seam-2.2.0.GA
-Djbosstools.test.seam.2.3.0.home=${requirementsDirectory}/jboss-seam-2.3.0</systemProperties>
</properties>
<build>
<plugins>
@@ -22,7 +22,7 @@
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
- <id>install-as-6.0.0</id>
+ <id>install-as-7.1.1</id>
<phase>pre-integration-test</phase>
<goals>
<goal>unpack</goal>
@@ -30,9 +30,9 @@
<configuration>
<artifactItems>
<artifactItem>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-distribution</artifactId>
- <version>6.0.0.Final</version>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-dist</artifactId>
+ <version>7.1.1.Final</version>
<type>zip</type>
</artifactItem>
</artifactItems>
@@ -46,7 +46,7 @@
<artifactId>maven-download-plugin</artifactId>
<executions>
<execution>
- <id>install-seam</id>
+ <id>install-seam22</id>
<phase>pre-integration-test</phase>
<goals>
<goal>wget</goal>
@@ -58,15 +58,16 @@
</configuration>
</execution>
<execution>
- <id>install-as-5.1.0</id>
+ <id>install-seam23</id>
<phase>pre-integration-test</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
- <
url>http://repository.jboss.org/sourceforge/jboss-5.1.0.GA.zip</url...
- <md5>78322c75ca0c13002a04418b4a8bc920</md5>
+ <
url>http://sourceforge.net/projects/jboss/files/JBoss%20Seam/2.3.0.ALP...
<unpack>true</unpack>
+ <outputDirectory>${requirementsDirectory}/jboss-seam-2.3.0</outputDirectory>
+ <md5>07b19de75bcb86b5f4cff3a15d7e2158</md5>
</configuration>
</execution>
</executions>
@@ -79,6 +80,9 @@
<skip>${swtbot.test.skip}</skip>
<testSuite>org.jboss.tools.maven.ui.bot.test</testSuite>
<testClass>org.jboss.tools.maven.ui.bot.test.MavenAllBotTests</testClass>
+ <!-- <environmentVariables>
+ <DISPLAY>:2.0</DISPLAY>
+ </environmentVariables> -->
<dependencies>
<dependency combine.children="append">
<type>p2-installable-unit</type>
@@ -115,14 +119,20 @@
<artifactId>org.jboss.tools.common.jdt.feature.feature.group</artifactId>
<version>0.0.0</version>
</dependency>
-
+
+ <dependency>
+ <type>p2-installable-unit</type>
+ <artifactId>org.jboss.tools.common.jdt.feature.feature.group</artifactId>
+ <version>0.0.0</version>
+ </dependency>
+
<!-- configurator test -->
<dependency>
<type>p2-installable-unit</type>
<artifactId>org.jboss.tools.ws.jaxrs.feature.feature.group</artifactId>
<version>0.0.0</version>
</dependency>
-
+
<!-- seam test -->
<dependency>
<type>p2-installable-unit</type>
@@ -139,9 +149,9 @@
<artifactId>org.eclipse.datatools.enablement.feature.feature.group</artifactId>
<version>0.0.0</version>
</dependency>
-
-
-
+
+
+
<!-- maven -->
<dependency>
<type>p2-installable-unit</type>
@@ -158,7 +168,7 @@
<artifactId>org.jboss.tools.maven.feature.feature.group</artifactId>
<version>0.0.0</version>
</dependency>
- <dependency>
+ <dependency>
<type>p2-installable-unit</type>
<artifactId>org.jboss.tools.maven.seam.feature.feature.group</artifactId>
<version>0.0.0</version>
@@ -198,4 +208,4 @@
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar1/.settings/org.eclipse.m2e.core.prefs
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar1/.settings/org.eclipse.m2e.core.prefs 2012-08-04
01:24:50 UTC (rev 42855)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar1/.settings/org.eclipse.m2e.core.prefs 2012-08-06
07:53:29 UTC (rev 42856)
@@ -1,5 +1,4 @@
-#Tue Jan 24 17:11:29 CET 2012
-activeProfiles=common-profile, jboss.repository, jbosss.repository
+activeProfiles=common-profile, jboss, profile.from.settings.xml
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar2/.settings/org.eclipse.m2e.core.prefs
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar2/.settings/org.eclipse.m2e.core.prefs 2012-08-04
01:24:50 UTC (rev 42855)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar2/.settings/org.eclipse.m2e.core.prefs 2012-08-06
07:53:29 UTC (rev 42856)
@@ -1,5 +1,4 @@
-#Tue Jan 24 17:11:28 CET 2012
-activeProfiles=common-profile, jboss.repository, jbosss.repository
+activeProfiles=common-profile, profile.from.settings.xml, jboss
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/AbstractMavenSWTBotTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/AbstractMavenSWTBotTest.java 2012-08-04
01:24:50 UTC (rev 42855)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/AbstractMavenSWTBotTest.java 2012-08-06
07:53:29 UTC (rev 42856)
@@ -10,133 +10,176 @@
************************************************************************************/
package org.jboss.tools.maven.ui.bot.test;
-import java.util.List;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.m2e.core.internal.IMavenConstants;
import org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase;
import org.eclipse.m2e.tests.common.JobHelpers;
import org.eclipse.m2e.tests.common.WorkspaceHelpers;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.results.Result;
-import org.eclipse.swtbot.swt.finder.results.VoidResult;
-import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.IPreferenceConstants;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.util.PrefUtil;
import org.eclipse.wst.validation.ValidationFramework;
+import org.jboss.tools.maven.ui.bot.test.utils.ProjectHasNature;
import org.jboss.tools.test.util.ResourcesUtils;
-import org.junit.After;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.view.ErrorLogView;
import org.junit.AfterClass;
-import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
@SuppressWarnings("restriction")
@RunWith(SWTBotJunit4ClassRunner.class)
public abstract class AbstractMavenSWTBotTest extends AbstractMavenProjectTestCase {
public static final String PACKAGE_EXPLORER = "Package Explorer";
//$NON-NLS-1$
+ public static final int TIMEOUT = 30*1000;
+ public static final int HAS_NATURE_TIMEOUT=10000;
+ private ErrorLogView errorLog;
- protected static SWTWorkbenchBot bot;
+ protected SWTBotExt bot = new SWTBotExt();
@BeforeClass
public static void beforeClass() throws Exception {
- bot = initSWTBot();
+ setUserSettings();
WorkbenchPlugin.getDefault().getPreferenceStore()
.setValue(IPreferenceConstants.RUN_IN_BACKGROUND, true);
PrefUtil.getAPIPreferenceStore().setValue(
IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS, false);
-
+ setUserSettings();
}
- public static SWTWorkbenchBot initSWTBot() throws CoreException {
- SWTWorkbenchBot swtbot = new SWTWorkbenchBot();
- SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
- SWTBotPreferences.TIMEOUT = 1000;
- SWTBotPreferences.PLAYBACK_DELAY = 5;
- waitForIdle();
+ //@AfterClass
+ public final static void cleanUp() throws Exception {
+ boolean buildAutomatically = ResourcesUtils.setBuildAutomatically(false);
+ ValidationFramework.getDefault().suspendAllValidation(true);
try {
- SWTBotView view = swtbot.viewByTitle("Welcome");
- if (view != null) {
- view.close();
- }
- } catch (WidgetNotFoundException ignore) {
+ WorkspaceHelpers.cleanWorkspace();
+ } finally {
+ ResourcesUtils.setBuildAutomatically(buildAutomatically);
+ ValidationFramework.getDefault().suspendAllValidation(false);
}
+ JobHelpers.waitForLaunchesToComplete(30*1000);
+ JobHelpers.waitForJobsToComplete();
+ }
- SWTBotShell[] shells = swtbot.shells();
- for (SWTBotShell shell : shells) {
- final Shell widget = shell.widget;
- Object parent = UIThreadRunnable.syncExec(shell.display,
- new Result<Object>() {
- public Object run() {
- return widget.isDisposed() ? null : widget.getParent();
- }
- });
- if (parent == null) {
- continue;
- }
- shell.close();
+ public void waitForIdle() {
+ JobHelpers.waitForLaunchesToComplete(TIMEOUT);
+ JobHelpers.waitForJobsToComplete();
+ }
+
+ public boolean isMavenProject(String projectName) throws CoreException {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ return project.hasNature(IMavenConstants.NATURE_ID);
+ }
+
+ public boolean hasNature(String projectName, String natureID){
+ try{
+ bot.waitUntil(new ProjectHasNature(projectName, natureID),HAS_NATURE_TIMEOUT);
+ } catch (TimeoutException ex){
+ return false;
}
+ return true;
+ }
- List<? extends SWTBotEditor> editors = swtbot.editors();
- for (SWTBotEditor e : editors) {
- e.close();
+ public void waitForShell(SWTUtilExt botUtil, String shellName) throws
InterruptedException {
+ while(!botUtil.isShellActive(shellName)){
+ Thread.sleep(500);
}
+ }
+
+ protected void addDependencies(String projectName, String groupId, String artifactId,
String version, String type) throws Exception{
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- return swtbot;
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ Document docPom =
docBuilder.parse(project.getProject().getFile("pom.xml").getContents());
+ Element dependenciesElement = null;
+ if(docPom.getElementsByTagName("dependencies").item(0)==null){
+ dependenciesElement = docPom.createElement("dependencies");
+ } else {
+ dependenciesElement = (Element)
docPom.getElementsByTagName("dependencies").item(0);
+ }
+ Element dependencyElement = docPom.createElement("dependency");
+ Element groupIdElement = docPom.createElement("groupId");
+ Element artifactIdElement = docPom.createElement("artifactId");
+ Element versionElement = docPom.createElement("version");
+ Element typeElement = docPom.createElement("type");
+
+ groupIdElement.setTextContent(groupId);
+ artifactIdElement.setTextContent(artifactId);
+ versionElement.setTextContent(version);
+
+ Element root = docPom.getDocumentElement();
+ dependencyElement.appendChild(groupIdElement);
+ dependencyElement.appendChild(artifactIdElement);
+ dependencyElement.appendChild(versionElement);
+ if(type!=null){
+ typeElement.setTextContent(type);
+ dependencyElement.appendChild(typeElement);
+ }
+ dependenciesElement.appendChild(dependencyElement);
+ root.appendChild(dependenciesElement);
+ TransformerFactory transfac = TransformerFactory.newInstance();
+ Transformer trans = transfac.newTransformer();
+ StringWriter xmlAsWriter = new StringWriter();
+ StreamResult result = new StreamResult(xmlAsWriter);
+ DOMSource source = new DOMSource(docPom);
+ trans.transform(source, result);
+ project.getProject().getFile("pom.xml").setContents(new
ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")), 0, null);
}
- @Before
- public void setUp() throws Exception {
- activateSchell();
- super.setUp();
- }
-
- public static void activateSchell() {
- UIThreadRunnable.syncExec(new VoidResult() {
- public void run() {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()
- .forceActive();
- }
- });
+ protected void updateConf(SWTUtilExt botUtil, String projectName){
+ SWTBotTree innerBot = bot.viewByTitle("Package
Explorer").bot().tree().select(projectName);
+ ContextMenuHelper.clickContextMenu(innerBot, "Maven","Update Project
Configuration...");
+ bot.button("OK").click();
+ botUtil.waitForAll(Long.MAX_VALUE);
+ botUtil.waitForNonIgnoredJobs();
}
- @After
- public void tearDown() throws Exception {
-
+ private static void setUserSettings() throws InterruptedException, IOException,
CoreException{
+ SWTBotExt botExt = new SWTBotExt();
+ botExt.menu("Window").menu("Preferences").click();
+ botExt.tree().expandNode("Maven").select("User Settings").click();
+ File f = new File("usersettings/settings.xml");
+ botExt.text(1).setText(f.getAbsolutePath());
+ botExt.button("Update Settings").click();
+ botExt.button("OK").click();
}
- @AfterClass
- public final static void cleanUp() throws Exception {
- boolean buildAutomatically = ResourcesUtils.setBuildAutomatically(false);
- ValidationFramework.getDefault().suspendAllValidation(true);
- try {
- executeAfterClass();
- WorkspaceHelpers.cleanWorkspace();
- } finally {
- ResourcesUtils.setBuildAutomatically(buildAutomatically);
- ValidationFramework.getDefault().suspendAllValidation(false);
- }
- waitForIdle();
+ protected void clearErrorLog(){
+ errorLog = new ErrorLogView();
+ errorLog.clear();
}
- protected static void executeAfterClass() throws Exception {
+ protected void checkErrorLog() {
+ int count = errorLog.getRecordCount();
+ if (count > 0) {
+ errorLog.logMessages();
+ fail("Unexpected messages in Error log, see test log");
+ }
}
-
-
- public static void waitForIdle() {
- JobHelpers.waitForLaunchesToComplete(30*1000);
- JobHelpers.waitForJobsToComplete();
- }
}
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/ConfiguratorsTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/ConfiguratorsTest.java 2012-08-04
01:24:50 UTC (rev 42855)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/ConfiguratorsTest.java 2012-08-06
07:53:29 UTC (rev 42856)
@@ -1,8 +1,5 @@
package org.jboss.tools.maven.ui.bot.test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.io.ByteArrayInputStream;
import java.io.StringWriter;
@@ -33,7 +30,7 @@
@SuppressWarnings("restriction")
@Require(perspective="Java EE")
-public class ConfiguratorsTest {
+public class ConfiguratorsTest extends AbstractMavenSWTBotTest{
public static final String PROJECT_NAME_JSF="testWEB_JSF";
public static final String PROJECT_NAME_JAXRS="testWEB_JAXRS";
@@ -42,13 +39,14 @@
public static final String JSF_NATURE="org.jboss.tools.jsf.jsfnature";
public static final String JAXRS_NATURE="org.jboss.tools.ws.jaxrs.nature";
public static final String CDI_NATURE="org.jboss.tools.cdi.core.cdinature";
- public static final String
JBOSS6_AS_HOME=System.getProperty("jbosstools.test.jboss.home.6.0");
+ public static final String WEB_XML_LOCATION="/WebContent/WEB-INF/web.xml";
+ public static final String
JBOSS7_AS_HOME=System.getProperty("jbosstools.test.jboss.home.7.1");
+//seam config, jpa config
- private SWTBotExt botExt = new SWTBotExt();
- private SWTUtilExt botUtil = new SWTUtilExt(botExt);
+ private SWTUtilExt botUtil= new SWTUtilExt(bot);
+
-
@BeforeClass
public static void setup(){
SWTBotExt setup = new SWTBotExt();
@@ -67,29 +65,33 @@
@Test
public void testJSFConfigurator() throws Exception{
createMavenizedDynamicWebProject(PROJECT_NAME_JSF+"_noRuntime", false);
- addDependencies(PROJECT_NAME_JSF+"_noRuntime", "com.sun.faces",
"mojarra-jsf-api", "2.0.0-b04");
- assertTrue("Project "+PROJECT_NAME_JSF+"_noRuntime"+" with
mojarra dependency doesn't have "+JSF_NATURE+"
nature",Utils.hasNature(PROJECT_NAME_JSF+"_noRuntime", JSF_NATURE));
+ addDependencies(PROJECT_NAME_JSF+"_noRuntime", "com.sun.faces",
"mojarra-jsf-api", "2.0.0-b04",null);
+ updateConf(botUtil,PROJECT_NAME_JSF+"_noRuntime");
+ assertTrue("Project "+PROJECT_NAME_JSF+"_noRuntime"+" with
mojarra dependency doesn't have "+JSF_NATURE+"
nature",hasNature(PROJECT_NAME_JSF+"_noRuntime", JSF_NATURE));
clean();
createMavenizedDynamicWebProject(PROJECT_NAME_JSF+"_noRuntime", false);
addFacesConf(PROJECT_NAME_JSF+"_noRuntime");
- assertTrue("Project "+PROJECT_NAME_JSF+"_noRuntime"+" with
faces config doesn't have "+JSF_NATURE+"
nature",Utils.hasNature(PROJECT_NAME_JSF+"_noRuntime", JSF_NATURE));
+ assertTrue("Project "+PROJECT_NAME_JSF+"_noRuntime"+" with
faces config doesn't have "+JSF_NATURE+"
nature",hasNature(PROJECT_NAME_JSF+"_noRuntime", JSF_NATURE));
clean();
+
//https://issues.jboss.org/browse/JBIDE-10831
createMavenizedDynamicWebProject(PROJECT_NAME_JSF+"_noRuntime", false);
addServlet(PROJECT_NAME_JSF+"_noRuntime","Faces
Servlet","javax.faces.webapp.FacesServlet","1");
- assertTrue("Project "+PROJECT_NAME_JSF+"_noRuntime"+"with
servlet in web.xml doesn't have "+JSF_NATURE+"
nature",Utils.hasNature(PROJECT_NAME_JSF+"_noRuntime", JSF_NATURE));
+ assertTrue("Project "+PROJECT_NAME_JSF+"_noRuntime"+"with
servlet in web.xml doesn't have "+JSF_NATURE+"
nature",hasNature(PROJECT_NAME_JSF+"_noRuntime", JSF_NATURE));
IProject facade =
ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME_JSF+"_noRuntime");
assertTrue("Project "+PROJECT_NAME_JSF+"_noRuntime"+"
doesn't have faces-config.xml
file",facade.getProject().getFile("faces-config.xml") != null);
+ clean();
createMavenizedDynamicWebProject(PROJECT_NAME_JSF, true);
- assertTrue("Project "+PROJECT_NAME_JSF+" doesn't have
"+JSF_NATURE+" nature",Utils.hasNature(PROJECT_NAME_JSF, JSF_NATURE));
+ assertTrue("Project "+PROJECT_NAME_JSF+" doesn't have
"+JSF_NATURE+" nature",hasNature(PROJECT_NAME_JSF, JSF_NATURE));
+ clean();
-
//https://issues.jboss.org/browse/JBIDE-8755
createMavenizedDynamicWebProject(PROJECT_NAME_JSF+"_seam", false);
- addDependencies(PROJECT_NAME_JSF+"_seam", "org.jboss.seam.faces",
"seam-faces", "3.0.0.Alpha3");
- assertTrue("Project "+PROJECT_NAME_JSF+"_seam"+" with
seam-faces3 dependency doesn't have "+JSF_NATURE+"
nature",Utils.hasNature(PROJECT_NAME_JSF+"_seam", JSF_NATURE));
+ addDependencies(PROJECT_NAME_JSF+"_seam", "org.jboss.seam.faces",
"seam-faces", "3.0.0.Alpha3",null);
+ updateConf(botUtil,PROJECT_NAME_JSF+"_seam");
+ assertTrue("Project "+PROJECT_NAME_JSF+"_seam"+" with
seam-faces3 dependency doesn't have "+JSF_NATURE+"
nature",hasNature(PROJECT_NAME_JSF+"_seam", JSF_NATURE));
@@ -99,189 +101,185 @@
@Test
public void testCDIConfigurator() throws Exception{
createMavenizedDynamicWebProject(PROJECT_NAME_CDI+"_noRuntime", false);
- addDependencies(PROJECT_NAME_CDI+"_noRuntime", "javax.enterprise",
"cdi-api","1.1.EDR1.2");
- assertTrue("Project "+PROJECT_NAME_CDI+"_noRuntime"+" with cdi
dependency doesn't have "+CDI_NATURE+"
nature.",Utils.hasNature(PROJECT_NAME_CDI+"_noRuntime", CDI_NATURE));
+ addDependencies(PROJECT_NAME_CDI+"_noRuntime", "javax.enterprise",
"cdi-api","1.1.EDR1.2",null);
+ updateConf(botUtil,PROJECT_NAME_CDI+"_noRuntime");
+ assertTrue("Project "+PROJECT_NAME_CDI+"_noRuntime"+" with cdi
dependency doesn't have "+CDI_NATURE+"
nature.",hasNature(PROJECT_NAME_CDI+"_noRuntime", CDI_NATURE));
+ clean();
createMavenizedEJBProject(PROJECT_NAME_CDI_EJB+"_noRuntime", false);
- addDependencies(PROJECT_NAME_CDI_EJB+"_noRuntime",
"javax.enterprise", "cdi-api","1.1.EDR1.2");
- assertTrue("Project "+PROJECT_NAME_CDI_EJB+"_noRuntime"+" with
cdi dependency doesn't have "+CDI_NATURE+"
nature.",Utils.hasNature(PROJECT_NAME_CDI_EJB+"_noRuntime", CDI_NATURE));
+ addDependencies(PROJECT_NAME_CDI_EJB+"_noRuntime",
"javax.enterprise", "cdi-api","1.1.EDR1.2",null);
+ updateConf(botUtil,PROJECT_NAME_CDI_EJB+"_noRuntime");
+ assertTrue("Project "+PROJECT_NAME_CDI_EJB+"_noRuntime"+" with
cdi dependency doesn't have "+CDI_NATURE+"
nature.",hasNature(PROJECT_NAME_CDI_EJB+"_noRuntime", CDI_NATURE));
+ clean();
createMavenizedDynamicWebProject(PROJECT_NAME_CDI, true);
- assertFalse("Project "+PROJECT_NAME_CDI+" has "+CDI_NATURE+"
nature.",Utils.hasNature(PROJECT_NAME_CDI, CDI_NATURE));
+ assertFalse("Project "+PROJECT_NAME_CDI+" has "+CDI_NATURE+"
nature.",hasNature(PROJECT_NAME_CDI, CDI_NATURE));
+ clean();
createMavenizedEJBProject(PROJECT_NAME_CDI_EJB, true);
- assertFalse("Project "+PROJECT_NAME_CDI_EJB+" has
"+CDI_NATURE+" nature.",Utils.hasNature(PROJECT_NAME_CDI_EJB,
CDI_NATURE));
+ assertFalse("Project "+PROJECT_NAME_CDI_EJB+" has
"+CDI_NATURE+" nature.",hasNature(PROJECT_NAME_CDI_EJB, CDI_NATURE));
+ clean();
-
//https://issues.jboss.org/browse/JBIDE-8755
createMavenizedDynamicWebProject(PROJECT_NAME_CDI+"_noRuntime_seam", false);
- addDependencies(PROJECT_NAME_CDI+"_noRuntime_seam",
"org.jboss.seam.faces", "seam-faces", "3.0.0.Alpha3");
- assertTrue("Project "+PROJECT_NAME_CDI+"_noRuntime_seam"+"
with seam-faces3 dependency doesn't have "+CDI_NATURE+"
nature.",Utils.hasNature(PROJECT_NAME_CDI+"_noRuntime_seam", CDI_NATURE));
+ addDependencies(PROJECT_NAME_CDI+"_noRuntime_seam",
"org.jboss.seam.faces", "seam-faces", "3.0.0.Alpha3",null);
+ updateConf(botUtil,PROJECT_NAME_CDI+"_noRuntime_seam");
+ assertTrue("Project "+PROJECT_NAME_CDI+"_noRuntime_seam"+"
with seam-faces3 dependency doesn't have "+CDI_NATURE+"
nature.",hasNature(PROJECT_NAME_CDI+"_noRuntime_seam", CDI_NATURE));
+ clean();
createMavenizedEJBProject(PROJECT_NAME_CDI_EJB+"_noRuntime_seam", false);
- addDependencies(PROJECT_NAME_CDI_EJB+"_noRuntime_seam",
"org.jboss.seam.faces", "seam-faces", "3.0.0.Alpha3");
- assertTrue("Project "+PROJECT_NAME_CDI_EJB+"_noRuntime_seam"+"
with seam-faces3 dependency doesn't have "+CDI_NATURE+"
nature.",Utils.hasNature(PROJECT_NAME_CDI_EJB+"_noRuntime_seam",
CDI_NATURE));
+ addDependencies(PROJECT_NAME_CDI_EJB+"_noRuntime_seam",
"org.jboss.seam.faces", "seam-faces", "3.0.0.Alpha3",null);
+ updateConf(botUtil,PROJECT_NAME_CDI_EJB+"_noRuntime_seam");
+ assertTrue("Project "+PROJECT_NAME_CDI_EJB+"_noRuntime_seam"+"
with seam-faces3 dependency doesn't have "+CDI_NATURE+"
nature.",hasNature(PROJECT_NAME_CDI_EJB+"_noRuntime_seam", CDI_NATURE));
clean();
createMavenizedDynamicWebProject(PROJECT_NAME_CDI+"_noRuntime_seam", false);
- addDependencies(PROJECT_NAME_CDI+"_noRuntime_seam",
"org.jboss.seam.international", "seam-international",
"3.0.0.Alpha1");
- assertTrue("Project "+PROJECT_NAME_CDI+"_noRuntime_seam"+"
with seam3 dependency doesn't have "+CDI_NATURE+"
nature.",Utils.hasNature(PROJECT_NAME_CDI+"_noRuntime_seam", CDI_NATURE));
+ addDependencies(PROJECT_NAME_CDI+"_noRuntime_seam",
"org.jboss.seam.international", "seam-international",
"3.0.0.Alpha1",null);
+ updateConf(botUtil,PROJECT_NAME_CDI+"_noRuntime_seam");
+ assertTrue("Project "+PROJECT_NAME_CDI+"_noRuntime_seam"+"
with seam3 dependency doesn't have "+CDI_NATURE+"
nature.",hasNature(PROJECT_NAME_CDI+"_noRuntime_seam", CDI_NATURE));
createMavenizedEJBProject(PROJECT_NAME_CDI_EJB+"_noRuntime_seam", false);
- addDependencies(PROJECT_NAME_CDI_EJB+"_noRuntime_seam",
"org.jboss.seam.international", "seam-international",
"3.0.0.Alpha1");
- assertTrue("Project "+PROJECT_NAME_CDI_EJB+"_noRuntime_seam"+"
with seam3 dependency doesn't have "+CDI_NATURE+"
nature.",Utils.hasNature(PROJECT_NAME_CDI_EJB+"_noRuntime_seam",
CDI_NATURE));
+ addDependencies(PROJECT_NAME_CDI_EJB+"_noRuntime_seam",
"org.jboss.seam.international", "seam-international",
"3.0.0.Alpha1",null);
+ updateConf(botUtil,PROJECT_NAME_CDI_EJB+"_noRuntime_seam");
+ assertTrue("Project "+PROJECT_NAME_CDI_EJB+"_noRuntime_seam"+"
with seam3 dependency doesn't have "+CDI_NATURE+"
nature.",hasNature(PROJECT_NAME_CDI_EJB+"_noRuntime_seam", CDI_NATURE));
+ clean();
+ createMavenizedEJBProject(PROJECT_NAME_CDI_EJB+"_noRuntime_deltaspike-api",
false);
+ addDependencies(PROJECT_NAME_CDI_EJB+"_noRuntime_deltaspike-api",
"org.apache.deltaspike.core", "deltaspike-core-api",
"incubating-0.1-SNAPSHOT",null);
+ updateConf(botUtil,PROJECT_NAME_CDI_EJB+"_noRuntime_deltaspike-api");
+ assertTrue("Project
"+PROJECT_NAME_CDI_EJB+"_noRuntime_deltaspike-api"+" with
deltaspike-api dependency doesn't have "+CDI_NATURE+"
nature.",hasNature(PROJECT_NAME_CDI_EJB+"_noRuntime_deltaspike-api",
CDI_NATURE));
+ clean();
+
+ createMavenizedDynamicWebProject(PROJECT_NAME_CDI+"_noRuntime_deltaspike-api",
false);
+ addDependencies(PROJECT_NAME_CDI+"_noRuntime_deltaspike-api",
"org.apache.deltaspike.core", "deltaspike-core-api",
"incubating-0.1-SNAPSHOT",null);
+ updateConf(botUtil,PROJECT_NAME_CDI+"_noRuntime_deltaspike-api");
+ assertTrue("Project
"+PROJECT_NAME_CDI+"_noRuntime_deltaspike-api"+" with deltaspike-api
dependency doesn't have "+CDI_NATURE+"
nature.",hasNature(PROJECT_NAME_CDI+"_noRuntime_deltaspike-api",
CDI_NATURE));
+ clean();
+
+ createMavenizedEJBProject(PROJECT_NAME_CDI_EJB+"_noRuntime_deltaspike-impl",
false);
+ addDependencies(PROJECT_NAME_CDI_EJB+"_noRuntime_deltaspike-impl",
"org.apache.deltaspike.core", "deltaspike-core-impl",
"incubating-0.1-SNAPSHOT",null);
+ updateConf(botUtil,PROJECT_NAME_CDI_EJB+"_noRuntime_deltaspike-impl");
+ assertTrue("Project
"+PROJECT_NAME_CDI_EJB+"_noRuntime_deltaspike-impl"+" with
deltaspike-impl dependency doesn't have "+CDI_NATURE+"
nature.",hasNature(PROJECT_NAME_CDI_EJB+"_noRuntime_deltaspike-impl",
CDI_NATURE));
+ clean();
+
+ createMavenizedDynamicWebProject(PROJECT_NAME_CDI+"_noRuntime_deltaspike-impl",
false);
+ addDependencies(PROJECT_NAME_CDI+"_noRuntime_deltaspike-impl",
"org.apache.deltaspike.core", "deltaspike-core-impl",
"incubating-0.1-SNAPSHOT",null);
+ updateConf(botUtil,PROJECT_NAME_CDI+"_noRuntime_deltaspike-impl");
+ assertTrue("Project
"+PROJECT_NAME_CDI+"_noRuntime_deltaspike-impl"+" with deltaspike-impl
dependency doesn't have "+CDI_NATURE+"
nature.",hasNature(PROJECT_NAME_CDI+"_noRuntime_deltaspike-impl",
CDI_NATURE));
+
}
@Test
public void testJAXRSConfigurator() throws Exception {
createMavenizedDynamicWebProject(PROJECT_NAME_JAXRS+"_noRuntime", false);
- addDependencies(PROJECT_NAME_JAXRS+"_noRuntime",
"com.cedarsoft.rest", "jersey", "1.0.0");
- assertTrue("Project "+PROJECT_NAME_JAXRS+"_noRuntime"+" with
jersey dependency doesn't have "+JAXRS_NATURE+"
nature.",Utils.hasNature(PROJECT_NAME_JAXRS+"_noRuntime", JAXRS_NATURE));
+ addDependencies(PROJECT_NAME_JAXRS+"_noRuntime",
"com.cedarsoft.rest", "jersey", "1.0.0",null);
+ updateConf(botUtil,PROJECT_NAME_JAXRS+"_noRuntime");
+ assertTrue("Project "+PROJECT_NAME_JAXRS+"_noRuntime"+" with
jersey dependency doesn't have "+JAXRS_NATURE+"
nature.",hasNature(PROJECT_NAME_JAXRS+"_noRuntime", JAXRS_NATURE));
clean();
+
createMavenizedDynamicWebProject(PROJECT_NAME_JAXRS+"_noRuntime", false);
- addDependencies(PROJECT_NAME_JAXRS+"_noRuntime",
"org.jboss.jbossas", "jboss-as-resteasy", "6.1.0.Final");
- assertTrue("Project "+PROJECT_NAME_JAXRS+"_noRuntime"+" with
resteasy dependency doesn't have "+JAXRS_NATURE+"
nature.",Utils.hasNature(PROJECT_NAME_JAXRS+"_noRuntime", JAXRS_NATURE));
+ addDependencies(PROJECT_NAME_JAXRS+"_noRuntime",
"org.jboss.jbossas", "jboss-as-resteasy",
"6.1.0.Final",null);
+ updateConf(botUtil,PROJECT_NAME_JAXRS+"_noRuntime");
+ assertTrue("Project "+PROJECT_NAME_JAXRS+"_noRuntime"+" with
resteasy dependency doesn't have "+JAXRS_NATURE+"
nature.",hasNature(PROJECT_NAME_JAXRS+"_noRuntime", JAXRS_NATURE));
+ clean();
createMavenizedDynamicWebProject(PROJECT_NAME_JAXRS, true);
- assertTrue("Project "+PROJECT_NAME_JAXRS+" doesn't have
"+JAXRS_NATURE+" nature.",Utils.hasNature(PROJECT_NAME_JAXRS,
JAXRS_NATURE));
+ assertTrue("Project "+PROJECT_NAME_JAXRS+" doesn't have
"+JAXRS_NATURE+" nature.",hasNature(PROJECT_NAME_JAXRS, JAXRS_NATURE));
}
private void createMavenizedDynamicWebProject(String projectName, boolean runtime)
throws Exception{
- botExt.menu("File").menu("New").menu("Dynamic Web
Project").click();
- botExt.textWithLabel("Project name:").setText(projectName);
+ bot.menu("File").menu("New").menu("Dynamic Web
Project").click();
+ bot.textWithLabel("Project name:").setText(projectName);
if(runtime){
- botExt.button("New Runtime...").click();
- Thread.sleep(500);
- botExt.tree().expandNode("JBoss Community").select("JBoss 6.x
Runtime");
- botExt.button("Next >").click();
- botExt.textWithLabel("Home Directory").setText(JBOSS6_AS_HOME);
- botExt.button("Finish").click();
+ bot.button("New Runtime...").click();
+ waitForShell(botUtil, "New Server Runtime Environment");
+ bot.tree().expandNode("JBoss Community").select("JBoss 7.1
Runtime");
+ bot.button("Next >").click();
+ bot.textWithLabel("Home Directory").setText(JBOSS7_AS_HOME);
+ bot.button("Finish").click();
} else {
- botExt.comboBoxInGroup("Target
runtime").setSelection("<None>");
+ bot.comboBoxInGroup("Target
runtime").setSelection("<None>");
}
- Utils.waitForShell(botUtil, "New Dynamic Web Project");
- botExt.button("Next >").click();
- Utils.waitForShell(botUtil, "New Dynamic Web Project");
- botExt.button("Next >").click();
- Utils.waitForShell(botUtil, "New Dynamic Web Project");
- botExt.checkBox("Generate web.xml deployment descriptor").select();
- botExt.button("Finish").click();
+ waitForShell(botUtil, "New Dynamic Web Project");
+ bot.button("Next >").click();
+ waitForShell(botUtil, "New Dynamic Web Project");
+ bot.button("Next >").click();
+ waitForShell(botUtil, "New Dynamic Web Project");
+ bot.checkBox("Generate web.xml deployment descriptor").select();
+ bot.button("Finish").click();
botUtil.waitForAll(Long.MAX_VALUE);
- Utils.waitForIdle();
- SWTBotTreeItem item = botExt.viewByTitle("Package
Explorer").bot().tree().getTreeItem(projectName).select();
+ waitForIdle();
+ SWTBotTreeItem item = bot.viewByTitle("Package
Explorer").bot().tree().getTreeItem(projectName).select();
item.pressShortcut(Keystrokes.ALT,Keystrokes.LF);
- SWTBot shellProperties = botExt.shell("Properties for
"+projectName).activate().bot();
+ SWTBot shellProperties = bot.shell("Properties for
"+projectName).activate().bot();
shellProperties.tree().select("Project Facets");
shellProperties.tree(1).getTreeItem("JBoss Maven Integration").check();
botUtil.waitForAll();
Thread.sleep(500);
- botExt.hyperlink("Further configuration required...").click();
- botExt.button("OK").click();
- botExt.button("OK").click();
+ bot.hyperlink("Further configuration required...").click();
+ bot.button("OK").click();
+ bot.button("OK").click();
botUtil.waitForAll();
- assertTrue(projectName+ " doesn't have maven
nature",Utils.isMavenProject(projectName));
- updateConf(projectName);
+ assertTrue(projectName+ " doesn't have maven
nature",isMavenProject(projectName));
+ updateConf(botUtil,projectName);
+ assertFalse("Project "+projectName+" has "+CDI_NATURE+"
nature.",hasNature(projectName, CDI_NATURE)); //false always
if(runtime){
- assertTrue("Project "+projectName+" doesn't have
"+JSF_NATURE+" nature.",Utils.hasNature(projectName, JSF_NATURE));
- assertTrue("Project "+projectName+" doesn't have
"+JAXRS_NATURE+" nature.",Utils.hasNature(projectName, JAXRS_NATURE));
- assertFalse("Project "+projectName+" has "+CDI_NATURE+"
nature.",Utils.hasNature(projectName, CDI_NATURE));
+ assertTrue("Project "+projectName+" doesn't have
"+JSF_NATURE+" nature.",hasNature(projectName, JSF_NATURE));
+ assertTrue("Project "+projectName+" doesn't have
"+JAXRS_NATURE+" nature.",hasNature(projectName, JAXRS_NATURE));
} else {
- assertFalse("Project "+projectName+" has "+JSF_NATURE+"
nature.",Utils.hasNature(projectName, JSF_NATURE));
- assertFalse("Project "+projectName+" has "+JAXRS_NATURE+"
nature.",Utils.hasNature(projectName, JAXRS_NATURE));
- assertFalse("Project "+projectName+" has "+CDI_NATURE+"
nature.",Utils.hasNature(projectName, CDI_NATURE));
+ assertFalse("Project "+projectName+" has "+JSF_NATURE+"
nature.",hasNature(projectName, JSF_NATURE));
+ assertFalse("Project "+projectName+" has "+JAXRS_NATURE+"
nature.",hasNature(projectName, JAXRS_NATURE));
}
}
private void createMavenizedEJBProject(String projectName, boolean runtime)throws
Exception{
- botExt.menu("File").menu("New").menu("EJB
Project").click();
- botExt.textWithLabel("Project name:").setText(projectName);
+ bot.menu("File").menu("New").menu("EJB
Project").click();
+ bot.textWithLabel("Project name:").setText(projectName);
if(runtime){
- botExt.button("New Runtime...").click();
- Thread.sleep(500);
- botExt.tree().expandNode("JBoss Community").select("JBoss 6.x
Runtime");
- botExt.button("Next >").click();
- botExt.textWithLabel("Home Directory").setText(JBOSS6_AS_HOME);
- botExt.button("Finish").click();
+ bot.button("New Runtime...").click();
+ waitForShell(botUtil,"New Server Runtime Environment");
+ bot.tree().expandNode("JBoss Community").select("JBoss 7.1
Runtime");
+ bot.button("Next >").click();
+ bot.textWithLabel("Home Directory").setText(JBOSS7_AS_HOME);
+ bot.button("Finish").click();
} else {
- botExt.comboBoxInGroup("Target
runtime").setSelection("<None>");
+ bot.comboBoxInGroup("Target
runtime").setSelection("<None>");
}
- Utils.waitForShell(botUtil, "New EJB Project");
- botExt.button("Finish").click();
+ waitForShell(botUtil,"New EJB Project");
+ bot.button("Finish").click();
botUtil.waitForAll(Long.MAX_VALUE);
- Utils.waitForIdle();
- SWTBotTreeItem item = botExt.viewByTitle("Package
Explorer").bot().tree().getTreeItem(projectName).select();
+ waitForIdle();
+ SWTBotTreeItem item = bot.viewByTitle("Package
Explorer").bot().tree().getTreeItem(projectName).select();
item.pressShortcut(Keystrokes.ALT,Keystrokes.LF);
- SWTBot shellProperties = botExt.shell("Properties for
"+projectName).activate().bot();
- shellProperties.tree().select("Project Facets");
- shellProperties.tree(1).getTreeItem("JBoss Maven Integration").check();
+ waitForShell(botUtil,"Properties for "+projectName);
+ bot.tree().select("Project Facets");
+ bot.tree(1).getTreeItem("JBoss Maven Integration").check();
botUtil.waitForAll();
Thread.sleep(500);
- botExt.hyperlink("Further configuration required...").click();
- botExt.comboBoxWithLabel("Packaging:").setSelection("ejb");
- botExt.button("OK").click();
- botExt.button("OK").click();
+ bot.hyperlink("Further configuration required...").click();
+ bot.comboBoxWithLabel("Packaging:").setSelection("ejb");
+ bot.button("OK").click();
+ bot.button("OK").click();
botUtil.waitForAll();
- assertTrue(projectName+ " doesn't has maven
nature",Utils.isMavenProject(projectName));
- updateConf(projectName);
- assertFalse("Project "+projectName+" has "+JSF_NATURE+"
nature.",Utils.hasNature(projectName, JSF_NATURE));
- assertFalse("Project "+projectName+" has "+JAXRS_NATURE+"
nature.",Utils.hasNature(projectName, JAXRS_NATURE));
- assertFalse("Project "+projectName+" has "+CDI_NATURE+"
nature.",Utils.hasNature(projectName, CDI_NATURE));
+ assertTrue(projectName+ " doesn't have maven
nature",isMavenProject(projectName));
+ updateConf(botUtil,projectName);
+ assertFalse("Project "+projectName+" has "+JSF_NATURE+"
nature.",hasNature(projectName, JSF_NATURE));
+ assertFalse("Project "+projectName+" has "+JAXRS_NATURE+"
nature.",hasNature(projectName, JAXRS_NATURE));
+ assertFalse("Project "+projectName+" has "+CDI_NATURE+"
nature.",hasNature(projectName, CDI_NATURE));
}
- private void addDependencies(String projectName, String groupId, String artifactId,
String version) throws Exception{
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
-
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = factory.newDocumentBuilder();
- Document docPom =
docBuilder.parse(project.getProject().getFile("pom.xml").getContents());
- Element dependenciesElement = docPom.createElement("dependencies");
- Element dependencyElement = docPom.createElement("dependency");
- Element groupIdElement = docPom.createElement("groupId");
- Element artifactIdElement = docPom.createElement("artifactId");
- Element versionElement = docPom.createElement("version");
-
- groupIdElement.setTextContent(groupId);
- artifactIdElement.setTextContent(artifactId);
- versionElement.setTextContent(version);
-
- Element root = docPom.getDocumentElement();
- dependencyElement.appendChild(groupIdElement);
- dependencyElement.appendChild(artifactIdElement);
- dependencyElement.appendChild(versionElement);
- dependenciesElement.appendChild(dependencyElement);
- root.appendChild(dependenciesElement);
- TransformerFactory transfac = TransformerFactory.newInstance();
- Transformer trans = transfac.newTransformer();
- StringWriter xmlAsWriter = new StringWriter();
- StreamResult result = new StreamResult(xmlAsWriter);
- DOMSource source = new DOMSource(docPom);
- trans.transform(source, result);
- project.getProject().getFile("pom.xml").setContents(new
ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")), 0, null);
- botUtil.waitForAll();
- updateConf(projectName);
- }
-
- private void updateConf(String projectName){
- SWTBotTree innerBot = botExt.viewByTitle("Package
Explorer").bot().tree().select(projectName);
- ContextMenuHelper.clickContextMenu(innerBot, "Maven","Update Project
Configuration...");
- botExt.button("OK").click();
- botUtil.waitForAll(Long.MAX_VALUE);
- botUtil.waitForNonIgnoredJobs();
- }
-
private void addFacesConf(String projectName) throws InterruptedException{
- SWTBotTree innerBot = botExt.viewByTitle("Package
Explorer").bot().tree().select(projectName);
+ SWTBotTree innerBot = bot.viewByTitle("Package
Explorer").bot().tree().select(projectName);
ContextMenuHelper.clickContextMenu(innerBot, "New","Other...");
- botExt.tree().expandNode("JBoss Tools
Web").expandNode("JSF").select("Faces Config");
- botExt.button("Next >").click();
- botExt.button("Browse...").click();
- botExt.tree().expandNode(projectName).expandNode("WebContent").select("WEB-INF");
- botExt.button("OK").click();
- botExt.button("Finish").click();
- updateConf(projectName);
+ bot.tree().expandNode("JBoss Tools
Web").expandNode("JSF").select("Faces Config");
+ bot.button("Next >").click();
+ bot.button("Browse...").click();
+ bot.tree().expandNode(projectName).expandNode("WebContent").select("WEB-INF");
+ bot.button("OK").click();
+ bot.button("Finish").click();
+ updateConf(botUtil,projectName);
}
private void addServlet(String projectName, String servletName, String servletClass,
String load) throws Exception{
@@ -289,7 +287,7 @@
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = factory.newDocumentBuilder();
- Document docPom =
docBuilder.parse(facade.getProject().getFile("/WebContent/WEB-INF/web.xml").getContents());
+ Document docPom =
docBuilder.parse(facade.getProject().getFile(WEB_XML_LOCATION).getContents());
Element servletElement = docPom.createElement("servlet");
Element servletNameElement = docPom.createElement("servlet-name");
Element servletClassElement = docPom.createElement("servlet-class");
@@ -310,8 +308,8 @@
StreamResult result = new StreamResult(xmlAsWriter);
DOMSource source = new DOMSource(docPom);
trans.transform(source, result);
- facade.getProject().getFile("/WebContent/WEB-INF/web.xml").setContents(new
ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")), 0, null);
+ facade.getProject().getFile(WEB_XML_LOCATION).setContents(new
ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")), 0, null);
botUtil.waitForAll();
- updateConf(projectName);
+ updateConf(botUtil,projectName);
}
}
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenProjectsTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenProjectsTest.java 2012-08-04
01:24:50 UTC (rev 42855)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenProjectsTest.java 2012-08-06
07:53:29 UTC (rev 42856)
@@ -6,12 +6,12 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.bindings.keys.KeyStroke;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.maven.ui.bot.test.utils.TableHasRows;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
import org.jboss.tools.ui.bot.ext.SWTUtilExt;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
@@ -23,30 +23,38 @@
public class CreateMavenProjectsTest extends AbstractMavenSWTBotTest{
public static final String REPO_URL = "http://repo1.maven.org/maven2";
- protected static SWTWorkbenchBot bot = new SWTWorkbenchBot();
+ public static final String NEXUS_URL =
"https://repository.jboss.org/nexus/content/repositories/releases/";
+ private SWTUtilExt botUtil= new SWTUtilExt(bot);
+
@BeforeClass
public static void setup(){
SWTBotExt setup = new SWTBotExt();
setup.menu("Window").menu("Show
View").menu("Other...").click();
setup.tree().expandNode("Java").select("Package
Explorer").click();
setup.button("OK").click();
+
}
@Test
public void updateRepositories() throws InterruptedException, CoreException {
- SWTBotExt botExt = new SWTBotExt();
- botExt.menu("Window").menu("Show
View").menu("Other...").click();
+ bot.menu("Window").menu("Show
View").menu("Other...").click();
+ waitForShell(botUtil, "Show View");
+ bot.tree().expandNode("Maven").select("Maven Repositories");
+ bot.button("OK").click();
+ bot.viewByTitle("Maven Repositories");
waitForIdle();
- botExt.tree().expandNode("Maven").select("Maven Repositories");
- botExt.button("OK").click();
- SWTBot b = botExt.viewByTitle("Maven Repositories").bot();
- AbstractMavenSWTBotTest.waitForIdle();
- b.tree().expandNode("Global Repositories").getNode("central (" +
REPO_URL + ")").contextMenu("Rebuild Index").click();
- botExt.button("OK").click();
- SWTUtilExt util = new SWTUtilExt(botExt);
- util.waitForAll();
- util.waitForJobs(Long.MAX_VALUE,"Rebuilding Indexes");
+ bot.tree().expandNode("Global Repositories").getNode("central (" +
REPO_URL + ")").contextMenu("Rebuild Index").click();
+ bot.button("OK").click();
+ botUtil.waitForAll();
+ botUtil.waitForJobs(Long.MAX_VALUE,"Rebuilding Indexes");
+ bot.tree().expandNode("Global Repositories").getNode("jboss (" +
NEXUS_URL + ")").contextMenu("Rebuild Index").click();
+ bot.button("OK").click();
+ botUtil.waitForAll();
+ botUtil.waitForJobs(Long.MAX_VALUE,"Rebuilding Indexes");
+ bot.tree().expandNode("Global Repositories").getNode("jboss (" +
NEXUS_URL + ")").contextMenu("Update Index").click();
+ botUtil.waitForAll();
+ botUtil.waitForJobs(Long.MAX_VALUE,"Updating Indexes");
}
@Test
@@ -55,7 +63,7 @@
createSimpleMavenProject(projectName, "jar");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
assertNoErrors(project);
- assertTrue(Utils.isMavenProject(projectName));
+ assertTrue(isMavenProject(projectName));
buildProject(projectName,"5 Maven build...",
"jar","-0.0.1-SNAPSHOT");
}
@@ -64,32 +72,30 @@
@Test
public void createSimpleJarMavenizedProject() throws Exception{
String projectName = "JarMavenized";
- SWTBotExt botExt = new SWTBotExt();
- botExt.menu("File").menu("New").menu("Other...").click();
+ bot.menu("File").menu("New").menu("Other...").click();
+ waitForShell(botUtil, "New");
+ bot.tree().expandNode("Java").select("Java Project");
+ bot.button("Next >").click();
+ bot.textWithLabel("Project name:").setText(projectName);
+ bot.button("Finish").click();
waitForIdle();
- SWTBot shell = botExt.shell("New").activate().bot();
- shell.tree().expandNode("Java").select("Java Project");
- shell.button("Next >").click();
- shell.textWithLabel("Project name:").setText(projectName);
- shell.button("Finish").click();
- waitForIdle();
- SWTBot explorer = botExt.viewByTitle("Package Explorer").bot();
- explorer.tree().getTreeItem(projectName).select().pressShortcut(Keystrokes.ALT,Keystrokes.LF);
+ bot.viewByTitle("Package Explorer");
+ bot.tree().getTreeItem(projectName).select().pressShortcut(Keystrokes.ALT,Keystrokes.LF);
+ waitForShell(botUtil, "Properties for "+projectName);
+ bot.tree().select("Project Facets");
+ Thread.sleep(500);
+ bot.link(0).click("Convert to faceted form...");
Thread.sleep(1000);
- botExt.tree().select("Project Facets");
- Thread.sleep(500);
- botExt.link(0).click("Convert to faceted form...");
- waitForIdle();
- botExt.tree(1).getTreeItem("JBoss Maven Integration").check();
+ bot.tree(1).getTreeItem("JBoss Maven Integration").check();
Thread.sleep(500);
- botExt.hyperlink("Further configuration required...").click();
- botExt.comboBoxWithLabel("Packaging:").setSelection("jar");
- botExt.button("OK").click();
- botExt.button("OK").click();
+ bot.hyperlink("Further configuration required...").click();
+ bot.comboBoxWithLabel("Packaging:").setSelection("jar");
+ bot.button("OK").click();
+ bot.button("OK").click();
waitForIdle();
IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
assertNoErrors(project);
- assertTrue(Utils.isMavenProject(projectName));
+ assertTrue(isMavenProject(projectName));
buildProject(projectName,"5 Maven build...",
"jar","-0.0.1-SNAPSHOT");
}
@@ -98,49 +104,47 @@
@Test
public void createSimpleWarMavenizedProject() throws Exception{
String projectName = "WarMavenized";
- SWTBotExt botExt = new SWTBotExt();
- botExt.menu("File").menu("New").menu("Other...").click();
+ bot.menu("File").menu("New").menu("Other...").click();
+ waitForShell(botUtil,"New");
+ bot.tree().expandNode("Web").select("Dynamic Web Project");
+ bot.button("Next >").click();
+ bot.textWithLabel("Project name:").setText(projectName);
+ bot.button("Modify...").click();
+ bot.tree().getTreeItem("JBoss Maven Integration").check();
+ bot.button("OK").click();
+ bot.button("Next >").click();
+ bot.button("Next >").click();
+ bot.checkBox("Generate web.xml deployment descriptor").select();
+ bot.button("Next >").click();
+ bot.button("Finish").click();
waitForIdle();
- SWTBot shell = botExt.shell("New").activate().bot();
- shell.tree().expandNode("Web").select("Dynamic Web Project");
- shell.button("Next >").click();
- botExt.textWithLabel("Project name:").setText(projectName);
- botExt.button("Modify...").click();
- botExt.tree().getTreeItem("JBoss Maven Integration").check();
- botExt.button("OK").click();
- botExt.button("Next >").click();
- botExt.button("Next >").click();
- botExt.checkBox("Generate web.xml deployment descriptor").select();
- botExt.button("Next >").click();
- botExt.button("Finish").click();
+ bot.button("No").click();
waitForIdle();
- botExt.button("No").click();
- waitForIdle();
IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
assertNoErrors(project);
- assertTrue(Utils.isMavenProject(projectName));
+ assertTrue(isMavenProject(projectName));
buildProject(projectName,"5 Maven build...",
"war","-0.0.1-SNAPSHOT");
}
-
+
@Test
public void createSimpleJSFProjectArchetype() throws Exception {
String projectName = "JsfQuickstart";
- createSimpleMavenProjectArchetype(projectName,"weld-jsf-jee-minimal",
"Nexus Indexer");
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- assertNoErrors(project);
- assertTrue(Utils.isMavenProject(projectName));
- buildProject(projectName, "6 Maven build...", "war","");
//version is 1.0.0
+ createSimpleMavenProjectArchetype(projectName,"maven-archetype-jsfwebapp",
"Nexus Indexer");
+ //IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ //assertNoErrors(project);
+ assertTrue(isMavenProject(projectName));
+ buildProject(projectName, "5 Maven build...", "war","");
//version is 1.0.0
}
@Test
public void createSimpleJarProjectArchetype() throws Exception {
String projectName = "ArchetypeQuickstart";
- createSimpleMavenProjectArchetype(projectName,"maven-archetype-quickstart",
"Nexus Indexer");
+ createSimpleMavenProjectArchetype(projectName,"maven-archetype-quickstart",
"Internal");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
assertNoErrors(project);
- assertTrue(Utils.isMavenProject(projectName));
- buildProject(projectName, "6 Maven build...",
"jar","-0.0.1-SNAPSHOT");
+ assertTrue(isMavenProject(projectName));
+ buildProject(projectName, "4 Maven build...",
"jar","-0.0.1-SNAPSHOT");
}
private void createSimpleMavenProjectArchetype(String projectName,String projectType,
String catalog) throws InterruptedException,CoreException {
@@ -156,6 +160,8 @@
shell.comboBox().setSelection(catalog);
SWTUtilExt botUtil = new SWTUtilExt(botExt);
botUtil.waitForAll();
+ botExt.waitUntil(new TableHasRows(botExt.table(),projectType),100000);
+ Thread.sleep(10000);
int index = botExt.table(0).indexOf(projectType, "Artifact Id");
if (index == -1) {
fail(projectType + " not found");
@@ -165,7 +171,7 @@
shell.comboBoxWithLabel("Group Id:").setText(projectName);
shell.comboBoxWithLabel("Artifact Id:").setText(projectName);
shell.button("Finish").click();
- waitForJobsToComplete();
+ waitForIdle();
}
private void createSimpleMavenProject(String projectName, String projectType) throws
InterruptedException, CoreException {
@@ -190,7 +196,10 @@
Thread.sleep(500);
SWTBotTreeItem item = explorer.tree().getTreeItem(projectName).select();
SWTBotExt swtBot = new SWTBotExt();
- item.contextMenu("Run As").menu(mavenBuild).click();
+ item.pressShortcut(Keystrokes.SHIFT,Keystrokes.ALT,KeyStroke.getInstance("X"));
+ Thread.sleep(1000);
+ item.pressShortcut(KeyStroke.getInstance("M"));
+ swtBot.waitForShell("Edit Configuration");
swtBot.textWithLabel("Goals:").setText("clean package");
swtBot.button("Run").click();
waitForIdle();
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedEARProjectTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedEARProjectTest.java 2012-08-04
01:24:50 UTC (rev 42855)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedEARProjectTest.java 2012-08-06
07:53:29 UTC (rev 42856)
@@ -1,7 +1,18 @@
package org.jboss.tools.maven.ui.bot.test;
-import static org.junit.Assert.assertTrue;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -18,18 +29,20 @@
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
@Require(perspective="Java EE")
-public class CreateMavenizedEARProjectTest {
+public class CreateMavenizedEARProjectTest extends AbstractMavenSWTBotTest{
public static final String WAR_PROJECT_NAME="earWeb";
public static final String EJB_PROJECT_NAME="earEJB";
public static final String EAR_PROJECT_NAME="ear";
+
+ private SWTUtilExt botUtil= new SWTUtilExt(bot);
- private SWTBotExt botext = new SWTBotExt();
- private SWTUtilExt botUtil = new SWTUtilExt(botext);
-
@BeforeClass
public static void setup(){
SWTBotExt setup = new SWTBotExt();
@@ -45,80 +58,123 @@
Thread.sleep(500);
createEJBProject(EJB_PROJECT_NAME);
Thread.sleep(500);
- botext.menu("File").menu("Enterprise Application
Project").click();
- botext.textWithLabel("Project name:").setText(EAR_PROJECT_NAME);
- botext.button("Modify...").click();
- botext.tree().getTreeItem("JBoss Maven Integration").check();
- botext.button("OK").click();
- botext.button("Next >").click();
- botext.button("Select All").click();
- botext.button("Next >").click();
- botext.comboBoxWithLabel("Packaging:").setSelection("ear");
- botext.button("Finish").click();
- Utils.waitForIdle();
- assertTrue(Utils.isMavenProject(EAR_PROJECT_NAME));
+ bot.menu("File").menu("Enterprise Application Project").click();
+ bot.textWithLabel("Project name:").setText(EAR_PROJECT_NAME);
+ bot.button("Modify...").click();
+ bot.tree().getTreeItem("JBoss Maven Integration").check();
+ bot.button("OK").click();
+ bot.button("Next >").click();
+ bot.button("Select All").click();
+ bot.button("Next >").click();
+ bot.comboBoxWithLabel("Packaging:").setSelection("ear");
+ bot.button("Finish").click();
+ waitForIdle();
+ assertTrue("EAR project isn't maven project",
isMavenProject(EAR_PROJECT_NAME));
installProject(WAR_PROJECT_NAME);
installProject(EJB_PROJECT_NAME);
- botext.viewByTitle("Project
Explorer").bot().tree().getTreeItem(EAR_PROJECT_NAME).contextMenu("Run
As").menu("5 Maven build...").click();
- Utils.waitForIdle();
- botext.textWithLabel("Goals:").setText("clean package");
- botext.button("Run").click();
- Utils.waitForIdle();
+ addDependencies(EAR_PROJECT_NAME, "org.jboss.tools", WAR_PROJECT_NAME,
"0.0.1-SNAPSHOT", "war");
+ addDependencies(EAR_PROJECT_NAME, "org.jboss.tools", EJB_PROJECT_NAME,
"0.0.1-SNAPSHOT", "ejb");
+ confEarMavenPlugn(EAR_PROJECT_NAME);
+ bot.viewByTitle("Project
Explorer").bot().tree().getTreeItem(EAR_PROJECT_NAME).contextMenu("Run
As").menu("3 Maven build...").click();
+ waitForIdle();
+ bot.textWithLabel("Goals:").setText("clean package");
+ bot.button("Run").click();
+ waitForIdle();
IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(EAR_PROJECT_NAME);
project.getFolder("target").refreshLocal(IResource.DEPTH_INFINITE, new
NullProgressMonitor());
IFolder earFolder = project.getFolder("target/" + EAR_PROJECT_NAME +
"-0.0.1-SNAPSHOT");
assertTrue(earFolder +" is missing ", earFolder.exists());
+ assertTrue(WAR_PROJECT_NAME+ ".war is missing in
ear",project.getFile("target/" +EAR_PROJECT_NAME+
"-0.0.1-SNAPSHOT/" +WAR_PROJECT_NAME+
"-0.0.1-SNAPSHOT.war").exists());
+ assertTrue(EJB_PROJECT_NAME+ ".jar is missing in
ear",project.getFile("target/" +EAR_PROJECT_NAME+
"-0.0.1-SNAPSHOT/" +EJB_PROJECT_NAME+
"-0.0.1-SNAPSHOT.jar").exists());
}
private void createWarProject(String projectName) throws CoreException,
InterruptedException{
- botext.menu("File").menu("Dynamic Web Project").click();
- botext.textWithLabel("Project name:").setText(projectName);
- botext.button("Next >").click();
- botext.button("Next >").click();
- botext.checkBox("Generate web.xml deployment descriptor").select();
- botext.button("Finish").click();
+ bot.menu("File").menu("Dynamic Web Project").click();
+ bot.textWithLabel("Project name:").setText(projectName);
+ bot.button("Next >").click();
+ bot.button("Next >").click();
+ bot.checkBox("Generate web.xml deployment descriptor").select();
+ bot.button("Finish").click();
botUtil.waitForAll(Long.MAX_VALUE);
- SWTBotTreeItem item = botext.viewByTitle("Package
Explorer").bot().tree().getTreeItem(projectName).select();
+ SWTBotTreeItem item = bot.viewByTitle("Package
Explorer").bot().tree().getTreeItem(projectName).select();
item.pressShortcut(Keystrokes.ALT,Keystrokes.LF);
- SWTBot shellProperties = botext.shell("Properties for
"+projectName).activate().bot();
+ waitForShell(botUtil, "Properties for "+projectName);
+ SWTBot shellProperties = bot.shell("Properties for
"+projectName).activate().bot();
shellProperties.tree().select("Project Facets");
shellProperties.tree(1).getTreeItem("JBoss Maven Integration").check();
- Utils.waitForIdle();
+ waitForIdle();
Thread.sleep(500);
- botext.hyperlink("Further configuration required...").click();
- botext.button("OK").click();
- botext.button("OK").click();
+ bot.hyperlink("Further configuration required...").click();
+ bot.button("OK").click();
+ bot.button("OK").click();
botUtil.waitForAll(Long.MAX_VALUE);
- assertTrue("Web project doesn't have maven
nature",Utils.isMavenProject(projectName));
+ assertTrue("Web project doesn't have maven
nature",isMavenProject(projectName));
}
private void createEJBProject(String projectName) throws CoreException,
InterruptedException{
- botext.menu("File").menu("EJB Project").click();
- botext.textWithLabel("Project name:").setText(projectName);
- botext.button("Modify...").click();
- botext.tree().getTreeItem("JBoss Maven Integration").check();
- botext.button("OK").click();
- botext.button("Next >").click();
- botext.button("Next >").click();
- botext.button("Next >").click();
- botext.comboBoxWithLabel("Packaging:").setSelection("ejb");
- botext.button("Finish").click();
+ bot.menu("File").menu("EJB Project").click();
+ bot.textWithLabel("Project name:").setText(projectName);
+ bot.button("Modify...").click();
+ bot.tree().getTreeItem("JBoss Maven Integration").check();
+ bot.button("OK").click();
+ bot.button("Next >").click();
+ bot.button("Next >").click();
+ bot.button("Next >").click();
+ bot.comboBoxWithLabel("Packaging:").setSelection("ejb");
+ bot.button("Finish").click();
botUtil.waitForAll(Long.MAX_VALUE);
- assertTrue("EJB project doesn't have maven nature",
Utils.isMavenProject(projectName));
+ assertTrue("EJB project doesn't have maven nature",
isMavenProject(projectName));
}
private void installProject(String projectName) throws InterruptedException{
- botext.menu("Window").menu("Show
View").menu("Other...").click();
- botext.tree().expandNode("Java").select("Package
Explorer").click();
- botext.button("OK").click();
- SWTBotTree innerBot = botext.viewByTitle("Package
Explorer").bot().tree().select(projectName);
+ bot.menu("Window").menu("Show
View").menu("Other...").click();
+ bot.tree().expandNode("Java").select("Package Explorer").click();
+ bot.button("OK").click();
+ SWTBotTree innerBot = bot.viewByTitle("Package
Explorer").bot().tree().select(projectName);
ContextMenuHelper.clickContextMenu(innerBot,"Run As","5 Maven
build...");
- botext.textWithLabel("Goals:").setText("clean package install");
- botext.button("Run").click();
- Utils.waitForIdle();
+ bot.textWithLabel("Goals:").setText("clean install");
+ bot.button("Run").click();
+ waitForIdle();
botUtil.waitForAll();
}
+ private void confEarMavenPlugn(String projectName) throws ParserConfigurationException,
SAXException, IOException, CoreException, TransformerException{
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ Document docPom =
docBuilder.parse(project.getProject().getFile("pom.xml").getContents());
+ Element configurationElement = (Element)
docPom.getElementsByTagName("configuration").item(0);
+ Element modulesElement = docPom.createElement("modules");
+ Element warModuleElement = docPom.createElement("webModule");
+ Element ejbModuleElement = docPom.createElement("ejbModule");
+ Element groupIdWarElement = docPom.createElement("groupId");
+ Element artifactIdWarElement = docPom.createElement("artifactId");
+ Element groupIdEJBElement = docPom.createElement("groupId");
+ Element artifactIdEJBElement = docPom.createElement("artifactId");
+
+ groupIdWarElement.setTextContent("org.jboss.tools");
+ groupIdEJBElement.setTextContent("org.jboss.tools");
+ artifactIdWarElement.setTextContent(WAR_PROJECT_NAME);
+ artifactIdEJBElement.setTextContent(EJB_PROJECT_NAME);
+
+ warModuleElement.appendChild(groupIdWarElement);
+ warModuleElement.appendChild(artifactIdWarElement);
+ ejbModuleElement.appendChild(groupIdEJBElement);
+ ejbModuleElement.appendChild(artifactIdEJBElement);
+ modulesElement.appendChild(warModuleElement);
+ modulesElement.appendChild(ejbModuleElement);
+ configurationElement.appendChild(modulesElement);
+
+ TransformerFactory transfac = TransformerFactory.newInstance();
+ Transformer trans = transfac.newTransformer();
+ StringWriter xmlAsWriter = new StringWriter();
+ StreamResult result = new StreamResult(xmlAsWriter);
+ DOMSource source = new DOMSource(docPom);
+ trans.transform(source, result);
+ project.getProject().getFile("pom.xml").setContents(new
ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")), 0, null);
+ }
+
}
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java 2012-08-04
01:24:50 UTC (rev 42855)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java 2012-08-06
07:53:29 UTC (rev 42856)
@@ -1,11 +1,10 @@
package org.jboss.tools.maven.ui.bot.test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringWriter;
-
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -14,7 +13,6 @@
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -23,13 +21,17 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.m2e.tests.common.WorkspaceHelpers;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTBotFactory;
import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.condition.TaskDuration;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -41,103 +43,69 @@
//TODO deployment
@SuppressWarnings("restriction")
@Require(perspective = "Web Development")
-public class CreateMavenizedJSFProjectTest{
- public static final String
JBOSS6_AS_HOME=System.getProperty("jbosstools.test.jboss.home.6.0");
+public class CreateMavenizedJSFProjectTest extends AbstractMavenSWTBotTest{
+ public static final String
JBOSS7_AS_HOME=System.getProperty("jbosstools.test.jboss.home.7.1");
public static final String POM_FILE = "pom.xml";
- public static final String PROJECT_NAME6="JSFProject6";
public static final String PROJECT_NAME7="JSFProject7";
- public static final String PROJECT_NAME6_v1="JSFProject6_1.2";
public static final String PROJECT_NAME7_v1="JSFProject7_1.2";
- public static final String SERVER_RUNTIME6="JBoss 6.x Runtime";
- public static final String SERVER_RUNTIME7="JBoss 7.x Runtime";
- public static final String SERVER6="JBoss AS 6.x";
- public static final String SERVER7="JBoss AS 7.x";
+ public static final String SERVER_RUNTIME7="JBoss 7.1 Runtime";
+ public static final String SERVER7="JBoss AS 7.1";
public static final String GROUPID ="javax.faces";
public static final String ARTIFACTID ="jsf-api";
public static final String JSF_VERSION_1_1_02 ="1.1.02";
public static final String JSF_VERSION_1_2 ="2.0";
public static final String JSF_VERSION_2 ="2.0";
+
+ private SWTUtilExt botUtil= new SWTUtilExt(bot);
- protected static SWTWorkbenchBot bot;
- private SWTUtilExt botUtil = new SWTUtilExt(bot);
-
-
@BeforeClass
public final static void beforeClass() throws Exception {
- bot = AbstractMavenSWTBotTest.initSWTBot();
SWTBotExt setup = new SWTBotExt();
setup.menu("Window").menu("Show
View").menu("Other...").click();
setup.tree().expandNode("Java").select("Package
Explorer").click();
setup.button("OK").click();
}
- @Test
- public void createJSFProjectTest_AS6_v2() throws InterruptedException, CoreException{
- createJSFProject(SERVER_RUNTIME6, SERVER6, JBOSS6_AS_HOME,"JSF 2.0",
PROJECT_NAME6);
- }
-
- @Test
- public void activateMavenFacet_AS6_v2() throws InterruptedException, CoreException{
- activateMavenFacet(PROJECT_NAME6);
- }
-
- @Test
- public void buildProject_AS6_v2() throws CoreException, ParserConfigurationException,
SAXException, IOException, TransformerException, InterruptedException{
- addDependencies(PROJECT_NAME6, JSF_VERSION_2);
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME6);
+ //@Test
+ public void createJSFProjectTest_AS7_JSFv2() throws InterruptedException, CoreException,
ParserConfigurationException, SAXException, IOException, TransformerException{
+ createJSFProject(SERVER_RUNTIME7, SERVER7, JBOSS7_AS_HOME,"JSF 2.0",
PROJECT_NAME7);
+ activateMavenFacet(PROJECT_NAME7);
+ addDependencies(PROJECT_NAME7, JSF_VERSION_2);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME7);
assertNoErrors(project);
- buildProject(PROJECT_NAME6);
+ buildProject(PROJECT_NAME7);
}
- /*
- @Test
- public void deployProject_AS6_v2() throws ParserConfigurationException, SAXException,
IOException, CoreException, TransformerException{
- addServerToPom(PROJECT_NAME6, JBOSS6_AS_HOME);
- deployModule(PROJECT_NAME6);
- }
- */
-
@Test
- public void createJSFProjectTest_AS6_v1() throws InterruptedException, CoreException{
- createJSFProject(SERVER_RUNTIME6, SERVER6, JBOSS6_AS_HOME,"JSF 1.2",
PROJECT_NAME6_v1);
- }
-
- @Test
- public void activateMavenFacet_AS6_v1() throws InterruptedException, CoreException{
- activateMavenFacet(PROJECT_NAME6_v1);
- }
-
- @Test
- public void buildProject_AS6_v1() throws CoreException, ParserConfigurationException,
SAXException, IOException, TransformerException, InterruptedException{
- addDependencies(PROJECT_NAME6_v1, JSF_VERSION_1_2);
- IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME6_v1);
+ public void createJSFProjectTest_AS7_JSFv1() throws InterruptedException, CoreException,
ParserConfigurationException, SAXException, IOException, TransformerException{
+ createJSFProject(SERVER_RUNTIME7, SERVER7, JBOSS7_AS_HOME,"JSF 1.2",
PROJECT_NAME7_v1);
+ activateMavenFacet(PROJECT_NAME7_v1);
+ addDependencies(PROJECT_NAME7_v1, JSF_VERSION_1_2);
+ IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME7_v1);
assertNoErrors(project);
- buildProject(PROJECT_NAME6_v1);
+ buildProject(PROJECT_NAME7_v1);
}
private void createJSFProject(String serverRuntime, String server, String serverHome,
String jsfVersion, String projectName) throws InterruptedException, CoreException{
bot.menu("File").menu("New").menu("JSF
Project").click();
- SWTBot shell = bot.shell("New JSF Project").activate().bot();
- shell.textWithLabel("Project Name*").setText(projectName);
- shell.comboBox(0).setSelection(jsfVersion);
- shell.comboBox(1).setSelection("JSFKickStartWithoutLibs");
- shell.button("Next >").click();
- Thread.sleep(1000);
- shell.button("New...").click();
- SWTBot shellRuntime = bot.shell("New Server Runtime").activate().bot();
- Thread.sleep(500);
- shellRuntime.tree().expandNode("JBoss Community").select(serverRuntime);
- shellRuntime.button("Next >").click();
- shellRuntime.textWithLabel("Home Directory").setText(serverHome);
- shellRuntime.button("Finish").click();
- Thread.sleep(500);
- shell.button(1).click();
- shellRuntime = bot.shell("New Server").activate().bot();
- shellRuntime.tree().expandNode("JBoss Community").select(server);
- shellRuntime.button("Finish").click();
+ bot.textWithLabel("Project Name*").setText(projectName);
+ bot.comboBox(0).setSelection(jsfVersion);
+ bot.comboBox(1).setSelection("JSFKickStartWithoutLibs");
+ bot.button("Next >").click();
+ bot.button("New...").click();
+ waitForShell(botUtil,"New Server Runtime");
+ bot.tree().expandNode("JBoss Community").select(serverRuntime);
+ bot.button("Next >").click();
+ bot.textWithLabel("Home Directory").setText(serverHome);
+ bot.button("Finish").click();
+ waitForShell(botUtil,"New JSF Project");
+ bot.button(1).click();
+ waitForShell(botUtil,"New Server");
+ bot.tree().expandNode("JBoss Community").select(server);
+ bot.button("Finish").click();
botUtil.waitForAll(Long.MAX_VALUE);
- shell.button("Finish").click();;
+ bot.button("Finish").click();;
botUtil.waitForAll(Long.MAX_VALUE);
}
@@ -173,26 +141,18 @@
}
private void activateMavenFacet(String projectName) throws InterruptedException,
CoreException{
- SWTBot explorer = bot.viewByTitle("Package Explorer").bot();
- SWTBotTreeItem item = explorer.tree().getTreeItem(projectName).select();
- Thread.sleep(500);
+ SWTBotTreeItem item = bot.viewByTitle("Package
Explorer").bot().tree().getTreeItem(projectName).select();
item.pressShortcut(Keystrokes.ALT,Keystrokes.LF);
- Thread.sleep(1000);
- SWTBot shellProperties = bot.shell("Properties for
"+projectName).activate().bot();
- shellProperties.tree().select("Project Facets");
+ waitForShell(botUtil,"Properties for "+projectName);
+ bot.tree().select("Project Facets");
+ bot.tree(1).getTreeItem("JBoss Maven Integration").check();
+ botUtil.waitForAll();
Thread.sleep(500);
- //botExt.link(0).click("Convert to faceted form...");
+ bot.hyperlink("Further configuration required...").click();
+ bot.button("OK").click();
+ bot.button("OK").click();
waitForIdle();
- shellProperties.tree(1).getTreeItem("JBoss Maven Integration").check();
- Thread.sleep(500);
- SWTBotExt swtBot = new SWTBotExt();
- swtBot.hyperlink("Further configuration required...").click();
- swtBot.button("OK").click();
- swtBot.button("OK").click();
- waitForIdle();
- IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- assertNoErrors(project);
- assertTrue(Utils.isMavenProject(projectName));
+ assertTrue(projectName+ " doesn't have maven nature",
isMavenProject(projectName));
}
private void buildProject(String projectName) throws CoreException{
@@ -213,69 +173,4 @@
assertFalse(warFolder.getFolder(webInfPath.append("dev")).exists());
assertTrue(warFolder.getFolder(webInfPath.append("lib")).exists());
}
-
- private void addServerToPom(String projectName, String serverLocation) throws
ParserConfigurationException, SAXException, IOException, CoreException,
TransformerException{
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = factory.newDocumentBuilder();
- Document docPom =
docBuilder.parse(project.getFile("pom.xml").getContents());
- Element pluginElement = docPom.createElement("plugin");
- Element groupIdElement = docPom.createElement("groupId");
- Element artifactIdElement = docPom.createElement("artifactId");
- Element versionElement = docPom.createElement("version");
- Element configurationElement = docPom.createElement("configuration");
- Element jbossHomeElement = docPom.createElement("jbossHome");
- Element serverNameElement = docPom.createElement("serverName");
- Element fileNameElement = docPom.createElement("fileName");
-
- groupIdElement.setTextContent("org.codehaus.mojo");
- artifactIdElement.setTextContent("jboss-maven-plugin");
- versionElement.setTextContent("1.5.0");
- jbossHomeElement.setTextContent(serverLocation);
- serverNameElement.setTextContent("default");
- fileNameElement.setTextContent("target"+projectName+".war");
-
- Element root = docPom.getDocumentElement();
- Element buildElement =
(Element)root.getElementsByTagName("build").item(0);
- Node plugins = buildElement.getElementsByTagName("plugins").item(0);
- configurationElement.appendChild(serverNameElement);
- configurationElement.appendChild(jbossHomeElement);
- configurationElement.appendChild(fileNameElement);
- pluginElement.appendChild(configurationElement);
- pluginElement.appendChild(versionElement);
- pluginElement.appendChild(artifactIdElement);
- pluginElement.appendChild(groupIdElement);
- plugins.appendChild(pluginElement);
- //save pom
- TransformerFactory transfac = TransformerFactory.newInstance();
- Transformer trans = transfac.newTransformer();
- StringWriter xmlAsWriter = new StringWriter();
- StreamResult result = new StreamResult(xmlAsWriter);
- DOMSource source = new DOMSource(docPom);
- trans.transform(source, result);
- project.getFile("pom.xml").setContents(new
ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")), 0, null);
- waitForIdle();
- }
-
- private void deployModule(String projectName){
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- SWTBot explorer = bot.viewByTitle("Package Explorer").bot();
- SWTBotTreeItem item = explorer.tree().getTreeItem(projectName).select();
- SWTBotExt swtBot = new SWTBotExt();
- item.contextMenu("Run As").menu("5 Maven build...").click();
- waitForIdle();
- swtBot.textWithLabel("Goals:").setText("jboss:hard-deploy");
- swtBot.button("Run").click();
- waitForIdle();
- }
-
-
- private static void waitForIdle() {
- AbstractMavenSWTBotTest.waitForIdle();
- }
-
- private static void assertNoErrors(IProject project) throws CoreException {
- WorkspaceHelpers.assertNoErrors(project);
- }
-
-}
+}
\ No newline at end of file
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java 2012-08-04
01:24:50 UTC (rev 42855)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java 2012-08-06
07:53:29 UTC (rev 42856)
@@ -11,27 +11,14 @@
package org.jboss.tools.maven.ui.bot.test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.io.File;
-import java.io.FilenameFilter;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Properties;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
import org.eclipse.datatools.connectivity.ConnectionProfileException;
import org.eclipse.datatools.connectivity.ProfileManager;
@@ -43,262 +30,128 @@
import org.eclipse.datatools.connectivity.drivers.IPropertySet;
import org.eclipse.datatools.connectivity.drivers.PropertySetImpl;
import org.eclipse.datatools.connectivity.drivers.models.TemplateDescriptor;
-import org.eclipse.m2e.core.internal.IMavenConstants;
import org.eclipse.m2e.tests.common.WorkspaceHelpers;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-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.widgets.SWTBotMenu;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IPerspectiveRegistry;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IRuntimeType;
-import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerType;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.ServerUtil;
-import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
-import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
-import org.eclipse.wst.validation.ValidationFramework;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.core.project.facet.SeamVersion;
-import org.jboss.tools.test.util.ResourcesUtils;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-/**
- * @author Snjeza
- *
- */
@SuppressWarnings("restriction")
-@Require(perspective="Seam")
-public class CreateMavenizedSeamProjectTest{
-
- protected static final long IDLE_TIME = 1 * 60 * 1000L;
+@Require(perspective = "Java EE")
+public class CreateMavenizedSeamProjectTest extends AbstractMavenSWTBotTest {
- private static final String CONNECTION_PROFILE_NAME = "DefaultDS";
-
- private static final String SEAM_RUNTIME_NAME = "Seam 2.2";
-
- private static final String JBOSS_AS_RUNTIME_NAME = "JBoss AS 5.1 Runtime";
-
- public static final String PACKAGE_EXPLORER = "Package Explorer";
//$NON-NLS-1$
-
- private static final String JBOSS_AS_SERVER_NAME = "JBoss AS 5.1 Server";
-
- public static final String JBOSS_AS_HOST = "localhost"; //$NON-NLS-1$
-
- public static final String JBOSS_AS_DEFAULT_CONFIGURATION_NAME = "default";
//$NON-NLS-1$
-
- public static final String HSQL_DRIVER_DEFINITION_ID
- = "DriverDefn.Hypersonic DB"; //$NON-NLS-1$
-
- public static final String HSQL_DRIVER_NAME = "Hypersonic DB"; //$NON-NLS-1$
-
- public static final String HSQL_DRIVER_TEMPLATE_ID
- = "org.eclipse.datatools.enablement.hsqldb.1_8.driver"; //$NON-NLS-1$
-
- public static final String DTP_DB_URL_PROPERTY_ID
- = "org.eclipse.datatools.connectivity.db.URL"; //$NON-NLS-1$
-
+ public static final String SEAM_WEB_PROJECT = "seamWeb";
+ public static final String SEAM_EAR_PROJECT = "seamEar";
+ public static final String JBOSS_AS_7_1 =
System.getProperty("jbosstools.test.jboss.home.7.1");
+ public static final String SEAM_2_3 =
System.getProperty("jbosstools.test.seam.2.3.0.home");
+ public static final String SEAM_2_3_NAME = "jboss-seam-2.3.0";
+ public static final String SEAM_2_2 =
System.getProperty("jbosstools.test.seam.2.2.0.home");
+ public static final String SEAM_2_2_NAME = "jboss-seam-2.2.0";
+ public static final String CONNECTION_PROFILE_NAME = "DefaultDS";
+ public static final String HSQL_DRIVER_DEFINITION_ID ="DriverDefn.Hypersonic
DB";
+ public static final String HSQL_DRIVER_NAME ="Hypersonic DB";
+ public static final String HSQL_DRIVER_TEMPLATE_ID =
"org.eclipse.datatools.enablement.hsqldb.1_8.driver";
+ public static final String DTP_DB_URL_PROPERTY_ID =
"org.eclipse.datatools.connectivity.db.URL";
public static final String HSQL_PROFILE_ID =
"org.eclipse.datatools.enablement.hsqldb.connectionProfile";
-
- public static final String JBOSS_AS_HOME =
System.getProperty("jbosstools.test.jboss.home.5.1");
-
- public static final String JBOSS_AS_RUNTIME_ID =
"org.jboss.ide.eclipse.as.runtime.51";
+ public static final String HSQLDB_DRIVER_LOCATION ="lib/hsqldb.jar";
+ public static final String CURRENT_SEAM_2_3 = "2.3.0.Beta2";
+ public static final String CURRENT_SEAM_2_2 ="2.2.2.Final";
- public static final String JBOSS_AS_SERVER_ID =
"org.jboss.ide.eclipse.as.51";
-
- public static final String SEAM_HOME_PROPERTY =
System.getProperty("jbosstools.test.seam.2.0.1.GA.home");
+
+ private SWTUtilExt botUtil = new SWTUtilExt(bot);
- public static final String HSQLDB_DRIVER_JAR_NAME = "hsqldb.jar";
//$NON-NLS-1$
-
- public static final String HSQLDB_DRIVER_LOCATION = "lib/ +
HSQLDB_DRIVER_JAR_NAME";//$NON-NLS-1$
-
- public static final String PROJECT_NAME_WAR = "MavenizedSeamProjectWar";
-
- public static final String TEST_PROJECT_NAME_WAR =
"MavenizedSeamProjectWar-test";
-
- public static final String PARENT_PROJECT_NAME_WAR =
"MavenizedSeamProjectWar-parent";
-
-
- public static final String PROJECT_NAME = "MavenizedSeamProject";
-
- public static final String EAR_PROJECT_NAME = "MavenizedSeamProject-ear";
-
- public static final String EJB_PROJECT_NAME = "MavenizedSeamProject-ejb";
-
- public static final String TEST_PROJECT_NAME = "MavenizedSeamProject-test";
-
- public static final String PARENT_PROJECT_NAME =
"MavenizedSeamProject-parent";
-
- public static final String DEPLOY_TYPE_EAR = "EAR";
-
- public static final String DEPLOY_TYPE_WAR = "WAR";
-
- protected static SWTWorkbenchBot bot;
-
@BeforeClass
- public final static void beforeClass() throws Exception {
- bot = AbstractMavenSWTBotTest.initSWTBot();
-
- String asLocation = JBOSS_AS_HOME;
-
- String runtimeType = JBOSS_AS_RUNTIME_ID;
- String serverType = JBOSS_AS_SERVER_ID;
-
- createJBossServer(new File(asLocation), serverType, runtimeType, JBOSS_AS_SERVER_NAME,
JBOSS_AS_RUNTIME_NAME);
-
- String seamPath = SEAM_HOME_PROPERTY;
- createSeamRuntime(SEAM_RUNTIME_NAME, seamPath, SeamVersion.SEAM_2_2);
-
- createDriver(asLocation, HSQLDB_DRIVER_LOCATION);
-
- activateSchell();
-
- createNewSeamWebProjectWizard(PROJECT_NAME, DEPLOY_TYPE_EAR);
-
- createNewSeamWebProjectWizard(PROJECT_NAME_WAR, DEPLOY_TYPE_WAR);
+ public static void setup() {
+ SWTBotExt setup = new SWTBotExt();
+ setup.menu("Window").menu("Show
View").menu("Other...").click();
+ setup.tree().expandNode("Java").select("Package
Explorer").click();
+ setup.button("OK").click();
}
-
-
-
- private static void removeProjects() throws Exception {
+
+ @Test
+ public void createSeamProjectTest() throws InterruptedException,
ConnectionProfileException, IOException, CoreException{
+ createSeamProject(SEAM_WEB_PROJECT,"2.3", "WAR", "Disable
Library Configuration");
+ createSeamProject(SEAM_EAR_PROJECT,"2.3", "EAR", "Disable
Library Configuration");
+ //checkErrors(); TODO QuickFix Project
WorkspaceHelpers.cleanWorkspace();
+ createSeamProject(SEAM_WEB_PROJECT,"2.2", "WAR", "Disable
Library Configuration");
+ createSeamProject(SEAM_EAR_PROJECT,"2.2", "EAR", "Disable
Library Configuration");
+ //checkErrors();
}
-
- private static void removeServers() throws CoreException {
- IServer server = ServerCore.findServer(JBOSS_AS_SERVER_NAME);
- IServerWorkingCopy wc = server.createWorkingCopy();
- IModule[] modules = wc.getModules();
- IProgressMonitor monitor = new NullProgressMonitor();
- wc.modifyModules(new IModule[] {} , modules, monitor);
- wc.save(true, monitor);
- server.publish(IServer.PUBLISH_INCREMENTAL, monitor);
- waitForIdle();
- server.getRuntime().delete();
- server.delete();
- waitForIdle();
- }
-
- protected static void switchPerspective(final String pid) {
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- IWorkbench workbench = PlatformUI.getWorkbench();
- IPerspectiveRegistry perspectiveRegistry = workbench
- .getPerspectiveRegistry();
- IPerspectiveDescriptor perspective = perspectiveRegistry
- .findPerspectiveWithId(pid);
- workbench.getActiveWorkbenchWindow().getActivePage()
- .setPerspective(perspective);
- }
- });
- }
- @Before
- public void setUp() throws Exception {
- activateSchell();
- }
-
- private static void activateSchell() {
- AbstractMavenSWTBotTest.activateSchell();
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
- @AfterClass
- public final static void afterClass() throws Exception {
- boolean buildAutomatically = ResourcesUtils.setBuildAutomatically(false);
- ValidationFramework.getDefault().suspendAllValidation(true);
- try {
- removeServers();
- removeProjects();
- } finally {
- ResourcesUtils.setBuildAutomatically(buildAutomatically);
- ValidationFramework.getDefault().suspendAllValidation(false);
+ private void checkErrors() throws CoreException{
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for(IProject project: projects){
+ assertNoErrors(project);
}
- waitForIdle();
}
- protected static void createJBossServer(File asLocation, String serverType, String
runtimeType, String name, String runtimeName) throws CoreException {
- if (!asLocation.isDirectory()) {
- return;
+ private void createSeamProject(String name, String version, String type, String
JSFLibrary) throws InterruptedException, ConnectionProfileException, IOException,
CoreException {
+ createDriver(JBOSS_AS_7_1, HSQLDB_DRIVER_LOCATION);
+ if(version.equals("2.3")){
+ createSeamRuntime(SEAM_2_3_NAME, SEAM_2_3, SeamVersion.SEAM_2_3);
+ } else if(version.equals("2.2")){
+ createSeamRuntime(SEAM_2_2_NAME, SEAM_2_2, SeamVersion.SEAM_2_2);
}
- IPath jbossAsLocationPath = new Path(asLocation.getAbsolutePath());
-
- IServer[] servers = ServerCore.getServers();
- for (int i = 0; i < servers.length; i++) {
- IRuntime runtime = servers[i].getRuntime();
- if(runtime != null && runtime.getLocation().equals(jbossAsLocationPath)) {
- return;
- }
+ bot.menu("File").menu("New").menu("Other...").click();
+ waitForShell(botUtil, "New");
+ bot.tree().expandNode("Seam").select("Seam Web Project");
+ bot.button("Next >").click();
+ waitForShell(botUtil, "New Seam Project");
+ bot.textWithLabel("Project name:").setText(name);
+ bot.button("New Runtime...").click();
+ waitForShell(botUtil, "New Server Runtime Environment");
+ bot.tree().expandNode("JBoss Community").select("JBoss 7.1
Runtime");
+ bot.button("Next >").click();
+ bot.textWithLabel("Home Directory").setText(JBOSS_AS_7_1);
+ bot.button("Finish").click();
+ bot.button("New...").click();
+ waitForShell(botUtil, "New Server");
+ bot.tree().expandNode("JBoss Community").select("JBoss AS 7.1");
+ bot.button("Finish").click();
+ bot.button("Modify...").click();
+ waitForShell(botUtil, "Project Facets");
+ bot.tree().getTreeItem("Seam").contextMenu("Change
Version...").click();
+ waitForShell(botUtil, "Change Version");
+ bot.comboBoxWithLabel("Version:").setSelection(version);
+ bot.button("OK").click();
+ bot.tree().getTreeItem("JBoss Maven Integration").check();
+ bot.button("OK").click();
+ bot.button("Next >").click();
+ bot.button("Next >").click();
+ bot.button("Next >").click();
+ assertTrue("Seam project doesn't have war packaging set by default",
bot.comboBoxWithLabel("Packaging:").selection() == "war");
+ String seamVersion = bot.textWithLabel("Seam Maven version:").getText();
+ if(version.equals("2.3")){
+ assertTrue(version+ " Seam project has " + seamVersion + " set by
default", seamVersion.equals(CURRENT_SEAM_2_3));
+ } else if(version.equals("2.2")){
+ assertTrue(version+ " Seam project has " + seamVersion + " set by
default", seamVersion.equals(CURRENT_SEAM_2_2));
}
-
- IRuntime runtime = null;
- IRuntime[] runtimes = ServerCore.getRuntimes();
- for (int i = 0; i < runtimes.length; i++) {
- if (runtimes[0].getLocation().equals(jbossAsLocationPath)) {
- runtime = runtimes[0].createWorkingCopy();
- break;
- }
+ bot.button("Next >").click();
+ bot.comboBoxWithLabel("Type:").setSelection("Disable Library
Configuration");
+ bot.button("Next >").click();
+ if(version.equals("2.3")){
+ bot.comboBox(0).setSelection(SEAM_2_3_NAME);
+ } else if(version.equals("2.2")){
+ bot.comboBox(0).setSelection(SEAM_2_2_NAME);
}
-
- IProgressMonitor progressMonitor = new NullProgressMonitor();
- if (runtime == null) {
- runtime = createRuntime(runtimeName, asLocation.getAbsolutePath(), progressMonitor,
runtimeType);
- }
- if (runtime != null) {
- createServer( runtime, serverType, name, progressMonitor);
- }
+ bot.radio(type).click();
+ bot.button("Finish").click();
+ waitForShell(botUtil, "Open Associated Perspective?");
+ bot.button("No").click();
+ botUtil.waitForNonIgnoredJobs();
}
- protected static IRuntime createRuntime(String runtimeName, String jbossASLocation,
IProgressMonitor progressMonitor, String runtimeType) throws CoreException {
- IRuntimeWorkingCopy runtime = null;
- String type = null;
- String version = null;
- String runtimeId = null;
- IPath jbossAsLocationPath = new Path(jbossASLocation);
- IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(type, version, runtimeType);
- if (runtimeTypes.length > 0) {
- runtime = runtimeTypes[0].createRuntime(runtimeId, progressMonitor);
- runtime.setLocation(jbossAsLocationPath);
- if(runtimeName!=null) {
- runtime.setName(runtimeName);
- }
- ((RuntimeWorkingCopy)
runtime).setAttribute("org.jboss.ide.eclipse.as.core.runtime.configurationName",
JBOSS_AS_DEFAULT_CONFIGURATION_NAME); //$NON-NLS-1$
-
- return runtime.save(false, progressMonitor);
- }
- return runtime;
- }
-
- protected static void createDriver(String jbossASLocation, String driverLocation) throws
ConnectionProfileException, IOException {
- if(ProfileManager.getInstance().getProfileByName(CONNECTION_PROFILE_NAME) != null) {
+ protected static void createDriver(String jbossASLocation,String driverLocation) throws
ConnectionProfileException,IOException {
+ if (ProfileManager.getInstance().getProfileByName(CONNECTION_PROFILE_NAME) != null) {
return;
}
String driverPath = new File(jbossASLocation + driverLocation).getCanonicalPath();
//$NON-NLS-1$
-
+
DriverInstance driver =
DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
if (driver == null) {
TemplateDescriptor descr =
TemplateDescriptor.getDriverTemplateDescriptor(HSQL_DRIVER_TEMPLATE_ID);
@@ -316,8 +169,10 @@
props.setProperty(id, value == null ? "" : value); //$NON-NLS-1$
}
props.setProperty(DTP_DB_URL_PROPERTY_ID, "jdbc:hsqldb:."); //$NON-NLS-1$
- props.setProperty(IDriverMgmtConstants.PROP_DEFN_TYPE, descr.getId());
- props.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST, driverPath);
+ props.setProperty(IDriverMgmtConstants.PROP_DEFN_TYPE,
+ descr.getId());
+ props.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST,
+ driverPath);
instance.setBaseProperties(props);
DriverManager.getInstance().removeDriverInstance(instance.getID());
@@ -326,48 +181,25 @@
}
driver = DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
- if (driver != null &&
ProfileManager.getInstance().getProfileByName(CONNECTION_PROFILE_NAME) == null) {
//$NON-NLS-1$
+ if (driver != null &&
ProfileManager.getInstance().getProfileByName(CONNECTION_PROFILE_NAME) == null) {
// create profile
Properties props = new Properties();
- props.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID,
HSQL_DRIVER_DEFINITION_ID);
- props.setProperty(IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID,
""); //$NON-NLS-1$
- props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID,
"Default"); //$NON-NLS-1$
- props.setProperty(IDBDriverDefinitionConstants.PASSWORD_PROP_ID, "");
//$NON-NLS-1$
- props.setProperty(IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID,
"false"); //$NON-NLS-1$
- props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID));
+ props.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID, HSQL_DRIVER_DEFINITION_ID);
+ props.setProperty(IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID,"");
+ props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID,driver.getProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID,driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID,driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID,"Default");
+ props.setProperty(IDBDriverDefinitionConstants.PASSWORD_PROP_ID, "");
+ props.setProperty(IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID,"false");
+ props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID,driver.getProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID));
props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.URL_PROP_ID));
-
- ProfileManager.getInstance().createProfile(CONNECTION_PROFILE_NAME, "The JBoss AS
Hypersonic embedded database", HSQL_PROFILE_ID, props, "", false);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ProfileManager.getInstance().createProfile(CONNECTION_PROFILE_NAME,"The JBoss AS
Hypersonic embedded database", HSQL_PROFILE_ID, props, "", false);
}
-
+
}
- protected static IServerWorkingCopy createServer(IRuntime runtime, String runtimeType,
String name, IProgressMonitor progressMonitor) throws CoreException {
- IServerType serverType = ServerCore.findServerType(runtimeType);
- IServerWorkingCopy server = serverType.createServer(null, null, runtime,
progressMonitor);
- server.setHost(JBOSS_AS_HOST);
- server.setName(name);
-
- // JBossServer.DEPLOY_DIRECTORY
- String deployVal =
runtime.getLocation().append("server").append(JBOSS_AS_DEFAULT_CONFIGURATION_NAME).append("deploy").toOSString();
//$NON-NLS-1$ //$NON-NLS-2$
- ((ServerWorkingCopy)
server).setAttribute("org.jboss.ide.eclipse.as.core.server.deployDirectory",
deployVal); //$NON-NLS-1$
-
- // IDeployableServer.TEMP_DEPLOY_DIRECTORY
- String deployTmpFolderVal =
runtime.getLocation().append("server").append(JBOSS_AS_DEFAULT_CONFIGURATION_NAME).append("tmp").append("jbosstoolsTemp").toOSString();
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ((ServerWorkingCopy)
server).setAttribute("org.jboss.ide.eclipse.as.core.server.tempDeployDirectory",
deployTmpFolderVal); //$NON-NLS-1$
-
- // If we'd need to set up a username / pw for JMX, do it here.
-// ((ServerWorkingCopy)serverWC).setAttribute(JBossServer.SERVER_USERNAME, authUser);
-// ((ServerWorkingCopy)serverWC).setAttribute(JBossServer.SERVER_PASSWORD, authPass);
-
- server.save(false, progressMonitor);
- return server;
- }
-
protected static void createSeamRuntime(String name, String seamPath, SeamVersion
seamVersion) {
SeamRuntime seamRuntime = SeamRuntimeManager.getInstance().findRuntimeByName(name);
if (seamRuntime != null) {
@@ -381,214 +213,9 @@
rt.setDefault(true);
rt.setVersion(seamVersion);
SeamRuntimeManager.getInstance().addRuntime(rt);
+ } else {
+ fail("Invalid seam runtime.");
}
}
- public static void createNewSeamWebProjectWizard(String projectName, String deployType)
throws Exception {
- waitForIdle();
- bot.menu("File").menu("New").menu("Seam Web
Project").click();
-
- SWTBotShell mainShell = bot.shell("New Seam Project");
- mainShell.activate();
-
- bot.textWithLabel("Project name:").setText(projectName);
- bot.button("Modify...").click();
- SWTBotShell shell = bot.shell("Project Facets");
- shell.activate();
-
- SWTBotTree treeWidget = bot.tree();
- SWTBotTreeItem jmi = treeWidget.getTreeItem("JBoss Maven Integration");
- jmi.check();
-
- bot.button("OK").click();
-
- mainShell.activate();
-
- bot.comboBox(0).setSelection(JBOSS_AS_RUNTIME_NAME);
- bot.comboBox(2).setSelection(JBOSS_AS_SERVER_NAME);
-
- bot.button("Next >").click();
- bot.button("Next >").click();
- bot.button("Next >").click();
- bot.button("Next >").click();
-
- bot.comboBox(0).setSelection("Library Provided by Target Runtime");
- bot.button("Next >").click();
-
- bot.comboBox(0).setSelection(SEAM_RUNTIME_NAME);
- String otherType = DEPLOY_TYPE_EAR;
- if (DEPLOY_TYPE_EAR.equals(deployType)) {
- otherType = DEPLOY_TYPE_WAR;
- }
- final SWTBotRadio radio = bot.radio(deployType);
- final SWTBotRadio otherRadio = bot.radio(otherType);
- radio.click();
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- radio.widget.setSelection(true);
- otherRadio.widget.setSelection(false);
- Event event = new Event();
- event.time = (int) System.currentTimeMillis();
- event.widget = radio.widget;
- event.display = Display.getCurrent();
- radio.widget.notifyListeners(SWT.Selection, event);
- }
- });
- //comboBox(1) = Libraries
- bot.comboBox(2).setSelection("HSQL");
- bot.comboBox(3).setSelection(CONNECTION_PROFILE_NAME);
- bot.button("Finish").click();
-
- waitForIdle();
- }
-
- @Test
- public void testAsLocation() {
- String asLocation = JBOSS_AS_HOME;
- assertTrue("Invalid JBoss AS location:" + asLocation, new
File(asLocation).isDirectory());
- }
-
- @Test
- public void testSeamLocation() {
- String seamLocation = SEAM_HOME_PROPERTY;
- assertTrue("Invalid Seam Runtime location:" + seamLocation, new
File(seamLocation).isDirectory());
- }
-
- @Test
- public void testErrors() throws Exception {
- checkErrors(PROJECT_NAME);
- checkErrors(EAR_PROJECT_NAME);
- checkErrors(EJB_PROJECT_NAME);
- checkErrors(TEST_PROJECT_NAME);
- checkErrors(PARENT_PROJECT_NAME);
- checkErrors(PROJECT_NAME_WAR);
- checkErrors(TEST_PROJECT_NAME_WAR);
- checkErrors(PARENT_PROJECT_NAME_WAR);
- }
-
- private void checkErrors(String projectName) throws CoreException {
- waitForIdle();
- List<IMarker> markers = new ArrayList<IMarker>();
- IProject project = ResourcesPlugin.getWorkspace().getRoot()
- .getProject(projectName);
- IMarker[] projectMarkers = project.findMarkers(IMarker.PROBLEM, true,
- IResource.DEPTH_INFINITE);
- for (int i = 0; i < projectMarkers.length; i++) {
- if (projectMarkers[i].getAttribute(IMarker.SEVERITY,
- IMarker.SEVERITY_ERROR) == IMarker.SEVERITY_ERROR) {
- if
(!"org.eclipse.m2e.core.maven2Problem.lifecycleMapping".equals(projectMarkers[i].getType()))
{
- markers.add(projectMarkers[i]);
- }
- }
- }
- assertTrue("The '" + projectName + "' contains errors.",
markers.size() == 0);
- }
-
- @Test
- public void testMavenProjects() throws Exception {
- isMavenProject(PROJECT_NAME);
- isMavenProject(EAR_PROJECT_NAME);
- isMavenProject(EJB_PROJECT_NAME);
- isMavenProject(TEST_PROJECT_NAME);
- isMavenProject(PARENT_PROJECT_NAME);
- isMavenProject(PROJECT_NAME_WAR);
- isMavenProject(TEST_PROJECT_NAME_WAR);
- isMavenProject(PARENT_PROJECT_NAME_WAR);
- }
-
- private void isMavenProject(String projectName) throws CoreException {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- assertTrue("The '" + projectName + "' project isn't a Maven
project.", project.hasNature(IMavenConstants.NATURE_ID));
- }
-
- // see
https://jira.jboss.org/browse/JBIDE-6587
- @Test
- public void testMavenWarArchive() throws Exception {
- final SWTBotView packageExplorer = bot.viewByTitle("Package Explorer");
- SWTBot innerBot = packageExplorer.bot();
- innerBot.activeShell().activate();
- SWTBotTree tree = innerBot.tree();
- final SWTBotTreeItem warProjectItem = tree.getTreeItem(PROJECT_NAME_WAR);
- warProjectItem.select();
-
- SWTBotMenu runAs = tree.contextMenu("Run As");
- runAs.menu("5 Maven build...").click();
- waitForIdle();
- SWTBotShell shell = bot.shell("Edit Configuration");
- shell.activate();
- SWTBot b = shell.bot();
- b.textWithLabel("Goals:").setText("clean package");
- b.button("Run").click();
- waitForIdle();
-
- IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME_WAR);
- project.getFolder("target").refreshLocal(IResource.DEPTH_INFINITE, new
NullProgressMonitor());
-
- IFolder warFolder = project.getFolder("target/" + PROJECT_NAME_WAR +
"-0.0.1-SNAPSHOT");
-
- assertTrue(warFolder +" is missing ", warFolder.exists());
-
- IPath webInfPath = new Path("WEB-INF");
- assertFalse(warFolder.getFolder(webInfPath.append("src")).exists());
- assertFalse(warFolder.getFolder(webInfPath.append("dev")).exists());
- assertTrue(warFolder.getFolder(webInfPath.append("lib")).exists());
-
- }
-
- private static void waitForIdle() {
- AbstractMavenSWTBotTest.waitForIdle();
- }
-
- public static void delay(long waitTimeMillis) {
- Display display = Display.getCurrent();
- if (display != null) {
- long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
- while (System.currentTimeMillis() < endTimeMillis) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.update();
- }
- // Otherwise, perform a simple sleep.
- else {
- try {
- Thread.sleep(waitTimeMillis);
- } catch (InterruptedException e) {
- // Ignored.
- }
- }
- }
-
-
- // see
https://jira.jboss.org/browse/JBIDE-6767
- @Test
- public void testLibraries() throws Exception {
- IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(EAR_PROJECT_NAME);
- File rootDirectory = new File(project.getLocation().toOSString(),
"EarContent");
- String[] libs = rootDirectory.list(new FilenameFilter() {
-
- public boolean accept(File dir, String name) {
- if (name.endsWith(".jar")) {
- return true;
- }
- return false;
- }
- });
- assertTrue(libs.length == 0);
- File libDirectory = new File (rootDirectory,"lib");
- if (libDirectory.isDirectory()) {
- libs = libDirectory.list(new FilenameFilter() {
-
- public boolean accept(File dir, String name) {
- if (name.endsWith(".jar")) {
- return true;
- }
- return false;
- }
- });
- assertTrue(libs.length == 0);
- }
- }
-
-}
+}
\ No newline at end of file
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JBossPerspectiveTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JBossPerspectiveTest.java 2012-08-04
01:24:50 UTC (rev 42855)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JBossPerspectiveTest.java 2012-08-06
07:53:29 UTC (rev 42856)
@@ -10,9 +10,6 @@
******************************************************************************/
package org.jboss.tools.maven.ui.bot.test;
-import junit.framework.TestCase;
-
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
@@ -26,7 +23,7 @@
*
*/
@RunWith(SWTBotJunit4ClassRunner.class)
-public class JBossPerspectiveTest extends TestCase {
+public class JBossPerspectiveTest extends AbstractMavenSWTBotTest {
/**
* Tests JBoss perspective has Maven stuff
@@ -34,8 +31,6 @@
*/
@Test
public void testJBossPerspective() throws WorkbenchException {
- SWTWorkbenchBot bot = new SWTWorkbenchBot();
- bot.viewByTitle("Welcome").close();
bot.menu("Window").menu("Open
Perspective").menu("Other...").click();
SWTBotShell shell = bot.shell("Open Perspective");
shell.activate();
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MaterializeLibraryTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MaterializeLibraryTest.java 2012-08-04
01:24:50 UTC (rev 42855)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MaterializeLibraryTest.java 2012-08-06
07:53:29 UTC (rev 42856)
@@ -3,15 +3,17 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.bindings.keys.KeyStroke;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.hamcrest.Matcher;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
import org.jboss.tools.ui.bot.ext.SWTUtilExt;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
-import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -20,8 +22,7 @@
private String projectName = "example";
- private SWTBotExt botExt = new SWTBotExt();
- private SWTUtilExt botUtil = new SWTUtilExt(botExt);
+ private SWTUtilExt botUtil= new SWTUtilExt(bot);
@BeforeClass
public static void setup(){
@@ -29,41 +30,30 @@
setup.menu("Window").menu("Show
View").menu("Other...").click();
setup.tree().expandNode("Java").select("Package
Explorer").click();
setup.button("OK").click();
+ setup.menu("Window").menu("Preferences").click();
+ setup.waitForShell("Preferences");
+ setup.tree().expandNode("JBoss Tools").select("Project Examples");
+ setup.checkBox("Show Project Ready wizard").deselect();
+ setup.checkBox("Show readme/cheatsheet file").deselect();
+ setup.button("OK").click();
}
+ @SuppressWarnings("restriction")
@Test
public void testMaterializeLibrary() throws Exception{
- botExt.menu("New").menu("Example...").click();
- botExt.tree().expandNode("JBoss Tools").select("Project
Examples");
+ bot.menu("New").menu("Example...").click();
+ bot.tree().expandNode("JBoss Tools").select("Project Examples");
waitForIdle();
- botExt.button("Next >").click();
- waitForIdle();
- while(!botUtil.isShellActive("New Project Example")){
- Thread.sleep(500);
- }
- botExt.tree().expandNode("JBoss Maven Archetypes").select("Spring MVC
Project");
- botExt.button("Next >").click();
- botExt.button("Next >").click();
- botExt.button("Next >").click();
- botExt.comboBoxWithLabel("Group Id:").setText(projectName);
- botExt.comboBoxWithLabel("Artifact Id:").setText(projectName);
- botExt.button("Finish").click();
-
-
-
- /* old wizard
- botExt.button("Finish").click();
- while(!botUtil.isShellActive("New JBoss Project")){
- Thread.sleep(500);
- }
- botExt.comboBoxWithLabel("Project name").setText(projectName);
- botExt.comboBoxWithLabel("Package").setText(projectName);
- botExt.button("Next >").click();
- botExt.button("Finish").click();
- */
- botUtil.waitForNonIgnoredJobs();
- Thread.sleep(5000);
- botExt.activeShell().bot().button("Finish").click();
+ bot.button("Next >").click();
+ waitForShell(botUtil, "New Project Example");
+ bot.tree().expandNode("JBoss Maven Archetypes").select("Spring MVC
Project");
+ bot.button("Next >").click();
+ bot.button("Next >").click();
+ bot.comboBoxWithLabel("Project name").setText(projectName);
+ bot.comboBoxWithLabel("Package").setText(projectName);
+ bot.button("Finish").click();
+ botUtil.waitForAll(Long.MAX_VALUE);
+
final SWTBotView packageExplorer = bot.viewByTitle("Package Explorer");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
SWTBotTree tree = packageExplorer.bot().tree();
@@ -72,21 +62,23 @@
item.select().pressShortcut(Keystrokes.SHIFT,Keystrokes.F10);
KeyStroke k = KeyStroke.getInstance("M");
item.pressShortcut(k);
+ waitForShell(botUtil, "Materialize Classpath Library");
+ bot.button("OK").click();
+ Thread.sleep(1000);
+ bot.activeShell().activate();
+ bot.button("OK").click();
waitForIdle();
- botExt.button("OK").click();
- Thread.sleep(500);
- botExt.button("OK").click();
- waitForIdle();
- assertFalse(project.getName()+" is still a maven
project!",Utils.isMavenProject(project.getName()));
+ assertFalse(project.getName()+" is still a maven
project!",isMavenProject(project.getName()));
testExcludedResources(project);
+ assertNoErrors(project);
}
private void testExcludedResources(IProject project) throws Exception{
final SWTBotView packageExplorer = bot.viewByTitle("Package Explorer");
packageExplorer.bot().tree().getTreeItem(project.getName()).select().pressShortcut(Keystrokes.ALT,Keystrokes.LF);
- botExt.tree().select("Java Build Path");
- botExt.tabItem("Source").activate();
- for(SWTBotTreeItem item: botExt.tree(1).getAllItems()){
+ bot.tree().select("Java Build Path");
+ bot.tabItem("Source").activate();
+ for(SWTBotTreeItem item: bot.tree(1).getAllItems()){
for(SWTBotTreeItem itemToCheck: item.getItems()){
if(itemToCheck.getText().startsWith("Included")){
assertTrue("(All) expected in Included
patterns",itemToCheck.getText().endsWith("(All)"));
@@ -95,6 +87,7 @@
}
}
}
+ bot.button("OK").click();
}
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenAllBotTests.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenAllBotTests.java 2012-08-04
01:24:50 UTC (rev 42855)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenAllBotTests.java 2012-08-06
07:53:29 UTC (rev 42856)
@@ -21,13 +21,14 @@
*/
@RunWith(RequirementAwareSuite.class)
@Suite.SuiteClasses({
- CreateMavenizedSeamProjectTest.class,
- CreateMavenizedEARProjectTest.class,
- CreateMavenizedJSFProjectTest.class,
- //MavenProfileSelectionTest.class, //failures
- MaterializeLibraryTest.class,
- CreateMavenProjectsTest.class,
- ConfiguratorsTest.class
+ CreateMavenizedSeamProjectTest.class, //OK
+ CreateMavenizedEARProjectTest.class, //OK
+ CreateMavenizedJSFProjectTest.class, //OK
+ MavenProfileSelectionTest.class, //OK
+ MaterializeLibraryTest.class, //OK
+ ConfiguratorsTest.class, //OK
+ CreateMavenProjectsTest.class, //OK but, bad jsf archetype
+ JBossPerspectiveTest.class
})
public class MavenAllBotTests {
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfileSelectionTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfileSelectionTest.java 2012-08-04
01:24:50 UTC (rev 42855)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfileSelectionTest.java 2012-08-06
07:53:29 UTC (rev 42856)
@@ -6,22 +6,28 @@
import java.util.HashSet;
import java.util.Set;
-import org.apache.maven.model.Profile;
+import org.codehaus.plexus.util.FileUtils;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.bindings.keys.ParseException;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.m2e.tests.common.JobHelpers;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,104 +38,87 @@
public class MavenProfileSelectionTest extends AbstractMavenSWTBotTest {
public static final String AUTOACTIVATED_PROFILE_IN_POM = "active-profile";
- public static final String AUTOACTIVATED_PROFILE_IN_USER_SETTINGS =
"profile.from.settings.xml";
- public static final String COMMON_PROFILE = "common-profile";
+ public static final String[] AUTOACTIVATED_PROFILES_IN_USER_SETTINGS =
{"profile.from.settings.xml", "jboss"};
+ public static final String[] COMMON_PROFILES = {"common-profile"};
+ public static final String[] ALL_PROFILES = {"inactive-profile",
"common-profile", "active-profile"};
+ private SWTUtilExt botUtil= new SWTUtilExt(bot);
+
@BeforeClass
- public static void setup(){
+ public static void setup() {
SWTBotExt setup = new SWTBotExt();
setup.menu("Window").menu("Show View").menu("Package
Explorer").click();
}
+ @After
+ public void after() throws InterruptedException, CoreException, IOException{
+ doCleanWorkspace();
+ }
+
@Test
- public void testOpenMavenProfiles() throws Exception {
- setUserSettings();
- IProject project = importProject("projects/simple-jar/pom.xml");
+ public void testOpenMavenProfiles() throws IOException, InterruptedException,
CoreException, ParseException{
+ importMavenProject("projects/simple-jar/pom.xml");
+ IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject("simple-jar");
waitForJobsToComplete();
testAutoActivatedProfiles();
- bot.menu("Window").menu("Show View").menu("Project
Explorer").click();
- final SWTBotView packageExplorer = bot.viewByTitle("Project Explorer");
- SWTBot innerBot = packageExplorer.bot();
- innerBot.activeShell().activate();
- SWTBotTree tree = innerBot.tree();
- SWTBotTreeItem projectItem = tree.getTreeItem(project.getName());
- projectItem.select();
- openProfilesDialog(projectItem);
- Thread.sleep(2000);
- //activate all profiles
- SWTBot shell = bot.shell("Select Maven profiles").activate().bot();
- shell.button("Select All").click();
- String selectedProfiles = shell.textWithLabel("Active profiles for simple-jar
:").getText();
- shell.button("OK").click();
-
- testActivatedProfiles(project.getName(), selectedProfiles, false);
- Thread.sleep(1000);
- openProfilesDialog(projectItem);
+ bot.viewByTitle("Package
Explorer").bot().tree().select("simple-jar").pressShortcut(Keystrokes.CTRL,
Keystrokes.ALT,KeyStroke.getInstance("P"));
+ waitForShell(botUtil,"Select Maven profiles");
+
+ //activate all profiles
+ bot.button("Select All").click();
+ bot.button("OK").click();
+ waitForIdle();
+ testActivatedProfiles(project.getName(), ALL_PROFILES);
+ bot.viewByTitle("Package
Explorer").bot().tree().select("simple-jar").pressShortcut(Keystrokes.CTRL,
Keystrokes.ALT,KeyStroke.getInstance("P"));
+
//disable all profiles
- shell = bot.shell("Select Maven profiles").activate().bot();
- shell.button("Deselect all").click();
- selectedProfiles = bot.textWithLabel("Active profiles for simple-jar
:").getText();
+ waitForShell(botUtil,"Select Maven profiles");
+ bot.button("Deselect all").click();
bot.button("OK").click();
-
- testActivatedProfiles(project.getName(), selectedProfiles, true);
+ waitForIdle();
+ testActivatedProfiles(project.getName(), null);
}
- @Test
- public void testOpenMultipleMavenProfiles() throws Exception{
- IProject project = importProject("projects/simple-jar/pom.xml");
- IProject project1 = importProject("projects/simple-jar1/pom.xml");
- IProject project2 = importProject("projects/simple-jar2/pom.xml");
+ //@Test
+ public void testOpenMultipleMavenProfiles() throws IOException, InterruptedException,
CoreException, ParseException{
+ importMavenProject("projects/simple-jar/pom.xml");
+ importMavenProject("projects/simple-jar1/pom.xml");
+ importMavenProject("projects/simple-jar2/pom.xml");
+ IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject("simple-jar");
+ IProject project1 =
ResourcesPlugin.getWorkspace().getRoot().getProject("simple-jar1");
+ IProject project2 =
ResourcesPlugin.getWorkspace().getRoot().getProject("simple-jar2");
waitForJobsToComplete();
- final SWTBotView packageExplorer = bot.viewByTitle("Project Explorer");
- SWTBot innerBot = packageExplorer.bot();
- innerBot.activeShell().activate();
- SWTBotTree tree = innerBot.tree();
- tree.select("simple-jar","simple-jar1","simple-jar2").pressShortcut(Keystrokes.CTRL,
Keystrokes.ALT,KeyStroke.getInstance("P"));
+ bot.viewByTitle("Package
Explorer").bot().tree().select("simple-jar","simple-jar1","simple-jar2").pressShortcut(Keystrokes.CTRL,
Keystrokes.ALT,KeyStroke.getInstance("P"));
SWTBot shell = bot.shell("Select Maven profiles").activate().bot();
shell.button("Select All").click();
shell.button("Activate").click();
shell.button("OK").click();
- testActivatedProfiles(project.getName(), COMMON_PROFILE+",
"+AUTOACTIVATED_PROFILE_IN_USER_SETTINGS, false);
- testActivatedProfiles(project1.getName(), COMMON_PROFILE+",
"+AUTOACTIVATED_PROFILE_IN_USER_SETTINGS, false);
- testActivatedProfiles(project2.getName(), COMMON_PROFILE+",
"+AUTOACTIVATED_PROFILE_IN_USER_SETTINGS, false);
+ waitForIdle();
+ testActivatedProfiles(project.getName(), COMMON_PROFILES);
+ testActivatedProfiles(project1.getName(), COMMON_PROFILES);
+ testActivatedProfiles(project2.getName(), COMMON_PROFILES);
}
- private void setUserSettings() throws InterruptedException, IOException, CoreException{
- SWTBotExt botExt = new SWTBotExt();
- botExt.menu("Window").menu("Preferences").click();
- botExt.tree().expandNode("Maven").select("User Settings").click();
- File f = new File("usersettings/settings.xml");
- botExt.text(1).setText(f.getAbsolutePath());
- botExt.button("OK").click();
- }
-
- private void openProfilesDialog(SWTBotTreeItem projectItem) throws ParseException,
InterruptedException{
+ private void openProfilesDialog(SWTBotTreeItem projectItem) throws ParseException{
projectItem.pressShortcut(Keystrokes.CTRL,
Keystrokes.ALT,KeyStroke.getInstance("P"));
- //projectItem.pressShortcut(Keystrokes.DOWN);
- //projectItem.pressShortcut(Keystrokes.LF);
final SWTBotShell selectDialogShell = bot.shell("Select Maven profiles");
assertEquals("Select Maven profiles", selectDialogShell.getText());
- Thread.sleep(1000);
}
- private void testActivatedProfiles(String projectName, String expectedProfiles, boolean
defaultProfile){
- String[] parsedexpectedProfiles = expectedProfiles.split(", ");
- String empty = "";
+ private void testActivatedProfiles(String projectName, String[] expectedProfiles) {
Set<String> setOfExpectedProfiles = new HashSet<String>();
- Collections.addAll(setOfExpectedProfiles, parsedexpectedProfiles);
- setOfExpectedProfiles.add(AUTOACTIVATED_PROFILE_IN_USER_SETTINGS);
- if(defaultProfile){
- setOfExpectedProfiles.add(AUTOACTIVATED_PROFILE_IN_POM);
+ if(expectedProfiles != null){
+ Collections.addAll(setOfExpectedProfiles, expectedProfiles);
+ for(String act: AUTOACTIVATED_PROFILES_IN_USER_SETTINGS){
+ setOfExpectedProfiles.add(act);
+ }
}
- setOfExpectedProfiles.remove(empty);
-
IMavenProjectFacade facade =
MavenPlugin.getMavenProjectRegistry().getMavenProject("org.jboss.tools.maven.tests",
projectName, "1.0.0-SNAPSHOT");
assertNotNull("facade is null",facade);
Set<String> setOfProfilesFacade = new HashSet<String>();
- for(Profile profile : facade.getMavenProject().getActiveProfiles()){
- setOfProfilesFacade.add(profile.getId());
- }
+
setOfProfilesFacade.addAll(MavenPlugin.getProjectConfigurationManager().getResolverConfiguration(facade.getProject()).getActiveProfileList());
+ setOfProfilesFacade.remove("");
assertEquals("Selected profiles in project " +projectName+ "
doesn't match", setOfExpectedProfiles, setOfProfilesFacade);
}
@@ -137,6 +126,51 @@
IMavenProjectFacade facade =
MavenPlugin.getMavenProjectRegistry().getMavenProject("org.jboss.tools.maven.tests",
"simple-jar", "1.0.0-SNAPSHOT");
assertNotNull("facade is null",facade);
assertEquals("Auto Activated profiles from pom.xml doesn't match",
AUTOACTIVATED_PROFILE_IN_POM,
facade.getMavenProject().getActiveProfiles().get(0).getId());
- assertEquals("Auto Activated profiles from settings.xml doesn't
match", AUTOACTIVATED_PROFILE_IN_USER_SETTINGS,
facade.getMavenProject().getActiveProfiles().get(1).getId());
+ assertEquals("Auto Activated profiles from settings.xml doesn't
match", AUTOACTIVATED_PROFILES_IN_USER_SETTINGS[0],
facade.getMavenProject().getActiveProfiles().get(1).getId());
+ assertEquals("Auto Activated profiles from settings.xml doesn't
match", AUTOACTIVATED_PROFILES_IN_USER_SETTINGS[1],
facade.getMavenProject().getActiveProfiles().get(2).getId());
}
+
+ private void importMavenProject(String pomPath) throws IOException,
InterruptedException{
+ bot.menu("File").menu("Import...").click();
+ waitForShell(botUtil, "Import");
+ bot.tree().expandNode("Maven").select("Existing Maven
Projects").click();
+ bot.button("Next >").click();
+ waitForShell(botUtil, "Import Maven Projects");
+ bot.comboBoxWithLabel("Root Directory:").setText((new
File(pomPath)).getParentFile().getCanonicalPath());
+ bot.button("Refresh").click();
+ waitForShell(botUtil, "Import Maven Projects");
+ Thread.sleep(5000);
+ bot.button("Finish").click();
+ botUtil.waitForAll();
+ }
+
+
+ private static void doCleanWorkspace() throws InterruptedException, CoreException,
IOException {
+ final IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ workspace.run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ IProject[] projects = workspace.getRoot().getProjects();
+ for(int i = 0; i < projects.length; i++ ) {
+ projects[i].delete(false, false, monitor);
+ }
+ }
+ }, new NullProgressMonitor());
+
+ JobHelpers.waitForJobsToComplete(new NullProgressMonitor());
+
+ File[] files = workspace.getRoot().getLocation().toFile().listFiles();
+ if(files != null) {
+ for(File file : files) {
+ if(!".metadata".equals(file.getName())) {
+ if(file.isDirectory()) {
+ FileUtils.deleteDirectory(file);
+ } else {
+ if(!file.delete()) {
+ throw new IOException("Could not delete file " +
file.getCanonicalPath());
+ }
+ }
+ }
+ }
+ }
+ }
}
Deleted:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Utils.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Utils.java 2012-08-04
01:24:50 UTC (rev 42855)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Utils.java 2012-08-06
07:53:29 UTC (rev 42856)
@@ -1,35 +0,0 @@
-package org.jboss.tools.maven.ui.bot.test;
-
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.m2e.core.internal.IMavenConstants;
-import org.jboss.tools.ui.bot.ext.SWTUtilExt;
-
-@SuppressWarnings("restriction")
-public class Utils {
-
-
- public static boolean isMavenProject(String projectName) throws CoreException {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- return project.hasNature(IMavenConstants.NATURE_ID);
- }
-
- public static boolean hasNature(String projectName, String natureID) throws
CoreException {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- return project.hasNature(natureID);
- }
-
- public static void waitForIdle() throws InterruptedException {
- AbstractMavenSWTBotTest.waitForIdle();
- }
-
- public static void waitForShell(SWTUtilExt util, String shellName) throws
InterruptedException {
- Thread.sleep(1000);
- while(!util.isShellActive(shellName)){
- Thread.sleep(500);
- }
- }
-
-}
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/utils/ProjectHasNature.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/utils/ProjectHasNature.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/utils/ProjectHasNature.java 2012-08-06
07:53:29 UTC (rev 42856)
@@ -0,0 +1,26 @@
+package org.jboss.tools.maven.ui.bot.test.utils;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
+
+public class ProjectHasNature extends DefaultCondition{
+
+ private IProject project;
+ private String natureID;
+
+ public ProjectHasNature(String projectName, String natureID){
+ this.project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ this.natureID=natureID;
+
+ }
+
+ public boolean test() throws Exception {
+ return project.hasNature(natureID);
+ }
+
+ public String getFailureMessage() {
+ return "Project "+project+" doesn't not have nature
"+natureID;
+ }
+
+}
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/utils/TableHasRows.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/utils/TableHasRows.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/utils/TableHasRows.java 2012-08-06
07:53:29 UTC (rev 42856)
@@ -0,0 +1,25 @@
+package org.jboss.tools.maven.ui.bot.test.utils;
+
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+
+public class TableHasRows extends DefaultCondition {
+ private final String projectType;
+ private final SWTBotTable table;
+
+ // initialize
+ public TableHasRows(SWTBotTable table, String projectType) {
+ this.table = table;
+ this.projectType = projectType;
+ }
+
+ // return true if the condition matches, false otherwise
+ public boolean test() {
+ return table.indexOf(projectType, "Artifact Id")!=-1;
+ }
+
+ // provide a human readable error message
+ public String getFailureMessage() {
+ return "Timed out waiting for " + table + " to contain rows.";
+ }
+ }
\ No newline at end of file
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/usersettings/settings.xml
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/usersettings/settings.xml 2012-08-04
01:24:50 UTC (rev 42855)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/usersettings/settings.xml 2012-08-06
07:53:29 UTC (rev 42856)
@@ -2,10 +2,48 @@
<settings>
<profiles>
<profile>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
<id>profile.from.settings.xml</id>
</profile>
+ <profile>
+ <id>jboss</id>
+ <repositories>
+ <repository>
+ <id>jboss</id>
+ <name>jboss</name>
+ <
url>https://repository.jboss.org/nexus/content/repositories/releases/
+ </url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>jboss</id>
+ <name>jboss</name>
+ <
url>https://repository.jboss.org/nexus/content/repositories/releases/
+ </url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
</profiles>
+ <activeProfiles>
+ <activeProfile>profile.from.settings.xml</activeProfile>
+ <activeProfile>jboss</activeProfile>
+ </activeProfiles>
</settings>
\ No newline at end of file