Examples of TestFile


Examples of org.gradle.util.TestFile

        assertThat(loadProperties(dir.file("cache.properties")), equalTo(properties));
    }

    @Test
    public void createsAnIndexedCache() {
        TestFile dir = tmpDir.getDir().file("dir");
        DefaultPersistentDirectoryCache cache = new DefaultPersistentDirectoryCache(dir, CacheUsage.ON, properties);
        assertThat(cache.openIndexedCache(), instanceOf(BTreePersistentIndexedCache.class));
    }
View Full Code Here

Examples of org.gradle.util.TestFile

        assertThat(cache.openIndexedCache(), instanceOf(BTreePersistentIndexedCache.class));
    }

    @Test
    public void reusesTheIndexedCache() {
        TestFile dir = tmpDir.getDir().file("dir");
        DefaultPersistentDirectoryCache cache = new DefaultPersistentDirectoryCache(dir, CacheUsage.ON, properties);
        assertThat(cache.openIndexedCache(), sameInstance(cache.openIndexedCache()));
    }
View Full Code Here

Examples of org.gradle.util.TestFile

        assertThat(cache.openIndexedCache(), sameInstance(cache.openIndexedCache()));
    }

    @Test
    public void closesIndexedCacheOnClose() {
        TestFile dir = tmpDir.getDir().file("dir");
        DefaultPersistentDirectoryCache cache = new DefaultPersistentDirectoryCache(dir, CacheUsage.ON, properties);
       
        BTreePersistentIndexedCache indexedCache = cache.openIndexedCache();
        assertTrue(indexedCache.isOpen());
View Full Code Here

Examples of org.gradle.util.TestFile

        assertFalse(indexedCache.isOpen());
    }
   
    @Test
    public void createsAnStateCache() {
        TestFile dir = tmpDir.getDir().file("dir");
        DefaultPersistentDirectoryCache cache = new DefaultPersistentDirectoryCache(dir, CacheUsage.ON, properties);
        assertThat(cache.openStateCache(), instanceOf(SimpleStateCache.class));
    }
View Full Code Here

Examples of org.gradle.util.TestFile

        assertThat(cache.openStateCache(), instanceOf(SimpleStateCache.class));
    }

    @Test
    public void reusesTheStateCache() {
        TestFile dir = tmpDir.getDir().file("dir");
        DefaultPersistentDirectoryCache cache = new DefaultPersistentDirectoryCache(dir, CacheUsage.ON, properties);
        assertThat(cache.openStateCache(), sameInstance(cache.openStateCache()));
    }
View Full Code Here

Examples of org.gradle.util.TestFile

        }
        return result;
    }

    private TestFile createCacheDir(String... extraProps) {
        TestFile dir = tmpDir.getDir();
        Properties properties = new Properties();
        properties.putAll(this.properties);
        properties.putAll(GUtil.map((Object[])extraProps));
        GUtil.saveProperties(properties, dir.file("cache.properties"));
        dir.file("some-file").touch();

        return dir;
    }
View Full Code Here

Examples of org.gradle.util.TestFile

    @Test
    public void reusesEmptySpaceWhenPuttingEntries() {
        BTreePersistentIndexedCache<String, String> cache = new BTreePersistentIndexedCache<String, String>(
                backingCache, new DefaultSerializer<String>(), (short) 4, 100);
        TestFile cacheFile = tmpDir.getDir().file("cache.bin");

        cache.put("key_1", "abcd");
        cache.put("key_2", "abcd");
        cache.put("key_3", "abcd");
        cache.put("key_4", "abcd");
        cache.put("key_5", "abcd");

        long len = cacheFile.length();
        assertThat(len, greaterThan(0L));

        cache.put("key_1", "1234");
        assertThat(cacheFile.length(), equalTo(len));

        cache.remove("key_1");
        cache.put("key_new", "a1b2");
        assertThat(cacheFile.length(), equalTo(len));

        cache.put("key_new", "longer value");
        assertThat(cacheFile.length(), greaterThan(len));
        len = cacheFile.length();

        cache.put("key_1", "1234");
        assertThat(cacheFile.length(), equalTo(len));
    }
View Full Code Here

Examples of org.gradle.util.TestFile

            values.add(i);
        }

        checkAddsAndRemoves(null, values);

        TestFile testFile = tmpDir.getDir().file("cache.bin");
        long len = testFile.length();

        checkAddsAndRemoves(Collections.<Integer>reverseOrder(), values);

        // need to make this better
        assertThat(testFile.length(), lessThan((long)(1.4 * len)));

        checkAdds(values);
       
        // need to make this better
        assertThat(testFile.length(), lessThan((long)(1.4 * 1.4 * len)));
    }
View Full Code Here

Examples of org.gradle.util.TestFile

    }

    @Test
    public void handlesBadlyFormedCacheFile() throws IOException {

        TestFile testFile = tmpDir.getDir().file("cache.bin");
        testFile.assertIsFile();
        testFile.write("some junk");

        BTreePersistentIndexedCache<String, Integer> cache = new BTreePersistentIndexedCache<String, Integer>(backingCache, serializer);

        assertNull(cache.get("key_1"));
        cache.put("key_1", 99);
View Full Code Here

Examples of org.gradle.util.TestFile

        this.format = format;
    }

    @TaskAction
    public void transform() {
        TestFile inputFile = new TestFile(this.inputFile);
        TestFile outputFile = new TestFile(this.outputFile);
        outputFile.write(String.format(format, inputFile.getText()));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.