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 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1838763 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5acb18ac04
commit
4663238bb8
@ -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'
|
||||
|
32
build.xml
32
build.xml
@ -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" />
|
||||
|
@ -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>
|
||||
|
@ -17,15 +17,53 @@
|
||||
|
||||
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 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.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;
|
||||
import org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException;
|
||||
import org.apache.poi.openxml4j.exceptions.ODFNotOfficeXmlFileException;
|
||||
import org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException;
|
||||
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
|
||||
import org.apache.poi.openxml4j.opc.internal.ContentTypeManager;
|
||||
import org.apache.poi.openxml4j.opc.internal.FileHelper;
|
||||
import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart;
|
||||
import org.apache.poi.openxml4j.opc.internal.ZipHelper;
|
||||
import org.apache.poi.openxml4j.util.ZipSecureFile;
|
||||
import org.apache.poi.sl.usermodel.SlideShow;
|
||||
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.util.IOUtils;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.util.TempFile;
|
||||
import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFRelation;
|
||||
import org.apache.xmlbeans.XmlException;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
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;
|
||||
@ -47,54 +85,12 @@ 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.extractor.POITextExtractor;
|
||||
import org.apache.poi.ooxml.POIXMLException;
|
||||
import org.apache.poi.UnsupportedFileFormatException;
|
||||
import org.apache.poi.ooxml.extractor.ExtractorFactory;
|
||||
import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
|
||||
import org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException;
|
||||
import org.apache.poi.openxml4j.exceptions.ODFNotOfficeXmlFileException;
|
||||
import org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException;
|
||||
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
|
||||
import org.apache.poi.openxml4j.opc.internal.ContentTypeManager;
|
||||
import org.apache.poi.openxml4j.opc.internal.FileHelper;
|
||||
import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart;
|
||||
import org.apache.poi.openxml4j.opc.internal.ZipHelper;
|
||||
import org.apache.poi.openxml4j.util.ZipSecureFile;
|
||||
import org.apache.poi.sl.usermodel.SlideShow;
|
||||
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;
|
||||
import org.apache.poi.util.TempFile;
|
||||
import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFRelation;
|
||||
import org.apache.xmlbeans.XmlException;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
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 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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -22,14 +22,15 @@ import static org.apache.poi.sl.TestCommonSL.sameColor;
|
||||
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);
|
||||
}
|
||||
|
@ -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 TestDateFormatConverter extends TestCase {
|
||||
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 TestDateFormatConverter extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJavaDateFormatsInExcel() throws Exception {
|
||||
Date date = new Date();
|
||||
|
||||
@ -135,11 +145,17 @@ public final class TestDateFormatConverter extends TestCase {
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user