[jbosstools-commits] JBoss Tools SVN: r43553 - in trunk/tests: scripts/installation-updates and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Mon Sep 10 11:33:49 EDT 2012


Author: mickael_istria
Date: 2012-09-10 11:33:49 -0400 (Mon, 10 Sep 2012)
New Revision: 43553

Added:
   trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/CheckForUpdatesTest.java
   trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/InstallFailureException.java
Modified:
   trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/InstallFromCentralTest.java
   trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/InstallTest.java
   trunk/tests/scripts/installation-updates/testInstall.sh
Log:
JBIDE-12508: Support Check for Updates

Added: trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/CheckForUpdatesTest.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/CheckForUpdatesTest.java	                        (rev 0)
+++ trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/CheckForUpdatesTest.java	2012-09-10 15:33:49 UTC (rev 43553)
@@ -0,0 +1,43 @@
+/******************************************************************************* 
+ * Copyright (c) 2012 Red Hat, Inc. 
+ * Distributed under license by Red Hat, Inc. All rights reserved. 
+ * This program is 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: 
+ *     Red Hat, Inc. - initial API and implementation 
+ ******************************************************************************/
+package org.jboss.tools.tests.installation;
+
+import org.eclipse.swtbot.eclipse.finder.SWTBotEclipseTestCase;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
+import org.junit.Test;
+
+/**
+ * @author mistria
+ */
+public class CheckForUpdatesTest extends SWTBotEclipseTestCase {
+
+	@Test
+	public void testCheckForUpdates() throws Exception {
+		bot.menu("Help").menu("Check for Updates");
+		this.bot.waitWhile(new ICondition() {
+			@Override
+			public boolean test() throws Exception {
+				return bot.activeShell().getText().equals("Contacting Software Sites");
+			}
+			
+			@Override
+			public void init(SWTBot bot) {
+			}
+			
+			@Override
+			public String getFailureMessage() {
+				return "Blocking while calculating deps";
+			}
+		}, 10 * 60000); // 5 minutes timeout
+		InstallTest.continueInstall(bot);
+	}
+}


Property changes on: trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/CheckForUpdatesTest.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/InstallFailureException.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/InstallFailureException.java	                        (rev 0)
+++ trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/InstallFailureException.java	2012-09-10 15:33:49 UTC (rev 43553)
@@ -0,0 +1,27 @@
+/******************************************************************************* 
+ * Copyright (c) 2012 Red Hat, Inc. 
+ * Distributed under license by Red Hat, Inc. All rights reserved. 
+ * This program is 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: 
+ *     Red Hat, Inc. - initial API and implementation 
+ ******************************************************************************/
+package org.jboss.tools.tests.installation;
+
+/**
+ * @author mistria
+ */
+public class InstallFailureException extends Exception {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1257171196315265973L;
+
+	public InstallFailureException(String details) {
+		super(details);
+	}
+
+}


Property changes on: trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/InstallFailureException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/InstallFromCentralTest.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/InstallFromCentralTest.java	2012-09-10 15:01:10 UTC (rev 43552)
+++ trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/InstallFromCentralTest.java	2012-09-10 15:33:49 UTC (rev 43553)
@@ -72,7 +72,6 @@
 		}
 		bot.button("Next >").click();
 		InstallTest.continueInstall(bot);
-		
 	}
 
 }

Modified: trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/InstallTest.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/InstallTest.java	2012-09-10 15:01:10 UTC (rev 43552)
+++ trunk/tests/plugins/org.jboss.tools.tests.installation/src/org/jboss/tools/tests/installation/InstallTest.java	2012-09-10 15:33:49 UTC (rev 43553)
@@ -14,7 +14,6 @@
 import junit.framework.Assert;
 
 import org.eclipse.swtbot.eclipse.finder.SWTBotEclipseTestCase;
-import org.eclipse.swtbot.eclipse.finder.SWTEclipseBot;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
 import org.eclipse.swtbot.swt.finder.SWTBot;
 import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
@@ -45,19 +44,7 @@
 		String site = System.getProperty("UPDATE_SITE");
 		Assert.assertNotNull("No site specified, set UPDATE_SITE system property first", site);
 		
-		try {
-			installFromSite(site);
-		} catch (Exception ex) {
-			String installDesc = this.bot.text().getText();
-			if (installDesc == null || installDesc.isEmpty()) {
-				throw new RuntimeException("Internal error", ex);
-			}
-			StringBuilder message = new StringBuilder();
-			message.append("Could not install from: " + site);
-			message.append(installDesc);
-			System.err.println(message.toString());
-			Assert.fail(message.toString());
-		}
+		installFromSite(site);
 	}
 
 	private void installFromSite(String site) {
@@ -100,66 +87,82 @@
 				return "Blocking while calculating deps";
 			}
 		}, 10 * 60000); // 5 minutes timeout
-		continueInstall(bot);
+		try {
+			continueInstall(bot);
+		} catch (InstallFailureException ex) {
+			StringBuilder message = new StringBuilder();
+			message.append("Could not install from: " + site);
+			message.append("\n");
+			message.append(ex.getMessage());
+		}
+		
 	}
 
