Skip to content

Commit

Permalink
test: fix sonarqube issues and add reload integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
buehner committed Oct 21, 2024
1 parent 0faeec7 commit 219e86f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ static void properties(DynamicPropertyRegistry registry) {

@BeforeAll
static void setUpRemoteApplicationContext() {

remoteAppContext =
new SpringApplicationBuilder(
TestConfigurationAutoConfiguration.class, BusEventCollector.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.geoserver.cloud.event.bus;

import org.geoserver.cloud.event.lifecycle.LifecycleEvent;
import org.geoserver.cloud.event.lifecycle.ReloadEvent;
import org.geoserver.cloud.event.lifecycle.ResetEvent;
import org.geoserver.config.GeoServer;
import org.geoserver.platform.GeoServerExtensions;
Expand All @@ -29,9 +30,29 @@ void testGeoServerHasExecutedReset() {
Consumer<GeoServer> modifier = GeoServer::reset;
modifier.accept(geoserver);

RemoteGeoServerEvent localRemoteEvent =
eventsCaptor.local().expectOneLifecycleEvent(ResetEvent.class);
RemoteGeoServerEvent sentEvent =
eventsCaptor.remote().expectOneLifecycleEvent(ResetEvent.class);
eventsCaptor.local().expectOneLifecycleEvent(ResetEvent.class);
eventsCaptor.remote().expectOneLifecycleEvent(ResetEvent.class);
}

@Test
void testGeoServerHasExecutedReload() {

this.eventsCaptor.stop().clear().captureLifecycleEventsOf(LifecycleEvent.class).start();

Consumer<GeoServer> modifier =
geoServer -> {
try {
geoServer.reload();
} catch (Exception e) {
throw new RuntimeException(e);
}
};
modifier.accept(geoserver);

// reload also triggers reset!
eventsCaptor.local().expectOneLifecycleEvent(ReloadEvent.class);
eventsCaptor.local().expectOneLifecycleEvent(ResetEvent.class);
eventsCaptor.remote().expectOneLifecycleEvent(ReloadEvent.class);
eventsCaptor.remote().expectOneLifecycleEvent(ResetEvent.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@

import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.plugin.CatalogPlugin;
import org.geoserver.config.DefaultGeoServerLoader;
import org.geoserver.config.GeoServer;
import org.geoserver.config.GeoServerLoader;
import org.geoserver.config.plugin.GeoServerImpl;
import org.geoserver.config.util.XStreamPersisterFactory;
import org.geoserver.platform.GeoServerResourceLoader;
import org.geoserver.platform.config.DefaultUpdateSequence;
import org.geoserver.platform.config.UpdateSequence;
import org.springframework.beans.factory.annotation.Qualifier;
Expand Down Expand Up @@ -41,4 +44,18 @@ GeoServer geoServer(@Qualifier("catalog") Catalog catalog) {
gs.setCatalog(catalog);
return gs;
}

@Bean
GeoServerResourceLoader geoServerResourceLoader() {
return new GeoServerResourceLoader();
}

@Bean
GeoServerLoader geoserverLoader(
@Qualifier("geoServer") GeoServer geoServer,
@Qualifier("geoServerResourceLoader") GeoServerResourceLoader geoServerResourceLoader) {
DefaultGeoServerLoader loader = new DefaultGeoServerLoader(geoServerResourceLoader);
loader.postProcessBeforeInitialization(geoServer, "geoserver");
return loader;
}
}

0 comments on commit 219e86f

Please sign in to comment.