Permalink
Browse files

JBIDE-13627 Add zip support

  • Loading branch information...
1 parent c60039c commit 23e533c258d5c9471cba4fe916bc6aac08742496 @psrna psrna committed Feb 22, 2013
View
@@ -1,2 +1,3 @@
bin/
target/
+screenshots/
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * 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 junit.framework.Assert;
+
+import org.eclipse.swtbot.eclipse.finder.SWTBotEclipseTestCase;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * This is a bot scenario which performs install through p2 UI
+ * using the zip repository.
+ *
+ * @author Pavol Srna
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class InstallZipTest extends SWTBotEclipseTestCase {
+
+ /**
+ * System property expected to receive URL of a p2 ZIP repo to install
+ */
+ public static final String ZIP_PROPERTY = "UPDATE_SITE_ZIP";
+
+ @Test
+ public void testInstall() throws Exception {
+ String zip = System.getProperty("ZIP");
+ Assert.assertNotNull("No ZIP specified, set ZIP system property first", zip);
+
+ installFromZip(zip);
+ }
+
+
+ private void installFromZip(String zip) {
+ this.bot.menu("Help").menu("Install New Software...").click();
+ this.bot.shell("Install").bot().button("Add...").click();
+ this.bot.shell("Add Repository").activate().setFocus();
+ this.bot.text(1).setText("jar:file:" + zip + "!/");
+ this.bot.button("OK").click();
+ this.bot.shell("Install").activate().setFocus();
+ this.bot.waitWhile(new ICondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ return bot.tree().getAllItems()[0].getText().startsWith("Pending...");
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "Could not see categories in tree";
+ }
+ });
+
+ try{
+
+ SWTWorkbenchBot myBot = new SWTWorkbenchBot();
+ SWTBotShell errorShell = myBot.shell("Error Contacting Site");
+ errorShell.activate();
+
+ StringBuilder message = new StringBuilder();
+ message.append("Could not install from: " + zip);
+ message.append("\n");
+ message.append(errorShell.bot().label(1).getText());
+
+ errorShell.bot().button("No").click();
+
+ fail(message.toString());
+
+ }catch(WidgetNotFoundException ex){
+ //do nothing
+ }
+
+
+ this.bot.button("Select All").click();
+
+ this.bot.button("Next >").click();
+ this.bot.waitUntil(new ICondition() {
+ @Override
+ public boolean test() throws Exception {
+ return bot.button("Cancel").isEnabled();
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "Blocking while calculating deps";
+ }
+ }, 10 * 60000); // 10 minutes timeout
+ try {
+ InstallTest.continueInstall(bot, "Installing Software");
+ } catch (InstallFailureException ex) {
+ StringBuilder message = new StringBuilder();
+ message.append("Could not install from: " + zip);
+ message.append("\n");
+ message.append(ex.getMessage());
+
+ fail(message.toString());
+ }
+
+ }
+
+
+
+
+
+}
@@ -1,4 +1,6 @@
import org.apache.tools.ant.taskdefs.Java;
+import org.apache.tools.ant.taskdefs.Get;
+import groovy.util.AntBuilder;
import java.text.SimpleDateFormat;
void usage() {
@@ -21,6 +23,8 @@ void installUrl(String repoUrl, File eclipseHome, String product) {
if (repoUrl.endsWith(".xml")) {
installFromCentral(repoUrl, eclipseHome, product);
+ } else if (repoUrl.endsWith(".zip")) {
+ installZipRepo(repoUrl, eclipseHome, product);
} else if (repoUrl.equals("CHECK_FOR_UPDATES")) {
checkForUpdates(eclipseHome, product);
} else {
@@ -29,6 +33,33 @@ void installUrl(String repoUrl, File eclipseHome, String product) {
}
+void installZipRepo(String repoUrl, File eclipseHome, String productName){
+
+ String additionalVMArgs = "";
+
+ if(new File(repoUrl).isFile()){
+ //local file, no need to download
+ additionalVMArgs = "-DZIP=" + repoUrl;
+ }else{
+ // wget zip file
+ println("DOWNLOAD FIRST: " + repoUrl);
+
+ String zipName = repoUrl.substring(repoUrl.lastIndexOf("/")+1);
+ File zip = new File("./" + zipName);
+
+ new AntBuilder().get(
+ src: repoUrl,
+ dest: zip.getAbsolutePath());
+
+ additionalVMArgs = "-DZIP=" + zip.getAbsolutePath();
+ }
+
+ // run install zip test
+ println("Installing content from " + repoUrl);
+ runSWTBotInstallRoutine(eclipseHome, productName, additionalVMArgs, "org.jboss.tools.tests.installation.InstallZipTest");
+
+}
+
//Takes repo URL as single parameter
void installRepo(String repoUrl, File eclipseHome, String productName) {
println("Installing content from " + repoUrl);
@@ -174,9 +205,14 @@ args[1..-1].each {
}
sites.each {
if (new File(it).isFile()) {
- new File(it).eachLine({ line ->
- installUrl(line, eclipseHome, productName);
- });
+
+ if(it.endsWith(".zip")){
+ installZipRepo(it, eclipseHome, productName);
+ }else{
+ new File(it).eachLine({ line ->
+ installUrl(line, eclipseHome, productName);
+ });
+ }
} else {
installUrl(it, eclipseHome, productName);
}

0 comments on commit 23e533c

Please sign in to comment.