Author: rawagner
Date: 2012-01-06 03:43:03 -0500 (Fri, 06 Jan 2012)
New Revision: 37670
Added:
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/Utils.java
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.classpath
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.project
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/pom.xml
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/CreateMavenizedEARProjectTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenAllBotTests.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfileSelectionTest.java
Log:
new test for Materialize library
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.classpath
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.classpath 2012-01-06 08:06:06 UTC
(rev 37669)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.classpath 2012-01-06 08:43:03 UTC
(rev 37670)
@@ -1,7 +1,7 @@
-<?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.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?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.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.project
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.project 2012-01-06 08:06:06 UTC
(rev 37669)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.project 2012-01-06 08:43:03 UTC
(rev 37670)
@@ -38,19 +38,39 @@
<location>/home/eiden/Java/RedHat/Eclipses/jbds5.0.0.M4b/studio/plugins/org.jboss.tools.common_3.3.0.v20111027-1555-H29-M4</location>
</link>
<link>
+ <name>lib-org.jboss.tools.common_3.3.0.v20111208-2036-H34-M5</name>
+ <type>2</type>
+ <location>/home/eiden/Java/RedHat/Eclipses/jbds5m5a/studio/plugins/org.jboss.tools.common_3.3.0.v20111208-2036-H34-M5</location>
+ </link>
+ <link>
<name>lib-org.jboss.tools.jst.web.kb_3.3.0.v20111021-1521-H30-M4</name>
<type>2</type>
<location>/home/eiden/Java/RedHat/Eclipses/jbds5.0.0.M4b/studio/plugins/org.jboss.tools.jst.web.kb_3.3.0.v20111021-1521-H30-M4</location>
</link>
<link>
+ <name>lib-org.jboss.tools.jst.web.kb_3.3.0.v20111208-2115-H35-M5</name>
+ <type>2</type>
+ <location>/home/eiden/Java/RedHat/Eclipses/jbds5m5a/studio/plugins/org.jboss.tools.jst.web.kb_3.3.0.v20111208-2115-H35-M5</location>
+ </link>
+ <link>
<name>lib-org.jboss.tools.tests_3.2.0.v20111108-2302-Beta1</name>
<type>2</type>
<location>/home/eiden/Java/RedHat/Eclipses/jbds5.0.0.M4b/studio/plugins/org.jboss.tools.tests_3.2.0.v20111108-2302-Beta1</location>
</link>
<link>
+ <name>lib-org.jboss.tools.tests_3.2.0.v20111124-2026-H477-M5</name>
+ <type>2</type>
+ <location>/home/eiden/Java/RedHat/Eclipses/jbds5m5a/studio/plugins/org.jboss.tools.tests_3.2.0.v20111124-2026-H477-M5</location>
+ </link>
+ <link>
<name>lib-org.jboss.tools.ui.bot.ext_3.2.0.v20111108-2302-Beta1</name>
<type>2</type>
<location>/home/eiden/Java/RedHat/Eclipses/jbds5.0.0.M4b/studio/plugins/org.jboss.tools.ui.bot.ext_3.2.0.v20111108-2302-Beta1</location>
</link>
+ <link>
+ <name>lib-org.jboss.tools.ui.bot.ext_3.2.0.v20111124-2026-H477-M5</name>
+ <type>2</type>
+ <location>/home/eiden/Java/RedHat/Eclipses/jbds5m5a/studio/plugins/org.jboss.tools.ui.bot.ext_3.2.0.v20111124-2026-H477-M5</location>
+ </link>
</linkedResources>
</projectDescription>
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-01-06 08:06:06 UTC
(rev 37669)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/pom.xml 2012-01-06 08:43:03 UTC
(rev 37670)
@@ -13,7 +13,7 @@
<packaging>eclipse-test-plugin</packaging>
<properties>
- <systemProperties>-Djbosstools.test.jboss.home.5.1=${requirement.build.root}/jboss-5.1.0.GA
-Djbosstools.test.seam.2.0.1.GA.home=${requirement.build.root}/jboss-seam-2.2.0.GA</systemProperties>
+ <systemProperties>-Djbosstools.test.jboss.home.6.0=${requirement.build.root}/jbossas-6.0.0.Final
-Djbosstools.test.jboss.home.5.1=${requirement.build.root}/jboss-5.1.0.GA
-Djbosstools.test.seam.2.0.1.GA.home=${requirement.build.root}/jboss-seam-2.2.0.GA</systemProperties>
</properties>
<build>
<plugins>
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-01-06
08:06:06 UTC (rev 37669)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/AbstractMavenSWTBotTest.java 2012-01-06
08:43:03 UTC (rev 37670)
@@ -40,6 +40,7 @@
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
+@SuppressWarnings("restriction")
@RunWith(SWTBotJunit4ClassRunner.class)
public abstract class AbstractMavenSWTBotTest extends AbstractMavenProjectTestCase {
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-01-06
08:06:06 UTC (rev 37669)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenProjectsTest.java 2012-01-06
08:43:03 UTC (rev 37670)
@@ -9,6 +9,7 @@
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
import org.jboss.tools.ui.bot.ext.SWTUtilExt;
@@ -43,28 +44,91 @@
createSimpleMavenProject(projectName, "jar");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
assertNoErrors(project);
- //Utils.isMavenProject(projectName);
- buildProject(projectName,"5 Maven build...");
+ assertTrue(Utils.isMavenProject(projectName));
+ buildProject(projectName,"5 Maven build...", "jar");
}
@Test
- public void createSimpleWarProject() throws Exception {
- String projectName = "MavenWar";
- createSimpleMavenProject(projectName, "war");
+ public void createSimpleJarProjectArchetype() throws Exception {
+ String projectName = "ArchetypeQuickstart";
+ createSimpleMavenProjectArchetype(projectName,"maven-archetype-quickstart",
"Nexus Indexer");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
assertNoErrors(project);
- //Utils.isMavenProject(projectName);
- buildProject(projectName,"5 Maven build...");
+ assertTrue(Utils.isMavenProject(projectName));
+ buildProject(projectName, "6 Maven build...", "jar");
}
-
+
+
@Test
- public void createSimpleJarProjectArchetype() throws Exception {
- String projectName = "ArchetypeQuickstart";
- createSimpleMavenProjectArchetype(projectName,"maven-archetype-quickstart",
"Nexus Indexer");
+ public void createSimpleJarMavenizedProject() throws InterruptedException,
CoreException{
+ String projectName = "JarMavenized";
+ SWTBotExt botExt = new SWTBotExt();
+ botExt.menu("File").menu("New").menu("Other...").click();
+ waitForIdle();
+ SWTBot shell = botExt.shell("New").activate().bot();
+ shell.tree().expandNode("Java").select("Java Project");
+ shell.button("Next >").click();
+ shell.textWithLabel("Project name:").setText(projectName);
+ shell.button("Finish").click();
+ waitForIdle();
+ SWTBot explorer = botExt.viewByTitle("Package Explorer").bot();
+ explorer.tree().getTreeItem(projectName).select().pressShortcut(Keystrokes.ALT,Keystrokes.LF);
+ Thread.sleep(1000);
+ botExt.tree().select("Project Facets");
+ Thread.sleep(500);
+ botExt.link(0).click("Convert to faceted form...");
+ waitForIdle();
+ botExt.tree(1).getTreeItem("JBoss Maven Integration").check();
+ Thread.sleep(500);
+ botExt.hyperlink("Further configuration required...").click();
+ botExt.comboBoxWithLabel("Packaging:").setSelection("jar");
+ botExt.button("OK").click();
+ botExt.button("OK").click();
+ waitForIdle();
+ IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ assertNoErrors(project);
+ assertTrue(Utils.isMavenProject(projectName));
+ buildProject(projectName,"5 Maven build...", "jar");
+
+ }
+
+
+ @Test
+ public void createSimpleWarMavenizedProject() throws InterruptedException,
CoreException{
+ String projectName = "WarMavenized";
+ SWTBotExt botExt = new SWTBotExt();
+ botExt.menu("File").menu("New").menu("Other...").click();
+ waitForIdle();
+ SWTBot shell = botExt.shell("New").activate().bot();
+ shell.tree().expandNode("Web").select("Dynamic Web Project");
+ shell.button("Next >").click();
+ botExt.textWithLabel("Project name:").setText(projectName);
+ botExt.button("Modify...").click();
+ botExt.tree().getTreeItem("JBoss Maven Integration").check();
+ botExt.button("OK").click();
+ botExt.button("Next >").click();
+ botExt.button("Next >").click();
+ botExt.checkBox("Generate web.xml deployment descriptor").select();
+ botExt.button("Next >").click();
+ botExt.button("Finish").click();
+ waitForIdle();
+ botExt.button("No").click();
+ waitForIdle();
+ IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ assertNoErrors(project);
+ assertTrue(Utils.isMavenProject(projectName));
+ buildProject(projectName,"5 Maven build...", "war");
+
+ }
+
+ @Test
+ public void createSimpleJSFProjectArchetype() throws Exception {
+ String projectName = "JsfQuickstart";
+ createSimpleMavenProjectArchetype(projectName,"weld-jsf-jee-minimal",
"Nexus Indexer");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
assertNoErrors(project);
- //Utils.isMavenProject(projectName);
- buildProject(projectName, "6 Maven build...");
+ assertTrue(Utils.isMavenProject(projectName));
+ buildProject(projectName, "6 Maven build...", "jar");
}
private void createSimpleMavenProjectArchetype(String projectName,String projectType,
String catalog) throws InterruptedException,CoreException {
@@ -76,7 +140,7 @@
shell.button("Next >").click();
shell.checkBox("Create a simple project (skip archetype
selection)").deselect();
shell.button("Next >").click();
- Thread.sleep(1000);
+ Thread.sleep(2000);
shell.comboBox().setSelection(catalog);
Thread.sleep(1000);
int index = botExt.table(0).indexOf(projectType, "Artifact Id");
@@ -88,9 +152,9 @@
shell.comboBoxWithLabel("Group Id:").setText(projectName);
shell.comboBoxWithLabel("Artifact Id:").setText(projectName);
shell.button("Finish").click();
- waitForIdle();
+ waitForJobsToComplete();
}
-
+
private void createSimpleMavenProject(String projectName, String projectType) throws
InterruptedException, CoreException {
SWTBotExt botExt = new SWTBotExt();
botExt.menu("File").menu("New").menu("Other...").click();
@@ -107,7 +171,7 @@
}
- private void buildProject(String projectName, String mavenBuild) throws CoreException {
+ private void buildProject(String projectName, String mavenBuild, String packaging)
throws CoreException {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
SWTBot explorer = bot.viewByTitle("Package Explorer").bot();
SWTBotTreeItem item = explorer.tree().getTreeItem(projectName).select();
@@ -118,7 +182,7 @@
waitForIdle();
project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
project.getFolder("target").refreshLocal(IResource.DEPTH_INFINITE,new
NullProgressMonitor());
- IFile jarFile = project.getFile("target/" + projectName +
"-0.0.1-SNAPSHOT.jar");
+ IFile jarFile = project.getFile("target/" + projectName +
"-0.0.1-SNAPSHOT."+packaging);
assertTrue(jarFile + " is missing ", jarFile.exists());
}
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedEARProjectTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedEARProjectTest.java 2012-01-06
08:06:06 UTC (rev 37669)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedEARProjectTest.java 2012-01-06
08:43:03 UTC (rev 37670)
@@ -1,28 +1,16 @@
package org.jboss.tools.maven.ui.bot.test;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.StringWriter;
+import static org.junit.Assert.assertTrue;
-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.jboss.tools.ui.bot.ext.SWTBotExt;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
import org.junit.Test;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
@Require(perspective="Java EE")
@@ -50,18 +38,21 @@
botext.comboBoxWithLabel("Packaging:").setSelection("ear");
botext.button("Finish").click();
waitForIdle();
+ assertTrue(Utils.isMavenProject(EAR_PROJECT_NAME));
installProject(WAR_PROJECT_NAME);
installProject(EJB_PROJECT_NAME);
- editEARPomDependencies();
botext.viewByTitle("Project
Explorer").bot().tree().getTreeItem(EAR_PROJECT_NAME).contextMenu("Run
As").menu("5 Maven build...").click();
waitForIdle();
botext.textWithLabel("Goals:").setText("clean package");
botext.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());
}
- private void createWarProject(String projectName){
+ private void createWarProject(String projectName) throws CoreException{
botext.menu("File").menu("Dynamic Web Project").click();
botext.textWithLabel("Project name:").setText(projectName);
botext.button("Modify...").click();
@@ -73,9 +64,11 @@
botext.button("Next >").click();
botext.button("Finish").click();
waitForIdle();
+ assertTrue(Utils.isMavenProject(projectName));
+
}
- private void createEJBProject(String projectName){
+ private void createEJBProject(String projectName) throws CoreException{
botext.menu("File").menu("EJB Project").click();
botext.textWithLabel("Project name:").setText(projectName);
botext.button("Modify...").click();
@@ -87,6 +80,7 @@
botext.comboBoxWithLabel("Packaging:").setSelection("ejb");
botext.button("Finish").click();
waitForIdle();
+ assertTrue(Utils.isMavenProject(projectName));
}
private void installProject(String projectName) throws InterruptedException{
@@ -96,86 +90,6 @@
waitForIdle();
}
- private void editEARPomDependencies() throws ParserConfigurationException, SAXException,
IOException, CoreException, TransformerException{
- IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(EAR_PROJECT_NAME);
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = factory.newDocumentBuilder();
- Document docPom =
docBuilder.parse(project.getFile("pom.xml").getContents());
- Element modulesElement = docPom.createElement("modules");
- Element webModuleElement = docPom.createElement("webModule");
- Element groupIdWebElement = docPom.createElement("groupId");
- Element artifactIdWebElement = docPom.createElement("artifactId");
- Element versionWebElement = docPom.createElement("version");
- Element bundleFileNameWebElement =
docPom.createElement("bundleFileName");
- Element ejbModuleElement = docPom.createElement("ejbModule");
- Element groupIdEjbElement = docPom.createElement("groupId");
- Element artifactIdEjbElement = docPom.createElement("artifactId");
- Element groupIdEjbModuleElement = docPom.createElement("groupId");
- Element artifactIdEjbModuleElement = docPom.createElement("artifactId");
- Element groupIdWebModuleElement = docPom.createElement("groupId");
- Element artifactIdWebModuleElement = docPom.createElement("artifactId");
- Element versionEjbElement = docPom.createElement("version");
- Element bundleFileNameEjbElement =
docPom.createElement("bundleFileName");
- Element dependenciesElement = docPom.createElement("dependencies");
- Element dependencyEjbElement = docPom.createElement("dependency");
- Element dependencyWarElement = docPom.createElement("dependency");
- Element typeEjbElement = docPom.createElement("type");
- Element typeWarElement = docPom.createElement("type");
-
- groupIdWebElement.setTextContent("org.jboss.tools");
- groupIdEjbElement.setTextContent("org.jboss.tools");
- artifactIdWebElement.setTextContent(WAR_PROJECT_NAME);
- artifactIdEjbElement.setTextContent(EJB_PROJECT_NAME);
- groupIdWebModuleElement.setTextContent("org.jboss.tools");
- groupIdEjbModuleElement.setTextContent("org.jboss.tools");
- artifactIdWebModuleElement.setTextContent(WAR_PROJECT_NAME);
- artifactIdEjbModuleElement.setTextContent(EJB_PROJECT_NAME);
- versionWebElement.setTextContent("0.0.1-SNAPSHOT");
- versionEjbElement.setTextContent("0.0.1-SNAPSHOT");
- typeWarElement.setTextContent("war");
- typeEjbElement.setTextContent("ejb");
-
bundleFileNameWebElement.setTextContent(WAR_PROJECT_NAME+"-0.0.1-SNAPSHOT.war");
-
bundleFileNameEjbElement.setTextContent(EJB_PROJECT_NAME+"-0.0.1-SNAPSHOT.jar");
-
- webModuleElement.appendChild(groupIdWebModuleElement);
- webModuleElement.appendChild(artifactIdEjbModuleElement);
- webModuleElement.appendChild(bundleFileNameWebElement);
- ejbModuleElement.appendChild(groupIdEjbModuleElement);
- ejbModuleElement.appendChild(artifactIdEjbModuleElement);
- ejbModuleElement.appendChild(bundleFileNameEjbElement);
- modulesElement.appendChild(webModuleElement);
- modulesElement.appendChild(ejbModuleElement);
-
- dependencyWarElement.appendChild(groupIdWebElement);
- dependencyWarElement.appendChild(artifactIdWebElement);
- dependencyWarElement.appendChild(versionWebElement);
- dependencyWarElement.appendChild(typeWarElement);
- dependencyEjbElement.appendChild(groupIdEjbElement);
- dependencyEjbElement.appendChild(artifactIdEjbElement);
- dependencyEjbElement.appendChild(versionEjbElement);
- dependencyEjbElement.appendChild(typeEjbElement);
- dependenciesElement.appendChild(dependencyWarElement);
- dependenciesElement.appendChild(dependencyEjbElement);
-
- Element root = docPom.getDocumentElement();
- Element buildElement =
(Element)root.getElementsByTagName("build").item(0);
- Node plugin = buildElement.getElementsByTagName("configuration").item(0);
-
- root.appendChild(dependenciesElement);
- plugin.appendChild(modulesElement);
-
- //save xml
- 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 static void waitForIdle() {
AbstractMavenSWTBotTest.waitForIdle();
}
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java 2012-01-06
08:06:06 UTC (rev 37669)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java 2012-01-06
08:43:03 UTC (rev 37670)
@@ -29,10 +29,7 @@
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.SWTTestExt;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
-import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
-import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Document;
@@ -40,11 +37,11 @@
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
+//TODO deployment
@SuppressWarnings("restriction")
@Require(perspective = "Web Development")
public class CreateMavenizedJSFProjectTest{
- public static final String
JBOSS6_AS_HOME=System.getProperty("jbosstools.test.jboss.home.6.1",
"/home/eiden/Java/RedHat/JBossASs/jboss-6.1.0.Final");
- public static final String
JBOSS7_AS_HOME=System.getProperty("jbosstools.test.jboss.home.7.0",
"/home/eiden/Java/RedHat/JBossASs/jboss-as-7.0.1.Final1");
+ public static final String
JBOSS6_AS_HOME=System.getProperty("jbosstools.test.jboss.home.6.0");
public static final String POM_FILE = "pom.xml";
public static final String PROJECT_NAME6="JSFProject6";
public static final String PROJECT_NAME7="JSFProject7";
@@ -90,23 +87,8 @@
}
*/
- @Test
- public void createJSFProjectTest_AS7_v2() throws InterruptedException, CoreException{
- createJSFProject(SERVER_RUNTIME7, SERVER7, JBOSS7_AS_HOME,"JSF 2.0",
PROJECT_NAME7);
- }
@Test
- public void activateMavenFacet_AS7_v2() throws InterruptedException, CoreException{
- activateMavenFacet(PROJECT_NAME7);
- }
-
- @Test
- public void buildProject_AS7_v2() throws CoreException, ParserConfigurationException,
SAXException, IOException, TransformerException, InterruptedException{
- addDependencies(PROJECT_NAME7, JSF_VERSION_2);
- buildProject(PROJECT_NAME7);
- }
-
- @Test
public void createJSFProjectTest_AS6_v1() throws InterruptedException, CoreException{
createJSFProject(SERVER_RUNTIME6, SERVER6, JBOSS6_AS_HOME,"JSF 1.2",
PROJECT_NAME6_v1);
}
@@ -122,23 +104,7 @@
buildProject(PROJECT_NAME6_v1);
}
- @Test
- public void createJSFProjectTest_AS7_v1() throws InterruptedException, CoreException{
- createJSFProject(SERVER_RUNTIME7, SERVER7, JBOSS7_AS_HOME,"JSF 1.2",
PROJECT_NAME7_v1);
- }
- @Test
- public void activateMavenFacet_AS7_v1() throws InterruptedException, CoreException{
- activateMavenFacet(PROJECT_NAME7_v1);
- }
-
- @Test
- public void buildProject_AS7_v1() throws CoreException, ParserConfigurationException,
SAXException, IOException, TransformerException, InterruptedException{
- addDependencies(PROJECT_NAME7_v1, JSF_VERSION_1_2);
- buildProject(PROJECT_NAME7_v1);
- }
-
-
private void createJSFProject(String serverRuntime, String server, String serverHome,
String jsfVersion, String projectName) throws InterruptedException, CoreException{
bot.menu("File").menu("New").menu("JSF
Project").click();
SWTBot shell = bot.shell("New JSF Project").activate().bot();
@@ -205,6 +171,10 @@
Thread.sleep(1000);
SWTBot shellProperties = bot.shell("Properties for
"+projectName).activate().bot();
shellProperties.tree().select("Project Facets");
+ Thread.sleep(500);
+ SWTBotExt botExt = new SWTBotExt();
+ botExt.link(0).click("Convert to faceted form...");
+ waitForIdle();
shellProperties.tree(1).getTreeItem("JBoss Maven Integration").check();
Thread.sleep(500);
SWTBotExt swtBot = new SWTBotExt();
@@ -214,7 +184,7 @@
waitForIdle();
IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
assertNoErrors(project);
- //Utils.isMavenProject(projectName);
+ assertTrue(Utils.isMavenProject(projectName));
}
private void buildProject(String projectName) throws CoreException{
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java 2012-01-06
08:06:06 UTC (rev 37669)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java 2012-01-06
08:43:03 UTC (rev 37670)
@@ -120,17 +120,17 @@
public static final String HSQL_PROFILE_ID =
"org.eclipse.datatools.enablement.hsqldb.connectionProfile";
- public static final String JBOSS_AS_HOME =
System.getProperty("jbosstools.test.jboss.home.5.1",
"/home/eiden/Java/RedHat/JBossASs/jboss-5.1.0.GA");//"E:\\JBossRuntimes\\jboss-5.1.0.GA");
+ public static final String JBOSS_AS_HOME =
System.getProperty("jbosstools.test.jboss.home.5.1");
public static final String JBOSS_AS_RUNTIME_ID =
"org.jboss.ide.eclipse.as.runtime.51";
public static final String JBOSS_AS_SERVER_ID =
"org.jboss.ide.eclipse.as.51";
- public static final String SEAM_HOME_PROPERTY =
System.getProperty("jbosstools.test.seam.2.0.1.GA.home",
"/home/eiden/Java/RedHat/libs/jboss-seam-2.2.1.Final");//E:\\JBossRuntimes\\jboss-seam-2.2.1.CR3");
+ public static final String SEAM_HOME_PROPERTY =
System.getProperty("jbosstools.test.seam.2.0.1.GA.home");
public static final String HSQLDB_DRIVER_JAR_NAME = "hsqldb.jar";
//$NON-NLS-1$
- public static final String HSQLDB_DRIVER_LOCATION = "/home/eiden/Java/RedHat/libs +
HSQLDB_DRIVER_JAR_NAME"; //"/common/lib/" + HSQLDB_DRIVER_JAR_NAME;
//$NON-NLS-1$
+ public static final String HSQLDB_DRIVER_LOCATION = "lib/ +
HSQLDB_DRIVER_JAR_NAME";//$NON-NLS-1$
public static final String PROJECT_NAME_WAR = "MavenizedSeamProjectWar";
Added:
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
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MaterializeLibraryTest.java 2012-01-06
08:43:03 UTC (rev 37670)
@@ -0,0 +1,66 @@
+package org.jboss.tools.maven.ui.bot.test;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+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.config.Annotations.Require;
+import org.junit.Test;
+
+@Require(perspective="Seam 2")
+public class MaterializeLibraryTest extends AbstractMavenSWTBotTest {
+
+ private String projectName = "exampleHTML5";
+
+ @Test
+ public void testMaterializeLibrary() throws Exception{
+ SWTBotExt ext = new SWTBotExt();
+ ext.menu("New").menu("Example...").click();
+ ext.tree().expandNode("JBoss Tools").select("Project Examples");
+ waitForIdle();
+ ext.button("Next >").click();
+ waitForIdle();
+ Thread.sleep(1000);
+ ext.tree(0).expandNode("Java EE 6 Quickstarts").select("Java EE 6 HTML5
Mobile Webapp");
+ ext.button("Finish").click();
+ ext.comboBoxWithLabel("Project name").setText(projectName);
+ ext.comboBoxWithLabel("Package").setText(projectName);
+ ext.button("Next >").click();
+ ext.button("Finish").click();
+ waitForIdle();
+ final SWTBotView packageExplorer = bot.viewByTitle("Package Explorer");
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ SWTBotTree tree = packageExplorer.bot().tree();
+ tree.expandNode(project.getName()).getNode("Maven
Dependencies").contextMenu("Materialize Library...").click();
+ waitForIdle();
+ SWTBotExt botExt = new SWTBotExt();
+ botExt.button("OK").click();
+ botExt.button("OK").click();
+ waitForIdle();
+ assertFalse(project.getName()+" is still a maven
project!",Utils.isMavenProject(project.getName()));
+ testExcludedResources(project);
+ }
+
+ public void testExcludedResources(IProject project) throws Exception{
+ final SWTBotView packageExplorer = bot.viewByTitle("Package Explorer");
+ packageExplorer.bot().tree().getTreeItem(project.getName()).select().pressShortcut(Keystrokes.ALT,Keystrokes.LF);
+ SWTBotExt botExt = new SWTBotExt();
+ botExt.tree().select("Java Build Path");
+ botExt.tabItem("Source").activate();
+ for(SWTBotTreeItem item: botExt.tree(1).getAllItems()){
+ for(SWTBotTreeItem itemToCheck: item.getItems()){
+ if(itemToCheck.getText().startsWith("Included")){
+ assertTrue("(All) expected in Included
patterns",itemToCheck.getText().endsWith("(All)"));
+ } else if (itemToCheck.getText().startsWith("Excluded")){
+ assertTrue("(None) expected in Excluded
patterns",itemToCheck.getText().endsWith("(None)"));
+ }
+ }
+ }
+ }
+
+
+}
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-01-06
08:06:06 UTC (rev 37669)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenAllBotTests.java 2012-01-06
08:43:03 UTC (rev 37670)
@@ -25,9 +25,10 @@
CreateMavenizedSeamProjectTest.class,
CreateMavenProjectsTest.class,
CreateMavenizedEARProjectTest.class,
- CreateMavenizedJSFProjectTest.class
+ CreateMavenizedJSFProjectTest.class,
+ MaterializeLibraryTest.class
})
public class MavenAllBotTests {
-}
\ No newline at end of file
+}
\ 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/MavenProfileSelectionTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfileSelectionTest.java 2012-01-06
08:06:06 UTC (rev 37669)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfileSelectionTest.java 2012-01-06
08:43:03 UTC (rev 37670)
@@ -1,17 +1,10 @@
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 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.apache.maven.model.Profile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.bindings.keys.ParseException;
@@ -24,13 +17,8 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.ui.bot.ext.SWTBotExt;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
@SuppressWarnings("restriction")
@RunWith(SWTBotJunit4ClassRunner.class)
@@ -38,53 +26,7 @@
public static final String AUTOACTIVATED_PROFILE_IN_POM = "active-profile";
public static final String AUTOACTIVATED_PROFILE_IN_USER_SETTINGS =
"jboss.repository";
-
- /*
- @BeforeClass
- public static void setUpUserSettings() throws InterruptedException, IOException,
SAXException, ParserConfigurationException, TransformerException{
- SWTBotExt bot = new SWTBotExt();
- bot.menu("Window").menu("Preferences").click();
- bot.tree().expandNode("Maven").select("User Settings");
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = factory.newDocumentBuilder();
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- Transformer transformer = transformerFactory.newTransformer();
- String settingsLocation = bot.text(1).getText();
- File settings = null;
- if(settingsLocation.equals("User settings file doesn't exist")){
- settingsLocation = bot.text(2).getText();
- settings = new File(settingsLocation);
- settings.createNewFile();
- Document doc = docBuilder.newDocument();
- Element rootElement = doc.createElement("settings");
- doc.appendChild(rootElement);
- DOMSource source = new DOMSource(doc);
- StreamResult result = new StreamResult(settingsLocation);
- transformer.transform(source, result);
- }
- settings = new File(settingsLocation);
- Document docPom = docBuilder.parse(settings);
- Element rootElement = docPom.getDocumentElement();
- Element profilesElement = docPom.createElement("profiles");
- Element profileElement = docPom.createElement("profile");
- Element idElement = docPom.createElement("id");
- Element activationElement = docPom.createElement("activation");
- Element activeByDefaultElement = docPom.createElement("activeByDefault");
-
- idElement.setTextContent(AUTOACTIVATED_PROFILE_IN_USER_SETTINGS);
- activeByDefaultElement.setTextContent("true");
-
- activationElement.appendChild(activeByDefaultElement);
- profileElement.appendChild(activationElement);
- profileElement.appendChild(idElement);
- profilesElement.appendChild(profileElement);
- rootElement.appendChild(profilesElement);
- DOMSource source = new DOMSource(docPom);
- StreamResult result = new StreamResult(settingsLocation);
- transformer.transform(source, result);
- }
- */
-
+
@Test
public void testOpenMavenProfiles() throws Exception {
IProject project = importProject("projects/simple-jar/pom.xml");
@@ -127,21 +69,28 @@
}
private void testActivatedProfiles(String projectName, String profilesToCheck){
-
- SWTBot explorer = bot.viewByTitle("Project Explorer").bot();
- SWTBotTreeItem item = explorer.tree().getTreeItem(projectName).select();
- item.pressShortcut(Keystrokes.ALT,Keystrokes.LF);
- SWTBot shell = bot.shell("Properties for "+projectName).activate().bot();
- shell.tree().select("Maven");
- assertEquals("Selected profiles doesn't match",
shell.textWithLabel("Active Maven Profiles (comma
separated):").getText(),profilesToCheck);
- shell.button("OK").click();
+ IMavenProjectFacade facade =
MavenPlugin.getMavenProjectRegistry().getMavenProject("org.jboss.tools.maven.tests",
"simple-jar", "1.0.0-SNAPSHOT");
+ assertNotNull("facade is null",facade);
+ String[] parsedProfiles = profilesToCheck.split(", ");
+ String empty = "";
+ Set<String> setOfProfiles = new HashSet<String>();
+ Collections.addAll(setOfProfiles, parsedProfiles);
+ setOfProfiles.add(AUTOACTIVATED_PROFILE_IN_POM);
+ setOfProfiles.add(AUTOACTIVATED_PROFILE_IN_USER_SETTINGS);
+ setOfProfiles.remove(empty);
+
+ Set<String> setOfProfilesFacade = new HashSet<String>();
+ for(Profile profile : facade.getMavenProject().getActiveProfiles()){
+ setOfProfilesFacade.add(profile.getId());
+ }
+
+ assertEquals("Selected profiles doesn't match", setOfProfilesFacade,
setOfProfiles);
}
private void testAutoActivatedProfiles(){
IMavenProjectFacade facade =
MavenPlugin.getMavenProjectRegistry().getMavenProject("org.jboss.tools.maven.tests",
"simple-jar", "1.0.0-SNAPSHOT");
assertNotNull("facade is null",facade);
- facade.getMavenProject().getActiveProfiles().get(0);
assertEquals("Auto Activated profiles from pom.xml doesn't match",
AUTOACTIVATED_PROFILE_IN_POM,
facade.getMavenProject().getActiveProfiles().get(0).getId());
assertEquals("Auto Activated profiles from settings.xml doesn't
match", AUTOACTIVATED_PROFILE_IN_USER_SETTINGS,
facade.getMavenProject().getActiveProfiles().get(1).getId());
}
Added:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Utils.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Utils.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Utils.java 2012-01-06
08:43:03 UTC (rev 37670)
@@ -0,0 +1,17 @@
+package org.jboss.tools.maven.ui.bot.test;
+
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.m2e.core.internal.IMavenConstants;
+
+@SuppressWarnings("restriction")
+public class Utils {
+
+ public static boolean isMavenProject(String projectName) throws CoreException {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ return project.hasNature(IMavenConstants.NATURE_ID);
+ }
+
+}