Package org.gradle.util

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


        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

        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

        }
        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

    @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

            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

    }

    @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

        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

        inTestDirectory().withTasks("build").run();
    }

    @Test
    public void compilationFailureBreaksBuild() {
        TestFile buildFile = testFile("build.gradle");
        buildFile.writelns("apply plugin: 'java'");
        testFile("src/main/java/org/gradle/broken.java").write("broken");

        ExecutionFailure failure = usingBuildFile(buildFile).withTasks("build").runWithFailure();

        failure.assertHasFileName(String.format("Build file '%s'", buildFile));
View Full Code Here

        failure.assertHasCause("Compile failed; see the compiler error output for details.");
    }

    @Test
    public void testCompilationFailureBreaksBuild() {
        TestFile buildFile = testFile("build.gradle");
        buildFile.writelns("apply plugin: 'java'");
        testFile("src/main/java/org/gradle/ok.java").write("package org.gradle; class ok { }");
        testFile("src/test/java/org/gradle/broken.java").write("broken");

        ExecutionFailure failure = usingBuildFile(buildFile).withTasks("build").runWithFailure();
View Full Code Here

TOP

Related Classes of org.gradle.util.TestFile

Copyright © 2018 www.massapicom. 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.