You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by li...@apache.org on 2012/09/24 15:46:49 UTC
svn commit: r1389376 - in /incubator/ooo/trunk/test:
testcommon/source/org/openoffice/test/common/ testgui/data/pvt/
testgui/source/pvt/gui/
Author: liuzhe
Date: Mon Sep 24 13:46:48 2012
New Revision: 1389376
URL: http://svn.apache.org/viewvc?rev=1389376&view=rev
Log:
Add DataSheet. We can output some data into one MS Office Excel 2003 XML file. It can be opened with OpenOffice.
Add new PVT files without sensitive content legally.
Added:
incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/DataSheet.java (with props)
incubator/ooo/trunk/test/testgui/data/pvt/complex_300p.doc (with props)
incubator/ooo/trunk/test/testgui/data/pvt/complex_800p.odt (with props)
incubator/ooo/trunk/test/testgui/data/pvt/plain_50p.doc (with props)
Removed:
incubator/ooo/trunk/test/testgui/data/pvt/plain_200p.doc
Modified:
incubator/ooo/trunk/test/testgui/source/pvt/gui/Benchmark.java
Added: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/DataSheet.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/DataSheet.java?rev=1389376&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/DataSheet.java (added)
+++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/DataSheet.java Mon Sep 24 13:46:48 2012
@@ -0,0 +1,94 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+package org.openoffice.test.common;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * The class can be used to output data into an Microsoft Excel 2003 XML file.
+ * The file can be opened with OpenOffice or MS Office.
+ *
+ */
+public class DataSheet {
+ private File file = null;
+ private Document doc = null;
+ private Element tableEl = null;
+ private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
+ public DataSheet(File file, String sheetName) {
+ this.file = file;
+ if (sheetName == null)
+ sheetName = "data";
+ doc = FileUtil.newXML();
+ Element workBookEl = doc.createElement("Workbook");
+ workBookEl.setAttribute("xmlns", "urn:schemas-microsoft-com:office:spreadsheet");
+ workBookEl.setAttribute("xmlns:ss", "urn:schemas-microsoft-com:office:spreadsheet");
+ doc.appendChild(workBookEl);
+// Element stylesEl = doc.createElement("Styles");
+// workBookEl.appendChild(stylesEl);
+// Element styleEl = doc.createElement("Style");
+// stylesEl.appendChild(styleEl);
+// styleEl.setAttribute("ss:ID", "ce1");
+// Element numberFormatEl = doc.createElement("NumberFormat");
+// styleEl.appendChild(numberFormatEl);
+// numberFormatEl.setAttribute("ss:Format", "General Date");
+ Element worksheetEl = doc.createElement("Worksheet");
+ worksheetEl.setAttribute("ss:Name", sheetName);
+ workBookEl.appendChild(worksheetEl);
+ tableEl = doc.createElement("Table");
+ worksheetEl.appendChild(tableEl);
+ }
+
+ public void addRow(Object... datas) {
+ Element rowEl = doc.createElement("Row");
+ for (Object o : datas) {
+ Element cellEl = doc.createElement("Cell");
+ rowEl.appendChild(cellEl);
+ Element dataEl = doc.createElement("Data");
+ cellEl.appendChild(dataEl);
+ if (o instanceof Number) {
+ dataEl.setAttribute("ss:Type", "Number");
+ dataEl.setTextContent(o.toString());
+ } else if (o instanceof Boolean) {
+ dataEl.setAttribute("ss:Type", "Boolean");
+ dataEl.setTextContent(o.toString());
+ } else if (o instanceof Date) {
+ dataEl.setAttribute("ss:Type", "String");
+ dataEl.setTextContent(DATEFORMAT.format((Date) o));
+ } else {
+ dataEl.setAttribute("ss:Type", "String");
+ dataEl.setTextContent(o == null ? "" : o.toString());
+ }
+ }
+
+ tableEl.appendChild(rowEl);
+ FileUtil.storeXML(doc, file);
+ }
+
+ public static void main(String... args) {
+ File file = new File("/home/lz/test.xml");
+ new DataSheet(file, "Benchmark").addRow(1,2,"String String", new Date());
+ }
+}
Propchange: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/DataSheet.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/ooo/trunk/test/testgui/data/pvt/complex_300p.doc
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testgui/data/pvt/complex_300p.doc?rev=1389376&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/ooo/trunk/test/testgui/data/pvt/complex_300p.doc
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/ooo/trunk/test/testgui/data/pvt/complex_300p.doc
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/ooo/trunk/test/testgui/data/pvt/complex_800p.odt
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testgui/data/pvt/complex_800p.odt?rev=1389376&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/ooo/trunk/test/testgui/data/pvt/complex_800p.odt
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/ooo/trunk/test/testgui/data/pvt/plain_50p.doc
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testgui/data/pvt/plain_50p.doc?rev=1389376&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/ooo/trunk/test/testgui/data/pvt/plain_50p.doc
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: incubator/ooo/trunk/test/testgui/source/pvt/gui/Benchmark.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testgui/source/pvt/gui/Benchmark.java?rev=1389376&r1=1389375&r2=1389376&view=diff
==============================================================================
--- incubator/ooo/trunk/test/testgui/source/pvt/gui/Benchmark.java (original)
+++ incubator/ooo/trunk/test/testgui/source/pvt/gui/Benchmark.java Mon Sep 24 13:46:48 2012
@@ -32,23 +32,19 @@ import static testlib.gui.AppTool.*;
import static testlib.gui.UIMap.*;
import java.awt.Rectangle;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
import java.util.HashMap;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.openoffice.test.OpenOffice;
import org.openoffice.test.common.Condition;
+import org.openoffice.test.common.DataSheet;
import org.openoffice.test.common.GraphicsUtil;
import org.openoffice.test.common.Logger;
import org.openoffice.test.common.SystemUtil;
-import org.openoffice.test.common.Testspace;
public class Benchmark {
@@ -58,9 +54,9 @@ public class Benchmark {
@Rule
public TestName testname = new TestName();
- private static PrintStream result;
+ private static DataSheet result;
- private static final double INTERVAL = 0.01;
+ private static final double INTERVAL = 0.1;
public Benchmark() {
@@ -68,17 +64,13 @@ public class Benchmark {
@BeforeClass
public static void beforeClass() throws Exception {
- File resultFile = Testspace.getFile("output/pvt_gui_benchmark.csv");
- resultFile.getParentFile().mkdirs();
- result = new PrintStream(new FileOutputStream(resultFile));
+ result = new DataSheet(getFile("output/pvt_gui_benchmark.xml"), "benckmark");
OpenOffice.killAll();
-
- result.println("Scenario,No,Consumed Time,Memory(VSZ),Memory(RSS),Handles(Windows Only)");
+ result.addRow("Scenario", "No", "Consumed Time", "Memory(VSZ)", "Memory(RSS)", "Handles(Windows Only)");
}
@AfterClass
public static void afterClass() throws Exception {
- result.close();
app.close();
}
@@ -90,7 +82,7 @@ public class Benchmark {
private void addRecord(int i, long start, long end) {
HashMap<String, Object> perf = getPerfData();
- result.println(testname.getMethodName() + "," + i + "," + (end - start) + "," + perf.get("vsz") + "," + perf.get("rss") + "," + perf.get("handles"));
+ result.addRow(testname.getMethodName(), i, (end - start), perf.get("vsz"), perf.get("rss"), perf.get("handles"));
}
@Test
@@ -180,7 +172,7 @@ public class Benchmark {
@Test
public void loadFinishPlainDOC() {
- loadFinish("pvt/plain_200p.doc", "Page 1 / 23[0-9]{1}");
+ loadFinish("pvt/plain_50p.doc", "Page i / 5[0-9]{1}");
}
@Test
@@ -219,15 +211,13 @@ public class Benchmark {
}
@Test
- @Ignore
public void loadFinishComplexDOC() {
- loadFinish("pvt/sw_complex_100p.doc", "Page 1 / ");
+ loadFinish("pvt/complex_300p.doc", "Page 1 / 3[0-9]{2}");
}
@Test
- @Ignore
public void loadFinishComplexODT() {
- loadFinish("pvt/sw_complex_100p_odf1.2.odt", "Page 1 / ");
+ loadFinish("pvt/complex_800p.odt", "Page 1 / 8[0-9]{2}");
}
@Test
@@ -287,7 +277,7 @@ public class Benchmark {
@Test
public void savePlainDOC() {
- save("pvt/sw_plain_120p.doc", "Page 1 / ");
+ save("pvt/plain_50p.doc", "Page i / 5[0-9]{1}");
}
@Test
@@ -297,12 +287,12 @@ public class Benchmark {
@Test
public void saveComplexDOC() {
- save("pvt/plain_200p.doc", "Page 1 / 23[0-9]{1}");
+ save("pvt/complex_300p.doc", "Page 1 / 3[0-9]{2}");
}
@Test
public void saveComplexODT() {
- save("pvt/sw_complex_100p_odf1.2.odt", "Page 1 / ");
+ save("pvt/complex_800p.odt", "Page 1 / 8[0-9]{2}");
}
@Test