poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1838763 - in /poi/trunk: ./ sonar/main/ src/ooxml/testcases/org/apache/poi/openxml4j/opc/ src/ooxml/testcases/org/apache/poi/xslf/usermodel/ src/testcases/org/apache/poi/ss/util/
Date Thu, 23 Aug 2018 20:23:20 GMT
Author: centic
Date: Thu Aug 23 20:23:20 2018
New Revision: 1838763

URL: http://svn.apache.org/viewvc?rev=1838763&view=rev
Log:
Adjust for JDK 11 ea-26 build, need to add jaxb via normal jar dependency now as it was removed
from the JDK
Also needed to remove a few uses of Mockito which fail now with certain abstract classes
Update to Mockito 2.21

Modified:
    poi/trunk/build.gradle
    poi/trunk/build.xml
    poi/trunk/sonar/main/pom.xml
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFFreeformShape.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java
    poi/trunk/src/testcases/org/apache/poi/ss/util/TestDateFormatConverter.java

Modified: poi/trunk/build.gradle
URL: http://svn.apache.org/viewvc/poi/trunk/build.gradle?rev=1838763&r1=1838762&r2=1838763&view=diff
==============================================================================
--- poi/trunk/build.gradle (original)
+++ poi/trunk/build.gradle Thu Aug 23 20:23:20 2018
@@ -176,6 +176,10 @@ project('main') {
         compile 'commons-logging:commons-logging:1.2'
         compile 'org.apache.commons:commons-collections4:4.2'
         compile 'org.apache.commons:commons-math3:3.6.1'
+        compile 'javax.xml.bind:jaxb-api:2.3.0'
+        compile 'com.sun.xml.bind:jaxb-impl:2.3.0.1'
+        compile 'com.sun.xml.bind:jaxb-core:2.3.0.1'
+        compile 'javax.activation:activation:1.1.1'
 
         testCompile 'junit:junit:4.12'
     }
