Skip to content

Commit c2f73e7

Browse files
authored
Merge pull request #1426 from GeoWebCache/backport-1425-to-1.27.x
[Backport 1.27.x] Fix loadFromEmptyReadOnlyDirectoryFails test
2 parents ef6d142 + fd92b30 commit c2f73e7

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

geowebcache/core/src/test/java/org/geowebcache/config/XMLConfigurationTest.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,25 @@ public void loadFromReadOnlyDirectory() throws GeoWebCacheException {
581581
@Test
582582
public void loadFromEmptyReadOnlyDirectoryFails() throws GeoWebCacheException, IOException {
583583
File roEmptyDir = this.temp.newFolder();
584-
Assume.assumeTrue(
585-
"Ignore if setWritable(false) does not succeed, may happen on Windows", roEmptyDir.setWritable(false));
584+
585+
// Try to make it read-only
586+
roEmptyDir.setWritable(false);
587+
588+
// Actively probe whether the directory is still writable (for gwc-release Docker on Windows)
589+
File probe = new File(roEmptyDir, "probe");
590+
boolean canWrite;
591+
try {
592+
canWrite = probe.createNewFile();
593+
if (canWrite) {
594+
probe.delete();
595+
}
596+
} catch (IOException e) {
597+
canWrite = false;
598+
}
599+
600+
// Skip if we can still write, this may happen on Windows
601+
Assume.assumeTrue("Skipping: directory is still writable", !canWrite);
602+
586603
try {
587604
config = new XMLConfiguration(null, roEmptyDir.getAbsolutePath());
588605
config.setGridSetBroker(gridSetBroker);

0 commit comments

Comments
 (0)