[jbosstools-commits] JBoss Tools SVN: r23816 - in trunk/maven/tests/org.jboss.tools.maven.ui.bot.test: src/org/jboss/tools/maven/ui/bot/test and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Jul 29 18:54:26 EDT 2010


Author: snjeza
Date: 2010-07-29 18:54:26 -0400 (Thu, 29 Jul 2010)
New Revision: 23816

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/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6714 Add SWTBot tests for JBoss Maven Integration


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	2010-07-29 20:55:00 UTC (rev 23815)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/META-INF/MANIFEST.MF	2010-07-29 22:54:26 UTC (rev 23816)
@@ -16,13 +16,21 @@
  org.eclipse.swtbot.swt.finder,
  org.junit4,
  org.jboss.tools.seam.core,
+ org.jboss.tools.maven.core,
+ org.jboss.tools.maven.hibernate,
+ org.jboss.tools.maven.jsf,
+ org.jboss.tools.maven.portlet,
+ org.jboss.tools.maven.seam,
+ org.jboss.tools.maven.ui,
  org.eclipse.wst.server.core,
  org.eclipse.datatools.connectivity;visibility:=reexport,
  org.eclipse.datatools.connectivity.db.generic,
  org.jboss.tools.common,
  org.jboss.tools.tests,
  org.maven.ide.eclipse;bundle-version="0.10.0",
- org.jboss.ide.eclipse.as.core
+ org.jboss.ide.eclipse.as.core,
+ org.maven.ide.eclipse.maven_model_edit;bundle-version="0.10.0",
+ org.hamcrest
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Eclipse-RegisterBuddy: org.apache.log4j

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	2010-07-29 20:55:00 UTC (rev 23815)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedSeamProjectTest.java	2010-07-29 22:54:26 UTC (rev 23816)
@@ -11,6 +11,7 @@
 
 package org.jboss.tools.maven.ui.bot.test;
 
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -19,6 +20,7 @@
 import java.util.List;
 import java.util.Properties;
 
+import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
@@ -47,12 +49,15 @@
 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.eclipse.finder.widgets.SWTBotViewMenu;
+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.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.SWTBotShell;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@@ -64,6 +69,7 @@
 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;
 import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
@@ -74,17 +80,24 @@
 import org.eclipse.wst.server.core.ServerUtil;
 import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
 import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
+import org.eclipse.wst.validation.ValidationFramework;
 import org.jboss.tools.seam.core.project.facet.SeamRuntime;
 import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
 import org.jboss.tools.seam.core.project.facet.SeamVersion;
 import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.ResourcesUtils;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.maven.ide.components.pom.Model;
+import org.maven.ide.components.pom.Parent;
+import org.maven.ide.components.pom.util.PomResourceImpl;
+import org.maven.ide.eclipse.MavenPlugin;
 import org.maven.ide.eclipse.core.IMavenConstants;
+import org.maven.ide.eclipse.embedder.MavenModelManager;
 
 /**
  * @author Snjeza
@@ -93,24 +106,16 @@
 @RunWith(SWTBotJunit4ClassRunner.class)
 public class CreateMavenizedSeamProjectTest {
 	
-	/**
-	 * 
-	 */
+	protected static final int IDLE_TIME = 60000;
+
 	private static final String CONNECTION_PROFILE_NAME = "DefaultDS";
 
-	/**
-	 * 
-	 */
 	private static final String SEAM_RUNTIME_NAME = "Seam 2.2";
 
-	/**
-	 * 
-	 */
 	private static final String JBOSS_AS_RUNTIME_NAME = "JBoss AS 5.1 Runtime";
 
-	/**
-	 * 
-	 */
+	public static final String PACKAGE_EXPLORER = "Package Explorer"; //$NON-NLS-1$
+	
 	private static final String JBOSS_AS_SERVER_NAME = "JBoss AS 5.1 Server";
 
 	public static final String JBOSS_AS_HOST = "localhost"; //$NON-NLS-1$
@@ -142,6 +147,13 @@
 	
 	public static final String HSQLDB_DRIVER_LOCATION = "/common/lib/" + HSQLDB_DRIVER_JAR_NAME; //$NON-NLS-1$
 	
+	public static final String PROJECT_NAME_WAR = "MavenizedSeamProjectWar";
+	
+	public static final String TEST_PROJECT_NAME_WAR = "MavenizedSeamProjectWar-test";
+	
+	public static final String PARENT_PROJECT_NAME_WAR = "MavenizedSeamProjectWar-parent";
+	
+	
 	public static final String PROJECT_NAME = "MavenizedSeamProject";
 	
 	public static final String EAR_PROJECT_NAME = "MavenizedSeamProject-ear";
@@ -152,8 +164,10 @@
 	
 	public static final String PARENT_PROJECT_NAME = "MavenizedSeamProject-parent";
 	
-	public static final String DEPOY_TYPE = "EAR";
+	public static final String DEPLOY_TYPE_EAR = "EAR";
 	
+	public static final String DEPLOY_TYPE_WAR = "WAR";
+	
 	protected static SWTWorkbenchBot bot;
 
 	@BeforeClass
@@ -174,14 +188,18 @@
 		
 		createDriver(asLocation, HSQLDB_DRIVER_LOCATION);
 		
