/** * Creates a new instance of <code>{@link FileAssert}</code>. * @param actual the actual value. * @return the created assertion object. */ public static FileAssert assertThat(File actual) { return new FileAssert(actual); }
/** * Specifies the name of the charset to use for text-based assertions on the file's contents. * * @param charsetName the name of the charset to use. * @return {@code this} assertion object. * @throws IllegalArgumentException if the given encoding is not supported on this platform. */ public FileAssert usingCharset(String charsetName) { if (!Charset.isSupported(charsetName)) throw new IllegalArgumentException(String.format("Charset:<'%s'> is not supported on this system", charsetName)); return usingCharset(Charset.forName(charsetName)); }
private void assertValue(String key, String value0, String value1) throws Exception { DiskLruCache.Value value = cache.get(key); assertThat(value.getString(0)).isEqualTo(value0); assertThat(value.getLength(0)).isEqualTo(value0.length()); assertThat(value.getString(1)).isEqualTo(value1); assertThat(value.getLength(1)).isEqualTo(value1.length()); assertThat(getCleanFile(key, 0)).exists(); assertThat(getCleanFile(key, 1)).exists(); } }
private void assertGarbageFilesAllDeleted() throws Exception { assertThat(getCleanFile("g1")).doesNotExist(); assertThat(getCleanFile("g2")).doesNotExist(); assertThat(new File(mCacheDir, "otherFile0.tmp")).doesNotExist(); assertThat(new File(mCacheDir, "otherFile1.clean")).doesNotExist(); }
@Test(expected = FileAlreadyExistsException.class) public void newByteChannelFileAlreadyExists() throws IOException { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final File tempFile = File.createTempFile( "foo", "bar" ); final Path path = GeneralPathImpl.newFromFile( fsProvider.getFileSystem( URI.create( "file:///" ) ), tempFile ); assertThat( path.toFile().exists() ).isTrue(); assertThat( path.toFile() ).isEqualTo( tempFile ); fsProvider.newByteChannel( path, null ); }
@Test public void readingTheSameFileMultipleTimes() throws Exception { set("a", "a", "b"); DiskLruCache.Value value = cache.get("a"); assertThat(value.getFile(0)).isSameAs(value.getFile(0)); }
private void assertValue(String key, String value) throws Exception { OptionalStream<SnapshotInputStream> in = mCache.get(key); if (in.isPresent()) { assertThat(IgDiskCacheTest.readFromInputStream(in.get())).isEqualTo(value); assertThat(new File(mCacheDir, key + Entry.CLEAN_FILE_EXTENSION)).exists(); in.get().close(); } }
private void assertGarbageFilesAllDeleted() throws Exception { assertThat(getCleanFile("g1", 0)).doesNotExist(); assertThat(getCleanFile("g1", 1)).doesNotExist(); assertThat(getCleanFile("g2", 0)).doesNotExist(); assertThat(getCleanFile("g2", 1)).doesNotExist(); assertThat(new File(cacheDir, "otherFile0")).doesNotExist(); assertThat(new File(cacheDir, "dir1")).doesNotExist(); }
private void assertValue(IgDiskCache cache, String key, String value) throws Exception { OptionalStream<SnapshotInputStream> in = cache.get(key); if (in.isPresent()) { assertThat(readFromInputStream(in.get())).isEqualTo(value); assertThat(getCleanFile(key)).exists(); in.get().close(); } }
private void assertAbsent(String key) throws Exception { DiskLruCache.Value value = cache.get(key); if (value != null) { Assert.fail(); } assertThat(getCleanFile(key, 0)).doesNotExist(); assertThat(getCleanFile(key, 1)).doesNotExist(); assertThat(getDirtyFile(key, 0)).doesNotExist(); assertThat(getDirtyFile(key, 1)).doesNotExist(); }
private void assertAbsent(IgDiskCache cache, String key) throws Exception { OptionalStream<SnapshotInputStream> in = cache.get(key); if (in.isPresent()) { in.get().close(); fail(); } assertThat(getCleanFile(key)).doesNotExist(); assertThat(getDirtyFile(key)).doesNotExist(); }