gump build fixing - move system properties tinkering into junit class
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1693978 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
77315b425f
commit
5a4575bb8c
@ -22,8 +22,15 @@ package org.apache.poi.sl.draw.geom;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
import javax.xml.bind.*;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.stream.*;
|
import javax.xml.bind.JAXBElement;
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
import javax.xml.stream.EventFilter;
|
||||||
|
import javax.xml.stream.XMLEventReader;
|
||||||
|
import javax.xml.stream.XMLInputFactory;
|
||||||
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
import javax.xml.stream.XMLStreamReader;
|
||||||
import javax.xml.stream.events.StartElement;
|
import javax.xml.stream.events.StartElement;
|
||||||
import javax.xml.stream.events.XMLEvent;
|
import javax.xml.stream.events.XMLEvent;
|
||||||
|
|
||||||
@ -37,7 +44,6 @@ import org.apache.poi.util.POILogger;
|
|||||||
public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
||||||
private final static POILogger LOG = POILogFactory.getLogger(PresetGeometries.class);
|
private final static POILogger LOG = POILogFactory.getLogger(PresetGeometries.class);
|
||||||
protected final static String BINDING_PACKAGE = "org.apache.poi.sl.draw.binding";
|
protected final static String BINDING_PACKAGE = "org.apache.poi.sl.draw.binding";
|
||||||
private static final String JAXPFACTORYID = "javax.xml.stream.XMLInputFactory";
|
|
||||||
|
|
||||||
protected static PresetGeometries _inst;
|
protected static PresetGeometries _inst;
|
||||||
|
|
||||||
@ -53,8 +59,6 @@ public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fixXmlSystemProperties();
|
|
||||||
|
|
||||||
XMLInputFactory staxFactory = XMLInputFactory.newFactory();
|
XMLInputFactory staxFactory = XMLInputFactory.newFactory();
|
||||||
XMLEventReader staxReader = staxFactory.createXMLEventReader(is);
|
XMLEventReader staxReader = staxFactory.createXMLEventReader(is);
|
||||||
XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter);
|
XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter);
|
||||||
@ -115,21 +119,4 @@ public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
|||||||
|
|
||||||
return _inst;
|
return _inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fixXmlSystemProperties() {
|
|
||||||
// handling for illegal system properties - mainly because of failing gump build
|
|
||||||
String xmlFactClass = System.getProperty(JAXPFACTORYID);
|
|
||||||
if (xmlFactClass != null) {
|
|
||||||
try {
|
|
||||||
Class.forName(xmlFactClass);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.log(POILogger.ERROR, "Invalid xml input factory config detected. ("+JAXPFACTORYID+"="+xmlFactClass+")");
|
|
||||||
try {
|
|
||||||
System.clearProperty(JAXPFACTORYID);
|
|
||||||
} catch (Exception e2) {
|
|
||||||
LOG.log(POILogger.ERROR, "Failed to remove invalid xml input factory", e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,6 @@ import java.lang.reflect.Field;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.xml.stream.XMLInputFactory;
|
|
||||||
|
|
||||||
import org.apache.poi.sl.draw.Drawable;
|
import org.apache.poi.sl.draw.Drawable;
|
||||||
import org.apache.poi.util.JvmBugs;
|
import org.apache.poi.util.JvmBugs;
|
||||||
import org.apache.poi.xslf.XSLFTestDataSamples;
|
import org.apache.poi.xslf.XSLFTestDataSamples;
|
||||||
@ -46,7 +44,7 @@ public class TestPPTX2PNG {
|
|||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void activateJaxpDebug() {
|
public static void activateJaxpDebug() {
|
||||||
jaxpDebugEnable = setDebugFld(true);
|
jaxpDebugEnable = setDebugFld(true);
|
||||||
fixDefaultInputFactory();
|
setXmlInputFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
@ -69,17 +67,13 @@ public class TestPPTX2PNG {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void fixDefaultInputFactory() {
|
private static void setXmlInputFactory() {
|
||||||
String originalValue = "com.sun.xml.internal.stream.XMLInputFactoryImpl";
|
String propName = "javax.xml.stream.XMLInputFactory";
|
||||||
|
String propVal = "com.sun.xml.internal.stream.XMLInputFactoryImpl";
|
||||||
try {
|
try {
|
||||||
Field fld = XMLInputFactory.class.getDeclaredField("DEFAULIMPL");
|
Class.forName(propVal);
|
||||||
fld.setAccessible(true);
|
System.setProperty(propName, propVal);
|
||||||
String val = (String)fld.get(null);
|
} catch (Exception e){
|
||||||
if (!originalValue.equals(val)) {
|
|
||||||
System.out.println("DefaultXMLInputFactory illegal changed to: "+val);
|
|
||||||
fld.set(null, originalValue);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user