Author: rawagner
Date: 2011-11-28 03:11:32 -0500 (Mon, 28 Nov 2011)
New Revision: 36683
Modified:
trunk/maven/tests/org.jboss.tools.maven.configurators.tests/.settings/org.eclipse.m2e.core.prefs
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.project
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/META-INF/MANIFEST.MF
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/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 and updated maven SWTBot tests
Modified:
trunk/maven/tests/org.jboss.tools.maven.configurators.tests/.settings/org.eclipse.m2e.core.prefs
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.configurators.tests/.settings/org.eclipse.m2e.core.prefs 2011-11-28
03:54:34 UTC (rev 36682)
+++
trunk/maven/tests/org.jboss.tools.maven.configurators.tests/.settings/org.eclipse.m2e.core.prefs 2011-11-28
08:11:32 UTC (rev 36683)
@@ -1,4 +1,4 @@
-#Tue Aug 02 13:44:10 CEST 2011
+#Mon Nov 28 08:59:23 CET 2011
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.project
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.project 2011-11-28 03:54:34 UTC
(rev 36682)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/.project 2011-11-28 08:11:32 UTC
(rev 36683)
@@ -1,28 +1,34 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.jboss.tools.maven.ui.bot.test</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.maven.ui.bot.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/META-INF/MANIFEST.MF 2011-11-28
03:54:34 UTC (rev 36682)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/META-INF/MANIFEST.MF 2011-11-28
08:11:32 UTC (rev 36683)
@@ -8,6 +8,9 @@
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.apache.log4j,
+ org.jboss.tools.ui.bot.ext,
+ org.eclipse.ui.ide;bundle-version="3.5.1",
+ org.eclipse.ui.forms;bundle-version="3.4.1",
org.eclipse.swtbot.eclipse.core,
org.eclipse.swtbot.swt.finder,
org.eclipse.swtbot.eclipse.finder,
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 2011-11-28
03:54:34 UTC (rev 36682)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java 2011-11-28
08:11:32 UTC (rev 36683)
@@ -11,7 +11,6 @@
package org.jboss.tools.maven.ui.bot.test;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -26,8 +25,6 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-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.IConfigurationElement;
@@ -35,7 +32,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
import org.eclipse.datatools.connectivity.ConnectionProfileException;
import org.eclipse.datatools.connectivity.ProfileManager;
@@ -47,27 +43,15 @@
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.jface.bindings.keys.KeyStroke;
-import org.eclipse.jface.bindings.keys.ParseException;
import org.eclipse.m2e.core.internal.IMavenConstants;
-import org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase;
-import org.eclipse.m2e.tests.common.JobHelpers;
import org.eclipse.m2e.tests.common.WorkspaceHelpers;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
-import org.eclipse.swtbot.swt.finder.results.Result;
-import org.eclipse.swtbot.swt.finder.results.VoidResult;
-import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
@@ -76,11 +60,7 @@
import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.IPerspectiveRegistry;
import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.IPreferenceConstants;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.internal.util.PrefUtil;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IRuntimeType;
@@ -108,8 +88,9 @@
* @author Snjeza
*
*/
+@SuppressWarnings("restriction")
@RunWith(SWTBotJunit4ClassRunner.class)
-public class CreateMavenizedSeamProjectTest {
+public class CreateMavenizedSeamProjectTest{
protected static final long IDLE_TIME = 1 * 60 * 1000L;
@@ -139,18 +120,18 @@
= "org.eclipse.datatools.connectivity.db.URL"; //$NON-NLS-1$
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",
"E:\\JBossRuntimes\\jboss-5.1.0.GA");
-
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",
"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",
"/home/eiden/Java/RedHat/libs/jboss-seam-2.2.1.Final");//E:\\JBossRuntimes\\jboss-seam-2.2.1.CR3");
public static final String HSQLDB_DRIVER_JAR_NAME = "hsqldb.jar";
//$NON-NLS-1$
- public static final String HSQLDB_DRIVER_LOCATION = "/common/lib/" +
HSQLDB_DRIVER_JAR_NAME; //$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 PROJECT_NAME_WAR = "MavenizedSeamProjectWar";
@@ -463,7 +444,7 @@
bot.button("Finish").click();
waitForIdle();
- }
+ }
@Test
public void testAsLocation() {
@@ -490,6 +471,7 @@
}
private void checkErrors(String projectName) throws CoreException {
+ waitForIdle();
List<IMarker> markers = new ArrayList<IMarker>();
IProject project = ResourcesPlugin.getWorkspace().getRoot()
.getProject(projectName);
@@ -526,21 +508,21 @@
// see
https://jira.jboss.org/browse/JBIDE-6587
@Test
public void testMavenWarArchive() throws Exception {
- final SWTBotView packageExplorer = bot.viewByTitle(PACKAGE_EXPLORER);
+ final SWTBotView packageExplorer = bot.viewByTitle("Package Explorer");
SWTBot innerBot = packageExplorer.bot();
innerBot.activeShell().activate();
- final SWTBotTree tree = innerBot.tree();
+ SWTBotTree tree = innerBot.tree();
final SWTBotTreeItem warProjectItem = tree.getTreeItem(PROJECT_NAME_WAR);
warProjectItem.select();
SWTBotMenu runAs = tree.contextMenu("Run As");
runAs.menu("5 Maven build...").click();
-
+ waitForIdle();
SWTBotShell shell = bot.shell("Edit Configuration");
shell.activate();
-
- bot.textWithLabel("Goals:").setText("clean package");
- bot.button("Run").click();
+ SWTBot b = shell.bot();
+ b.textWithLabel("Goals:").setText("clean package");
+ b.button("Run").click();
waitForIdle();
IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME_WAR);
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 2011-11-28
03:54:34 UTC (rev 36682)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenAllBotTests.java 2011-11-28
08:11:32 UTC (rev 36683)
@@ -20,9 +20,10 @@
*/
@Suite.SuiteClasses({
- //MavenProfileSelectionTest.class, FIXME enable tests for profiles
- JBossPerspectiveTest.class,
+ MavenProfileSelectionTest.class,
CreateMavenizedSeamProjectTest.class,
+ CreateMavenizedJSFProjectTest.class,
+ CreateMavenProjectsTest.class
})
@RunWith(Suite.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 2011-11-28
03:54:34 UTC (rev 36682)
+++
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfileSelectionTest.java 2011-11-28
08:11:32 UTC (rev 36683)
@@ -1,17 +1,10 @@
-/*************************************************************************************
- * 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 org.eclipse.core.resources.IProject;
import org.eclipse.jface.bindings.keys.KeyStroke;
+import org.eclipse.jface.bindings.keys.ParseException;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
@@ -26,31 +19,70 @@
@RunWith(SWTBotJunit4ClassRunner.class)
public class MavenProfileSelectionTest extends AbstractMavenSWTBotTest {
+ public static final String AUTOACTIVATED_PROFILE_IN_POM = "active-profile";
+ public static final String AUTOACTIVATED_PROFILE_IN_USER_SETTINGS =
"environment";
+
+
+
@Test
- //FIXME Test fail due to Modal Dialog. Need to find a solution
public void testOpenMavenProfiles() throws Exception {
-
IProject project = importProject("projects/simple-jar/pom.xml");
waitForJobsToComplete();
//Select the project
- final SWTBotView packageExplorer = bot.viewByTitle(PACKAGE_EXPLORER);
+ testAutoActivatedProfiles();
+ final SWTBotView packageExplorer = bot.viewByTitle("Project Explorer");
SWTBot innerBot = packageExplorer.bot();
innerBot.activeShell().activate();
- final SWTBotTree tree = innerBot.tree();
- final SWTBotTreeItem projectItem = tree.getTreeItem(project.getName());
+ SWTBotTree tree = innerBot.tree();
+ SWTBotTreeItem projectItem = tree.getTreeItem(project.getName());
projectItem.select();
- //Open the profiles dialog
- projectItem.pressShortcut(Keystrokes.CTRL, Keystrokes.ALT,
KeyStroke.getInstance("P"));
-
- //FIXME Either the dialog doesn't open abd the test fails
- //or SWTBot is blocked by the modal dialog
+ openProfilesDialog(projectItem);
+ Thread.sleep(2000);
+ //activate all profiles
+ SWTBot shell = bot.shell("Select Maven profiles").activate().bot();
+ shell.button("Select All").click();
+ String selectedProfiles = shell.textWithLabel("Active profiles for simple-jar
:").getText();
+ shell.button("OK").click();
+
+ testActivatedProfiles(project.getName(), selectedProfiles);
+ Thread.sleep(1000);
+ openProfilesDialog(projectItem);
+
+ //disable all profiles
+ shell = bot.shell("Select Maven profiles").activate().bot();
+ shell.button("Deselect all").click();
+ selectedProfiles = bot.textWithLabel("Active profiles for simple-jar
:").getText();
+ bot.button("OK").click();
+
+ testActivatedProfiles(project.getName(), selectedProfiles);
+ }
+
+ private void openProfilesDialog(SWTBotTreeItem projectItem) throws ParseException,
InterruptedException{
+ projectItem.pressShortcut(Keystrokes.CTRL,
Keystrokes.ALT,KeyStroke.getInstance("P"));
+ projectItem.pressShortcut(Keystrokes.DOWN);
+ projectItem.pressShortcut(Keystrokes.LF);
final SWTBotShell selectDialogShell = bot.shell("Select Maven profiles");
- assertNotNull("selectDialogShell not found", selectDialogShell);
assertEquals("Select Maven profiles", selectDialogShell.getText());
+ Thread.sleep(1000);
+ }
+
+ 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();
- selectDialogShell.activate();
- Thread.sleep(5000);
- //TODO implement real tests
- bot.button("Cancel").click();
}
+
+ 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());
+ }
}