diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/integration/CacheWriterTest.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/integration/CacheWriterTest.java index 9a830cfcf5..6fbc001ae6 100644 --- a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/integration/CacheWriterTest.java +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/integration/CacheWriterTest.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import javax.cache.integration.CacheWriter; import javax.cache.integration.CacheWriterException; @@ -72,6 +73,19 @@ public void putAll_fails() { } } + @Test + public void putAllImmutable_fails() { + doThrow(CacheWriterException.class).when(writer).writeAll(any()); + var immutableMap = Map.of(KEY_1, VALUE_1); + + try { + jcache.putAll(immutableMap); + Assert.fail(); + } catch (CacheWriterException e) { + assertThat(immutableMap).isEmpty(); + } + } + @Test(expectedExceptions = CacheWriterException.class) public void remove_fails() { jcache.put(KEY_1, VALUE_1);