@@ -234,7 +238,7 @@ project('ooxml') {
         compile files('../../ooxml-lib/ooxml-security-1.1.jar')
 
         testCompile 'junit:junit:4.12'
-        testCompile 'org.mockito:mockito-core:2.13.0'
+        testCompile 'org.mockito:mockito-core:2.21.0'
         testCompile 'org.xmlunit:xmlunit-core:2.5.1'
         testCompile project(path: ':main', configuration: 'tests')
         testCompile 'org.openjdk.jmh:jmh-core:1.19'

Modified: poi/trunk/build.xml
URL: http://svn.apache.org/viewvc/poi/trunk/build.xml?rev=1838763&r1=1838762&r2=1838763&view=diff
==============================================================================
--- poi/trunk/build.xml (original)
+++ poi/trunk/build.xml Thu Aug 23 20:23:20 2018
@@ -185,6 +185,18 @@ under the License.
     <property name="main.commons-math3.jar" location="${main.lib}/commons-math3-3.6.1.jar"/>
     <property name="main.commons-math3.url"
               value="${repository.m2}/maven2/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.jar"/>
+    <property name="main.xmlbind.jar" location="${main.lib}/jaxb-api-2.3.0.jar"/>
+    <property name="main.xmlbind.url"
+              value="${repository.m2}/maven2/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar"/>
+    <property name="main.xmlbind-impl.jar" location="${main.lib}/jaxb-impl-2.3.0.1.jar"/>
+    <property name="main.xmlbind-impl.url"
+              value="${repository.m2}/maven2/com/sun/xml/bind/jaxb-impl/2.3.0.1/jaxb-impl-2.3.0.1.jar"/>
+    <property name="main.xmlbind-core.jar" location="${main.lib}/jaxb-core-2.3.0.1.jar"/>
+    <property name="main.xmlbind-core.url"
+              value="${repository.m2}/maven2/com/sun/xml/bind/jaxb-core/2.3.0.1/jaxb-core-2.3.0.1.jar"/>
+    <property name="main.activation.jar" location="${main.lib}/activation-1.1.1.jar"/>
+    <property name="main.activation.url"
+              value="${repository.m2}/maven2/javax/activation/activation/1.1.1/activation-1.1.1.jar"/>
 
     <!-- xml signature libs -->
     <property name="dsig.xmlsec.jar" location="${compile.lib}/xmlsec-2.1.0.jar"/>
@@ -327,6 +339,10 @@ under the License.
         <pathelement location="${main.commons-codec.jar}"/>
         <pathelement location="${main.commons-collections4.jar}"/>
         <pathelement location="${main.commons-math3.jar}"/>
+        <pathelement location="${main.xmlbind.jar}"/>
+        <pathelement location="${main.xmlbind-impl.jar}"/>
+        <pathelement location="${main.xmlbind-core.jar}"/>
+        <pathelement location="${main.activation.jar}"/>
     </path>
 
     <!-- some libraries should only be required for compiling/running tests -->
@@ -684,6 +700,10 @@ under the License.
                     <available file="${dsig.sl4j-api.jar}"/>
                     <available file="${main.commons-collections4.jar}"/>
                     <available file="${main.commons-math3.jar}"/>
+                    <available file="${main.xmlbind.jar}"/>
+                    <available file="${main.xmlbind-impl.jar}"/>
+                    <available file="${main.xmlbind-core.jar}"/>
+                    <available file="${main.activation.jar}"/>
 
                     <!-- we had some CI failures when the extracted files for JaCoCo were
missing somehow... -->
                     <available file="${main.lib}/jacocoagent.jar"/>
@@ -716,6 +736,10 @@ under the License.
         <downloadfile src="${jacoco.url}" dest="${jacoco.zip}"/>
         <downloadfile src="${main.commons-collections4.url}" dest="${main.commons-collections4.jar}"/>
         <downloadfile src="${main.commons-math3.url}" dest="${main.commons-math3.jar}"/>
+        <downloadfile src="${main.xmlbind.url}" dest="${main.xmlbind.jar}"/>
+        <downloadfile src="${main.xmlbind-impl.url}" dest="${main.xmlbind-impl.jar}"/>
+        <downloadfile src="${main.xmlbind-core.url}" dest="${main.xmlbind-core.jar}"/>
+        <downloadfile src="${main.activation.url}" dest="${main.activation.jar}"/>
         <unzip src="${jacoco.zip}" dest=".">
             <patternset>
                 <include name="lib/*.jar"/>
@@ -2025,6 +2049,10 @@ under the License.
                     <include name="commons-logging-*.jar"/>
                     <include name="commons-collections4-*.jar"/>
                     <include name="commons-math3-*.jar"/>
+                    <include name="jaxb-api-*.jar"/>
+                    <include name="jaxb-impl-*.jar"/>
+                    <include name="jaxb-core-*.jar"/>
+                    <include name="activation-*.jar"/>
                     <include name="junit-*.jar"/>
                     <include name="log4j-*.jar"/>
                 </fileset>
@@ -2297,6 +2325,10 @@ under the License.
             <auxClasspath path="${main.jmh.jar}"/>
             <auxClasspath path="${main.jmhAnnotation.jar}"/>
             <auxClasspath path="${main.ant.jar}" />
+            <auxClasspath path="${main.xmlbind.jar}" />
+            <auxClasspath path="${main.xmlbind-impl.jar}" />
+            <auxClasspath path="${main.xmlbind-core.jar}" />
+            <auxClasspath path="${main.activation.jar}" />
             <sourcePath path="src/java" />
             <sourcePath path="src/ooxml/java" />
             <sourcePath path="src/scratchpad/src" />

Modified: poi/trunk/sonar/main/pom.xml
URL: http://svn.apache.org/viewvc/poi/trunk/sonar/main/pom.xml?rev=1838763&r1=1838762&r2=1838763&view=diff
==============================================================================
--- poi/trunk/sonar/main/pom.xml (original)
+++ poi/trunk/sonar/main/pom.xml Thu Aug 23 20:23:20 2018
@@ -130,5 +130,25 @@
             <artifactId>commons-logging</artifactId>
             <version>1.2</version>
         </dependency>
+        <dependency>
+            <groupId>javax.xml.bind</groupId>
+            <artifactId>jaxb-api</artifactId>
+            <version>2.3.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-impl</artifactId>
+            <version>2.3.0.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-core</artifactId>
+            <version>2.3.0.1</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.activation</groupId>
+            <artifactId>activation</artifactId>
+            <version>1.1.1</version>
+        </dependency>
     </dependencies>
 </project>

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java?rev=1838763&r1=1838762&r2=1838763&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java Thu Aug 23
20:23:20 2018
@@ -17,46 +17,17 @@
 
 package org.apache.poi.openxml4j.opc;
 
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PushbackInputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.TreeMap;
-import java.util.function.BiConsumer;
-import java.util.regex.Pattern;
-
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
 import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
 import org.apache.commons.compress.archivers.zip.ZipFile;
 import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.POITestCase;
+import org.apache.poi.UnsupportedFileFormatException;
 import org.apache.poi.extractor.POITextExtractor;
 import org.apache.poi.ooxml.POIXMLException;
-import org.apache.poi.UnsupportedFileFormatException;
 import org.apache.poi.ooxml.extractor.ExtractorFactory;
+import org.apache.poi.ooxml.util.DocumentHelper;
 import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
@@ -73,7 +44,6 @@ import org.apache.poi.sl.usermodel.Slide
 import org.apache.poi.sl.usermodel.SlideShowFactory;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.usermodel.WorkbookFactory;
-import org.apache.poi.ooxml.util.DocumentHelper;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
@@ -89,13 +59,39 @@ import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.mockito.Mockito;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PushbackInputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.TreeMap;
+import java.util.function.BiConsumer;
+import java.util.regex.Pattern;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 public final class TestPackage {
     private static final POILogger logger = POILogFactory.getLogger(TestPackage.class);
 
@@ -784,7 +780,7 @@ public final class TestPackage {
 	 */
     @Test
     public void zipBombCreateAndHandle()
-    throws IOException, EncryptedDocumentException, InvalidFormatException {
+    throws IOException, EncryptedDocumentException {
 		ByteArrayOutputStream bos = new ByteArrayOutputStream(2500000);
 
         try (ZipFile zipFile = ZipHelper.openZipFile(OpenXML4JTestDataSamples.getSampleFile("sample.xlsx"));
@@ -884,7 +880,7 @@ public final class TestPackage {
 	}
 
     @Test
-    public void zipBombCheckSizesWithinLimits() throws IOException, EncryptedDocumentException,
InvalidFormatException {
+    public void zipBombCheckSizesWithinLimits() throws IOException, EncryptedDocumentException
{
 		getZipStatsAndConsume((max_size, min_ratio) -> {
 			// use values close to, but within the limits
 			ZipSecureFile.setMinInflateRatio(min_ratio - 0.002);
@@ -895,7 +891,7 @@ public final class TestPackage {
 	}
 
 	@Test
-	public void zipBombCheckSizesRatioTooSmall() throws IOException, EncryptedDocumentException,
InvalidFormatException {
+	public void zipBombCheckSizesRatioTooSmall() throws IOException, EncryptedDocumentException
{
 		expectedEx.expect(POIXMLException.class);
 		expectedEx.expectMessage("You can adjust this limit via ZipSecureFile.setMinInflateRatio()");
 		getZipStatsAndConsume((max_size, min_ratio) -> {
@@ -905,7 +901,7 @@ public final class TestPackage {
 	}
 
 	@Test
-	public void zipBombCheckSizesSizeTooBig() throws IOException, EncryptedDocumentException,
InvalidFormatException {
+	public void zipBombCheckSizesSizeTooBig() throws IOException, EncryptedDocumentException
{
 		expectedEx.expect(POIXMLException.class);
 		expectedEx.expectMessage("You can adjust this limit via ZipSecureFile.setMaxEntrySize()");
 		getZipStatsAndConsume((max_size, min_ratio) -> {
@@ -915,7 +911,7 @@ public final class TestPackage {
 		});
 	}
 
-	private void getZipStatsAndConsume(BiConsumer<Long,Double> ratioCon) throws IOException,
InvalidFormatException {
+	private void getZipStatsAndConsume(BiConsumer<Long,Double> ratioCon) throws IOException
{
     	// use a test file with a xml file bigger than 100k (ZipArchiveThresholdInputStream.GRACE_ENTRY_SIZE)
 		final File file = XSSFTestDataSamples.getSampleFile("poc-shared-strings.xlsx");
 
@@ -980,7 +976,7 @@ public final class TestPackage {
 
     // bug 61381
     @Test
-    public void testTooShortFilterStreams() throws IOException, InvalidFormatException {
+    public void testTooShortFilterStreams() throws IOException {
         File xssf = OpenXML4JTestDataSamples.getSampleFile("sample.xlsx");
         File hssf = POIDataSamples.getSpreadSheetInstance().getFile("SampleSS.xls");
         
@@ -1093,7 +1089,7 @@ public final class TestPackage {
 	@Test(expected = InvalidFormatException.class)
 	public void testBug62592() throws Exception {
 		InputStream is = OpenXML4JTestDataSamples.openSampleStream("62592.thmx");
-		OPCPackage p = OPCPackage.open(is);
+		/*OPCPackage p =*/ OPCPackage.open(is);
 	}
 
 	@Test
@@ -1107,18 +1103,29 @@ public final class TestPackage {
 
 	@Test
 	public void testDoNotCloseStream() throws IOException {
-		OutputStream os = Mockito.mock(OutputStream.class);
+		// up to JDK 10 we did use Mockito here, but OutputStream is
+		// an abstract class and fails mocking with some changes in JDK 11
+		// so we use a simple empty output stream implementation instead
+		OutputStream os = new OutputStream() {
+			@Override
+			public void write(int b) {
+			}
+
+			@Override
+			public void close() {
+				throw new IllegalStateException("close should not be called here");
+			}
+		};
+
 		try (XSSFWorkbook wb = new XSSFWorkbook()) {
 			wb.createSheet();
 			wb.write(os);
 		}
-		verify(os, never()).close();
 
 		try (SXSSFWorkbook wb = new SXSSFWorkbook()) {
 			wb.createSheet();
 			wb.write(os);
 		}
-		verify(os, never()).close();
 	}
 
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFFreeformShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFFreeformShape.java?rev=1838763&r1=1838762&r2=1838763&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFFreeformShape.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFFreeformShape.java
Thu Aug 23 20:23:20 2018
@@ -17,13 +17,13 @@
 package org.apache.poi.xslf.usermodel;
 
 
-import static org.apache.poi.xslf.usermodel.TestXSLFSimpleShape.getSpPr;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
+import org.apache.poi.sl.draw.SLGraphics;
+import org.junit.Test;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
 
 import java.awt.Color;
 import java.awt.Graphics2D;
+import java.awt.Shape;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Ellipse2D;
 import java.awt.geom.Line2D;
@@ -33,10 +33,8 @@ import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.io.IOException;
 
-import org.junit.Test;
-import org.mockito.AdditionalAnswers;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
+import static org.apache.poi.xslf.usermodel.TestXSLFSimpleShape.getSpPr;
+import static org.junit.Assert.assertEquals;
 
 public class TestXSLFFreeformShape {
 
@@ -78,17 +76,32 @@ public class TestXSLFFreeformShape {
             BufferedImage img = new BufferedImage(300, 300, BufferedImage.TYPE_INT_ARGB);
             Graphics2D graphics = img.createGraphics();
             try {
-                Graphics2D graphicsMock = Mockito.mock(Graphics2D.class, AdditionalAnswers.delegatesTo(graphics));
+                // previously we used Mockito here, but since JDK 11 mocking the Graphics2D
does
+                // not work any longer
+                Graphics2D graphicsMock = new SLGraphics(new XSLFGroupShape(CTGroupShape.Factory.newInstance(),
slide)) {
+                    boolean called;
+
+                    @Override
+                    public void draw(Shape shape) {
+                        if(called) {
+                            throw new IllegalStateException("Should only be called once,
but was called a second time");
+                        }
+                        called = true;
+
+                        if(!(shape instanceof Path2D.Double)) {
+                            throw new IllegalStateException("Expecting a shape of type Path2D.Double,
but had " + shape.getClass());
+                        }
+
+                        Path2D.Double actual = (Path2D.Double) shape;
+                        PathIterator pi = actual.getPathIterator(new AffineTransform());
+                        comparePoint(pi, PathIterator.SEG_MOVETO, 100, 150);
+                        pi.next();
+                        comparePoint(pi, PathIterator.SEG_LINETO, 100, 300);
+
+                        super.draw(shape);
+                    }
+                };
                 slide.draw(graphicsMock);
-
-                ArgumentCaptor<Path2D.Double> captor = ArgumentCaptor.forClass(Path2D.Double.class);
-                verify(graphicsMock, times(1)).draw(captor.capture());
-
-                Path2D.Double actual = captor.getValue();
-                PathIterator pi = actual.getPathIterator(new AffineTransform());
-                comparePoint(pi, PathIterator.SEG_MOVETO, 100, 150);
-                pi.next();
-                comparePoint(pi, PathIterator.SEG_LINETO, 100, 300);
             } finally {
                 graphics.dispose();
             }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java?rev=1838763&r1=1838762&r2=1838763&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java Thu Aug
23 20:23:20 2018
@@ -22,14 +22,15 @@ import static org.apache.poi.sl.TestComm
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 import java.awt.Color;
 import java.io.IOException;
 
 import org.apache.poi.sl.draw.DrawTextParagraph;
 import org.junit.Test;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextLineBreak;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
 
 /**
  * @author Yegor Kozlov
@@ -104,14 +105,16 @@ public class TestXSLFTextRun {
     }
 
     @Test
-    public void testCopyNullFontSize() throws IOException {
+    public void testCopyNullFontSize() {
         XMLSlideShow ppt = new XMLSlideShow();
         XSLFSlide slide = ppt.createSlide();
         XSLFTextShape sh = slide.createAutoShape();
 
         XSLFTextRun r = sh.addNewTextParagraph().addNewTextRun();
-        XSLFTextRun s = mock(XSLFTextRun.class);
-        when(s.getFontSize()).thenReturn(null);
+
+        XSLFTextRun s = new XSLFTextRun(CTTextLineBreak.Factory.newInstance(),
+                new XSLFTextParagraph(CTTextParagraph.Factory.newInstance(),
+                        new XSLFTextBox(CTShape.Factory.newInstance(), slide)));
 
         r.copy(s);
     }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestDateFormatConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestDateFormatConverter.java?rev=1838763&r1=1838762&r2=1838763&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestDateFormatConverter.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestDateFormatConverter.java Thu Aug 23
20:23:20 2018
@@ -27,8 +27,6 @@ import java.util.Arrays;
 import java.util.Date;
 import java.util.Locale;
 
-import junit.framework.TestCase;
-
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellStyle;
@@ -37,10 +35,11 @@ import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.util.TempFile;
+import org.junit.Ignore;
+import org.junit.Test;
 
-public final class TestDateFormatConverter extends TestCase {
+public final class TestDateFormatConverter {
     private void outputLocaleDataFormats( Date date, boolean dates, boolean times, int style,
String styleName ) throws Exception {
-
         try (Workbook workbook = new HSSFWorkbook()) {
             String sheetName;
             if (dates) {
@@ -100,8 +99,18 @@ public final class TestDateFormatConvert
                     row.createCell(5).setCellValue(javaDateFormatPattern);
                     row.createCell(6).setCellValue(excelFormatPattern);
                 } catch (Exception e) {
-                    throw new RuntimeException("Failed for locale: " + locale + ", having
locales: " +
-                            Arrays.toString(DateFormat.getAvailableLocales()), e);
+                    // this can be removed after https://bugs.openjdk.java.net/browse/JDK-8209047
is available
+                    // in JDK 11 ea > 26
+                    if(locale.toString().startsWith("my") &&
+                            e.getMessage().contains("Illegal pattern character 'B'") &&
+                                    System.getProperty("java.version").startsWith("11"))
{
+                        System.out.println("DateFormat.getDateTimeInstance() fails for Malaysian
Locale on JDK 11, submitted bug report to Oracle");
+                        continue;
+                    }
+
+                    throw new RuntimeException(
+                            "Failed for locale: " + locale + " and style " + style + "\n"
+
+                            "Having locales: " + Arrays.toString(DateFormat.getAvailableLocales()),
e);
                 }
             }
 
@@ -114,6 +123,7 @@ public final class TestDateFormatConvert
         }
     }
 
+    @Test
     public void testJavaDateFormatsInExcel() throws Exception {
         Date date = new Date();
 
@@ -135,11 +145,17 @@ public final class TestDateFormatConvert
         outputLocaleDataFormats(date, false, true, DateFormat.LONG, "Long" );
         outputLocaleDataFormats(date, false, true, DateFormat.FULL, "Full" );
     }
-    
+
+    @Test
     public void testJDK8EmptyLocale() {
         // JDK 8 seems to add an empty locale-string to the list returned via DateFormat.getAvailableLocales()
         // therefore we now cater for this special locale as well
         DateFormatConverter.getPrefixForLocale(new Locale(""));
     }
 
+    @Ignore("Fails on JDK 11, submitted as ID : 9056763")
+    @Test
+    public void testJDK11MyLocale() {
+        DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.forLanguageTag("my"));
+    }
 }



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


Mime
View raw message