@Test
public void testPut() throws Exception {

    CacheKey key = new CacheKey("groupName", ResourceType.CSS);
    CacheValue value = CacheValue.valueOf("rawContent", "hash");
    final URL classFile = DiskbackedCacheTest.class.getResource(DiskbackedCache.class.getSimpleName() + ".class");
    final Path path = Paths.get(classFile.toURI()).getParent().resolve("db");
    try (DirectoryStream<Path> paths = Files.newDirectoryStream(path.getParent(), "cache*.db")) {
        for (Path path1 : paths) {
            Files.deleteIfExists(path1);
        }
    }
    try (DiskbackedCache cache = new DiskbackedCache(100, path.toString())) {
        cache.put(key, value);
        CacheValue loaded = cache.get(key);
        assertEquals(value.getHash(), loaded.getHash());
        assertEquals(value.getRawContent(), loaded.getRawContent());
        assertArrayEquals(value.getGzippedContent(), loaded.getGzippedContent());
    }
    try (DiskbackedCache cache2 = new DiskbackedCache(100, path.toString())) {
        CacheValue loaded = cache2.get(key);
        assertEquals(value.getHash(), loaded.getHash());
        assertEquals(value.getRawContent(), loaded.getRawContent());
        assertArrayEquals(value.getGzippedContent(), loaded.getGzippedContent());
    }
}