poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1839195 - in /poi/trunk/src: java/org/apache/poi/ java/org/apache/poi/sl/usermodel/ ooxml/testcases/org/apache/poi/ss/format/ testcases/org/apache/poi/ss/format/ testcases/org/apache/poi/ss/usermodel/
Date Sun, 26 Aug 2018 11:41:09 GMT
Author: centic
Date: Sun Aug 26 11:41:09 2018
New Revision: 1839195

URL: http://svn.apache.org/viewvc?rev=1839195&view=rev
Log:
Adjust test for JDK 9, 10 and 11
fix some IDE/Javadoc warnings

Modified:
    poi/trunk/src/java/org/apache/poi/POIDocument.java
    poi/trunk/src/java/org/apache/poi/sl/usermodel/SlideShow.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java
    poi/trunk/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java

Modified: poi/trunk/src/java/org/apache/poi/POIDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/POIDocument.java?rev=1839195&r1=1839194&r2=1839195&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/POIDocument.java (original)
+++ poi/trunk/src/java/org/apache/poi/POIDocument.java Sun Aug 26 11:41:09 2018
@@ -231,13 +231,10 @@ public abstract class POIDocument implem
     
             // Find the entry, and get an input stream for it
             step = "getting";
-            DocumentInputStream dis = dirNode.createDocumentInputStream( dirNode.getEntry(setName)
);
-            try {
+            try (DocumentInputStream dis = dirNode.createDocumentInputStream(dirNode.getEntry(setName)))
{
                 // Create the Property Set
                 step = "creating";
                 return PropertySetFactory.create(dis);
-            } finally {
-                dis.close();
             }
         } catch (IOException e) {
             throw e;
@@ -424,7 +421,7 @@ public abstract class POIDocument implem
      * Closes the underlying {@link NPOIFSFileSystem} from which
      *  the document was read, if any. Has no effect on documents
      *  opened from an InputStream, or newly created ones.
-     * <p>Once {@link #close()} has been called, no further operations
+     * <p>Once close() has been called, no further operations
      *  should be called on the document.
      */
     @Override

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/SlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/SlideShow.java?rev=1839195&r1=1839194&r2=1839195&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/SlideShow.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/SlideShow.java Sun Aug 26 11:41:09 2018
@@ -130,7 +130,7 @@ public interface SlideShow<
     /**
      * @return the instance which handles the persisting of the slideshow,
      * which is either a subclass of {@link org.apache.poi.POIDocument}
-     * or {@link org.apache.poi.POIXMLDocument}
+     * or {@link org.apache.poi.ooxml.POIXMLDocument}
      *
      * @since POI 4.0.0
      */

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java?rev=1839195&r1=1839194&r2=1839195&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java Sun Aug
26 11:41:09 2018
@@ -55,7 +55,7 @@ public class TestCellFormatPart extends
     }
 
     @Test
-    public void testGeneralFormat() throws Exception {
+    public void testGeneralFormat() {
         runFormatTests("GeneralFormatTests.xlsx", new CellValue() {
             @Override
             public Object getValue(Cell cell) {
@@ -71,7 +71,8 @@ public class TestCellFormatPart extends
         });
     }
 
-    public void testNumberFormat() throws Exception {
+    @Test
+    public void testNumberFormat() {
         runFormatTests("NumberFormatTests.xlsx", new CellValue() {
             @Override
             public Object getValue(Cell cell) {
@@ -81,7 +82,7 @@ public class TestCellFormatPart extends
     }
 
     @Test
-    public void testNumberApproxFormat() throws Exception {
+    public void testNumberApproxFormat() {
         runFormatTests("NumberFormatApproxTests.xlsx", new CellValue() {
             @Override
             public Object getValue(Cell cell) {
@@ -102,7 +103,7 @@ public class TestCellFormatPart extends
     }
 
     @Test
-    public void testDateFormat() throws Exception {
+    public void testDateFormat() {
         TimeZone tz = LocaleUtil.getUserTimeZone();
         LocaleUtil.setUserTimeZone(TimeZone.getTimeZone("CET"));
         try {
@@ -118,7 +119,7 @@ public class TestCellFormatPart extends
     }
 
     @Test
-    public void testElapsedFormat() throws Exception {
+    public void testElapsedFormat() {
         runFormatTests("ElapsedFormatTests.xlsx", new CellValue() {
             @Override
             public Object getValue(Cell cell) {
@@ -128,7 +129,7 @@ public class TestCellFormatPart extends
     }
 
     @Test
-    public void testTextFormat() throws Exception {
+    public void testTextFormat() {
         runFormatTests("TextFormatTests.xlsx", new CellValue() {
             @Override
             public Object getValue(Cell cell) {
@@ -143,7 +144,7 @@ public class TestCellFormatPart extends
     }
 
     @Test
-    public void testConditions() throws Exception {
+    public void testConditions() {
         runFormatTests("FormatConditionTests.xlsx", new CellValue() {
             @Override
             Object getValue(Cell cell) {

Modified: poi/trunk/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java?rev=1839195&r1=1839194&r2=1839195&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java Sun Aug 26 11:41:09
2018
@@ -96,8 +96,7 @@ public class CellFormatTestBase {
         }
     }
 
-    protected void runFormatTests(String workbookName, CellValue valueGetter)
-            throws IOException {
+    protected void runFormatTests(String workbookName, CellValue valueGetter) {
 
         openWorkbook(workbookName);
 
@@ -136,11 +135,8 @@ public class CellFormatTestBase {
      * @param workbookName The workbook name.  This is presumed to live in the
      *                     "spreadsheets" directory under the directory named in
      *                     the Java property "POI.testdata.path".
-     *
-     * @throws IOException
      */
-    protected void openWorkbook(String workbookName)
-            throws IOException {
+    protected void openWorkbook(String workbookName) {
         workbook = _testDataProvider.openSampleWorkbook(workbookName);
         workbook.setMissingCellPolicy(MissingCellPolicy.CREATE_NULL_AS_BLANK);
         testFile = workbookName;

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java?rev=1839195&r1=1839194&r2=1839195&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java Sun
Aug 26 11:41:09 2018
@@ -18,7 +18,6 @@
 package org.apache.poi.ss.usermodel;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 
 import java.text.DateFormatSymbols;
 import java.text.FieldPosition;
@@ -42,6 +41,41 @@ public class TestExcelStyleDateFormatter
      */
     @Test
     public void test60369() throws ParseException {
+        Map<Locale, List<String>> testMap = initializeLocales();
+
+        // We have to set up dates as well.
+        SimpleDateFormat testDateFormat = new SimpleDateFormat("dd.MM.yyyy", Locale.ROOT);
+        List<Date> testDates = Arrays.asList(
+                testDateFormat.parse("12.01.1980"),
+                testDateFormat.parse("11.02.1995"),
+                testDateFormat.parse("10.03.2045"),
+                testDateFormat.parse("09.04.2016"),
+                testDateFormat.parse("08.05.2017"),
+                testDateFormat.parse("07.06.1945"),
+                testDateFormat.parse("06.07.1998"),
+                testDateFormat.parse("05.08.2099"),
+                testDateFormat.parse("04.09.1988"),
+                testDateFormat.parse("03.10.2023"),
+                testDateFormat.parse("02.11.1978"),
+                testDateFormat.parse("01.12.1890"));
+
+        // Let's iterate over the test setup.
+        for (Locale locale : testMap.keySet()) {
+            ExcelStyleDateFormatter formatter = new ExcelStyleDateFormatter(EXCEL_DATE_FORMAT,
new DateFormatSymbols(locale));
+            for (int i = 0; i < testDates.size(); i++) {
+                // Call the method to be tested!
+                String result =
+                        formatter.format(testDates.get(i),
+                                new StringBuffer(),
+                                new FieldPosition(java.text.DateFormat.MONTH_FIELD)).toString();
+                //System.err.println(result +  " - " + getUnicode(result.charAt(0)));
+                assertEquals("Failed for locale " + locale + " and date " + testDates.get(i)
+ ", having: " + result,
+                        getUnicode(testMap.get(locale).get(i).charAt(0)), getUnicode(result.charAt(0)));
+            }
+        }
+    }
+
+    private Map<Locale, List<String>> initializeLocales() {
         // Setting up the locale to be tested together with a list of asserted unicode-formatted
results and put them in a map.
         Locale germanLocale = Locale.GERMAN;
         List<String> germanResultList = Arrays.asList("\u004a", "\u0046", "\u004d",
"\u0041", "\u004d",
@@ -96,37 +130,7 @@ public class TestExcelStyleDateFormatter
         testMap.put(indianLocale,        indianResultList);
         testMap.put(indonesianLocale,    indonesianResultList);
 
-        // We have to set up dates as well.
-        SimpleDateFormat testDateFormat = new SimpleDateFormat("dd.MM.yyyy", Locale.ROOT);
-        List<Date> testDates = Arrays.asList(
-                testDateFormat.parse("12.01.1980"),
-                testDateFormat.parse("11.02.1995"),
-                testDateFormat.parse("10.03.2045"),
-                testDateFormat.parse("09.04.2016"),
-                testDateFormat.parse("08.05.2017"),
-                testDateFormat.parse("07.06.1945"),
-                testDateFormat.parse("06.07.1998"),
-                testDateFormat.parse("05.08.2099"),
-                testDateFormat.parse("04.09.1988"),
-                testDateFormat.parse("03.10.2023"),
-                testDateFormat.parse("02.11.1978"),
-                testDateFormat.parse("01.12.1890"));
-
-        // Let's iterate over the test setup.
-        for (Locale locale : testMap.keySet()) {
-            //System.err.println("Locale: " + locale);
-            ExcelStyleDateFormatter formatter = new ExcelStyleDateFormatter(EXCEL_DATE_FORMAT,
new DateFormatSymbols(locale));
-            for (int i = 0; i < 12; i++) {
-                // Call the method to be tested!
-                String result =
-                        formatter.format(testDates.get(i),
-                                new StringBuffer(),
-                                new FieldPosition(java.text.DateFormat.MONTH_FIELD)).toString();
-                //System.err.println(result +  " - " + getUnicode(result.charAt(0)));
-                assertEquals("testing locale " + locale,
-                        getUnicode(testMap.get(locale).get(i).charAt(0)), getUnicode(result.charAt(0)));
-            }
-        }
+        return testMap;
     }
 
     private String getUnicode(char c) {
@@ -135,8 +139,8 @@ public class TestExcelStyleDateFormatter
 
     @Test
     public void testConstruct() {
-        assertNotNull(new ExcelStyleDateFormatter(EXCEL_DATE_FORMAT, LocaleUtil.getUserLocale()));
-        assertNotNull(new ExcelStyleDateFormatter(EXCEL_DATE_FORMAT));
+        new ExcelStyleDateFormatter(EXCEL_DATE_FORMAT, LocaleUtil.getUserLocale());
+        new ExcelStyleDateFormatter(EXCEL_DATE_FORMAT);
     }
 
     @Test



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


Mime
View raw message