Conversion.java (9b5f68a3) | Conversion.java (329fd865) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 10 unchanged lines hidden (view full) --- 19 * 20 *************************************************************/ 21 22package pvt.uno; 23 24import static org.openoffice.test.common.Testspace.*; 25 26import java.io.File; | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 10 unchanged lines hidden (view full) --- 19 * 20 *************************************************************/ 21 22package pvt.uno; 23 24import static org.openoffice.test.common.Testspace.*; 25 26import java.io.File; |
27import java.io.FileOutputStream; 28import java.io.PrintStream; | |
29 30import org.junit.After; 31import org.junit.AfterClass; 32import org.junit.Before; 33import org.junit.BeforeClass; 34import org.junit.Rule; 35import org.junit.Test; 36import org.junit.runner.RunWith; 37import org.openoffice.test.OpenOffice; | 27 28import org.junit.After; 29import org.junit.AfterClass; 30import org.junit.Before; 31import org.junit.BeforeClass; 32import org.junit.Rule; 33import org.junit.Test; 34import org.junit.runner.RunWith; 35import org.openoffice.test.OpenOffice; |
36import org.openoffice.test.common.DataSheet; |
|
38import org.openoffice.test.common.FileProvider; 39import org.openoffice.test.common.FileProvider.FileFilter; 40import org.openoffice.test.common.FileProvider.FileRepeat; 41import org.openoffice.test.common.FileProvider.FileRepos; 42import org.openoffice.test.common.FileUtil; 43import org.openoffice.test.common.Logger; | 37import org.openoffice.test.common.FileProvider; 38import org.openoffice.test.common.FileProvider.FileFilter; 39import org.openoffice.test.common.FileProvider.FileRepeat; 40import org.openoffice.test.common.FileProvider.FileRepos; 41import org.openoffice.test.common.FileUtil; 42import org.openoffice.test.common.Logger; |
44import org.openoffice.test.common.Testspace; | |
45import org.openoffice.test.uno.UnoApp; 46 47import com.sun.star.beans.PropertyValue; 48import com.sun.star.document.MacroExecMode; 49import com.sun.star.lang.XComponent; 50import com.sun.star.uno.UnoRuntime; 51import com.sun.star.util.XCloseable; 52 53 54@RunWith(FileProvider.class) 55public class Conversion { 56 57 @Rule 58 public Logger log = Logger.getLogger(this); 59 60 @FileRepos 61 public static String repos = System.getProperty("conversion.repos", getDataPath("conversion_pvt")); 62 @FileFilter | 43import org.openoffice.test.uno.UnoApp; 44 45import com.sun.star.beans.PropertyValue; 46import com.sun.star.document.MacroExecMode; 47import com.sun.star.lang.XComponent; 48import com.sun.star.uno.UnoRuntime; 49import com.sun.star.util.XCloseable; 50 51 52@RunWith(FileProvider.class) 53public class Conversion { 54 55 @Rule 56 public Logger log = Logger.getLogger(this); 57 58 @FileRepos 59 public static String repos = System.getProperty("conversion.repos", getDataPath("conversion_pvt")); 60 @FileFilter |
63 public static String filter = System.getProperty("conversion.filter", "-f .*\\.((doc)|(dot)|(odt)|(ott))$ writer_pdf_Export pdf " 64 + "-f .*\\.((xls)|(xlt)|(ods)|(ots))$ calc_pdf_Export pdf " 65 + "-f .*\\.((ppt)|(ppt)|(odp)|(otp))$ impress_pdf_Export pdf " 66 + "-f .*\\.((doc)|(dot)|(docx)|(docm)|(dotx)|(dotm))$ writer8 odt " 67 + "-f .*\\.((xls)|(xlt)|(xlsx)|(xltx)|(xlsm)|(xltm))$ calc8 ods " 68 + "-f .*\\.((ppt)|(pot)|(pptx)|(pptm)|(potm)|(potx))$ impress8 odp " 69 + "-f .*\\.((odt)|(ott))$ 'MS Word 97' doc " 70 + "-f .*\\.((ods)|(ots))$ 'MS Excel 97' xls " 71 + "-f .*\\.((odp)|(otp))$ 'MS PowerPoint 97' ppt"); | 61 public static String filter = System.getProperty("conversion.filter", 62 "-f .*(doc|dot|odt|ott)$ writer_pdf_Export pdf " 63 + "-f .*(xls|xlt|ods|ots)$ calc_pdf_Export pdf " 64 + "-f .*(ppt|ppt|odp|otp)$ impress_pdf_Export pdf " 65 + "-f .*(doc|dot|docx|docm|dotx|dotm)$ writer8 odt " 66 + "-f .*(xls|xlt|xlsx|xltx|xlsm|xltm)$ calc8 ods " 67 + "-f .*(ppt|pot|pptx|pptm|potm|potx)$ impress8 odp " 68 + "-f .*(odt|ott)$ 'MS Word 97' doc " 69 + "-f .*(ods|ots)$ 'MS Excel 97' xls " 70 + "-f .*(odp|otp)$ 'MS PowerPoint 97' ppt"); |
72 73 @FileRepeat 74 public static int repeat = Integer.parseInt(System.getProperty("conversion.repeat", "8")); 75 76 public static String clean = System.getProperty("conversion.clean", "file"); 77 | 71 72 @FileRepeat 73 public static int repeat = Integer.parseInt(System.getProperty("conversion.repeat", "8")); 74 75 public static String clean = System.getProperty("conversion.clean", "file"); 76 |
78 private static UnoApp app = new UnoApp(); | 77 private static OpenOffice aoo = new OpenOffice(); |
79 | 78 |
80 private static PrintStream result; | 79 private static UnoApp app = null; |
81 | 80 |
81 private static DataSheet result; 82 |
|
82 private static int counter = 0; 83 84 @BeforeClass 85 public static void beforeClass() throws Exception { | 83 private static int counter = 0; 84 85 @BeforeClass 86 public static void beforeClass() throws Exception { |
86 //Disable automation 87 OpenOffice.getDefault().setAutomationPort(-1); 88 OpenOffice.getDefault().addArgs("-invisible", "-conversionmode", "-headless", "-hidemenu"); 89 90 File resultFile = Testspace.getFile("output/conversion.csv"); 91 resultFile.getParentFile().mkdirs(); 92 result = new PrintStream(new FileOutputStream(resultFile)); 93 result.println("File,Scenario,File Size,Time Consumed After Closing,Time Consumed After Saving,Time Consumed After Loading"); | 87 aoo.setUnoUrl(OpenOffice.DEFAULT_UNO_URL); 88 aoo.addArgs("-invisible", "-conversionmode", "-hidemenu"); 89 app = new UnoApp(aoo); 90 result = new DataSheet(getFile("output/pvt_uno_conversion.xml"), "conversion"); 91 result.addRow("File","Scenario","File Size","Time Consumed After Closing","Time Consumed After Saving","Time Consumed After Loading"); |
94 } 95 96 @AfterClass 97 public static void afterClass() throws Exception { | 92 } 93 94 @AfterClass 95 public static void afterClass() throws Exception { |
98 result.close(); | |
99 app.close(); 100 } 101 102 private String sourcePath = null; 103 private String targetFilterName = null; 104 private String targetExtName = null; 105 106 private File sourceFile = null; --- 27 unchanged lines hidden (view full) --- 134 String pathRepos = new File(repos).getCanonicalPath().replace("\\", "/") + "/"; 135 sourceFileId = pathSource.replace(pathRepos, ""); 136 log.info("Start [File: " + sourceFileId + "] [Size: " + (sourceFile.length() / 1024) + "KB] [Scenario: " + scenario + "]"); 137 app.start(); 138 } 139 140 @After 141 public void after() throws Exception{ | 96 app.close(); 97 } 98 99 private String sourcePath = null; 100 private String targetFilterName = null; 101 private String targetExtName = null; 102 103 private File sourceFile = null; --- 27 unchanged lines hidden (view full) --- 131 String pathRepos = new File(repos).getCanonicalPath().replace("\\", "/") + "/"; 132 sourceFileId = pathSource.replace(pathRepos, ""); 133 log.info("Start [File: " + sourceFileId + "] [Size: " + (sourceFile.length() / 1024) + "KB] [Scenario: " + scenario + "]"); 134 app.start(); 135 } 136 137 @After 138 public void after() throws Exception{ |
142 result.println(sourceFileId + "," + scenario + "," + sourceFile.length() + "," + closeTime + "," + saveTime + "," + loadTime); | 139 result.addRow(sourceFileId, scenario, sourceFile.length(), closeTime, saveTime, loadTime); |
143 log.info("Result [After Closing: " + closeTime + "] [After Saving: " + saveTime + "] [After Loading: " + loadTime + "]"); 144 if (closeTime < 0) { 145 app.close(); 146 } else if ("file".equalsIgnoreCase(clean) && counter % repeat == 0) { 147 app.close(); 148 } 149 } 150 --- 28 unchanged lines hidden --- | 140 log.info("Result [After Closing: " + closeTime + "] [After Saving: " + saveTime + "] [After Loading: " + loadTime + "]"); 141 if (closeTime < 0) { 142 app.close(); 143 } else if ("file".equalsIgnoreCase(clean) && counter % repeat == 0) { 144 app.close(); 145 } 146 } 147 --- 28 unchanged lines hidden --- |