Browse Source

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
tags/fop-2_8
Simon Steiner 2 years ago
parent
commit
2c7ad11dc7
1 changed files with 23 additions and 19 deletions
  1. 23
    19
      fop-core/src/test/java/org/apache/fop/apps/FopFactoryTestCase.java

+ 23
- 19
fop-core/src/test/java/org/apache/fop/apps/FopFactoryTestCase.java View File

@@ -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
}
}
}

Loading…
Cancel
Save