-		createNewSeamWebProjectWizard(PROJECT_NAME, DEPOY_TYPE);
+		activateSchell();
+		
+		createNewSeamWebProjectWizard(PROJECT_NAME, DEPLOY_TYPE_EAR);
+		
+		createNewSeamWebProjectWizard(PROJECT_NAME_WAR, DEPLOY_TYPE_WAR);
 	}
 
 	private static void initSWTBot() throws CoreException {
 		bot = new SWTWorkbenchBot();
 		SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
 		SWTBotPreferences.TIMEOUT = 1000;
-		SWTBotPreferences.PLAYBACK_DELAY = 25;
+		SWTBotPreferences.PLAYBACK_DELAY = 5;
 		JobUtils.waitForIdle(60000);
 		try {
 			SWTBotView view = bot.viewByTitle("Welcome");
@@ -232,6 +250,20 @@
 		}, new NullProgressMonitor());
 	}
 
+	private static void removeServers() throws CoreException {
+		IServer server = ServerCore.findServer(JBOSS_AS_SERVER_NAME);
+		IServerWorkingCopy wc = server.createWorkingCopy();
+		IModule[] modules = wc.getModules();
+		IProgressMonitor monitor = new NullProgressMonitor();
+		wc.modifyModules(new IModule[] {} , modules, monitor);
+		wc.save(true, monitor);
+		server.publish(IServer.PUBLISH_INCREMENTAL, monitor);
+		JobUtils.waitForIdle(IDLE_TIME);
+		server.getRuntime().delete();
+		server.delete();
+		JobUtils.waitForIdle(IDLE_TIME);
+	}
+
 	protected static void switchPerspective(final String pid) {
 		Display.getDefault().syncExec(new Runnable() {
 
@@ -249,13 +281,17 @@
 	
 	@Before
     public void setUp() throws Exception {
-        UIThreadRunnable.syncExec(new VoidResult() {
+        activateSchell();
+    }
+
+	private static void activateSchell() {
+		UIThreadRunnable.syncExec(new VoidResult() {
             public void run() {
             	PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()
                         .forceActive();
             }
         });
-    }
+	}
 	
 	@After
 	public void tearDown() throws Exception {
@@ -264,7 +300,16 @@
 	
 	@AfterClass
 	public final static void afterClass() throws Exception {
-		removeProjects();
+		boolean buildAutomatically = ResourcesUtils.setBuildAutomatically(false);
+		ValidationFramework.getDefault().suspendAllValidation(true);
+		try {
+			removeServers();
+			removeProjects();
+		} finally {
+			ResourcesUtils.setBuildAutomatically(buildAutomatically);
+			ValidationFramework.getDefault().suspendAllValidation(false);
+		}
+		JobUtils.waitForIdle(IDLE_TIME);
 	}
 	
 	protected static void createJBossServer(File asLocation, String serverType, String runtimeType, String name, String runtimeName) throws CoreException {
@@ -442,7 +487,7 @@
 		bot.button("Next >").click();
 		
 		bot.comboBox(0).setSelection(SEAM_RUNTIME_NAME);
-		bot.radio(DEPOY_TYPE).click();
+		bot.radio(deployType).click();
 		bot.comboBox(1).setSelection("HSQL");
 		bot.comboBox(2).setSelection(CONNECTION_PROFILE_NAME);
 		bot.button("Finish").click();
@@ -458,6 +503,9 @@
 		checkErrors(EJB_PROJECT_NAME);
 		checkErrors(TEST_PROJECT_NAME);
 		checkErrors(PARENT_PROJECT_NAME);
+		checkErrors(PROJECT_NAME_WAR);
+		checkErrors(TEST_PROJECT_NAME_WAR);
+		checkErrors(PARENT_PROJECT_NAME_WAR);
 	}
 
 	private void checkErrors(String projectName) throws CoreException {
@@ -482,6 +530,9 @@
 		isMavenProject(EJB_PROJECT_NAME);
 		isMavenProject(TEST_PROJECT_NAME);
 		isMavenProject(PARENT_PROJECT_NAME);
+		isMavenProject(PROJECT_NAME_WAR);
+		isMavenProject(TEST_PROJECT_NAME_WAR);
+		isMavenProject(PARENT_PROJECT_NAME_WAR);
 	}
 
 	private void isMavenProject(String projectName) throws CoreException {
@@ -489,4 +540,33 @@
 		assertTrue("The '" + projectName + "' project isn't a Maven project.", project.hasNature(IMavenConstants.NATURE_ID));
 	}
 
+	// see https://jira.jboss.org/browse/JBIDE-6587
+	@Test
+	public void testMavenWarArchive() throws Exception {
+		final SWTBotView packageExplorer = bot.viewByTitle(PACKAGE_EXPLORER);
+		SWTBot innerBot = packageExplorer.bot();
+		innerBot.activeShell().activate();
+		final SWTBotTree tree = innerBot.tree();
+		final SWTBotTreeItem warProjectItem = tree.getTreeItem(PROJECT_NAME_WAR);
+		warProjectItem.select();
+		
+		SWTBotMenu runAs = tree.contextMenu("Run As");
+		runAs.menu("6 Maven build...").click();
+
+		SWTBotShell shell = bot.shell("Edit Configuration");
+		shell.activate();
+		
+		bot.textWithLabel("Goals:").setText("clean package");
+		bot.button("Run").click();
+		
+		JobUtils.waitForIdle(IDLE_TIME);
+		
+		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME_WAR);
+		project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+		IPath webInfPath = new Path("target/" + PROJECT_NAME_WAR + "-0.0.1-SNAPSHOT/WEB-INF");
+		assertFalse(project.getFolder(webInfPath.append("src")).exists());
+		assertFalse(project.getFolder(webInfPath.append("dev")).exists());
+		assertTrue(project.getFolder(webInfPath.append("lib")).exists());
+		
+	}
 }



More information about the jbosstools-commits mailing list