-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gwc - handles workspace-based paths (#380)
- Loading branch information
Showing
12 changed files
with
513 additions
and
20 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
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
51 changes: 51 additions & 0 deletions
51
src/catalog/plugin/src/test/java/org/geoserver/catalog/GeoServerCatalogTestData.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,51 @@ | ||
/* | ||
* (c) 2024 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; | ||
|
||
import lombok.experimental.UtilityClass; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.geotools.test.TestData; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URISyntaxException; | ||
import java.nio.file.Path; | ||
|
||
/** | ||
* The purpose of this class is to provide a geoserver datadir which is not fake (it is actually a | ||
* copy of the one from GeoServer upstream), which could be used for testing. | ||
* | ||
* <p>It copies a zip file into a directory - generally a temporary one - an unzip it, so that it is | ||
* ready for use. | ||
*/ | ||
@UtilityClass | ||
public class GeoServerCatalogTestData { | ||
|
||
/** | ||
* This method copies the zipped datadir into the Path object given as argument and unzip it at | ||
* the same place. | ||
* | ||
* <p>It is the caller's responsability to clean up when the datadir is not needed anymore. | ||
* | ||
* <p>Note: we have to copy the resource into the directory first, because the method from | ||
* GeoTools which is being used does not support zip URIs nested into jar files. | ||
* | ||
* @param tmpPath the temporary path where the datadir has to be unzipped to. | ||
* @throws URISyntaxException | ||
* @throws IOException | ||
*/ | ||
public static void unzipGeoserverCatalogTestData(Path tmpPath) | ||
throws URISyntaxException, IOException { | ||
InputStream zippedDatadir = | ||
GeoServerCatalogTestData.class.getResourceAsStream("/test-data-directory.zip"); | ||
File tmpDir = tmpPath.toFile(); | ||
File destFile = new File(tmpDir, "test-data-directory.zip"); | ||
FileUtils.copyToFile(zippedDatadir, destFile); | ||
TestData.unzip(destFile, tmpDir); | ||
destFile.delete(); | ||
} | ||
} |
Binary file not shown.
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
42 changes: 42 additions & 0 deletions
42
...ava/org/geoserver/cloud/autoconfigure/gwc/web/gwc/GeoWebCacheUIAutoConfigurationTest.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,42 @@ | ||
/* | ||
* (c) 2024 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.cloud.autoconfigure.gwc.web.gwc; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import org.geoserver.cloud.autoconfigure.gwc.GeoWebCacheContextRunner; | ||
import org.geoserver.cloud.autoconfigure.web.gwc.GeoWebCacheUIAutoConfiguration; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
import org.springframework.boot.autoconfigure.AutoConfigurations; | ||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner; | ||
|
||
import java.io.File; | ||
|
||
public class GeoWebCacheUIAutoConfigurationTest { | ||
|
||
WebApplicationContextRunner runner; | ||
|
||
@TempDir File tmpDir; | ||
|
||
@BeforeEach | ||
void setUp() throws Exception { | ||
runner = | ||
GeoWebCacheContextRunner.newMinimalGeoWebCacheContextRunner(tmpDir) | ||
.withPropertyValues("gwc.web-ui=true") | ||
.withConfiguration( | ||
AutoConfigurations.of(GeoWebCacheUIAutoConfiguration.class)); | ||
} | ||
|
||
@Test | ||
void beansForLocalWorkspacePathsHandlingArePresent() { | ||
runner.run( | ||
context -> { | ||
assertNotNull(context.getBean("gwcDemoUrlHandlerMapping")); | ||
assertNotNull(context.getBean("gwcRestWebUrlHandlerMapping")); | ||
}); | ||
} | ||
} |
Oops, something went wrong.