aboutsummaryrefslogtreecommitdiffstats
path: root/fop-core
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2022-01-28 13:05:33 +0000
committerSimon Steiner <ssteiner@apache.org>2022-01-28 13:05:33 +0000
commit2c7ad11dc716e70e8ac297786e7a766fd779056a (patch)
treeb71cb48961b9e1af9042ecb164de5fecff7d9bbf /fop-core
parent999ca17b4f4c879db6e40c58cca8763129bd4b07 (diff)
downloadxmlgraphics-fop-2c7ad11dc716e70e8ac297786e7a766fd779056a.tar.gz
xmlgraphics-fop-2c7ad11dc716e70e8ac297786e7a766fd779056a.zip
Skip test on Java 18, as security manager is disabled
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1897565 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core')
-rw-r--r--fop-core/src/test/java/org/apache/fop/apps/FopFactoryTestCase.java42
1 files changed, 23 insertions, 19 deletions
diff --git a/fop-core/src/test/java/org/apache/fop/apps/FopFactoryTestCase.java b/fop-core/src/test/java/org/apache/fop/apps/FopFactoryTestCase.java
index ee95810a6..d11a10954 100644
--- a/fop-core/src/test/java/org/apache/fop/apps/FopFactoryTestCase.java
+++ b/fop-core/src/test/java/org/apache/fop/apps/FopFactoryTestCase.java
@@ -77,21 +77,22 @@ public class FopFactoryTestCase extends BaseConstructiveUserConfigTest {
@Test
public void testSecurityManager() throws Exception {
- System.setSecurityManager(new SecurityManager() {
- public void checkPermission(Permission perm) {
- for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
- if (element.toString().contains("java.security.AccessController.doPrivileged")
- || element.toString().contains("newFop(")
- || element.toString().contains("setSecurityManager(")) {
- return;
+ try {
+ System.setSecurityManager(new SecurityManager() {
+ public void checkPermission(Permission perm) {
+ for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
+ if (element.toString().contains("java.security.AccessController.doPrivileged")
+ || element.toString().contains("newFop(")
+ || element.toString().contains("setSecurityManager(")) {
+ return;
+ }
}
+ throw new RuntimeException("doPrivileged not used for " + perm);
}
- throw new RuntimeException("doPrivileged not used for " + perm);
- }
- });
- FopFactory fopFactory = FopFactory.newInstance(new URI("."));
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- String fo = "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" "
+ });
+ FopFactory fopFactory = FopFactory.newInstance(new URI("."));
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ String fo = "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" "
+ "xmlns:fox=\"http://xmlgraphics.apache.org/fop/extensions\">\n"
+ " <fo:layout-master-set>\n"
+ " <fo:simple-page-master master-name=\"simple\" page-height=\"27.9cm\" page-width=\"21.6cm\">\n"
@@ -105,11 +106,14 @@ public class FopFactoryTestCase extends BaseConstructiveUserConfigTest {
+ "</fo:flow>\n"
+ " </fo:page-sequence>\n"
+ "</fo:root>\n";
- Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, fopFactory.newFOUserAgent(), out);
- Transformer transformer = TransformerFactory.newInstance().newTransformer();
- Source src = new StreamSource(new ByteArrayInputStream(fo.getBytes()));
- Result res = new SAXResult(fop.getDefaultHandler());
- transformer.transform(src, res);
- System.setSecurityManager(null);
+ Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, fopFactory.newFOUserAgent(), out);
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ Source src = new StreamSource(new ByteArrayInputStream(fo.getBytes()));
+ Result res = new SAXResult(fop.getDefaultHandler());
+ transformer.transform(src, res);
+ System.setSecurityManager(null);
+ } catch (UnsupportedOperationException e) {
+ //skip on java 18
+ }
}
}