From 5642713c8b328e0a39a7d6cec571c2a0f305b305 Mon Sep 17 00:00:00 2001 From: Peter Smythe Date: Mon, 1 Sep 2025 20:45:18 +0200 Subject: [PATCH 1/2] Fix loadFromEmptyReadOnlyDirectoryFails test which fails when building gwc-release (Docker) on Windows --- .../config/XMLConfigurationTest.java | 45 +++++++++++++------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java index 9511050db7..0e7241ed0a 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java @@ -578,18 +578,35 @@ public void loadFromReadOnlyDirectory() throws GeoWebCacheException { } } - @Test - public void loadFromEmptyReadOnlyDirectoryFails() throws GeoWebCacheException, IOException { - File roEmptyDir = this.temp.newFolder(); - Assume.assumeTrue( - "Ignore if setWritable(false) does not succeed, may happen on Windows", roEmptyDir.setWritable(false)); - try { - config = new XMLConfiguration(null, roEmptyDir.getAbsolutePath()); - config.setGridSetBroker(gridSetBroker); - - assertThrows(ConfigurationException.class, () -> config.afterPropertiesSet()); - } finally { - roEmptyDir.setWritable(true); - } - } + @Test + public void loadFromEmptyReadOnlyDirectoryFails() throws GeoWebCacheException, IOException { + File roEmptyDir = this.temp.newFolder(); + + // Try to make it read-only + roEmptyDir.setWritable(false); + + // Actively probe whether the directory is still writable (for gwc-release Docker on Windows) + File probe = new File(roEmptyDir, "probe"); + boolean canWrite; + try { + canWrite = probe.createNewFile(); + if (canWrite) { + probe.delete(); + } + } catch (IOException e) { + canWrite = false; + } + + // Skip if we can still write, this may happen on Windows + Assume.assumeTrue("Skipping: directory is still writable", !canWrite); + + try { + config = new XMLConfiguration(null, roEmptyDir.getAbsolutePath()); + config.setGridSetBroker(gridSetBroker); + + assertThrows(ConfigurationException.class, () -> config.afterPropertiesSet()); + } finally { + roEmptyDir.setWritable(true); + } + } } From fd92b30f1781559442d4d8921031ff60580940ac Mon Sep 17 00:00:00 2001 From: Peter Smythe Date: Mon, 1 Sep 2025 20:49:14 +0200 Subject: [PATCH 2/2] mvn spotless:apply --- .../config/XMLConfigurationTest.java | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java index 0e7241ed0a..3b31511163 100644 --- a/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java +++ b/geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java @@ -578,35 +578,35 @@ public void loadFromReadOnlyDirectory() throws GeoWebCacheException { } } - @Test - public void loadFromEmptyReadOnlyDirectoryFails() throws GeoWebCacheException, IOException { - File roEmptyDir = this.temp.newFolder(); - - // Try to make it read-only - roEmptyDir.setWritable(false); - - // Actively probe whether the directory is still writable (for gwc-release Docker on Windows) - File probe = new File(roEmptyDir, "probe"); - boolean canWrite; - try { - canWrite = probe.createNewFile(); - if (canWrite) { - probe.delete(); - } - } catch (IOException e) { - canWrite = false; - } - - // Skip if we can still write, this may happen on Windows - Assume.assumeTrue("Skipping: directory is still writable", !canWrite); - - try { - config = new XMLConfiguration(null, roEmptyDir.getAbsolutePath()); - config.setGridSetBroker(gridSetBroker); - - assertThrows(ConfigurationException.class, () -> config.afterPropertiesSet()); - } finally { - roEmptyDir.setWritable(true); - } - } + @Test + public void loadFromEmptyReadOnlyDirectoryFails() throws GeoWebCacheException, IOException { + File roEmptyDir = this.temp.newFolder(); + + // Try to make it read-only + roEmptyDir.setWritable(false); + + // Actively probe whether the directory is still writable (for gwc-release Docker on Windows) + File probe = new File(roEmptyDir, "probe"); + boolean canWrite; + try { + canWrite = probe.createNewFile(); + if (canWrite) { + probe.delete(); + } + } catch (IOException e) { + canWrite = false; + } + + // Skip if we can still write, this may happen on Windows + Assume.assumeTrue("Skipping: directory is still writable", !canWrite); + + try { + config = new XMLConfiguration(null, roEmptyDir.getAbsolutePath()); + config.setGridSetBroker(gridSetBroker); + + assertThrows(ConfigurationException.class, () -> config.afterPropertiesSet()); + } finally { + roEmptyDir.setWritable(true); + } + } }