-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEOS-11284] Load DataDirectoryGeoServerLoader through GeoserverLoade…
…rProxy Let GeoServerLoaderProxy decide whether to instantiate a DefaultGeoServerLoader or a DataDirectoryGeoServerLoader based on externalized configuration, and remove the spring @configuration class for DataDirectoryGeoServerLoader. This preserves the behavior of allowing only one GeoServerLoader bean contributed by an external plugin. Otherwise the jdcconfig one would fail.
- Loading branch information
Showing
8 changed files
with
138 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 0 additions & 81 deletions
81
.../src/main/java/org/geoserver/catalog/datadir/config/DataDirectoryLoaderConfiguration.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...c/test/java/org/geoserver/catalog/datadir/DataDirectoryGeoServerLoaderEnablementTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* (c) 2022 Open Source Geospatial Foundation - all rights reserved | ||
* This code is licensed under the GPL 2.0 license, available at the root | ||
* application directory. | ||
*/ | ||
package org.geoserver.catalog.datadir; | ||
|
||
import static org.geoserver.catalog.datadir.DataDirectoryGeoServerLoader.ENVVAR_KEY; | ||
import static org.geoserver.catalog.datadir.DataDirectoryGeoServerLoader.SYSPROP_KEY; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import org.geoserver.platform.GeoServerExtensionsHelper; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.core.env.Environment; | ||
|
||
public class DataDirectoryGeoServerLoaderEnablementTest { | ||
|
||
@Before | ||
public void setup() { | ||
GeoServerExtensionsHelper.setIsSpringContext(false); | ||
} | ||
|
||
@After | ||
public void destroyAppContext() { | ||
GeoServerExtensionsHelper.init(null); | ||
} | ||
|
||
@Test | ||
public void testEnabledByDefault() { | ||
assertTrue(DataDirectoryGeoServerLoader.isEnabled(null)); | ||
} | ||
|
||
@Test | ||
public void testEnabled() { | ||
GeoServerExtensionsHelper.property(SYSPROP_KEY, "true"); | ||
assertTrue(DataDirectoryGeoServerLoader.isEnabled(null)); | ||
} | ||
|
||
@Test | ||
public void testDisabledWithSystemProperty() { | ||
GeoServerExtensionsHelper.property(SYSPROP_KEY, "false"); | ||
assertFalse(DataDirectoryGeoServerLoader.isEnabled(null)); | ||
} | ||
|
||
@Test | ||
public void testDisabledWithEnvVariable() { | ||
GeoServerExtensionsHelper.property(ENVVAR_KEY, "false"); | ||
assertFalse(DataDirectoryGeoServerLoader.isEnabled(null)); | ||
} | ||
|
||
@Test | ||
public void testDisabledWithAppContextEnvironment() { | ||
ApplicationContext appContext = mock(ApplicationContext.class); | ||
Environment env = mock(Environment.class); | ||
when(appContext.getEnvironment()).thenReturn(env); | ||
when(env.getProperty(ENVVAR_KEY)).thenReturn("false"); | ||
assertFalse(DataDirectoryGeoServerLoader.isEnabled(appContext)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.