Package org.gradle.util

Examples of org.gradle.util.TestFile


        assertThat(repository.cache("a/b/c").forObject(gradle).open(), sameInstance(cache));
    }

    @Test
    public void createsCacheForAFile() {
        final TestFile dir = tmpDir.createDir("otherDir");

        context.checking(new Expectations() {{
            one(cacheFactory).open(dir.file(".gradle", version, "a/b/c"), CacheUsage.ON, Collections.EMPTY_MAP);
            will(returnValue(cache));
        }});

        assertThat(repository.cache("a/b/c").forObject(dir).open(), sameInstance(cache));
    }
View Full Code Here


    public final TemporaryFolder tmpDir = new TemporaryFolder();
    private final Map<String, String> properties = GUtil.map("prop", "value", "prop2", "other-value");

    @Test
    public void cacheIsInvalidWhenCacheDirDoesNotExist() {
        TestFile emptyDir = tmpDir.getDir().file("dir");
        emptyDir.assertDoesNotExist();

        DefaultPersistentDirectoryCache cache = new DefaultPersistentDirectoryCache(emptyDir, CacheUsage.ON, properties);
        assertFalse(cache.isValid());

        emptyDir.assertIsDir();
    }
View Full Code Here

        emptyDir.assertIsDir();
    }

    @Test
    public void cacheIsInvalidWhenPropertiesFileDoesNotExist() {
        TestFile dir = tmpDir.getDir().file("dir").createDir();

        DefaultPersistentDirectoryCache cache = new DefaultPersistentDirectoryCache(dir, CacheUsage.ON, properties);
        assertFalse(cache.isValid());

        dir.assertIsDir();
    }
View Full Code Here

        dir.assertIsDir();
    }

    @Test
    public void rebuildsCacheWhenPropertiesHaveChanged() {
        TestFile dir = createCacheDir("prop", "other-value");

        DefaultPersistentDirectoryCache cache = new DefaultPersistentDirectoryCache(dir, CacheUsage.ON, properties);
        assertFalse(cache.isValid());

        dir.assertHasDescendants();
    }
View Full Code Here

        dir.assertHasDescendants();
    }

    @Test
    public void rebuildsCacheWhenCacheRebuildRequested() {
        TestFile dir = createCacheDir();

        DefaultPersistentDirectoryCache cache = new DefaultPersistentDirectoryCache(dir, CacheUsage.REBUILD, properties);
        assertFalse(cache.isValid());

        dir.assertHasDescendants();
    }
View Full Code Here

        dir.assertHasDescendants();
    }

    @Test
    public void usesExistingCacheDirWhenItIsNotInvalid() {
        TestFile dir = createCacheDir();

        DefaultPersistentDirectoryCache cache = new DefaultPersistentDirectoryCache(dir, CacheUsage.ON, properties);
        assertTrue(cache.isValid());

        dir.file("cache.properties").assertIsFile();
        dir.file("some-file").assertIsFile();
    }
View Full Code Here

        dir.file("some-file").assertIsFile();
    }

    @Test
    public void updateCreatesPropertiesFileWhenItDoesNotExist() {
        TestFile dir = tmpDir.getDir().file("dir");

        DefaultPersistentDirectoryCache cache = new DefaultPersistentDirectoryCache(dir, CacheUsage.ON, properties);
        cache.markValid();

        assertTrue(cache.isValid());
        assertThat(loadProperties(dir.file("cache.properties")), equalTo(properties));
    }
View Full Code Here

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

    @Test
    public void updatesPropertiesWhenMarkedValid() {
        TestFile dir = createCacheDir("prop", "some-other-value");

        DefaultPersistentDirectoryCache cache = new DefaultPersistentDirectoryCache(dir, CacheUsage.ON, properties);
        cache.markValid();

        assertTrue(cache.isValid());
        assertThat(loadProperties(dir.file("cache.properties")), equalTo(properties));
    }
View Full Code Here

        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

        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

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.