Return-Path: X-Original-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 264EBDC8F for ; Thu, 25 Oct 2012 02:02:05 +0000 (UTC) Received: (qmail 69590 invoked by uid 500); 25 Oct 2012 02:02:04 -0000 Delivered-To: apmail-incubator-ooo-commits-archive@incubator.apache.org Received: (qmail 69556 invoked by uid 500); 25 Oct 2012 02:02:04 -0000 Mailing-List: contact ooo-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ooo-dev@incubator.apache.org Delivered-To: mailing list ooo-commits@incubator.apache.org Received: (qmail 69549 invoked by uid 99); 25 Oct 2012 02:02:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2012 02:02:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2012 02:02:01 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9BE22238896F; Thu, 25 Oct 2012 02:01:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1401949 - /incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java Date: Thu, 25 Oct 2012 02:01:17 -0000 To: ooo-commits@incubator.apache.org From: liuzhe@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121025020117.9BE22238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: liuzhe Date: Thu Oct 25 02:01:17 2012 New Revision: 1401949 URL: http://svn.apache.org/viewvc?rev=1401949&view=rev Log: Use testspace/install as the default directory to search OpenOffice Modified: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java Modified: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java?rev=1401949&r1=1401948&r2=1401949&view=diff ============================================================================== --- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java (original) +++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java Thu Oct 25 02:01:17 2012 @@ -30,7 +30,7 @@ import java.util.logging.Level; /** * Install openoffice from installation package before running test - * + * */ public class Installer implements Runnable { private static Logger log = Logger.getLogger(Installer.class); @@ -38,7 +38,7 @@ public class Installer implements Runnab File downloadUrl = Testspace.getFile("download/url"); File installDir = Testspace.getFile("install"); File installTempDir = Testspace.getFile("install_temp"); - + @Override public void run() { String prop = System.getProperty("singleton"); @@ -61,11 +61,11 @@ public class Installer implements Runnab throw new RuntimeException(MessageFormat.format("{0} can not be downloaded!", prop)); FileUtil.writeStringToFile(downloadUrl, prop); } else { - boolean[] skipped = {false}; + boolean[] skipped = { false }; packFile = FileUtil.download(prop, downloadDir, true, skipped); if (packFile == null) throw new RuntimeException(MessageFormat.format("{0} can not be downloaded!", prop)); - if (("true".equalsIgnoreCase(onlyNewProp) || "yes".equalsIgnoreCase(onlyNewProp)) && skipped[0]) + if (("true".equalsIgnoreCase(onlyNewProp) || "yes".equalsIgnoreCase(onlyNewProp)) && skipped[0]) throw new RuntimeException(MessageFormat.format("{0} is old. Test is allowed only on new build.", prop)); } } else { @@ -73,52 +73,52 @@ public class Installer implements Runnab if (!packFile.isFile()) throw new RuntimeException(MessageFormat.format("{0} does not exists or is not a file!", prop)); } - + try { FileUtil.deleteFile(installDir); FileUtil.deleteFile(installTempDir); installTempDir.mkdirs(); if (packFile.getName().endsWith(".gz")) { StringBuffer output = new StringBuffer(); - if (SystemUtil.exec(new String[]{"tar", "-zxpf", packFile.getAbsolutePath(), "-C", installTempDir.getAbsolutePath()}, output) != 0) - throw new RuntimeException(MessageFormat.format("{0} can not be installed! Cause: {1}" , packFile, output)); + if (SystemUtil.exec(new String[] { "tar", "-zxpf", packFile.getAbsolutePath(), "-C", installTempDir.getAbsolutePath() }, output) != 0) + throw new RuntimeException(MessageFormat.format("{0} can not be installed! Cause: {1}", packFile, output)); } else { if (!FileUtil.unzip(packFile, installTempDir)) throw new RuntimeException(MessageFormat.format("{0} can not be installed!", packFile)); } - // On windows, if path is too long, openoffice can not be started. + // On windows, if path is too long, openoffice can not be + // started. File[] files = installTempDir.listFiles(); if (files != null && files.length == 1 && files[0].isDirectory()) { files[0].renameTo(installDir); } - File sofficeBin = FileUtil.findFile(installDir, "soffice.bin", false); - if (sofficeBin == null) - throw new RuntimeException(MessageFormat.format("{0} is not a valid openoffice installation package!" , packFile)); - try { - String openofficeHome = sofficeBin.getParentFile().getParentFile().getCanonicalPath(); - log.log(Level.INFO, MessageFormat.format("{0} is installed to {1}", prop, openofficeHome)); - System.setProperty("openoffice.home", openofficeHome); - } catch (IOException e) { - //ignore, never occurs - } - + System.setProperty("openoffice.home", installDir.getAbsolutePath()); } finally { FileUtil.deleteFile(installTempDir); } } - - prop = System.getProperty("openoffice.home"); - if (!FileUtil.fileExists(prop)) { - throw new RuntimeException("No OpenOffice is found!"); - } - - String[] jars = {"juh.jar", "unoil.jar", "ridl.jar", "jurt.jar"}; - for (String jar : jars) { - File file = FileUtil.findFile(prop, jar); - if (file != null) - addToClassPath(file); - } - + + prop = System.getProperty("openoffice.home", installDir.getAbsolutePath()); + File sofficeBin = FileUtil.findFile(new File(prop), "soffice.bin", false); + if (sofficeBin == null) + throw new RuntimeException(MessageFormat.format( + "No valid OpenOffice is found in {0}! Use system property openoffice.home to specify a valid OpenOffice installation directory.", prop)); + try { + prop = sofficeBin.getParentFile().getParentFile().getCanonicalPath(); + System.setProperty("openoffice.home", prop); + log.log(Level.INFO, MessageFormat.format("OpenOffice in {0} will be tested.", prop)); + } catch (IOException e) { + // ignore, never occurs + } + + String[] jars = { "juh.jar", "unoil.jar", "ridl.jar", "jurt.jar" }; + for (String jar : jars) { + File file = FileUtil.findFile(prop, jar); + + if (file != null) + addToClassPath(file); + } + } public static boolean addToClassPath(File file) { @@ -135,7 +135,7 @@ public class Installer implements Runnab return false; } - + public static void main(String... args) { new Installer().run(); }