Author: ssteiner Date: Fri Jan 28 13:05:33 2022 New Revision: 1897565 URL: http://svn.apache.org/viewvc?rev=1897565&view=rev Log: Skip test on Java 18, as security manager is disabled
Modified: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/FopFactoryTestCase.java Modified: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/FopFactoryTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/FopFactoryTestCase.java?rev=1897565&r1=1897564&r2=1897565&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/FopFactoryTestCase.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/FopFactoryTestCase.java Fri Jan 28 13:05:33 2022 @@ -77,21 +77,22 @@ public class FopFactoryTestCase extends @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 + "</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 + } } } --------------------------------------------------------------------- To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org