-	public static void continueInstall(final SWTWorkbenchBot bot) {
-		bot.button("Next >").click();
-		bot.radio(0).click();
-		bot.button("Finish").click();	
-		// wait for Security pop-up, or install finished.
-		final SWTBotShell shell = bot.shell("Installing Software");
-		bot.waitWhile(new ICondition() {
-			
-			@Override
-			public boolean test() throws Exception {
-				return shell.isActive();
-			}
-			
-			@Override
-			public void init(SWTBot bot) {
-			}
-			
-			@Override
-			public String getFailureMessage() {
-				return null;
-			}
-		}, 20 * 60000); // 20 minutes_tino
-		if (bot.activeShell().getText().equals("Security Warning")) {
-			bot.button("OK").click();
-			System.err.println("OK clicked");
-			bot.waitUntil(new ICondition() {
+	public static void continueInstall(final SWTWorkbenchBot bot) throws InstallFailureException {
+		try {
+			bot.button("Next >").click();
+			bot.radio(0).click();
+			bot.button("Finish").click();	
+			// wait for Security pop-up, or install finished.
+			final SWTBotShell shell = bot.shell("Installing Software");
+			bot.waitWhile(new ICondition() {
+				
 				@Override
 				public boolean test() throws Exception {
-					try {
-						boolean stillOpen = bot.shell("Installing Software").isOpen();
-						System.err.println("still open? " + stillOpen);
-						return !stillOpen;
-					} catch (WidgetNotFoundException ex) {
-						System.err.println("no shell");
-						// Shell already closed
-						return true;
-					}
+					return shell.isActive();
 				}
-			
+				
 				@Override
 				public void init(SWTBot bot) {
 				}
-			
+				
 				@Override
 				public String getFailureMessage() {
 					return null;
 				}
-			}, 15 * 60000); // 15 more minutes
+			}, 20 * 60000); // 20 minutes_tino
+			if (bot.activeShell().getText().equals("Security Warning")) {
+				bot.button("OK").click();
+				System.err.println("OK clicked");
+				bot.waitUntil(new ICondition() {
+					@Override
+					public boolean test() throws Exception {
+						try {
+							boolean stillOpen = bot.shell("Installing Software").isOpen();
+							System.err.println("still open? " + stillOpen);
+							return !stillOpen;
+						} catch (WidgetNotFoundException ex) {
+							System.err.println("no shell");
+							// Shell already closed
+							return true;
+						}
+					}
+				
+					@Override
+					public void init(SWTBot bot) {
+					}
+				
+					@Override
+					public String getFailureMessage() {
+						return null;
+					}
+				}, 15 * 60000); // 15 more minutes
+			}
+			SWTBot restartShellBot = bot.shell("Software Updates").bot();
+			try {
+				// Eclipse 3.7.x => "Not now"
+				restartShellBot.button("Not Now").click(); // Don't restart in test, test executor will do it.
+			} catch (WidgetNotFoundException ex) {
+				// Eclipse 4.2 => "No"
+				restartShellBot.button("No").click();
+			}
+		} catch (Exception ex) {
+			String installDesc = bot.text().getText();
+			if (installDesc == null || installDesc.isEmpty()) {
+				throw new RuntimeException("Internal error", ex);
+			}
+			throw new InstallFailureException(installDesc);
 		}
-		SWTBot restartShellBot = bot.shell("Software Updates").bot();
-		try {
-			// Eclipse 3.7.x => "Not now"
-			restartShellBot.button("Not Now").click(); // Don't restart in test, test executor will do it.
-		} catch (WidgetNotFoundException ex) {
-			// Eclipse 4.2 => "No"
-			restartShellBot.button("No").click();
-		}
 	}
 
 

Modified: trunk/tests/scripts/installation-updates/testInstall.sh
===================================================================
--- trunk/tests/scripts/installation-updates/testInstall.sh	2012-09-10 15:01:10 UTC (rev 43552)
+++ trunk/tests/scripts/installation-updates/testInstall.sh	2012-09-10 15:33:49 UTC (rev 43553)
@@ -2,11 +2,12 @@
 
 usage() {
 	echo "Script to test installation"
-	echo "usage: $0 <eclipse_home> <file_containing_list_of_sites|repository_url>*"
+	echo "usage: $0 <eclipse_home> <file_containing_list_of_sites|repository_url|CHECK_FOR_UPDATES>*"
 	echo "   <eclipse_home>: an eclipse installation will be performed on"
 	echo "   <file_containing_list_of_sites> a file containing a list of p2-friendly URLs of repositories"
 	echo "                                   separated by spaces or line breaks"
 	echo "   <repository_url>: URL of a p2 repo to install from"
+	echo "   CHECK_FOR_UPDATES: will trigger the check for updates"
 }
 
 
@@ -18,7 +19,12 @@
 		#Found .xml suffix
 		install_central "$1"
 	else
-		install_repo "$1"
+		echo "$repoName" | grep CHECK_FOR_UPDATES
+		if [ "$?" -eq 0 ]; then
+			check_for_updates
+		else
+			install_repo "$1"
+		fi
 	fi 
 }
 	
@@ -77,6 +83,32 @@
 		fi
 }
 
+# Check for updates
+check_for_updates() {
+	echo "Checking for updates" 
+		report=TEST-install-$(date +%Y%m%d%H%M).xml
+			#Invoke tests
+		output=$(java \
+ -Dorg.eclipse.swtbot.search.timeout=10000 \
+ -Dusage_reporting_enabled=false \
+ -Xms256M -Xmx768M -XX:MaxPermSize=512M \
+ -jar plugins/org.eclipse.equinox.launcher_*.jar \
+ -application org.eclipse.swtbot.eclipse.junit4.headless.swtbottestapplication \
+ -testApplication org.eclipse.ui.ide.workbench \
+ -product $productName \
+ -data workspace/ \
+ formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,$report \
+ formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter \
+ -testPluginName org.jboss.tools.tests.installation \
+ -className org.jboss.tools.tests.installation.CheckForUpdatesTest \
+ -consoleLog -debug)
+		if [[ ! "$output" == *"Failures: 0, Errors: 0"* ]]; then
+			echo "Error while installing from " $site ". Read $report for details and see screenshots/"
+			popd
+			exit 1
+		fi
+}
+
 eclipse_home=$1
 shift
 



More information about the jbosstools-commits mailing list