Author: rawagner
Date: 2012-08-30 04:43:37 -0400 (Thu, 30 Aug 2012)
New Revision: 43316
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/AbstractConfiguratorsTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/ArchetypesTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CDIConfiguratorTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/EARProjectTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JAXRSConfiguratorTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JPAConfiguratorTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JSFConfiguratorTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JSFProjectTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfilesTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/SeamConfiguratorTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/SeamProjectTest.java
Removed:
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/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
Modified:
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/.classpath
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/.classpath
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/CreateMavenProjectsTest.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
Log:
bot tests updated for juno
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-30 07:57:46 UTC
(rev 43315)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/pom.xml 2012-08-30 08:43:37 UTC
(rev 43316)
@@ -12,9 +12,9 @@
<packaging>eclipse-test-plugin</packaging>
- <properties>
- <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>
+ <properties>
+ <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>
<plugin>
@@ -80,9 +80,6 @@
<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>
@@ -185,11 +182,21 @@
</dependency>
<dependency>
<type>p2-installable-unit</type>
+ <artifactId>org.jboss.tools.maven.jpa.feature.feature.group</artifactId>
+ <version>0.0.0</version>
+ </dependency>
+ <dependency>
+ <type>p2-installable-unit</type>
<artifactId>org.jboss.tools.maven.jsf.feature.feature.group</artifactId>
<version>0.0.0</version>
</dependency>
<dependency>
<type>p2-installable-unit</type>
+ <artifactId>org.jboss.tools.maven.hibernate.feature.feature.group</artifactId>
+ <version>0.0.0</version>
+ </dependency>
+ <dependency>
+ <type>p2-installable-unit</type>
<artifactId>org.jboss.tools.maven.portlet.feature.feature.group</artifactId>
<version>0.0.0</version>
</dependency>
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar1/.classpath
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar1/.classpath 2012-08-30
07:57:46 UTC (rev 43315)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar1/.classpath 2012-08-30
08:43:37 UTC (rev 43316)
@@ -1,6 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con"
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="src" output="target/classes"
path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes"
path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
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-30
07:57:46 UTC (rev 43315)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar1/.settings/org.eclipse.m2e.core.prefs 2012-08-30
08:43:37 UTC (rev 43316)
@@ -1,4 +1,4 @@
-activeProfiles=common-profile, jboss, profile.from.settings.xml
+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/projects/simple-jar2/.classpath
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar2/.classpath 2012-08-30
07:57:46 UTC (rev 43315)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/projects/simple-jar2/.classpath 2012-08-30
08:43:37 UTC (rev 43316)
@@ -1,6 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con"
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="src" output="target/classes"
path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes"
path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/AbstractConfiguratorsTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/AbstractConfiguratorsTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/AbstractConfiguratorsTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -0,0 +1,241 @@
+package org.jboss.tools.maven.ui.bot.test;
+
+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.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.m2e.tests.common.WorkspaceHelpers;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+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.Before;
+import org.junit.BeforeClass;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+@Require(perspective="Java EE")
+public abstract class AbstractConfiguratorsTest extends AbstractMavenSWTBotTest{
+
+ public static final String PROJECT_NAME_JSF="testWEB_JSF";
+ public static final String PROJECT_NAME_JAXRS="testWEB_JAXRS";
+ public static final String PROJECT_NAME_CDI="testWEB_CDI";
+ public static final String PROJECT_NAME_CDI_EJB="testEJB_CDI";
+ public static final String PROJECT_NAME_SEAM="testWEB_SEAM";
+ public static final String PROJECT_NAME_JPA="testWEB_JPA";
+ 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
SEAM_NATURE="org.jboss.tools.seam.core.seamnature";
+ public static final String
JPA_NATURE="org.hibernate.eclipse.console.hibernateNature";
+
+ 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");
+//jpa config, gwt, hibernate
+
+ 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();
+ }
+
+ @Before
+ public void clean() throws InterruptedException, CoreException{
+ WorkspaceHelpers.cleanWorkspace();
+ bot.sleep(1000);
+ }
+
+ public void addPersistence(String projectName) throws ParserConfigurationException,
SAXException, IOException, CoreException, TransformerException, InterruptedException {
+ SWTBotTree innerBot = bot.viewByTitle("Package
Explorer").bot().tree().select(projectName);
+ ContextMenuHelper.clickContextMenu(innerBot, "New","Other...");
+ bot.tree().expandNode("XML").select("XML File");
+ bot.button("Next >").click();
+ bot.textWithLabel("Enter or select the parent
folder:").setText(projectName+"/src/META-INF");
+ bot.textWithLabel("File name:").setText("persistence.xml");
+ bot.button("Finish").click();
+ waitForIdle();
+ bot.sleep(1000);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ Document docPer = docBuilder.newDocument();
+
+ Element persistenceElement = docPer.createElement("persistence");
+ persistenceElement.setAttribute("version","2.0");
+ persistenceElement.setAttribute("xmlns",
"http://java.sun.com/xml/ns/persistence");
+
persistenceElement.setAttribute("xmlns:xsi","http://www.w3...;
+ persistenceElement.setAttribute("xsi:schemaLocation",
"http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd");
+
+
+ Element persistenceUnitElement =
docPer.createElement("persistence-unit");
+ persistenceUnitElement.setAttribute("name","primary");
+ persistenceUnitElement.setAttribute("transaction-type","JTA");
+
+ persistenceElement.appendChild(persistenceUnitElement);
+ docPer.appendChild(persistenceElement);
+ TransformerFactory transfac = TransformerFactory.newInstance();
+ Transformer trans = transfac.newTransformer();
+ StringWriter xmlAsWriter = new StringWriter();
+ StreamResult result = new StreamResult(xmlAsWriter);
+ DOMSource source = new DOMSource(docPer);
+ trans.transform(source, result);
+ project.getProject().getFolder("src").getFolder("META-INF").getFile("persistence.xml").setContents(new
ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")), 0, null);
+
+ waitForIdle();
+ }
+
+ public void createMavenizedDynamicWebProject(String projectName, boolean runtime) throws
Exception{
+ bot.menu("File").menu("New").menu("Other...").click();
+ bot.waitForShell("New");
+ bot.tree().expandNode("Web").select("Dynamic Web Project");
+ bot.button("Next >").click();
+ bot.waitForShell("New Dynamic Web Project");
+ bot.textWithLabel("Project name:").setText(projectName);
+ if(runtime){
+ 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 {
+ bot.comboBoxInGroup("Target
runtime").setSelection("<None>");
+ }
+ bot.sleep(1000);
+ 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);
+ waitForIdle();
+ SWTBotTree item = bot.viewByTitle("Package
Explorer").bot().tree().select(projectName);
+ ContextMenuHelper.clickContextMenu(item, "Properties");
+ 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);
+ bot.hyperlink("Further configuration required...").click();
+ bot.button("OK").click();
+ bot.button("OK").click();
+ botUtil.waitForAll();
+ 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.",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.",hasNature(projectName, JSF_NATURE));
+ assertFalse("Project "+projectName+" has "+JAXRS_NATURE+"
nature.",hasNature(projectName, JAXRS_NATURE));
+ }
+ }
+
+ public void createMavenizedEJBProject(String projectName, boolean runtime)throws
Exception{
+ bot.sleep(10000);
+ bot.menu("File").menu("New").menu("Other...").click();
+ bot.waitForShell("New");
+ bot.tree().expandNode("EJB").select("EJB Project");
+ bot.button("Next >").click();
+ bot.waitForShell("New EJB Project");
+ bot.textWithLabel("Project name:").setText(projectName);
+ if(runtime){
+ 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 {
+ bot.comboBoxInGroup("Target
runtime").setSelection("<None>");
+ }
+ waitForShell(botUtil,"New EJB Project");
+ bot.button("Finish").click();
+ botUtil.waitForAll(Long.MAX_VALUE);
+ waitForIdle();
+ SWTBotTree item = bot.viewByTitle("Package
Explorer").bot().tree().select(projectName);
+ ContextMenuHelper.clickContextMenu(item, "Properties");
+ waitForShell(botUtil,"Properties for "+projectName);
+ bot.tree().select("Project Facets");
+ bot.tree(1).getTreeItem("JBoss Maven Integration").check();
+ botUtil.waitForAll();
+ Thread.sleep(500);
+ 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 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));
+
+ }
+
+ public void addFacesConf(String projectName) throws InterruptedException{
+ SWTBotTree innerBot = bot.viewByTitle("Package
Explorer").bot().tree().select(projectName);
+ ContextMenuHelper.clickContextMenu(innerBot, "New","Other...");
+ 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);
+ }
+
+ public void addServlet(String projectName, String servletName, String servletClass,
String load) throws Exception{
+ IProject facade = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ 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");
+ Element loadElement = docPom.createElement("load-on-startup");
+
+ servletNameElement.setTextContent(servletName);
+ servletClassElement.setTextContent(servletClass);
+ loadElement.setTextContent(load);
+
+ Element root = docPom.getDocumentElement();
+ servletElement.appendChild(servletNameElement);
+ servletElement.appendChild(servletClassElement);
+ servletElement.appendChild(loadElement);
+ root.appendChild(servletElement);
+ 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);
+ facade.getProject().getFile(WEB_XML_LOCATION).setContents(new
ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")), 0, null);
+ botUtil.waitForAll();
+ updateConf(botUtil,projectName);
+ }
+}
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-30
07:57:46 UTC (rev 43315)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/AbstractMavenSWTBotTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -22,15 +22,22 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.eclipse.core.resources.IFile;
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.NullProgressMonitor;
+import org.eclipse.jface.bindings.keys.KeyStroke;
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.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.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.internal.IPreferenceConstants;
@@ -42,14 +49,13 @@
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.parts.SWTBotRadioExt;
import org.jboss.tools.ui.bot.ext.view.ErrorLogView;
-import org.junit.AfterClass;
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 {
@@ -62,15 +68,14 @@
@BeforeClass
public static void beforeClass() throws Exception {
- setUserSettings();
+ setUserSettingsAndPerspective();
WorkbenchPlugin.getDefault().getPreferenceStore()
.setValue(IPreferenceConstants.RUN_IN_BACKGROUND, true);
PrefUtil.getAPIPreferenceStore().setValue(
IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS, false);
- setUserSettings();
}
-
+
//@AfterClass
public final static void cleanUp() throws Exception {
boolean buildAutomatically = ResourcesUtils.setBuildAutomatically(false);
@@ -159,13 +164,16 @@
botUtil.waitForNonIgnoredJobs();
}
- private static void setUserSettings() throws InterruptedException, IOException,
CoreException{
+ private static void setUserSettingsAndPerspective() 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.tree().expandNode("General").select("Perspectives").click();
+ SWTBotRadioExt radio = new SWTBotRadioExt(botExt.radio("Never
open").widget);
+ radio.clickWithoutDeselectionEvent();
botExt.button("OK").click();
}
@@ -182,4 +190,24 @@
}
}
+ public void buildProject(String projectName, String mavenBuild, String packaging, String
version) throws Exception {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ bot.viewByTitle("Package Explorer").setFocus();
+ SWTBot explorer = bot.viewByTitle("Package Explorer").bot();
+ bot.sleep(500);
+ SWTBotTreeItem item = explorer.tree().getTreeItem(projectName).select();
+ SWTBotExt swtBot = new SWTBotExt();
+ item.pressShortcut(Keystrokes.SHIFT,Keystrokes.ALT,KeyStroke.getInstance("X"));
+ bot.sleep(1000);
+ item.pressShortcut(KeyStroke.getInstance("M"));
+ swtBot.waitForShell("Edit Configuration");
+ swtBot.textWithLabel("Goals:").setText("clean package");
+ swtBot.button("Run").click();
+ waitForIdle();
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ project.getFolder("target").refreshLocal(IResource.DEPTH_INFINITE,new
NullProgressMonitor());
+ IFile jarFile = project.getFile("target/" + projectName +
version+"."+packaging);
+ assertTrue(jarFile + " is missing ", jarFile.exists());
+ }
+
}
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/ArchetypesTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/ArchetypesTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/ArchetypesTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -0,0 +1,99 @@
+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.swtbot.swt.finder.SWTBot;
+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;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@Require(perspective="Java")
+public class ArchetypesTest extends AbstractMavenSWTBotTest{
+
+ public static final String REPO_URL = "http://repo1.maven.org/maven2";
+ public static final String NEXUS_URL =
"https://repository.jboss.org/nexus/content/repositories/releases/";
+
+ @BeforeClass
+ public static void setup() throws InterruptedException, CoreException{
+ 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();
+ updateRepositories();
+
+ }
+
+ public static void updateRepositories() throws InterruptedException, CoreException {
+ SWTBotExt bot = new SWTBotExt();
+ SWTUtilExt botUtil= new SWTUtilExt(bot);
+ bot.menu("Window").menu("Show
View").menu("Other...").click();
+ bot.tree().expandNode("Maven").select("Maven Repositories");
+ bot.button("OK").click();
+ bot.viewByTitle("Maven Repositories");
+ bot.sleep(1000);
+ 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
+ public void createSimpleJSFProjectArchetype() throws Exception {
+ String projectName = "JsfQuickstart";
+ 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
+ }
+
+ @SuppressWarnings("restriction")
+ @Test
+ public void createSimpleJarProjectArchetype() throws Exception {
+ String projectName = "ArchetypeQuickstart";
+ createSimpleMavenProjectArchetype(projectName,"maven-archetype-quickstart",
"Internal");
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ assertNoErrors(project);
+ 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 {
+ SWTBotExt botExt = new SWTBotExt();
+ botExt.menu("File").menu("New").menu("Other...").click();
+ waitForIdle();
+ SWTBot shell = botExt.shell("New").activate().bot();
+ shell.tree().expandNode("Maven").select("Maven Project");
+ shell.button("Next >").click();
+ shell.checkBox("Create a simple project (skip archetype
selection)").deselect();
+ shell.button("Next >").click();
+ Thread.sleep(2000);
+ 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");
+ }
+ shell.table(0).select(index);
+ shell.button("Next >").click();
+ shell.comboBoxWithLabel("Group Id:").setText(projectName);
+ shell.comboBoxWithLabel("Artifact Id:").setText(projectName);
+ shell.button("Finish").click();
+ waitForIdle();
+ }
+}
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CDIConfiguratorTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CDIConfiguratorTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CDIConfiguratorTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -0,0 +1,82 @@
+package org.jboss.tools.maven.ui.bot.test;
+
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.junit.Test;
+
+public class CDIConfiguratorTest extends AbstractConfiguratorsTest{
+
+ private SWTUtilExt botUtil= new SWTUtilExt(bot);
+
+ @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",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",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.",hasNature(PROJECT_NAME_CDI, CDI_NATURE));
+ clean();
+
+ createMavenizedEJBProject(PROJECT_NAME_CDI_EJB, true);
+ 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",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",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",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",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));
+
+ }
+
+}
Deleted:
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-30
07:57:46 UTC (rev 43315)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/ConfiguratorsTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -1,315 +0,0 @@
-package org.jboss.tools.maven.ui.bot.test;
-
-import java.io.ByteArrayInputStream;
-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.tests.common.WorkspaceHelpers;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
-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.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-@SuppressWarnings("restriction")
-@Require(perspective="Java EE")
-public class ConfiguratorsTest extends AbstractMavenSWTBotTest{
-
- public static final String PROJECT_NAME_JSF="testWEB_JSF";
- public static final String PROJECT_NAME_JAXRS="testWEB_JAXRS";
- public static final String PROJECT_NAME_CDI="testWEB_CDI";
- public static final String PROJECT_NAME_CDI_EJB="testEJB_CDI";
- 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 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 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();
- }
-
- @Before
- public void clean() throws InterruptedException, CoreException{
- WorkspaceHelpers.cleanWorkspace();
- }
-
- //https://issues.jboss.org/browse/JBIDE-10468
- //https://issues.jboss.org/browse/JBIDE-10831
- @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",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",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",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",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",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));
-
-
-
- }
-
-
- @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",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",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.",hasNature(PROJECT_NAME_CDI, CDI_NATURE));
- clean();
-
- createMavenizedEJBProject(PROJECT_NAME_CDI_EJB, true);
- 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",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",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",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",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",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",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.",hasNature(PROJECT_NAME_JAXRS, JAXRS_NATURE));
- }
-
-
- private void createMavenizedDynamicWebProject(String projectName, boolean runtime)
throws Exception{
- bot.menu("File").menu("New").menu("Dynamic Web
Project").click();
- bot.textWithLabel("Project name:").setText(projectName);
- if(runtime){
- 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 {
- bot.comboBoxInGroup("Target
runtime").setSelection("<None>");
- }
- 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);
- waitForIdle();
- SWTBotTreeItem item = bot.viewByTitle("Package
Explorer").bot().tree().getTreeItem(projectName).select();
- item.pressShortcut(Keystrokes.ALT,Keystrokes.LF);
- 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);
- bot.hyperlink("Further configuration required...").click();
- bot.button("OK").click();
- bot.button("OK").click();
- botUtil.waitForAll();
- 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.",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.",hasNature(projectName, JSF_NATURE));
- assertFalse("Project "+projectName+" has "+JAXRS_NATURE+"
nature.",hasNature(projectName, JAXRS_NATURE));
- }
- }
-
- private void createMavenizedEJBProject(String projectName, boolean runtime)throws
Exception{
- bot.menu("File").menu("New").menu("EJB
Project").click();
- bot.textWithLabel("Project name:").setText(projectName);
- if(runtime){
- 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 {
- bot.comboBoxInGroup("Target
runtime").setSelection("<None>");
- }
- waitForShell(botUtil,"New EJB Project");
- bot.button("Finish").click();
- botUtil.waitForAll(Long.MAX_VALUE);
- waitForIdle();
- SWTBotTreeItem item = bot.viewByTitle("Package
Explorer").bot().tree().getTreeItem(projectName).select();
- item.pressShortcut(Keystrokes.ALT,Keystrokes.LF);
- waitForShell(botUtil,"Properties for "+projectName);
- bot.tree().select("Project Facets");
- bot.tree(1).getTreeItem("JBoss Maven Integration").check();
- botUtil.waitForAll();
- Thread.sleep(500);
- 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 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 addFacesConf(String projectName) throws InterruptedException{
- SWTBotTree innerBot = bot.viewByTitle("Package
Explorer").bot().tree().select(projectName);
- ContextMenuHelper.clickContextMenu(innerBot, "New","Other...");
- 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{
- IProject facade = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
-
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = factory.newDocumentBuilder();
- 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");
- Element loadElement = docPom.createElement("load-on-startup");
-
- servletNameElement.setTextContent(servletName);
- servletClassElement.setTextContent(servletClass);
- loadElement.setTextContent(load);
-
- Element root = docPom.getDocumentElement();
- servletElement.appendChild(servletNameElement);
- servletElement.appendChild(servletClassElement);
- servletElement.appendChild(loadElement);
- root.appendChild(servletElement);
- 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);
- facade.getProject().getFile(WEB_XML_LOCATION).setContents(new
ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")), 0, null);
- botUtil.waitForAll();
- 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-30
07:57:46 UTC (rev 43315)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenProjectsTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -1,63 +1,23 @@
package org.jboss.tools.maven.ui.bot.test;
-import org.eclipse.core.resources.IFile;
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.NullProgressMonitor;
-import org.eclipse.jface.bindings.keys.KeyStroke;
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;
-import org.junit.BeforeClass;
import org.junit.Test;
-@SuppressWarnings("restriction")
@Require(perspective="Java")
public class CreateMavenProjectsTest extends AbstractMavenSWTBotTest{
- public static final String REPO_URL = "http://repo1.maven.org/maven2";
- 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 {
- 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();
- 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
public void createSimpleJarProject() throws Exception {
String projectName = "MavenJar";
createSimpleMavenProject(projectName, "jar");
@@ -79,8 +39,8 @@
bot.textWithLabel("Project name:").setText(projectName);
bot.button("Finish").click();
waitForIdle();
- bot.viewByTitle("Package Explorer");
- bot.tree().getTreeItem(projectName).select().pressShortcut(Keystrokes.ALT,Keystrokes.LF);
+ bot.viewByTitle("Package Explorer").setFocus();
+ 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);
@@ -117,63 +77,16 @@
bot.checkBox("Generate web.xml deployment descriptor").select();
bot.button("Next >").click();
bot.button("Finish").click();
+ //waitForIdle();
+ //bot.button("No").click();
waitForIdle();
- bot.button("No").click();
- waitForIdle();
IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
assertNoErrors(project);
assertTrue(isMavenProject(projectName));
buildProject(projectName,"5 Maven build...",
"war","-0.0.1-SNAPSHOT");
}
-
- @Test
- public void createSimpleJSFProjectArchetype() throws Exception {
- String projectName = "JsfQuickstart";
- 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",
"Internal");
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- assertNoErrors(project);
- 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 {
- SWTBotExt botExt = new SWTBotExt();
- botExt.menu("File").menu("New").menu("Other...").click();
- waitForIdle();
- SWTBot shell = botExt.shell("New").activate().bot();
- shell.tree().expandNode("Maven").select("Maven Project");
- shell.button("Next >").click();
- shell.checkBox("Create a simple project (skip archetype
selection)").deselect();
- shell.button("Next >").click();
- Thread.sleep(2000);
- 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");
- }
- shell.table(0).select(index);
- shell.button("Next >").click();
- shell.comboBoxWithLabel("Group Id:").setText(projectName);
- shell.comboBoxWithLabel("Artifact Id:").setText(projectName);
- shell.button("Finish").click();
- waitForIdle();
- }
-
private void createSimpleMavenProject(String projectName, String projectType) throws
InterruptedException, CoreException {
SWTBotExt botExt = new SWTBotExt();
botExt.menu("File").menu("New").menu("Other...").click();
@@ -190,23 +103,4 @@
}
- private void buildProject(String projectName, String mavenBuild, String packaging,
String version) throws Exception {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- SWTBot explorer = bot.viewByTitle("Package Explorer").bot();
- Thread.sleep(500);
- SWTBotTreeItem item = explorer.tree().getTreeItem(projectName).select();
- SWTBotExt swtBot = new SWTBotExt();
- 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();
- project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- project.getFolder("target").refreshLocal(IResource.DEPTH_INFINITE,new
NullProgressMonitor());
- IFile jarFile = project.getFile("target/" + projectName +
version+"."+packaging);
- assertTrue(jarFile + " is missing ", jarFile.exists());
- }
-
}
Deleted:
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-30
07:57:46 UTC (rev 43315)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedEARProjectTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -1,180 +0,0 @@
-package org.jboss.tools.maven.ui.bot.test;
-
-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;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
-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.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 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);
-
- @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 createEARProject() throws Exception{
- createWarProject(WAR_PROJECT_NAME);
- Thread.sleep(500);
- createEJBProject(EJB_PROJECT_NAME);
- Thread.sleep(500);
- 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);
- 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{
- 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 = bot.viewByTitle("Package
Explorer").bot().tree().getTreeItem(projectName).select();
- item.pressShortcut(Keystrokes.ALT,Keystrokes.LF);
- 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();
- waitForIdle();
- Thread.sleep(500);
- 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",isMavenProject(projectName));
-
- }
-
- private void createEJBProject(String projectName) throws CoreException,
InterruptedException{
- 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",
isMavenProject(projectName));
- }
-
- private void installProject(String projectName) throws InterruptedException{
- 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...");
- 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);
- }
-
-
-}
Deleted:
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-30
07:57:46 UTC (rev 43315)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -1,176 +0,0 @@
-package org.jboss.tools.maven.ui.bot.test;
-
-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;
-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;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-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;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-//TODO deployment
-@SuppressWarnings("restriction")
-@Require(perspective = "Web Development")
-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_NAME7="JSFProject7";
- public static final String PROJECT_NAME7_v1="JSFProject7_1.2";
- 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);
-
- @BeforeClass
- public final static void beforeClass() throws Exception {
- 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_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_NAME7);
- }
-
- @Test
- 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_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();
- 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);
- bot.button("Finish").click();;
- botUtil.waitForAll(Long.MAX_VALUE);
- }
-
-
- private void addDependencies(String projectName, String jsfVersion) throws
ParserConfigurationException, SAXException, IOException, CoreException,
TransformerException, InterruptedException{
- 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 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(jsfVersion);
- dependencyElement.appendChild(groupIdElement);
- dependencyElement.appendChild(versionElement);
- dependencyElement.appendChild(artifactIdElement);
- dependenciesElement.appendChild(dependencyElement);
- Element root = docPom.getDocumentElement();
- root.appendChild(dependenciesElement);
- //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 activateMavenFacet(String projectName) throws InterruptedException,
CoreException{
- SWTBotTreeItem item = bot.viewByTitle("Package
Explorer").bot().tree().getTreeItem(projectName).select();
- item.pressShortcut(Keystrokes.ALT,Keystrokes.LF);
- waitForShell(botUtil,"Properties for "+projectName);
- bot.tree().select("Project Facets");
- bot.tree(1).getTreeItem("JBoss Maven Integration").check();
- botUtil.waitForAll();
- Thread.sleep(500);
- bot.hyperlink("Further configuration required...").click();
- bot.button("OK").click();
- bot.button("OK").click();
- waitForIdle();
- assertTrue(projectName+ " doesn't have maven nature",
isMavenProject(projectName));
- }
-
- private void buildProject(String projectName) throws CoreException{
- 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();
- swtBot.textWithLabel("Goals:").setText("clean package");
- swtBot.button("Run").click();
- waitForIdle();
- project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- project.getFolder("target").refreshLocal(IResource.DEPTH_INFINITE, new
NullProgressMonitor());
- IFolder warFolder = project.getFolder("target/" + projectName +
"-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());
- }
-}
\ No newline at end of file
Deleted:
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-30
07:57:46 UTC (rev 43315)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -1,221 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2008-2011 Red Hat, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- *
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * JBoss by Red Hat - Initial implementation.
- ************************************************************************************/
-
-package org.jboss.tools.maven.ui.bot.test;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
-import org.eclipse.datatools.connectivity.ConnectionProfileException;
-import org.eclipse.datatools.connectivity.ProfileManager;
-import org.eclipse.datatools.connectivity.db.generic.IDBConnectionProfileConstants;
-import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants;
-import org.eclipse.datatools.connectivity.drivers.DriverInstance;
-import org.eclipse.datatools.connectivity.drivers.DriverManager;
-import org.eclipse.datatools.connectivity.drivers.IDriverMgmtConstants;
-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.tests.common.WorkspaceHelpers;
-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.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.BeforeClass;
-import org.junit.Test;
-
-@SuppressWarnings("restriction")
-@Require(perspective = "Java EE")
-public class CreateMavenizedSeamProjectTest extends AbstractMavenSWTBotTest {
-
- 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 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";
-
-
- 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 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 void checkErrors() throws CoreException{
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for(IProject project: projects){
- assertNoErrors(project);
- }
- }
-
- 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);
- }
- 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));
- }
- 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);
- }
- bot.radio(type).click();
- bot.button("Finish").click();
- waitForShell(botUtil, "Open Associated Perspective?");
- bot.button("No").click();
- botUtil.waitForNonIgnoredJobs();
- }
-
- 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);
- IPropertySet instance = new PropertySetImpl(HSQL_DRIVER_NAME,
HSQL_DRIVER_DEFINITION_ID);
- instance.setName(HSQL_DRIVER_NAME);
- instance.setID(HSQL_DRIVER_DEFINITION_ID);
- Properties props = new Properties();
-
- IConfigurationElement[] template = descr.getProperties();
- for (int i = 0; i < template.length; i++) {
- IConfigurationElement prop = template[i];
- String id = prop.getAttribute("id"); //$NON-NLS-1$
-
- String value = prop.getAttribute("value"); //$NON-NLS-1$
- 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);
-
- instance.setBaseProperties(props);
- DriverManager.getInstance().removeDriverInstance(instance.getID());
- System.gc();
- DriverManager.getInstance().addDriverInstance(instance);
- }
-
- driver = DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
- 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,"");
- 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);
- }
-
- }
-
-
- protected static void createSeamRuntime(String name, String seamPath, SeamVersion
seamVersion) {
- SeamRuntime seamRuntime = SeamRuntimeManager.getInstance().findRuntimeByName(name);
- if (seamRuntime != null) {
- return;
- }
- File seamFolder = new File(seamPath);
- if(seamFolder.exists() && seamFolder.isDirectory()) {
- SeamRuntime rt = new SeamRuntime();
- rt.setHomeDir(seamPath);
- rt.setName(name);
- rt.setDefault(true);
- rt.setVersion(seamVersion);
- SeamRuntimeManager.getInstance().addRuntime(rt);
- } else {
- fail("Invalid seam runtime.");
- }
- }
-
-}
\ No newline at end of file
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/EARProjectTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/EARProjectTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/EARProjectTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -0,0 +1,184 @@
+package org.jboss.tools.maven.ui.bot.test;
+
+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;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
+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.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 EARProjectTest 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);
+
+ @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 createEARProject() throws Exception{
+ createWarProject(WAR_PROJECT_NAME);
+ Thread.sleep(500);
+ createEJBProject(EJB_PROJECT_NAME);
+ Thread.sleep(500);
+ 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);
+ 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("Package Explorer").setFocus();
+ SWTBotTree innerBot = bot.viewByTitle("Package
Explorer").bot().tree().select(EAR_PROJECT_NAME);
+ ContextMenuHelper.clickContextMenu(innerBot,"Run As","3 Maven
build...");
+ waitForShell(botUtil,"Edit Configuration");
+ 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{
+ 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 = bot.viewByTitle("Package
Explorer").bot().tree().getTreeItem(projectName).select();
+ item.pressShortcut(Keystrokes.ALT,Keystrokes.LF);
+ 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();
+ waitForIdle();
+ bot.sleep(500);
+ 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",isMavenProject(projectName));
+
+ }
+
+ private void createEJBProject(String projectName) throws CoreException,
InterruptedException{
+ 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",
isMavenProject(projectName));
+ }
+
+ private void installProject(String projectName) throws InterruptedException{
+ 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...");
+ waitForShell(botUtil,"Edit Configuration");
+ bot.textWithLabel("Goals:").setText("clean install");
+ bot.button("Run").click();
+ waitForIdle();
+ botUtil.waitForAll();
+ bot.sleep(5000);
+ }
+
+ 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);
+ }
+
+
+}
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JAXRSConfiguratorTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JAXRSConfiguratorTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JAXRSConfiguratorTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -0,0 +1,29 @@
+package org.jboss.tools.maven.ui.bot.test;
+
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.junit.Test;
+
+public class JAXRSConfiguratorTest extends AbstractConfiguratorsTest{
+
+ private SWTUtilExt botUtil= new SWTUtilExt(bot);
+
+ @Test
+ public void testJAXRSConfigurator() throws Exception {
+ createMavenizedDynamicWebProject(PROJECT_NAME_JAXRS+"_noRuntime", false);
+ 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",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.",hasNature(PROJECT_NAME_JAXRS, JAXRS_NATURE));
+ }
+
+}
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JPAConfiguratorTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JPAConfiguratorTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JPAConfiguratorTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -0,0 +1,19 @@
+package org.jboss.tools.maven.ui.bot.test;
+
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.junit.Test;
+
+public class JPAConfiguratorTest extends AbstractConfiguratorsTest{
+
+ private SWTUtilExt botUtil= new SWTUtilExt(bot);
+
+ @Test
+ public void testJPAConfigurator() throws Exception{
+ createMavenizedDynamicWebProject(PROJECT_NAME_JPA+"_noRuntime", false);
+ addPersistence(PROJECT_NAME_JPA+"_noRuntime");
+ updateConf(botUtil,PROJECT_NAME_JPA+"_noRuntime");
+ assertTrue("Project "+PROJECT_NAME_JPA+"_noRuntime"+" with
persistence.xml file doesn't have "+JPA_NATURE+"
nature.",hasNature(PROJECT_NAME_JPA+"_noRuntime", JPA_NATURE));
+ clean();
+ }
+}
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JSFConfiguratorTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JSFConfiguratorTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JSFConfiguratorTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -0,0 +1,49 @@
+package org.jboss.tools.maven.ui.bot.test;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.junit.Test;
+
+public class JSFConfiguratorTest extends AbstractConfiguratorsTest{
+
+
+
+ private SWTUtilExt botUtil= new SWTUtilExt(bot);
+
+ @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",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",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",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",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",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));
+
+
+
+ }
+}
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JSFProjectTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JSFProjectTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/JSFProjectTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -0,0 +1,172 @@
+package org.jboss.tools.maven.ui.bot.test;
+
+
+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;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+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.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.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+//TODO deployment
+@Require(perspective="Web Development")
+public class JSFProjectTest 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_NAME7="JSFProject7";
+ public static final String PROJECT_NAME7_v1="JSFProject7_1.2";
+ 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);
+
+ @BeforeClass
+ public final static void beforeClass() throws Exception {
+ 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_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_NAME7);
+ }
+
+ @Test
+ 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_NAME7_v1);
+ }
+
+
+ private void createJSFProject(String serverRuntime, String server, String serverHome,
String jsfVersion, String projectName) throws InterruptedException, CoreException{
+ bot.menu("File").menu("New").menu("Other...").click();
+ waitForShell(botUtil, "New");
+ bot.tree().expandNode("JBoss Tools
Web").expandNode("JSF").select("JSF Project");
+ bot.button("Next >").click();
+ waitForShell(botUtil, "New JSF Project");
+ 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);
+ bot.button("Finish").click();;
+ botUtil.waitForAll(Long.MAX_VALUE);
+ }
+
+
+ private void addDependencies(String projectName, String jsfVersion) throws
ParserConfigurationException, SAXException, IOException, CoreException,
TransformerException, InterruptedException{
+ 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 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(jsfVersion);
+ dependencyElement.appendChild(groupIdElement);
+ dependencyElement.appendChild(versionElement);
+ dependencyElement.appendChild(artifactIdElement);
+ dependenciesElement.appendChild(dependencyElement);
+ Element root = docPom.getDocumentElement();
+ root.appendChild(dependenciesElement);
+ //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 activateMavenFacet(String projectName) throws InterruptedException,
CoreException{
+ bot.viewByTitle("Package Explorer").setFocus();
+ SWTBotTreeItem item = bot.viewByTitle("Package
Explorer").bot().tree().getTreeItem(projectName).select();
+ item.pressShortcut(Keystrokes.ALT,Keystrokes.LF);
+ waitForShell(botUtil,"Properties for "+projectName);
+ bot.tree().select("Project Facets");
+ bot.tree(1).getTreeItem("JBoss Maven Integration").check();
+ botUtil.waitForAll();
+ Thread.sleep(500);
+ bot.hyperlink("Further configuration required...").click();
+ bot.button("OK").click();
+ bot.button("OK").click();
+ waitForIdle();
+ assertTrue(projectName+ " doesn't have maven nature",
isMavenProject(projectName));
+ }
+
+ private void buildProject(String projectName) throws CoreException{
+ 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();
+ swtBot.textWithLabel("Goals:").setText("clean package");
+ swtBot.button("Run").click();
+ waitForIdle();
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ project.getFolder("target").refreshLocal(IResource.DEPTH_INFINITE, new
NullProgressMonitor());
+ IFolder warFolder = project.getFolder("target/" + projectName +
"-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());
+ }
+}
\ 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/MaterializeLibraryTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MaterializeLibraryTest.java 2012-08-30
07:57:46 UTC (rev 43315)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MaterializeLibraryTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -3,14 +3,11 @@
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;
@@ -64,10 +61,10 @@
item.pressShortcut(k);
waitForShell(botUtil, "Materialize Classpath Library");
bot.button("OK").click();
- Thread.sleep(1000);
+ bot.sleep(1000);
bot.activeShell().activate();
bot.button("OK").click();
- waitForIdle();
+ botUtil.waitForAll(Long.MAX_VALUE);
assertFalse(project.getName()+" is still a maven
project!",isMavenProject(project.getName()));
testExcludedResources(project);
assertNoErrors(project);
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-30
07:57:46 UTC (rev 43315)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenAllBotTests.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -21,13 +21,18 @@
*/
@RunWith(RequirementAwareSuite.class)
@Suite.SuiteClasses({
- 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
+ SeamProjectTest.class,
+ EARProjectTest.class,
+ JSFProjectTest.class,
+ MavenProfilesTest.class,
+ MaterializeLibraryTest.class,
+ JAXRSConfiguratorTest.class,
+ JPAConfiguratorTest.class,
+ JSFConfiguratorTest.class,
+ SeamConfiguratorTest.class,
+ CDIConfiguratorTest.class,
+ CreateMavenProjectsTest.class,
+ //ArchetypesTest.class,
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-30
07:57:46 UTC (rev 43315)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfileSelectionTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -33,8 +33,6 @@
import org.junit.runner.RunWith;
@Require(perspective="Java")
-@SuppressWarnings("restriction")
-(a)RunWith(SWTBotJunit4ClassRunner.class)
public class MavenProfileSelectionTest extends AbstractMavenSWTBotTest {
public static final String AUTOACTIVATED_PROFILE_IN_POM = "active-profile";
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfilesTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfilesTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfilesTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -0,0 +1,176 @@
+package org.jboss.tools.maven.ui.bot.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+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.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.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.condition.ButtonIsDisabled;
+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;
+
+@Require(perspective="Java")
+public class MavenProfilesTest extends AbstractMavenSWTBotTest {
+
+ public static final String AUTOACTIVATED_PROFILE_IN_POM = "active-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() {
+ 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 IOException, InterruptedException,
CoreException, ParseException{
+ importMavenProject("projects/simple-jar/pom.xml");
+ IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject("simple-jar");
+ waitForJobsToComplete();
+ testAutoActivatedProfiles();
+ 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
+ waitForShell(botUtil,"Select Maven profiles");
+ bot.button("Deselect all").click();
+ bot.button("OK").click();
+ waitForIdle();
+ testActivatedProfiles(project.getName(), null);
+ }
+
+ @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();
+ 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();
+ waitForIdle();
+ testActivatedProfiles(project.getName(), COMMON_PROFILES);
+ testActivatedProfiles(project1.getName(), COMMON_PROFILES);
+ testActivatedProfiles(project2.getName(), COMMON_PROFILES);
+ }
+
+ @SuppressWarnings("unused")
+ private void openProfilesDialog(SWTBotTreeItem projectItem) throws ParseException{
+ projectItem.pressShortcut(Keystrokes.CTRL,
Keystrokes.ALT,KeyStroke.getInstance("P"));
+ final SWTBotShell selectDialogShell = bot.shell("Select Maven profiles");
+ assertEquals("Select Maven profiles", selectDialogShell.getText());
+ }
+
+ private void testActivatedProfiles(String projectName, String[] expectedProfiles) {
+ Set<String> setOfExpectedProfiles = new HashSet<String>();
+ if(expectedProfiles != null){
+ Collections.addAll(setOfExpectedProfiles, expectedProfiles);
+ for(String act: AUTOACTIVATED_PROFILES_IN_USER_SETTINGS){
+ setOfExpectedProfiles.add(act);
+ }
+ }
+ 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>();
+
setOfProfilesFacade.addAll(MavenPlugin.getProjectConfigurationManager().getResolverConfiguration(facade.getProject()).getActiveProfileList());
+ setOfProfilesFacade.remove("");
+ assertEquals("Selected profiles in project " +projectName+ "
doesn't match", setOfExpectedProfiles, setOfProfilesFacade);
+ }
+
+ private void testAutoActivatedProfiles(){
+ 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_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");
+ bot.waitWhile(new ButtonIsDisabled("Finish"),150000);
+ 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());
+ }
+ }
+ }
+ }
+ }
+ }
+}
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/SeamConfiguratorTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/SeamConfiguratorTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/SeamConfiguratorTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -0,0 +1,43 @@
+package org.jboss.tools.maven.ui.bot.test;
+
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.junit.Test;
+
+public class SeamConfiguratorTest extends AbstractConfiguratorsTest{
+
+ private SWTUtilExt botUtil= new SWTUtilExt(bot);
+
+ @Test
+ public void testSeamConfigurator() throws Exception{
+ createMavenizedDynamicWebProject(PROJECT_NAME_SEAM+"_noRuntime", false);
+ addDependencies(PROJECT_NAME_SEAM+"_noRuntime", "org.jboss.seam",
"jboss-seam", "2.3.0.Beta2",null);
+ updateConf(botUtil,PROJECT_NAME_SEAM+"_noRuntime");
+ assertTrue("Project "+PROJECT_NAME_SEAM+"_noRuntime"+" with
jboss-seam dependency doesn't have "+SEAM_NATURE+"
nature.",hasNature(PROJECT_NAME_SEAM+"_noRuntime", SEAM_NATURE));
+ clean();
+
+ createMavenizedDynamicWebProject(PROJECT_NAME_SEAM+"_noRuntime", false);
+ addDependencies(PROJECT_NAME_SEAM+"_noRuntime", "org.jboss.seam",
"jboss-seam-ui", "2.3.0.ALPHA",null);
+ updateConf(botUtil,PROJECT_NAME_SEAM+"_noRuntime");
+ assertTrue("Project "+PROJECT_NAME_SEAM+"_noRuntime"+" with
jboss-seam-ui dependency doesn't have "+SEAM_NATURE+"
nature.",hasNature(PROJECT_NAME_SEAM+"_noRuntime", SEAM_NATURE));
+ clean();
+
+ createMavenizedDynamicWebProject(PROJECT_NAME_SEAM+"_noRuntime", false);
+ addDependencies(PROJECT_NAME_SEAM+"_noRuntime", "org.jboss.seam",
"jboss-seam-pdf", "2.3.0.ALPHA",null);
+ updateConf(botUtil,PROJECT_NAME_SEAM+"_noRuntime");
+ assertTrue("Project "+PROJECT_NAME_SEAM+"_noRuntime"+" with
jboss-seam-pdf dependency doesn't have "+SEAM_NATURE+"
nature.",hasNature(PROJECT_NAME_SEAM+"_noRuntime", SEAM_NATURE));
+ clean();
+
+ createMavenizedDynamicWebProject(PROJECT_NAME_SEAM+"_noRuntime", false);
+ addDependencies(PROJECT_NAME_SEAM+"_noRuntime", "org.jboss.seam",
"jboss-seam-remoting", "2.3.0.ALPHA",null);
+ updateConf(botUtil,PROJECT_NAME_SEAM+"_noRuntime");
+ assertTrue("Project "+PROJECT_NAME_SEAM+"_noRuntime"+" with
jboss-seam-remoting dependency doesn't have "+SEAM_NATURE+"
nature.",hasNature(PROJECT_NAME_SEAM+"_noRuntime", SEAM_NATURE));
+ clean();
+
+ createMavenizedDynamicWebProject(PROJECT_NAME_SEAM+"_noRuntime", false);
+ addDependencies(PROJECT_NAME_SEAM+"_noRuntime", "org.jboss.seam",
"jboss-seam-ioc", "2.3.0.ALPHA",null);
+ updateConf(botUtil,PROJECT_NAME_SEAM+"_noRuntime");
+ assertTrue("Project "+PROJECT_NAME_SEAM+"_noRuntime"+" with
jboss-seam-ioc dependency doesn't have "+SEAM_NATURE+"
nature.",hasNature(PROJECT_NAME_SEAM+"_noRuntime", SEAM_NATURE));
+ clean();
+ }
+}
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/SeamProjectTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/SeamProjectTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/SeamProjectTest.java 2012-08-30
08:43:37 UTC (rev 43316)
@@ -0,0 +1,218 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+
+package org.jboss.tools.maven.ui.bot.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.ConnectionProfileException;
+import org.eclipse.datatools.connectivity.ProfileManager;
+import org.eclipse.datatools.connectivity.db.generic.IDBConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants;
+import org.eclipse.datatools.connectivity.drivers.DriverInstance;
+import org.eclipse.datatools.connectivity.drivers.DriverManager;
+import org.eclipse.datatools.connectivity.drivers.IDriverMgmtConstants;
+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.tests.common.WorkspaceHelpers;
+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.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.BeforeClass;
+import org.junit.Test;
+
+@Require(perspective = "Java EE")
+public class SeamProjectTest extends AbstractMavenSWTBotTest {
+
+ 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 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";
+
+
+ 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 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 void checkErrors() throws CoreException{
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for(IProject project: projects){
+ assertNoErrors(project);
+ }
+ }
+
+ 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);
+ }
+ 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));
+ }
+ 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);
+ }
+ bot.radio(type).click();
+ bot.button("Finish").click();
+ waitForIdle();
+ }
+
+ 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);
+ IPropertySet instance = new PropertySetImpl(HSQL_DRIVER_NAME,
HSQL_DRIVER_DEFINITION_ID);
+ instance.setName(HSQL_DRIVER_NAME);
+ instance.setID(HSQL_DRIVER_DEFINITION_ID);
+ Properties props = new Properties();
+
+ IConfigurationElement[] template = descr.getProperties();
+ for (int i = 0; i < template.length; i++) {
+ IConfigurationElement prop = template[i];
+ String id = prop.getAttribute("id"); //$NON-NLS-1$
+
+ String value = prop.getAttribute("value"); //$NON-NLS-1$
+ 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);
+
+ instance.setBaseProperties(props);
+ DriverManager.getInstance().removeDriverInstance(instance.getID());
+ System.gc();
+ DriverManager.getInstance().addDriverInstance(instance);
+ }
+
+ driver = DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
+ 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,"");
+ 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);
+ }
+
+ }
+
+
+ protected static void createSeamRuntime(String name, String seamPath, SeamVersion
seamVersion) {
+ SeamRuntime seamRuntime = SeamRuntimeManager.getInstance().findRuntimeByName(name);
+ if (seamRuntime != null) {
+ return;
+ }
+ File seamFolder = new File(seamPath);
+ if(seamFolder.exists() && seamFolder.isDirectory()) {
+ SeamRuntime rt = new SeamRuntime();
+ rt.setHomeDir(seamPath);
+ rt.setName(name);
+ rt.setDefault(true);
+ rt.setVersion(seamVersion);
+ SeamRuntimeManager.getInstance().addRuntime(rt);
+ } else {
+ fail("Invalid seam runtime.");
+ }
+ }
+
+}
\ No newline at end of file