diff --git a/geowebcache/core/pom.xml b/geowebcache/core/pom.xml index d309d9b99..05cf22068 100644 --- a/geowebcache/core/pom.xml +++ b/geowebcache/core/pom.xml @@ -23,6 +23,10 @@ org.geotools gt-coverage + + org.geotools + gt-xml + org.apache.commons commons-collections4 diff --git a/geowebcache/core/src/main/java/org/geowebcache/config/XMLConfiguration.java b/geowebcache/core/src/main/java/org/geowebcache/config/XMLConfiguration.java index 7c330fb78..9cc3ea4ac 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/config/XMLConfiguration.java +++ b/geowebcache/core/src/main/java/org/geowebcache/config/XMLConfiguration.java @@ -21,7 +21,9 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.io.OutputStreamWriter; +import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; @@ -41,19 +43,21 @@ import java.util.logging.Logger; import java.util.stream.Collectors; import javax.annotation.Nullable; +import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; import org.geotools.util.logging.Logging; +import org.geotools.xml.XMLUtils; import org.geowebcache.GeoWebCacheEnvironment; import org.geowebcache.GeoWebCacheException; import org.geowebcache.GeoWebCacheExtensions; @@ -117,6 +121,10 @@ public class XMLConfiguration public static final String DEFAULT_CONFIGURATION_FILE_NAME = "geowebcache.xml"; + public static final String SCHEMA_NAMESPACE_PREFIX = "http://geowebcache.org/schema/"; + + public static final String DEFAULT_SCHEMA_RESOURCE = "geowebcache.xsd"; + private static Logger log = Logging.getLogger(XMLConfiguration.class.getName()); /** Web app context, used to look up {@link XMLConfigurationProvider}s. */ @@ -614,9 +622,9 @@ private synchronized void addOrReplaceGridSet(final XMLGridSet gridSet) throws I static Node loadDocument(InputStream xmlFile) throws ConfigurationException, IOException { Node topNode = null; try { - DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilderFactory docBuilderFactory = XMLUtils.newDocumentBuilderFactory(); docBuilderFactory.setNamespaceAware(true); - DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); + DocumentBuilder docBuilder = XMLUtils.newDocumentBuilder(docBuilderFactory); topNode = checkAndTransform(docBuilder.parse(xmlFile)); } catch (Exception e) { throw (IOException) new IOException(e.getMessage()).initCause(e); @@ -629,14 +637,12 @@ private static Node checkAndTransform(Document doc) throws ConfigurationExceptio Node rootNode = doc.getDocumentElement(); // debugPrint(rootNode); - if (!rootNode.getNodeName().equals("gwcConfiguration")) { log.config("The configuration file is of the pre 1.0 type, trying to convert."); rootNode = applyTransform(rootNode, "geowebcache_pre10.xsl").getFirstChild(); } // debugPrint(rootNode); - if (rootNode.getNamespaceURI().equals("http://geowebcache.org/schema/1.0.0")) { log.config("Updating configuration from 1.0.0 to 1.0.1"); rootNode = applyTransform(rootNode, "geowebcache_100.xsl").getFirstChild(); @@ -716,6 +722,11 @@ private static Node checkAndTransform(Document doc) throws ConfigurationExceptio rootNode = applyTransform(rootNode, "geowebcache_151.xsl").getFirstChild(); } + if (!rootNode.getNamespaceURI().equals("http://geowebcache.org/schema/2.0.0")) { + log.config("Updating configuration to 2.0.0"); + rootNode = applyTransform(rootNode, "geowebcache_200.xsl").getFirstChild(); + } + // Check again after transform if (!rootNode.getNodeName().equals("gwcConfiguration")) { log.log(Level.SEVERE, "Unable to parse file, expected gwcConfiguration at root after transform."); @@ -726,8 +737,8 @@ private static Node checkAndTransform(Document doc) throws ConfigurationExceptio validate(rootNode); log.config("TileLayerConfiguration file validated fine."); } catch (SAXException e) { - log.warning("GWC configuration validation error: " + e.getMessage()); - log.warning( + log.fine("GWC configuration validation error: " + e.getMessage()); + log.fine( "Will try to use configuration anyway. Please check the order of declared elements against the schema."); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); @@ -739,11 +750,14 @@ private static Node checkAndTransform(Document doc) throws ConfigurationExceptio static void validate(Node rootNode) throws SAXException, IOException { // Perform validation - // TODO dont know why this one suddenly failed to look up, revert to - // XMLConstants.W3C_XML_SCHEMA_NS_URI - SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); + SchemaFactory factory = XMLUtils.newSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI); + // We do not need access to external schemas + factory.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); + factory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); try (InputStream is = XMLConfiguration.class.getResourceAsStream("geowebcache.xsd")) { - + if (is == null) { + throw new IOException("Could not load schema resource 'geowebcache.xsd'"); + } Schema schema = factory.newSchema(new StreamSource(is)); Validator validator = schema.newValidator(); @@ -758,7 +772,7 @@ static String getCurrentSchemaVersion() { Document dom; try (InputStream is = XMLConfiguration.class.getResourceAsStream("geowebcache.xsd")) { - dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is); + dom = XMLUtils.newDocumentBuilder().parse(is); } catch (Exception e) { throw new RuntimeException(e); } @@ -777,7 +791,7 @@ private static Node applyTransform(Node oldRootNode, String xslFilename) { try (InputStream is = XMLConfiguration.class.getResourceAsStream(xslFilename)) { try { - transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(is)); + transformer = XMLUtils.newTransformer(new StreamSource(is)); transformer.transform(new DOMSource(oldRootNode), result); } catch (TransformerFactoryConfigurationError | TransformerException e) { log.log(Level.FINE, e.getMessage(), e); @@ -1462,4 +1476,17 @@ public void deinitialize() throws Exception { this.layers = null; this.gwcConfig = null; } + + /** Print a DOM tree to an output stream or if there is an exception while doing so, print the stack trace. */ + public static void printDom(Node dom, OutputStream os) { + Transformer trans; + PrintWriter w = new PrintWriter(os); + try { + trans = XMLUtils.newTransformer(); // XMLUtils.newTransformer() + trans.transform(new DOMSource(dom), new StreamResult(new OutputStreamWriter(os))); + } catch (TransformerException e) { + w.println("An error ocurred while transforming the given DOM:"); + e.printStackTrace(w); + } + } } diff --git a/geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache.xsd b/geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache.xsd index bd9009b06..6d30dda30 100644 --- a/geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache.xsd +++ b/geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache.xsd @@ -1,7 +1,7 @@ + targetNamespace="http://geowebcache.org/schema/2.0.0" xmlns:gwc="http://geowebcache.org/schema/2.0.0" + elementFormDefault="qualified" version="2.0.0"> diff --git a/geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache_200.xsl b/geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache_200.xsl new file mode 100644 index 000000000..056fb12fc --- /dev/null +++ b/geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache_200.xsl @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/ServerConfigurationTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/ServerConfigurationTest.java index 437d3c939..752c31e8d 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/ServerConfigurationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/ServerConfigurationTest.java @@ -36,7 +36,7 @@ public class ServerConfigurationTest { - private static final String VERSION_PATTERN = "1(\\.\\d+)+(\\-\\w+)*"; + private static final String VERSION_PATTERN = "2(\\.\\d+)+(\\-\\w+)*"; ServerConfiguration config; diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationBackwardsCompatibilityTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationBackwardsCompatibilityTest.java index d77ecac5b..8427015a5 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationBackwardsCompatibilityTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationBackwardsCompatibilityTest.java @@ -29,6 +29,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import org.geotools.xml.XMLUtils; import org.geowebcache.GeoWebCacheException; import org.geowebcache.config.meta.ServiceInformation; import org.geowebcache.filter.request.RequestFilter; @@ -45,7 +46,9 @@ public class XMLConfigurationBackwardsCompatibilityTest { public static final String GWC_125_CONFIG_FILE = "geowebcache_125.xml"; - public static final String LATEST_FILENAME = "geowebcache_130.xml"; + public static final String GWC_130_CONFIG_FILE = "geowebcache_130.xml"; + + public static final String LATEST_FILENAME = "geowebcache_200.xml"; @Test public void testLoadPre10() throws Exception { @@ -227,14 +230,14 @@ private XMLConfiguration loadConfig(String fileName) throws Exception { /** Utility method to print out a dom. */ protected void print(Document dom) throws Exception { - TransformerFactory txFactory = TransformerFactory.newInstance(); + TransformerFactory txFactory = XMLUtils.newTransformerFactory(); try { txFactory.setAttribute("{http://xml.apache.org/xalan}indent-number", Integer.valueOf(2)); } catch (Exception e) { // some } - Transformer tx = txFactory.newTransformer(); + Transformer tx = XMLUtils.newTransformer(txFactory); tx.setOutputProperty(OutputKeys.METHOD, "xml"); tx.setOutputProperty(OutputKeys.INDENT, "yes"); diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java index e921fad22..812417d74 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java @@ -40,6 +40,7 @@ import java.io.FileInputStream; import java.io.FilterOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.net.URL; import java.util.ArrayList; @@ -81,6 +82,7 @@ import org.mockito.Mockito; import org.springframework.context.ApplicationContext; import org.springframework.web.context.WebApplicationContext; +import org.w3c.dom.Node; import org.xml.sax.SAXParseException; public class XMLConfigurationTest { @@ -115,6 +117,15 @@ public void setUp() throws Exception { config.afterPropertiesSet(); } + @Test + public void testValidateVersionedSchemaFromNamespace() throws Exception { + try (InputStream xml = XMLConfigurationTest.class.getResourceAsStream("geowebcache-config-env.xml")) { + assertNotNull(xml); + Node document = XMLConfiguration.loadDocument(xml); + XMLConfiguration.validate(document); + } + } + @Test public void testAddLayer() throws Exception { int count = config.getLayerCount(); @@ -477,10 +488,17 @@ public void testOverrideGridSetDefaults() throws Exception { overrideDescription.contains("OVERRIDE")); } + /** + * GeoWebCache 1.8.0 default to one disabled blob store + * + * @throws Exception + */ @Test - public void testNoBlobStores() throws Exception { + public void testSingleDisabledBlobStores() throws Exception { assertNotNull(config.getBlobStores()); - assertTrue(config.getBlobStores().isEmpty()); + assertEquals("single blobstore", 1, config.getBlobStoreCount()); + BlobStoreInfo store = config.getBlobStores().get(0); + assertFalse("single disabled blobstore", store.isEnabled()); } @Test @@ -499,6 +517,8 @@ public void testAddBlobStores() throws Exception { store2.setFileSystemBlockSize(512); store2.setBaseDirectory("/tmp/test2"); + int baseline = config.getBlobStoreCount(); + config.addBlobStore(store1); config.addBlobStore(store2); @@ -516,12 +536,12 @@ public void testAddBlobStores() throws Exception { List stores = config2.getBlobStores(); assertNotNull(stores); - assertEquals(2, stores.size()); - assertNotSame(store1, stores.get(0)); - assertEquals(store1, stores.get(0)); + assertEquals(baseline + 2, stores.size()); + assertNotSame(store1, stores.get(baseline + 0)); + assertEquals(store1, stores.get(baseline + 0)); - assertNotSame(store2, stores.get(1)); - assertEquals(store2, stores.get(1)); + assertNotSame(store2, stores.get(baseline + 1)); + assertEquals(store2, stores.get(baseline + 1)); } @Test @@ -558,6 +578,8 @@ public void close() throws IOException { config = new XMLConfiguration(null, resourceProvider); config.setGridSetBroker(gridSetBroker); + int initialCount = config.getBlobStoreCount(); + FileBlobStoreInfo store1 = new FileBlobStoreInfo(); store1.setName("store1"); store1.setDefault(true); @@ -566,9 +588,9 @@ public void close() throws IOException { store1.setBaseDirectory("/tmp/test"); assertThrows(ConfigurationPersistenceException.class, () -> config.addBlobStore(store1)); - assertEquals(0, config.getBlobStoreCount()); - GeoWebCacheConfiguration configuration = config.loadConfiguration(); - assertTrue("store shouldn't be saved", configuration.getBlobStores().isEmpty()); + assertEquals(1, config.getBlobStoreCount()); + config.loadConfiguration(); + assertEquals("store shouldn't be saved", initialCount, config.getBlobStoreCount()); } /** @@ -606,12 +628,20 @@ public void testAddBlobStoreExceptionFromListener() throws Exception { private void assertAddBlobStoreFails(FileBlobStoreInfo store, Class expectedCause) throws ConfigurationException { + ConfigurationPersistenceException expected; + + int baseline = config.getBlobStoreCount(); + expected = assertThrows(ConfigurationPersistenceException.class, () -> config.addBlobStore(store)); assertThat(expected.getCause(), instanceOf(expectedCause)); - assertEquals(0, config.getBlobStoreCount()); + + assertEquals(baseline, config.getBlobStoreCount()); GeoWebCacheConfiguration configuration = config.loadConfiguration(); - assertTrue("store shouldn't be saved", configuration.getBlobStores().isEmpty()); + assertEquals( + "store shouldn't be saved", + baseline, + configuration.getBlobStores().size()); } /** @@ -643,9 +673,10 @@ public void testModifyBlobStoreExceptionFromListener() throws Exception { // note, I'm not sure why XMLConfiguration.addBlobStore() only rolls-back on UnsuitableStorageException and not // on IOException or GeoWebCacheException + // doThrow(new IOException("fake")).when(listener).handleModifyBlobStore(Mockito.any()); // assertModifyBlobStoreFails(original, IOException.class); - // + // doThrow(new GeoWebCacheException("fake")).when(listener).handleModifyBlobStore(Mockito.any()); // assertModifyBlobStoreFails(original, GeoWebCacheException.class); } @@ -653,18 +684,20 @@ public void testModifyBlobStoreExceptionFromListener() throws Exception { private void assertModifyBlobStoreFails(FileBlobStoreInfo original, Class expectedCause) throws ConfigurationException { + int baseline = config.getBlobStoreCount(); + FileBlobStoreInfo modified = (FileBlobStoreInfo) original.clone(); modified.setBaseDirectory("/tmp/test2"); - assertEquals(1, config.getBlobStoreCount()); + assertEquals(baseline, config.getBlobStoreCount()); ConfigurationPersistenceException expected; expected = assertThrows(ConfigurationPersistenceException.class, () -> config.modifyBlobStore(modified)); assertThat(expected.getCause(), instanceOf(expectedCause)); GeoWebCacheConfiguration reloaded = config.loadConfiguration(); - assertEquals(1, reloaded.getBlobStores().size()); + assertEquals(baseline, reloaded.getBlobStores().size()); - BlobStoreInfo stored = reloaded.getBlobStores().get(0); + BlobStoreInfo stored = reloaded.getBlobStores().get(baseline - 1); assertEquals("store shouldn't be saved", original, stored); } diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache-config-env.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache-config-env.xml index 01e9f8b2d..95e591932 100644 --- a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache-config-env.xml +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache-config-env.xml @@ -1,7 +1,7 @@ + xmlns="http://geowebcache.org/schema/2.0.0" + xsi:schemaLocation="http://geowebcache.org/schema/2.0.0 https://raw.githubusercontent.com/GeoWebCache/geowebcache/refs/heads/main/geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache_200.xsd"> + + defaultCache + false + /tmp/defaultCache + 4096 + + + + + + + + + + + + + + + EPSG:2163 + + 2163 + + + + -2495667.977678598 + -2223677.196231552 + 3291070.6104286816 + 959189.3312465074 + + + + 25000000 + 1000000 + 100000 + 25000 + + 200 + 200 + + + CanadaAtlasNonotree + + 3979 + + + + -2441613 + -861451 + 3176326 + 3969977 + + + + 21945.0742188 + 7315.02473958 + 2438.34157986 + 812.78052662 + 270.926842207 + + + + + + + + + states + + image/gif + image/jpeg + image/png + image/png8 + + + + EPSG:4326 + + + -129.6 + 3.45 + -62.1 + 70.9 + + + + + EPSG:2163 + + + + + STYLES + population + + population + polygon + pophatch + + + + + + http://localhost:8080/geoserver/topp/wms + + + + + + 20 + 20 + + + + + + raster test layer + + image/gif + image/jpeg + image/png + image/png8 + + + + EPSG:4326 + + + CanadaAtlasNonotree + + + + http://localhost:8080/geoserver/wms + + nurc:Arc_Sample + + + + + + + img states + + Nicer title for Image States + This is a description. Fascinating. + + + image/gif + image/jpeg + image/png + image/png8 + + + + + EPSG:4326 + + + -129.6 + 3.45 + -62.1 + 70.9 + + + + + + + + + + + + + http://localhost:8080/geoserver/wms + + + nurc:Img_Sample,topp:states + false + 0x0066FF + + + + + 20 + 20 + 5000 + 10000 + + + 20 + 20 + + + + + + diff --git a/geowebcache/diskquota/bdb/src/test/java/org/geowebcache/diskquota/BDBQuotaStoreTest.java b/geowebcache/diskquota/bdb/src/test/java/org/geowebcache/diskquota/BDBQuotaStoreTest.java index a248d38b1..cd4f2ca01 100644 --- a/geowebcache/diskquota/bdb/src/test/java/org/geowebcache/diskquota/BDBQuotaStoreTest.java +++ b/geowebcache/diskquota/bdb/src/test/java/org/geowebcache/diskquota/BDBQuotaStoreTest.java @@ -142,7 +142,7 @@ private XMLConfiguration loadXMLConfig() { xmlConfig = new XMLConfiguration( context.getContextProvider(), new MockConfigurationResourceProvider(() -> XMLConfiguration.class.getResourceAsStream( - XMLConfigurationBackwardsCompatibilityTest.LATEST_FILENAME))); + XMLConfigurationBackwardsCompatibilityTest.GWC_130_CONFIG_FILE))); } catch (Exception e) { // Do nothing } diff --git a/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/JDBCQuotaStoreTest.java b/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/JDBCQuotaStoreTest.java index 5404c99cf..e326b40c3 100644 --- a/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/JDBCQuotaStoreTest.java +++ b/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/JDBCQuotaStoreTest.java @@ -281,7 +281,7 @@ private XMLConfiguration loadXMLConfig() throws Exception { return new XMLConfiguration( null, new MockConfigurationResourceProvider(() -> XMLConfiguration.class.getResourceAsStream( - XMLConfigurationBackwardsCompatibilityTest.LATEST_FILENAME))); + XMLConfigurationBackwardsCompatibilityTest.GWC_130_CONFIG_FILE))); } @Test diff --git a/geowebcache/georss/src/main/java/org/geowebcache/georss/StaxGeoRSSReader.java b/geowebcache/georss/src/main/java/org/geowebcache/georss/StaxGeoRSSReader.java index f6a26af12..53f166c68 100644 --- a/geowebcache/georss/src/main/java/org/geowebcache/georss/StaxGeoRSSReader.java +++ b/geowebcache/georss/src/main/java/org/geowebcache/georss/StaxGeoRSSReader.java @@ -33,6 +33,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import org.geotools.util.logging.Logging; +import org.geotools.xml.XMLUtils; import org.geowebcache.georss.GML31ParsingUtils.GML; import org.locationtech.jts.geom.Geometry; @@ -77,7 +78,7 @@ private static final class GEORSS { private final GML31ParsingUtils gmlParser; public StaxGeoRSSReader(final Reader feed) throws XMLStreamException, FactoryConfigurationError { - XMLInputFactory factory = XMLInputFactory.newInstance(); + XMLInputFactory factory = XMLUtils.newXMLInputFactory(); reader = factory.createXMLStreamReader(feed); reader.nextTag(); diff --git a/geowebcache/pmd-ruleset.xml b/geowebcache/pmd-ruleset.xml index 4031bf176..16037db14 100644 --- a/geowebcache/pmd-ruleset.xml +++ b/geowebcache/pmd-ruleset.xml @@ -114,5 +114,180 @@ GeoWebCache ruleset. See https://pmd.github.io/pmd/pmd_userdocs_making_rulesets. - + + + + + Notice use of DocumentBuilderFactory.newInstance() which should be avoided in favor of + XMLUtils.DocumentBuilderFactory(Hints) to respect GeoTools init configuration. + + 3 + + + + + + + + + + + Notice use of DocumentBuilderFactory.newDocumentBuilder() which should be avoided in favor of + XMLUtils.newDocumentBuilder(Hints) to respect GeoTools init configuration. + + 3 + + + + + + + + + + + Notice use of TransformerFactory.newInstance() which should be avoided in favor of + XMLUtils.newTransformerFactory(Hints) to respect GeoTools init configuration. + + 3 + + + + + + + + + + + Notice use of TransformerFactory.newTransformer() which should be avoided in favor of + XMLUtils.newTransformer(Hints) to respect GeoTools init configuration. + + 3 + + + + + + + + + + + Notice use of TransformerFactory.newTransformer(Source) which should be avoided in favor of + XMLUtils.newTransformer(Source,Hints) to respect GeoTools init configuration. + + 3 + + + + + + + + + + + Notice use of SAXParserFactory.newInstance() which should be avoided in favor of + XMLUtils.newSAXParserFactory(Hints) to respect GeoTools init configuration. + + 3 + + + + + + + + + + + Notice use of SAXParserFactory.newSAXParser() which should be avoided in favor of + XMLUtils.newSAXParser(Hints) to respect GeoTools init configuration. + + 3 + + + + + + + + + + + + Notice use of SAXParserFactory.newSAXParser() which should be avoided in favor of + XMLUtils.newSAXParser(Hints) to respect GeoTools init configuration. + + 3 + + + + + + + + + + + + Notice use of SchemaFactory.newInstance() which should be avoided in favor of + XMLUtils.newInstance(Hints) to respect GeoTools init configuration. + + 3 + + + + + + + + + diff --git a/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSGetCapabilitiesTest.java b/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSGetCapabilitiesTest.java index 5a68a1533..d2d384af9 100644 --- a/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSGetCapabilitiesTest.java +++ b/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSGetCapabilitiesTest.java @@ -16,8 +16,8 @@ import java.util.HashMap; import java.util.Map; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import org.easymock.EasyMock; +import org.geotools.xml.XMLUtils; import org.geowebcache.config.DefaultGridsets; import org.geowebcache.config.legends.LegendRawInfo; import org.geowebcache.config.legends.LegendsRawInfo; @@ -120,8 +120,7 @@ public void testEscapeXMLChars() throws Exception { String xml = capabilities.generateGetCapabilities(StandardCharsets.UTF_8); - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); + DocumentBuilder builder = XMLUtils.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xml)); Document document = builder.parse(is);