Conversion.java (3e7cc3ec) Conversion.java (5f863819)
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

--- 23 unchanged lines hidden (view full) ---

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;
38import org.openoffice.test.common.FileProvider;
39import org.openoffice.test.common.FileProvider.FileFilter;
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

--- 23 unchanged lines hidden (view full) ---

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;
38import org.openoffice.test.common.FileProvider;
39import org.openoffice.test.common.FileProvider.FileFilter;
40import 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;
43import org.openoffice.test.common.Testspace;
44import org.openoffice.test.uno.UnoApp;
45
46import com.sun.star.beans.PropertyValue;
47import com.sun.star.document.MacroExecMode;

--- 7 unchanged lines hidden (view full) ---

55
56 @Rule
57 public Logger log = Logger.getLogger(this);
58
59 @FileRepos
60 public static String repos = getDataFile("pvt_conversion").getAbsolutePath();
61
62 @FileFilter
41import org.openoffice.test.common.FileProvider.FileRepos;
42import org.openoffice.test.common.FileUtil;
43import 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;

--- 7 unchanged lines hidden (view full) ---

56
57 @Rule
58 public Logger log = Logger.getLogger(this);
59
60 @FileRepos
61 public static String repos = getDataFile("pvt_conversion").getAbsolutePath();
62
63 @FileFilter
63 public static String filter = "-f .*\\.((doc)|(dot)|(odt)|(ott))$ writer_pdf_Export pdf "
64 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 "
65 + "-f .*\\.((xls)|(xlt)|(ods)|(ots))$ calc_pdf_Export pdf "
66 + "-f .*\\.((ppt)|(ppt)|(odp)|(otp))$ impress_pdf_Export pdf "
67 + "-f .*\\.((doc)|(dot)|(docx)|(docm)|(dotx)|(dotm))$ writer8 odt "
68 + "-f .*\\.((xls)|(xlt)|(xlsx)|(xltx)|(xlsm)|(xltm))$ calc8 ods "
69 + "-f .*\\.((ppt)|(pot)|(pptx)|(pptm)|(potm)|(potx))$ impress8 odp "
70 + "-f .*\\.((odt)|(ott))$ 'MS Word 97' doc "
71 + "-f .*\\.((ods)|(ots))$ 'MS Excel 97' xls "
71 + "-f .*\\.((odp)|(otp))$ 'MS PowerPoint 97' ppt";
72 + "-f .*\\.((odp)|(otp))$ 'MS PowerPoint 97' ppt");
72
73
74 @FileRepeat
75 public static int repeat = 8;
76
73 private static UnoApp app = new UnoApp();
74
75 private static PrintStream result;
76
77 private static UnoApp app = new UnoApp();
78
79 private static PrintStream result;
80
81 private static int counter = 0;
82
77 @BeforeClass
78 public static void beforeClass() throws Exception {
79 //Disable automation
80 OpenOffice.getDefault().setAutomationPort(-1);
81 OpenOffice.getDefault().addArgs("-invisible", "-conversionmode", "-headless", "-hidemenu");
82
83 File resultFile = Testspace.getFile("output/conversion.csv");
84 resultFile.getParentFile().mkdirs();

--- 22 unchanged lines hidden (view full) ---

107 private long saveTime = -1;
108 private long closeTime = -1;
109
110 public Conversion(String sourcePath, String targetFilterName, String targetExtName) {
111 super();
112 this.sourcePath = sourcePath;
113 this.targetFilterName = targetFilterName;
114 this.targetExtName = targetExtName;
83 @BeforeClass
84 public static void beforeClass() throws Exception {
85 //Disable automation
86 OpenOffice.getDefault().setAutomationPort(-1);
87 OpenOffice.getDefault().addArgs("-invisible", "-conversionmode", "-headless", "-hidemenu");
88
89 File resultFile = Testspace.getFile("output/conversion.csv");
90 resultFile.getParentFile().mkdirs();

--- 22 unchanged lines hidden (view full) ---

113 private long saveTime = -1;
114 private long closeTime = -1;
115
116 public Conversion(String sourcePath, String targetFilterName, String targetExtName) {
117 super();
118 this.sourcePath = sourcePath;
119 this.targetFilterName = targetFilterName;
120 this.targetExtName = targetExtName;
121 counter++;
115 }
116
117 @Before
118 public void before() throws Exception {
119 sourceFile = prepareDataFile(sourcePath);
120 sourceFileUrl = FileUtil.getUrl(this.sourceFile);
121 targetFile = getFile("classtemp/" + sourceFile.getName()+ "." + targetExtName);
122 targetFileUrl = FileUtil.getUrl(this.targetFile);

--- 4 unchanged lines hidden (view full) ---

127 log.info("Start [File: " + sourceFileId + "] [Size: " + (sourceFile.length() / 1024) + "KB] [Scenario: " + scenario + "]");
128 app.start();
129 }
130
131 @After
132 public void after() throws Exception{
133 result.println(sourceFileId + "," + scenario + "," + closeTime + "," + saveTime + "," + loadTime);
134 log.info("Result [After Closing: " + closeTime + "] [After Saving: " + saveTime + "] [After Loading: " + loadTime + "]");
122 }
123
124 @Before
125 public void before() throws Exception {
126 sourceFile = prepareDataFile(sourcePath);
127 sourceFileUrl = FileUtil.getUrl(this.sourceFile);
128 targetFile = getFile("classtemp/" + sourceFile.getName()+ "." + targetExtName);
129 targetFileUrl = FileUtil.getUrl(this.targetFile);

--- 4 unchanged lines hidden (view full) ---

134 log.info("Start [File: " + sourceFileId + "] [Size: " + (sourceFile.length() / 1024) + "KB] [Scenario: " + scenario + "]");
135 app.start();
136 }
137
138 @After
139 public void after() throws Exception{
140 result.println(sourceFileId + "," + scenario + "," + closeTime + "," + saveTime + "," + loadTime);
141 log.info("Result [After Closing: " + closeTime + "] [After Saving: " + saveTime + "] [After Loading: " + loadTime + "]");
135 if (closeTime < 0) {
142 if (counter % 8 == 0) {
136 app.close();
137 }
138 }
139
140 private PropertyValue propertyValue(String name, Object value) {
141 PropertyValue p = new PropertyValue();
142 p.Name = name;
143 p.Value= value;

--- 14 unchanged lines hidden (view full) ---

158 app.saveDocumentToURL(doc, targetFileUrl,
159 propertyValue( "FilterName", targetFilterName),
160 propertyValue( "Overwrite", true));
161 saveTime = System.currentTimeMillis() - start;
162 XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, doc);
163 xCloseable.close(true);
164 closeTime = System.currentTimeMillis() - start;
165 }
143 app.close();
144 }
145 }
146
147 private PropertyValue propertyValue(String name, Object value) {
148 PropertyValue p = new PropertyValue();
149 p.Name = name;
150 p.Value= value;

--- 14 unchanged lines hidden (view full) ---

165 app.saveDocumentToURL(doc, targetFileUrl,
166 propertyValue( "FilterName", targetFilterName),
167 propertyValue( "Overwrite", true));
168 saveTime = System.currentTimeMillis() - start;
169 XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, doc);
170 xCloseable.close(true);
171 closeTime = System.currentTimeMillis() - start;
172 }
173
166}
174}