From 56ceb87db6ce59a8cb03df3144173a8b9f7a7d15 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Feb 2021 09:41:06 +0000 Subject: [PATCH 01/11] Bump junit from 4.12 to 4.13.1 in /geowebcache Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.1. - [Release notes](https://github.com/junit-team/junit4/releases) - [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.12.md) - [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13.1) Signed-off-by: dependabot[bot] --- geowebcache/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geowebcache/pom.xml b/geowebcache/pom.xml index 3ae51e5f9..e272b18aa 100644 --- a/geowebcache/pom.xml +++ b/geowebcache/pom.xml @@ -229,7 +229,7 @@ junit junit - 4.12 + 4.13.1 test From ce06f8fd8035ac9fb0fe09b69ceb769ae548f964 Mon Sep 17 00:00:00 2001 From: Andrea Aime Date: Sat, 6 Feb 2021 11:26:50 +0100 Subject: [PATCH 02/11] Enable PMD checks on tests, align PMD config files with GeoTools --- .../arcgis/layer/ArcGISCacheLayer.java | 14 +- .../compact/ArcGISCompactCacheTest.java | 24 +- .../arcgis/config/CacheInfoPersisterTest.java | 11 +- .../arcgis/layer/GridSetBuilderTest.java | 7 +- ...nLayerConformanceWithArcGisLayersTest.java | 1 + ...AbstractAzureBlobStoreIntegrationTest.java | 5 - .../AzureBlobStoreConfigProviderTest.java | 1 + .../azure/AzureBlobStoreDataTest.java | 1 + .../OnlineAzureBlobStoreIntegrationTest.java | 1 - .../org/geowebcache/service/OWSException.java | 2 +- .../storage/CompositeBlobStore.java | 6 +- .../blobstore/file/DefaultFilePathFilter.java | 5 +- .../file/DefaultFilePathGenerator.java | 6 +- .../org/geowebcache/MetastoreRemoverTest.java | 18 +- .../file/XYZFileBlobStoreComformanceTest.java | 3 - .../file/ZXYFilePathGeneratorTest.java | 3 - ...tsConfigurationGridsetConformanceTest.java | 1 + .../config/XMLConfigurationXSchemaTest.java | 53 +- .../parameters/FloatParameterFilterTest.java | 1 - .../IntegerParameterFilterTest.java | 1 - .../geowebcache/grid/GridCalculatorTest.java | 29 - .../geowebcache/layer/wms/HttpClientTest.java | 11 +- .../geowebcache/layer/wms/MetaTileTest.java | 52 +- .../geowebcache/layer/wms/WMSLayerTest.java | 6 +- .../org/geowebcache/mime/XMLMimeTest.java | 2 +- .../storage/BlobStoreSuitabilityTest.java | 10 +- .../geowebcache/storage/BlobStoreTest.java | 15 +- ...BlobStoreConfigurationIntegrationTest.java | 7 - .../storage/StorageBrokerTest.java | 18 +- .../storage/TileRangeIteratorTest.java | 6 +- .../blobstore/memory/MemoryBlobStoreTest.java | 35 +- .../geowebcache/util/MockWMSSourceHelper.java | 4 - .../diskquota/LayerCacheInfoBuilderTest.java | 167 ---- .../diskquota/storage/PagePyramidTest.java | 8 +- .../diskquota/jdbc/FixtureUtilities.java | 2 +- .../diskquota/jdbc/JDBCQuotaStoreTest.java | 29 +- .../diskquota/jdbc/OnlineTestRule.java | 28 +- .../HazelcastCacheProviderTest.java | 28 +- .../georss/GeoRSSTileRangeBuilderTest.java | 16 +- .../georss/RasterMaskTestUtils.java | 6 +- .../georss/StaxGeoRSSReaderTest.java | 40 +- geowebcache/pmd-junit-ruleset.xml | 51 ++ geowebcache/pmd-ruleset.xml | 190 +++-- geowebcache/pom.xml | 2 + .../rest/controller/BlobStoreController.java | 6 +- .../rest/controller/BoundsController.java | 6 +- .../controller/FilterUpdateController.java | 5 +- .../rest/controller/GridSetController.java | 6 +- .../controller/MassTruncateController.java | 7 +- .../rest/controller/ReloadController.java | 7 +- .../rest/controller/SeedController.java | 6 +- .../rest/controller/ServerController.java | 6 +- .../rest/controller/TileLayerController.java | 6 +- .../rest/converter/GWCConverter.java | 5 +- .../geowebcache/rest/service/FormService.java | 11 +- .../rest/bounds/BoundsControllerTest.java | 6 +- .../filter/FilterUpdateControllerTest.java | 6 +- .../geowebcache/rest/reload/ReloadTest.java | 6 +- .../rest/seed/MassTruncateControllerTest.java | 2 - .../rest/service/FormServiceTest.java | 1 - .../org/geowebcache/s3/S3BlobStoreInfo.java | 5 +- .../AbstractS3BlobStoreIntegrationTest.java | 4 - .../s3/OfflineS3BlobStoreIntegrationTest.java | 3 + .../s3/S3BlobStoreConfigProviderTest.java | 1 + .../s3/S3BlobStoreConfigSerializeTest.java | 6 +- .../geowebcache/sqlite/MbtilesPBFTest.java | 3 +- .../sqlite/OperationsRestTest.java | 10 +- .../org/geowebcache/sqlite/SqlitlePerf.java | 75 +- .../org/geowebcache/swift/SwiftBlobStore.java | 17 +- .../geowebcache/swift/SwiftBlobStoreTest.java | 33 +- .../org/geowebcache/swift/SwiftTileTest.java | 16 +- .../swift/SwiftUploadTaskTest.java | 13 +- .../java/org/geowebcache/jetty/JettyRule.java | 1 + .../jetty/RestIntegrationTest.java | 795 ++++++++++-------- .../java/org/geowebcache/jetty/Start.java | 10 +- ...esGridSetConfigurationConformanceTest.java | 1 + ...tiesLayerConfigurationConformanceTest.java | 1 + .../org/geowebcache/io/codec/TestSpring.java | 37 +- .../service/wms/WMSTileFuserTest.java | 37 +- .../service/wmts/WMTSRestTest.java | 5 - .../service/wmts/WMTSServiceTest.java | 3 +- 81 files changed, 1033 insertions(+), 1061 deletions(-) delete mode 100644 geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/LayerCacheInfoBuilderTest.java create mode 100644 geowebcache/pmd-junit-ruleset.xml diff --git a/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/layer/ArcGISCacheLayer.java b/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/layer/ArcGISCacheLayer.java index 9235f1772..68b1dc765 100644 --- a/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/layer/ArcGISCacheLayer.java +++ b/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/layer/ArcGISCacheLayer.java @@ -30,10 +30,20 @@ import org.geowebcache.arcgis.compact.ArcGISCompactCache; import org.geowebcache.arcgis.compact.ArcGISCompactCacheV1; import org.geowebcache.arcgis.compact.ArcGISCompactCacheV2; -import org.geowebcache.arcgis.config.*; +import org.geowebcache.arcgis.config.CacheInfo; +import org.geowebcache.arcgis.config.CacheInfoPersister; +import org.geowebcache.arcgis.config.CacheStorageInfo; +import org.geowebcache.arcgis.config.LODInfo; +import org.geowebcache.arcgis.config.TileCacheInfo; import org.geowebcache.conveyor.Conveyor.CacheResult; import org.geowebcache.conveyor.ConveyorTile; -import org.geowebcache.grid.*; +import org.geowebcache.grid.BoundingBox; +import org.geowebcache.grid.Grid; +import org.geowebcache.grid.GridSet; +import org.geowebcache.grid.GridSetBroker; +import org.geowebcache.grid.GridSubset; +import org.geowebcache.grid.GridSubsetFactory; +import org.geowebcache.grid.OutsideCoverageException; import org.geowebcache.io.FileResource; import org.geowebcache.io.Resource; import org.geowebcache.layer.AbstractTileLayer; diff --git a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/compact/ArcGISCompactCacheTest.java b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/compact/ArcGISCompactCacheTest.java index 169f1430e..f82c5b0f2 100755 --- a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/compact/ArcGISCompactCacheTest.java +++ b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/compact/ArcGISCompactCacheTest.java @@ -107,9 +107,9 @@ public void testBundleFileResourceV1() throws Exception { Assert.assertEquals(6342, resource.getSize()); File f = new File("5_12_7.jpg"); - FileOutputStream fos = new FileOutputStream(f); - resource.transferTo(fos.getChannel()); - fos.close(); + try (FileOutputStream fos = new FileOutputStream(f)) { + resource.transferTo(fos.getChannel()); + } Assert.assertTrue(startsWithJPEGHeader(f)); @@ -120,9 +120,9 @@ public void testBundleFileResourceV1() throws Exception { Assert.assertEquals(6308, resource.getSize()); f = new File("6_25_17.jpg"); - fos = new FileOutputStream(f); - resource.transferTo(fos.getChannel()); - fos.close(); + try (FileOutputStream fos = new FileOutputStream(f)) { + resource.transferTo(fos.getChannel()); + } Assert.assertTrue(startsWithJPEGHeader(f)); @@ -141,9 +141,9 @@ public void testBundleFileResourceV2() throws Exception { Assert.assertEquals(7288, resource.getSize()); File f = new File("4_5_4.jpg"); - FileOutputStream fos = new FileOutputStream(f); - resource.transferTo(fos.getChannel()); - fos.close(); + try (FileOutputStream fos = new FileOutputStream(f)) { + resource.transferTo(fos.getChannel()); + } Assert.assertTrue(startsWithJPEGHeader(f)); @@ -154,9 +154,9 @@ public void testBundleFileResourceV2() throws Exception { Assert.assertEquals(6055, resource.getSize()); f = new File("5_11_5.jpg"); - fos = new FileOutputStream(f); - resource.transferTo(fos.getChannel()); - fos.close(); + try (FileOutputStream fos = new FileOutputStream(f)) { + resource.transferTo(fos.getChannel()); + } Assert.assertTrue(startsWithJPEGHeader(f)); diff --git a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/config/CacheInfoPersisterTest.java b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/config/CacheInfoPersisterTest.java index c1ca377ae..171ee4910 100644 --- a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/config/CacheInfoPersisterTest.java +++ b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/config/CacheInfoPersisterTest.java @@ -228,14 +228,9 @@ public void testLoadCacheInfo_ArcGIS_10() throws Exception { private CacheInfo load(final URL url) throws Exception { CacheInfoPersister persister = new CacheInfoPersister(); - InputStream stream = url.openStream(); - Reader reader = new InputStreamReader(stream); - CacheInfo cacheInfo; - try { - cacheInfo = persister.load(reader); - } finally { - stream.close(); + try (InputStream stream = url.openStream(); + Reader reader = new InputStreamReader(stream)) { + return persister.load(reader); } - return cacheInfo; } } diff --git a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/GridSetBuilderTest.java b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/GridSetBuilderTest.java index 499d20efd..280cf0208 100644 --- a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/GridSetBuilderTest.java +++ b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/GridSetBuilderTest.java @@ -35,12 +35,9 @@ public class GridSetBuilderTest { public void setUp() throws Exception { URL url = getClass().getResource("/arcgis_09.2_conf.xml"); CacheInfoPersister persister = new CacheInfoPersister(); - InputStream stream = url.openStream(); - Reader reader = new InputStreamReader(stream); - try { + try (InputStream stream = url.openStream(); + Reader reader = new InputStreamReader(stream)) { cacheInfo = persister.load(reader); - } finally { - stream.close(); } layerBounds = new BoundingBox(-10, -10, 100, 50); builder = new GridSetBuilder(); diff --git a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/XMLConfigurationLayerConformanceWithArcGisLayersTest.java b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/XMLConfigurationLayerConformanceWithArcGisLayersTest.java index fc9383b68..127fc7e1d 100644 --- a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/XMLConfigurationLayerConformanceWithArcGisLayersTest.java +++ b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/XMLConfigurationLayerConformanceWithArcGisLayersTest.java @@ -205,6 +205,7 @@ protected TileLayerConfiguration getConfig(MockWepAppContextRule extensions) thr } @Override + @Test public void testGetExistingHasGridset() throws Exception { Optional retrieved = getInfo(config, getExistingInfo()); assertThat( diff --git a/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AbstractAzureBlobStoreIntegrationTest.java b/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AbstractAzureBlobStoreIntegrationTest.java index 8d9c55ffd..026fdbab9 100644 --- a/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AbstractAzureBlobStoreIntegrationTest.java +++ b/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AbstractAzureBlobStoreIntegrationTest.java @@ -278,7 +278,6 @@ public void testDeleteLayer() throws Exception { // check the tiles are gone too, give it up to 100 seconds long start = System.currentTimeMillis(); - boolean allDeleted = false; boolean t20Deleted = false, t21Deleted = false, t22Deleted = false; while (System.currentTimeMillis() - start < 100000 && (!t20Deleted || !t21Deleted || !t22Deleted)) { @@ -604,10 +603,6 @@ private void seed( } } - private TileObject put(long x, long y, int z) throws StorageException { - return put(x, y, z, DEFAULT_GRIDSET, DEFAULT_FORMAT, null); - } - private TileObject put( long x, long y, diff --git a/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AzureBlobStoreConfigProviderTest.java b/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AzureBlobStoreConfigProviderTest.java index 0022e84ea..81af95560 100644 --- a/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AzureBlobStoreConfigProviderTest.java +++ b/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AzureBlobStoreConfigProviderTest.java @@ -27,6 +27,7 @@ public class AzureBlobStoreConfigProviderTest { @Before + @SuppressWarnings("PMD.CloseResource") public void setUp() throws Exception { System.setProperty("CONTAINER", "MYCONTAINER"); System.setProperty("MYKEY", "99942777gfa+"); diff --git a/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AzureBlobStoreDataTest.java b/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AzureBlobStoreDataTest.java index 79bceaba9..bafee3db6 100644 --- a/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AzureBlobStoreDataTest.java +++ b/geowebcache/azureblob/src/test/java/org/geowebcache/azure/AzureBlobStoreDataTest.java @@ -26,6 +26,7 @@ public class AzureBlobStoreDataTest { @Before + @SuppressWarnings("PMD.CloseResource") public void setUp() throws Exception { System.setProperty("CONTAINER", "MYCONTAINER"); System.setProperty("ACCOUNT_NAME", "MYNAME"); diff --git a/geowebcache/azureblob/src/test/java/org/geowebcache/azure/OnlineAzureBlobStoreIntegrationTest.java b/geowebcache/azureblob/src/test/java/org/geowebcache/azure/OnlineAzureBlobStoreIntegrationTest.java index 800db3a1b..d52c0b232 100644 --- a/geowebcache/azureblob/src/test/java/org/geowebcache/azure/OnlineAzureBlobStoreIntegrationTest.java +++ b/geowebcache/azureblob/src/test/java/org/geowebcache/azure/OnlineAzureBlobStoreIntegrationTest.java @@ -35,7 +35,6 @@ protected AzureBlobStoreData getConfiguration() { @Test public void testCreatesStoreMetadataOnStart() { String prefix = tempFolder.getConfig().getPrefix(); - String container = tempFolder.getConfig().getContainer(); // if the file does not exist a StorageException will be thrown int status = tempFolder diff --git a/geowebcache/core/src/main/java/org/geowebcache/service/OWSException.java b/geowebcache/core/src/main/java/org/geowebcache/service/OWSException.java index fe4dff183..eadbae95f 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/service/OWSException.java +++ b/geowebcache/core/src/main/java/org/geowebcache/service/OWSException.java @@ -16,7 +16,7 @@ import org.geowebcache.io.ByteArrayResource; import org.geowebcache.io.Resource; -import org.owasp.encoder.*; +import org.owasp.encoder.Encode; public class OWSException extends Exception { private static final long serialVersionUID = -8024005353689857211L; diff --git a/geowebcache/core/src/main/java/org/geowebcache/storage/CompositeBlobStore.java b/geowebcache/core/src/main/java/org/geowebcache/storage/CompositeBlobStore.java index 52dbe5f4a..144cddea1 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/CompositeBlobStore.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/CompositeBlobStore.java @@ -30,7 +30,11 @@ import org.apache.commons.logging.LogFactory; import org.geowebcache.GeoWebCacheException; import org.geowebcache.GeoWebCacheExtensions; -import org.geowebcache.config.*; +import org.geowebcache.config.BlobStoreConfigurationListener; +import org.geowebcache.config.BlobStoreInfo; +import org.geowebcache.config.ConfigurationException; +import org.geowebcache.config.FileBlobStoreInfo; +import org.geowebcache.config.ServerConfiguration; import org.geowebcache.layer.TileLayer; import org.geowebcache.layer.TileLayerDispatcher; import org.geowebcache.locks.LockProvider; diff --git a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathFilter.java b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathFilter.java index 327cd2b64..2a03c7c32 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathFilter.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathFilter.java @@ -14,7 +14,10 @@ */ package org.geowebcache.storage.blobstore.file; -import static org.geowebcache.storage.blobstore.file.FilePathUtils.*; +import static org.geowebcache.storage.blobstore.file.FilePathUtils.filteredGridSetId; +import static org.geowebcache.storage.blobstore.file.FilePathUtils.filteredLayerName; +import static org.geowebcache.storage.blobstore.file.FilePathUtils.findParameter; +import static org.geowebcache.storage.blobstore.file.FilePathUtils.findZoomLevel; import com.google.common.base.Preconditions; import java.io.File; diff --git a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathGenerator.java b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathGenerator.java index 19b89ad99..110a83734 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathGenerator.java +++ b/geowebcache/core/src/main/java/org/geowebcache/storage/blobstore/file/DefaultFilePathGenerator.java @@ -14,7 +14,11 @@ */ package org.geowebcache.storage.blobstore.file; -import static org.geowebcache.storage.blobstore.file.FilePathUtils.*; +import static org.geowebcache.storage.blobstore.file.FilePathUtils.appendFiltered; +import static org.geowebcache.storage.blobstore.file.FilePathUtils.appendGridsetZoomLevelDir; +import static org.geowebcache.storage.blobstore.file.FilePathUtils.filteredGridSetId; +import static org.geowebcache.storage.blobstore.file.FilePathUtils.findZoomLevel; +import static org.geowebcache.storage.blobstore.file.FilePathUtils.zeroPadder; import static org.geowebcache.util.FileUtils.listFilesNullSafe; import java.io.File; diff --git a/geowebcache/core/src/test/java/org/geowebcache/MetastoreRemoverTest.java b/geowebcache/core/src/test/java/org/geowebcache/MetastoreRemoverTest.java index 11e7e1b6d..cece31e9e 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/MetastoreRemoverTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/MetastoreRemoverTest.java @@ -43,18 +43,16 @@ public void testMigrationWithDates() throws Exception { testMigration(true); } - public void testMigration(boolean migrateCreationDates) throws Exception { + protected void testMigration(boolean migrateCreationDates) throws Exception { System.setProperty("MIGRATE_CREATION_DATES", String.valueOf(migrateCreationDates)); // the remover does the migration on instantiation - MetastoreRemover remover = - new MetastoreRemover( - new DefaultStorageFinder(new ApplicationContextProvider()) { - @Override - public synchronized String getDefaultPath() - throws ConfigurationException { - return root.toString(); - } - }); + new MetastoreRemover( + new DefaultStorageFinder(new ApplicationContextProvider()) { + @Override + public synchronized String getDefaultPath() throws ConfigurationException { + return root.toString(); + } + }); // the first param has been removed and replaced, the file last modified date has been // replaced diff --git a/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/XYZFileBlobStoreComformanceTest.java b/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/XYZFileBlobStoreComformanceTest.java index 2da6d822b..d15740868 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/XYZFileBlobStoreComformanceTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/XYZFileBlobStoreComformanceTest.java @@ -32,8 +32,6 @@ import org.geowebcache.grid.GridSubsetFactory; import org.geowebcache.layer.TileLayer; import org.geowebcache.layer.TileLayerDispatcher; -import org.geowebcache.locks.LockProvider; -import org.geowebcache.locks.NoOpLockProvider; import org.geowebcache.storage.AbstractBlobStoreTest; import org.geowebcache.storage.blobstore.file.FileBlobStore; import org.geowebcache.storage.blobstore.file.XYZFilePathGenerator; @@ -58,7 +56,6 @@ public static Collection data() { @Override public void createTestUnit() throws Exception { this.layers = createMock(TileLayerDispatcher.class); - LockProvider lockProvider = new NoOpLockProvider(); GridSet wgs84Grid = new DefaultGridsets(false, false).worldEpsg4326(); GridSubset gridSubset = GridSubsetFactory.createGridSubSet(wgs84Grid); Stream.of("testLayer", "testLayer1", "testLayer2") diff --git a/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/ZXYFilePathGeneratorTest.java b/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/ZXYFilePathGeneratorTest.java index 5a04333b0..91c340c97 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/ZXYFilePathGeneratorTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/ZXYFilePathGeneratorTest.java @@ -19,8 +19,6 @@ import org.geowebcache.grid.GridSubsetFactory; import org.geowebcache.layer.TileLayer; import org.geowebcache.layer.TileLayerDispatcher; -import org.geowebcache.locks.LockProvider; -import org.geowebcache.locks.NoOpLockProvider; import org.geowebcache.mime.ImageMime; import org.geowebcache.storage.TileObject; import org.geowebcache.storage.blobstore.file.FilePathGenerator; @@ -54,7 +52,6 @@ public void setUp() throws Exception { testRoot.mkdir(); TileLayerDispatcher layers = createMock(TileLayerDispatcher.class); - LockProvider lockProvider = new NoOpLockProvider(); String name = "states"; TileLayer mock = createMock(name, TileLayer.class); expect(mock.getName()).andStubReturn(name); diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/DefaultGridsetsConfigurationGridsetConformanceTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/DefaultGridsetsConfigurationGridsetConformanceTest.java index d12ae861a..da30357b0 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/DefaultGridsetsConfigurationGridsetConformanceTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/DefaultGridsetsConfigurationGridsetConformanceTest.java @@ -101,6 +101,7 @@ protected void modifyInfo(GridSetConfiguration config, GridSet info) throws Exce } @Override + @Test public void testCanSaveGoodInfo() throws Exception { // Should not be able to save anything as it is read only assertThat(config.canSave(getGoodInfo("test", 1)), equalTo(false)); diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationXSchemaTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationXSchemaTest.java index fe5ee28f6..65ad939cb 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationXSchemaTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationXSchemaTest.java @@ -42,16 +42,17 @@ public class XMLConfigurationXSchemaTest { public void testNotAllowNonGWCClass() throws Exception { // Check that classes from other packages on the class path can't be serialized ContextualConfigurationProvider.Context pc = ContextualConfigurationProvider.Context.REST; - WebApplicationContext wac = new StaticWebApplicationContext(); + try (StaticWebApplicationContext wac = new StaticWebApplicationContext()) { - XStream xs = new GeoWebCacheXStream(); + XStream xs = new GeoWebCacheXStream(); - xs = XMLConfiguration.getConfiguredXStreamWithContext(xs, wac, pc); + xs = XMLConfiguration.getConfiguredXStreamWithContext(xs, wac, pc); - exception.expect(com.thoughtworks.xstream.security.ForbiddenClassException.class); + exception.expect(com.thoughtworks.xstream.security.ForbiddenClassException.class); - @SuppressWarnings("unused") - Object o = xs.fromXML("<" + org.easymock.Capture.class.getCanonicalName() + " />"); + @SuppressWarnings("unused") + Object o = xs.fromXML("<" + org.easymock.Capture.class.getCanonicalName() + " />"); + } } @Ignore // Need to tighten the XStream permissions to get this to pass @@ -59,16 +60,18 @@ public void testNotAllowNonGWCClass() throws Exception { public void testNotAllowNonXMLGWCClass() throws Exception { // Check that a class in GWC that shouldn't be serialized to XML can't be ContextualConfigurationProvider.Context pc = ContextualConfigurationProvider.Context.REST; - WebApplicationContext wac = new StaticWebApplicationContext(); + try (StaticWebApplicationContext wac = new StaticWebApplicationContext()) { - XStream xs = new GeoWebCacheXStream(); + XStream xs = new GeoWebCacheXStream(); - xs = XMLConfiguration.getConfiguredXStreamWithContext(xs, wac, pc); + xs = XMLConfiguration.getConfiguredXStreamWithContext(xs, wac, pc); - exception.expect(com.thoughtworks.xstream.security.ForbiddenClassException.class); + exception.expect(com.thoughtworks.xstream.security.ForbiddenClassException.class); - @SuppressWarnings("unused") - Object o = xs.fromXML("<" + XMLConfigurationXSchemaTest.class.getCanonicalName() + " />"); + @SuppressWarnings("unused") + Object o = + xs.fromXML("<" + XMLConfigurationXSchemaTest.class.getCanonicalName() + " />"); + } } @Test @@ -115,14 +118,15 @@ public void testPropertyCanAllow() throws Exception { whitelistProperty.setValue("org.easymock.**"); ContextualConfigurationProvider.Context pc = ContextualConfigurationProvider.Context.REST; - WebApplicationContext wac = new StaticWebApplicationContext(); - XStream xs = new GeoWebCacheXStream(); + try (StaticWebApplicationContext wac = new StaticWebApplicationContext()) { + XStream xs = new GeoWebCacheXStream(); - xs = XMLConfiguration.getConfiguredXStreamWithContext(xs, wac, pc); + xs = XMLConfiguration.getConfiguredXStreamWithContext(xs, wac, pc); - Object o = xs.fromXML("<" + org.easymock.Capture.class.getCanonicalName() + " />"); + Object o = xs.fromXML("<" + org.easymock.Capture.class.getCanonicalName() + " />"); - assertThat(o, instanceOf(org.easymock.Capture.class)); + assertThat(o, instanceOf(org.easymock.Capture.class)); + } } @Test @@ -132,15 +136,16 @@ public void testPropertyCanAllowMultiple() throws Exception { whitelistProperty.setValue("org.easymock.**; org.junit.**"); ContextualConfigurationProvider.Context pc = ContextualConfigurationProvider.Context.REST; - WebApplicationContext wac = new StaticWebApplicationContext(); - XStream xs = new GeoWebCacheXStream(); + try (StaticWebApplicationContext wac = new StaticWebApplicationContext()) { + XStream xs = new GeoWebCacheXStream(); - xs = XMLConfiguration.getConfiguredXStreamWithContext(xs, wac, pc); + xs = XMLConfiguration.getConfiguredXStreamWithContext(xs, wac, pc); - Object o1 = xs.fromXML("<" + org.easymock.Capture.class.getCanonicalName() + " />"); - Object o2 = xs.fromXML("<" + org.junit.rules.TestName.class.getCanonicalName() + " />"); + Object o1 = xs.fromXML("<" + org.easymock.Capture.class.getCanonicalName() + " />"); + Object o2 = xs.fromXML("<" + org.junit.rules.TestName.class.getCanonicalName() + " />"); - assertThat(o1, instanceOf(org.easymock.Capture.class)); - assertThat(o2, instanceOf(org.junit.rules.TestName.class)); + assertThat(o1, instanceOf(org.easymock.Capture.class)); + assertThat(o2, instanceOf(org.junit.rules.TestName.class)); + } } } diff --git a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/FloatParameterFilterTest.java b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/FloatParameterFilterTest.java index d3c64ed32..c6e060fe6 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/FloatParameterFilterTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/FloatParameterFilterTest.java @@ -79,7 +79,6 @@ public void testBasic() throws Exception { @Test public void testThreshold() throws Exception { filter.setThreshold(15f); - ; assertThat(filter.getLegalValues(), containsInAnyOrder("42.0", "6.283", "-17.5")); diff --git a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/IntegerParameterFilterTest.java b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/IntegerParameterFilterTest.java index 3e6d1fcbd..627ac9673 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/IntegerParameterFilterTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/IntegerParameterFilterTest.java @@ -76,7 +76,6 @@ public void testBasic() throws Exception { @Test public void testThreshold() throws Exception { filter.setThreshold(15); - ; for (String test : Arrays.asList("42", "2", "0", "-1", "-200")) { assertThat( diff --git a/geowebcache/core/src/test/java/org/geowebcache/grid/GridCalculatorTest.java b/geowebcache/core/src/test/java/org/geowebcache/grid/GridCalculatorTest.java index 95ad73339..d2fc9695c 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/grid/GridCalculatorTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/grid/GridCalculatorTest.java @@ -2,7 +2,6 @@ import static org.junit.Assert.assertArrayEquals; -import java.util.Arrays; import java.util.Collections; import org.geowebcache.config.DefaultGridsets; import org.junit.Assert; @@ -34,10 +33,6 @@ public void test1gridLevels4326() throws Exception { for (int i = 0; i < solution.length; i++) { long[] bounds = grid.getCoverage(i); - if (!Arrays.equals(solution[i], bounds)) { - System.out.println( - i + " " + Arrays.toString(solution[i]) + " " + Arrays.toString(bounds)); - } assertArrayEquals(solution[i], bounds); } } @@ -62,9 +57,6 @@ public void test2gridLevels4326() throws Exception { for (int i = 0; i < solution.length; i++) { long[] bounds = grid.getCoverage(i); - if (!Arrays.equals(solution[i], bounds)) { - System.out.println(Arrays.toString(solution[i]) + " " + Arrays.toString(bounds)); - } assertArrayEquals(solution[i], bounds); } } @@ -90,9 +82,6 @@ public void test3gridLevels4326() throws Exception { for (int i = 0; i < solution.length; i++) { long[] bounds = grid.getCoverage(i); - if (!Arrays.equals(solution[i], bounds)) { - System.out.println(Arrays.toString(solution[i]) + " " + Arrays.toString(bounds)); - } assertArrayEquals(solution[i], bounds); } } @@ -119,9 +108,6 @@ public void test4gridLevels4326() throws Exception { for (int i = 0; i < solution.length; i++) { long[] bounds = grid.getCoverage(i); - if (!Arrays.equals(solution[i], bounds)) { - System.out.println(Arrays.toString(solution[i]) + " " + Arrays.toString(bounds)); - } assertArrayEquals(solution[i], bounds); } } @@ -140,10 +126,6 @@ public void test1gridLevels900913() throws Exception { for (int i = 0; i < solution.length; i++) { long[] bounds = grid.getCoverage(i); - if (!Arrays.equals(solution[i], bounds)) { - System.out.println("test1gridLevels900913, level " + i); - System.out.println(Arrays.toString(solution[i]) + " " + Arrays.toString(bounds)); - } assertArrayEquals(solution[i], bounds); } } @@ -168,10 +150,6 @@ public void test2gridLevels900913() throws Exception { for (int i = 0; i < solution.length; i++) { long[] bounds = grid.getCoverage(i); - if (!Arrays.equals(solution[i], bounds)) { - System.out.println("test2gridLevels900913, level " + i); - System.out.println(Arrays.toString(solution[i]) + " " + Arrays.toString(bounds)); - } assertArrayEquals(solution[i], bounds); } } @@ -197,10 +175,6 @@ public void test3gridLevels900913() throws Exception { for (int i = 0; i < solution.length; i++) { long[] bounds = grid.getCoverage(i); - if (!Arrays.equals(solution[i], bounds)) { - System.out.println("test3gridLevels900913, level " + i); - System.out.println(Arrays.toString(solution[i]) + " " + Arrays.toString(bounds)); - } assertArrayEquals(solution[i], bounds); } } @@ -260,9 +234,6 @@ public void test5gridLevels4326() throws Exception { for (int i = 0; i < solution.length; i++) { long[] bounds = grid.getCoverage(i); - if (!Arrays.equals(solution[i], bounds)) { - System.out.println(Arrays.toString(solution[i]) + " " + Arrays.toString(bounds)); - } assertArrayEquals(solution[i], bounds); } } diff --git a/geowebcache/core/src/test/java/org/geowebcache/layer/wms/HttpClientTest.java b/geowebcache/core/src/test/java/org/geowebcache/layer/wms/HttpClientTest.java index b1c20c6a1..d764a1d32 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/layer/wms/HttpClientTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/layer/wms/HttpClientTest.java @@ -19,11 +19,15 @@ import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.auth.AuthScope; import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.junit.Before; import org.junit.Test; public class HttpClientTest { + static final Log LOG = LogFactory.getLog(HttpClientTest.class); + static final boolean RUN_PERFORMANCE_TEST = false; static final int LOOP_COUNT = 100000; @@ -54,17 +58,12 @@ public void testHttpClientConstruction() throws Exception { hc.getState().setCredentials(authscope, credentials); getMethod.setDoAuthentication(true); hc.getParams().setAuthenticationPreemptive(true); - - if (hc.getHostConfiguration().getPort() == 0) { - // Dummy - } - // System.out.print(i); } long stop = System.currentTimeMillis(); long diff = (stop - start); - System.out.println("Time to create " + LOOP_COUNT + " in " + diff + " milliseconds"); + LOG.info("Time to create " + LOOP_COUNT + " in " + diff + " milliseconds"); } } } diff --git a/geowebcache/core/src/test/java/org/geowebcache/layer/wms/MetaTileTest.java b/geowebcache/core/src/test/java/org/geowebcache/layer/wms/MetaTileTest.java index bfbde0ca1..243f36cac 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/layer/wms/MetaTileTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/layer/wms/MetaTileTest.java @@ -5,7 +5,6 @@ import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.awt.image.RenderedImage; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; @@ -56,18 +55,7 @@ public void test1MetaTile() throws Exception { metaHeight, Collections.singletonMap("test", "test1")); - long[] solution = {0, 0, 0, 0, 0}; - boolean test = Arrays.equals(mt.getMetaTileGridBounds(), solution); - if (!test) { - System.out.println("1 - " + mt.debugString()); - System.out.println( - "test1MetaTile {" - + Arrays.toString(solution) - + "} {" - + Arrays.toString(mt.getMetaTileGridBounds()) - + "}"); - } - Assert.assertTrue(test); + Assert.assertArrayEquals(new long[] {0, 0, 0, 0, 0}, mt.getMetaTileGridBounds()); } @Test @@ -92,17 +80,7 @@ public void test2MetaTile() throws Exception { Collections.singletonMap("test", "test1")); long[] solution = {126, 63, 127, 63, 6}; - boolean test = Arrays.equals(mt.getMetaTileGridBounds(), solution); - if (!test) { - System.out.println("2 - " + mt.debugString()); - System.out.println( - "test2MetaTile {" - + Arrays.toString(solution) - + "} {" - + Arrays.toString(mt.getMetaTileGridBounds()) - + "}"); - } - Assert.assertTrue(test); + Assert.assertArrayEquals(mt.getMetaTileGridBounds(), solution); } @Test @@ -127,17 +105,7 @@ public void test3MetaTile() throws Exception { Collections.singletonMap("test", "test1")); long[] solution = {0, 0, 0, 0, 0}; - boolean test = Arrays.equals(mt.getMetaTileGridBounds(), solution); - if (!test) { - System.out.println("3 - " + mt.debugString()); - System.out.println( - "test3MetaTile {" - + Arrays.toString(solution) - + "} {" - + Arrays.toString(mt.getMetaTileGridBounds()) - + "}"); - } - Assert.assertTrue(test); + Assert.assertArrayEquals(mt.getMetaTileGridBounds(), solution); } @Test @@ -163,19 +131,7 @@ public void test4MetaTile() throws Exception { Collections.singletonMap("test", "test1")); long[] solution = {69, 69, 63, 63, 6}; - boolean test = Arrays.equals(mt.getMetaTileGridBounds(), solution); - if (test) { - - } else { - System.out.println("4 - " + mt.debugString()); - System.out.println( - "test4MetaTile {" - + Arrays.toString(solution) - + "} {" - + Arrays.toString(mt.getMetaTileGridBounds()) - + "}"); - } - Assert.assertTrue(test); + Assert.assertArrayEquals(mt.getMetaTileGridBounds(), solution); } /** @throws Exception */ diff --git a/geowebcache/core/src/test/java/org/geowebcache/layer/wms/WMSLayerTest.java b/geowebcache/core/src/test/java/org/geowebcache/layer/wms/WMSLayerTest.java index 23e350726..20d181954 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/layer/wms/WMSLayerTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/layer/wms/WMSLayerTest.java @@ -307,7 +307,7 @@ public void checkJpegPng( public void testCascadeGetLegendGraphics() throws Exception { // setup the layer WMSLayer layer = createWMSLayer("image/png"); - final byte[] responseBody = new String("Fake body").getBytes(); + final byte[] responseBody = "Fake body".getBytes(); layer.setSourceHelper( new WMSHttpHelper() { @Override @@ -369,7 +369,7 @@ public GetMethod executeRequest( public void testCascadeWithoutContentType() throws Exception { // setup the layer WMSLayer layer = createWMSLayer("image/png"); - final byte[] responseBody = new String("Fake body").getBytes(); + final byte[] responseBody = "Fake body".getBytes(); layer.setSourceHelper( new WMSHttpHelper() { @Override @@ -494,8 +494,6 @@ public void testMinMaxCacheGetTile() throws Exception { // assertTrue(Math.abs(494 - mock.cacheMisses.get()) < 10); // assertTrue(Math.abs(172 - mock.wmsMetaRequestCounter.get()) < 10); // stats - System.out.println("transientCacheSize " + mock.transientCache.size()); - System.out.println("transientCacheStorage " + mock.transientCache.storageSize()); } private void seedTiles(StorageBroker storageBroker, TileRange tr, final WMSLayer tl) diff --git a/geowebcache/core/src/test/java/org/geowebcache/mime/XMLMimeTest.java b/geowebcache/core/src/test/java/org/geowebcache/mime/XMLMimeTest.java index d91cf384e..a98c7f22c 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/mime/XMLMimeTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/mime/XMLMimeTest.java @@ -133,6 +133,6 @@ public void testUnknownExtension() throws MimeException { @Test(expected = MimeException.class) public void testUnknownFormat() throws MimeException { - MimeType result = MimeType.createFromFormat("xxx/xxx"); + MimeType.createFromFormat("xxx/xxx"); } } diff --git a/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreSuitabilityTest.java b/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreSuitabilityTest.java index 46acfba2f..673e3173f 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreSuitabilityTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreSuitabilityTest.java @@ -54,7 +54,7 @@ public BlobStoreSuitabilityTest() { @SuppressWarnings({"rawtypes", "unchecked"}) @Theory - public void testEmptyOk(Object persistenceLocation) throws Exception { + public void emptyOk(Object persistenceLocation) throws Exception { suitability.setValue(CompositeBlobStore.StoreSuitabilityCheck.EMPTY); assumeThat(persistenceLocation, empty()); @@ -64,7 +64,7 @@ public void testEmptyOk(Object persistenceLocation) throws Exception { @SuppressWarnings({"rawtypes", "unchecked"}) @Theory - public void testEmptyFail(Object persistenceLocation) throws Exception { + public void emptyFail(Object persistenceLocation) throws Exception { suitability.setValue(CompositeBlobStore.StoreSuitabilityCheck.EMPTY); assumeThat(persistenceLocation, not(empty())); @@ -75,7 +75,7 @@ public void testEmptyFail(Object persistenceLocation) throws Exception { @SuppressWarnings({"unchecked", "rawtypes"}) @Theory - public void testExistingOk(Object persistenceLocation) throws Exception { + public void existingOk(Object persistenceLocation) throws Exception { suitability.setValue(CompositeBlobStore.StoreSuitabilityCheck.EXISTING); assumeThat(persistenceLocation, (either(empty()).or(existing()))); @@ -85,7 +85,7 @@ public void testExistingOk(Object persistenceLocation) throws Exception { @SuppressWarnings({"unchecked", "rawtypes"}) @Theory - public void testExistingFail(Object persistenceLocation) throws Exception { + public void existingFail(Object persistenceLocation) throws Exception { suitability.setValue(CompositeBlobStore.StoreSuitabilityCheck.EXISTING); assumeThat(persistenceLocation, not(either(empty()).or(existing()))); @@ -95,7 +95,7 @@ public void testExistingFail(Object persistenceLocation) throws Exception { } @Theory - public void testNoneOk(Object persistenceLocation) throws Exception { + public void noneOk(Object persistenceLocation) throws Exception { suitability.setValue(CompositeBlobStore.StoreSuitabilityCheck.NONE); BlobStore store = create(persistenceLocation); diff --git a/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreTest.java b/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreTest.java index e1397f1be..950c49db6 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreTest.java @@ -47,9 +47,10 @@ public void tearDown() throws Exception { if (fh.exists()) { FileUtils.deleteDirectory(fh); if (fh.exists()) { - System.out.println( - "Unable to delete " + org.geowebcache.util.FileUtils.printFileTree(fh)); - Assert.fail("Could not cleanup blob store directory"); + Assert.fail( + "Could not cleanup blob store directory\n" + + "Unable to delete " + + org.geowebcache.util.FileUtils.printFileTree(fh)); } } } @@ -253,9 +254,11 @@ public BlobStore setup() throws Exception { if (!fh.exists()) { Files.createDirectory(fh.toPath()); if (!fh.exists()) { - System.out.println( - "Unable to create " + org.geowebcache.util.FileUtils.printFileTree(fh)); - throw new StorageException("Unable to create " + fh.getAbsolutePath()); + throw new StorageException( + "Unable to create " + + fh.getAbsolutePath() + + "\nUnable to create " + + org.geowebcache.util.FileUtils.printFileTree(fh)); } } diff --git a/geowebcache/core/src/test/java/org/geowebcache/storage/CompositeBlobStoreConfigurationIntegrationTest.java b/geowebcache/core/src/test/java/org/geowebcache/storage/CompositeBlobStoreConfigurationIntegrationTest.java index a64b8e7a2..672465a34 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/storage/CompositeBlobStoreConfigurationIntegrationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/storage/CompositeBlobStoreConfigurationIntegrationTest.java @@ -175,9 +175,6 @@ public void testModifySetDefault() throws IOException, GeoWebCacheException { public void testRename() throws IOException, GeoWebCacheException { testAdd(); - FileBlobStoreInfo info = - (FileBlobStoreInfo) blobStoreAggregator.getBlobStore("newFileBlobStore"); - blobStoreAggregator.renameBlobStore("newFileBlobStore", "renamedFileBlobStore"); assertFalse(compositeBlobStore.blobStores.containsKey("newFileBlobStore")); assertTrue(compositeBlobStore.blobStores.containsKey("renamedFileBlobStore")); @@ -187,9 +184,6 @@ public void testRename() throws IOException, GeoWebCacheException { public void testRenameDefault() throws IOException, GeoWebCacheException { testAddDefault(); - FileBlobStoreInfo info = - (FileBlobStoreInfo) blobStoreAggregator.getBlobStore("newFileBlobStore"); - blobStoreAggregator.renameBlobStore("newFileBlobStore", "renamedFileBlobStore"); assertFalse(compositeBlobStore.blobStores.containsKey("newFileBlobStore")); assertTrue(compositeBlobStore.blobStores.containsKey("renamedFileBlobStore")); @@ -221,7 +215,6 @@ public void testRemoveDefault() throws IOException { "message", containsString("default blob store can't be removed")))); blobStoreAggregator.removeBlobStore("newFileBlobStore"); - System.out.println("FOO"); } finally { assertTrue(compositeBlobStore.blobStores.containsKey("newFileBlobStore")); assertTrue(blobStoreAggregator.blobStoreExists("newFileBlobStore")); diff --git a/geowebcache/core/src/test/java/org/geowebcache/storage/StorageBrokerTest.java b/geowebcache/core/src/test/java/org/geowebcache/storage/StorageBrokerTest.java index 12791de45..3f2dcc4ce 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/storage/StorageBrokerTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/storage/StorageBrokerTest.java @@ -1,12 +1,16 @@ package org.geowebcache.storage; import java.io.File; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.geowebcache.io.ByteArrayResource; import org.geowebcache.io.Resource; import org.geowebcache.storage.blobstore.file.FileBlobStore; import org.junit.Test; public class StorageBrokerTest { + static final Log LOG = LogFactory.getLog(StorageBrokerTest.class); + public static final String TEST_DB_NAME = "gwcTestStorageBroker"; public static final String TEST_BLOB_DIR_NAME = "gwcTestBlobs"; @@ -36,7 +40,6 @@ public void testTileSingleThread() throws Exception { public void testTileMultiThread() throws Exception { if (!RUN_PERFORMANCE_TESTS) return; - System.out.println("\n"); StorageBroker sb = resetAndPrepStorageBroker(); long iterations = REPEAT_COUNT; @@ -58,7 +61,7 @@ public void testTileMultiThread() throws Exception { long perSec = totalTiles * 1000 / diff; long bw = (20 * 1024 * 8 * perSec) / 1000000; - System.out.println( + LOG.info( "Total time: " + diff + "ms for " @@ -74,10 +77,7 @@ public void testTileMultiThread() throws Exception { } private StorageBroker resetAndPrepStorageBroker() throws Exception { - System.out.println("Deleting old test database."); - String blobPath = findTempDir() + File.separator + TEST_BLOB_DIR_NAME; - System.out.println("Creating new blobstore in " + blobPath); File blobDirs = new File(blobPath); if (!blobDirs.exists() && !blobDirs.mkdirs()) { @@ -85,15 +85,12 @@ private StorageBroker resetAndPrepStorageBroker() throws Exception { } BlobStore blobStore = new FileBlobStore(blobPath); - TransientCache transCache = new TransientCache(100, 1024, 2000); StorageBroker sb = new DefaultStorageBroker(blobStore, new TransientCache(100, 1024, 2000)); // long[] xyz = {1L,2L,3L}; Resource blob = new ByteArrayResource(new byte[20 * 1024]); - System.out.println("Inserting into database, " + TILE_PUT_COUNT + " tiles"); - long startInsert = System.currentTimeMillis(); for (int i = 1; i < TILE_PUT_COUNT; i++) { long tmp = (long) Math.log(i) + 1; @@ -106,8 +103,7 @@ private StorageBroker resetAndPrepStorageBroker() throws Exception { } long stopInsert = System.currentTimeMillis(); - System.out.println( - TILE_PUT_COUNT + " inserts took " + Long.toString(stopInsert - startInsert) + "ms"); + LOG.info(TILE_PUT_COUNT + " inserts took " + (stopInsert - startInsert) + "ms"); return sb; } @@ -135,7 +131,7 @@ private void runBasicTileTest(StorageBroker sb, long run, String name) throws St long stop = System.currentTimeMillis(); - System.out.println( + LOG.info( name + " - run " + run diff --git a/geowebcache/core/src/test/java/org/geowebcache/storage/TileRangeIteratorTest.java b/geowebcache/core/src/test/java/org/geowebcache/storage/TileRangeIteratorTest.java index b560bb773..7237648f5 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/storage/TileRangeIteratorTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/storage/TileRangeIteratorTest.java @@ -16,6 +16,8 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.geowebcache.config.DefaultGridsets; import org.geowebcache.grid.BoundingBox; import org.geowebcache.grid.GridSet; @@ -33,6 +35,8 @@ public class TileRangeIteratorTest { + static final Log LOG = LogFactory.getLog(TileRangeIteratorTest.class); + private MimeType mimeType; private String parameters; @@ -120,7 +124,7 @@ public void testTraverseIndividualZoomLevelsNoMetaTilingMultiThreading() throws tilesProcessed); // } sw.stop(); - System.err.println( + LOG.info( nThreads + " threads finished in " + sw.getTotalTimeMillis() diff --git a/geowebcache/core/src/test/java/org/geowebcache/storage/blobstore/memory/MemoryBlobStoreTest.java b/geowebcache/core/src/test/java/org/geowebcache/storage/blobstore/memory/MemoryBlobStoreTest.java index 6e943e8ff..9564ee674 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/storage/blobstore/memory/MemoryBlobStoreTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/storage/blobstore/memory/MemoryBlobStoreTest.java @@ -110,9 +110,10 @@ public void testNullStore() throws Exception { assertEquals(to.getBlobFormat(), to2.getBlobFormat()); // Checks if the resources are equals - InputStream is = to.getBlob().getInputStream(); - InputStream is2 = to2.getBlob().getInputStream(); - checkInputStreams(is, is2); + try (InputStream is = to.getBlob().getInputStream(); + InputStream is2 = to2.getBlob().getInputStream()) { + checkInputStreams(is, is2); + } // Ensure Cache contains the result TileObject to3 = cache.getTileObj(to); @@ -120,9 +121,10 @@ public void testNullStore() throws Exception { assertEquals(to.getBlobFormat(), to3.getBlobFormat()); // Checks if the resources are equals - is = to.getBlob().getInputStream(); - InputStream is3 = to3.getBlob().getInputStream(); - checkInputStreams(is, is3); + try (InputStream is = to.getBlob().getInputStream(); + InputStream is3 = to3.getBlob().getInputStream()) { + checkInputStreams(is, is3); + } // Ensure that NullBlobStore does not contain anything assertFalse(nbs.get(to)); @@ -160,9 +162,10 @@ public void testTilePut() throws Exception { assertEquals(to.getBlobFormat(), to2.getBlobFormat()); // Checks if the resources are equals - InputStream is = to.getBlob().getInputStream(); - InputStream is2 = to2.getBlob().getInputStream(); - checkInputStreams(is, is2); + try (InputStream is = to.getBlob().getInputStream(); + InputStream is2 = to2.getBlob().getInputStream()) { + checkInputStreams(is, is2); + } // Ensure Cache contains the result TileObject to3 = cache.getTileObj(to); @@ -170,9 +173,10 @@ public void testTilePut() throws Exception { assertEquals(to.getBlobFormat(), to3.getBlobFormat()); // Checks if the resources are equals - is = to.getBlob().getInputStream(); - InputStream is3 = to3.getBlob().getInputStream(); - checkInputStreams(is, is3); + try (InputStream is = to.getBlob().getInputStream(); + InputStream is3 = to3.getBlob().getInputStream()) { + checkInputStreams(is, is3); + } } @Test @@ -205,9 +209,10 @@ public void testTileDelete() throws Exception { mbs.get(to2); // Checks if the resources are equals - InputStream is = to2.getBlob().getInputStream(); - InputStream is2 = bytes.getInputStream(); - checkInputStreams(is, is2); + try (InputStream is = to2.getBlob().getInputStream(); + InputStream is2 = bytes.getInputStream()) { + checkInputStreams(is, is2); + } // Delete TileObject TileObject to3 = diff --git a/geowebcache/core/src/test/java/org/geowebcache/util/MockWMSSourceHelper.java b/geowebcache/core/src/test/java/org/geowebcache/util/MockWMSSourceHelper.java index cda0b059a..b15a6dc01 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/util/MockWMSSourceHelper.java +++ b/geowebcache/core/src/test/java/org/geowebcache/util/MockWMSSourceHelper.java @@ -2,7 +2,6 @@ import java.awt.BasicStroke; import java.awt.Color; -import java.awt.Font; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; @@ -25,8 +24,6 @@ import org.geowebcache.mime.MimeType; public class MockWMSSourceHelper extends WMSSourceHelper { - private Font font = Font.decode("Arial-BOLD-14"); - private Map, byte[]> images = new HashMap<>(); @Override @@ -37,7 +34,6 @@ protected void makeRequest( MimeType expectedMimeType, Resource target) throws GeoWebCacheException { - long ts = System.currentTimeMillis(); long[][] tiles; int tileW; int tileH; diff --git a/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/LayerCacheInfoBuilderTest.java b/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/LayerCacheInfoBuilderTest.java deleted file mode 100644 index adc9ee508..000000000 --- a/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/LayerCacheInfoBuilderTest.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * This program is free software: you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - *

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - *

You should have received a copy of the GNU Lesser General Public License along with this - * program. If not, see . - * - * @author Gabriel Roldan (OpenGeo) 2010 - */ -package org.geowebcache.diskquota; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.ExecutorService; -import org.geowebcache.GeoWebCacheException; -import org.geowebcache.filter.parameters.ParametersUtils; -import org.geowebcache.grid.GridSubset; -import org.geowebcache.layer.TileLayer; -import org.geowebcache.mime.MimeType; -import org.geowebcache.storage.TileObject; -import org.geowebcache.storage.blobstore.file.DefaultFilePathGenerator; -import org.geowebcache.storage.blobstore.file.FilePathGenerator; -import org.junit.Test; - -public class LayerCacheInfoBuilderTest { - - private LayerCacheInfoBuilder infoBuilder; - - private final int blockSize = 2048; - - private File rootCacheDir; - - private ExecutorService threadPool; - - FilePathGenerator pathGenerator = - new DefaultFilePathGenerator("") { - protected String getParametersId( - String base, java.util.Map parameters) throws IOException { - // we assume no collisions for these tests - String parametersKvp = ParametersUtils.getKvp(parameters); - return ParametersUtils.buildKey(parametersKvp); - }; - }; - - @Test - public void testFake() {} - - /* - * TODO fix tests /* - * - * @Override protected void setUp() throws Exception { File target = new File("target"); if - * (!target.exists() || !target.isDirectory() || !target.canWrite()) { throw new - * IllegalStateException("Can't set up tests, " + target.getAbsolutePath() + - * " is not a writable directory"); } - * - * rootCacheDir = new File(target, getClass().getSimpleName()); - * FileUtils.rmFileCacheDir(rootCacheDir, null); rootCacheDir.mkdirs(); - * - * threadPool = Executors.newSingleThreadExecutor(); - * - * infoBuilder = new LayerCacheInfoBuilder(rootCacheDir, threadPool); } - * - * @Override protected void tearDown() throws Exception { if (threadPool != null) { - * threadPool.shutdownNow(); } if (rootCacheDir != null) { - * FileUtils.rmFileCacheDir(rootCacheDir, null); } } - * - * public void testBuildCacheInfo() throws MimeException, IOException, InterruptedException { - * - * final String layerName = "MockLayer"; TileLayer mockLayer = - * EasyMock.createMock(TileLayer.class); - * EasyMock.expect(mockLayer.getName()).andReturn(layerName).anyTimes(); GridSet gridSet = new - * GridSetBroker(false, false).WORLD_EPSG4326; GridSubset gridSubset = - * GridSubsetFactory.createGridSubSet(gridSet); EasyMock.expect(mockLayer.getGridSubsets()) - * .andReturn( new Hashtable(Collections.singletonMap( gridSubset.getName(), - * gridSubset))).anyTimes(); EasyMock.replay(mockLayer); - * - * final String gridSetId = gridSubset.getName(); final LayerQuota layerQuota = new - * LayerQuota(layerName, "MockPolicy"); final int numFiles = 10; final int fileSize = - * this.blockSize + 1; - * - * ExpirationPolicy mockPolicy = EasyMock.createMock(ExpirationPolicy.class); - * - * mockPolicy.createTileInfo(EasyMock.eq(layerQuota), EasyMock.eq(gridSetId), - * EasyMock.anyLong(), EasyMock.anyLong(), EasyMock.anyInt()); - * EasyMock.expectLastCall().times(numFiles); EasyMock.replay(mockPolicy); - * - * mockSeed(mockLayer, numFiles, fileSize); - * - * layerQuota.setExpirationPolicy(mockPolicy); - * - * infoBuilder.buildCacheInfo(mockLayer, layerQuota); - * - * // be careful and don't wait more than 30s long startTime = System.currentTimeMillis(); long - * ellapsedTime = 0; while (infoBuilder.isRunning(layerName)) { Thread.sleep(500); ellapsedTime - * = System.currentTimeMillis() - startTime; if (ellapsedTime > 30000) { - * fail(LayerCacheInfoBuilder.class.getSimpleName() + - * ".buildCacheInfo was running for too long, aborting test!"); } } EasyMock.verify(mockLayer); - * EasyMock.verify(mockPolicy); - * - * // was layer used quota updated? final int blockFileSize = (int) Math.ceil((double) fileSize - * / this.blockSize) this.blockSize; final long expectedCacheSize = numFiles * blockFileSize; - * - * Quota expectedUsedQuota = new Quota(expectedCacheSize, StorageUnit.B); - * - * Quota usedQuota = layerQuota.getUsedQuota(); - * - * assertTrue(usedQuota.getBytes().longValue() > 0); - * - * assertEquals(0L, usedQuota.difference(expectedUsedQuota).getBytes().longValue()); } - */ - /** Seeds {@code numFiles} fake tiles of {@code fileSize} each at random tile indices */ - private void mockSeed(TileLayer layer, int numFiles, int fileSize) - throws GeoWebCacheException, IOException { - final String layerName = layer.getName(); - - final GridSubset gridSubset = layer.getGridSubset(layer.getGridSubsets().iterator().next()); - final String gridSetId = gridSubset.getName(); - final String prefix = this.rootCacheDir.getAbsolutePath(); - String format = "image/png"; - final MimeType mimeType = MimeType.createFromFormat(format); - - final byte[] mockTileContents = new byte[fileSize]; - Arrays.fill(mockTileContents, (byte) 0xFF); - - // just to control the same tile is not created more than once - Set addedTiles = new HashSet<>(); - - long[] tileIndex; - while (addedTiles.size() < numFiles) { - int level = - (int) - (gridSubset.getZoomStart() - + ((gridSubset.getZoomStop() - gridSubset.getZoomStart()) - * Math.random())); - - String tileKey = null; - File tilePath; - do { - long[] coverage = gridSubset.getCoverage(level); // {minx,miny,maxx,maxy,z} - long x = (long) (coverage[0] + ((coverage[2] - coverage[0]) * Math.random())); - long y = (long) (coverage[1] + ((coverage[3] - coverage[1]) * Math.random())); - tileIndex = new long[] {x, y, level}; - TileObject tile = - TileObject.createCompleteTileObject( - layerName, tileIndex, gridSetId, format, null, null); - tilePath = pathGenerator.tilePath(tile, mimeType); - tileKey = tilePath.getAbsolutePath(); - } while (addedTiles.contains(tileKey)); - addedTiles.add(tileKey); - - File tileDir = tilePath.getParentFile(); - tileDir.mkdirs(); - try (FileOutputStream fout = new FileOutputStream(tilePath)) { - fout.write(mockTileContents); - } - } - } -} diff --git a/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/storage/PagePyramidTest.java b/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/storage/PagePyramidTest.java index 9dbcdda77..586c33f41 100644 --- a/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/storage/PagePyramidTest.java +++ b/geowebcache/diskquota/core/src/test/java/org/geowebcache/diskquota/storage/PagePyramidTest.java @@ -23,6 +23,8 @@ import java.util.Collections; import java.util.List; import java.util.Locale; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.geowebcache.config.DefaultGridsets; import org.geowebcache.diskquota.storage.PagePyramid.PageLevelInfo; import org.geowebcache.grid.GridSet; @@ -36,6 +38,8 @@ public class PagePyramidTest { + static final Log LOG = LogFactory.getLog(PagePyramidTest.class); + GridSet world_EPSG3857 = new GridSetBroker(Collections.singletonList(new DefaultGridsets(true, false))) .getWorldEpsg3857(); @@ -87,7 +91,7 @@ private void printPyramid(int zoomStart, int zoomStop, PagePyramid pp) { totalPages += levelPages; totalTiles = totalTiles.add(tilesPerPage.multiply(BigInteger.valueOf(levelPages))); - System.out.println( + LOG.info( FilePathUtils.zeroPadder(z, 2) + ": (total pages =" + nf.format(totalPages) @@ -97,7 +101,7 @@ private void printPyramid(int zoomStart, int zoomStop, PagePyramid pp) { + nf.format(tilesPerPage.multiply(BigInteger.valueOf(levelPages))) + ") "); } - System.out.println("Total pages: " + totalPages); + LOG.info("Total pages: " + totalPages); } @Test diff --git a/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/FixtureUtilities.java b/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/FixtureUtilities.java index b413d7d08..c3027ae1e 100644 --- a/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/FixtureUtilities.java +++ b/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/FixtureUtilities.java @@ -87,7 +87,7 @@ public static File getFixtureFile(File fixtureDirectory, String fixtureId) { */ public static void printSkipNotice(String fixtureId, File fixtureFile) { try { - System.out.println( + log.info( "Skipping " + fixtureId + " tests. Fixture file " 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 ec0893984..b822ce57a 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 @@ -12,7 +12,6 @@ import com.google.common.base.Objects; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.math.BigInteger; import java.sql.Connection; import java.sql.SQLException; @@ -23,7 +22,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -101,7 +99,6 @@ protected void setUpInternal() throws Exception { EasyMock.replay(cacheDirFinder); XMLConfiguration xmlConfig = loadXMLConfig(); - LinkedList configList = new LinkedList<>(); extensions.addBean( "xmlConfig", xmlConfig, @@ -312,19 +309,13 @@ protected void cleanupDatabase(DataSource dataSource) throws SQLException { private String[] paramIds; private XMLConfiguration loadXMLConfig() throws Exception { - InputStream is = null; - XMLConfiguration xmlConfig = null; - - xmlConfig = - new XMLConfiguration( - null, - new MockConfigurationResourceProvider( - () -> - XMLConfiguration.class.getResourceAsStream( - XMLConfigurationBackwardsCompatibilityTest - .LATEST_FILENAME))); - - return xmlConfig; + return new XMLConfiguration( + null, + new MockConfigurationResourceProvider( + () -> + XMLConfiguration.class.getResourceAsStream( + XMLConfigurationBackwardsCompatibilityTest + .LATEST_FILENAME))); } @Test @@ -471,7 +462,7 @@ public void testDeleteGridSet() throws InterruptedException { Quota newTset4Quota = store.getUsedQuotaByTileSetId(tset4.getId()); // validate test quota 1 assertNotNull(newTset1Quota); - assertEquals(new BigInteger("0"), newTset1Quota.getBytes()); + assertEquals(BigInteger.valueOf(0), newTset1Quota.getBytes()); // validate test quota 2 assertNotNull(newTset2Quota); assertEquals(tset2Quota.getBytes(), newTset2Quota.getBytes()); @@ -480,7 +471,7 @@ public void testDeleteGridSet() throws InterruptedException { assertEquals(tset3Quota.getBytes(), newTset3Quota.getBytes()); // validate test quota 4 assertNotNull(newTset4Quota); - assertEquals(new BigInteger("0"), newTset4Quota.getBytes()); + assertEquals(BigInteger.valueOf(0), newTset4Quota.getBytes()); // test the global quota globalQuota = store.getGloballyUsedQuota(); assertEquals(tset2Quota.getBytes().add(tset3Quota.getBytes()), globalQuota.getBytes()); @@ -529,7 +520,7 @@ public void testDeleteParameters() throws InterruptedException { tset2Quota = store.getUsedQuotaByTileSetId(tset2.getId()); assertNotNull(tset2Quota); - assertEquals(new BigInteger("0"), tset2Quota.getBytes()); + assertEquals(BigInteger.valueOf(0), tset2Quota.getBytes()); globalQuota = store.getGloballyUsedQuota(); assertEquals(tset1Quota.getBytes(), globalQuota.getBytes()); } diff --git a/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/OnlineTestRule.java b/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/OnlineTestRule.java index 3d64991b9..d15da92b1 100644 --- a/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/OnlineTestRule.java +++ b/geowebcache/diskquota/jdbc/src/test/java/org/geowebcache/diskquota/jdbc/OnlineTestRule.java @@ -25,12 +25,16 @@ import java.util.HashMap; import java.util.Map; import java.util.Properties; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.junit.Assume; import org.junit.AssumptionViolatedException; import org.junit.rules.ExternalResource; public class OnlineTestRule extends ExternalResource { + static final Log LOG = LogFactory.getLog(OnlineTestRule.class); + /** System property set to totally disable any online tests */ public static final String ONLINE_TEST_PROFILE = "onlineTestProfile"; /** @@ -78,7 +82,7 @@ void checkAvailable() { try { available = isOnline(); } catch (Throwable t) { - System.out.println( + LOG.info( "Skipping " + fixtureId + " tests, resources not available: " + t.getMessage()); t.printStackTrace(); available = Boolean.FALSE; @@ -141,17 +145,17 @@ void createExampleFixture(File exFixtureFile, Properties exampleFixture) { exFixtureFile.getParentFile().mkdirs(); exFixtureFile.createNewFile(); - FileOutputStream fout = new FileOutputStream(exFixtureFile); + try (FileOutputStream fout = new FileOutputStream(exFixtureFile)) { - exampleFixture.store( - fout, - "This is an example fixture. Update the " - + "values and remove the .example suffix to enable the test"); - fout.flush(); - fout.close(); - System.out.println("Wrote example fixture file to " + exFixtureFile); + exampleFixture.store( + fout, + "This is an example fixture. Update the " + + "values and remove the .example suffix to enable the test"); + fout.flush(); + } + LOG.info("Wrote example fixture file to " + exFixtureFile); } catch (IOException ioe) { - System.out.println("Unable to write out example fixture " + exFixtureFile); + LOG.info("Unable to write out example fixture " + exFixtureFile); ioe.printStackTrace(); } } @@ -201,9 +205,7 @@ protected final void after() { try { disconnect(); } catch (Exception e) { - if (skipOnFailure) { - // do nothing - } else { + if (!skipOnFailure) { throw new AssertionError( "Exception during disconnect of fixture " + fixtureId, e); } diff --git a/geowebcache/distributed/src/test/java/org/geowebcache/blobstore/memory/distributed/HazelcastCacheProviderTest.java b/geowebcache/distributed/src/test/java/org/geowebcache/blobstore/memory/distributed/HazelcastCacheProviderTest.java index 50c20eb3a..d6dafff4f 100644 --- a/geowebcache/distributed/src/test/java/org/geowebcache/blobstore/memory/distributed/HazelcastCacheProviderTest.java +++ b/geowebcache/distributed/src/test/java/org/geowebcache/blobstore/memory/distributed/HazelcastCacheProviderTest.java @@ -130,26 +130,29 @@ public void testTilePut() throws Exception { assertEquals(to.getBlobFormat(), to2.getBlobFormat()); // Checks if the resources are equals - InputStream is = to.getBlob().getInputStream(); - InputStream is2 = to2.getBlob().getInputStream(); - checkInputStreams(is, is2); + try (InputStream is = to.getBlob().getInputStream(); + InputStream is2 = to2.getBlob().getInputStream()) { + checkInputStreams(is, is2); + } // Ensure Caches contain the result TileObject to3 = cache1.getTileObj(to); assertNotNull(to3); // Checks if the resources are equals - is = to.getBlob().getInputStream(); - InputStream is3 = to3.getBlob().getInputStream(); - checkInputStreams(is, is3); + try (InputStream is = to.getBlob().getInputStream(); + InputStream is3 = to3.getBlob().getInputStream()) { + checkInputStreams(is, is3); + } TileObject to4 = cache2.getTileObj(to); assertNotNull(to4); // Checks if the resources are equals - is = to.getBlob().getInputStream(); - InputStream is4 = to4.getBlob().getInputStream(); - checkInputStreams(is, is4); + try (InputStream is = to.getBlob().getInputStream(); + InputStream is4 = to4.getBlob().getInputStream()) { + checkInputStreams(is, is4); + } } @Test @@ -181,9 +184,10 @@ public void testTileDelete() throws Exception { assertTrue(mem2.get(to2)); // Checks if the resources are equals - InputStream is = to2.getBlob().getInputStream(); - InputStream is2 = bytes.getInputStream(); - checkInputStreams(is, is2); + try (InputStream is = to2.getBlob().getInputStream(); + InputStream is2 = bytes.getInputStream()) { + checkInputStreams(is, is2); + } // Delete TileObject TileObject to3 = diff --git a/geowebcache/georss/src/test/java/org/geowebcache/georss/GeoRSSTileRangeBuilderTest.java b/geowebcache/georss/src/test/java/org/geowebcache/georss/GeoRSSTileRangeBuilderTest.java index 6f5617e40..57bca53fa 100644 --- a/geowebcache/georss/src/test/java/org/geowebcache/georss/GeoRSSTileRangeBuilderTest.java +++ b/geowebcache/georss/src/test/java/org/geowebcache/georss/GeoRSSTileRangeBuilderTest.java @@ -17,7 +17,6 @@ import static org.geowebcache.georss.RasterMaskTestUtils.buildSampleFilterMatrix; import java.io.BufferedReader; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -118,15 +117,12 @@ public void testLatestUpdate() private void assertLatestUpdate(String expected, String fileName) throws IOException, XMLStreamException, FactoryConfigurationError { - InputStream stream = getClass().getResourceAsStream("test-data/" + fileName); - if (stream == null) { - throw new FileNotFoundException("test-data/" + fileName); + try (InputStream stream = getClass().getResourceAsStream("test-data/" + fileName); + Reader feed = new BufferedReader(new InputStreamReader(stream, "UTF-8")); ) { + StaxGeoRSSReader reader = new StaxGeoRSSReader(feed); + GeoRSSTileRangeBuilder b = new GeoRSSTileRangeBuilder(layer, gridsetId, 10); + b.buildTileRangeMask(reader, null); + Assert.assertEquals(expected, b.getLastEntryUpdate()); } - Reader feed = new BufferedReader(new InputStreamReader(stream, "UTF-8")); - - StaxGeoRSSReader reader = new StaxGeoRSSReader(feed); - GeoRSSTileRangeBuilder b = new GeoRSSTileRangeBuilder(layer, gridsetId, 10); - b.buildTileRangeMask(reader, null); - Assert.assertEquals(expected, b.getLastEntryUpdate()); } } diff --git a/geowebcache/georss/src/test/java/org/geowebcache/georss/RasterMaskTestUtils.java b/geowebcache/georss/src/test/java/org/geowebcache/georss/RasterMaskTestUtils.java index 4cd09623b..604fecb48 100644 --- a/geowebcache/georss/src/test/java/org/geowebcache/georss/RasterMaskTestUtils.java +++ b/geowebcache/georss/src/test/java/org/geowebcache/georss/RasterMaskTestUtils.java @@ -18,6 +18,8 @@ import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.geowebcache.grid.GridSubset; import org.geowebcache.layer.TileLayer; import org.locationtech.jts.geom.Geometry; @@ -26,6 +28,8 @@ public class RasterMaskTestUtils { + static final Log LOG = LogFactory.getLog(RasterMaskTestUtils.class); + public static boolean debugToDisk; public static GeometryRasterMaskBuilder buildSampleFilterMatrix( @@ -64,7 +68,7 @@ public static void logImages(final File target, final GeometryRasterMaskBuilder for (int i = 0; i < byLevelMasks.length; i++) { File output = new File(target, "level_" + i + ".tiff"); - System.out.println("--- writing " + output.getAbsolutePath() + "---"); + LOG.info("--- writing " + output.getAbsolutePath() + "---"); ImageIO.write(byLevelMasks[i], "TIFF", output); } } diff --git a/geowebcache/georss/src/test/java/org/geowebcache/georss/StaxGeoRSSReaderTest.java b/geowebcache/georss/src/test/java/org/geowebcache/georss/StaxGeoRSSReaderTest.java index 92c1b4e15..16223ef6a 100644 --- a/geowebcache/georss/src/test/java/org/geowebcache/georss/StaxGeoRSSReaderTest.java +++ b/geowebcache/georss/src/test/java/org/geowebcache/georss/StaxGeoRSSReaderTest.java @@ -48,36 +48,38 @@ public void testConstructor() throws Exception { @Test public void testParsePointFeed() throws Exception { - Reader feed = reader("point_feed.xml"); - StaxGeoRSSReader reader = new StaxGeoRSSReader(feed); + try (Reader feed = reader("point_feed.xml")) { + StaxGeoRSSReader reader = new StaxGeoRSSReader(feed); - List entries = read(reader); + List entries = read(reader); - Assert.assertEquals(3, entries.size()); - assertRequiredMembers(entries); + Assert.assertEquals(3, entries.size()); + assertRequiredMembers(entries); - Assert.assertTrue(entries.get(0).getWhere() instanceof Point); - Assert.assertTrue(entries.get(1).getWhere() instanceof Point); - Assert.assertTrue(entries.get(2).getWhere() instanceof Point); + Assert.assertTrue(entries.get(0).getWhere() instanceof Point); + Assert.assertTrue(entries.get(1).getWhere() instanceof Point); + Assert.assertTrue(entries.get(2).getWhere() instanceof Point); + } } @Test public void testMultiGeometryTypesFeed() throws Exception { - Reader feed = reader("mixedgeometries_feed.xml"); - StaxGeoRSSReader reader = new StaxGeoRSSReader(feed); + try (Reader feed = reader("mixedgeometries_feed.xml")) { + StaxGeoRSSReader reader = new StaxGeoRSSReader(feed); - List entries = read(reader); + List entries = read(reader); - Assert.assertEquals(6, entries.size()); - assertRequiredMembers(entries); + Assert.assertEquals(6, entries.size()); + assertRequiredMembers(entries); - Assert.assertTrue(entries.get(0).getWhere() instanceof Point); - Assert.assertTrue(entries.get(1).getWhere() instanceof MultiPoint); - Assert.assertTrue(entries.get(2).getWhere() instanceof Polygon); - Assert.assertTrue(entries.get(3).getWhere() instanceof MultiPolygon); - Assert.assertTrue(entries.get(4).getWhere() instanceof LineString); - Assert.assertTrue(entries.get(5).getWhere() instanceof MultiLineString); + Assert.assertTrue(entries.get(0).getWhere() instanceof Point); + Assert.assertTrue(entries.get(1).getWhere() instanceof MultiPoint); + Assert.assertTrue(entries.get(2).getWhere() instanceof Polygon); + Assert.assertTrue(entries.get(3).getWhere() instanceof MultiPolygon); + Assert.assertTrue(entries.get(4).getWhere() instanceof LineString); + Assert.assertTrue(entries.get(5).getWhere() instanceof MultiLineString); + } } private void assertRequiredMembers(List entries) { diff --git a/geowebcache/pmd-junit-ruleset.xml b/geowebcache/pmd-junit-ruleset.xml new file mode 100644 index 000000000..aaf73bc2e --- /dev/null +++ b/geowebcache/pmd-junit-ruleset.xml @@ -0,0 +1,51 @@ + + + + +GeoTools Junit ruleset. See https://pmd.github.io/latest/pmd_userdocs_understanding_rulesets.html + + + + + + + + + + + + Don't use JUnit3, use JUnit4 instead + + 3 + + + + + + + + + diff --git a/geowebcache/pmd-ruleset.xml b/geowebcache/pmd-ruleset.xml index f22f3da40..bc02e39ca 100644 --- a/geowebcache/pmd-ruleset.xml +++ b/geowebcache/pmd-ruleset.xml @@ -1,4 +1,4 @@ - + - + + +GeoTools ruleset. See https://pmd.github.io/latest/pmd_userdocs_understanding_rulesets.html + + + + + + + + + + + + + + - - The default ruleset used by the Maven PMD Plugin, when no other ruleset is specified. - It contains the rules of the old (pre PMD 6.0.0) rulesets java-basic, java-empty, java-imports, - java-unnecessary, java-unusedcode. - - This ruleset might be used as a starting point for an own customized ruleset [0]. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - [0] https://pmd.github.io/latest/pmd_userdocs_understanding_rulesets.html + + + + + + + + + + + + + + + + + + + Don't use wildcard imports - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 3 + + + + + + + + diff --git a/geowebcache/pom.xml b/geowebcache/pom.xml index e272b18aa..75de29a3b 100644 --- a/geowebcache/pom.xml +++ b/geowebcache/pom.xml @@ -729,11 +729,13 @@ ${geowebcacheBaseDir}/pmd-ruleset.xml + ${geowebcacheBaseDir}/pmd-junit-ruleset.xml 3 3 true true + true target/generated-sources diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BlobStoreController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BlobStoreController.java index 05a5120cb..ac1bf3a84 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BlobStoreController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BlobStoreController.java @@ -25,7 +25,11 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; @Component @RestController diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BoundsController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BoundsController.java index e2a20e776..8909637a6 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BoundsController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/BoundsController.java @@ -26,7 +26,11 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; @Component @RestController diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/FilterUpdateController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/FilterUpdateController.java index b4655e230..e08bd860b 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/FilterUpdateController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/FilterUpdateController.java @@ -32,7 +32,10 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; @Component @RestController diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/GridSetController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/GridSetController.java index b56908662..eccbb736b 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/GridSetController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/GridSetController.java @@ -24,7 +24,11 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; @Component @RestController diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/MassTruncateController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/MassTruncateController.java index eb0148355..6167652a2 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/MassTruncateController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/MassTruncateController.java @@ -33,7 +33,12 @@ import org.geowebcache.GeoWebCacheException; import org.geowebcache.io.GeoWebCacheXStream; import org.geowebcache.rest.exception.RestException; -import org.geowebcache.seed.*; +import org.geowebcache.seed.MassTruncateRequest; +import org.geowebcache.seed.TileBreeder; +import org.geowebcache.seed.TruncateBboxRequest; +import org.geowebcache.seed.TruncateLayerRequest; +import org.geowebcache.seed.TruncateOrphansRequest; +import org.geowebcache.seed.TruncateParametersRequest; import org.geowebcache.storage.StorageBroker; import org.geowebcache.storage.StorageException; import org.geowebcache.util.ApplicationContextProvider; diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ReloadController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ReloadController.java index a06c951bd..30a825204 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ReloadController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ReloadController.java @@ -39,7 +39,12 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; @Component @RestController diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/SeedController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/SeedController.java index 54188222f..b35f784f8 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/SeedController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/SeedController.java @@ -38,7 +38,11 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; @Component @RestController diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ServerController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ServerController.java index 599d832b4..1c72f5821 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ServerController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/ServerController.java @@ -24,7 +24,11 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; @Component @RestController diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/TileLayerController.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/TileLayerController.java index 9f6e2afed..656fe64fe 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/TileLayerController.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/controller/TileLayerController.java @@ -33,7 +33,11 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; @Component @RestController diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/converter/GWCConverter.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/converter/GWCConverter.java index 982708839..6be808a38 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/converter/GWCConverter.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/converter/GWCConverter.java @@ -29,7 +29,10 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.geowebcache.config.*; +import org.geowebcache.config.BlobStoreInfo; +import org.geowebcache.config.ContextualConfigurationProvider; +import org.geowebcache.config.XMLConfiguration; +import org.geowebcache.config.XMLGridSet; import org.geowebcache.grid.GridSet; import org.geowebcache.io.GeoWebCacheXStream; import org.geowebcache.layer.TileLayer; diff --git a/geowebcache/rest/src/main/java/org/geowebcache/rest/service/FormService.java b/geowebcache/rest/src/main/java/org/geowebcache/rest/service/FormService.java index 93c744980..936b7678f 100644 --- a/geowebcache/rest/src/main/java/org/geowebcache/rest/service/FormService.java +++ b/geowebcache/rest/src/main/java/org/geowebcache/rest/service/FormService.java @@ -24,7 +24,16 @@ import static org.geowebcache.seed.TileBreeder.createTileRange; import java.text.NumberFormat; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; import javax.servlet.http.HttpServletRequest; import org.geowebcache.GeoWebCacheException; import org.geowebcache.filter.parameters.FloatParameterFilter; diff --git a/geowebcache/rest/src/test/java/org/geowebcache/rest/bounds/BoundsControllerTest.java b/geowebcache/rest/src/test/java/org/geowebcache/rest/bounds/BoundsControllerTest.java index 254fd2351..910b3acc0 100644 --- a/geowebcache/rest/src/test/java/org/geowebcache/rest/bounds/BoundsControllerTest.java +++ b/geowebcache/rest/src/test/java/org/geowebcache/rest/bounds/BoundsControllerTest.java @@ -24,7 +24,11 @@ import org.geowebcache.config.TileLayerConfiguration; import org.geowebcache.config.XMLConfiguration; import org.geowebcache.config.XMLConfigurationBackwardsCompatibilityTest; -import org.geowebcache.grid.*; +import org.geowebcache.grid.BoundingBox; +import org.geowebcache.grid.GridSet; +import org.geowebcache.grid.GridSetBroker; +import org.geowebcache.grid.GridSetFactory; +import org.geowebcache.grid.SRS; import org.geowebcache.layer.TileLayerDispatcher; import org.geowebcache.rest.controller.BoundsController; import org.junit.Before; diff --git a/geowebcache/rest/src/test/java/org/geowebcache/rest/filter/FilterUpdateControllerTest.java b/geowebcache/rest/src/test/java/org/geowebcache/rest/filter/FilterUpdateControllerTest.java index 51c31e726..f82ba4c6f 100644 --- a/geowebcache/rest/src/test/java/org/geowebcache/rest/filter/FilterUpdateControllerTest.java +++ b/geowebcache/rest/src/test/java/org/geowebcache/rest/filter/FilterUpdateControllerTest.java @@ -10,7 +10,11 @@ import org.geowebcache.config.TileLayerConfiguration; import org.geowebcache.config.XMLConfiguration; import org.geowebcache.config.XMLConfigurationBackwardsCompatibilityTest; -import org.geowebcache.grid.*; +import org.geowebcache.grid.BoundingBox; +import org.geowebcache.grid.GridSet; +import org.geowebcache.grid.GridSetBroker; +import org.geowebcache.grid.GridSetFactory; +import org.geowebcache.grid.SRS; import org.geowebcache.layer.TileLayerDispatcher; import org.geowebcache.rest.controller.FilterUpdateController; import org.junit.Before; diff --git a/geowebcache/rest/src/test/java/org/geowebcache/rest/reload/ReloadTest.java b/geowebcache/rest/src/test/java/org/geowebcache/rest/reload/ReloadTest.java index f2a8b4fa8..a10ddad2f 100644 --- a/geowebcache/rest/src/test/java/org/geowebcache/rest/reload/ReloadTest.java +++ b/geowebcache/rest/src/test/java/org/geowebcache/rest/reload/ReloadTest.java @@ -19,7 +19,11 @@ import org.geowebcache.GeoWebCacheException; import org.geowebcache.config.MockGridSetConfiguration; -import org.geowebcache.grid.*; +import org.geowebcache.grid.BoundingBox; +import org.geowebcache.grid.GridSet; +import org.geowebcache.grid.GridSetBroker; +import org.geowebcache.grid.GridSetFactory; +import org.geowebcache.grid.SRS; import org.geowebcache.layer.TileLayerDispatcher; import org.geowebcache.rest.controller.ReloadController; import org.junit.Before; diff --git a/geowebcache/rest/src/test/java/org/geowebcache/rest/seed/MassTruncateControllerTest.java b/geowebcache/rest/src/test/java/org/geowebcache/rest/seed/MassTruncateControllerTest.java index a2b2e99c1..21ff81ae3 100644 --- a/geowebcache/rest/src/test/java/org/geowebcache/rest/seed/MassTruncateControllerTest.java +++ b/geowebcache/rest/src/test/java/org/geowebcache/rest/seed/MassTruncateControllerTest.java @@ -188,8 +188,6 @@ public void testGetMassTruncate() throws Exception { .andReturn(); assertEquals(200, result.getResponse().getStatus()); - - System.out.print(result); } @Test diff --git a/geowebcache/rest/src/test/java/org/geowebcache/rest/service/FormServiceTest.java b/geowebcache/rest/src/test/java/org/geowebcache/rest/service/FormServiceTest.java index ffe830d1f..8567714e7 100644 --- a/geowebcache/rest/src/test/java/org/geowebcache/rest/service/FormServiceTest.java +++ b/geowebcache/rest/src/test/java/org/geowebcache/rest/service/FormServiceTest.java @@ -84,7 +84,6 @@ public void testThreads() { .anyTimes(); replay(breeder); Set layer1GridSet = new HashSet<>(Arrays.asList("test_grid1")); - String layerName = "test"; GridSubset gs = createMock(GridSubset.class); expect(gs.getOriginalExtent()).andReturn(new BoundingBox(0, 0, 10, 10)).anyTimes(); expect(gs.getZoomStart()).andReturn(0).anyTimes(); diff --git a/geowebcache/s3storage/src/main/java/org/geowebcache/s3/S3BlobStoreInfo.java b/geowebcache/s3storage/src/main/java/org/geowebcache/s3/S3BlobStoreInfo.java index e0c16f7ba..f2ccc763d 100644 --- a/geowebcache/s3storage/src/main/java/org/geowebcache/s3/S3BlobStoreInfo.java +++ b/geowebcache/s3storage/src/main/java/org/geowebcache/s3/S3BlobStoreInfo.java @@ -19,8 +19,11 @@ import com.amazonaws.ClientConfiguration; import com.amazonaws.Protocol; -import com.amazonaws.auth.*; +import com.amazonaws.auth.AWSCredentials; +import com.amazonaws.auth.AWSCredentialsProvider; import com.amazonaws.auth.AnonymousAWSCredentials; +import com.amazonaws.auth.BasicAWSCredentials; +import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.S3ClientOptions; import com.amazonaws.services.s3.model.CannedAccessControlList; diff --git a/geowebcache/s3storage/src/test/java/org/geowebcache/s3/AbstractS3BlobStoreIntegrationTest.java b/geowebcache/s3storage/src/test/java/org/geowebcache/s3/AbstractS3BlobStoreIntegrationTest.java index 9b0c50475..161b51f09 100644 --- a/geowebcache/s3storage/src/test/java/org/geowebcache/s3/AbstractS3BlobStoreIntegrationTest.java +++ b/geowebcache/s3storage/src/test/java/org/geowebcache/s3/AbstractS3BlobStoreIntegrationTest.java @@ -519,10 +519,6 @@ private void seed( } } - private TileObject put(long x, long y, int z) throws StorageException { - return put(x, y, z, DEFAULT_GRIDSET, DEFAULT_FORMAT, null); - } - private TileObject put( long x, long y, diff --git a/geowebcache/s3storage/src/test/java/org/geowebcache/s3/OfflineS3BlobStoreIntegrationTest.java b/geowebcache/s3storage/src/test/java/org/geowebcache/s3/OfflineS3BlobStoreIntegrationTest.java index 5e0f1353a..255696d6b 100644 --- a/geowebcache/s3storage/src/test/java/org/geowebcache/s3/OfflineS3BlobStoreIntegrationTest.java +++ b/geowebcache/s3storage/src/test/java/org/geowebcache/s3/OfflineS3BlobStoreIntegrationTest.java @@ -18,6 +18,7 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Ignore; +import org.junit.Test; /** * Offline integration tests for {@link S3BlobStore}. @@ -51,12 +52,14 @@ protected S3BlobStoreInfo getConfiguration() { @Override @Ignore // randomly fails + @Test public void testTruncateOptimizationIfNoListeners() throws StorageException, MimeException { super.testTruncateOptimizationIfNoListeners(); } @Override @Ignore // randomly fails + @Test public void testTruncateShortCutsIfNoTilesInGridsetPrefix() throws StorageException, MimeException { super.testTruncateShortCutsIfNoTilesInGridsetPrefix(); diff --git a/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConfigProviderTest.java b/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConfigProviderTest.java index 77248bdcb..d37f82308 100644 --- a/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConfigProviderTest.java +++ b/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConfigProviderTest.java @@ -27,6 +27,7 @@ public class S3BlobStoreConfigProviderTest { @Before + @SuppressWarnings("PMD.CloseResource") public void setUp() throws Exception { System.setProperty("BUCKET", "MYBUCKET"); System.setProperty("CONNECTIONS", "30"); diff --git a/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConfigSerializeTest.java b/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConfigSerializeTest.java index 2c4177b38..45285c1c0 100644 --- a/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConfigSerializeTest.java +++ b/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConfigSerializeTest.java @@ -98,9 +98,7 @@ public void testInvalidAccess() throws Exception { S3BlobStoreConfigProvider provider = new S3BlobStoreConfigProvider(); XStream xs = provider.getConfiguredXStream(new XStream()); exception.expect(XStreamException.class); - S3BlobStoreInfo config = - (S3BlobStoreInfo) - xs.fromXML( - "testfalseNOT_A_REAL_ACCESS_TYPEtrue"); + xs.fromXML( + "testfalseNOT_A_REAL_ACCESS_TYPEtrue"); } } diff --git a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesPBFTest.java b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesPBFTest.java index 9b65255a1..7ccf1b13e 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesPBFTest.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesPBFTest.java @@ -15,7 +15,8 @@ package org.geowebcache.sqlite; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.FileOutputStream; diff --git a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/OperationsRestTest.java b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/OperationsRestTest.java index cb871bf99..5fa6eb8c0 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/OperationsRestTest.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/OperationsRestTest.java @@ -24,7 +24,11 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.nio.file.*; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.List; import java.util.zip.ZipEntry; @@ -36,7 +40,9 @@ import org.geowebcache.storage.CompositeBlobStore; import org.geowebcache.storage.SuitabilityCheckRule; import org.geowebcache.storage.TileObject; -import org.junit.*; +import org.junit.After; +import org.junit.Rule; +import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mock.web.MockMultipartFile; diff --git a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqlitlePerf.java b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqlitlePerf.java index b66aab8af..a60530479 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqlitlePerf.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqlitlePerf.java @@ -324,48 +324,49 @@ private static File createSeedFile(File rootDirectory, long[][] tiles) throws Ex if (LOGGER.isInfoEnabled()) { LOGGER.info(String.format("Start seeding file '%s'.", seedFile)); } - Connection connection = DriverManager.getConnection("jdbc:sqlite:" + seedFile.getPath()); - String createTableSql = - "CREATE TABLE IF NOT EXISTS tiles (zoom_level integer, tile_column integer, " - + "tile_row integer, tile_data blob, CONSTRAINT pk_tiles PRIMARY KEY(zoom_level, tile_column,tile_row));"; - executeSql(connection, createTableSql); - // start seeding wrapped in a transaction (improves performance) - long startTime = System.currentTimeMillis(); - executeSql(connection, "BEGIN TRANSACTION;"); - String sql = "INSERT OR REPLACE INTO tiles VALUES(?, ?, ?, ?);"; - // insert the tiles in batches - try (PreparedStatement statement = connection.prepareStatement(sql)) { - for (int i = 0; i < TILES; i++) { - Tile tile = Tile.random(); - tiles[i][0] = tile.x; - tiles[i][1] = tile.y; - tiles[i][2] = tile.z; - statement.setLong(1, tile.z); - statement.setLong(2, tile.x); - statement.setLong(3, tile.y); - statement.setBytes(4, tile.data); - statement.addBatch(); - if (i != 0 && i % 10000 == 0) { - statement.executeBatch(); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(String.format("Inserted batch %d.", i)); + try (Connection connection = + DriverManager.getConnection("jdbc:sqlite:" + seedFile.getPath())) { + String createTableSql = + "CREATE TABLE IF NOT EXISTS tiles (zoom_level integer, tile_column integer, " + + "tile_row integer, tile_data blob, CONSTRAINT pk_tiles PRIMARY KEY(zoom_level, tile_column,tile_row));"; + executeSql(connection, createTableSql); + // start seeding wrapped in a transaction (improves performance) + long startTime = System.currentTimeMillis(); + executeSql(connection, "BEGIN TRANSACTION;"); + String sql = "INSERT OR REPLACE INTO tiles VALUES(?, ?, ?, ?);"; + // insert the tiles in batches + try (PreparedStatement statement = connection.prepareStatement(sql)) { + for (int i = 0; i < TILES; i++) { + Tile tile = Tile.random(); + tiles[i][0] = tile.x; + tiles[i][1] = tile.y; + tiles[i][2] = tile.z; + statement.setLong(1, tile.z); + statement.setLong(2, tile.x); + statement.setLong(3, tile.y); + statement.setBytes(4, tile.data); + statement.addBatch(); + if (i != 0 && i % 10000 == 0) { + statement.executeBatch(); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(String.format("Inserted batch %d.", i)); + } } } + statement.executeBatch(); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(String.format("Inserted batch %d.", TILES)); + } + } catch (Exception exception) { + throw Utils.exception(exception, "Error executing SQL '%s'.", sql); } - statement.executeBatch(); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(String.format("Inserted batch %d.", TILES)); + // clean everything + executeSql(connection, "END TRANSACTION;"); + long endTime = System.currentTimeMillis(); + if (LOGGER.isInfoEnabled()) { + LOGGER.info(String.format("Insert time '%d' (batch mode).", endTime - startTime)); } - } catch (Exception exception) { - throw Utils.exception(exception, "Error executing SQL '%s'.", sql); - } - // clean everything - executeSql(connection, "END TRANSACTION;"); - long endTime = System.currentTimeMillis(); - if (LOGGER.isInfoEnabled()) { - LOGGER.info(String.format("Insert time '%d' (batch mode).", endTime - startTime)); } - connection.close(); return seedFile; } diff --git a/geowebcache/swiftblob/src/main/java/org/geowebcache/swift/SwiftBlobStore.java b/geowebcache/swiftblob/src/main/java/org/geowebcache/swift/SwiftBlobStore.java index 230e24be1..9c1f92baa 100644 --- a/geowebcache/swiftblob/src/main/java/org/geowebcache/swift/SwiftBlobStore.java +++ b/geowebcache/swiftblob/src/main/java/org/geowebcache/swift/SwiftBlobStore.java @@ -22,8 +22,13 @@ import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import com.google.common.io.ByteStreams; -import java.io.*; -import java.util.*; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; @@ -34,7 +39,13 @@ import org.geowebcache.io.ByteArrayResource; import org.geowebcache.layer.TileLayerDispatcher; import org.geowebcache.mime.MimeType; -import org.geowebcache.storage.*; +import org.geowebcache.storage.BlobStore; +import org.geowebcache.storage.BlobStoreListener; +import org.geowebcache.storage.BlobStoreListenerList; +import org.geowebcache.storage.StorageException; +import org.geowebcache.storage.TileObject; +import org.geowebcache.storage.TileRange; +import org.geowebcache.storage.TileRangeIterator; import org.jclouds.io.Payload; import org.jclouds.openstack.swift.v1.SwiftApi; import org.jclouds.openstack.swift.v1.blobstore.RegionScopedBlobStoreContext; diff --git a/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftBlobStoreTest.java b/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftBlobStoreTest.java index 6b25a0371..f581a6f9a 100644 --- a/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftBlobStoreTest.java +++ b/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftBlobStoreTest.java @@ -15,19 +15,43 @@ package org.geowebcache.swift; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import com.google.common.io.ByteSource; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; import org.geowebcache.io.ByteArrayResource; import org.geowebcache.io.Resource; import org.geowebcache.layer.TileLayerDispatcher; import org.geowebcache.mime.MimeType; -import org.geowebcache.storage.*; +import org.geowebcache.storage.BlobStoreListener; +import org.geowebcache.storage.BlobStoreListenerList; +import org.geowebcache.storage.StorageException; +import org.geowebcache.storage.TileObject; +import org.geowebcache.storage.TileRange; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.io.payloads.ByteSourcePayload; import org.jclouds.openstack.swift.v1.SwiftApi; @@ -228,6 +252,7 @@ public void testPutWhenBlobIsAnInvalidMimeType() { } @Test + @SuppressWarnings("PMD.CloseResource") public void get() { String thePayloadData = "Test Content"; Date lastModified = new Date(); diff --git a/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftTileTest.java b/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftTileTest.java index f7c10b5ff..39467aca8 100644 --- a/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftTileTest.java +++ b/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftTileTest.java @@ -144,22 +144,24 @@ public void testPutWhenBlobIsNull() throws IOException { } @Test - public void testGetPayloadMetadataOutputLength() { + public void testGetPayloadMetadataOutputLength() throws IOException { Long testOutputLengthValue = 5L; ReflectionTestUtils.setField(swiftTile, "outputLength", testOutputLengthValue); - Payload testPayload = swiftTile.getPayload(); - Assert.assertEquals( - testOutputLengthValue, testPayload.getContentMetadata().getContentLength()); + try (Payload testPayload = swiftTile.getPayload()) { + Assert.assertEquals( + testOutputLengthValue, testPayload.getContentMetadata().getContentLength()); + } } @Test - public void testGetPayloadMetadataMimeType() { + public void testGetPayloadMetadataMimeType() throws IOException { String testBlobFormat = "image/png"; ReflectionTestUtils.setField(swiftTile, "blobFormat", testBlobFormat); - Payload testPayload = swiftTile.getPayload(); - Assert.assertEquals(testBlobFormat, testPayload.getContentMetadata().getContentType()); + try (Payload testPayload = swiftTile.getPayload()) { + Assert.assertEquals(testBlobFormat, testPayload.getContentMetadata().getContentType()); + } } @Test diff --git a/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftUploadTaskTest.java b/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftUploadTaskTest.java index e6705e7a5..1f1411cbc 100644 --- a/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftUploadTaskTest.java +++ b/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftUploadTaskTest.java @@ -14,7 +14,13 @@ */ package org.geowebcache.swift; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.anyLong; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import org.jclouds.io.Payload; import org.jclouds.io.payloads.BaseMutableContentMetadata; @@ -27,10 +33,6 @@ public class SwiftUploadTaskTest extends SwiftTileTest { private ObjectApi testObjectApi = mock(ObjectApi.class); private String testKey = "TestKey"; - public void setUp() throws Exception { - super.setUp(); - } - @Test public void testRunWithEmptyListeners() { SwiftUploadTask swiftUploadTask = @@ -57,6 +59,7 @@ public void testRunWithNullObject() { } @Test + @SuppressWarnings("PMD.CloseResource") public void testRunWithValidObject() { SwiftObject testSwiftObject = mock(SwiftObject.class); Payload testPayload = mock(Payload.class); diff --git a/geowebcache/web/src/test/java/org/geowebcache/jetty/JettyRule.java b/geowebcache/web/src/test/java/org/geowebcache/jetty/JettyRule.java index f29e6be3e..c9b7aef20 100644 --- a/geowebcache/web/src/test/java/org/geowebcache/jetty/JettyRule.java +++ b/geowebcache/web/src/test/java/org/geowebcache/jetty/JettyRule.java @@ -24,6 +24,7 @@ * * @author Kevin Smith, Boundless */ +@SuppressWarnings("PMD.CloseResource") public class JettyRule extends org.junit.rules.ExternalResource { private static final String JETTY_PORT_PROPERTY = "jetty.port"; diff --git a/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java b/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java index eb932316f..516536c67 100644 --- a/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java +++ b/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java @@ -124,10 +124,11 @@ public void setUp() throws Exception { + " 120\n" + ""; - CloseableHttpResponse response = - handlePut(URI.create("/geowebcache/rest/global"), admin.getClient(), globalUpdate); - assertEquals(200, response.getStatusLine().getStatusCode()); - response.close(); + try (CloseableHttpResponse response = + handlePut( + URI.create("/geowebcache/rest/global"), admin.getClient(), globalUpdate)) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } } Matcher hasXPath(final String xpathExpr, final Matcher matcher) { @@ -142,62 +143,67 @@ Matcher hasXPath(final String xpathExpr) { @Test public void testGetLogo() throws Exception { - CloseableHttpResponse response = + try (CloseableHttpResponse response = handleGet( URI.create("/geowebcache/rest/web/geowebcache_logo.png"), - anonymous.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + anonymous.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } } @Test public void testGetCss() throws Exception { - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/web/gwc.css"), anonymous.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/web/gwc.css"), anonymous.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } } @Test public void testGetBadWebResource() throws Exception { - CloseableHttpResponse response = + try (CloseableHttpResponse response = handleGet( URI.create("/geowebcache/rest/web/thisDoesNotExist"), - anonymous.getClient()); - assertEquals(404, response.getStatusLine().getStatusCode()); + anonymous.getClient())) { + assertEquals(404, response.getStatusLine().getStatusCode()); + } } /* ServerController Integration Tests ********************************************************/ @Test public void testGetGlobal() throws Exception { - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/global.xml"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); - - Document doc = getResponseEntityAsXML(response); - - assertThat(doc, hasXPath("/global/serviceInformation/title", equalTo("GeoWebCache"))); - assertThat( - doc, - hasXPath( - "normalize-space(/global/serviceInformation/description)", - equalTo( - "GeoWebCache is an advanced tile cache for WMS servers. It supports a large variety of " - + "protocols and formats, including WMS-C, WMTS, KML, Google Maps and Virtual Earth."))); - assertThat( - doc, hasXPath("count(/global/serviceInformation/keywords/string)", equalTo("4"))); - assertThat( - doc, - hasXPath( - "/global/serviceInformation/serviceProvider/providerName", - equalTo("John Smith inc."))); - assertThat( - doc, - hasXPath( - "/global/serviceInformation/serviceProvider/serviceContact/individualName", - equalTo("John Smith"))); - assertThat(doc, hasXPath("/global/runtimeStatsEnabled", equalTo("true"))); - assertThat(doc, hasXPath("/global/wmtsCiteCompliant", equalTo("false"))); - assertThat(doc, hasXPath("/global/backendTimeout", equalTo("120"))); + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/global.xml"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + + Document doc = getResponseEntityAsXML(response); + + assertThat(doc, hasXPath("/global/serviceInformation/title", equalTo("GeoWebCache"))); + assertThat( + doc, + hasXPath( + "normalize-space(/global/serviceInformation/description)", + equalTo( + "GeoWebCache is an advanced tile cache for WMS servers. It supports a large variety of " + + "protocols and formats, including WMS-C, WMTS, KML, Google Maps and Virtual Earth."))); + assertThat( + doc, + hasXPath("count(/global/serviceInformation/keywords/string)", equalTo("4"))); + assertThat( + doc, + hasXPath( + "/global/serviceInformation/serviceProvider/providerName", + equalTo("John Smith inc."))); + assertThat( + doc, + hasXPath( + "/global/serviceInformation/serviceProvider/serviceContact/individualName", + equalTo("John Smith"))); + assertThat(doc, hasXPath("/global/runtimeStatsEnabled", equalTo("true"))); + assertThat(doc, hasXPath("/global/wmtsCiteCompliant", equalTo("false"))); + assertThat(doc, hasXPath("/global/backendTimeout", equalTo("120"))); + } } @Test @@ -240,58 +246,66 @@ public void testPutGlobal() throws Exception { testGetGlobal(); - CloseableHttpResponse response = - handlePut(URI.create("/geowebcache/rest/global"), admin.getClient(), globalUpdate); - assertEquals(200, response.getStatusLine().getStatusCode()); - response.close(); - - response = handleGet(URI.create("/geowebcache/rest/global.xml"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); - - Document doc = getResponseEntityAsXML(response); - - assertThat(doc, hasXPath("/global/serviceInformation/title", equalTo("GeoWebCache"))); - assertThat( - doc, - hasXPath( - "normalize-space(/global/serviceInformation/description)", - equalTo( - "GeoWebCache is an advanced tile cache for WMS servers. It supports a large variety of " - + "protocols and formats, including WMS-C, WMTS, KML, Google Maps and Virtual Earth."))); - assertThat( - doc, hasXPath("count(/global/serviceInformation/keywords/string)", equalTo("3"))); - assertThat( - doc, - hasXPath( - "/global/serviceInformation/serviceProvider/providerName", - equalTo("Jane Doe inc."))); - assertThat( - doc, - hasXPath( - "/global/serviceInformation/serviceProvider/serviceContact/individualName", - equalTo("Jane Doe"))); - assertThat(doc, hasXPath("/global/runtimeStatsEnabled", equalTo("false"))); - assertThat(doc, hasXPath("/global/wmtsCiteCompliant", equalTo("false"))); - assertThat(doc, hasXPath("/global/backendTimeout", equalTo("120"))); + try (CloseableHttpResponse response = + handlePut( + URI.create("/geowebcache/rest/global"), admin.getClient(), globalUpdate)) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } + + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/global.xml"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + + Document doc = getResponseEntityAsXML(response); + + assertThat(doc, hasXPath("/global/serviceInformation/title", equalTo("GeoWebCache"))); + assertThat( + doc, + hasXPath( + "normalize-space(/global/serviceInformation/description)", + equalTo( + "GeoWebCache is an advanced tile cache for WMS servers. It supports a large variety of " + + "protocols and formats, including WMS-C, WMTS, KML, Google Maps and Virtual Earth."))); + assertThat( + doc, + hasXPath("count(/global/serviceInformation/keywords/string)", equalTo("3"))); + assertThat( + doc, + hasXPath( + "/global/serviceInformation/serviceProvider/providerName", + equalTo("Jane Doe inc."))); + assertThat( + doc, + hasXPath( + "/global/serviceInformation/serviceProvider/serviceContact/individualName", + equalTo("Jane Doe"))); + assertThat(doc, hasXPath("/global/runtimeStatsEnabled", equalTo("false"))); + assertThat(doc, hasXPath("/global/wmtsCiteCompliant", equalTo("false"))); + assertThat(doc, hasXPath("/global/backendTimeout", equalTo("120"))); + } } @Test public void testPutGlobalRoundTrip() throws Exception { testGetGlobal(); - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/global.xml"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + final String globalUpdate; + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/global.xml"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); - final String globalUpdate = getResponseEntity(response); + globalUpdate = getResponseEntity(response); + } - response = - handlePut(URI.create("/geowebcache/rest/global"), admin.getClient(), globalUpdate); - assertEquals(200, response.getStatusLine().getStatusCode()); - response.close(); + try (CloseableHttpResponse response = + handlePut( + URI.create("/geowebcache/rest/global"), admin.getClient(), globalUpdate)) { + assertEquals(200, response.getStatusLine().getStatusCode()); + response.close(); - // Round-tripping the XML should not cause changes - testGetGlobal(); + // Round-tripping the XML should not cause changes + testGetGlobal(); + } } @Test @@ -302,40 +316,44 @@ public void testPutGlobalPartial() throws Exception { testGetGlobal(); - CloseableHttpResponse response = - handlePut(URI.create("/geowebcache/rest/global"), admin.getClient(), globalUpdate); - assertEquals(200, response.getStatusLine().getStatusCode()); - response.close(); - - response = handleGet(URI.create("/geowebcache/rest/global.xml"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); - - Document doc = getResponseEntityAsXML(response); - - // Verify only the PUT value has changed - assertThat(doc, hasXPath("/global/serviceInformation/title", equalTo("GeoWebCache"))); - assertThat( - doc, - hasXPath( - "normalize-space(/global/serviceInformation/description)", - equalTo( - "GeoWebCache is an advanced tile cache for WMS servers. It supports a large variety of " - + "protocols and formats, including WMS-C, WMTS, KML, Google Maps and Virtual Earth."))); - assertThat( - doc, hasXPath("count(/global/serviceInformation/keywords/string)", equalTo("4"))); - assertThat( - doc, - hasXPath( - "/global/serviceInformation/serviceProvider/providerName", - equalTo("John Smith inc."))); - assertThat( - doc, - hasXPath( - "/global/serviceInformation/serviceProvider/serviceContact/individualName", - equalTo("John Smith"))); - assertThat(doc, hasXPath("/global/runtimeStatsEnabled", equalTo("true"))); - assertThat(doc, hasXPath("/global/wmtsCiteCompliant", equalTo("false"))); - assertThat(doc, hasXPath("/global/backendTimeout", equalTo("150"))); + try (CloseableHttpResponse response = + handlePut( + URI.create("/geowebcache/rest/global"), admin.getClient(), globalUpdate)) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } + + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/global.xml"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + + Document doc = getResponseEntityAsXML(response); + + // Verify only the PUT value has changed + assertThat(doc, hasXPath("/global/serviceInformation/title", equalTo("GeoWebCache"))); + assertThat( + doc, + hasXPath( + "normalize-space(/global/serviceInformation/description)", + equalTo( + "GeoWebCache is an advanced tile cache for WMS servers. It supports a large variety of " + + "protocols and formats, including WMS-C, WMTS, KML, Google Maps and Virtual Earth."))); + assertThat( + doc, + hasXPath("count(/global/serviceInformation/keywords/string)", equalTo("4"))); + assertThat( + doc, + hasXPath( + "/global/serviceInformation/serviceProvider/providerName", + equalTo("John Smith inc."))); + assertThat( + doc, + hasXPath( + "/global/serviceInformation/serviceProvider/serviceContact/individualName", + equalTo("John Smith"))); + assertThat(doc, hasXPath("/global/runtimeStatsEnabled", equalTo("true"))); + assertThat(doc, hasXPath("/global/wmtsCiteCompliant", equalTo("false"))); + assertThat(doc, hasXPath("/global/backendTimeout", equalTo("150"))); + } } @Test @@ -343,27 +361,31 @@ public void testPutGlobalLock() throws Exception { final String globalUpdate = "nioLock"; - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/global.xml"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/global.xml"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); - Document doc = getResponseEntityAsXML(response); + Document doc = getResponseEntityAsXML(response); - // Lock provider is null by default. If this is the case, it won't show up in the - // configuration - assertThat(doc, hasXPath("count(/global/lockProvider)", equalTo("0"))); + // Lock provider is null by default. If this is the case, it won't show up in the + // configuration + assertThat(doc, hasXPath("count(/global/lockProvider)", equalTo("0"))); + } - response = - handlePut(URI.create("/geowebcache/rest/global"), admin.getClient(), globalUpdate); - assertEquals(200, response.getStatusLine().getStatusCode()); - response.close(); + try (CloseableHttpResponse response = + handlePut( + URI.create("/geowebcache/rest/global"), admin.getClient(), globalUpdate)) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } - response = handleGet(URI.create("/geowebcache/rest/global.xml"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/global.xml"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); - doc = getResponseEntityAsXML(response); + Document doc = getResponseEntityAsXML(response); - assertThat(doc, hasXPath("/global/lockProvider", equalTo("nioLock"))); + assertThat(doc, hasXPath("/global/lockProvider", equalTo("nioLock"))); + } } @Test @@ -371,10 +393,11 @@ public void testPutGlobalReadOnly() throws Exception { // PUT a value that is read-only final String globalUpdate = "foobar"; - CloseableHttpResponse response = - handlePut(URI.create("/geowebcache/rest/global"), admin.getClient(), globalUpdate); - assertEquals(400, response.getStatusLine().getStatusCode()); - response.close(); + try (CloseableHttpResponse response = + handlePut( + URI.create("/geowebcache/rest/global"), admin.getClient(), globalUpdate)) { + assertEquals(400, response.getStatusLine().getStatusCode()); + } } /* TileLayerController Integration Tests *****************************************************/ @@ -623,6 +646,7 @@ public void testGetLayer() throws Exception { } @Test + @SuppressWarnings("PMD.CloseResource") public void testLayerNoAuth() throws Exception { for (CloseableHttpClient client : Arrays.asList(anonymous.getClient(), notAUser.getClient())) { @@ -645,6 +669,7 @@ public void testLayerNoAuth() throws Exception { * Check that the given request gives a 401 Forbidden when not authenticated, and otherwise has * a response matching the given matcher */ + @SuppressWarnings("PMD.CloseResource") protected void testSecured(HttpUriRequest request, Matcher authenticatedStatus) throws Exception { { @@ -689,67 +714,71 @@ public void testAddLayer() throws Exception { @Test public void testGetBlobStoresXML() throws Exception { - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/blobstores.xml"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); - - Document doc = getResponseEntityAsXML(response); - - assertThat(doc, hasXPath("count(/blobStores/blobStore)", equalTo("1"))); - assertThat(doc, hasXPath("/blobStores/blobStore[1]/name", equalTo("defaultCache"))); - assertThat( - doc, - hasXPath( - "/blobStores/blobStore[1]/atom:link/@href", - equalTo(jetty.getUri() + "rest/blobstores/defaultCache.xml"))); - assertThat( - doc, - hasXPath( - "/blobStores/blobStore[1]/atom:link/@type", - equalTo(MediaType.TEXT_XML_VALUE))); + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/blobstores.xml"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + + Document doc = getResponseEntityAsXML(response); + + assertThat(doc, hasXPath("count(/blobStores/blobStore)", equalTo("1"))); + assertThat(doc, hasXPath("/blobStores/blobStore[1]/name", equalTo("defaultCache"))); + assertThat( + doc, + hasXPath( + "/blobStores/blobStore[1]/atom:link/@href", + equalTo(jetty.getUri() + "rest/blobstores/defaultCache.xml"))); + assertThat( + doc, + hasXPath( + "/blobStores/blobStore[1]/atom:link/@type", + equalTo(MediaType.TEXT_XML_VALUE))); + } } @Test public void testGetBlobStoresJSON() throws Exception { - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/blobstores.json"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/blobstores.json"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); - JSONArray jsonArray = getResponseEntityAsJSONArray(response); - assertEquals(1, jsonArray.length()); - assertEquals("defaultCache", jsonArray.get(0)); + JSONArray jsonArray = getResponseEntityAsJSONArray(response); + assertEquals(1, jsonArray.length()); + assertEquals("defaultCache", jsonArray.get(0)); + } } @Test public void testGetBlobStoreXML() throws Exception { - CloseableHttpResponse response = + try (CloseableHttpResponse response = handleGet( URI.create("/geowebcache/rest/blobstores/defaultCache.xml"), - admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); - Document doc = getResponseEntityAsXML(response); + Document doc = getResponseEntityAsXML(response); - assertThat(doc, hasXPath("//id", equalTo("defaultCache"))); - assertThat(doc, hasXPath("//enabled", equalTo("false"))); - assertThat(doc, hasXPath("//baseDirectory", equalTo("/tmp/defaultCache"))); - assertThat(doc, hasXPath("//fileSystemBlockSize", equalTo("4096"))); + assertThat(doc, hasXPath("//id", equalTo("defaultCache"))); + assertThat(doc, hasXPath("//enabled", equalTo("false"))); + assertThat(doc, hasXPath("//baseDirectory", equalTo("/tmp/defaultCache"))); + assertThat(doc, hasXPath("//fileSystemBlockSize", equalTo("4096"))); + } } @Test public void testGetBlobStoreJSON() throws Exception { - CloseableHttpResponse response = + try (CloseableHttpResponse response = handleGet( URI.create("/geowebcache/rest/blobstores/defaultCache.json"), - admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); - - JSONObject jsonObject = getResponseEntityAsJSONObject(response); - jsonObject = jsonObject.getJSONObject("FileBlobStore"); - assertEquals("defaultCache", jsonObject.get("id")); - assertEquals(false, jsonObject.get("enabled")); - assertEquals("/tmp/defaultCache", jsonObject.get("baseDirectory")); - assertEquals(4096, jsonObject.get("fileSystemBlockSize")); + admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + + JSONObject jsonObject = getResponseEntityAsJSONObject(response); + jsonObject = jsonObject.getJSONObject("FileBlobStore"); + assertEquals("defaultCache", jsonObject.get("id")); + assertEquals(false, jsonObject.get("enabled")); + assertEquals("/tmp/defaultCache", jsonObject.get("baseDirectory")); + assertEquals(4096, jsonObject.get("fileSystemBlockSize")); + } } @Test @@ -763,31 +792,34 @@ public void testPutBlobStoreCreateModifyDelete() throws Exception { + ""; // Make it sure doesn't exist - CloseableHttpResponse response = + try (CloseableHttpResponse response = handleGet( - URI.create("/geowebcache/rest/blobstores/newCache.xml"), admin.getClient()); - assertEquals(404, response.getStatusLine().getStatusCode()); - response.close(); + URI.create("/geowebcache/rest/blobstores/newCache.xml"), + admin.getClient())) { + assertEquals(404, response.getStatusLine().getStatusCode()); + } - response = + try (CloseableHttpResponse response = handlePut( URI.create("/geowebcache/rest/blobstores/newCache"), admin.getClient(), - blobStore); - assertEquals(201, response.getStatusLine().getStatusCode()); - response.close(); + blobStore)) { + assertEquals(201, response.getStatusLine().getStatusCode()); + } - response = + try (CloseableHttpResponse response = handleGet( - URI.create("/geowebcache/rest/blobstores/newCache.xml"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + URI.create("/geowebcache/rest/blobstores/newCache.xml"), + admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); - Document doc = getResponseEntityAsXML(response); + Document doc = getResponseEntityAsXML(response); - assertThat(doc, hasXPath("//id", equalTo("newCache"))); - assertThat(doc, hasXPath("//enabled", equalTo("false"))); - assertThat(doc, hasXPath("//baseDirectory", equalTo("/tmp/newCache"))); - assertThat(doc, hasXPath("//fileSystemBlockSize", equalTo("4096"))); + assertThat(doc, hasXPath("//id", equalTo("newCache"))); + assertThat(doc, hasXPath("//enabled", equalTo("false"))); + assertThat(doc, hasXPath("//baseDirectory", equalTo("/tmp/newCache"))); + assertThat(doc, hasXPath("//fileSystemBlockSize", equalTo("4096"))); + } String blobStoreUpdate = "\n" @@ -797,111 +829,122 @@ public void testPutBlobStoreCreateModifyDelete() throws Exception { + " 2048\n" + ""; - response = + try (CloseableHttpResponse response = handlePut( URI.create("/geowebcache/rest/blobstores/newCache"), admin.getClient(), - blobStoreUpdate); - assertEquals(200, response.getStatusLine().getStatusCode()); - response.close(); + blobStoreUpdate)) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } - response = + try (CloseableHttpResponse response = handleGet( - URI.create("/geowebcache/rest/blobstores/newCache.xml"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + URI.create("/geowebcache/rest/blobstores/newCache.xml"), + admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); - doc = getResponseEntityAsXML(response); + Document doc = getResponseEntityAsXML(response); - assertThat(doc, hasXPath("//id", equalTo("newCache"))); - assertThat(doc, hasXPath("//enabled", equalTo("false"))); - assertThat(doc, hasXPath("//baseDirectory", equalTo("/tmp/newCache"))); - assertThat(doc, hasXPath("//fileSystemBlockSize", equalTo("2048"))); + assertThat(doc, hasXPath("//id", equalTo("newCache"))); + assertThat(doc, hasXPath("//enabled", equalTo("false"))); + assertThat(doc, hasXPath("//baseDirectory", equalTo("/tmp/newCache"))); + assertThat(doc, hasXPath("//fileSystemBlockSize", equalTo("2048"))); + } - response = + try (CloseableHttpResponse response = handleDelete( - URI.create("/geowebcache/rest/blobstores/newCache.xml"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); - response.close(); + URI.create("/geowebcache/rest/blobstores/newCache.xml"), + admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } - response = + try (CloseableHttpResponse response = handleGet( - URI.create("/geowebcache/rest/blobstores/newCache.xml"), admin.getClient()); - assertEquals(404, response.getStatusLine().getStatusCode()); - response.close(); + URI.create("/geowebcache/rest/blobstores/newCache.xml"), + admin.getClient())) { + assertEquals(404, response.getStatusLine().getStatusCode()); + } } /* GridSetController Integration Tests *****************************************************/ @Test public void testGetGridSetsXML() throws Exception { - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/gridsets.xml"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); - - Document doc = getResponseEntityAsXML(response); - - assertThat(doc, hasXPath("count(/gridSets/gridSet)", equalTo("7"))); - assertThat(doc, hasXPath("/gridSets/gridSet[1]/name", equalTo("EPSG:2163"))); - assertThat( - doc, - hasXPath( - "/gridSets/gridSet[1]/atom:link/@href", - equalTo(jetty.getUri() + "rest/gridsets/EPSG:2163.xml"))); - assertThat( - doc, - hasXPath( - "/gridSets/gridSet[1]/atom:link/@type", equalTo(MediaType.TEXT_XML_VALUE))); + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/gridsets.xml"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + + Document doc = getResponseEntityAsXML(response); + + assertThat(doc, hasXPath("count(/gridSets/gridSet)", equalTo("7"))); + assertThat(doc, hasXPath("/gridSets/gridSet[1]/name", equalTo("EPSG:2163"))); + assertThat( + doc, + hasXPath( + "/gridSets/gridSet[1]/atom:link/@href", + equalTo(jetty.getUri() + "rest/gridsets/EPSG:2163.xml"))); + assertThat( + doc, + hasXPath( + "/gridSets/gridSet[1]/atom:link/@type", + equalTo(MediaType.TEXT_XML_VALUE))); + } } @Test public void testGetGridSetsJSON() throws Exception { - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/gridsets.json"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/gridsets.json"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); - JSONArray jsonArray = getResponseEntityAsJSONArray(response); - assertEquals(7, jsonArray.length()); - assertEquals("EPSG:2163", jsonArray.get(0)); + JSONArray jsonArray = getResponseEntityAsJSONArray(response); + assertEquals(7, jsonArray.length()); + assertEquals("EPSG:2163", jsonArray.get(0)); + } } @Test public void testGetGridSetXML() throws Exception { - CloseableHttpResponse response = + try (CloseableHttpResponse response = handleGet( - URI.create("/geowebcache/rest/gridsets/EPSG:2163.xml"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); - - Document doc = getResponseEntityAsXML(response); - - assertThat(doc, hasXPath("//name", equalTo("EPSG:2163"))); - assertThat(doc, hasXPath("//srs/number", equalTo("2163"))); - assertThat(doc, hasXPath("//extent/coords/double[1]", equalTo("-2495667.977678598"))); - assertThat(doc, hasXPath("//extent/coords/double[2]", equalTo("-2223677.196231552"))); - assertThat(doc, hasXPath("//extent/coords/double[3]", equalTo("3291070.6104286816"))); - assertThat(doc, hasXPath("//extent/coords/double[4]", equalTo("959189.3312465074"))); - assertThat(doc, hasXPath("//scaleDenominators/double[1]", equalTo("2.5E7"))); - assertThat(doc, hasXPath("//metersPerUnit", equalTo("1.0"))); - assertThat(doc, hasXPath("//pixelSize", equalTo("2.8E-4"))); - assertThat(doc, hasXPath("//yCoordinateFirst", equalTo("false"))); - assertThat(doc, hasXPath("//tileWidth", equalTo("200"))); - assertThat(doc, hasXPath("//tileHeight", equalTo("200"))); + URI.create("/geowebcache/rest/gridsets/EPSG:2163.xml"), + admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + + Document doc = getResponseEntityAsXML(response); + + assertThat(doc, hasXPath("//name", equalTo("EPSG:2163"))); + assertThat(doc, hasXPath("//srs/number", equalTo("2163"))); + assertThat(doc, hasXPath("//extent/coords/double[1]", equalTo("-2495667.977678598"))); + assertThat(doc, hasXPath("//extent/coords/double[2]", equalTo("-2223677.196231552"))); + assertThat(doc, hasXPath("//extent/coords/double[3]", equalTo("3291070.6104286816"))); + assertThat(doc, hasXPath("//extent/coords/double[4]", equalTo("959189.3312465074"))); + assertThat(doc, hasXPath("//scaleDenominators/double[1]", equalTo("2.5E7"))); + assertThat(doc, hasXPath("//metersPerUnit", equalTo("1.0"))); + assertThat(doc, hasXPath("//pixelSize", equalTo("2.8E-4"))); + assertThat(doc, hasXPath("//yCoordinateFirst", equalTo("false"))); + assertThat(doc, hasXPath("//tileWidth", equalTo("200"))); + assertThat(doc, hasXPath("//tileHeight", equalTo("200"))); + } } @Test public void testGetGridSetJSON() throws Exception { - CloseableHttpResponse response = + try (CloseableHttpResponse response = handleGet( - URI.create("/geowebcache/rest/gridsets/EPSG:2163.json"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); - - JSONObject jsonObject = getResponseEntityAsJSONObject(response); - jsonObject = jsonObject.getJSONObject("gridSet"); - assertEquals("EPSG:2163", jsonObject.get("name")); - assertEquals(2163, jsonObject.getJSONObject("srs").get("number")); - assertEquals( - "[-2495667.977678598,-2223677.196231552,3291070.6104286816,959189.3312465074]", - jsonObject.getJSONObject("extent").get("coords").toString()); - assertEquals("false", jsonObject.get("yCoordinateFirst").toString()); + URI.create("/geowebcache/rest/gridsets/EPSG:2163.json"), + admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + + JSONObject jsonObject = getResponseEntityAsJSONObject(response); + jsonObject = jsonObject.getJSONObject("gridSet"); + assertEquals("EPSG:2163", jsonObject.get("name")); + assertEquals(2163, jsonObject.getJSONObject("srs").get("number")); + assertEquals( + "[-2495667.977678598,-2223677.196231552,3291070.6104286816,959189.3312465074]", + jsonObject.getJSONObject("extent").get("coords").toString()); + assertEquals("false", jsonObject.get("yCoordinateFirst").toString()); + } } @Test @@ -942,37 +985,38 @@ public void testPutGridSetCreateModifyDelete() throws Exception { + ""; // Make it sure doesn't exist - CloseableHttpResponse response = + try (CloseableHttpResponse response = handleGet( URI.create("/geowebcache/rest/gridsets/testGridset.xml"), - admin.getClient()); - assertEquals(404, response.getStatusLine().getStatusCode()); - response.close(); + admin.getClient())) { + assertEquals(404, response.getStatusLine().getStatusCode()); + } - response = + try (CloseableHttpResponse response = handlePut( URI.create("/geowebcache/rest/gridsets/testGridset.xml"), admin.getClient(), - gridSet); - assertEquals(201, response.getStatusLine().getStatusCode()); - response.close(); + gridSet)) { + assertEquals(201, response.getStatusLine().getStatusCode()); + } - response = + try (CloseableHttpResponse response = handleGet( URI.create("/geowebcache/rest/gridsets/testGridset.xml"), - admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); - Document doc = getResponseEntityAsXML(response); + Document doc = getResponseEntityAsXML(response); - assertThat(doc, hasXPath("//name", equalTo("testGridset"))); - assertThat(doc, hasXPath("//srs/number", equalTo("4326"))); - assertThat(doc, hasXPath("//scaleDenominators/double[1]", equalTo("2.5E7"))); - assertThat(doc, hasXPath("//metersPerUnit", equalTo("1.0"))); - assertThat(doc, hasXPath("//pixelSize", equalTo("2.8E-4"))); - assertThat(doc, hasXPath("//yCoordinateFirst", equalTo("false"))); - assertThat(doc, hasXPath("//tileWidth", equalTo("211"))); - assertThat(doc, hasXPath("//tileHeight", equalTo("211"))); + assertThat(doc, hasXPath("//name", equalTo("testGridset"))); + assertThat(doc, hasXPath("//srs/number", equalTo("4326"))); + assertThat(doc, hasXPath("//scaleDenominators/double[1]", equalTo("2.5E7"))); + assertThat(doc, hasXPath("//metersPerUnit", equalTo("1.0"))); + assertThat(doc, hasXPath("//pixelSize", equalTo("2.8E-4"))); + assertThat(doc, hasXPath("//yCoordinateFirst", equalTo("false"))); + assertThat(doc, hasXPath("//tileWidth", equalTo("211"))); + assertThat(doc, hasXPath("//tileHeight", equalTo("211"))); + } String gridSetUpdate = "\n" @@ -1009,83 +1053,85 @@ public void testPutGridSetCreateModifyDelete() throws Exception { + " false\n" + ""; - response = + try (CloseableHttpResponse response = handlePut( URI.create("/geowebcache/rest/gridsets/testGridset"), admin.getClient(), - gridSetUpdate); - assertEquals(200, response.getStatusLine().getStatusCode()); - response.close(); + gridSetUpdate)) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } - response = + try (CloseableHttpResponse response = handleGet( URI.create("/geowebcache/rest/gridsets/testGridset.xml"), - admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); - - doc = getResponseEntityAsXML(response); + admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); - assertThat(doc, hasXPath("//name", equalTo("testGridset"))); - assertThat(doc, hasXPath("//srs/number", equalTo("2163"))); - assertThat(doc, hasXPath("//scaleDenominators/double[1]", equalTo("2.5E7"))); - assertThat(doc, hasXPath("//metersPerUnit", equalTo("1.0"))); - assertThat(doc, hasXPath("//pixelSize", equalTo("2.8E-4"))); - assertThat(doc, hasXPath("//yCoordinateFirst", equalTo("false"))); - assertThat(doc, hasXPath("//tileWidth", equalTo("200"))); - assertThat(doc, hasXPath("//tileHeight", equalTo("200"))); + Document doc = getResponseEntityAsXML(response); + assertThat(doc, hasXPath("//name", equalTo("testGridset"))); + assertThat(doc, hasXPath("//srs/number", equalTo("2163"))); + assertThat(doc, hasXPath("//scaleDenominators/double[1]", equalTo("2.5E7"))); + assertThat(doc, hasXPath("//metersPerUnit", equalTo("1.0"))); + assertThat(doc, hasXPath("//pixelSize", equalTo("2.8E-4"))); + assertThat(doc, hasXPath("//yCoordinateFirst", equalTo("false"))); + assertThat(doc, hasXPath("//tileWidth", equalTo("200"))); + assertThat(doc, hasXPath("//tileHeight", equalTo("200"))); + } - response = + try (CloseableHttpResponse response = handleDelete( URI.create("/geowebcache/rest/gridsets/testGridset.xml"), - admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); - response.close(); + admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } - response = + try (CloseableHttpResponse response = handleGet( URI.create("/geowebcache/rest/gridsets/testGridset.xml"), - admin.getClient()); - assertEquals(404, response.getStatusLine().getStatusCode()); - response.close(); + admin.getClient())) { + assertEquals(404, response.getStatusLine().getStatusCode()); + } } /* DiskQuotaController Integration Tests *****************************************************/ @Test public void testDiskQuotaXML() throws Exception { - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/diskquota.xml"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); - if (response.getStatusLine().getStatusCode() == 200) { - Document doc = getResponseEntityAsXML(response); - assertThat(doc, hasXPath("//enabled", equalTo("false"))); - assertThat(doc, hasXPath("//cacheCleanUpFrequency", equalTo("10"))); - assertThat(doc, hasXPath("//cacheCleanUpUnits", equalTo("SECONDS"))); - assertThat(doc, hasXPath("//maxConcurrentCleanUps", equalTo("2"))); - assertThat(doc, hasXPath("//globalExpirationPolicyName", equalTo("LFU"))); - assertThat(doc, hasXPath("//globalQuota/id", equalTo("0"))); - assertThat(doc, hasXPath("//globalQuota/bytes", equalTo("524288000"))); + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/diskquota.xml"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + if (response.getStatusLine().getStatusCode() == 200) { + Document doc = getResponseEntityAsXML(response); + assertThat(doc, hasXPath("//enabled", equalTo("false"))); + assertThat(doc, hasXPath("//cacheCleanUpFrequency", equalTo("10"))); + assertThat(doc, hasXPath("//cacheCleanUpUnits", equalTo("SECONDS"))); + assertThat(doc, hasXPath("//maxConcurrentCleanUps", equalTo("2"))); + assertThat(doc, hasXPath("//globalExpirationPolicyName", equalTo("LFU"))); + assertThat(doc, hasXPath("//globalQuota/id", equalTo("0"))); + assertThat(doc, hasXPath("//globalQuota/bytes", equalTo("524288000"))); + } } } @Test public void testDiskQuotaJson() throws Exception { - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/diskquota.json"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); - if (response.getStatusLine().getStatusCode() == 200) { - JSONObject jsonObject = getResponseEntityAsJSONObject(response); - Object obj = jsonObject.get("org.geowebcache.diskquota.DiskQuotaConfig"); - if (obj instanceof JSONObject) { - assertEquals(false, ((JSONObject) obj).get("enabled")); - assertEquals(10, ((JSONObject) obj).get("cacheCleanUpFrequency")); - assertEquals("SECONDS", ((JSONObject) obj).get("cacheCleanUpUnits")); - assertEquals(2, ((JSONObject) obj).get("maxConcurrentCleanUps")); - assertEquals("LFU", ((JSONObject) obj).get("globalExpirationPolicyName")); - Object globalQuota = ((JSONObject) obj).get("globalQuota"); - if (globalQuota instanceof JSONObject) { - assertEquals(0, ((JSONObject) globalQuota).get("id")); - assertEquals(524288000, ((JSONObject) globalQuota).get("bytes")); + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/diskquota.json"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + if (response.getStatusLine().getStatusCode() == 200) { + JSONObject jsonObject = getResponseEntityAsJSONObject(response); + Object obj = jsonObject.get("org.geowebcache.diskquota.DiskQuotaConfig"); + if (obj instanceof JSONObject) { + assertEquals(false, ((JSONObject) obj).get("enabled")); + assertEquals(10, ((JSONObject) obj).get("cacheCleanUpFrequency")); + assertEquals("SECONDS", ((JSONObject) obj).get("cacheCleanUpUnits")); + assertEquals(2, ((JSONObject) obj).get("maxConcurrentCleanUps")); + assertEquals("LFU", ((JSONObject) obj).get("globalExpirationPolicyName")); + Object globalQuota = ((JSONObject) obj).get("globalQuota"); + if (globalQuota instanceof JSONObject) { + assertEquals(0, ((JSONObject) globalQuota).get("id")); + assertEquals(524288000, ((JSONObject) globalQuota).get("bytes")); + } } } } @@ -1118,73 +1164,84 @@ public void testSeedPost() throws Exception { + // ""; - CloseableHttpResponse response = + try (CloseableHttpResponse response = handlePost( URI.create("/geowebcache/rest/seed/topp:states.xml"), admin.getClient(), - seedLayer); - assertEquals(200, response.getStatusLine().getStatusCode()); + seedLayer)) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } } @Test public void testSeedGet() throws Exception { - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/seed/topp:states"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/seed/topp:states"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } } @Test public void testSeedGetNoLayer() throws Exception { - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/seed"), admin.getClient()); - assertEquals(405, response.getStatusLine().getStatusCode()); + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/seed"), admin.getClient())) { + assertEquals(405, response.getStatusLine().getStatusCode()); + } } @Test public void testSeedGetSeedForm() throws Exception { - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/seed/topp:states"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/seed/topp:states"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } } @Test public void testSeedGetJson() throws Exception { - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/seed.json"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + try (CloseableHttpResponse response = + handleGet(URI.create("/geowebcache/rest/seed.json"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } } @Test public void testSeedGetLayerJson() throws Exception { - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/seed/topp:states.json"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + try (CloseableHttpResponse response = + handleGet( + URI.create("/geowebcache/rest/seed/topp:states.json"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } } @Test public void testSeedGetLayerXml() throws Exception { - CloseableHttpResponse response = - handleGet(URI.create("/geowebcache/rest/seed/topp:states.xml"), admin.getClient()); - assertEquals(200, response.getStatusLine().getStatusCode()); + try (CloseableHttpResponse response = + handleGet( + URI.create("/geowebcache/rest/seed/topp:states.xml"), admin.getClient())) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } } @Test public void testKillAll() throws Exception { String killCommand = "kill_all=all"; - CloseableHttpResponse response = - handlePost(URI.create("/geowebcache/rest/seed"), admin.getClient(), killCommand); - assertEquals(200, response.getStatusLine().getStatusCode()); + try (CloseableHttpResponse response = + handlePost(URI.create("/geowebcache/rest/seed"), admin.getClient(), killCommand)) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } } @Test public void testLayerKillAll() throws Exception { String killCommand = "kill_all=all"; - CloseableHttpResponse response = + try (CloseableHttpResponse response = handlePost( URI.create("/geowebcache/rest/seed/topp:states"), admin.getClient(), - killCommand); - assertEquals(200, response.getStatusLine().getStatusCode()); + killCommand)) { + assertEquals(200, response.getStatusLine().getStatusCode()); + } } @Test diff --git a/geowebcache/web/src/test/java/org/geowebcache/jetty/Start.java b/geowebcache/web/src/test/java/org/geowebcache/jetty/Start.java index 69bc85699..ce60f951b 100644 --- a/geowebcache/web/src/test/java/org/geowebcache/jetty/Start.java +++ b/geowebcache/web/src/test/java/org/geowebcache/jetty/Start.java @@ -19,6 +19,7 @@ * * @author wolf */ +@SuppressWarnings("PMD.CloseResource") public class Start { private static final Log log = LogFactory.getLog(Start.class); @@ -87,13 +88,4 @@ public void run() { } } } - - private static int parsePort(String portVariable) { - if (portVariable == null) return -1; - try { - return Integer.valueOf(portVariable).intValue(); - } catch (NumberFormatException e) { - return -1; - } - } } diff --git a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesGridSetConfigurationConformanceTest.java b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesGridSetConfigurationConformanceTest.java index 6d8b5a24f..0e61c35f7 100644 --- a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesGridSetConfigurationConformanceTest.java +++ b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesGridSetConfigurationConformanceTest.java @@ -194,6 +194,7 @@ protected void modifyInfo(GridSetConfiguration config, GridSet info) throws Exce } @Override + @Test public void testCanSaveGoodInfo() throws Exception { // Should not be able to save anything as it is read only assertThat(config.canSave(getGoodInfo("test", 1)), equalTo(false)); diff --git a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesLayerConfigurationConformanceTest.java b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesLayerConfigurationConformanceTest.java index 8b74faa0c..7c456bf47 100644 --- a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesLayerConfigurationConformanceTest.java +++ b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesLayerConfigurationConformanceTest.java @@ -191,6 +191,7 @@ protected void modifyInfo(TileLayerConfiguration config, TileLayer info) throws } @Override + @Test public void testCanSaveGoodInfo() throws Exception { // Should not be able to save anything as it is read only assertThat(config.canSave(getGoodInfo("test", 1)), equalTo(false)); diff --git a/geowebcache/wms/src/test/java/org/geowebcache/io/codec/TestSpring.java b/geowebcache/wms/src/test/java/org/geowebcache/io/codec/TestSpring.java index f343071b6..0c0e7afc0 100644 --- a/geowebcache/wms/src/test/java/org/geowebcache/io/codec/TestSpring.java +++ b/geowebcache/wms/src/test/java/org/geowebcache/io/codec/TestSpring.java @@ -15,26 +15,27 @@ public class TestSpring { @Test public void testBeanSelection() { // Selection of the Test Application Context - ClassPathXmlApplicationContext context = - new ClassPathXmlApplicationContext("appContextTest2.xml"); - // Check that the initializer is present - Object obj = context.getBean("ioInitializer"); - Assert.assertNotNull(obj); - Assert.assertTrue(obj instanceof ImageIOInitializer); + try (ClassPathXmlApplicationContext context = + new ClassPathXmlApplicationContext("appContextTest2.xml")) { + // Check that the initializer is present + Object obj = context.getBean("ioInitializer"); + Assert.assertNotNull(obj); + Assert.assertTrue(obj instanceof ImageIOInitializer); - // Ensure that the excluded spi are present - ImageIOInitializer init = (ImageIOInitializer) obj; - List excluded = init.getExcludedSpis(); - Assert.assertNotNull(excluded); - Assert.assertTrue(excluded.isEmpty()); + // Ensure that the excluded spi are present + ImageIOInitializer init = (ImageIOInitializer) obj; + List excluded = init.getExcludedSpis(); + Assert.assertNotNull(excluded); + Assert.assertTrue(excluded.isEmpty()); - // Ensure that a decoder is present - Object obj2 = context.getBean("TIFFDecoder"); - Assert.assertNotNull(obj2); - Assert.assertTrue(obj2 instanceof ImageDecoderImpl); + // Ensure that a decoder is present + Object obj2 = context.getBean("TIFFDecoder"); + Assert.assertNotNull(obj2); + Assert.assertTrue(obj2 instanceof ImageDecoderImpl); - // Test if the container has been created - ImageDecoderContainer container = context.getBean(ImageDecoderContainer.class); - Assert.assertNotNull(container); + // Test if the container has been created + ImageDecoderContainer container = context.getBean(ImageDecoderContainer.class); + Assert.assertNotNull(container); + } } } diff --git a/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSTileFuserTest.java b/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSTileFuserTest.java index 5ff9f9f02..049944e78 100644 --- a/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSTileFuserTest.java +++ b/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSTileFuserTest.java @@ -178,19 +178,21 @@ public void testTileFuserSecurityLayerNotNull() throws Exception { }); WMSTileFuser tileFuser = new WMSTileFuser(tld, sb, fuserRequest(layer, gridSubset, bounds, width, height)); - ClassPathXmlApplicationContext context = - new ClassPathXmlApplicationContext("appContextTest.xml"); - tileFuser.setApplicationContext(context); + try (ClassPathXmlApplicationContext context = + new ClassPathXmlApplicationContext("appContextTest.xml")) { + tileFuser.setApplicationContext(context); - tileFuser.setSecurityDispatcher(secDisp); - MockHttpServletResponse response = new MockHttpServletResponse(); - RuntimeStats stats = mock(RuntimeStats.class); + tileFuser.setSecurityDispatcher(secDisp); + MockHttpServletResponse response = new MockHttpServletResponse(); + RuntimeStats stats = mock(RuntimeStats.class); - tileFuser.writeResponse(response, stats); + tileFuser.writeResponse(response, stats); - Mockito.verify(secDisp, times(4)) - .checkSecurity( - Mockito.argThat(hasProperty("tileLayer", notNullValue(TileLayer.class)))); + Mockito.verify(secDisp, times(4)) + .checkSecurity( + Mockito.argThat( + hasProperty("tileLayer", notNullValue(TileLayer.class)))); + } } @Test @@ -300,15 +302,16 @@ public boolean get(TileObject stObj) throws StorageException { tileFuser.setSecurityDispatcher(secDisp); // Selection of the ApplicationContext associated - ClassPathXmlApplicationContext context = - new ClassPathXmlApplicationContext("appContextTest.xml"); - tileFuser.setApplicationContext(context); - MockHttpServletResponse response = new MockHttpServletResponse(); + try (ClassPathXmlApplicationContext context = + new ClassPathXmlApplicationContext("appContextTest.xml")) { + tileFuser.setApplicationContext(context); + MockHttpServletResponse response = new MockHttpServletResponse(); - tileFuser.writeResponse( - response, new RuntimeStats(1, Arrays.asList(1), Arrays.asList("desc"))); + tileFuser.writeResponse( + response, new RuntimeStats(1, Arrays.asList(1), Arrays.asList("desc"))); - assertTrue(response.getContentAsString().length() > 0); + assertTrue(response.getContentAsString().length() > 0); + } } finally { temp.delete(); } diff --git a/geowebcache/wmts/src/test/java/org/geowebcache/service/wmts/WMTSRestTest.java b/geowebcache/wmts/src/test/java/org/geowebcache/service/wmts/WMTSRestTest.java index 9b06eab04..c38b7b2c1 100644 --- a/geowebcache/wmts/src/test/java/org/geowebcache/service/wmts/WMTSRestTest.java +++ b/geowebcache/wmts/src/test/java/org/geowebcache/service/wmts/WMTSRestTest.java @@ -37,7 +37,6 @@ import org.apache.commons.io.FileUtils; import org.custommonkey.xmlunit.SimpleNamespaceContext; import org.custommonkey.xmlunit.XMLUnit; -import org.custommonkey.xmlunit.XpathEngine; import org.geowebcache.config.DefaultGridsets; import org.geowebcache.config.ServerConfiguration; import org.geowebcache.config.XMLGridSubset; @@ -73,9 +72,6 @@ public class WMTSRestTest { - // private static Map namespaces = new HashMap(0); - private static XpathEngine xpath; - GridSetBroker broker = new GridSetBroker(Collections.singletonList(new DefaultGridsets(true, true))); private WMTSService wmtsService; @@ -103,7 +99,6 @@ public static void setupXMLUnit() { namespaces.put("ows", "http://www.opengis.net/ows/1.1"); namespaces.put("wmts", "http://www.opengis.net/wmts/1.0"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); - xpath = XMLUnit.newXpathEngine(); } @Test diff --git a/geowebcache/wmts/src/test/java/org/geowebcache/service/wmts/WMTSServiceTest.java b/geowebcache/wmts/src/test/java/org/geowebcache/service/wmts/WMTSServiceTest.java index 58a08730a..4eaff59ea 100644 --- a/geowebcache/wmts/src/test/java/org/geowebcache/service/wmts/WMTSServiceTest.java +++ b/geowebcache/wmts/src/test/java/org/geowebcache/service/wmts/WMTSServiceTest.java @@ -1239,8 +1239,7 @@ public Conveyor getConveyor( @Override public boolean handleRequest(Conveyor conveyor) throws OWSException { if (conveyor.getHint().equalsIgnoreCase("CustomOperation")) { - try { - OutputStream os = conveyor.servletResp.getOutputStream(); + try (OutputStream os = conveyor.servletResp.getOutputStream()) { os.write("CustomOperation Result".getBytes()); os.flush(); } catch (IOException exception) { From 72e066b09e78bdf9044e99d99d0b5101da6a2ee3 Mon Sep 17 00:00:00 2001 From: Mauro Bartolomeoli Date: Mon, 22 Feb 2021 08:24:07 +0100 Subject: [PATCH 03/11] #926: update jaiext to 1.1.20 --- geowebcache/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geowebcache/pom.xml b/geowebcache/pom.xml index 75de29a3b..855cd5dc0 100644 --- a/geowebcache/pom.xml +++ b/geowebcache/pom.xml @@ -12,7 +12,7 @@ 25-SNAPSHOT 1.18.0 - 1.1.19 + 1.1.20 5.1.20.RELEASE 5.1.13.RELEASE 1.4.11.1 From 629db5678e403ac4abdde880cd04ecb80c94c374 Mon Sep 17 00:00:00 2001 From: Andrea Aime Date: Tue, 16 Feb 2021 18:04:40 +0100 Subject: [PATCH 04/11] Introduce 512px tiles as a possible alternative for the default gridsets --- .../geowebcache/config/DefaultGridsets.java | 62 ++++++++++++++++++- .../geowebcache/grid/DefaultGridSetsTest.java | 52 ++++++++++++++++ .../jetty/RestIntegrationTest.java | 4 +- 3 files changed, 113 insertions(+), 5 deletions(-) diff --git a/geowebcache/core/src/main/java/org/geowebcache/config/DefaultGridsets.java b/geowebcache/core/src/main/java/org/geowebcache/config/DefaultGridsets.java index 95c2b22aa..bf7b9929a 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/config/DefaultGridsets.java +++ b/geowebcache/core/src/main/java/org/geowebcache/config/DefaultGridsets.java @@ -14,6 +14,7 @@ */ package org.geowebcache.config; +import java.util.Arrays; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.geowebcache.GeoWebCacheException; @@ -33,16 +34,28 @@ public class DefaultGridsets extends SimpleGridSetConfiguration { private final GridSet WORLD_EPSG4326; + private final GridSet WORLD_EPSG4326x2; + private final GridSet WORLD_EPSG3857; + private final GridSet WORLD_EPSG3857x2; + public GridSet worldEpsg4326() { return new GridSet(WORLD_EPSG4326); } + public GridSet worldEpsg4326x2() { + return new GridSet(WORLD_EPSG4326x2); + } + public GridSet worldEpsg3857() { return new GridSet(WORLD_EPSG3857); } + public GridSet worldEpsg3857x2() { + return new GridSet(WORLD_EPSG3857x2); + } + /** * Construct the default gridsets bean * @@ -79,11 +92,30 @@ public DefaultGridsets(boolean useEPSG900913, boolean useGWC11xNames) { true); WORLD_EPSG4326.setDescription( "A default WGS84 tile matrix set where the first zoom level " - + "covers the world with two tiles on the horizonal axis and one tile " + + "covers the world with two tiles on the horizontal axis and one tile " + "over the vertical axis and each subsequent zoom level is calculated by half " - + "the resolution of its previous one."); + + "the resolution of its previous one. Tiles are 256px wide."); addInternal(WORLD_EPSG4326); + WORLD_EPSG4326x2 = + GridSetFactory.createGridSet( + unprojectedName + "x2", + SRS.getEPSG4326(), + BoundingBox.WORLD4326, + false, + GridSetFactory.DEFAULT_LEVELS, + null, + GridSetFactory.DEFAULT_PIXEL_SIZE_METER, + 512, + 512, + true); + WORLD_EPSG4326x2.setDescription( + "A default WGS84 tile matrix set where the first zoom level " + + "covers the world with two tiles on the horizontal axis and one tile " + + "over the vertical axis and each subsequent zoom level is calculated by half " + + "the resolution of its previous one. Tiles are 512px wide."); + addInternal(WORLD_EPSG4326x2); + final SRS googleMapsCompatibleSRS = useEPSG900913 ? SRS.getEPSG900913() : SRS.getEPSG3857(); log.debug( "Adding " @@ -104,7 +136,6 @@ public DefaultGridsets(boolean useEPSG900913, boolean useGWC11xNames) { 256, 256, false); - WORLD_EPSG3857.setDescription( "This well-known scale set has been defined to be compatible with Google Maps and" + " Microsoft Live Map projections and zoom levels. Level 0 allows representing the whole " @@ -113,6 +144,27 @@ public DefaultGridsets(boolean useEPSG900913, boolean useGWC11xNames) { addInternal(WORLD_EPSG3857); + WORLD_EPSG3857x2 = + GridSetFactory.createGridSet( + mercatorName + "x2", + googleMapsCompatibleSRS, + BoundingBox.WORLD3857, + false, + halveResolutions(commonPractice900913Resolutions()), + null, + 1.0D, + GridSetFactory.DEFAULT_PIXEL_SIZE_METER, + null, + 512, + 512, + false); + WORLD_EPSG3857x2.setDescription( + "This well-known scale set has been defined to be compatible with Google Maps and" + + " Microsoft Live Map projections and zoom levels. Level 0 allows representing the whole " + + "world in a single 512x512 pixels. The next level represents the whole world in 2x2 tiles " + + "of 512x512 pixels and so on in powers of 2. Scale denominator is only accurate near the equator."); + addInternal(WORLD_EPSG3857x2); + log.debug("Adding GlobalCRS84Pixel"); GridSet GlobalCRS84Pixel = GridSetFactory.createGridSet( @@ -184,6 +236,10 @@ public DefaultGridsets(boolean useEPSG900913, boolean useGWC11xNames) { addInternal(GoogleCRS84Quad); } + private double[] halveResolutions(double[] resolutions) { + return Arrays.stream(resolutions).map(r -> r / 2).toArray(); + } + @Override public void afterPropertiesSet() throws GeoWebCacheException {} diff --git a/geowebcache/core/src/test/java/org/geowebcache/grid/DefaultGridSetsTest.java b/geowebcache/core/src/test/java/org/geowebcache/grid/DefaultGridSetsTest.java index 1e702365a..862d43b1c 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/grid/DefaultGridSetsTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/grid/DefaultGridSetsTest.java @@ -17,9 +17,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; import java.util.Arrays; import org.geowebcache.config.DefaultGridsets; +import org.hamcrest.CoreMatchers; import org.junit.Test; public class DefaultGridSetsTest { @@ -86,4 +88,54 @@ public void testNonGwc11xDefaultGridSets() throws Exception { googleMapsCompatible, defaultMercatorGridSet); } + + @Test + public void test4326x2() { + DefaultGridsets gs = new DefaultGridsets(true, true); + GridSet base = gs.worldEpsg4326(); + GridSet x2 = gs.worldEpsg4326x2(); + + // description + assertThat(base.getDescription(), CoreMatchers.containsString("256")); + assertThat(x2.getDescription(), CoreMatchers.containsString("512")); + + // tile sizes + assertEquals(256, base.getTileWidth()); + assertEquals(256, base.getTileHeight()); + assertEquals(512, x2.getTileWidth()); + assertEquals(512, x2.getTileHeight()); + + // reference pixel size and scale denominators + for (int level = 0; level < base.getNumLevels(); level++) { + assertEquals( + base.getGrid(level).getScaleDenominator(), + x2.getGrid(level).getScaleDenominator() * 2, + 1e-6); + } + } + + @Test + public void test3857x2() { + DefaultGridsets gs = new DefaultGridsets(true, true); + GridSet base = gs.worldEpsg3857(); + GridSet x2 = gs.worldEpsg3857x2(); + + // description + assertThat(base.getDescription(), CoreMatchers.containsString("256x256")); + assertThat(x2.getDescription(), CoreMatchers.containsString("512x512")); + + // tile sizes + assertEquals(256, base.getTileWidth()); + assertEquals(256, base.getTileHeight()); + assertEquals(512, x2.getTileWidth()); + assertEquals(512, x2.getTileHeight()); + + // reference pixel size and scale denominators + for (int level = 0; level < base.getNumLevels(); level++) { + assertEquals( + base.getGrid(level).getScaleDenominator(), + x2.getGrid(level).getScaleDenominator() * 2, + 1e-6); + } + } } diff --git a/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java b/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java index 516536c67..98af05553 100644 --- a/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java +++ b/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java @@ -876,7 +876,7 @@ public void testGetGridSetsXML() throws Exception { Document doc = getResponseEntityAsXML(response); - assertThat(doc, hasXPath("count(/gridSets/gridSet)", equalTo("7"))); + assertThat(doc, hasXPath("count(/gridSets/gridSet)", equalTo("9"))); assertThat(doc, hasXPath("/gridSets/gridSet[1]/name", equalTo("EPSG:2163"))); assertThat( doc, @@ -898,7 +898,7 @@ public void testGetGridSetsJSON() throws Exception { assertEquals(200, response.getStatusLine().getStatusCode()); JSONArray jsonArray = getResponseEntityAsJSONArray(response); - assertEquals(7, jsonArray.length()); + assertEquals(9, jsonArray.length()); assertEquals("EPSG:2163", jsonArray.get(0)); } } From 6b9ba4e8478c31e02d1e0c0095f3f954be0863d7 Mon Sep 17 00:00:00 2001 From: Jim Hughes Date: Fri, 26 Feb 2021 15:27:30 -0500 Subject: [PATCH 05/11] Updating JTS Version to 1.18.1. Signed-off-by: Jim Hughes --- geowebcache/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geowebcache/pom.xml b/geowebcache/pom.xml index 855cd5dc0..1b56e0a1e 100644 --- a/geowebcache/pom.xml +++ b/geowebcache/pom.xml @@ -11,7 +11,7 @@ 25-SNAPSHOT - 1.18.0 + 1.18.1 1.1.20 5.1.20.RELEASE 5.1.13.RELEASE From fc8d18c0513c86cb05e22c587bfffa99ce7e780d Mon Sep 17 00:00:00 2001 From: Jody Garnett Date: Mon, 1 Mar 2021 22:11:34 -0800 Subject: [PATCH 06/11] Use geowebcache.xsd schema 1.19.0 --- .../core/src/main/resources/geowebcache.xml | 4 +- .../org/geowebcache/config/geowebcache.xsd | 4 +- .../geowebcache/config/geowebcache_1180.xsd | 2188 +++++++++++++++++ .../geowebcache/config/geowebcache_1180.xml | 283 +++ 4 files changed, 2475 insertions(+), 4 deletions(-) create mode 100644 geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache_1180.xsd create mode 100644 geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1180.xml diff --git a/geowebcache/core/src/main/resources/geowebcache.xml b/geowebcache/core/src/main/resources/geowebcache.xml index 2e4cec35f..285ee2be2 100644 --- a/geowebcache/core/src/main/resources/geowebcache.xml +++ b/geowebcache/core/src/main/resources/geowebcache.xml @@ -1,7 +1,7 @@ + xmlns="http://geowebcache.org/schema/1.19.0" + xsi:schemaLocation="http://geowebcache.org/schema/1.19.0 http://geowebcache.org/schema/1.19.0/geowebcache.xsd"> 1.8.0 120 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 d196a94b0..db4328df8 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/1.19.0" xmlns:gwc="http://geowebcache.org/schema/1.19.0" + elementFormDefault="qualified" version="1.19.0"> diff --git a/geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache_1180.xsd b/geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache_1180.xsd new file mode 100644 index 000000000..0fdcf3cbf --- /dev/null +++ b/geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache_1180.xsd @@ -0,0 +1,2188 @@ + + + + + + + Wrapper element for XStream. Make sure it has the correct namespace + + + + + + + + The version number should match the XSD namespace + and the version + of GWC + + + + + + + The backend timeout is the number of seconds GWC + will wait for a + backend server to return something + before closing the connection. + + + + + + + If TRUE the implementation of WMTS service will strictly + comply with the corresponding CITE tests. + + + + + + + The name of the lock provider. For single node installs don't set the property, + for clustered implementation you can use "nio" instead (will work if your shared + file-system supports file locks) + + + + + + + Determines whether cached=false is allowed for + requests going + through the WMS service, including + converters such as Google Maps. Enabling this + disables caching for those + requests. + + + + + + + Runtime statistics run, by default, every three + second and + provide data about how many requests the + system has been serving in the past 3, 15 and 60 + seconds, as well + as aggregate numbers. + + The overhead of this system is extremely low, by + default it is enabled. + + + + + + + Service information such as you or your company's + details that + you want provided in capabilities + documents. + + + + + + + If you wish to have every connection to HTTP + backends use HTTP + Authentication set this to the + username. You must then also set httpPassword for it + to take effect. + + This + feature should be considered experimental in + 1.2.0. + + + + + + + If you wish to have every connection to HTTP + backends use HTTP + Authentication set this to the + password. You must then also set httpUsername for it + to take effect. + + This + feature should be considered experimental in + 1.2.0. + + + + + + + + These are the global format modifiers that apply to + all layers in + this file, unless the layer has + separately defined modifiers. They can be used to + avoid repeated + compression, by making image/png + backend requests before compressing to image/jpeg . + They can also be used + for special tweaks, such as + setting the background color for formats that do not + support transparency. + + + + + + + + The list of blob stores. BlobStores allow to define a storage mechanism and format, such as the legacy file system + based storage, an Amazon S3 instance with a TMS-like key structure, etc; independently of where the tiles come from + in the TileLayer configuration. + + + + + + + + + + + + + The list of grid sets provided by this + configuration. + + + + + + + + + + + + The list of WMS layers provided by this + configuration. + + + + + + + + + + + + + Parameter used for configuring full WMS requests for GeoWebCache. Setting this parameter to true enables full WMS requests. + + + + + + + + + + + + + A blob store must have a unique identifier assigned through this element, which can be referenced + by any number of TileLayer's 'blobStoreId'. + + + + + + + Defines whether the blob store is enabled (true) or disabled (false). Attempting to use + a TileLayer whose blob store is disabled will result in a runtime exception. + + + + + + + + The default attribute can only be true for one of the configured blob stores. + If no blob store is configured as the default one, then one will be created automatically + following the legacy location discovery method of looking for the GEOWEBCACHE_CACHE_DIR environment + variable, servlet context parameter, or JVM argument. + Additionally, any layer that has no blobStoreId set will default to use the default blob store, + whether it is defined in the configuration file, or created automatically using the legacy method. + So, it is allowed that none of the configured blob stores has its 'default' attribute set to true, + but it's a configuration error that more than one is set as the default one. In such case, an exception + will be thrown at application startup. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + the name of the AWS S3 bucket where to store tiles + + + + + + An optional prefix path to use as the "root folder" to store tiles at. + For example, if the bucket is bucket.gwc.example and prefix is "mycache", all tiles will be stored under + bucket.gwc.example/mycache/{layer name} instead of bucket.gwc.example/{layer name}. + + + + + + The public access key the client uses to connect to S3. + + + + + The secret key the client uses to connect to S3 + + + + + Whether S3 object access is public or private + + + + + Maximum number of concurrent HTTP connections the S3 client may use. + + + + + Whether to use HTTPS when connecting to S3 or not + + + + + Endpoint of the server, if using an alternative S3-compatible server instead of Amazon. + + + + + + The optional Windows domain name for configuring an NTLM proxy. + If you aren't using a Windows NTLM proxy, you do not need to set this field. + + + + + + + The optional Windows workstation name for configuring NTLM proxy support. + If you aren't using a Windows NTLM proxy, you do not need to set this field. + + + + + + The optional proxy host the client will connect through. + + + + + The optional proxy port the client will connect through. + + + + + The optional proxy user name to use if connecting through a proxy. + + + + + The optional proxy password to use when connecting through a proxy. + + + + + Whether gzip compression should be used. + + + + + + + + + + + + + + The identifier of the BlobStore this layer tiles shall be saved on. + If not provided, the default blob store will be used. + + + + + + + Whether the layer is enabled or not. Defaults to true. If the + Layer is not enabled + it will not be listed in capabilities documents, and any attempt to perform a request + against it will throw an exception. But a disabled layer CAN be seeded, as it's the + administrator's choice + whether to temporarily disable or not a Layer to perform a long seed + + + + + + + The name of the layer that GWC should respond to. It is equivalent + to the + value of LAYERS= in WMS requests, and can contain commas. See wmsLayers + + + + + + + Meta information like a title and description intended for human + consumption + + + + + + + List of formats to be supported. These must be known to + GeoWebCache. Legal values are + image/png, image/png8, image/png24, image/gif, image/jpeg, image/tiff, gml, + application/vnd.google-earth.kml+xml, application/vnd.google-earth.kmz+xml, + + + + + + + List of formats to be supported for GetFeatureInfo. These must be known to + GeoWebCache. Legal values are + text/plain, text/html, application/vnd.ogc.gml and application/json + + + + + + + If formatModifiers are specified on the layer the global ones will + be + ignored. Format modifiers can be used to apply special tweaks depending + on the requested format, such as + requesting image/png from the backend + and then persist that to disk. + + + + + + + DEPRECATED + + + + + + + The grid definitions contain information about the SRS, the + maximum extent for + this SRS and the bounds of your data. + + + + + + + (1.2.2) Update sources provide information about when tiles should + be expired + in GeoWebCache. As of 1.2.2, only GeoRSS is supported. + + + + + + + Request filters are applied to all requests and make it possible + to apply + special rules for certain requests. The filters themselves are written + in Java, though they can be + made configurable through XML. + + + + + + + (1.2.2) GeoWebCache can provide ETags based on the last time a + tile was modified and + thus support conditional gets. Note that most clients only refer to this tag + once the + data has expired, so set use small values for the client expiration. + This functionality is not available if + the metastore is disabled. + + + + + + + The metatiling factors used for this layer. These are used to + scale the bounding + box and height/width. With tiles that are 256 by 256 pixels, a 4 by 4 metatiled + requests + results in a 1024 by 1024 pixel image requested from the backend server. + Higher reduced the number of + repeated labels, but can overload the backend server. + + + + + + + How old the tile may be before it is refetched from the backend. + The default value is 0, which means infinite, otherwise specified in seconds. + As of GWC 1.1.0 this element is + not fully implemented. + + + + + + + A list of expiration rules, so that cache expiration can be + controlled + per layer per zoom level. Special expiration values are -1 to disable + caching and -2 to never + expire. + + This list must start with minZoom="0" and be monotonically increasing. + + + + + + + The HTTP expiration header sent to client. Can either be a value + in number of seconds + or 0 to disable the header. A special value of -1 may be used to set no-cache + headers. By + default the expiration header from the WMS backend is used. If it is not + set or not available (no request has + been forwarded to backend since startup) + then the value is set to 3600 seconds. + + This list must start with + minZoom="0" and be monotonically increasing. + + + + + + + A list of expiration rules, so that client expiration (set through + HTTP response + headers) can be controlled per layer per zoom level + + + + + + + The backend timeout is the number of seconds GWC will wait for a + backend + server to return something before closing the connection. + The default value is the global value, + alternatively 120s. + + + + + + + Whether this layer allows the clients to bypass the cache. The + default value + is the global value, alternatively false. + + + + + + + Whether this layer supports getfeatureinfo requests, which are + proxied to the WMS backend. + The default is false. + + + + + + + The QUERY_LAYERS value sent to the WMS backend server. This should + refer to one or more (comma separated) queryable layers. If omitted, + the wmsLayers will be used. + + + + + + + A list of parameter filters, meaning parameters the client may + specify that GWC + will forward to the backend. Each combination of parameters effectively + results in a new set + of tiles. + + + + + + + + + + + + + + + A list of URLs to backend servers than can render tiles for this + layer. They are used in a + round robin fashion for load balancing and automatic failover. + + The only time you can + ommit this element is if you expect the layer to be merged + with that from another source. + + + + + + + The LAYERS parameter sent to the WMS backend. + It may contain + commas, to request composites of several layers from the backend, + and be different from the name element. + + + + + + + This is the value sent to the backend server for the STYLES + parameter. + It may contain commas. + + + + + + + The gutter is a buffer around the image that is sliced away when + saving the tiles + to disk. It only applies to metatiles and is not applied if the resulting request + would + exceed the layer bounds. Note that your styles on the backend should avoid + rendering labels near the edges of + requested images. The default is zero. + + + + + + + The ERROR parameter sent to the WMS backend. The default is + application/vnd.ogc.se_xml, + the alternative is application/vnd.ogc.se_inimage + + + + + + + The VERSION parameter sent to the WMS backend. + The default is 1.1.1 + + + + + + + + + + + + + + If you wish to have this WMS layer to use + HTTP Authentication set + this to the username. You must then also + set httpPassword for it to take effect. + + + + + + + If you wish to have this WMS layer to use + HTTP Authentication set + this to the username. You must then also + set httpUsername for it to take effect. + + + + + + + + The TILED parameter sent to the WMS backend. + The default is FALSE, + you should generally not change this. + + + + + + + The TRANSPARENT parameter sent to the WMS backend. + This will result + in transparent PNGs and GIFs. The default is TRUE. + + + + + + + The BGCOLOR parameter sent to the WMS backend. + This tells the WMS + backend what color to use where the image canvas is blank. + It is specified as as an RGB string ( 0xFF0000 = + red, 0x00FF00= green, 0x0000FF = blue ) + + + + + + + The PALETTE parameter sent to the WMS backend. + This tells the + server whether it should use a palette, something that can often + speed up rendering for 8 bit images (GIF and + 8 bit PNG) because the WMS server + does not have to determine the optimal palette for the tile. + + + + + + + Fixed parameters that are appended to every request to the + backend. + For instance KEY1=value1&amp;KEY2=value2 + + + + + + + As of GWC 1.1.0 this element is deprecated. The plugin for + GeoServer will use + %GEOSERVER_DATA_DIR%\gwc , whereas users of the standalone version may specify + this in + geowebcache-servlet.xml + + + + + + + An indication of how many concurrent threads can simultaneously request tiles from this layer with + minimal thread contention. If not set defaults to 32. This property is deprecated and scheduled to + be removed in 1.4.0. + + + + + + + Defines legends information for this layer styles. + + + + + + + What WMS request mode to use, Get, the default WMS stardard mode, FormPost, a urlencoded form POST + supported by many servers, useful to cascade large requests exceeding the limits of a URL length + + + + + + + + + + + + + + + + + + Defines the location of a read only Layer generated in the ArcGIS exploded format. + This layer + must be pre-seeded, as GWC does not support seeding nor on-demand caching of such a layer, + hence its only utility + is to allow GWC to serve pre seeded layers from ArcGIS Server 9.2+. + + + + + + + Defines the configuration for a cached layer generated by ArcGIS Server in exploded format. + ArcGIS + compact cache format is not supported as it is not an open format. + For this layer to work, there must be an + accompanying file called conf.cdi next to conf.xml, that + declared the layer's spatial extent, as oposed to + conf.xml that declares the coordinate reference + system, tile origin, and cache resolutions. + Note that to serve + ArcGIS cached layers generated by ArcGIS Server 9.2 and 9.3, a conf.cdi file must + be created by hand in order to + specify the layer's bounding box, and must be like the following: + <EnvelopeN> + <XMin>...</XMin> + <YMin>...</YMin> + <XMax>...</XMax> + <YMax>...</YMax> + </EnvelopeN> + + With this + information, GWC will generate a GridSet and GridSubset definition for the layer that + match the ArcGIS tiling + scheme and Layer bounding box. + + + + + + + Whether the layer is enabled or not. Defaults to true. If the + Layer is not enabled + it will not be listed in capabilities documents, and any attempt to perform a request + against it will throw an exception. But a disabled layer CAN be seeded, as it's the + administrator's choice + whether to temporarily disable or not a Layer to perform a long seed + + + + + + + Whether the layer is included in capabilities documents. Defaults + to true. When false the layer will not be included in capabilities + documents but will otherwise work normally. + + + + + + + Is the layer transient. Defaults to false. A transient layer's + configuration will not be persisted over restart/reload. This does + not affect the persistence of tiles. + + + + + + + The name of the layer that GWC should respond to. + + + + + + + The absolute path to the location of the ArcGIS tiling scheme definition file (conf.xml) for + this layer. + For example, "/path/to/arcgis/cache/MyLayer/Layers/conf.xml" + + + + + + + Optional. The absolute path to the location of the root tiles directory. Defaults to the + "__alllayers" + directory if not set, which shall be in the same directory than the conf.xml file. + The default + layout of an ArcGIS tiling schema is such "conf.xml" and "__alllayers" are in the same directory. + This + property allows to separate the location of the tiling scheme definition (conf.xml) and the actual + directory + containing the tiles. + + + + + + + Optional. Configure whether or not the z-values (levels) should be hex-encoded or not. + Defaults to false + + + + + + + + + + + + + + + + + + The numeric part of the EPSG code, i.e. for EPSG:4326 use "4326". + + + + + + + + + + + + The name is the unique identifer of the grid set + + + + + + + A description of the gridset + + + + + + + + The extent of the grid. This should generally be the biggest + bounding box that is valid for the selected SRS. If you change the + grid bounds you must also clear all caches + related to this layer. + Coordinates must be specified in the context of the SRS for which the + grid is being + defined. + + To set tighter bounds and avoid repetitive tiles, use the gridSubset + on each layer to define the + exact bounds. + + The area does not have to be square, GeoWebCache will automatically + pad it to form a set of + suitable, rectangular grids + + + + + + + In many cases the specified extent does not result in an integer + height or width for every resolution. In these cases GeoWebCache + will modify the extent in the X and/or Y + direction. + + If you set this to true GWC will not change the top coordinate, + but expand the bottom instead. This + is convenient for systems + like WMTS, but may confuse WMS-C clients. + + + + + + + + You can either specify an array of resolutions in descending + order, + scales in ascending order OR the number of zoom levels. + + Resolutions are specified as (SRS units) / + pixel. For instance, + if your grid bounds are 180 by 180 degrees (in WGS84, this would be + either + hemissphere), and the tiles are 256 by 256 pixels, then first + resolution would be 180 degress / 256 pixels + = 0.703125 degrees / pixel. + + + + + + + You can either specify an array of resolutions in descending + order, + scales in ascending order OR the number of zoom levels. + + Scales are calculated in accordance with the + OGC WMS 1.3.0 standard. + Slightly simplified: scale = resolution / 0.00028 + + + + + + + You can either specify an array of resolutions in descending + order, + scales in ascending order OR the number of zoom levels. + + If the desired number of zoom levels is + specified GWC will try to + automatically determine a sensible set of resolutions. + + + + + + + + The value of "1 map unit" in real world meters. This value is + used + for approximate scale calculations and is usually not very accurate. + For lat/lon you should use + 40041470 + meters / 360.0 degrees = 111226.31 m/degree + + If no value is specified, it is assumed that the coordinate + system is defined in meters. + + + + + + + The size of one pixel in meters. OGC makes teh assumption this is + 0.28mm, so the default value is 0.00028. The value is used for + scale calculations and passed to the + automatically generated + OpenLayers demos. + + + + + + + If you specify scales or resolutions, you may optionally specify + a + list of scale names that, in WMTS, identify each Matrix. + + + + + + + The number of pixels every tile is in the Y-direction. The default + is 256 + + If you change this value you must also reconsidering metatiling and + clear the cache. + + + + + + + The number of pixels every tile is in the X-direction. The default + is 256 + + If you change this value you must also reconsidering metatiling and + clear the cache. + + + + + + + Indicates whether the Coordinate Reference System has lat/long - y/x axis order + + + + + + + + + + + + + + + + + + This name must match the name of the parent gridSet exactly. + + + + + + + These bounds define the subset of the extent that this + grid subset + covers. The bounds must be given in the + same spatial reference system as the extent. + + The default is the full + extent of the parent grid set. + + + + + + + If the the layer does not make sense at high zoom levels + you can + define a starting point here. + + The default is 0. + + + + + + + If the layer does not contain features that make sense to show + when + zoomed in then you can set the stop level here. + + The default is the length of the resolutions / scale + array, plus one. + + + + + + + If provided, requests for zoom levels below this threshold will + pass through to the original service. + + + + + + + If provided, requests for zoom levels above this threshold will + pass through to the original service. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Regular expression parameter filters + + + + + + + Floating point parameter filters + + + + + + + String parameter filters + + + + + + + + + + + + + The key for which the filter should be invoked. The key is case + insensitive. + + + + + + + The default value. This value is used When the client does not + specify + the parameter in the request. If you omit this element, the entire parameter + wil be omitted if the + client does not include it in request. + + + + + + + Case normalization rule for this filter. + + + + + + + The regular expression used to match against the value requested + by the client. + Care should be taken to allow as few values as possible and to make the + expression as efficient + as possible. See Java's regular expression documentation, + the dialect is similar to Perl's regular + expressions. + + + + + + + + + + + + The key for which the filter should be invoked. The key is NOT + casesensitive. + + + + + + + The default value. This value is used When the client does not + specify + the parameter in the request. If you omit this element, the entire parameter + wil be omitted if the + client does not include it in request. + + This value must be included in the list of values + + + + + + + A list of floating point numbers that are possible values. When a + client request is + received these are scanned linearly and that best match, in terms of smallest + absolute + difference, is used. + + + + + + + For a request to be accepted, the difference between the value and + the best match + must not exceed the threshold specified here. A reasonable value is the largest + difference + between two adjacent values. + + + + + + + + + + + + The key for which the filter should be invoked. The key is NOT + casesensitive. + + + + + + + The default value. This value is used When the client does not + specify + the parameter in the request. If you omit this element, the entire parameter + wil be omitted if the + client does not include it in request. + + This value must be included in the list of values + + + + + + + A list of integers that are possible values. When a + client request is + received these are scanned linearly and that best match, in terms of smallest + absolute + difference, is used. + + + + + + + For a request to be accepted, the difference between the value and + the best match + must not exceed the threshold specified here. A reasonable value is the largest + difference + between two adjacent values. + + + + + + + + + + + + The key for which the filter should be invoked. The key is NOT + casesensitive. + + + + + + + The default value. This value is used When the client does not + specify + the parameter in the request. If you omit this element, the entire parameter + wil be omitted if the + client does not include it in request. + + This value must be included in the list of values + + + + + + + Case normalization rule for this filter. + + + + + + + A list of strings that represent possible values. These are case + sensitive. + + + + + + + + + + + + The case to normalize to: NONE for no normalization, UPPER for upper case, LOWER for lower case. + + + + + + + The locale to use when normalizing the case. For instance: "en" for English, "en_CA" for Canadian English. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Format modifiers, used to request PNGs when compressing to JPEG, + overriding transparency, palette and setting the background for specifc formats. + + + + + + + + + + + + Format modifiers are keyed by the format requested by the client + accessing GWC + + + + + + + This is the format used when GWC queries the backend server + + + + + + + This overrides the value for transparent when GWC queries the + backend server. + If the response format does not support transparency you generally want this off. + + + + + + + This is the bgColor used when GWC queries the backend server. It + is a + 0x prefixed RGB value, for example 0xDDDDDD is light grey. It only applies + if transparency is off. + + + + + + + This is the palette used when GWC queries the backend server. + The + palette must be known on the backend server. It does not affect + the palette used when GWC persists the tiles. + + + + + + + This is a floating point value that describes the compression. It + has to be a postive number less than or equal to 1.0. For minimal + compression (best quality) use 1.0, smaller + values yield better + file sizes. Note that as of GWC 1.1.3 this setting only applies + to the response format + JPEG. + + + + + + + + + + + + The circular extent filter is just a dummy filter for testing + purposes + + + + + + + A filter that uses a raster to represent each tile on the grid. A + black pixel represents + one that has data which GWC will return. Other values are interpreted as meaning no + data. + This allows great refinement compared to the rectangular bounds. This particular implementation uses + WMS requests to retrieve filters for each zoomlevel, which are then stored in memory until + GWC is restarted. + + + + + + + A filter that uses a raster to represent each tile on the grid. A + black pixel represents + one that has data which GWC will return. Other values are interpreted as meaning no + data. + This allows great refinement compared to the rectangular bounds. This particular implementation uses + reads raster files from a directory, which are then stored in memory until GWC is restarted. + + + + + + + + + + + + The name of the filter. This is added to the HTTP header when a + filter triggers, + to make debugging the filters easier. This name should be unique. + + + + + + + + + + + + The name of the filter. This is added to the HTTP header when a + filter triggers, + to make debugging the filters easier. This name should be unique. + + + + + + + This is the minimum zoom level for which the filter is applied. If + the request + is for a lower zoom level, and you do not enable resample below, it will + be accepted. + + + + + + + The maximum zoom level for which to load a raster. For higher zoom + levels + the last supported level will be upsampled. The best value is a compromise + between the size of the + raster (depends on the bounds) and a zoom level + that is sufficcient to approximate the shape of the actual + data. + + + + + + + If you enable resampling and zoomStart, requests + for zoom levels + < zoomStart will be upsampled and then checked against the + zoomStart raster. This is useful if, due to + rounding errors, the raster + for zoom levels lowers than zoomStart do not contain all features. + all features at + higher zoom levels. + + + + + + + Whether to load all the rasters from zoom level 0 to zoomStop upon + initialization. + + + + + + + Setting this variable to TRUE provides visual debug output by + returning a bright + green tile where normally a transparent one would be returned. This also means + KML + hierarchies will link to these particular tiles. + + + + + + + The LAYERS value sent to the WMS backend server. This should refer + to one + or more (comma separated) layers that cover all data of interest. It can + be the data itself, or a + simpler metadata layer. + + + + + + + The STYLES value sent to the WMS backend server. This should refer + to an + exaggerated style to ensure the tiles do not cut off any features. + A sample SLD is distributed with GWC + in the resource (WEB-INF/class) directory. + + + + + + + The timeout for requesting a raster from the WMS server. The + default is two + minutes, since these can be quite large. + + + + + + + + + + + + The name of the filter. This is added to the HTTP header when a + filter triggers, + to make debugging the filters easier. This name should be unique. + + + + + + + This is the minimum zoom level for which the filter is applied. If + the request + is for a lower zoom level, and you do not enable resample below, it will + be accepted. + + + + + + + The maximum zoom level for which to load a raster. For higher zoom + levels + the last supported level will be upsampled. The best value is a compromise + between the size of the + raster (depends on the bounds) and a zoom level + that is sufficcient to approximate the shape of the actual + data. + + + + + + + If you enable resampling and zoomStart, requests + for zoom levels + < zoomStart will be upsampled and then checked against the + zoomStart raster. This is useful if, due to + rounding errors, the raster + for zoom levels lowers than zoomStart do not contain all features. + all features at + higher zoom levels. + + + + + + + Whether to load all the rasters from zoom level 0 to zoomStop upon + initialization. + + + + + + + Setting this variable to TRUE provides visual debug output by + returning a bright + green tile where normally a transparent one would be returned. This also means + KML + hierarchies will link to these particular tiles. + + + + + + + The local storage path for the raster files used to build the + filter. + This should be a local path at least readable by the user + that GWC runs as. The files should have + names as follows: + [name of filter]_EPSG_[EPSG code]_[zoom level, from 0 to zoomStop].[fileExtension] + Example: + testfilter_EPSG_4326_4.tiff + + + + + + + The extension of the raster files. Typically you would use a 1 bit + TIFF, + but PNG and GIF could also be used. + + + + + + + + + + + + The name of the filter. This is added to the HTTP header when a + filter triggers, + to make debugging the filters easier. This name should be unique. + + + + + + + + + + + + + + + + + DEPRECATED + + + + + + + + + + + + + + + + + + + + DEPRECATED + + + + + + + DEPRECATED + + + + + + + + DEPRECATED + + + + + + + + DEPRECATED + + + + + + + DEPRECATED + + + + + + + + + + + + + + + + + + + + + + A parameterized URL to a GeoRSS GML feed. If you insert + someVariable=${lastUpdate}, + ${lastUpdate} will be replaced with the timestamp of the last processed update + from this source. + + + + + + + The name of the grid set for which this feed applies. Note that + the geometries + provided by the feed must be in the spatial reference system of the grid set. + + + + + + + How often the GeoRSS source should be polled. Omitting this value + or setting it + to -1 will disable this feed. + + + + + + + If omitted the operation is "truncate" by default, alternatively + it can be "reseed". + Note that even if you specify "seed", the affected area will first be truncated + before + seeding starts, to get rid of stale data as quickly as possible. + + + + + + + By default all tiles in the affected area will be refreshed. You + may specify a + single format (use the MIME type) so that only tiles of that type are updated, + e.g. "image/png" + + + + + + + This controls the number of threads to use per format while + seeding, + provided the operation is seed or reseed. (Truncate is synchronous + and single threaded.) So if you + write 2 threads here, and the layer + supports 3 formats, and no format is specified above, then the total + number of threads will be 3x2 = 6 + + + + + + + In order to determine what tiles are affected the geometries from + the + feed are rendered onto canvases where every pixel represents a tile. + This number determines the max zoom + level for which to create such a + raster. A higher number means a higher resolution image and thus less + tiles, + but requires more memory. 11 is usually a good number. + + + + + + + + + + + + + A human friendly title for the layer + + + + + + + A description / abstract for the layer + + + + + + + Keywords that describe this layer. + + + + + + + + + + + + + The title of this service as you would like others to see it. + + + + + + + A description of this service. + + + + + + + Keywords that describe this service. + + + + + + + Contact information for the organisation and/or responsible person + for this service. + + + + + + + Any fees that relate to the use of this service. + + + + + + + Any access constraints that relate to the use of this service. + + + + + + + + + + + + + + + + + A keyword that describes this service. + + + + + + + + + + + + The name of the provider of this service (i.e. organisation name). + + + + + + + The web site for the provider of this service. + + + + + + + The contact details for this service. + + + + + + + + + + + + The contact person for this service. + + + + + + + The position within the organisation of the service contact. + + + + + + + The address type for the service contact, i.e. "Home", or "Work" + + + + + + + The street address of the service contact. + + + + + + + The city of the service contact. + + + + + + + The state/province/territory of the service contact. + + + + + + + The postal code of the service contact. + + + + + + + The country of the service contact. + + + + + + + The phone number of the service contact. + + + + + + + The fax number of the service contact. + + + + + + + The email address of the service contact. + + + + + + + + + + + Legend width. + + + + + + + Legend height. + + + + + + + Legend format. + + + + + + + URL that should be used to produce the legend get URL. + + + + + + + Complete URL that should be used as is. + + + + + + + Minimum scale denominator (inclusive) for which this legend image is valid. + + + + + + + Maximum scale denominator (exclusive) for which this legend image is valid. + + + + + + + + The style that corresponds to this legend. + + + + + + + + + + A style legend definition. + + + + + + + + Default width that should be used if no legend width is defined. + + + + + + + Default height that should be used if no legend height is defined. + + + + + + + Default format that should be used if no legend format is defined. + + + + + diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1180.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1180.xml new file mode 100644 index 000000000..2e4cec35f --- /dev/null +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1180.xml @@ -0,0 +1,283 @@ + + + 1.8.0 + 120 + + GeoWebCache + GeoWebCache is an advanced tile cache for WMS servers. It supports a large variety of protocols and + formats, including WMS-C, WMTS, KML, Google Maps and Virtual Earth. + + WFS + WMS + WMTS + GEOWEBCACHE + + + John Smith inc. + http://www.example.com/ + + John Smith + Geospatial Expert + Work + 1 Bumpy St. + Hobart + TAS + 7005 + Australia + +61 3 0000 0000 + +61 3 0000 0001 + john.smith@example.com + + + NONE + NONE + + + + + + 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 + + + + + + + + + topp: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 + + + + + https://demo.boundlessgeo.com/geoserver/topp/wms + + + + + + 20 + 20 + + + + + + raster test layer + + image/gif + image/jpeg + image/png + image/png8 + + + + EPSG:4326 + + + CanadaAtlasNonotree + + + + https://demo.boundlessgeo.com/geoserver/wms + + nasa:bluemarble + + + + + + + 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 + + + + + + + + + + + + https://demo.boundlessgeo.com/geoserver/wms + + nurc:Img_Sample,topp:states + false + 0x0066FF + + + + + 20 + 20 + 5000 + 10000 + + + 20 + 20 + + + + + + From f7941e0f8e091df05e69acc734542ebb7b130ce8 Mon Sep 17 00:00:00 2001 From: Jody Garnett Date: Mon, 1 Mar 2021 22:15:27 -0800 Subject: [PATCH 07/11] Update with explicit 1.19.0 schema --- .../geowebcache/config/geowebcache_1190.xsd | 2188 +++++++++++++++++ .../geowebcache/config/geowebcache_1190.xml | 283 +++ 2 files changed, 2471 insertions(+) create mode 100644 geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache_1190.xsd create mode 100644 geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1190.xml diff --git a/geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache_1190.xsd b/geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache_1190.xsd new file mode 100644 index 000000000..7af323826 --- /dev/null +++ b/geowebcache/core/src/main/resources/org/geowebcache/config/geowebcache_1190.xsd @@ -0,0 +1,2188 @@ + + + + + + + Wrapper element for XStream. Make sure it has the correct namespace + + + + + + + + The version number should match the XSD namespace + and the version + of GWC + + + + + + + The backend timeout is the number of seconds GWC + will wait for a + backend server to return something + before closing the connection. + + + + + + + If TRUE the implementation of WMTS service will strictly + comply with the corresponding CITE tests. + + + + + + + The name of the lock provider. For single node installs don't set the property, + for clustered implementation you can use "nio" instead (will work if your shared + file-system supports file locks) + + + + + + + Determines whether cached=false is allowed for + requests going + through the WMS service, including + converters such as Google Maps. Enabling this + disables caching for those + requests. + + + + + + + Runtime statistics run, by default, every three + second and + provide data about how many requests the + system has been serving in the past 3, 15 and 60 + seconds, as well + as aggregate numbers. + + The overhead of this system is extremely low, by + default it is enabled. + + + + + + + Service information such as you or your company's + details that + you want provided in capabilities + documents. + + + + + + + If you wish to have every connection to HTTP + backends use HTTP + Authentication set this to the + username. You must then also set httpPassword for it + to take effect. + + This + feature should be considered experimental in + 1.2.0. + + + + + + + If you wish to have every connection to HTTP + backends use HTTP + Authentication set this to the + password. You must then also set httpUsername for it + to take effect. + + This + feature should be considered experimental in + 1.2.0. + + + + + + + + These are the global format modifiers that apply to + all layers in + this file, unless the layer has + separately defined modifiers. They can be used to + avoid repeated + compression, by making image/png + backend requests before compressing to image/jpeg . + They can also be used + for special tweaks, such as + setting the background color for formats that do not + support transparency. + + + + + + + + The list of blob stores. BlobStores allow to define a storage mechanism and format, such as the legacy file system + based storage, an Amazon S3 instance with a TMS-like key structure, etc; independently of where the tiles come from + in the TileLayer configuration. + + + + + + + + + + + + + The list of grid sets provided by this + configuration. + + + + + + + + + + + + The list of WMS layers provided by this + configuration. + + + + + + + + + + + + + Parameter used for configuring full WMS requests for GeoWebCache. Setting this parameter to true enables full WMS requests. + + + + + + + + + + + + + A blob store must have a unique identifier assigned through this element, which can be referenced + by any number of TileLayer's 'blobStoreId'. + + + + + + + Defines whether the blob store is enabled (true) or disabled (false). Attempting to use + a TileLayer whose blob store is disabled will result in a runtime exception. + + + + + + + + The default attribute can only be true for one of the configured blob stores. + If no blob store is configured as the default one, then one will be created automatically + following the legacy location discovery method of looking for the GEOWEBCACHE_CACHE_DIR environment + variable, servlet context parameter, or JVM argument. + Additionally, any layer that has no blobStoreId set will default to use the default blob store, + whether it is defined in the configuration file, or created automatically using the legacy method. + So, it is allowed that none of the configured blob stores has its 'default' attribute set to true, + but it's a configuration error that more than one is set as the default one. In such case, an exception + will be thrown at application startup. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + the name of the AWS S3 bucket where to store tiles + + + + + + An optional prefix path to use as the "root folder" to store tiles at. + For example, if the bucket is bucket.gwc.example and prefix is "mycache", all tiles will be stored under + bucket.gwc.example/mycache/{layer name} instead of bucket.gwc.example/{layer name}. + + + + + + The public access key the client uses to connect to S3. + + + + + The secret key the client uses to connect to S3 + + + + + Whether S3 object access is public or private + + + + + Maximum number of concurrent HTTP connections the S3 client may use. + + + + + Whether to use HTTPS when connecting to S3 or not + + + + + Endpoint of the server, if using an alternative S3-compatible server instead of Amazon. + + + + + + The optional Windows domain name for configuring an NTLM proxy. + If you aren't using a Windows NTLM proxy, you do not need to set this field. + + + + + + + The optional Windows workstation name for configuring NTLM proxy support. + If you aren't using a Windows NTLM proxy, you do not need to set this field. + + + + + + The optional proxy host the client will connect through. + + + + + The optional proxy port the client will connect through. + + + + + The optional proxy user name to use if connecting through a proxy. + + + + + The optional proxy password to use when connecting through a proxy. + + + + + Whether gzip compression should be used. + + + + + + + + + + + + + + The identifier of the BlobStore this layer tiles shall be saved on. + If not provided, the default blob store will be used. + + + + + + + Whether the layer is enabled or not. Defaults to true. If the + Layer is not enabled + it will not be listed in capabilities documents, and any attempt to perform a request + against it will throw an exception. But a disabled layer CAN be seeded, as it's the + administrator's choice + whether to temporarily disable or not a Layer to perform a long seed + + + + + + + The name of the layer that GWC should respond to. It is equivalent + to the + value of LAYERS= in WMS requests, and can contain commas. See wmsLayers + + + + + + + Meta information like a title and description intended for human + consumption + + + + + + + List of formats to be supported. These must be known to + GeoWebCache. Legal values are + image/png, image/png8, image/png24, image/gif, image/jpeg, image/tiff, gml, + application/vnd.google-earth.kml+xml, application/vnd.google-earth.kmz+xml, + + + + + + + List of formats to be supported for GetFeatureInfo. These must be known to + GeoWebCache. Legal values are + text/plain, text/html, application/vnd.ogc.gml and application/json + + + + + + + If formatModifiers are specified on the layer the global ones will + be + ignored. Format modifiers can be used to apply special tweaks depending + on the requested format, such as + requesting image/png from the backend + and then persist that to disk. + + + + + + + DEPRECATED + + + + + + + The grid definitions contain information about the SRS, the + maximum extent for + this SRS and the bounds of your data. + + + + + + + (1.2.2) Update sources provide information about when tiles should + be expired + in GeoWebCache. As of 1.2.2, only GeoRSS is supported. + + + + + + + Request filters are applied to all requests and make it possible + to apply + special rules for certain requests. The filters themselves are written + in Java, though they can be + made configurable through XML. + + + + + + + (1.2.2) GeoWebCache can provide ETags based on the last time a + tile was modified and + thus support conditional gets. Note that most clients only refer to this tag + once the + data has expired, so set use small values for the client expiration. + This functionality is not available if + the metastore is disabled. + + + + + + + The metatiling factors used for this layer. These are used to + scale the bounding + box and height/width. With tiles that are 256 by 256 pixels, a 4 by 4 metatiled + requests + results in a 1024 by 1024 pixel image requested from the backend server. + Higher reduced the number of + repeated labels, but can overload the backend server. + + + + + + + How old the tile may be before it is refetched from the backend. + The default value is 0, which means infinite, otherwise specified in seconds. + As of GWC 1.1.0 this element is + not fully implemented. + + + + + + + A list of expiration rules, so that cache expiration can be + controlled + per layer per zoom level. Special expiration values are -1 to disable + caching and -2 to never + expire. + + This list must start with minZoom="0" and be monotonically increasing. + + + + + + + The HTTP expiration header sent to client. Can either be a value + in number of seconds + or 0 to disable the header. A special value of -1 may be used to set no-cache + headers. By + default the expiration header from the WMS backend is used. If it is not + set or not available (no request has + been forwarded to backend since startup) + then the value is set to 3600 seconds. + + This list must start with + minZoom="0" and be monotonically increasing. + + + + + + + A list of expiration rules, so that client expiration (set through + HTTP response + headers) can be controlled per layer per zoom level + + + + + + + The backend timeout is the number of seconds GWC will wait for a + backend + server to return something before closing the connection. + The default value is the global value, + alternatively 120s. + + + + + + + Whether this layer allows the clients to bypass the cache. The + default value + is the global value, alternatively false. + + + + + + + Whether this layer supports getfeatureinfo requests, which are + proxied to the WMS backend. + The default is false. + + + + + + + The QUERY_LAYERS value sent to the WMS backend server. This should + refer to one or more (comma separated) queryable layers. If omitted, + the wmsLayers will be used. + + + + + + + A list of parameter filters, meaning parameters the client may + specify that GWC + will forward to the backend. Each combination of parameters effectively + results in a new set + of tiles. + + + + + + + + + + + + + + + A list of URLs to backend servers than can render tiles for this + layer. They are used in a + round robin fashion for load balancing and automatic failover. + + The only time you can + ommit this element is if you expect the layer to be merged + with that from another source. + + + + + + + The LAYERS parameter sent to the WMS backend. + It may contain + commas, to request composites of several layers from the backend, + and be different from the name element. + + + + + + + This is the value sent to the backend server for the STYLES + parameter. + It may contain commas. + + + + + + + The gutter is a buffer around the image that is sliced away when + saving the tiles + to disk. It only applies to metatiles and is not applied if the resulting request + would + exceed the layer bounds. Note that your styles on the backend should avoid + rendering labels near the edges of + requested images. The default is zero. + + + + + + + The ERROR parameter sent to the WMS backend. The default is + application/vnd.ogc.se_xml, + the alternative is application/vnd.ogc.se_inimage + + + + + + + The VERSION parameter sent to the WMS backend. + The default is 1.1.1 + + + + + + + + + + + + + + If you wish to have this WMS layer to use + HTTP Authentication set + this to the username. You must then also + set httpPassword for it to take effect. + + + + + + + If you wish to have this WMS layer to use + HTTP Authentication set + this to the username. You must then also + set httpUsername for it to take effect. + + + + + + + + The TILED parameter sent to the WMS backend. + The default is FALSE, + you should generally not change this. + + + + + + + The TRANSPARENT parameter sent to the WMS backend. + This will result + in transparent PNGs and GIFs. The default is TRUE. + + + + + + + The BGCOLOR parameter sent to the WMS backend. + This tells the WMS + backend what color to use where the image canvas is blank. + It is specified as as an RGB string ( 0xFF0000 = + red, 0x00FF00= green, 0x0000FF = blue ) + + + + + + + The PALETTE parameter sent to the WMS backend. + This tells the + server whether it should use a palette, something that can often + speed up rendering for 8 bit images (GIF and + 8 bit PNG) because the WMS server + does not have to determine the optimal palette for the tile. + + + + + + + Fixed parameters that are appended to every request to the + backend. + For instance KEY1=value1&amp;KEY2=value2 + + + + + + + As of GWC 1.1.0 this element is deprecated. The plugin for + GeoServer will use + %GEOSERVER_DATA_DIR%\gwc , whereas users of the standalone version may specify + this in + geowebcache-servlet.xml + + + + + + + An indication of how many concurrent threads can simultaneously request tiles from this layer with + minimal thread contention. If not set defaults to 32. This property is deprecated and scheduled to + be removed in 1.4.0. + + + + + + + Defines legends information for this layer styles. + + + + + + + What WMS request mode to use, Get, the default WMS stardard mode, FormPost, a urlencoded form POST + supported by many servers, useful to cascade large requests exceeding the limits of a URL length + + + + + + + + + + + + + + + + + + Defines the location of a read only Layer generated in the ArcGIS exploded format. + This layer + must be pre-seeded, as GWC does not support seeding nor on-demand caching of such a layer, + hence its only utility + is to allow GWC to serve pre seeded layers from ArcGIS Server 9.2+. + + + + + + + Defines the configuration for a cached layer generated by ArcGIS Server in exploded format. + ArcGIS + compact cache format is not supported as it is not an open format. + For this layer to work, there must be an + accompanying file called conf.cdi next to conf.xml, that + declared the layer's spatial extent, as oposed to + conf.xml that declares the coordinate reference + system, tile origin, and cache resolutions. + Note that to serve + ArcGIS cached layers generated by ArcGIS Server 9.2 and 9.3, a conf.cdi file must + be created by hand in order to + specify the layer's bounding box, and must be like the following: + <EnvelopeN> + <XMin>...</XMin> + <YMin>...</YMin> + <XMax>...</XMax> + <YMax>...</YMax> + </EnvelopeN> + + With this + information, GWC will generate a GridSet and GridSubset definition for the layer that + match the ArcGIS tiling + scheme and Layer bounding box. + + + + + + + Whether the layer is enabled or not. Defaults to true. If the + Layer is not enabled + it will not be listed in capabilities documents, and any attempt to perform a request + against it will throw an exception. But a disabled layer CAN be seeded, as it's the + administrator's choice + whether to temporarily disable or not a Layer to perform a long seed + + + + + + + Whether the layer is included in capabilities documents. Defaults + to true. When false the layer will not be included in capabilities + documents but will otherwise work normally. + + + + + + + Is the layer transient. Defaults to false. A transient layer's + configuration will not be persisted over restart/reload. This does + not affect the persistence of tiles. + + + + + + + The name of the layer that GWC should respond to. + + + + + + + The absolute path to the location of the ArcGIS tiling scheme definition file (conf.xml) for + this layer. + For example, "/path/to/arcgis/cache/MyLayer/Layers/conf.xml" + + + + + + + Optional. The absolute path to the location of the root tiles directory. Defaults to the + "__alllayers" + directory if not set, which shall be in the same directory than the conf.xml file. + The default + layout of an ArcGIS tiling schema is such "conf.xml" and "__alllayers" are in the same directory. + This + property allows to separate the location of the tiling scheme definition (conf.xml) and the actual + directory + containing the tiles. + + + + + + + Optional. Configure whether or not the z-values (levels) should be hex-encoded or not. + Defaults to false + + + + + + + + + + + + + + + + + + The numeric part of the EPSG code, i.e. for EPSG:4326 use "4326". + + + + + + + + + + + + The name is the unique identifer of the grid set + + + + + + + A description of the gridset + + + + + + + + The extent of the grid. This should generally be the biggest + bounding box that is valid for the selected SRS. If you change the + grid bounds you must also clear all caches + related to this layer. + Coordinates must be specified in the context of the SRS for which the + grid is being + defined. + + To set tighter bounds and avoid repetitive tiles, use the gridSubset + on each layer to define the + exact bounds. + + The area does not have to be square, GeoWebCache will automatically + pad it to form a set of + suitable, rectangular grids + + + + + + + In many cases the specified extent does not result in an integer + height or width for every resolution. In these cases GeoWebCache + will modify the extent in the X and/or Y + direction. + + If you set this to true GWC will not change the top coordinate, + but expand the bottom instead. This + is convenient for systems + like WMTS, but may confuse WMS-C clients. + + + + + + + + You can either specify an array of resolutions in descending + order, + scales in ascending order OR the number of zoom levels. + + Resolutions are specified as (SRS units) / + pixel. For instance, + if your grid bounds are 180 by 180 degrees (in WGS84, this would be + either + hemissphere), and the tiles are 256 by 256 pixels, then first + resolution would be 180 degress / 256 pixels + = 0.703125 degrees / pixel. + + + + + + + You can either specify an array of resolutions in descending + order, + scales in ascending order OR the number of zoom levels. + + Scales are calculated in accordance with the + OGC WMS 1.3.0 standard. + Slightly simplified: scale = resolution / 0.00028 + + + + + + + You can either specify an array of resolutions in descending + order, + scales in ascending order OR the number of zoom levels. + + If the desired number of zoom levels is + specified GWC will try to + automatically determine a sensible set of resolutions. + + + + + + + + The value of "1 map unit" in real world meters. This value is + used + for approximate scale calculations and is usually not very accurate. + For lat/lon you should use + 40041470 + meters / 360.0 degrees = 111226.31 m/degree + + If no value is specified, it is assumed that the coordinate + system is defined in meters. + + + + + + + The size of one pixel in meters. OGC makes teh assumption this is + 0.28mm, so the default value is 0.00028. The value is used for + scale calculations and passed to the + automatically generated + OpenLayers demos. + + + + + + + If you specify scales or resolutions, you may optionally specify + a + list of scale names that, in WMTS, identify each Matrix. + + + + + + + The number of pixels every tile is in the Y-direction. The default + is 256 + + If you change this value you must also reconsidering metatiling and + clear the cache. + + + + + + + The number of pixels every tile is in the X-direction. The default + is 256 + + If you change this value you must also reconsidering metatiling and + clear the cache. + + + + + + + Indicates whether the Coordinate Reference System has lat/long - y/x axis order + + + + + + + + + + + + + + + + + + This name must match the name of the parent gridSet exactly. + + + + + + + These bounds define the subset of the extent that this + grid subset + covers. The bounds must be given in the + same spatial reference system as the extent. + + The default is the full + extent of the parent grid set. + + + + + + + If the the layer does not make sense at high zoom levels + you can + define a starting point here. + + The default is 0. + + + + + + + If the layer does not contain features that make sense to show + when + zoomed in then you can set the stop level here. + + The default is the length of the resolutions / scale + array, plus one. + + + + + + + If provided, requests for zoom levels below this threshold will + pass through to the original service. + + + + + + + If provided, requests for zoom levels above this threshold will + pass through to the original service. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Regular expression parameter filters + + + + + + + Floating point parameter filters + + + + + + + String parameter filters + + + + + + + + + + + + + The key for which the filter should be invoked. The key is case + insensitive. + + + + + + + The default value. This value is used When the client does not + specify + the parameter in the request. If you omit this element, the entire parameter + wil be omitted if the + client does not include it in request. + + + + + + + Case normalization rule for this filter. + + + + + + + The regular expression used to match against the value requested + by the client. + Care should be taken to allow as few values as possible and to make the + expression as efficient + as possible. See Java's regular expression documentation, + the dialect is similar to Perl's regular + expressions. + + + + + + + + + + + + The key for which the filter should be invoked. The key is NOT + casesensitive. + + + + + + + The default value. This value is used When the client does not + specify + the parameter in the request. If you omit this element, the entire parameter + wil be omitted if the + client does not include it in request. + + This value must be included in the list of values + + + + + + + A list of floating point numbers that are possible values. When a + client request is + received these are scanned linearly and that best match, in terms of smallest + absolute + difference, is used. + + + + + + + For a request to be accepted, the difference between the value and + the best match + must not exceed the threshold specified here. A reasonable value is the largest + difference + between two adjacent values. + + + + + + + + + + + + The key for which the filter should be invoked. The key is NOT + casesensitive. + + + + + + + The default value. This value is used When the client does not + specify + the parameter in the request. If you omit this element, the entire parameter + wil be omitted if the + client does not include it in request. + + This value must be included in the list of values + + + + + + + A list of integers that are possible values. When a + client request is + received these are scanned linearly and that best match, in terms of smallest + absolute + difference, is used. + + + + + + + For a request to be accepted, the difference between the value and + the best match + must not exceed the threshold specified here. A reasonable value is the largest + difference + between two adjacent values. + + + + + + + + + + + + The key for which the filter should be invoked. The key is NOT + casesensitive. + + + + + + + The default value. This value is used When the client does not + specify + the parameter in the request. If you omit this element, the entire parameter + wil be omitted if the + client does not include it in request. + + This value must be included in the list of values + + + + + + + Case normalization rule for this filter. + + + + + + + A list of strings that represent possible values. These are case + sensitive. + + + + + + + + + + + + The case to normalize to: NONE for no normalization, UPPER for upper case, LOWER for lower case. + + + + + + + The locale to use when normalizing the case. For instance: "en" for English, "en_CA" for Canadian English. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Format modifiers, used to request PNGs when compressing to JPEG, + overriding transparency, palette and setting the background for specifc formats. + + + + + + + + + + + + Format modifiers are keyed by the format requested by the client + accessing GWC + + + + + + + This is the format used when GWC queries the backend server + + + + + + + This overrides the value for transparent when GWC queries the + backend server. + If the response format does not support transparency you generally want this off. + + + + + + + This is the bgColor used when GWC queries the backend server. It + is a + 0x prefixed RGB value, for example 0xDDDDDD is light grey. It only applies + if transparency is off. + + + + + + + This is the palette used when GWC queries the backend server. + The + palette must be known on the backend server. It does not affect + the palette used when GWC persists the tiles. + + + + + + + This is a floating point value that describes the compression. It + has to be a postive number less than or equal to 1.0. For minimal + compression (best quality) use 1.0, smaller + values yield better + file sizes. Note that as of GWC 1.1.3 this setting only applies + to the response format + JPEG. + + + + + + + + + + + + The circular extent filter is just a dummy filter for testing + purposes + + + + + + + A filter that uses a raster to represent each tile on the grid. A + black pixel represents + one that has data which GWC will return. Other values are interpreted as meaning no + data. + This allows great refinement compared to the rectangular bounds. This particular implementation uses + WMS requests to retrieve filters for each zoomlevel, which are then stored in memory until + GWC is restarted. + + + + + + + A filter that uses a raster to represent each tile on the grid. A + black pixel represents + one that has data which GWC will return. Other values are interpreted as meaning no + data. + This allows great refinement compared to the rectangular bounds. This particular implementation uses + reads raster files from a directory, which are then stored in memory until GWC is restarted. + + + + + + + + + + + + The name of the filter. This is added to the HTTP header when a + filter triggers, + to make debugging the filters easier. This name should be unique. + + + + + + + + + + + + The name of the filter. This is added to the HTTP header when a + filter triggers, + to make debugging the filters easier. This name should be unique. + + + + + + + This is the minimum zoom level for which the filter is applied. If + the request + is for a lower zoom level, and you do not enable resample below, it will + be accepted. + + + + + + + The maximum zoom level for which to load a raster. For higher zoom + levels + the last supported level will be upsampled. The best value is a compromise + between the size of the + raster (depends on the bounds) and a zoom level + that is sufficcient to approximate the shape of the actual + data. + + + + + + + If you enable resampling and zoomStart, requests + for zoom levels + < zoomStart will be upsampled and then checked against the + zoomStart raster. This is useful if, due to + rounding errors, the raster + for zoom levels lowers than zoomStart do not contain all features. + all features at + higher zoom levels. + + + + + + + Whether to load all the rasters from zoom level 0 to zoomStop upon + initialization. + + + + + + + Setting this variable to TRUE provides visual debug output by + returning a bright + green tile where normally a transparent one would be returned. This also means + KML + hierarchies will link to these particular tiles. + + + + + + + The LAYERS value sent to the WMS backend server. This should refer + to one + or more (comma separated) layers that cover all data of interest. It can + be the data itself, or a + simpler metadata layer. + + + + + + + The STYLES value sent to the WMS backend server. This should refer + to an + exaggerated style to ensure the tiles do not cut off any features. + A sample SLD is distributed with GWC + in the resource (WEB-INF/class) directory. + + + + + + + The timeout for requesting a raster from the WMS server. The + default is two + minutes, since these can be quite large. + + + + + + + + + + + + The name of the filter. This is added to the HTTP header when a + filter triggers, + to make debugging the filters easier. This name should be unique. + + + + + + + This is the minimum zoom level for which the filter is applied. If + the request + is for a lower zoom level, and you do not enable resample below, it will + be accepted. + + + + + + + The maximum zoom level for which to load a raster. For higher zoom + levels + the last supported level will be upsampled. The best value is a compromise + between the size of the + raster (depends on the bounds) and a zoom level + that is sufficcient to approximate the shape of the actual + data. + + + + + + + If you enable resampling and zoomStart, requests + for zoom levels + < zoomStart will be upsampled and then checked against the + zoomStart raster. This is useful if, due to + rounding errors, the raster + for zoom levels lowers than zoomStart do not contain all features. + all features at + higher zoom levels. + + + + + + + Whether to load all the rasters from zoom level 0 to zoomStop upon + initialization. + + + + + + + Setting this variable to TRUE provides visual debug output by + returning a bright + green tile where normally a transparent one would be returned. This also means + KML + hierarchies will link to these particular tiles. + + + + + + + The local storage path for the raster files used to build the + filter. + This should be a local path at least readable by the user + that GWC runs as. The files should have + names as follows: + [name of filter]_EPSG_[EPSG code]_[zoom level, from 0 to zoomStop].[fileExtension] + Example: + testfilter_EPSG_4326_4.tiff + + + + + + + The extension of the raster files. Typically you would use a 1 bit + TIFF, + but PNG and GIF could also be used. + + + + + + + + + + + + The name of the filter. This is added to the HTTP header when a + filter triggers, + to make debugging the filters easier. This name should be unique. + + + + + + + + + + + + + + + + + DEPRECATED + + + + + + + + + + + + + + + + + + + + DEPRECATED + + + + + + + DEPRECATED + + + + + + + + DEPRECATED + + + + + + + + DEPRECATED + + + + + + + DEPRECATED + + + + + + + + + + + + + + + + + + + + + + A parameterized URL to a GeoRSS GML feed. If you insert + someVariable=${lastUpdate}, + ${lastUpdate} will be replaced with the timestamp of the last processed update + from this source. + + + + + + + The name of the grid set for which this feed applies. Note that + the geometries + provided by the feed must be in the spatial reference system of the grid set. + + + + + + + How often the GeoRSS source should be polled. Omitting this value + or setting it + to -1 will disable this feed. + + + + + + + If omitted the operation is "truncate" by default, alternatively + it can be "reseed". + Note that even if you specify "seed", the affected area will first be truncated + before + seeding starts, to get rid of stale data as quickly as possible. + + + + + + + By default all tiles in the affected area will be refreshed. You + may specify a + single format (use the MIME type) so that only tiles of that type are updated, + e.g. "image/png" + + + + + + + This controls the number of threads to use per format while + seeding, + provided the operation is seed or reseed. (Truncate is synchronous + and single threaded.) So if you + write 2 threads here, and the layer + supports 3 formats, and no format is specified above, then the total + number of threads will be 3x2 = 6 + + + + + + + In order to determine what tiles are affected the geometries from + the + feed are rendered onto canvases where every pixel represents a tile. + This number determines the max zoom + level for which to create such a + raster. A higher number means a higher resolution image and thus less + tiles, + but requires more memory. 11 is usually a good number. + + + + + + + + + + + + + A human friendly title for the layer + + + + + + + A description / abstract for the layer + + + + + + + Keywords that describe this layer. + + + + + + + + + + + + + The title of this service as you would like others to see it. + + + + + + + A description of this service. + + + + + + + Keywords that describe this service. + + + + + + + Contact information for the organisation and/or responsible person + for this service. + + + + + + + Any fees that relate to the use of this service. + + + + + + + Any access constraints that relate to the use of this service. + + + + + + + + + + + + + + + + + A keyword that describes this service. + + + + + + + + + + + + The name of the provider of this service (i.e. organisation name). + + + + + + + The web site for the provider of this service. + + + + + + + The contact details for this service. + + + + + + + + + + + + The contact person for this service. + + + + + + + The position within the organisation of the service contact. + + + + + + + The address type for the service contact, i.e. "Home", or "Work" + + + + + + + The street address of the service contact. + + + + + + + The city of the service contact. + + + + + + + The state/province/territory of the service contact. + + + + + + + The postal code of the service contact. + + + + + + + The country of the service contact. + + + + + + + The phone number of the service contact. + + + + + + + The fax number of the service contact. + + + + + + + The email address of the service contact. + + + + + + + + + + + Legend width. + + + + + + + Legend height. + + + + + + + Legend format. + + + + + + + URL that should be used to produce the legend get URL. + + + + + + + Complete URL that should be used as is. + + + + + + + Minimum scale denominator (inclusive) for which this legend image is valid. + + + + + + + Maximum scale denominator (exclusive) for which this legend image is valid. + + + + + + + + The style that corresponds to this legend. + + + + + + + + + + A style legend definition. + + + + + + + + Default width that should be used if no legend width is defined. + + + + + + + Default height that should be used if no legend height is defined. + + + + + + + Default format that should be used if no legend format is defined. + + + + + diff --git a/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1190.xml b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1190.xml new file mode 100644 index 000000000..285ee2be2 --- /dev/null +++ b/geowebcache/core/src/test/resources/org/geowebcache/config/geowebcache_1190.xml @@ -0,0 +1,283 @@ + + + 1.8.0 + 120 + + GeoWebCache + GeoWebCache is an advanced tile cache for WMS servers. It supports a large variety of protocols and + formats, including WMS-C, WMTS, KML, Google Maps and Virtual Earth. + + WFS + WMS + WMTS + GEOWEBCACHE + + + John Smith inc. + http://www.example.com/ + + John Smith + Geospatial Expert + Work + 1 Bumpy St. + Hobart + TAS + 7005 + Australia + +61 3 0000 0000 + +61 3 0000 0001 + john.smith@example.com + + + NONE + NONE + + + + + + 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 + + + + + + + + + topp: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 + + + + + https://demo.boundlessgeo.com/geoserver/topp/wms + + + + + + 20 + 20 + + + + + + raster test layer + + image/gif + image/jpeg + image/png + image/png8 + + + + EPSG:4326 + + + CanadaAtlasNonotree + + + + https://demo.boundlessgeo.com/geoserver/wms + + nasa:bluemarble + + + + + + + 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 + + + + + + + + + + + + https://demo.boundlessgeo.com/geoserver/wms + + nurc:Img_Sample,topp:states + false + 0x0066FF + + + + + 20 + 20 + 5000 + 10000 + + + 20 + 20 + + + + + + From c2bd9fc48514fe50a81e75b02316b7fa6b7bd561 Mon Sep 17 00:00:00 2001 From: Jody Garnett Date: Mon, 1 Mar 2021 22:19:39 -0800 Subject: [PATCH 08/11] Updated version to 1.19-SNAPSHOT --- geowebcache/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geowebcache/pom.xml b/geowebcache/pom.xml index 1b56e0a1e..994e55c34 100644 --- a/geowebcache/pom.xml +++ b/geowebcache/pom.xml @@ -10,7 +10,7 @@ http://geowebcache.org - 25-SNAPSHOT + 25-SNAPSHOT-SNAPSHOT 1.18.1 1.1.20 5.1.20.RELEASE From 97f50d51891b851fc81e0e9d2ce05e0f334cdedb Mon Sep 17 00:00:00 2001 From: Jody Garnett Date: Tue, 2 Mar 2021 09:17:55 -0800 Subject: [PATCH 09/11] Updated version to 1.20-SNAPSHOT --- documentation/en/user/source/conf.py | 4 ++-- geowebcache/arcgiscache/pom.xml | 2 +- geowebcache/azureblob/pom.xml | 2 +- geowebcache/core/pom.xml | 2 +- geowebcache/diskquota/bdb/pom.xml | 2 +- geowebcache/diskquota/core/pom.xml | 2 +- geowebcache/diskquota/jdbc/pom.xml | 2 +- geowebcache/diskquota/pom.xml | 2 +- geowebcache/distributed/pom.xml | 2 +- geowebcache/georss/pom.xml | 2 +- geowebcache/gmaps/pom.xml | 2 +- geowebcache/kml/pom.xml | 2 +- geowebcache/pom.xml | 6 +++--- geowebcache/release/doc.xml | 2 +- geowebcache/release/src.xml | 2 +- geowebcache/rest/pom.xml | 2 +- geowebcache/s3storage/pom.xml | 2 +- geowebcache/sqlite/pom.xml | 2 +- geowebcache/swiftblob/pom.xml | 2 +- geowebcache/tms/pom.xml | 2 +- geowebcache/ve/pom.xml | 2 +- geowebcache/web/pom.xml | 2 +- geowebcache/wms/pom.xml | 2 +- geowebcache/wmts/pom.xml | 2 +- 24 files changed, 27 insertions(+), 27 deletions(-) diff --git a/documentation/en/user/source/conf.py b/documentation/en/user/source/conf.py index 81e88a867..9d533723d 100644 --- a/documentation/en/user/source/conf.py +++ b/documentation/en/user/source/conf.py @@ -45,9 +45,9 @@ # other places throughout the built documents. # # The short X.Y version. -version = '1.19' +version = '1.20' # The full version, including alpha/beta/rc tags. -release = '1.19.x' +release = '1.20-SNAPSHOT' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: diff --git a/geowebcache/arcgiscache/pom.xml b/geowebcache/arcgiscache/pom.xml index d80415252..2b441e353 100644 --- a/geowebcache/arcgiscache/pom.xml +++ b/geowebcache/arcgiscache/pom.xml @@ -5,7 +5,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-arcgiscache diff --git a/geowebcache/azureblob/pom.xml b/geowebcache/azureblob/pom.xml index 5e4b79236..abc0f40dc 100644 --- a/geowebcache/azureblob/pom.xml +++ b/geowebcache/azureblob/pom.xml @@ -5,7 +5,7 @@ geowebcache org.geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT 4.0.0 diff --git a/geowebcache/core/pom.xml b/geowebcache/core/pom.xml index 0d6250e8a..4117a216f 100644 --- a/geowebcache/core/pom.xml +++ b/geowebcache/core/pom.xml @@ -6,7 +6,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-core diff --git a/geowebcache/diskquota/bdb/pom.xml b/geowebcache/diskquota/bdb/pom.xml index cbc9ff8eb..9f650ad06 100644 --- a/geowebcache/diskquota/bdb/pom.xml +++ b/geowebcache/diskquota/bdb/pom.xml @@ -5,7 +5,7 @@ org.geowebcache gwc-diskquota - 1.19-SNAPSHOT + 1.20-SNAPSHOT gwc-diskquota-bdb jar diff --git a/geowebcache/diskquota/core/pom.xml b/geowebcache/diskquota/core/pom.xml index 311c97fef..81cefa0d4 100644 --- a/geowebcache/diskquota/core/pom.xml +++ b/geowebcache/diskquota/core/pom.xml @@ -5,7 +5,7 @@ org.geowebcache gwc-diskquota - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-diskquota-core diff --git a/geowebcache/diskquota/jdbc/pom.xml b/geowebcache/diskquota/jdbc/pom.xml index f737bc00b..22fb1126e 100644 --- a/geowebcache/diskquota/jdbc/pom.xml +++ b/geowebcache/diskquota/jdbc/pom.xml @@ -6,7 +6,7 @@ org.geowebcache gwc-diskquota - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-diskquota-jdbc diff --git a/geowebcache/diskquota/pom.xml b/geowebcache/diskquota/pom.xml index 610ae26db..b52d02a2e 100644 --- a/geowebcache/diskquota/pom.xml +++ b/geowebcache/diskquota/pom.xml @@ -5,7 +5,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-diskquota diff --git a/geowebcache/distributed/pom.xml b/geowebcache/distributed/pom.xml index 9d4223128..98b289d94 100644 --- a/geowebcache/distributed/pom.xml +++ b/geowebcache/distributed/pom.xml @@ -5,7 +5,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-distributed diff --git a/geowebcache/georss/pom.xml b/geowebcache/georss/pom.xml index c2a7a3ca9..fb6e3d97d 100644 --- a/geowebcache/georss/pom.xml +++ b/geowebcache/georss/pom.xml @@ -5,7 +5,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-georss diff --git a/geowebcache/gmaps/pom.xml b/geowebcache/gmaps/pom.xml index 4cf842578..944ab46a2 100644 --- a/geowebcache/gmaps/pom.xml +++ b/geowebcache/gmaps/pom.xml @@ -6,7 +6,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-gmaps diff --git a/geowebcache/kml/pom.xml b/geowebcache/kml/pom.xml index 82d39ff2f..0facadc87 100644 --- a/geowebcache/kml/pom.xml +++ b/geowebcache/kml/pom.xml @@ -6,7 +6,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-kml diff --git a/geowebcache/pom.xml b/geowebcache/pom.xml index 994e55c34..9b664a0f0 100644 --- a/geowebcache/pom.xml +++ b/geowebcache/pom.xml @@ -5,12 +5,12 @@ org.geowebcache geowebcache pom - 1.19-SNAPSHOT + 1.20-SNAPSHOT geowebcache http://geowebcache.org - 25-SNAPSHOT-SNAPSHOT + 26-SNAPSHOT 1.18.1 1.1.20 5.1.20.RELEASE @@ -628,7 +628,7 @@ release/war.xml release/doc.xml - geowebcache-1.19-SNAPSHOT + geowebcache-1.20-SNAPSHOT ${project.build.directory}/release diff --git a/geowebcache/release/doc.xml b/geowebcache/release/doc.xml index c3983ba17..0b0413faf 100644 --- a/geowebcache/release/doc.xml +++ b/geowebcache/release/doc.xml @@ -7,7 +7,7 @@ ../documentation/en/user/build/html - geowebcache-1.19-SNAPSHOT/doc + geowebcache-1.20-SNAPSHOT/doc **/* diff --git a/geowebcache/release/src.xml b/geowebcache/release/src.xml index 82df5b0b0..ad7fe788e 100644 --- a/geowebcache/release/src.xml +++ b/geowebcache/release/src.xml @@ -7,7 +7,7 @@ ${project.basedir} - geowebcache-1.19-SNAPSHOT/ + geowebcache-1.20-SNAPSHOT/ true **/${project.build.directory}/** diff --git a/geowebcache/rest/pom.xml b/geowebcache/rest/pom.xml index 2e9fec2fb..178b106cf 100644 --- a/geowebcache/rest/pom.xml +++ b/geowebcache/rest/pom.xml @@ -5,7 +5,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-rest diff --git a/geowebcache/s3storage/pom.xml b/geowebcache/s3storage/pom.xml index a79db1381..ec0a4b39c 100644 --- a/geowebcache/s3storage/pom.xml +++ b/geowebcache/s3storage/pom.xml @@ -5,7 +5,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-aws-s3 diff --git a/geowebcache/sqlite/pom.xml b/geowebcache/sqlite/pom.xml index d4e8cf9b6..c5c0e3522 100644 --- a/geowebcache/sqlite/pom.xml +++ b/geowebcache/sqlite/pom.xml @@ -4,7 +4,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-sqlite diff --git a/geowebcache/swiftblob/pom.xml b/geowebcache/swiftblob/pom.xml index 861334319..c54d46596 100644 --- a/geowebcache/swiftblob/pom.xml +++ b/geowebcache/swiftblob/pom.xml @@ -6,7 +6,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache diff --git a/geowebcache/tms/pom.xml b/geowebcache/tms/pom.xml index da2cf6d87..78de6befd 100644 --- a/geowebcache/tms/pom.xml +++ b/geowebcache/tms/pom.xml @@ -6,7 +6,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-tms diff --git a/geowebcache/ve/pom.xml b/geowebcache/ve/pom.xml index 43954d919..c2c3b4f3e 100644 --- a/geowebcache/ve/pom.xml +++ b/geowebcache/ve/pom.xml @@ -6,7 +6,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-ve diff --git a/geowebcache/web/pom.xml b/geowebcache/web/pom.xml index 9f5752e5e..eb4022ea2 100644 --- a/geowebcache/web/pom.xml +++ b/geowebcache/web/pom.xml @@ -5,7 +5,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-web diff --git a/geowebcache/wms/pom.xml b/geowebcache/wms/pom.xml index 215149980..dbc1ccb48 100644 --- a/geowebcache/wms/pom.xml +++ b/geowebcache/wms/pom.xml @@ -6,7 +6,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-wms diff --git a/geowebcache/wmts/pom.xml b/geowebcache/wmts/pom.xml index bdb268da8..cb72f1a47 100644 --- a/geowebcache/wmts/pom.xml +++ b/geowebcache/wmts/pom.xml @@ -6,7 +6,7 @@ org.geowebcache geowebcache - 1.19-SNAPSHOT + 1.20-SNAPSHOT org.geowebcache gwc-wmts From 21564108d6f1386246a9a9febeed3e63e7a963d9 Mon Sep 17 00:00:00 2001 From: Jody Garnett Date: Mon, 1 Mar 2021 23:19:26 -0800 Subject: [PATCH 10/11] Updated release notes for 1.19-RC --- RELEASE_NOTES.txt | 114 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 09b6f76ef..633cffc1a 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,3 +1,56 @@ +GeoWebCache 1.19-RC (2021-03-01) +-------------------------------- + +Release candidate for 1.19.x series. + +Improvements: ++++++++++++++ +- Introduce 512px tiles as possible alternative for the default gridsets +- Update to JTS 1.18.1 +- Update JAIEXT 1.1.20 +- Update Spring to v5.1.20.RELEASE and Spring security to 5.1.13.RELEASE + +Internal: ++++++++++ +- Enabled PMD checks on tests, Switch JUnit tests from v3 to v4 +- Use geotools factory for http connections +- Cleaning up unnecessary casts +- Cleaning up unecessary type specifications +- Repalce iterator loops with enhanced for loops +- Use isEmpty instead of size() == 0 +- Use try-with-resources replacing try/finally +- Replace use of Vector/Hashtable with ArrayList/HashMap + +GeoWebCache 1.18.2 (2021-01-18) +------------------------------- + +Stable release of the 1.18.x series + +Improvements: ++++++++++++++ +- In the seeding form, order threads count numerically instead of lexicographically +- Bounding box toString scales poorly due to internal synchornization of NumberFormat +- Creating a new UUID for each temp file scales poorly, reduce the calculation of those to a lower number, appending an atomic integer at the end +- Upgrading to jaiext 1.1.18, better BufferedImageAdapter (also improves scalability) + +GeoWebCache 1.18.1 (2020-11-18) +------------------------------- + +Stable release of the 1.18.x series + +Improvements: ++++++++++++++ +- Allow the S3 storage to work against Cohesity too, in addition to AWS S3 and Minio + +GeoWebCache 1.18.0 (2020-09-21) +------------------------------- + +First stable release of the 1.18.x series. + +Fixes: +++++++ +- Fixed documentation scripts branch reference + GeoWebCache 1.18.0 ------------------- @@ -6,6 +59,67 @@ Improvements: - Use of repo.osgeo.org +GeoWebCache 1.18-RC (2020-09-01) +-------------------------------- + +Release candidate. + +Improvements: + +* Include the default ServiceInfo into the WMS & WMTS GetCapabilities document +* Use of JTS 1.17.1 + +GeoWebCache 1.17.4 (2020-12-20) +------------------------------- + +Improvements: ++++++++++++++ +- Allow the S3 storage to work against Cohesity too. + +GeoWebCache 1.17.3 (2020-09-25) +------------------------------- + +First maintenance release of the 1.17.x series + +Improvements: ++++++++++++++ +- Upgraded JTS to 1.17.0 +- Upgraded JAI-EXT to 1.1.17 + +Fixes: +++++++ +- Dispose image reader in MetaTile (improves stability downstreams in GeoServer, when using GDAL image readers) + +GeoWebCache 1.17.2 (2020-07-19) +------------------------------- + +Stable release of 1.17.x series. + +Improvements: ++++++++++++++ +- Upgrade to PostgreSQL driver 42.2.14 +- Upgrade to jai-ext 1.1.15 +- Upgrade to spring-framework to 5.1.16 and spring-security to 5.1.11 + +GeoWebCache 1.17.1 (2020-06-01) +------------------------------- + +Stable release of 1.17.x series. + +Improvements: ++++++++++++++ +- Upgrade to GeoTools 23.1. + +GeoWebCache 1.17.0 (2020-04-14) +------------------------------- + +Initial release of 1.17.x series. + +Improvements: ++++++++++++++ +- Use of repo.osgeo.org +- Upgraded jai-ext to 1.1.14 + GeoWebCache 1.17-RC (2020-03-11) -------------------------------- From 50b202fdb0875cd65c4a99dae813291a80c684ea Mon Sep 17 00:00:00 2001 From: Andrea Aime Date: Mon, 15 Mar 2021 12:01:43 +0100 Subject: [PATCH 11/11] Fixing deprecated API, work in progress! --- ...nLayerConformanceWithArcGisLayersTest.java | 2 +- .../GeoWebCacheDispatcherTest.java | 2 +- .../GeoWebCacheExtensionsTest.java | 2 +- .../geowebcache/MockExtensionRuleTest.java | 2 +- .../file/FileBlobStoreComformanceTest.java | 2 +- .../config/BlobStoreConfigurationTest.java | 169 +++++++++--------- .../geowebcache/config/ConfigurationTest.java | 33 ++-- ...tsConfigurationGridsetConformanceTest.java | 2 +- .../config/GridSetConfigurationTest.java | 2 +- .../config/LayerConfigurationTest.java | 2 +- .../config/ServerConfigurationTest.java | 2 +- .../XMLConfigurationConstructorsTest.java | 2 +- .../XMLConfigurationLayerConformanceTest.java | 2 +- .../config/XMLConfigurationTest.java | 2 +- .../config/XMLConfigurationXSchemaTest.java | 44 ++--- .../config/legends/LegendInfoBuilderTest.java | 2 +- .../parameters/FloatParameterFilterTest.java | 2 +- .../IntegerParameterFilterTest.java | 2 +- .../parameters/ParametersUtilsTest.java | 2 +- .../parameters/RegexParameterFilterTest.java | 2 +- .../parameters/StringParameterFilterTest.java | 2 +- .../geowebcache/grid/DefaultGridSetsTest.java | 2 +- .../geowebcache/grid/GridSetBrokerTest.java | 2 +- .../org/geowebcache/grid/GridSetTest.java | 2 +- .../geowebcache/layer/wms/TileLayerTest.java | 2 +- .../geowebcache/layer/wms/WMSLayerTest.java | 2 +- .../seed/TruncateBboxRequestTest.java | 2 +- .../storage/AbstractBlobStoreTest.java | 2 +- .../storage/BlobStoreSuitabilityTest.java | 2 +- .../storage/CompositeBlobStoreTest.java | 2 +- .../storage/TransientCacheTest.java | 2 +- .../org/geowebcache/util/FileUtilsTest.java | 2 +- .../diskquota/BDBQuotaStoreTest.java | 2 +- .../diskquota/jdbc/JDBCQuotaStoreTest.java | 2 +- .../rest/service/FormServiceTest.java | 2 +- .../s3/OnlineS3BlobStoreIntegrationTest.java | 2 +- .../s3/S3BlobStoreConfigSerializeTest.java | 2 +- .../geowebcache/sqlite/FileManagerTest.java | 2 +- .../sqlite/MbtilesBlobStoreTest.java | 2 +- .../geowebcache/sqlite/MbtilesPBFTest.java | 2 +- .../sqlite/OperationsRestTest.java | 2 +- .../sqlite/SqliteBlobStoreTest.java | 2 +- .../sqlite/SqliteConnectionManagerTest.java | 2 +- .../geowebcache/swift/SwiftBlobStoreTest.java | 2 +- .../org/geowebcache/swift/SwiftTileTest.java | 2 +- .../jetty/RestIntegrationTest.java | 2 +- .../wms/GetCapabilitiesConfigurationTest.java | 2 +- ...esGridSetConfigurationConformanceTest.java | 2 +- ...tiesLayerConfigurationConformanceTest.java | 2 +- .../service/wms/WMSGetCapabilitiesTest.java | 2 +- .../service/wms/WMSServiceTest.java | 2 +- 51 files changed, 165 insertions(+), 177 deletions(-) diff --git a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/XMLConfigurationLayerConformanceWithArcGisLayersTest.java b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/XMLConfigurationLayerConformanceWithArcGisLayersTest.java index 127fc7e1d..d2cd971fe 100644 --- a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/XMLConfigurationLayerConformanceWithArcGisLayersTest.java +++ b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/XMLConfigurationLayerConformanceWithArcGisLayersTest.java @@ -16,7 +16,7 @@ import static org.geowebcache.util.TestUtils.isPresent; import static org.hamcrest.Matchers.hasProperty; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.io.File; import java.io.IOException; diff --git a/geowebcache/core/src/test/java/org/geowebcache/GeoWebCacheDispatcherTest.java b/geowebcache/core/src/test/java/org/geowebcache/GeoWebCacheDispatcherTest.java index baa52a11e..17f657ce4 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/GeoWebCacheDispatcherTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/GeoWebCacheDispatcherTest.java @@ -15,7 +15,7 @@ package org.geowebcache; import static org.geowebcache.TestHelpers.hasStatus; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.util.Collections; import javax.servlet.http.HttpServletResponse; diff --git a/geowebcache/core/src/test/java/org/geowebcache/GeoWebCacheExtensionsTest.java b/geowebcache/core/src/test/java/org/geowebcache/GeoWebCacheExtensionsTest.java index 22b22a398..c2f96e917 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/GeoWebCacheExtensionsTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/GeoWebCacheExtensionsTest.java @@ -4,12 +4,12 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import java.util.HashMap; diff --git a/geowebcache/core/src/test/java/org/geowebcache/MockExtensionRuleTest.java b/geowebcache/core/src/test/java/org/geowebcache/MockExtensionRuleTest.java index 02b6bb7b5..e7803203a 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/MockExtensionRuleTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/MockExtensionRuleTest.java @@ -14,11 +14,11 @@ */ package org.geowebcache; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.sameInstance; -import static org.junit.Assert.assertThat; import java.util.Collection; import org.hamcrest.Matchers; diff --git a/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/FileBlobStoreComformanceTest.java b/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/FileBlobStoreComformanceTest.java index 5a8cc206e..0eb80143a 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/FileBlobStoreComformanceTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/blobstore/file/FileBlobStoreComformanceTest.java @@ -14,9 +14,9 @@ */ package org.geowebcache.blobstore.file; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/BlobStoreConfigurationTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/BlobStoreConfigurationTest.java index 45bbacbd7..3d32daa9b 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/BlobStoreConfigurationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/BlobStoreConfigurationTest.java @@ -19,13 +19,14 @@ import static org.easymock.EasyMock.verify; import static org.geowebcache.util.TestUtils.isPresent; import static org.geowebcache.util.TestUtils.notPresent; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.arrayContainingInAnyOrder; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasProperty; -import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.sameInstance; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertThrows; import java.io.IOException; import java.util.Collection; @@ -36,6 +37,7 @@ import org.easymock.IMocksControl; import org.geowebcache.GeoWebCacheException; import org.geowebcache.storage.UnsuitableStorageException; +import org.hamcrest.CoreMatchers; import org.junit.Test; public abstract class BlobStoreConfigurationTest @@ -87,10 +89,8 @@ public void testRollBackOnUnsuitableStorageExceptionInAddHandler() throws Except expectLastCall().andThrow(new UnsuitableStorageException("TEST")); EasyMock.replay(listener); config.addBlobStoreListener(listener); - exception.expect(instanceOf(ConfigurationPersistenceException.class)); - exception.expectCause(instanceOf(UnsuitableStorageException.class)); try { - config.addBlobStore(info); + assertThrows(ConfigurationPersistenceException.class, () -> config.addBlobStore(info)); } finally { verify(listener); assertThat(config.getBlobStore("test"), notPresent()); @@ -109,10 +109,11 @@ public void testRollBackOnUnsuitableStorageExceptionInModifyHandler() throws Exc EasyMock.replay(listener); config.addBlobStoreListener(listener); config.addBlobStore(info1); - exception.expect(instanceOf(ConfigurationPersistenceException.class)); - exception.expectCause(instanceOf(UnsuitableStorageException.class)); try { config.modifyBlobStore(info2); + } catch (ConfigurationPersistenceException expected) { + assertThat( + expected.getCause(), CoreMatchers.instanceOf(UnsuitableStorageException.class)); } finally { verify(listener); assertThat(config.getBlobStore("test"), isPresent(infoEquals(info1))); @@ -142,10 +143,10 @@ public void testRollBackOnSupressedUnsuitableStorageExceptionInModifyHandler() config.addBlobStoreListener(listener1); config.addBlobStoreListener(listener2); config.addBlobStore(info1); - exception.expect(instanceOf(ConfigurationPersistenceException.class)); - exception.expectCause(instanceOf(IOException.class)); try { config.modifyBlobStore(info2); + } catch (ConfigurationPersistenceException expected) { + assertThat(expected.getCause(), CoreMatchers.instanceOf(IOException.class)); } finally { control.verify(); assertThat(config.getBlobStore("test"), isPresent(infoEquals(info1))); @@ -168,10 +169,10 @@ public void testRollBackOnSupressedUnsuitableStorageExceptionInAddHandler() thro control.replay(); config.addBlobStoreListener(listener1); config.addBlobStoreListener(listener2); - exception.expect(instanceOf(ConfigurationPersistenceException.class)); - exception.expectCause(instanceOf(IOException.class)); try { config.addBlobStore(info1); + } catch (ConfigurationPersistenceException expected) { + assertThat(expected.getCause(), CoreMatchers.instanceOf(IOException.class)); } finally { control.verify(); assertThat(config.getBlobStore("test"), notPresent()); @@ -464,12 +465,11 @@ public void testExceptionInAddListenerIsWrapped() throws Exception { EasyMock.expectLastCall().andThrow(ex); EasyMock.replay(listener); - exception.expect( - allOf( - instanceOf(ConfigurationPersistenceException.class), - hasProperty("cause", sameInstance(ex)))); - - this.addInfo(this.config, goodInfo); + try { + this.addInfo(this.config, goodInfo); + } catch (ConfigurationPersistenceException expected) { + assertSame(ex, ex.getCause()); + } } @Test @@ -537,21 +537,22 @@ public void testExceptionInAddListenerRecordsSuppressedExceptions() throws Excep EasyMock.replay(listener1, listener2); - exception.expect( - allOf( - instanceOf(ConfigurationPersistenceException.class), - hasProperty( - "cause", - allOf( - sameInstance(ex2), - hasProperty( - "suppressed", - arrayContainingInAnyOrder(sameInstance(ex1))))))); - - this.addInfo(this.config, goodInfo); + try { + this.addInfo(this.config, goodInfo); + } catch (ConfigurationPersistenceException expected) { + assertThat( + expected, + hasProperty( + "cause", + allOf( + sameInstance(ex2), + hasProperty( + "suppressed", + arrayContainingInAnyOrder(sameInstance(ex1)))))); + } } - // Exceptions during modify handlers + // Exceptions during modify handlers @Test public void testExceptionInModifyListenerIsWrapped() throws Exception { BlobStoreConfigurationListener listener = @@ -564,12 +565,11 @@ public void testExceptionInModifyListenerIsWrapped() throws Exception { EasyMock.expectLastCall().andThrow(ex); EasyMock.replay(listener); - exception.expect( - allOf( - instanceOf(ConfigurationPersistenceException.class), - hasProperty("cause", sameInstance(ex)))); - - this.modifyInfo(this.config, goodInfo); + try { + this.modifyInfo(this.config, goodInfo); + } catch (ConfigurationPersistenceException expected) { + assertThat(expected, hasProperty("cause", sameInstance(ex))); + } } /** @@ -650,18 +650,19 @@ public void testExceptionInModifyListenerRecordsSuppressedExceptions() throws Ex EasyMock.replay(listener1, listener2); - exception.expect( - allOf( - instanceOf(ConfigurationPersistenceException.class), - hasProperty( - "cause", - allOf( - sameInstance(ex2), - hasProperty( - "suppressed", - arrayContainingInAnyOrder(sameInstance(ex1))))))); - - this.modifyInfo(this.config, goodInfo); + try { + this.modifyInfo(this.config, goodInfo); + } catch (ConfigurationPersistenceException expected) { + assertThat( + expected, + hasProperty( + "cause", + allOf( + sameInstance(ex2), + hasProperty( + "suppressed", + arrayContainingInAnyOrder(sameInstance(ex1)))))); + } } // Exceptions during rename handlers @@ -689,12 +690,11 @@ public void testExceptionInRenameListenerIsWrapped() throws Exception { EasyMock.expectLastCall().andThrow(ex); EasyMock.replay(listener); - exception.expect( - allOf( - instanceOf(ConfigurationPersistenceException.class), - hasProperty("cause", sameInstance(ex)))); - - this.renameInfo(this.config, "test", "test2"); + try { + this.renameInfo(this.config, "test", "test2"); + } catch (ConfigurationPersistenceException expected) { + assertThat(expected, hasProperty("cause", sameInstance(ex))); + } } @Test @@ -763,18 +763,19 @@ public void testExceptionInRenameListenerRecordsSuppressedExceptions() throws Ex EasyMock.replay(listener1, listener2); - exception.expect( - allOf( - instanceOf(ConfigurationPersistenceException.class), - hasProperty( - "cause", - allOf( - sameInstance(ex2), - hasProperty( - "suppressed", - arrayContainingInAnyOrder(sameInstance(ex1))))))); - - this.renameInfo(this.config, "test", "test2"); + try { + this.renameInfo(this.config, "test", "test2"); + } catch (ConfigurationPersistenceException expected) { + assertThat( + expected, + hasProperty( + "cause", + allOf( + sameInstance(ex2), + hasProperty( + "suppressed", + arrayContainingInAnyOrder(sameInstance(ex1)))))); + } } // Exceptions during remove handlers @@ -802,12 +803,11 @@ public void testExceptionInRemoveListenerIsWrapped() throws Exception { EasyMock.expectLastCall().andThrow(ex); EasyMock.replay(listener); - exception.expect( - allOf( - instanceOf(ConfigurationPersistenceException.class), - hasProperty("cause", sameInstance(ex)))); - - this.removeInfo(this.config, "test"); + try { + this.removeInfo(this.config, "test"); + } catch (ConfigurationPersistenceException expected) { + assertThat(expected, hasProperty("cause", sameInstance(ex))); + } } @Test @@ -876,17 +876,18 @@ public void testExceptionInRemoveListenerRecordsSuppressedExceptions() throws Ex EasyMock.replay(listener1, listener2); - exception.expect( - allOf( - instanceOf(ConfigurationPersistenceException.class), - hasProperty( - "cause", - allOf( - sameInstance(ex2), - hasProperty( - "suppressed", - arrayContainingInAnyOrder(sameInstance(ex1))))))); - - this.removeInfo(this.config, "test"); + try { + this.removeInfo(this.config, "test"); + } catch (ConfigurationPersistenceException expected) { + assertThat( + expected, + hasProperty( + "cause", + allOf( + sameInstance(ex2), + hasProperty( + "suppressed", + arrayContainingInAnyOrder(sameInstance(ex1)))))); + } } } diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/ConfigurationTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/ConfigurationTest.java index 10bcdc840..502500afa 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/ConfigurationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/ConfigurationTest.java @@ -18,11 +18,11 @@ import static org.geowebcache.util.TestUtils.isPresent; import static org.geowebcache.util.TestUtils.notPresent; import static org.geowebcache.util.TestUtils.requirePresent; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertThrows; import java.util.ArrayList; import java.util.Collection; @@ -37,16 +37,12 @@ import org.hamcrest.Matcher; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public abstract class ConfigurationTest { protected C config; - @Rule public ExpectedException exception = ExpectedException.none(); - @Before public void setUpTestUnit() throws Exception { config = getConfig(); @@ -82,11 +78,7 @@ public void testDoubleAddException() throws Exception { I doubleGridSet = getGoodInfo("test", 2); assertThat("Invalid test", goodGridSet, not(infoEquals(doubleGridSet))); addInfo(config, goodGridSet); - exception.expect( - instanceOf( - IllegalArgumentException - .class)); // May want to change to something more specific. - addInfo(config, doubleGridSet); + assertThrows(IllegalArgumentException.class, () -> addInfo(config, doubleGridSet)); } @Test @@ -107,9 +99,7 @@ public void testDoubleAddNoChange() throws Exception { @Test public void testAddBadInfoException() throws Exception { I badGridSet = getBadInfo("test", 1); - exception.expect( - IllegalArgumentException.class); // May want to change to something more specific. - addInfo(config, badGridSet); + assertThrows(IllegalArgumentException.class, () -> addInfo(config, badGridSet)); } @Test @@ -154,8 +144,8 @@ public void testGetNotExists() throws Exception { @Test public void testRemoveNotExists() throws Exception { - exception.expect(NoSuchElementException.class); - removeInfo(config, "GridSetThatDoesntExist"); + assertThrows( + NoSuchElementException.class, () -> removeInfo(config, "GridSetThatDoesntExist")); } @Test @@ -173,9 +163,7 @@ public void testModifyBadGridSetException() throws Exception { testAdd(); I badGridSet = getBadInfo("test", 2); - exception.expect(IllegalArgumentException.class); // Could be more specific - - modifyInfo(config, badGridSet); + assertThrows(IllegalArgumentException.class, () -> modifyInfo(config, badGridSet)); } @Test @@ -211,8 +199,7 @@ public void testPersistModify() throws Exception { @Test public void testModifyNotExistsExcpetion() throws Exception { I goodGridSet = getGoodInfo("test", 2); - exception.expect(NoSuchElementException.class); - modifyInfo(config, goodGridSet); + assertThrows(NoSuchElementException.class, () -> modifyInfo(config, goodGridSet)); } @Test @@ -303,10 +290,10 @@ public void testNoChangeOnPersistExceptionOnAdd() throws Exception { // Force a failure failNextWrite(); - exception.expect(ConfigurationPersistenceException.class); try { - addInfo(config, goodGridSet); + assertThrows( + ConfigurationPersistenceException.class, () -> addInfo(config, goodGridSet)); } finally { // Should be unchanged Optional retrieved = getInfo(config, "test"); diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/DefaultGridsetsConfigurationGridsetConformanceTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/DefaultGridsetsConfigurationGridsetConformanceTest.java index da30357b0..e20053eac 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/DefaultGridsetsConfigurationGridsetConformanceTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/DefaultGridsetsConfigurationGridsetConformanceTest.java @@ -14,8 +14,8 @@ */ package org.geowebcache.config; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; import org.geowebcache.grid.GridSet; import org.hamcrest.CustomMatcher; diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/GridSetConfigurationTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/GridSetConfigurationTest.java index 1c7737764..9e71c2de4 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/GridSetConfigurationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/GridSetConfigurationTest.java @@ -14,8 +14,8 @@ */ package org.geowebcache.config; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; import java.util.Collection; import java.util.Optional; diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/LayerConfigurationTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/LayerConfigurationTest.java index 99fc1a465..b25d49ef3 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/LayerConfigurationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/LayerConfigurationTest.java @@ -14,8 +14,8 @@ */ package org.geowebcache.config; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; import java.util.Collection; import java.util.Optional; 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 3cf82ca5b..bca5a1a94 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/ServerConfigurationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/ServerConfigurationTest.java @@ -14,12 +14,12 @@ */ package org.geowebcache.config; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasProperty; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import java.io.File; diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationConstructorsTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationConstructorsTest.java index 29ddcd7bd..b73f576fb 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationConstructorsTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationConstructorsTest.java @@ -21,7 +21,7 @@ import static org.easymock.EasyMock.verify; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.io.File; import java.io.IOException; diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationLayerConformanceTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationLayerConformanceTest.java index 74bad83fd..a24fbf87d 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationLayerConformanceTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationLayerConformanceTest.java @@ -15,8 +15,8 @@ package org.geowebcache.config; import static org.geowebcache.util.TestUtils.isPresent; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasProperty; -import static org.junit.Assert.assertThat; import java.io.File; import java.io.IOException; 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 6425918fa..acc23732e 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java @@ -17,6 +17,7 @@ import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; @@ -27,7 +28,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationXSchemaTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationXSchemaTest.java index 65ad939cb..40683eeec 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationXSchemaTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationXSchemaTest.java @@ -14,10 +14,12 @@ */ package org.geowebcache.config; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertThrows; import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.security.ForbiddenClassException; import java.util.Collections; import org.easymock.Capture; import org.easymock.EasyMock; @@ -27,14 +29,11 @@ import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.StaticWebApplicationContext; public class XMLConfigurationXSchemaTest { - @Rule public ExpectedException exception = ExpectedException.none(); - @Rule public PropertyRule whitelistProperty = PropertyRule.system("GEOWEBCACHE_XSTREAM_WHITELIST"); @@ -43,15 +42,15 @@ public void testNotAllowNonGWCClass() throws Exception { // Check that classes from other packages on the class path can't be serialized ContextualConfigurationProvider.Context pc = ContextualConfigurationProvider.Context.REST; try (StaticWebApplicationContext wac = new StaticWebApplicationContext()) { - - XStream xs = new GeoWebCacheXStream(); - - xs = XMLConfiguration.getConfiguredXStreamWithContext(xs, wac, pc); - - exception.expect(com.thoughtworks.xstream.security.ForbiddenClassException.class); - - @SuppressWarnings("unused") - Object o = xs.fromXML("<" + org.easymock.Capture.class.getCanonicalName() + " />"); + XStream xs = + XMLConfiguration.getConfiguredXStreamWithContext( + new GeoWebCacheXStream(), wac, pc); + + assertThrows( + ForbiddenClassException.class, + () -> { + xs.fromXML("<" + org.easymock.Capture.class.getCanonicalName() + " />"); + }); } } @@ -62,15 +61,16 @@ public void testNotAllowNonXMLGWCClass() throws Exception { ContextualConfigurationProvider.Context pc = ContextualConfigurationProvider.Context.REST; try (StaticWebApplicationContext wac = new StaticWebApplicationContext()) { - XStream xs = new GeoWebCacheXStream(); - - xs = XMLConfiguration.getConfiguredXStreamWithContext(xs, wac, pc); - - exception.expect(com.thoughtworks.xstream.security.ForbiddenClassException.class); - - @SuppressWarnings("unused") - Object o = - xs.fromXML("<" + XMLConfigurationXSchemaTest.class.getCanonicalName() + " />"); + XStream xs = + XMLConfiguration.getConfiguredXStreamWithContext( + new GeoWebCacheXStream(), wac, pc); + assertThrows( + ForbiddenClassException.class, + () -> + xs.fromXML( + "<" + + XMLConfigurationXSchemaTest.class.getCanonicalName() + + " />")); } } diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/legends/LegendInfoBuilderTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/legends/LegendInfoBuilderTest.java index 01e49f63a..9b8d58770 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/legends/LegendInfoBuilderTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/legends/LegendInfoBuilderTest.java @@ -14,9 +14,9 @@ */ package org.geowebcache.config.legends; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; import org.junit.Test; diff --git a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/FloatParameterFilterTest.java b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/FloatParameterFilterTest.java index c6e060fe6..625af935a 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/FloatParameterFilterTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/FloatParameterFilterTest.java @@ -14,12 +14,12 @@ */ package org.geowebcache.filter.parameters; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import com.thoughtworks.xstream.XStream; diff --git a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/IntegerParameterFilterTest.java b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/IntegerParameterFilterTest.java index 627ac9673..5d1b5bcb6 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/IntegerParameterFilterTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/IntegerParameterFilterTest.java @@ -14,12 +14,12 @@ */ package org.geowebcache.filter.parameters; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import com.thoughtworks.xstream.XStream; diff --git a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/ParametersUtilsTest.java b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/ParametersUtilsTest.java index a3cfe73b0..c885a8d38 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/ParametersUtilsTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/ParametersUtilsTest.java @@ -14,10 +14,10 @@ */ package org.geowebcache.filter.parameters; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.isEmptyString; -import static org.junit.Assert.assertThat; import java.util.Collections; import java.util.Map; diff --git a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/RegexParameterFilterTest.java b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/RegexParameterFilterTest.java index fa68f88da..5bb9665cb 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/RegexParameterFilterTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/RegexParameterFilterTest.java @@ -14,6 +14,7 @@ */ package org.geowebcache.filter.parameters; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasProperty; @@ -21,7 +22,6 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; diff --git a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/StringParameterFilterTest.java b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/StringParameterFilterTest.java index cf4bc98b3..ff32968d4 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/StringParameterFilterTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/filter/parameters/StringParameterFilterTest.java @@ -14,13 +14,13 @@ */ package org.geowebcache.filter.parameters; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import com.thoughtworks.xstream.XStream; diff --git a/geowebcache/core/src/test/java/org/geowebcache/grid/DefaultGridSetsTest.java b/geowebcache/core/src/test/java/org/geowebcache/grid/DefaultGridSetsTest.java index 862d43b1c..f5e1e9edd 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/grid/DefaultGridSetsTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/grid/DefaultGridSetsTest.java @@ -14,10 +14,10 @@ */ package org.geowebcache.grid; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; import java.util.Arrays; import org.geowebcache.config.DefaultGridsets; diff --git a/geowebcache/core/src/test/java/org/geowebcache/grid/GridSetBrokerTest.java b/geowebcache/core/src/test/java/org/geowebcache/grid/GridSetBrokerTest.java index eda5ebdbd..c58479295 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/grid/GridSetBrokerTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/grid/GridSetBrokerTest.java @@ -16,6 +16,7 @@ import static org.geowebcache.util.TestUtils.isPresent; import static org.geowebcache.util.TestUtils.notPresent; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasProperty; @@ -24,7 +25,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; diff --git a/geowebcache/core/src/test/java/org/geowebcache/grid/GridSetTest.java b/geowebcache/core/src/test/java/org/geowebcache/grid/GridSetTest.java index 0f0be92d2..e6d67c1ed 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/grid/GridSetTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/grid/GridSetTest.java @@ -1,10 +1,10 @@ package org.geowebcache.grid; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasProperty; import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertThat; import java.util.Collections; import org.geowebcache.config.DefaultGridsets; diff --git a/geowebcache/core/src/test/java/org/geowebcache/layer/wms/TileLayerTest.java b/geowebcache/core/src/test/java/org/geowebcache/layer/wms/TileLayerTest.java index cb9ef3fac..69572b58c 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/layer/wms/TileLayerTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/layer/wms/TileLayerTest.java @@ -1,11 +1,11 @@ package org.geowebcache.layer.wms; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalToIgnoringCase; import static org.hamcrest.Matchers.hasEntry; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; import java.util.Arrays; import java.util.Collection; diff --git a/geowebcache/core/src/test/java/org/geowebcache/layer/wms/WMSLayerTest.java b/geowebcache/core/src/test/java/org/geowebcache/layer/wms/WMSLayerTest.java index 20d181954..b5b42c9df 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/layer/wms/WMSLayerTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/layer/wms/WMSLayerTest.java @@ -22,10 +22,10 @@ import static org.geowebcache.TestHelpers.createRequest; import static org.geowebcache.TestHelpers.createWMSLayer; import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import java.awt.Color; diff --git a/geowebcache/core/src/test/java/org/geowebcache/seed/TruncateBboxRequestTest.java b/geowebcache/core/src/test/java/org/geowebcache/seed/TruncateBboxRequestTest.java index 197cfc22e..8fd906c2d 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/seed/TruncateBboxRequestTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/seed/TruncateBboxRequestTest.java @@ -15,12 +15,12 @@ package org.geowebcache.seed; import static org.easymock.EasyMock.eq; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.any; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import java.util.Arrays; import java.util.Collections; diff --git a/geowebcache/core/src/test/java/org/geowebcache/storage/AbstractBlobStoreTest.java b/geowebcache/core/src/test/java/org/geowebcache/storage/AbstractBlobStoreTest.java index e7f575a9a..7c326ea3a 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/storage/AbstractBlobStoreTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/storage/AbstractBlobStoreTest.java @@ -21,6 +21,7 @@ import static org.easymock.EasyMock.geq; import static org.easymock.EasyMock.isNull; import static org.geowebcache.util.FileMatchers.resource; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.describedAs; import static org.hamcrest.Matchers.empty; @@ -30,7 +31,6 @@ import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; import java.nio.charset.StandardCharsets; import java.util.Arrays; diff --git a/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreSuitabilityTest.java b/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreSuitabilityTest.java index 673e3173f..f0deefd1d 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreSuitabilityTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/storage/BlobStoreSuitabilityTest.java @@ -14,10 +14,10 @@ */ package org.geowebcache.storage; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.either; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; import static org.junit.Assume.assumeThat; import org.hamcrest.Matcher; diff --git a/geowebcache/core/src/test/java/org/geowebcache/storage/CompositeBlobStoreTest.java b/geowebcache/core/src/test/java/org/geowebcache/storage/CompositeBlobStoreTest.java index 554eba09a..a1ea0a66a 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/storage/CompositeBlobStoreTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/storage/CompositeBlobStoreTest.java @@ -14,13 +14,13 @@ */ package org.geowebcache.storage; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.argThat; import static org.mockito.Matchers.eq; diff --git a/geowebcache/core/src/test/java/org/geowebcache/storage/TransientCacheTest.java b/geowebcache/core/src/test/java/org/geowebcache/storage/TransientCacheTest.java index e5eac76d7..9a8e86d82 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/storage/TransientCacheTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/storage/TransientCacheTest.java @@ -19,7 +19,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import com.google.common.base.Ticker; import java.io.InputStream; diff --git a/geowebcache/core/src/test/java/org/geowebcache/util/FileUtilsTest.java b/geowebcache/core/src/test/java/org/geowebcache/util/FileUtilsTest.java index 225c068a8..fed3ae11e 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/util/FileUtilsTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/util/FileUtilsTest.java @@ -15,11 +15,11 @@ package org.geowebcache.util; import static org.geowebcache.util.LogTestWrapper.message; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import java.io.File; 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 b1803125f..90ef8fa2e 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 @@ -7,7 +7,7 @@ import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.io.File; import java.math.BigInteger; 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 b822ce57a..d13b3edf1 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 @@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; diff --git a/geowebcache/rest/src/test/java/org/geowebcache/rest/service/FormServiceTest.java b/geowebcache/rest/src/test/java/org/geowebcache/rest/service/FormServiceTest.java index 8567714e7..fe6a19549 100644 --- a/geowebcache/rest/src/test/java/org/geowebcache/rest/service/FormServiceTest.java +++ b/geowebcache/rest/src/test/java/org/geowebcache/rest/service/FormServiceTest.java @@ -20,7 +20,7 @@ import static org.easymock.EasyMock.verify; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasProperty; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertTrue; import java.util.Arrays; diff --git a/geowebcache/s3storage/src/test/java/org/geowebcache/s3/OnlineS3BlobStoreIntegrationTest.java b/geowebcache/s3storage/src/test/java/org/geowebcache/s3/OnlineS3BlobStoreIntegrationTest.java index fe2c9961c..ba2c759c3 100644 --- a/geowebcache/s3storage/src/test/java/org/geowebcache/s3/OnlineS3BlobStoreIntegrationTest.java +++ b/geowebcache/s3storage/src/test/java/org/geowebcache/s3/OnlineS3BlobStoreIntegrationTest.java @@ -13,7 +13,7 @@ package org.geowebcache.s3; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import org.junit.Assume; import org.junit.Rule; diff --git a/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConfigSerializeTest.java b/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConfigSerializeTest.java index 45285c1c0..ed1244578 100644 --- a/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConfigSerializeTest.java +++ b/geowebcache/s3storage/src/test/java/org/geowebcache/s3/S3BlobStoreConfigSerializeTest.java @@ -16,7 +16,7 @@ import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import com.amazonaws.services.s3.model.CannedAccessControlList; import com.thoughtworks.xstream.XStream; diff --git a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/FileManagerTest.java b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/FileManagerTest.java index 9dd36dafb..22ae0fea5 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/FileManagerTest.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/FileManagerTest.java @@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.io.File; import java.util.Collections; diff --git a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesBlobStoreTest.java b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesBlobStoreTest.java index 166ba147b..fea6da3c8 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesBlobStoreTest.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesBlobStoreTest.java @@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.io.File; import java.util.ArrayList; diff --git a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesPBFTest.java b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesPBFTest.java index 7ccf1b13e..2dec4c62a 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesPBFTest.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/MbtilesPBFTest.java @@ -15,7 +15,7 @@ package org.geowebcache.sqlite; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertTrue; import java.io.File; diff --git a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/OperationsRestTest.java b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/OperationsRestTest.java index 5fa6eb8c0..8b7a14024 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/OperationsRestTest.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/OperationsRestTest.java @@ -17,7 +17,7 @@ import static org.geowebcache.sqlite.Utils.Tuple.tuple; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import java.io.File; diff --git a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqliteBlobStoreTest.java b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqliteBlobStoreTest.java index 8c9cc418f..9ea8aa1a7 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqliteBlobStoreTest.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqliteBlobStoreTest.java @@ -16,7 +16,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.io.File; import java.nio.file.Files; diff --git a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqliteConnectionManagerTest.java b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqliteConnectionManagerTest.java index b373efbbf..421c57785 100644 --- a/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqliteConnectionManagerTest.java +++ b/geowebcache/sqlite/src/test/java/org/geowebcache/sqlite/SqliteConnectionManagerTest.java @@ -19,7 +19,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.io.File; import java.sql.Connection; diff --git a/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftBlobStoreTest.java b/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftBlobStoreTest.java index f581a6f9a..de2c59d6a 100644 --- a/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftBlobStoreTest.java +++ b/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftBlobStoreTest.java @@ -19,7 +19,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.any; diff --git a/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftTileTest.java b/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftTileTest.java index 39467aca8..484c6c6e7 100644 --- a/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftTileTest.java +++ b/geowebcache/swiftblob/src/test/java/org/geowebcache/swift/SwiftTileTest.java @@ -15,7 +15,7 @@ package org.geowebcache.swift; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.anyLong; diff --git a/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java b/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java index 98af05553..6f826ba6d 100644 --- a/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java +++ b/geowebcache/web/src/test/java/org/geowebcache/jetty/RestIntegrationTest.java @@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.io.File; import java.io.IOException; diff --git a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesConfigurationTest.java b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesConfigurationTest.java index 640f8fd16..86157d1b5 100644 --- a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesConfigurationTest.java +++ b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesConfigurationTest.java @@ -25,7 +25,7 @@ import static org.hamcrest.beans.HasPropertyWithValue.hasProperty; import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; import static org.hamcrest.text.IsEqualIgnoringCase.equalToIgnoringCase; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import com.google.common.collect.Sets; import java.net.URL; diff --git a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesGridSetConfigurationConformanceTest.java b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesGridSetConfigurationConformanceTest.java index 0e61c35f7..86d6c1135 100644 --- a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesGridSetConfigurationConformanceTest.java +++ b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesGridSetConfigurationConformanceTest.java @@ -19,7 +19,7 @@ import static org.geowebcache.util.TestUtils.assertPresent; import static org.geowebcache.util.TestUtils.requirePresent; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import com.google.common.base.Objects; import java.net.URL; diff --git a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesLayerConfigurationConformanceTest.java b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesLayerConfigurationConformanceTest.java index 7c456bf47..7c7c6b04c 100644 --- a/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesLayerConfigurationConformanceTest.java +++ b/geowebcache/wms/src/test/java/org/geowebcache/config/wms/GetCapabilitiesLayerConfigurationConformanceTest.java @@ -17,7 +17,7 @@ import static org.easymock.EasyMock.createNiceMock; import static org.easymock.EasyMock.expect; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.net.URL; import java.util.Collections; 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 4472a5d2c..299259d5b 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 @@ -5,7 +5,7 @@ import static org.easymock.EasyMock.replay; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.io.StringReader; import java.nio.charset.StandardCharsets; diff --git a/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSServiceTest.java b/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSServiceTest.java index de77de5a3..3566afbbb 100644 --- a/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSServiceTest.java +++ b/geowebcache/wms/src/test/java/org/geowebcache/service/wms/WMSServiceTest.java @@ -10,7 +10,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Matchers.eq;