@Test
public void canLoadValidCache() throws IOException {

    File tempDir = Files.createTempDirectory( "jgrab-persistent-cache-test" ).toFile();
    File dep1 = new File( tempDir, "valid-dep.jar" );
    File dep2 = new File( tempDir, "other-dep.jar" );
    File dep3 = new File( tempDir, "guava-20.0.jar" );
    for (File file1 : Arrays.asList( dep1, dep2, dep3 )) {
        assertTrue( file1.createNewFile() );
    }
    byte[] contents = ( "some:valid-dep:1.0,other-dep:name " +
            dep1 + File.pathSeparator + dep2 + "\n" +
            "com.guava:guava:20.0 " + dep3 )
            .getBytes( StandardCharsets.UTF_8 );
    File file = new File( tempDir, "cache" );
    assertTrue( file.createNewFile() );
    Files.write( file.toPath(), contents, StandardOpenOption.WRITE );
    // create a cache with known contents
    PersistentCache cache = new PersistentCache( file );
    Supplier<List<File>> badSupplier = () -> {
        throw new RuntimeException( "Should not be called" );
    };
    Set<Dependency> firstDeps = asDependencies( Stream.of(
            "some:valid-dep:1.0", "other-dep:name" ) );
    Set<Dependency> secondDeps = asDependencies( Stream.of( "com.guava:guava:20.0" ) );
    List<File> firstEntry = cache.libsFor( firstDeps, badSupplier );
    List<File> secondEntry = cache.libsFor( secondDeps, badSupplier );
    assertEquals( asList( dep1, dep2 ), firstEntry );
    assertEquals( asList( dep3 ), secondEntry );
}