poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1765731 - in /poi/trunk/src/ooxml/testcases/org/apache/poi: openxml4j/opc/TestContentType.java xssf/extractor/TestXSSFExcelExtractor.java xwpf/extractor/TestXWPFWordExtractor.java
Date Wed, 19 Oct 2016 23:04:39 GMT
Author: onealj
Date: Wed Oct 19 23:04:39 2016
New Revision: 1765731

URL: http://svn.apache.org/viewvc?rev=1765731&view=rev
Log:
Eclipse automated refactor/cleanup: convert for loops to for-each loops

Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExcelExtractor.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java?rev=1765731&r1=1765730&r2=1765731&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java Wed Oct
19 23:04:39 2016
@@ -44,8 +44,8 @@ public final class TestContentType exten
 		String[] contentTypesToTest = new String[] { "text/xml",
 				"application/pgp-key", "application/vnd.hp-PCLXL",
 				"application/vnd.lotus-1-2-3" };
-		for (int i = 0; i < contentTypesToTest.length; ++i) {
-			new ContentType(contentTypesToTest[i]);
+		for (String contentType : contentTypesToTest) {
+			new ContentType(contentType);
 		}
 	}
 
@@ -72,14 +72,13 @@ public final class TestContentType exten
 				"text[/xml", "text]/xml", "text?/xml", "tex=t/xml",
 				"te{xt/xml", "tex}t/xml", "te xt/xml",
 				"text" + (char) 9 + "/xml", "text xml", " text/xml " };
-		for (int i = 0; i < contentTypesToTest.length; ++i) {
+		for (String contentType : contentTypesToTest) {
 			try {
-				new ContentType(contentTypesToTest[i]);
+				new ContentType(contentType);
 			} catch (InvalidFormatException e) {
 				continue;
 			}
-			fail("Must have fail for content type: '" + contentTypesToTest[i]
-					+ "' !");
+			fail("Must have fail for content type: '" + contentType + "' !");
 		}
 	}
 
@@ -110,14 +109,13 @@ public final class TestContentType exten
                 "mail/toto;titi = tata", // spaces not allowed
                 "text/\u0080" // characters above ASCII are not allowed
         };
-		for (int i = 0; i < contentTypesToTest.length; ++i) {
+		for (String contentType : contentTypesToTest) {
 			try {
-				new ContentType(contentTypesToTest[i]);
+				new ContentType(contentType);
 			} catch (InvalidFormatException e) {
 				continue;
 			}
-			fail("Must have fail for content type: '" + contentTypesToTest[i]
-					+ "' !");
+			fail("Must have fail for content type: '" + contentType + "' !");
 		}
 	}
 
@@ -128,14 +126,13 @@ public final class TestContentType exten
 	 */
 	public void testContentTypeCommentFailure() {
 		String[] contentTypesToTest = new String[] { "text/xml(comment)" };
-		for (int i = 0; i < contentTypesToTest.length; ++i) {
+		for (String contentType : contentTypesToTest) {
 			try {
-				new ContentType(contentTypesToTest[i]);
+				new ContentType(contentType);
 			} catch (InvalidFormatException e) {
 				continue;
 			}
-			fail("Must have fail for content type: '" + contentTypesToTest[i]
-					+ "' !");
+			fail("Must have fail for content type: '" + contentType + "' !");
 		}
 	}
 	

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExcelExtractor.java?rev=1765731&r1=1765730&r2=1765731&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExcelExtractor.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExcelExtractor.java
Wed Oct 19 23:04:39 2016
@@ -133,10 +133,8 @@ public class TestXSSFExcelExtractor exte
 		
 		POITextExtractor[] extractors =
 			new POITextExtractor[] { ooxmlExtractor, ole2Extractor };
-		for (int i = 0; i < extractors.length; i++) {
-			@SuppressWarnings("resource")
-            POITextExtractor extractor = extractors[i];
-			
+		
+		for (POITextExtractor extractor : extractors) {
 			String text = extractor.getText().replaceAll("[\r\t]", "");
 			assertTrue(text.startsWith("First Sheet\nTest spreadsheet\n2nd row2nd row 2nd column\n"));
 			Pattern pattern = Pattern.compile(".*13(\\.0+)?\\s+Sheet3.*", Pattern.DOTALL);

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java?rev=1765731&r1=1765730&r2=1765731&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
Wed Oct 19 23:04:39 2016
@@ -23,6 +23,8 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import junit.framework.TestCase;
+
+import org.apache.poi.util.StringUtil;
 import org.apache.poi.xwpf.XWPFTestDataSamples;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 
@@ -51,15 +53,9 @@ public class TestXWPFWordExtractor exten
                 "Phasellus ultricies mi nec leo. Sed tempus. In sit amet lorem at velit faucibus
vestibulum.\n"
         ));
 
-        // Check number of paragraphs
-        int ps = 0;
-        char[] t = text.toCharArray();
-        for (int i = 0; i < t.length; i++) {
-            if (t[i] == '\n') {
-                ps++;
-            }
-        }
-        assertEquals(3, ps);
+        // Check number of paragraphs by counting number of newlines
+        int numberOfParagraphs = StringUtil.count(text, '\n');
+        assertEquals(3, numberOfParagraphs);
 
         extractor.close();
     }
@@ -90,15 +86,9 @@ public class TestXWPFWordExtractor exten
                 "11.4%\t\t90\t\t\t\t\t250\t\t1,310\t\n\n \n\n\n"
         ));
 
-        // Check number of paragraphs
-        int ps = 0;
-        char[] t = text.toCharArray();
-        for (int i = 0; i < t.length; i++) {
-            if (t[i] == '\n') {
-                ps++;
-            }
-        }
-        assertEquals(134, ps);
+        // Check number of paragraphs by counting number of newlines
+        int numberOfParagraphs = StringUtil.count(text, '\n');
+        assertEquals(134, numberOfParagraphs);
 
         extractor.close();
     }



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


Mime
View raw message