From 8087ad6bd95831f073b81c43dc76e65bad139368 Mon Sep 17 00:00:00 2001 From: Gabriel Roldan Date: Fri, 17 May 2024 10:59:01 -0300 Subject: [PATCH 1/2] Remove unnecessary synchronization --- .../GsCloudLayerGroupContainmentCache.java | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCache.java b/src/catalog/backends/common/src/main/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCache.java index 221e90741..1318edfe7 100644 --- a/src/catalog/backends/common/src/main/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCache.java +++ b/src/catalog/backends/common/src/main/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCache.java @@ -170,12 +170,9 @@ private void clearGroupInfo(LayerGroupInfo lg) { .forEach( p -> { String rid = ((LayerInfo) p).getResource().getId(); - synchronized (rid) { - Set containers = - resourceContainmentCache.get(rid); - if (containers != null) { - containers.remove(data); - } + Set containers = resourceContainmentCache.get(rid); + if (containers != null) { + containers.remove(data); } }); // this group does not contain anything anymore, remove from containment @@ -320,11 +317,9 @@ private void updateContainedLayers( String resourceId = ((LayerInfo) removed).getResource().getId(); Set containers = resourceContainmentCache.get(resourceId); if (containers != null) { - synchronized (resourceId) { - containers.remove(groupSummary); - if (containers.isEmpty()) { - resourceContainmentCache.remove(resourceId, containers); - } + containers.remove(groupSummary); + if (containers.isEmpty()) { + resourceContainmentCache.remove(resourceId, containers); } } } else { @@ -342,12 +337,10 @@ private void updateContainedLayers( for (PublishedInfo added : addedLayers) { if (added instanceof LayerInfo) { String resourceId = ((LayerInfo) added).getResource().getId(); - synchronized (resourceId) { - Set containers = - resourceContainmentCache.computeIfAbsent( - resourceId, CONCURRENT_SET_BUILDER); - containers.add(groupSummary); - } + Set containers = + resourceContainmentCache.computeIfAbsent( + resourceId, CONCURRENT_SET_BUILDER); + containers.add(groupSummary); } else { LayerGroupInfo child = (LayerGroupInfo) added; LayerGroupSummary summary = groupCache.get(child.getId()); From 059a26608fb7e239d66670822fbacf6cee143393 Mon Sep 17 00:00:00 2001 From: Gabriel Roldan Date: Fri, 17 May 2024 12:18:47 -0300 Subject: [PATCH 2/2] General code clean up --- .../gwc/app/GeoWebCacheApplicationTest.java | 3 +- .../cloud/web/app/WebUIApplicationTest.java | 4 - .../wfs/app/WfsApplicationPgconfigIT.java | 4 +- ...onmentAdminAuthenticationProviderTest.java | 2 +- ...eoServerSecurityAutoConfigurationTest.java | 2 +- ...GsCloudLayerGroupContainmentCacheTest.java | 42 +++++----- ...RemoteEventDataDirectoryProcessorTest.java | 8 +- .../ToPgsqlCompatibleFilterDuplicator.java | 18 ++--- .../PgconfigCatalogInfoRepository.java | 10 +-- .../resource/PgconfigResourceStore.java | 2 +- .../PgconfigCatalogResourcesSynchronizer.java | 2 +- .../PgconfigBackendAutoConfigurationTest.java | 2 +- ...configDataSourceAutoConfigurationTest.java | 2 +- ...PgconfigCatalogBackendConformanceTest.java | 4 +- ...configConfigRepositoryConformanceTest.java | 2 +- .../config/PgconfigUpdateSequenceTest.java | 2 +- .../resource/PgconfigResourceTest.java | 23 ++++-- ...ngCatalogFacadeContainmentSupportTest.java | 6 +- .../cache/CachingCatalogFacadeTest.java | 10 +-- .../cache/CachingGeoServerFacadeTest.java | 12 +-- .../event/bus/BusAmqpIntegrationTests.java | 9 +-- .../bus/CatalogRemoteApplicationEventsIT.java | 7 +- ...logApplicationEventsConfigurationTest.java | 20 ++--- .../catalog/GeoServerCatalogModuleTest.java | 11 +-- .../catalog/PatchSerializationTest.java | 23 +++--- .../filter/ExpressionRoundtripTest.java | 11 +-- .../geoserver/catalog/CatalogTestData.java | 76 +++++++++--------- .../geoserver/catalog/faker/CatalogFaker.java | 11 +-- .../plugin/CatalogConformanceTest.java | 78 +++++++------------ .../CatalogFacadeExtensionAdapterTest.java | 4 - .../XmlCatalogInfoLookupConformanceTest.java | 5 +- .../plugin/locking/LockingCatalogTest.java | 5 +- .../GeoServerConfigConformanceTest.java | 22 +++--- .../backend/GwcCoreAutoConfigurationTest.java | 7 +- ...TileLayerCatalogAutoConfigurationTest.java | 11 +-- .../AzureBlobstoreAutoConfigurationTest.java | 2 +- .../S3BlobstoreAutoConfigurationTest.java | 2 +- .../WMSIntegrationAutoConfigurationTest.java | 5 +- .../RESTConfigAutoConfigurationTest.java | 5 +- .../pgconfig/PgconfigTileLayerCatalogIT.java | 4 +- .../config/blobstore/AzureBlobStoreTest.java | 1 - .../AzureBlobStoreXmlConfigurationTest.java | 6 +- .../CloudGwcXmlConfigurationTest.java | 6 +- .../ResourceStoreTileLayerCatalogTest.java | 19 ++--- ...impleJNDIStaticContextInitializerTest.java | 3 +- .../FilteringXmlBeanDefinitionReaderTest.java | 7 -- .../CssStylingConfigurationTest.java | 4 +- 47 files changed, 219 insertions(+), 305 deletions(-) diff --git a/src/apps/geoserver/gwc/src/test/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplicationTest.java b/src/apps/geoserver/gwc/src/test/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplicationTest.java index 870631ea3..0039127cd 100644 --- a/src/apps/geoserver/gwc/src/test/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplicationTest.java +++ b/src/apps/geoserver/gwc/src/test/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplicationTest.java @@ -11,7 +11,6 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParser; -import org.json.simple.parser.ParseException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -37,7 +36,7 @@ void before() { } @Test - void testRESTDefaultContentType() throws ParseException { + void testRESTDefaultContentType() { ResponseEntity response = testGetRequestContentType("/gwc/rest/layers", APPLICATION_JSON); JsonElement parsed = JsonParser.parseString(response.getBody()); diff --git a/src/apps/geoserver/webui/src/test/java/org/geoserver/cloud/web/app/WebUIApplicationTest.java b/src/apps/geoserver/webui/src/test/java/org/geoserver/cloud/web/app/WebUIApplicationTest.java index 432f38988..a67d4a62e 100644 --- a/src/apps/geoserver/webui/src/test/java/org/geoserver/cloud/web/app/WebUIApplicationTest.java +++ b/src/apps/geoserver/webui/src/test/java/org/geoserver/cloud/web/app/WebUIApplicationTest.java @@ -101,7 +101,6 @@ private void print(Component component) { void GeoServerHomePage_smoke_test_anonymous() { GeoServerHomePage page = tester.startPage(GeoServerHomePage.class); assertNotNull(page); - // print(page); tester.assertInvisible("catalogLinks"); tester.assertComponent("providedCaps", ListView.class); } @@ -111,7 +110,6 @@ void GeoServerHomePage_smoke_test_logged_in() { login(); GeoServerHomePage page = tester.startPage(GeoServerHomePage.class); assertNotNull(page); - // print(page); tester.assertComponent("catalogLinks:layersLink", BookmarkablePageLink.class); tester.assertComponent("catalogLinks:storesLink", BookmarkablePageLink.class); tester.assertComponent("catalogLinks:workspacesLink", BookmarkablePageLink.class); @@ -132,7 +130,6 @@ void GlobalSettingsPage_smoke_test() { tester.assertRenderedPage(GlobalSettingsPage.class); GlobalSettingsPage page = (GlobalSettingsPage) tester.getLastRenderedPage(); assertNotNull(page); - // print(page); assertHidden("proxyBaseUrlContainer"); assertHidden("useHeadersProxyURL"); assertHidden("loggingSettingsContainer"); @@ -144,7 +141,6 @@ void GlobalSettingsPage_smoke_test() { void GeoServerHomePage_smoke_test_service_links() { GeoServerHomePage page = tester.startPage(GeoServerHomePage.class); assertNotNull(page); - // print(page); tester.assertComponent("serviceList", ServicesPanel.class); tester.assertVisible("serviceList"); tester.assertComponent("serviceList:serviceDescriptions:0", ListItem.class); diff --git a/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationPgconfigIT.java b/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationPgconfigIT.java index 4facc5522..ac03f68e5 100644 --- a/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationPgconfigIT.java +++ b/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationPgconfigIT.java @@ -13,8 +13,6 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import java.io.IOException; - @SpringBootTest(classes = WfsApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) @ActiveProfiles("pgconfigjndi") @Testcontainers(disabledWithoutDocker = true) @@ -35,7 +33,7 @@ class WfsApplicationPgconfigIT extends WfsApplicationTest { * */ @DynamicPropertySource - static void setUpDataDir(DynamicPropertyRegistry registry) throws IOException { + static void setUpDataDir(DynamicPropertyRegistry registry) { registry.add("pgconfig.host", container::getHost); registry.add( "pgconfig.port", diff --git a/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/EnvironmentAdminAuthenticationProviderTest.java b/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/EnvironmentAdminAuthenticationProviderTest.java index a2abbe700..be64125fd 100644 --- a/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/EnvironmentAdminAuthenticationProviderTest.java +++ b/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/EnvironmentAdminAuthenticationProviderTest.java @@ -34,7 +34,7 @@ class EnvironmentAdminAuthenticationProviderTest { private ApplicationContextRunner runner; @BeforeEach - void setUp() throws Exception { + void setUp() { runner = GeoServerSecurityAutoConfigurationTest.createContextRunner(tempDir); } diff --git a/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/GeoServerSecurityAutoConfigurationTest.java b/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/GeoServerSecurityAutoConfigurationTest.java index 0007ab979..4153d2793 100644 --- a/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/GeoServerSecurityAutoConfigurationTest.java +++ b/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/GeoServerSecurityAutoConfigurationTest.java @@ -42,7 +42,7 @@ class GeoServerSecurityAutoConfigurationTest { private ApplicationContextRunner runner; @BeforeEach - void setUp() throws Exception { + void setUp() { runner = createContextRunner(tempDir); } diff --git a/src/catalog/backends/common/src/test/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCacheTest.java b/src/catalog/backends/common/src/test/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCacheTest.java index 0acb96e49..89380e1bd 100644 --- a/src/catalog/backends/common/src/test/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCacheTest.java +++ b/src/catalog/backends/common/src/test/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCacheTest.java @@ -8,7 +8,9 @@ import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -150,7 +152,7 @@ private static void addWorkspaceNamespace(String wsName) { } @BeforeEach - public void setupLayerGrups() throws Exception { + public void setupLayerGrups() { LayerInfo lakes = catalog.getLayerByName(getLayerId(MockData.LAKES)); LayerInfo forests = catalog.getLayerByName(getLayerId(MockData.FORESTS)); LayerInfo roads = catalog.getLayerByName(getLayerId(MockData.ROAD_SEGMENTS)); @@ -173,7 +175,7 @@ public void setupLayerGrups() throws Exception { } @AfterEach - public void clearLayerGroups() throws Exception { + public void clearLayerGroups() { CascadeDeleteVisitor remover = new CascadeDeleteVisitor(catalog); for (LayerGroupInfo lg : catalog.getLayerGroups()) { if (catalog.getLayerGroup(lg.getId()) != null) { @@ -183,7 +185,7 @@ public void clearLayerGroups() throws Exception { } private LayerGroupInfo addLayerGroup( - String name, Mode mode, WorkspaceInfo ws, PublishedInfo... layers) throws Exception { + String name, Mode mode, WorkspaceInfo ws, PublishedInfo... layers) { CatalogBuilder cb = new CatalogBuilder(catalog); LayerGroupInfo group = catalog.getFactory().createLayerGroup(); @@ -198,7 +200,11 @@ private LayerGroupInfo addLayerGroup( group.getStyles().add(null); } } - cb.calculateLayerGroupBounds(group); + try { + cb.calculateLayerGroupBounds(group); + } catch (Exception e) { + throw new IllegalStateException(e); + } catalog.add(group); if (ws != null) { return catalog.getLayerGroupByName(ws.getName(), name); @@ -247,7 +253,7 @@ void buildLayerGroupCaches() { } @Test - void testInitialSetup() throws Exception { + void testInitialSetup() { // nature Collection natureContainers = cc.getContainerGroupsFor(nature); assertEquals(1, natureContainers.size()); @@ -268,7 +274,7 @@ void testInitialSetup() throws Exception { } @Test - void testAddLayerToNature() throws Exception { + void testAddLayerToNature() { LayerInfo neatline = catalog.getLayerByName(getLayerId(MockData.MAP_NEATLINE)); nature.getLayers().add(neatline); nature.getStyles().add(null); @@ -278,7 +284,7 @@ void testAddLayerToNature() throws Exception { } @Test - void testAddLayerToContainer() throws Exception { + void testAddLayerToContainer() { LayerInfo neatline = catalog.getLayerByName(getLayerId(MockData.MAP_NEATLINE)); container.getLayers().add(neatline); container.getStyles().add(null); @@ -288,7 +294,7 @@ void testAddLayerToContainer() throws Exception { } @Test - void testRemoveLayerFromNature() throws Exception { + void testRemoveLayerFromNature() { LayerInfo lakes = catalog.getLayerByName(getLayerId(MockData.LAKES)); nature.getLayers().remove(lakes); nature.getStyles().remove(0); @@ -301,7 +307,7 @@ void testRemoveLayerFromNature() throws Exception { } @Test - void testRemoveLayerFromContainer() throws Exception { + void testRemoveLayerFromContainer() { LayerInfo roads = catalog.getLayerByName(getLayerId(MockData.ROAD_SEGMENTS)); container.getLayers().remove(roads); container.getStyles().remove(0); @@ -313,7 +319,7 @@ void testRemoveLayerFromContainer() throws Exception { } @Test - void testRemoveNatureFromContainer() throws Exception { + void testRemoveNatureFromContainer() { container.getLayers().remove(nature); container.getStyles().remove(0); catalog.save(container); @@ -326,7 +332,7 @@ void testRemoveNatureFromContainer() throws Exception { } @Test - void testRemoveAllGrups() throws Exception { + void testRemoveAllGrups() { catalog.remove(container); catalog.remove(nature); @@ -337,7 +343,7 @@ void testRemoveAllGrups() throws Exception { } @Test - void testAddRemoveNamed() throws Exception { + void testAddRemoveNamed() { final String NAMED_GROUP = "named"; LayerInfo neatline = catalog.getLayerByName(getLayerId(MockData.MAP_NEATLINE)); LayerInfo lakes = catalog.getLayerByName(getLayerId(MockData.LAKES)); @@ -358,7 +364,7 @@ void testAddRemoveNamed() throws Exception { } @Test - void testAddRemoveNestedNamed() throws Exception { + void testAddRemoveNestedNamed() { final String NESTED_NAMED = "nestedNamed"; LayerInfo neatline = catalog.getLayerByName(getLayerId(MockData.MAP_NEATLINE)); LayerInfo lakes = catalog.getLayerByName(getLayerId(MockData.LAKES)); @@ -384,7 +390,7 @@ void testAddRemoveNestedNamed() throws Exception { } @Test - void testRenameGroup() throws Exception { + void testRenameGroup() { nature.setName("renamed"); catalog.save(nature); @@ -394,7 +400,7 @@ void testRenameGroup() throws Exception { } @Test - void testRenameWorkspace() throws Exception { + void testRenameWorkspace() { WorkspaceInfo ws = catalog.getDefaultWorkspace(); ws.setName("renamed"); try { @@ -410,7 +416,7 @@ void testRenameWorkspace() throws Exception { } @Test - void testChangeWorkspace() throws Exception { + void testChangeWorkspace() { DataStoreInfo store = catalog.getDataStores().get(0); try { WorkspaceInfo aws = catalog.getWorkspaceByName(ANOTHER_WS); @@ -430,7 +436,7 @@ void testChangeWorkspace() throws Exception { } @Test - void testChangeGroupMode() throws Exception { + void testChangeGroupMode() { LayerGroupSummary summary = cc.groupCache.get(nature.getId()); assertEquals(Mode.SINGLE, summary.getMode()); diff --git a/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/event/remote/datadir/RemoteEventDataDirectoryProcessorTest.java b/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/event/remote/datadir/RemoteEventDataDirectoryProcessorTest.java index 475d7c2cf..44fe1c346 100644 --- a/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/event/remote/datadir/RemoteEventDataDirectoryProcessorTest.java +++ b/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/event/remote/datadir/RemoteEventDataDirectoryProcessorTest.java @@ -59,7 +59,7 @@ class RemoteEventDataDirectoryProcessorTest { GeoServerInfo global; @BeforeEach - void setUp() throws Exception { + void setUp() { mockFacade = mock(ExtendedCatalogFacade.class); var catalog = mock(CatalogPlugin.class); when(catalog.getFacade()).thenReturn(mockFacade); @@ -84,8 +84,8 @@ void testRemoteEventDataDirectoryProcessor() { var catalogFacade = mock(ExtendedCatalogFacade.class); when(rawCatalog.getFacade()).thenReturn(catalogFacade); - var processor = new RemoteEventDataDirectoryProcessor(configFacade, rawCatalog); - assertSame(catalogFacade, processor.catalogFacade()); + var p = new RemoteEventDataDirectoryProcessor(configFacade, rawCatalog); + assertSame(catalogFacade, p.catalogFacade()); } @Test @@ -256,8 +256,6 @@ void testOnRemoteModifyEvent_IgnoresSetDefaultEvents() { @Test void testOnRemoteModifyEvent_GeoServerInfo() { - GeoServerInfo global = this.global; - when(mockGeoServerFacade.getGlobal()) .thenReturn(ModificationProxy.create(global, GeoServerInfo.class)); diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/ToPgsqlCompatibleFilterDuplicator.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/ToPgsqlCompatibleFilterDuplicator.java index 9e2d33f43..3bc37fd10 100644 --- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/ToPgsqlCompatibleFilterDuplicator.java +++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/ToPgsqlCompatibleFilterDuplicator.java @@ -145,17 +145,13 @@ protected Filter adaptMatchActionForCollectionLiteral(final BinaryComparisonOper } private Function, Filter> createOredOrAndedBuilder(final MatchAction matchAction) { - Function, Filter> aggregateBuilder; - if (matchAction == MatchAction.ALL) { - // if all of the possible combinations match, the result is true (aggregated AND) - aggregateBuilder = ff::and; - } else if (matchAction == MatchAction.ANY) { - // if any of the possible combinations match, the result is true (aggregated OR) - aggregateBuilder = ff::or; - } else { - throw new IllegalStateException(); - } - return aggregateBuilder; + return switch (matchAction) { + // if all of the possible combinations match, the result is true (aggregated AND) + case ALL -> ff::and; + // if any of the possible combinations match, the result is true (aggregated OR) + case ANY -> ff::or; + default -> throw new IllegalStateException(); + }; } /** diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/repository/PgconfigCatalogInfoRepository.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/repository/PgconfigCatalogInfoRepository.java index d80d132ff..b8d5b8df6 100644 --- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/repository/PgconfigCatalogInfoRepository.java +++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/repository/PgconfigCatalogInfoRepository.java @@ -222,14 +222,6 @@ private Filter applyTypeFilter(Filter filter, Class type) { return filter; } - private String applyTypeFilter(String sql, @NonNull Class type) { - if (!getContentType().equals(type)) { - String infoType = infoType(type); - sql += " AND \"@type\" = '%s'::infotype".formatted(infoType); - } - return sql; - } - protected String applyOffsetLimit(String sql, Integer offset, Integer limit) { if (null != offset) sql += " OFFSET %d".formatted(offset); if (null != limit) sql += " LIMIT %d".formatted(limit); @@ -303,7 +295,7 @@ private Object[] prepareParams(PgconfigQueryBuilder qb) { } private Object asPreparedValue(Object val) { - if (val instanceof Enum e) return e.name(); + if (val instanceof Enum e) return e.name(); return val; } diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/resource/PgconfigResourceStore.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/resource/PgconfigResourceStore.java index af7ab63c2..af78f93a2 100644 --- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/resource/PgconfigResourceStore.java +++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/resource/PgconfigResourceStore.java @@ -425,7 +425,7 @@ public PgconfigResource mkdirs(PgconfigResource resource) { PgconfigResource parent = getParent(resource); if (null == parent) return resource; if (!parent.exists()) { - parent = (PgconfigResource) parent.mkdirs(); + parent = parent.mkdirs(); } resource.parentId = parent.getId(); resource.type = Type.DIRECTORY; diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/pgconfig/PgconfigCatalogResourcesSynchronizer.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/pgconfig/PgconfigCatalogResourcesSynchronizer.java index 8c2aa031e..65a936624 100644 --- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/pgconfig/PgconfigCatalogResourcesSynchronizer.java +++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/pgconfig/PgconfigCatalogResourcesSynchronizer.java @@ -82,7 +82,7 @@ public void handleRemoveEvent(CatalogRemoveEvent event) { if (source instanceof WorkspaceInfo ws) { log.debug("Removing workspace {}", ws.getName()); rmRes(dd.get(ws)); - } else if (source instanceof NamespaceInfo ns) { + } else if (source instanceof NamespaceInfo) { // do not remove the directory, only when removing the workspace } else if (source instanceof StoreInfo store) { log.debug("Removing datastore {}", store.getName()); diff --git a/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/PgconfigBackendAutoConfigurationTest.java b/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/PgconfigBackendAutoConfigurationTest.java index 103d90c14..e2568ba6a 100644 --- a/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/PgconfigBackendAutoConfigurationTest.java +++ b/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/PgconfigBackendAutoConfigurationTest.java @@ -44,7 +44,7 @@ class PgconfigBackendAutoConfigurationTest { PgconfigBackendAutoConfiguration.class)); @BeforeEach - void setUp() throws Exception { + void setUp() { runner = container.withJdbcUrlConfig(runner); } diff --git a/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/PgconfigDataSourceAutoConfigurationTest.java b/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/PgconfigDataSourceAutoConfigurationTest.java index 77056befe..fdad6a10a 100644 --- a/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/PgconfigDataSourceAutoConfigurationTest.java +++ b/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/PgconfigDataSourceAutoConfigurationTest.java @@ -47,7 +47,7 @@ class PgconfigDataSourceAutoConfigurationTest { String password; @BeforeEach - void setUp() throws Exception { + void setUp() { url = container.getJdbcUrl(); username = container.getUsername(); password = container.getPassword(); diff --git a/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/catalog/PgconfigCatalogBackendConformanceTest.java b/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/catalog/PgconfigCatalogBackendConformanceTest.java index d199aadb0..902f99ade 100644 --- a/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/catalog/PgconfigCatalogBackendConformanceTest.java +++ b/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/catalog/PgconfigCatalogBackendConformanceTest.java @@ -40,7 +40,7 @@ class PgconfigCatalogBackendConformanceTest extends CatalogConformanceTest { @Override @BeforeEach - public void setUp() throws Exception { + public void setUp() { container.setUp(); super.setUp(); } @@ -94,7 +94,7 @@ LockRepository pgconfigLockRepository() { returned ft/ft2 where mockito is not throwing the expected exception """) @Override - public void testSaveDataStoreRollbacksBothStoreAndResources() throws Exception {} + public void testSaveDataStoreRollbacksBothStoreAndResources() {} static @BeforeAll void beforeAll() throws Exception { try { diff --git a/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/config/PgconfigConfigRepositoryConformanceTest.java b/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/config/PgconfigConfigRepositoryConformanceTest.java index a94c31dfc..dd62a804f 100644 --- a/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/config/PgconfigConfigRepositoryConformanceTest.java +++ b/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/config/PgconfigConfigRepositoryConformanceTest.java @@ -25,7 +25,7 @@ class PgconfigConfigRepositoryConformanceTest extends GeoServerConfigConformance @Override @BeforeEach - public void setUp() throws Exception { + public void setUp() { container.setUp(); super.setUp(); } diff --git a/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/config/PgconfigUpdateSequenceTest.java b/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/config/PgconfigUpdateSequenceTest.java index 4274a9a0b..1183f395c 100644 --- a/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/config/PgconfigUpdateSequenceTest.java +++ b/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/config/PgconfigUpdateSequenceTest.java @@ -27,7 +27,7 @@ class PgconfigUpdateSequenceTest implements UpdateSequenceConformanceTest { private GeoServer geoserver; @BeforeEach - public void init() throws Exception { + public void init() { container.setUp(); facade = new PgconfigGeoServerFacade(container.getTemplate()); geoserver = new GeoServerImpl(facade); diff --git a/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/resource/PgconfigResourceTest.java b/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/resource/PgconfigResourceTest.java index e2e3153f3..4056a26d3 100644 --- a/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/resource/PgconfigResourceTest.java +++ b/src/catalog/backends/pgconfig/src/test/java/org/geoserver/cloud/backend/pgconfig/resource/PgconfigResourceTest.java @@ -214,12 +214,12 @@ public void theoryAlteringFileAltersResource(String path) throws Exception { @Override @Ignore("This behaviour is specific to the file based implementation") - public void theoryAddingFileToDirectoryAddsResource(String path) throws Exception { + public void theoryAddingFileToDirectoryAddsResource(String path) { // disabled } @Theory - public void theoryRenamedDirectoryRenamesChildren(String path) throws Exception { + public void theoryRenamedDirectoryRenamesChildren(String path) { final Resource res = getResource(path); assumeThat(res, is(directory())); @@ -257,11 +257,20 @@ public void testDefaultIgnoredDirs() { @Test public void testRemoveIgnoredDirs() { - assertFileSystemDir("temp"); - assertFileSystemDir("tmp"); - assertFileSystemDir("legendsamples"); - assertFileSystemDir("data"); - assertFileSystemDir("logs"); + testRemoveIgnoredDir("temp"); + testRemoveIgnoredDir("tmp"); + testRemoveIgnoredDir("legendsamples"); + testRemoveIgnoredDir("data"); + testRemoveIgnoredDir("logs"); + } + + private void testRemoveIgnoredDir(String ignoredDir) { + assertFileSystemFile(ignoredDir + "/child1"); + assertFileSystemFile(ignoredDir + "/child2"); + store.remove(ignoredDir); + assertThat(store.get(ignoredDir), is(undefined())); + assertThat(store.get(ignoredDir + "/child1"), is(undefined())); + assertThat(store.get(ignoredDir + "/child2"), is(undefined())); } @Test diff --git a/src/catalog/cache/src/test/java/org/geoserver/cloud/catalog/cache/CachingCatalogFacadeContainmentSupportTest.java b/src/catalog/cache/src/test/java/org/geoserver/cloud/catalog/cache/CachingCatalogFacadeContainmentSupportTest.java index 654651190..c5826e787 100644 --- a/src/catalog/cache/src/test/java/org/geoserver/cloud/catalog/cache/CachingCatalogFacadeContainmentSupportTest.java +++ b/src/catalog/cache/src/test/java/org/geoserver/cloud/catalog/cache/CachingCatalogFacadeContainmentSupportTest.java @@ -61,7 +61,7 @@ class CachingCatalogFacadeContainmentSupportTest { private CachingCatalogFacadeContainmentSupport support; @BeforeEach - void setUp() throws Exception { + void setUp() { support = new CachingCatalogFacadeContainmentSupport(); } @@ -79,7 +79,7 @@ void testGetDefaultWorkspace() throws Exception { } @Test - void testEvictDefaultWorkspace() throws Exception { + void testEvictDefaultWorkspace() { support.getCache().put(DEFAULT_WORKSPACE_CACHE_KEY, stub(WorkspaceInfo.class)); support.evictDefaultWorkspace(); assertNotCached(DEFAULT_WORKSPACE_CACHE_KEY); @@ -121,7 +121,7 @@ void testEvictDefaultDataStoreWorkspaceInfo() { } @Test - void testGetDoesNotCacheNullValues() throws Exception { + void testGetDoesNotCacheNullValues() { WorkspaceInfo ws = stub(WorkspaceInfo.class); InfoIdKey idKey = InfoIdKey.valueOf(ws); diff --git a/src/catalog/cache/src/test/java/org/geoserver/cloud/catalog/cache/CachingCatalogFacadeTest.java b/src/catalog/cache/src/test/java/org/geoserver/cloud/catalog/cache/CachingCatalogFacadeTest.java index 3536a9ff6..783e2d4a4 100644 --- a/src/catalog/cache/src/test/java/org/geoserver/cloud/catalog/cache/CachingCatalogFacadeTest.java +++ b/src/catalog/cache/src/test/java/org/geoserver/cloud/catalog/cache/CachingCatalogFacadeTest.java @@ -73,7 +73,7 @@ class CachingCatalogFacadeTest { CachingCatalogFacade facade; @BeforeEach - void setUp() throws Exception { + void setUp() { MockitoAnnotations.openMocks(this); facade = new CachingCatalogFacade(subject, supportMock); } @@ -83,7 +83,7 @@ static VerificationMode once() { } @SuppressWarnings("unchecked") - private ArgumentCaptor> loaderCaptor(Class type) { + private ArgumentCaptor> loaderCaptor() { return ArgumentCaptor.forClass(Callable.class); } @@ -141,7 +141,7 @@ void testAdd() { void testAdd(Class type) { I info = stub(type); facade.add(info); - var loaderCaptor = loaderCaptor(type); + ArgumentCaptor> loaderCaptor = loaderCaptor(); verify(supportMock, once()).evictAndGet(same(info), loaderCaptor.capture()); loaderCaptor.getValue().call(); @@ -191,7 +191,7 @@ Optional newPrefixedName(CatalogInfo info, Patch patch) { ConfigInfoType configInfoType = ConfigInfoType.valueOf(type); verify(supportMock, once()).evict(id, newPrefixedName, configInfoType); - var loaderCaptor = loaderCaptor(type); + ArgumentCaptor> loaderCaptor = loaderCaptor(); verify(supportMock, once()).evictAndGet(same(info), loaderCaptor.capture()); loaderCaptor.getValue().call(); @@ -257,7 +257,7 @@ void testGetDefaultDataStore() { WorkspaceInfo ws = mock(WorkspaceInfo.class); facade.getDefaultDataStore(ws); - var loaderCaptor = loaderCaptor(DataStoreInfo.class); + ArgumentCaptor> loaderCaptor = loaderCaptor(); verify(supportMock, once()).getDefaultDataStore(same(ws), loaderCaptor.capture()); loaderCaptor.getValue().call(); diff --git a/src/catalog/cache/src/test/java/org/geoserver/cloud/catalog/cache/CachingGeoServerFacadeTest.java b/src/catalog/cache/src/test/java/org/geoserver/cloud/catalog/cache/CachingGeoServerFacadeTest.java index a71dced10..7a086998f 100644 --- a/src/catalog/cache/src/test/java/org/geoserver/cloud/catalog/cache/CachingGeoServerFacadeTest.java +++ b/src/catalog/cache/src/test/java/org/geoserver/cloud/catalog/cache/CachingGeoServerFacadeTest.java @@ -253,9 +253,9 @@ void onSettingsInfoRemoveEvent() { @Test void onServiceInfoModifyEvent() { TestService1 service = wsService1; - WorkspaceInfo ws = service.getWorkspace(); - when(mock.getService(ws, ServiceInfo.class)).thenReturn(service); - when(mock.getService(ws, TestService1.class)).thenReturn(service); + WorkspaceInfo ws1 = service.getWorkspace(); + when(mock.getService(ws1, ServiceInfo.class)).thenReturn(service); + when(mock.getService(ws1, TestService1.class)).thenReturn(service); ServiceInfoKey idKey = ServiceInfoKey.byId(service.getId()); ServiceInfoKey nameKey = ServiceInfoKey.byName(service.getWorkspace(), service.getName()); @@ -264,7 +264,7 @@ void onServiceInfoModifyEvent() { final ServiceModified event = event(ServiceModified.class, service.getId(), SERVICE); // query as ServiceInfo.class - caching.getService(ws, ServiceInfo.class); + caching.getService(ws1, ServiceInfo.class); assertThat(cache.get(idKey)).isNotNull(); assertThat(cache.get(nameKey)).isNotNull(); assertThat(cache.get(typeKey)).isNotNull(); @@ -276,7 +276,7 @@ void onServiceInfoModifyEvent() { assertThat(cache.get(typeKey)).isNull(); // query as TestService1.class - caching.getService(ws, TestService1.class); + caching.getService(ws1, TestService1.class); assertThat(cache.get(idKey)).isNotNull(); assertThat(cache.get(nameKey)).isNotNull(); assertThat(cache.get(typeKey)).isNotNull(); @@ -288,7 +288,7 @@ void onServiceInfoModifyEvent() { assertThat(cache.get(typeKey)).isNull(); // query as WMSInfo.class - caching.getService(ws, WMSInfo.class); + caching.getService(ws1, WMSInfo.class); assertThat(cache.get(idKey)).isNull(); assertThat(cache.get(nameKey)).isNull(); assertThat(cache.get(typeKey)).isNull(); diff --git a/src/catalog/event-bus/src/test/java/org/geoserver/cloud/event/bus/BusAmqpIntegrationTests.java b/src/catalog/event-bus/src/test/java/org/geoserver/cloud/event/bus/BusAmqpIntegrationTests.java index 204ebe8bb..cefc351f8 100644 --- a/src/catalog/event-bus/src/test/java/org/geoserver/cloud/event/bus/BusAmqpIntegrationTests.java +++ b/src/catalog/event-bus/src/test/java/org/geoserver/cloud/event/bus/BusAmqpIntegrationTests.java @@ -331,8 +331,6 @@ protected void assertRemoteEvent(T info, RemoteGeoServerEvent b GeoServerEvent event = busEvent.getEvent(); assertNotNull(event); assertNotNull(((InfoEvent) event).getObjectId()); - // assertNotNull(event.getTarget()); - // assertNull(event.getSource()); final ConfigInfoType infoType = ((InfoEvent) event).getObjectType(); assertThat(infoType).isNotNull(); @@ -340,9 +338,7 @@ protected void assertRemoteEvent(T info, RemoteGeoServerEvent b assertThat(infoType).isEqualTo(expectedType); switch (infoType) { - case CATALOG: - case GEOSERVER: - case LOGGING: + case CATALOG, GEOSERVER, LOGGING: assertNotNull(((InfoEvent) event).getObjectId()); break; default: @@ -358,9 +354,6 @@ protected void assertRemoteEvent(T info, RemoteGeoServerEvent b assertThat(object.getId()).isEqualTo(info.getId()); assertResolved(object, Info.class); - info = ModificationProxy.unwrap(info); - object = ModificationProxy.unwrap(object); - // testData.assertEqualsLenientConnectionParameters(info, object); } if (event instanceof InfoModified modifyEvent) { diff --git a/src/catalog/event-bus/src/test/java/org/geoserver/cloud/event/bus/CatalogRemoteApplicationEventsIT.java b/src/catalog/event-bus/src/test/java/org/geoserver/cloud/event/bus/CatalogRemoteApplicationEventsIT.java index 92e27108c..cb750710f 100644 --- a/src/catalog/event-bus/src/test/java/org/geoserver/cloud/event/bus/CatalogRemoteApplicationEventsIT.java +++ b/src/catalog/event-bus/src/test/java/org/geoserver/cloud/event/bus/CatalogRemoteApplicationEventsIT.java @@ -540,12 +540,12 @@ private E testCatalogModifiedEvent( RemoteGeoServerEvent localRemoteEvent = eventsCaptor.local().expectOne(eventType, filter); RemoteGeoServerEvent sentEvent = eventsCaptor.remote().expectOne(eventType, filter); - assertCatalogEvent(catalog, (InfoModified) localRemoteEvent.getEvent(), expected); - assertCatalogEvent(catalog, (InfoModified) sentEvent.getEvent(), expected); + assertCatalogEvent((InfoModified) localRemoteEvent.getEvent(), expected); + assertCatalogEvent((InfoModified) sentEvent.getEvent(), expected); return eventType.cast(sentEvent.getEvent()); } - private void assertCatalogEvent(Catalog catalog, InfoModified event, Patch expected) { + private void assertCatalogEvent(InfoModified event, Patch expected) { assertThat(event.getObjectId()).isEqualTo("catalog"); // i.e. InfoEvent.CATALOG_ID assertThat(event.getObjectType()).isEqualTo(ConfigInfoType.CATALOG); @@ -555,6 +555,5 @@ private void assertCatalogEvent(Catalog catalog, InfoModified event, Patch expec // can't compare value equality here, RevolvingProxy instances won't be resolved against // the remote catalog because that depends on having an actual catalog backend // configured - // assertEquals(expected, actual); } } diff --git a/src/catalog/events/src/test/java/org/geoserver/cloud/config/catalog/events/CatalogApplicationEventsConfigurationTest.java b/src/catalog/events/src/test/java/org/geoserver/cloud/config/catalog/events/CatalogApplicationEventsConfigurationTest.java index 17025a009..424b95d77 100644 --- a/src/catalog/events/src/test/java/org/geoserver/cloud/config/catalog/events/CatalogApplicationEventsConfigurationTest.java +++ b/src/catalog/events/src/test/java/org/geoserver/cloud/config/catalog/events/CatalogApplicationEventsConfigurationTest.java @@ -119,11 +119,11 @@ void testCatalogSetDefaultWorkspace() { listener.clear(); catalog.setDefaultWorkspace(testData.workspaceC); - testModify(catalog, "defaultWorkspace", testData.workspaceA, testData.workspaceC); + testModify(catalog, "defaultWorkspace", testData.workspaceC); listener.clear(); catalog.setDefaultWorkspace(testData.workspaceB); - testModify(catalog, "defaultWorkspace", testData.workspaceC, testData.workspaceB); + testModify(catalog, "defaultWorkspace", testData.workspaceB); } @Test @@ -136,11 +136,11 @@ void testCatalogSetDefaultNamespace() { listener.clear(); catalog.setDefaultNamespace(testData.namespaceC); - testModify(catalog, "defaultNamespace", testData.namespaceA, testData.namespaceC); + testModify(catalog, "defaultNamespace", testData.namespaceC); listener.clear(); catalog.setDefaultNamespace(testData.namespaceB); - testModify(catalog, "defaultNamespace", testData.namespaceC, testData.namespaceB); + testModify(catalog, "defaultNamespace", testData.namespaceB); } @Test @@ -285,10 +285,8 @@ void testConfigPrePostModifyEvents_ServiceInfo() { testConfigModifyService(testData.wmsService); testConfigModifyService(testData.wfsService); - // WCSInfoImpl.equals() doesn't work - // testConfigModifyService(testData.wcsService); - // WPSInfoImpl.equals() doesn't work - // testConfigModifyService(testData.wpsService); + // WCSInfoImpl.equals() doesn't work, can't do testConfigModifyService(testData.wcsService); + // WPSInfoImpl.equals() doesn't work, can't do testConfigModifyService(testData.wpsService); } private void testConfigModifyService(ServiceInfo service) { @@ -362,11 +360,7 @@ private void testModify( assertThat(post.getPatch()).isEqualTo(expected); } - private void testModify( - CatalogInfo objectChanged, - String propertyName, - CatalogInfo oldValue, - CatalogInfo newValue) { + private void testModify(CatalogInfo objectChanged, String propertyName, CatalogInfo newValue) { CatalogInfoModified post = listener.expectOne(CatalogInfoModified.class); diff --git a/src/catalog/jackson-bindings/geoserver/src/test/java/org/geoserver/jackson/databind/catalog/GeoServerCatalogModuleTest.java b/src/catalog/jackson-bindings/geoserver/src/test/java/org/geoserver/jackson/databind/catalog/GeoServerCatalogModuleTest.java index eaf1b4392..40cfff429 100644 --- a/src/catalog/jackson-bindings/geoserver/src/test/java/org/geoserver/jackson/databind/catalog/GeoServerCatalogModuleTest.java +++ b/src/catalog/jackson-bindings/geoserver/src/test/java/org/geoserver/jackson/databind/catalog/GeoServerCatalogModuleTest.java @@ -381,7 +381,7 @@ protected ContactInfoImpl contact(String org) { return contact; } - protected AttributionInfoImpl attInfo(String id) throws Exception { + protected AttributionInfoImpl attInfo(String id) { AttributionInfoImpl attinfo = new AttributionInfoImpl(); attinfo.setId(id); attinfo.setHref("http://nevermind"); @@ -480,17 +480,12 @@ private PropertyIsEqualTo equals(String propertyName, Object literal) { } private T roundTrip(T orig, Class clazz) throws JsonProcessingException { - return roundTrip(orig, clazz, clazz); - } - - private V roundTrip(T orig, Class source, Class target) - throws JsonProcessingException { ObjectWriter writer = objectMapper.writer(); writer = writer.withDefaultPrettyPrinter(); String encoded = writer.writeValueAsString(orig); print("encoded: {}", encoded); @SuppressWarnings("unchecked") - V decoded = (V) objectMapper.readValue(encoded, target); + T decoded = (T) objectMapper.readValue(encoded, clazz); print("decoded: {}", decoded); return decoded; } @@ -699,7 +694,7 @@ void testValueMetadataMap() throws Exception { } @Test - void testQuery() throws Exception { + void testQuery() { Arrays.stream(ClassMappings.values()) .map(ClassMappings::getInterface) .filter(CatalogInfo.class::isAssignableFrom) diff --git a/src/catalog/jackson-bindings/geoserver/src/test/java/org/geoserver/jackson/databind/catalog/PatchSerializationTest.java b/src/catalog/jackson-bindings/geoserver/src/test/java/org/geoserver/jackson/databind/catalog/PatchSerializationTest.java index a3a45a0b1..8029eb9aa 100644 --- a/src/catalog/jackson-bindings/geoserver/src/test/java/org/geoserver/jackson/databind/catalog/PatchSerializationTest.java +++ b/src/catalog/jackson-bindings/geoserver/src/test/java/org/geoserver/jackson/databind/catalog/PatchSerializationTest.java @@ -14,7 +14,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; @@ -425,8 +424,6 @@ void referencedEnvelope() throws Exception { @Test void numberRange() throws Exception { testPatch("range", NumberRange.create(-1, 1)); - // testPatch("range", NumberRange.create(-1.1f, 1.1f)); - // testPatch("range", NumberRange.create((short) 10, (short) 15)); testPatch("range", NumberRange.create(Double.MIN_VALUE, 1.01)); } @@ -537,10 +534,10 @@ void testPatchWithListProperty() throws Exception { testPatch("contact", List.of(data.faker().contactInfo(), data.faker().contactInfo())); testPatch("serviceInfos", List.of(data.wmsService)); - // REVISIT: WFSInfoImpl.equals is broken - // testPatch("serviceInfos", List.of(data.wmsService, data.wfsService)); - // REVISIT: WCSInfoImpl.equals is broken - // testPatch("serviceInfos", List.of(data.wcsService)); + // REVISIT: WFSInfoImpl.equals is broken, can't do testPatch("serviceInfos", + // List.of(data.wmsService, data.wfsService)); + // REVISIT: WCSInfoImpl.equals is broken, can't do testPatch("serviceInfos", + // List.of(data.wcsService)); } @Test @@ -745,16 +742,14 @@ private Patch testPatch(String name, Object value) throws Exception { return testPatch(patch); } - private Patch testPatch(Patch patch) throws JsonProcessingException, JsonMappingException { + private Patch testPatch(Patch patch) throws JsonProcessingException { Patch resolved = testPatchNoEquals(patch); assertEquals(patch, resolved); return resolved; } - private Patch testPatchNoEquals(Patch patch) - throws JsonProcessingException, JsonMappingException { - + private Patch testPatchNoEquals(Patch patch) throws JsonProcessingException { Patch decoded = roundtrip(patch); Patch resolved = resolve(decoded); print("resolved: {}", resolved); @@ -782,7 +777,7 @@ protected Patch resolve(Patch decoded) { return resolved; } - private Patch roundtrip(Patch patch) throws JsonProcessingException, JsonMappingException { + private Patch roundtrip(Patch patch) throws JsonProcessingException { Object patchValue = patch.getPatches().get(0).getValue(); boolean encodeByReference = ProxyUtils.encodeByReference(patchValue); @@ -843,14 +838,14 @@ protected void assertNotAProxy(Object value) { .as( () -> String.format( - "%s should not be a ResolvingProxy", + "%s should not be a ResolvingProxy: %s", info.getId(), typeName(info))) .isFalse(); assertThat(ProxyUtils.isModificationProxy(info)) .as( () -> String.format( - "%s should not be a ModificationProxy", + "%s should not be a ModificationProxy: %s", info.getId(), typeName(info))) .isFalse(); } diff --git a/src/catalog/jackson-bindings/geotools/src/test/java/org/geotools/jackson/databind/filter/ExpressionRoundtripTest.java b/src/catalog/jackson-bindings/geotools/src/test/java/org/geotools/jackson/databind/filter/ExpressionRoundtripTest.java index b678b0892..e49605dde 100644 --- a/src/catalog/jackson-bindings/geotools/src/test/java/org/geotools/jackson/databind/filter/ExpressionRoundtripTest.java +++ b/src/catalog/jackson-bindings/geotools/src/test/java/org/geotools/jackson/databind/filter/ExpressionRoundtripTest.java @@ -393,7 +393,7 @@ private void testFunctionRoundtrip(FunctionName functionDescriptor) throws Excep assertNull(functionName.getNamespaceURI(), "Unexpected non-null function name nsURI"); assertEquals(name, functionName.getLocalPart()); - List parameters = buildParameters(argumentCount, arguments); + List parameters = buildParameters(arguments); Function dto = new Function(); dto.setName(name); dto.setParameters(parameters); @@ -418,7 +418,7 @@ private void testFunctionNameRoundtrip(FunctionName functionName) throws Excepti roundtripTest(dto); } - private List buildParameters(int argumentCount, List> arguments) { + private List buildParameters(List> arguments) { List parameters = new ArrayList<>(); arguments.forEach(p -> parameters.addAll(buildSampleParameter(p))); return parameters; @@ -426,13 +426,10 @@ private List buildParameters(int argumentCount, List> a private List buildSampleParameter(Parameter p) { int occurs = p.isRequired().booleanValue() ? p.getMinOccurs() : 1; - return IntStream.range(0, occurs).mapToObj(i -> buildSampleParam(i, p)).toList(); + return IntStream.range(0, occurs).mapToObj(i -> buildSampleParam(p)).toList(); } - // static Set allFunctionParamTypes = new TreeSet<>(); - - private Expression buildSampleParam(int i, Parameter p) { - // allFunctionParamTypes.add(p.getType().getCanonicalName()); + private Expression buildSampleParam(Parameter p) { Object val = p.getDefaultValue(); if (val == null) { val = sampleValue(p.getType()); diff --git a/src/catalog/plugin/src/test/java/org/geoserver/catalog/CatalogTestData.java b/src/catalog/plugin/src/test/java/org/geoserver/catalog/CatalogTestData.java index d8105763e..91b4a1681 100644 --- a/src/catalog/plugin/src/test/java/org/geoserver/catalog/CatalogTestData.java +++ b/src/catalog/plugin/src/test/java/org/geoserver/catalog/CatalogTestData.java @@ -6,8 +6,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import com.google.common.base.Function; - import lombok.Getter; import lombok.NonNull; import lombok.experimental.Accessors; @@ -45,6 +43,7 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; +import java.util.function.Function; import java.util.function.Supplier; /** @@ -211,34 +210,33 @@ public void deleteAll(Catalog catalog) { public LayerGroupInfo layerGroup1; public CatalogTestData addObjects() { - Catalog catalog = this.catalog.get(); - workspaceA = add(workspaceA, catalog::add, catalog::getWorkspace); - workspaceB = add(workspaceB, catalog::add, catalog::getWorkspace); - workspaceC = add(workspaceC, catalog::add, catalog::getWorkspace); + Catalog cat = this.catalog.get(); + workspaceA = add(workspaceA, cat::add, cat::getWorkspace); + workspaceB = add(workspaceB, cat::add, cat::getWorkspace); + workspaceC = add(workspaceC, cat::add, cat::getWorkspace); - namespaceA = add(namespaceA, catalog::add, catalog::getNamespace); - namespaceB = add(namespaceB, catalog::add, catalog::getNamespace); - namespaceC = add(namespaceC, catalog::add, catalog::getNamespace); + namespaceA = add(namespaceA, cat::add, cat::getNamespace); + namespaceB = add(namespaceB, cat::add, cat::getNamespace); + namespaceC = add(namespaceC, cat::add, cat::getNamespace); - dataStoreA = add(dataStoreA, catalog::add, catalog::getDataStore); - dataStoreB = add(dataStoreB, catalog::add, catalog::getDataStore); - dataStoreC = add(dataStoreC, catalog::add, catalog::getDataStore); + dataStoreA = add(dataStoreA, cat::add, cat::getDataStore); + dataStoreB = add(dataStoreB, cat::add, cat::getDataStore); + dataStoreC = add(dataStoreC, cat::add, cat::getDataStore); - coverageStoreA = add(coverageStoreA, catalog::add, catalog::getCoverageStore); - wmsStoreA = add(wmsStoreA, catalog::add, id -> catalog.getStore(id, WMSStoreInfo.class)); - wmtsStoreA = add(wmtsStoreA, catalog::add, id -> catalog.getStore(id, WMTSStoreInfo.class)); + coverageStoreA = add(coverageStoreA, cat::add, cat::getCoverageStore); + wmsStoreA = add(wmsStoreA, cat::add, id -> cat.getStore(id, WMSStoreInfo.class)); + wmtsStoreA = add(wmtsStoreA, cat::add, id -> cat.getStore(id, WMTSStoreInfo.class)); - featureTypeA = add(featureTypeA, catalog::add, catalog::getFeatureType); - coverageA = add(coverageA, catalog::add, catalog::getCoverage); - wmsLayerA = add(wmsLayerA, catalog::add, id -> catalog.getResource(id, WMSLayerInfo.class)); - wmtsLayerA = - add(wmtsLayerA, catalog::add, id -> catalog.getResource(id, WMTSLayerInfo.class)); + featureTypeA = add(featureTypeA, cat::add, cat::getFeatureType); + coverageA = add(coverageA, cat::add, cat::getCoverage); + wmsLayerA = add(wmsLayerA, cat::add, id -> cat.getResource(id, WMSLayerInfo.class)); + wmtsLayerA = add(wmtsLayerA, cat::add, id -> cat.getResource(id, WMTSLayerInfo.class)); - style1 = add(style1, catalog::add, catalog::getStyle); - style2 = add(style2, catalog::add, catalog::getStyle); + style1 = add(style1, cat::add, cat::getStyle); + style2 = add(style2, cat::add, cat::getStyle); - layerFeatureTypeA = add(layerFeatureTypeA, catalog::add, catalog::getLayer); - layerGroup1 = add(layerGroup1, catalog::add, catalog::getLayerGroup); + layerFeatureTypeA = add(layerFeatureTypeA, cat::add, cat::getLayer); + layerGroup1 = add(layerGroup1, cat::add, cat::getLayerGroup); return this; } @@ -512,7 +510,7 @@ public FeatureTypeInfo createFeatureType( boolean enabled) { FeatureTypeInfo fttype = getFactory().createFeatureType(); OwsUtils.set(fttype, "id", id); - fttype.setEnabled(true); + fttype.setEnabled(enabled); fttype.setName(name); fttype.setAbstract(ftAbstract); fttype.setDescription(ftDescription); @@ -523,21 +521,19 @@ public FeatureTypeInfo createFeatureType( } public void assertEqualsLenientConnectionParameters(Info info1, Info info2) { - if (info1 != null && info2 != null) { - if (info1 instanceof DataStoreInfo ds1) { - DataStoreInfo ds2 = (DataStoreInfo) info2; - Map p1 = new HashMap<>(ds1.getConnectionParameters()); - Map p2 = new HashMap<>(ds2.getConnectionParameters()); - p1.forEach( - (k, v) -> - ds1.getConnectionParameters() - .put(k, Converters.convert(v, String.class))); - p2.forEach( - (k, v) -> - ds2.getConnectionParameters() - .put(k, Converters.convert(v, String.class))); - assertEquals(ds1.getConnectionParameters(), ds2.getConnectionParameters()); - } + if (info1 != null && info2 != null && info1 instanceof DataStoreInfo ds1) { + DataStoreInfo ds2 = (DataStoreInfo) info2; + Map p1 = new HashMap<>(ds1.getConnectionParameters()); + Map p2 = new HashMap<>(ds2.getConnectionParameters()); + p1.forEach( + (k, v) -> + ds1.getConnectionParameters() + .put(k, Converters.convert(v, String.class))); + p2.forEach( + (k, v) -> + ds2.getConnectionParameters() + .put(k, Converters.convert(v, String.class))); + assertEquals(ds1.getConnectionParameters(), ds2.getConnectionParameters()); } assertEquals(info1, info2); } diff --git a/src/catalog/plugin/src/test/java/org/geoserver/catalog/faker/CatalogFaker.java b/src/catalog/plugin/src/test/java/org/geoserver/catalog/faker/CatalogFaker.java index 6e3edff7d..03363ab5b 100644 --- a/src/catalog/plugin/src/test/java/org/geoserver/catalog/faker/CatalogFaker.java +++ b/src/catalog/plugin/src/test/java/org/geoserver/catalog/faker/CatalogFaker.java @@ -311,7 +311,7 @@ public FeatureTypeInfo featureTypeInfo( boolean enabled) { FeatureTypeInfo fttype = catalogFactory().createFeatureType(); OwsUtils.set(fttype, "id", id); - fttype.setEnabled(true); + fttype.setEnabled(enabled); fttype.setName(name); fttype.setAbstract(ftAbstract); fttype.setDescription(ftDescription); @@ -403,13 +403,12 @@ public GeoServerInfo geoServerInfo() { g.setGlobalServices(true); g.setId("GeoServer.global"); g.setJAI(jaiInfo()); - // don't set lock provider to avoid a warning stack trace that the bean does not exist - // g.setLockProviderName("testLockProvider"); + // don't set lock provider with g.setLockProviderName("testLockProvider") to avoid a warning + // stack trace that the bean does not exist g.setMetadata(metadataMap("k1", Integer.valueOf(1), "k2", "2", "k3", Boolean.FALSE)); g.setResourceErrorHandling(ResourceErrorHandling.OGC_EXCEPTION_REPORT); g.setSettings(settingsInfo(null)); g.setUpdateSequence(faker().random().nextLong(1000L)); - g.setUseHeadersProxyURL(true); g.setWebUIMode(WebUIMode.DO_NOT_REDIRECT); g.setXmlExternalEntitiesEnabled(Boolean.TRUE); g.setXmlPostRequestLogBufferSize(1024); @@ -472,7 +471,6 @@ public ContactInfo contactInfo() { c.setAddressPostalCode(fakeAddress.zipCode()); c.setAddressState(fakeAddress.state()); - // c.setContactEmail(faker.hacker().); c.setContactFacsimile(faker.phoneNumber().phoneNumber()); c.setContactOrganization(faker.company().name()); c.setContactPerson(faker.name().fullName()); @@ -620,8 +618,7 @@ public CoverageDimensionInfo coverageDimensionInfo() { c.setDimensionType(SampleDimensionType.UNSIGNED_1BIT); c.setId(faker.idNumber().valid()); c.setName(faker.internet().domainName()); - c.setNullValues(Lists.newArrayList(0.0)); // , Double.NEGATIVE_INFINITY, - // Double.POSITIVE_INFINITY)); + c.setNullValues(Lists.newArrayList(0.0)); c.setRange(NumberRange.create(0.0, 255.0)); c.setUnit("unit"); return c; diff --git a/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/CatalogConformanceTest.java b/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/CatalogConformanceTest.java index 6336a086c..5851b7057 100644 --- a/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/CatalogConformanceTest.java +++ b/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/CatalogConformanceTest.java @@ -105,6 +105,7 @@ import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; +import java.io.UncheckedIOException; import java.lang.reflect.Proxy; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -115,6 +116,7 @@ import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -170,13 +172,17 @@ protected void addLayerAccessRule( } @BeforeEach - public void setUp() throws Exception { + public void setUp() { catalog = createCatalog(tmpFolder); assertNotNull( catalog.getResourceLoader(), "Catalog must be supplied with a GeoServerResourceLoader"); dd = new GeoServerDataDirectory(catalog.getResourceLoader()); - dataAccessRuleDAO = new DataAccessRuleDAO(dd, catalog); + try { + dataAccessRuleDAO = new DataAccessRuleDAO(dd, catalog); + } catch (IOException e) { + throw new UncheckedIOException(e); + } dataAccessRuleDAO.reload(); data = CatalogTestData.empty(() -> catalog, () -> null).initialize(); @@ -471,7 +477,6 @@ void testModifyNamespace() { assertEquals(data.namespaceA.getURI(), ns3.getURI()); catalog.save(ns2); - // ns3 = catalog.getNamespaceByPrefix(ns.getPrefix()); ns3 = catalog.getNamespaceByPrefix("ns2Prefix"); assertEquals(ns2, ns3); assertEquals("ns2Prefix", ns3.getPrefix()); @@ -932,13 +937,13 @@ void testModifyDataStore() { } @Test - void testChangeDataStoreWorkspace_no_resources() throws Exception { + void testChangeDataStoreWorkspace_no_resources() { addDataStore(); testChangeStoreWorkspace(data.dataStoreA); } @Test - void testChangeDataStoreWorkspaceUpdatesResourcesNamespace() throws Exception { + void testChangeDataStoreWorkspaceUpdatesResourcesNamespace() { addFeatureType(); DataStoreInfo store = data.dataStoreA; StoreInfo updated = testChangeStoreWorkspace(store); @@ -946,7 +951,7 @@ void testChangeDataStoreWorkspaceUpdatesResourcesNamespace() throws Exception { } @Test - void testChangeCoverageStoreWorkspaceUpdatesResourcesNamespace() throws Exception { + void testChangeCoverageStoreWorkspaceUpdatesResourcesNamespace() { addCoverage(); StoreInfo store = data.coverageStoreA; StoreInfo updated = testChangeStoreWorkspace(store); @@ -954,7 +959,7 @@ void testChangeCoverageStoreWorkspaceUpdatesResourcesNamespace() throws Exceptio } @Test - void testChangeWMSStoreWorkspaceUpdatesResourcesNamespace() throws Exception { + void testChangeWMSStoreWorkspaceUpdatesResourcesNamespace() { addWMSLayer(); StoreInfo store = data.wmsStoreA; StoreInfo updated = testChangeStoreWorkspace(store); @@ -962,7 +967,7 @@ void testChangeWMSStoreWorkspaceUpdatesResourcesNamespace() throws Exception { } @Test - void testChangeWTMSStoreWorkspaceUpdatesResourcesNamespace() throws Exception { + void testChangeWTMSStoreWorkspaceUpdatesResourcesNamespace() { addWMTSLayer(); StoreInfo store = data.wmtsStoreA; StoreInfo updated = testChangeStoreWorkspace(store); @@ -970,7 +975,7 @@ void testChangeWTMSStoreWorkspaceUpdatesResourcesNamespace() throws Exception { } @Test - void testChangeDataStoreWorkspace_fails_on_no_matching_namespace() throws Exception { + void testChangeDataStoreWorkspace_fails_on_no_matching_namespace() { addDataStore(); WorkspaceInfo ws2 = addWorkspace("newWorkspace"); @@ -988,7 +993,7 @@ void testChangeDataStoreWorkspace_fails_on_no_matching_namespace() throws Except } @Test - void testSaveDataStoreRollbacksStoreWhenFailsToUpdateResourcesNamespace() throws Exception { + void testSaveDataStoreRollbacksStoreWhenFailsToUpdateResourcesNamespace() { Assumptions.assumeTrue(catalog instanceof CatalogPlugin); addFeatureType(); @@ -1026,7 +1031,7 @@ void testSaveDataStoreRollbacksStoreWhenFailsToUpdateResourcesNamespace() throws } @Test - protected void testSaveDataStoreRollbacksBothStoreAndResources() throws Exception { + protected void testSaveDataStoreRollbacksBothStoreAndResources() { Assumptions.assumeTrue(catalog instanceof CatalogPlugin); addFeatureType(); @@ -1046,8 +1051,6 @@ protected void testSaveDataStoreRollbacksBothStoreAndResources() throws Exceptio addNamespace(newWorkspace.getName()); catalog = Mockito.spy((CatalogPlugin) catalog); - // make sure catalog returns resources in the expected order - // doReturn(Arrays.asList(ft, ft2)).when(catalog).getResourcesByStore(any(), any()); // let the first ft's namespace be updated, fail on the second doThrow(IllegalStateException.class) @@ -1073,7 +1076,7 @@ protected void testSaveDataStoreRollbacksBothStoreAndResources() throws Exceptio } } - private StoreInfo testChangeStoreWorkspace(StoreInfo store) throws Exception { + private StoreInfo testChangeStoreWorkspace(StoreInfo store) { WorkspaceInfo ws2 = addWorkspace("newWorkspace"); addNamespace(ws2.getName()); @@ -1533,19 +1536,13 @@ void testAddLayer() { () -> catalog.add(l2), "adding with no name should throw exception"); - // l2.setName( "l2" ); assertThrows( NullPointerException.class, () -> catalog.add(l2), "adding with no resource should throw exception"); l2.setResource(data.featureTypeA); - // try { - // catalog.add( l2 ); - // fail( "adding with no default style should throw exception"); - // } - // catch( Exception e) {} - // + l2.setDefaultStyle(data.style1); IllegalArgumentException e = @@ -1754,19 +1751,11 @@ void testModifyLayer() { addLayer(); LayerInfo l2 = catalog.getLayerByName(data.layerFeatureTypeA.getName()); - // l2.setName( null ); l2.setResource(null); LayerInfo l3 = catalog.getLayerByName(data.layerFeatureTypeA.getName()); assertEquals(data.layerFeatureTypeA.getName(), l3.getName()); - // try { - // catalog.save(l2); - // fail( "setting name to null should throw exception"); - // } - // catch( Exception e ) {} - // - // l2.setName( "changed" ); assertThrows( NullPointerException.class, () -> catalog.save(l2), @@ -1775,8 +1764,6 @@ void testModifyLayer() { l2.setResource(data.featureTypeA); catalog.save(l2); - // TODO: reinstate with resource/publishing split done - // l3 = catalog.getLayerByName( "changed" ); l3 = catalog.getLayerByName(data.featureTypeA.getName()); assertNotNull(l3); } @@ -1889,7 +1876,7 @@ void testAddStyle() { } @Test - void testAddStyleWithNameConflict() throws Exception { + void testAddStyleWithNameConflict() { addWorkspace(); addStyle(); @@ -1962,7 +1949,7 @@ void testGetStyleByNameWithWorkspace() { } @Test - void testGetStyleByNameWithWorkspace2() throws Exception { + void testGetStyleByNameWithWorkspace2() { addWorkspace(); WorkspaceInfo ws2 = catalog.getFactory().createWorkspace(); @@ -2184,7 +2171,7 @@ void testStyleEvents() { } @Test - void testProxyBehaviour() throws Exception { + void testProxyBehaviour() { testAddLayer(); // l = catalog.getLayerByName( "layerName"); @@ -2205,7 +2192,7 @@ void testProxyBehaviour() throws Exception { } @Test - void testProxyListBehaviour() throws Exception { + void testProxyListBehaviour() { catalog.add(data.style1); StyleInfo s2 = catalog.getFactory().createStyle(); @@ -2237,7 +2224,7 @@ public int compare(StyleInfo o1, StyleInfo o2) { } @Test - void testExceptionThrowingListener() throws Exception { + void testExceptionThrowingListener() { ExceptionThrowingListener l = new ExceptionThrowingListener(); catalog.addListener(l); @@ -2304,6 +2291,8 @@ void testAddWMTSStore() { * *

NOTE this actually runs now, it just takes an awful amount of time to execute. * Revisit. + * + * @throws Exception */ @Test @Disabled( @@ -2346,7 +2335,7 @@ void testGetLayerByIdWithConcurrentAdd() throws Exception { } @Test - void testAddLayerGroupNameConflict() throws Exception { + void testAddLayerGroupNameConflict() { addLayerGroup(); LayerGroupInfo lg2 = catalog.getFactory().createLayerGroup(); @@ -2480,7 +2469,6 @@ void testGetLayerGroupByNameWithWorkspace() { NamespaceInfo ns2 = factory.createNamespace(); // namespace prefix shall match workspace name, until we decide it cannot ns2.setPrefix("ns2"); - // ns2.setPrefix(ws2.getName()); ns2.setURI("http://ns2"); catalog.add(ns2); @@ -2558,7 +2546,6 @@ void testGetLayerGroups() { void testLayerGroupTitle() { addLayer(); LayerGroupInfo lg2 = catalog.getFactory().createLayerGroup(); - // lg2.setWorkspace(catalog.getDefaultWorkspace()); lg2.setName("layerGroup2"); lg2.setTitle("layerGroup2 title"); lg2.getLayers().add(data.layerFeatureTypeA); @@ -2581,7 +2568,6 @@ void testLayerGroupTitle() { void testLayerGroupAbstract() { addLayer(); LayerGroupInfo lg2 = catalog.getFactory().createLayerGroup(); - // lg2.setWorkspace(catalog.getDefaultWorkspace()); lg2.setName("layerGroup2"); lg2.setAbstract("layerGroup2 abstract"); lg2.getLayers().add(data.layerFeatureTypeA); @@ -2757,7 +2743,7 @@ void testLayerGroupRenderingLayers() { } @Test - void testRemoveLayerGroupInLayerGroup() throws Exception { + void testRemoveLayerGroupInLayerGroup() { addLayerGroup(); LayerGroupInfo lg2 = catalog.getFactory().createLayerGroup(); @@ -2869,7 +2855,7 @@ protected LayerAddRunner(CountDownLatch ready, CountDownLatch done, int idx) { this.idx = idx; } - protected void runInternal() throws Exception { + protected void runInternal() { CatalogFactory factory = catalog.getFactory(); for (int i = 0; i < GET_LAYER_BY_ID_WITH_CONCURRENT_ADD_TEST_COUNT; i++) { // GR: Adding a new feature type info too, we can't really add multiple layers per @@ -2963,9 +2949,6 @@ void testGet() { filter = equal("defaultStyle.name", s2.getName()); assertEquals(l2.getId(), catalog.get(LayerInfo.class, filter).getId()); - // Waiting for fix of MultiCompareFilterImpl.evaluate for Sets - // filter = equal("styles", l2.getStyles(), MatchAction.ALL); - // assertEquals(l2.getId(), catalog.get(LayerInfo.class, filter).getId()); filter = equal("styles.id", s2.getId(), MatchAction.ONE); assertEquals(l1.getId(), catalog.get(LayerInfo.class, filter).getId()); @@ -3093,12 +3076,11 @@ void testListPredicateExtended() { ft3.setDescription("FT3"); catalog.save(ft3); - Filter filter = acceptAll(); Set expected; Set actual; // opposite equality - filter = factory.equal(factory.literal(ft1.getId()), factory.property("id"), true); + Filter filter = factory.equal(factory.literal(ft1.getId()), factory.property("id"), true); expected = Sets.newHashSet(ft1); actual = Sets.newHashSet(catalog.list(ResourceInfo.class, filter)); assertEquals(expected, actual); @@ -3572,7 +3554,7 @@ protected FeatureTypeInfo newFeatureType(String name, DataStoreInfo ds) { } @Test - void testConcurrentCatalogModification() throws Exception { + void testConcurrentCatalogModification() throws InterruptedException, ExecutionException { Logger logger = Logging.getLogger(CatalogImpl.class); final int tasks = 8; ExecutorService executor = Executors.newFixedThreadPool(tasks / 2); diff --git a/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/CatalogFacadeExtensionAdapterTest.java b/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/CatalogFacadeExtensionAdapterTest.java index 82b1f65f1..12820e8e8 100644 --- a/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/CatalogFacadeExtensionAdapterTest.java +++ b/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/CatalogFacadeExtensionAdapterTest.java @@ -83,8 +83,4 @@ void testAdapterReplacesLegacyCatalogFacadeCatalog() { instanceOf(CatalogFacadeExtensionAdapter.SilentCatalog.class)); assertNotSame(decoratorAtFacadeConstructor, legacyFacade.getCatalog()); } - - // @Test void testQuery() { - // catalog.list(of, filter); - // } } diff --git a/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/XmlCatalogInfoLookupConformanceTest.java b/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/XmlCatalogInfoLookupConformanceTest.java index 052308c7e..721429756 100644 --- a/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/XmlCatalogInfoLookupConformanceTest.java +++ b/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/XmlCatalogInfoLookupConformanceTest.java @@ -19,7 +19,8 @@ class XmlCatalogInfoLookupConformanceTest extends CatalogConformanceTest { - protected @Override CatalogPlugin createCatalog(File tmpFolder) { + @Override + protected CatalogPlugin createCatalog(File tmpFolder) { CatalogPlugin catalog = new org.geoserver.catalog.plugin.CatalogPlugin(); XStreamPersisterFactory xpf = new XStreamPersisterFactory(); XStreamPersister codec = xpf.createXMLPersister(); @@ -56,7 +57,7 @@ class XmlCatalogInfoLookupConformanceTest extends CatalogConformanceTest { returned ft/ft2 where mockito is not throwing the expected exception """) @Override - public void testSaveDataStoreRollbacksBothStoreAndResources() throws Exception {} + public void testSaveDataStoreRollbacksBothStoreAndResources() {} @Disabled( "don't care it can't save the resourceinfo when saving a layer, it's just a demo implementation") diff --git a/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/locking/LockingCatalogTest.java b/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/locking/LockingCatalogTest.java index 47bee9251..dc4b902cb 100644 --- a/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/locking/LockingCatalogTest.java +++ b/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/locking/LockingCatalogTest.java @@ -46,14 +46,11 @@ class LockingCatalogTest { * @throws java.lang.Exception */ @BeforeEach - void setUp() throws Exception { + void setUp() { configLock = createConfigLock(); catalog = new LockingCatalog(configLock); GeoServer geoserver = new GeoServerImpl(); geoserver.setCatalog(catalog); - // GeoServerResourceLoader resourceLoader; - // XStreamPersister xstreamPersister; - // catalog.addListener(new GeoServerConfigPersister(resourceLoader, xstreamPersister)); faker = new CatalogFaker(catalog, geoserver); } diff --git a/src/catalog/plugin/src/test/java/org/geoserver/config/GeoServerConfigConformanceTest.java b/src/catalog/plugin/src/test/java/org/geoserver/config/GeoServerConfigConformanceTest.java index ff046ccd3..c220971a8 100644 --- a/src/catalog/plugin/src/test/java/org/geoserver/config/GeoServerConfigConformanceTest.java +++ b/src/catalog/plugin/src/test/java/org/geoserver/config/GeoServerConfigConformanceTest.java @@ -38,7 +38,7 @@ public abstract class GeoServerConfigConformanceTest { protected GeoServer geoServer; @BeforeEach - public void setUp() throws Exception { + public void setUp() { geoServer = createGeoServer(); } @@ -56,7 +56,7 @@ protected ServiceInfo createService() { } @Test - void testGlobal() throws Exception { + void testGlobal() { GeoServerInfo global = geoServer.getFactory().createGlobal(); geoServer.setGlobal(global); @@ -66,7 +66,7 @@ void testGlobal() throws Exception { // GEOS-7890 @Test - void testEquals() throws Exception { + void testEquals() { GeoServerInfo global1 = geoServer.getFactory().createGlobal(); GeoServerInfo global2 = geoServer.getFactory().createGlobal(); global1.setGlobalServices(Boolean.valueOf(true)); @@ -82,7 +82,7 @@ void testEquals() throws Exception { } @Test - void testModifyGlobal() throws Exception { + void testModifyGlobal() { GeoServerInfo global = geoServer.getFactory().createGlobal(); geoServer.setGlobal(global); @@ -98,7 +98,7 @@ void testModifyGlobal() throws Exception { } @Test - void testAddService() throws Exception { + void testAddService() { ServiceInfo service = createService(); service.setName("wms"); geoServer.add(service); @@ -122,7 +122,7 @@ void testAddService() throws Exception { } @Test - void testModifyService() throws Exception { + void testModifyService() { ServiceInfo service = createService(); ((ServiceInfoImpl) service).setId("id"); service.setName("wms"); @@ -142,7 +142,7 @@ void testModifyService() throws Exception { } @Test - void testGlobalEvents() throws Exception { + void testGlobalEvents() { TestListener tl = new TestListener(); geoServer.addListener(tl); @@ -195,7 +195,7 @@ public void handleServiceChange( } @Test - void testSetClientPropsHasEffect() throws Exception { + void testSetClientPropsHasEffect() { GeoServerInfoImpl gsii = new GeoServerInfoImpl(geoServer); Map before = gsii.getClientProperties(); @@ -207,7 +207,7 @@ void testSetClientPropsHasEffect() throws Exception { } @Test - void testGetSettings() throws Exception { + void testGetSettings() { GeoServerInfo global = geoServer.getFactory().createGlobal(); geoServer.setGlobal(global); @@ -239,7 +239,7 @@ void testGetSettings() throws Exception { } @Test - void testModifySettings() throws Exception { + void testModifySettings() { WorkspaceInfo ws = geoServer.getCatalog().getFactory().createWorkspace(); ws.setName("acme"); geoServer.getCatalog().add(ws); @@ -264,7 +264,7 @@ void testModifySettings() throws Exception { @SuppressWarnings("unchecked") @Test - void testServiceWithWorkspace() throws Exception { + void testServiceWithWorkspace() { // Make a workspace WorkspaceInfo ws1 = geoServer.getCatalog().getFactory().createWorkspace(); ws1.setName("TEST-WORKSPACE-1"); diff --git a/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/backend/GwcCoreAutoConfigurationTest.java b/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/backend/GwcCoreAutoConfigurationTest.java index cabba08ad..8dd3888b7 100644 --- a/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/backend/GwcCoreAutoConfigurationTest.java +++ b/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/backend/GwcCoreAutoConfigurationTest.java @@ -35,11 +35,8 @@ class GwcCoreAutoConfigurationTest { @TempDir File tmpDir; WebApplicationContextRunner runner; - /** - * @throws java.lang.Exception - */ @BeforeEach - void setUp() throws Exception { + void setUp() { runner = GeoWebCacheContextRunner.newMinimalGeoWebCacheContextRunner(tmpDir); } @@ -64,7 +61,7 @@ void defaultCacheDirectoryIsAFile() throws IOException { } @Test - void contextLoads() throws IOException { + void contextLoads() { runner.run( context -> { assertThat(context.isTypeMatch("gwcXmlConfig", CloudGwcXmlConfiguration.class)) diff --git a/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/backend/PgconfigTileLayerCatalogAutoConfigurationTest.java b/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/backend/PgconfigTileLayerCatalogAutoConfigurationTest.java index 6740cc22c..37196af5f 100644 --- a/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/backend/PgconfigTileLayerCatalogAutoConfigurationTest.java +++ b/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/backend/PgconfigTileLayerCatalogAutoConfigurationTest.java @@ -48,16 +48,13 @@ class PgconfigTileLayerCatalogAutoConfigurationTest { private WebApplicationContextRunner runner; @BeforeAll - static void setUpBeforeClass() throws Exception {} + static void setUpBeforeClass() {} @AfterAll - static void tearDownAfterClass() throws Exception {} + static void tearDownAfterClass() {} - /** - * @throws java.lang.Exception - */ @BeforeEach - void setUp() throws Exception { + void setUp() { runner = GeoWebCacheContextRunner.newMinimalGeoWebCacheContextRunner(cacheDir) .withConfiguration( @@ -71,7 +68,7 @@ void setUp() throws Exception { } @AfterEach - void tearDown() throws Exception { + void tearDown() { container.tearDown(); } diff --git a/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/blobstore/AzureBlobstoreAutoConfigurationTest.java b/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/blobstore/AzureBlobstoreAutoConfigurationTest.java index ccf8f4d3c..647a37960 100644 --- a/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/blobstore/AzureBlobstoreAutoConfigurationTest.java +++ b/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/blobstore/AzureBlobstoreAutoConfigurationTest.java @@ -31,7 +31,7 @@ class AzureBlobstoreAutoConfigurationTest { @TempDir File tmpDir; @BeforeEach - void setUp() throws Exception { + void setUp() { runner = GeoWebCacheContextRunner.newMinimalGeoWebCacheContextRunner(tmpDir) .withConfiguration( diff --git a/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/blobstore/S3BlobstoreAutoConfigurationTest.java b/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/blobstore/S3BlobstoreAutoConfigurationTest.java index ea8c6a5d8..fdfca5ca9 100644 --- a/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/blobstore/S3BlobstoreAutoConfigurationTest.java +++ b/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/blobstore/S3BlobstoreAutoConfigurationTest.java @@ -31,7 +31,7 @@ class S3BlobstoreAutoConfigurationTest { @TempDir File tmpDir; @BeforeEach - void setUp() throws Exception { + void setUp() { runner = GeoWebCacheContextRunner.newMinimalGeoWebCacheContextRunner(tmpDir) .withConfiguration( diff --git a/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/integration/WMSIntegrationAutoConfigurationTest.java b/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/integration/WMSIntegrationAutoConfigurationTest.java index ccd46ab79..e3c7c95b5 100644 --- a/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/integration/WMSIntegrationAutoConfigurationTest.java +++ b/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/integration/WMSIntegrationAutoConfigurationTest.java @@ -33,11 +33,8 @@ class WMSIntegrationAutoConfigurationTest { @TempDir File tmpDir; WebApplicationContextRunner runner; - /** - * @throws java.lang.Exception - */ @BeforeEach - void setUp() throws Exception { + void setUp() { runner = GeoWebCacheContextRunner.newMinimalGeoWebCacheContextRunner(tmpDir) .withConfiguration( diff --git a/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/service/RESTConfigAutoConfigurationTest.java b/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/service/RESTConfigAutoConfigurationTest.java index 94e7400b9..422eb23dc 100644 --- a/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/service/RESTConfigAutoConfigurationTest.java +++ b/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/service/RESTConfigAutoConfigurationTest.java @@ -28,11 +28,8 @@ class RESTConfigAutoConfigurationTest { @TempDir File tmpDir; WebApplicationContextRunner runner; - /** - * @throws java.lang.Exception - */ @BeforeEach - void setUp() throws Exception { + void setUp() { runner = GeoWebCacheContextRunner.newMinimalGeoWebCacheContextRunner(tmpDir) .withConfiguration( diff --git a/src/gwc/backends/pgconfig/src/test/java/org/geoserver/cloud/gwc/backend/pgconfig/PgconfigTileLayerCatalogIT.java b/src/gwc/backends/pgconfig/src/test/java/org/geoserver/cloud/gwc/backend/pgconfig/PgconfigTileLayerCatalogIT.java index ebec8ca43..1a6aebe3d 100644 --- a/src/gwc/backends/pgconfig/src/test/java/org/geoserver/cloud/gwc/backend/pgconfig/PgconfigTileLayerCatalogIT.java +++ b/src/gwc/backends/pgconfig/src/test/java/org/geoserver/cloud/gwc/backend/pgconfig/PgconfigTileLayerCatalogIT.java @@ -48,7 +48,7 @@ class PgconfigTileLayerCatalogIT { private PgconfigTileLayerCatalog tlCatalog; @BeforeEach - void setUp() throws Exception { + void setUp() { container.setUp(); PgconfigBackendBuilder backendBuilder = new PgconfigBackendBuilder(container.getDataSource()); @@ -61,7 +61,7 @@ void setUp() throws Exception { } @AfterEach - void cleanDb() throws Exception { + void cleanDb() { container.tearDown(); LocalWorkspace.remove(); } diff --git a/src/gwc/blobstores/src/test/java/org/geoserver/cloud/gwc/config/blobstore/AzureBlobStoreTest.java b/src/gwc/blobstores/src/test/java/org/geoserver/cloud/gwc/config/blobstore/AzureBlobStoreTest.java index e21965485..eec97c568 100644 --- a/src/gwc/blobstores/src/test/java/org/geoserver/cloud/gwc/config/blobstore/AzureBlobStoreTest.java +++ b/src/gwc/blobstores/src/test/java/org/geoserver/cloud/gwc/config/blobstore/AzureBlobStoreTest.java @@ -53,7 +53,6 @@ protected AzureBlobStoreInfo newAzureBlobStoreInfo() { bsi.setContainer("azureblobstoretest"); bsi.setName("AzureBlobStoreTest"); bsi.setEnabled(true); - // bsi.setPrefix("/gwc/"); return bsi; } diff --git a/src/gwc/blobstores/src/test/java/org/geoserver/cloud/gwc/config/blobstore/AzureBlobStoreXmlConfigurationTest.java b/src/gwc/blobstores/src/test/java/org/geoserver/cloud/gwc/config/blobstore/AzureBlobStoreXmlConfigurationTest.java index 17f81a5f8..e13dda9d2 100644 --- a/src/gwc/blobstores/src/test/java/org/geoserver/cloud/gwc/config/blobstore/AzureBlobStoreXmlConfigurationTest.java +++ b/src/gwc/blobstores/src/test/java/org/geoserver/cloud/gwc/config/blobstore/AzureBlobStoreXmlConfigurationTest.java @@ -16,6 +16,7 @@ import org.geoserver.cloud.gwc.event.BlobStoreEvent; import org.geoserver.cloud.gwc.event.GeoWebCacheEvent; import org.geoserver.cloud.gwc.repository.CloudGwcXmlConfiguration; +import org.geowebcache.GeoWebCacheException; import org.geowebcache.azure.AzureBlobStoreInfo; import org.geowebcache.config.BlobStoreConfigurationListener; import org.geowebcache.config.BlobStoreInfo; @@ -29,6 +30,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; @@ -49,7 +51,7 @@ class AzureBlobStoreXmlConfigurationTest { private final DefaultGridsets defaultGridsets = new DefaultGridsets(false, false); @BeforeEach - void setUp() throws Exception { + void setUp() throws IOException, GeoWebCacheException { mockEventPublisher = new AtomicReference<>(); configFile = tmpdir.resolve("geowebcache.xml"); @@ -58,7 +60,7 @@ void setUp() throws Exception { config = createStubConfig(); } - private CloudGwcXmlConfiguration createStubConfig() throws Exception { + private CloudGwcXmlConfiguration createStubConfig() throws GeoWebCacheException { ApplicationContextProvider appCtx = mock(ApplicationContextProvider.class); ConfigurationResourceProvider inFac = diff --git a/src/gwc/core/src/test/java/org/geoserver/cloud/gwc/repository/CloudGwcXmlConfigurationTest.java b/src/gwc/core/src/test/java/org/geoserver/cloud/gwc/repository/CloudGwcXmlConfigurationTest.java index a7e68f990..016202eef 100644 --- a/src/gwc/core/src/test/java/org/geoserver/cloud/gwc/repository/CloudGwcXmlConfigurationTest.java +++ b/src/gwc/core/src/test/java/org/geoserver/cloud/gwc/repository/CloudGwcXmlConfigurationTest.java @@ -19,6 +19,7 @@ import org.geoserver.cloud.gwc.event.BlobStoreEvent; import org.geoserver.cloud.gwc.event.GeoWebCacheEvent; import org.geoserver.cloud.gwc.event.GridsetEvent; +import org.geowebcache.GeoWebCacheException; import org.geowebcache.config.BlobStoreConfigurationListener; import org.geowebcache.config.BlobStoreInfo; import org.geowebcache.config.ConfigurationResourceProvider; @@ -33,6 +34,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; @@ -54,7 +56,7 @@ class CloudGwcXmlConfigurationTest { private final DefaultGridsets defaultGridsets = new DefaultGridsets(false, false); @BeforeEach - void setUp() throws Exception { + void setUp() throws IOException, GeoWebCacheException { mockEventPublisher = new AtomicReference<>(); configFile = tmpdir.resolve("geowebcache.xml"); @@ -63,7 +65,7 @@ void setUp() throws Exception { config = createStubConfig(); } - private CloudGwcXmlConfiguration createStubConfig() throws Exception { + private CloudGwcXmlConfiguration createStubConfig() throws GeoWebCacheException { ApplicationContextProvider appCtx = mock(ApplicationContextProvider.class); ConfigurationResourceProvider inFac = diff --git a/src/gwc/core/src/test/java/org/geoserver/cloud/gwc/repository/ResourceStoreTileLayerCatalogTest.java b/src/gwc/core/src/test/java/org/geoserver/cloud/gwc/repository/ResourceStoreTileLayerCatalogTest.java index a5e22cc88..2d1e8c191 100644 --- a/src/gwc/core/src/test/java/org/geoserver/cloud/gwc/repository/ResourceStoreTileLayerCatalogTest.java +++ b/src/gwc/core/src/test/java/org/geoserver/cloud/gwc/repository/ResourceStoreTileLayerCatalogTest.java @@ -11,9 +11,6 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import com.google.common.collect.ImmutableSet; - -import org.apache.commons.io.FileUtils; import org.geoserver.catalog.impl.ModificationProxy; import org.geoserver.gwc.layer.GeoServerTileLayerInfo; import org.geoserver.gwc.layer.GeoServerTileLayerInfoImpl; @@ -28,7 +25,6 @@ import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashSet; @@ -48,7 +44,7 @@ class ResourceStoreTileLayerCatalogTest { private ResourceStoreTileLayerCatalog catalog; @BeforeEach - void setUp() throws Exception { + void setUp() { resourceLoader = new GeoServerResourceLoader(baseDirectory); new File(baseDirectory, "gwc-layers").mkdir(); Optional webappCtx = Optional.empty(); @@ -118,14 +114,14 @@ void testSave() { final GeoServerTileLayerInfo oldValue = catalog.save(original); assertNotNull(oldValue); - assertEquals(ImmutableSet.of("image/png", "image/jpeg"), oldValue.getMimeFormats()); + assertEquals(Set.of("image/png", "image/jpeg"), oldValue.getMimeFormats()); assertEquals("name1", oldValue.getName()); assertNull(catalog.getLayerByName("name1")); assertNotNull(catalog.getLayerByName("name2")); GeoServerTileLayerInfo modified = catalog.getLayerById("id1"); - assertEquals(ImmutableSet.of("image/gif"), modified.getMimeFormats()); + assertEquals(Set.of("image/gif"), modified.getMimeFormats()); } @Test @@ -162,7 +158,7 @@ void testSaveWithEmptyStyleParamFilter() { assertNotNull(catalog.getLayerByName("name2")); GeoServerTileLayerInfo modified = catalog.getLayerById("id1"); - assertEquals(ImmutableSet.of("image/gif"), modified.getMimeFormats()); + assertEquals(Set.of("image/gif"), modified.getMimeFormats()); } @Test @@ -219,7 +215,7 @@ void testEvents() throws IOException, InterruptedException { } @Test - void testSavedXML() throws Exception { + void testSavedXML() { // checking that the persistence looks as expected final GeoServerTileLayerInfo original; { @@ -246,9 +242,8 @@ void testSavedXML() throws Exception { catalog.save(original); - File file = new File(baseDirectory, "gwc-layers/id1.xml"); - String xml = FileUtils.readFileToString(file, StandardCharsets.UTF_8); - + // File file = new File(baseDirectory, "gwc-layers/id1.xml"); + // String xml = FileUtils.readFileToString(file, StandardCharsets.UTF_8); // XPathEngine xpath = XMLUnit.newXpathEngine(); // Document doc = XMLUnit.buildControlDocument(xml); // // no custom attribute for the class, we set a default diff --git a/src/library/spring-boot-simplejndi/src/test/java/org/geoserver/cloud/config/jndi/SimpleJNDIStaticContextInitializerTest.java b/src/library/spring-boot-simplejndi/src/test/java/org/geoserver/cloud/config/jndi/SimpleJNDIStaticContextInitializerTest.java index f5958ed85..913a0e282 100644 --- a/src/library/spring-boot-simplejndi/src/test/java/org/geoserver/cloud/config/jndi/SimpleJNDIStaticContextInitializerTest.java +++ b/src/library/spring-boot-simplejndi/src/test/java/org/geoserver/cloud/config/jndi/SimpleJNDIStaticContextInitializerTest.java @@ -14,7 +14,6 @@ import javax.naming.Context; import javax.naming.InitialContext; -import javax.naming.NamingException; import javax.naming.spi.NamingManager; /** @@ -27,7 +26,7 @@ class SimpleJNDIStaticContextInitializerTest { .withInitializer(new SimpleJNDIStaticContextInitializer()); @Test - void test() throws NamingException { + void test() { runner.run( context -> { InitialContext initialContext = new InitialContext(); diff --git a/src/library/spring-factory/src/test/java/org/geoserver/cloud/config/factory/FilteringXmlBeanDefinitionReaderTest.java b/src/library/spring-factory/src/test/java/org/geoserver/cloud/config/factory/FilteringXmlBeanDefinitionReaderTest.java index 07fe103d9..6add36b8d 100644 --- a/src/library/spring-factory/src/test/java/org/geoserver/cloud/config/factory/FilteringXmlBeanDefinitionReaderTest.java +++ b/src/library/spring-factory/src/test/java/org/geoserver/cloud/config/factory/FilteringXmlBeanDefinitionReaderTest.java @@ -96,13 +96,6 @@ void excludeAllEndingWithProviderOrStartingWithFilter() { verify(location, "geoServer"); } - @Test - void excludeByIdAttribute() { - String location = - "%s#name=^(?!nullLockProvider|memoryLockProvider).*$".formatted(baseResource); - verify(location, "filterFactory", "geoServer"); - } - @Test void excludeByNameAttribute() { String location = "%s#name=^(?!filterFactory|geoServer).*$".formatted(baseResource); diff --git a/src/starters/wms-extensions/src/test/java/org/geoserver/cloud/autoconfigure/wms/extensions/CssStylingConfigurationTest.java b/src/starters/wms-extensions/src/test/java/org/geoserver/cloud/autoconfigure/wms/extensions/CssStylingConfigurationTest.java index bda5779a9..ee6f4fa24 100644 --- a/src/starters/wms-extensions/src/test/java/org/geoserver/cloud/autoconfigure/wms/extensions/CssStylingConfigurationTest.java +++ b/src/starters/wms-extensions/src/test/java/org/geoserver/cloud/autoconfigure/wms/extensions/CssStylingConfigurationTest.java @@ -45,7 +45,7 @@ void cssHandler_disabled_registers_module_status() { .withBean("sldHandler", SLDHandler.class) .withPropertyValues("geoserver.styling.css.enabled=false") .run( - (context) -> { + context -> { assertThat(context).doesNotHaveBean(CssHandler.class); assertThat(context).hasBean("cssDisabledModuleStatus"); assertThat(context) @@ -59,7 +59,7 @@ void cssHandler_conditional_on_sldHandler() { contextRunner .withPropertyValues("geoserver.styling.css.enabled=true") .run( - (context) -> { + context -> { assertThat(context).doesNotHaveBean(SLDHandler.class); assertThat(context).doesNotHaveBean(CssHandler.class); assertThat(context).doesNotHaveBean("cssDisabledModuleStatus");