Package org.gradle.util

Examples of org.gradle.util.TestFile.file()


    @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


        TestFile dir = createCacheDir();

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

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

    @Test
    public void updateCreatesPropertiesFileWhenItDoesNotExist() {
View Full Code Here

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

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

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

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

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

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

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

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

    @Test
    public void createsAnIndexedCache() {
        TestFile dir = tmpDir.getDir().file("dir");
View Full Code Here

    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

        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

            "include 'child'",
            "project(':child').buildFileName = 'child.gradle'"
        );

        TestFile subDirectory = getTestDir().file("child");
        subDirectory.file("build.gradle").write("throw new RuntimeException()");
        subDirectory.file("child.gradle").write("task('do-stuff')");

        inDirectory(subDirectory).withSearchUpwards().withTasks("do-stuff").run();
        usingProjectDir(subDirectory).withSearchUpwards().withTasks("do-stuff").run();
    }
View Full Code Here

            "project(':child').buildFileName = 'child.gradle'"
        );

        TestFile subDirectory = getTestDir().file("child");
        subDirectory.file("build.gradle").write("throw new RuntimeException()");
        subDirectory.file("child.gradle").write("task('do-stuff')");

        inDirectory(subDirectory).withSearchUpwards().withTasks("do-stuff").run();
        usingProjectDir(subDirectory).withSearchUpwards().withTasks("do-stuff").run();
    }
View Full Code Here

        visitor.endVisit();

        TestFile expandDir = tmpDir.getDir().file("expanded");
        zipFile.unzipTo(expandDir);
        expandDir.file("dir/file1").assertContents(equalTo("contents of dir/file1"));
        expandDir.file("file2").assertContents(equalTo("contents of file2"));
    }

    @Test
    public void wrapsFailureToOpenOutputFile() {
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.