poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1828179 - in /poi/trunk/src/ooxml/java/org/apache/poi: dev/OOXMLPrettyPrint.java util/OOXMLLite.java
Date Mon, 02 Apr 2018 17:16:08 GMT
Author: centic
Date: Mon Apr  2 17:16:07 2018
New Revision: 1828179

URL: http://svn.apache.org/viewvc?rev=1828179&view=rev
Log:
OOXMLLite: IDE warnings and add an additional listener to print out progress during running
tests

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/dev/OOXMLPrettyPrint.java
    poi/trunk/src/ooxml/java/org/apache/poi/util/OOXMLLite.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/dev/OOXMLPrettyPrint.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/dev/OOXMLPrettyPrint.java?rev=1828179&r1=1828178&r2=1828179&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/dev/OOXMLPrettyPrint.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/dev/OOXMLPrettyPrint.java Mon Apr  2 17:16:07
2018
@@ -84,25 +84,19 @@ public class OOXMLPrettyPrint {
 	}
 
     private static void handleFile(File file, File outFile) throws ZipException,
-            IOException, TransformerException, ParserConfigurationException {
+            IOException, ParserConfigurationException {
         System.out.println("Reading zip-file " + file + " and writing pretty-printed XML
to " + outFile);
 
-        ZipFile zipFile = ZipHelper.openZipFile(file);
-		try {
-		    ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(outFile)));
-		    try {
-		        new OOXMLPrettyPrint().handle(zipFile, out);
-		    } finally {
-		        out.close();
-		    }
+		try (ZipFile zipFile = ZipHelper.openZipFile(file)) {
+			try (ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(outFile))))
{
+				new OOXMLPrettyPrint().handle(zipFile, out);
+			}
 		} finally {
-		    zipFile.close();
-
-		    System.out.println();
+			System.out.println();
 		}
     }
 
-	private void handle(ZipFile file, ZipOutputStream out) throws IOException, TransformerException
{
+	private void handle(ZipFile file, ZipOutputStream out) throws IOException {
         Enumeration<? extends ZipEntry> entries = file.entries();
         while(entries.hasMoreElements()) {
             ZipEntry entry = entries.nextElement();

Modified: poi/trunk/src/ooxml/java/org/apache/poi/util/OOXMLLite.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/util/OOXMLLite.java?rev=1828179&r1=1828178&r2=1828179&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/util/OOXMLLite.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/util/OOXMLLite.java Mon Apr  2 17:16:07 2018
@@ -40,6 +40,7 @@ import junit.framework.TestCase;
 
 import org.junit.Test;
 import org.junit.internal.TextListener;
+import org.junit.runner.Description;
 import org.junit.runner.JUnitCore;
 import org.junit.runner.Result;
 
@@ -73,7 +74,14 @@ public final class OOXMLLite {
         _ooxmlJar = new File(ooxmlJar);
     }
 
-    public static void main(String[] args) throws IOException, ClassNotFoundException {
+    public static void main(String[] args) throws IOException {
+        System.out.println("Free memory (bytes): " + 
+                Runtime.getRuntime().freeMemory());
+        long maxMemory = Runtime.getRuntime().maxMemory();
+        System.out.println("Maximum memory (bytes): " + 
+        (maxMemory == Long.MAX_VALUE ? "no limit" : maxMemory));
+        System.out.println("Total memory (bytes): " + 
+                Runtime.getRuntime().totalMemory());
 
         String dest = null, test = null, ooxml = null;
 
@@ -94,7 +102,7 @@ public final class OOXMLLite {
         builder.build();
     }
 
-    void build() throws IOException, ClassNotFoundException {
+    void build() throws IOException {
         List<Class<?>> lst = new ArrayList<>();
         //collect unit tests
         String exclude = StringUtil.join("|",
@@ -153,10 +161,21 @@ public final class OOXMLLite {
         System.out.println("Collecting unit tests from " + _testDir);
         collectTests(_testDir, _testDir, lst, ".+.class$", ".+(" + exclude + ").class");
         System.out.println("Found " + lst.size() + " classes");
-        
+
         //run tests
         JUnitCore jUnitCore = new JUnitCore();
-        jUnitCore.addListener(new TextListener(System.out));
+        jUnitCore.addListener(new TextListener(System.out) {
+            private int count;
+            @Override
+            public void testStarted(Description description) {
+                count++;
+                if(count % 100 == 0) {
+                    System.out.println();
+                    System.out.println(count + "/" + lst.size() + ": " + description.getDisplayName());
+                }
+                super.testStarted(description);
+            }
+        });
         Result result = jUnitCore.run(lst.toArray(new Class<?>[lst.size()]));
         if (!result.wasSuccessful()) {
             throw new RuntimeException("Tests did not succeed, cannot build ooxml-lite jar");
@@ -227,8 +246,7 @@ public final class OOXMLLite {
      * @param out   output
      * @param ptrn  the pattern (regexp) to filter found files
      */
-    private static void collectTests(File root, File arg, List<Class<?>> out,
String ptrn, String exclude)
-    throws ClassNotFoundException {
+    private static void collectTests(File root, File arg, List<Class<?>> out,
String ptrn, String exclude) {
         if (arg.isDirectory()) {
             File files[] = arg.listFiles();
             if (files != null) {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message