use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class MapFileTreeTest method overwritesFileWhenGeneratedContentChanges.
@Test
public void overwritesFileWhenGeneratedContentChanges() {
final AtomicReference<String> currentContentReference = new AtomicReference<String>("content");
tree.add("path/file.txt", new Action<OutputStream>() {
@Override
public void execute(OutputStream outputStream) {
try {
outputStream.write(currentContentReference.get().getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
assertVisits(tree, toList("path/file.txt"), toList("path"));
TestFile file = rootDir.file("path/file.txt");
file.assertContents(equalTo("content"));
TestFile.Snapshot snapshot = file.snapshot();
currentContentReference.set("updated content");
assertVisits(tree, toList("path/file.txt"), toList("path"));
file.assertContents(equalTo("updated content"));
file.assertHasChangedSince(snapshot);
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class JvmSourceFile method writeToDir.
public TestFile writeToDir(TestFile base) {
TestFile file = base.file(path, name);
writeToFile(file);
return file;
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class WebProjectIntegrationTest method generatesArtifactsWhenVersionIsEmpty.
@Test
public void generatesArtifactsWhenVersionIsEmpty() {
testFile("settings.gradle").write("rootProject.name = 'empty'");
TestFile buildFile = testFile("build.gradle");
buildFile.writelns("apply plugin: 'war'", "version = ''");
testFile("src/main/resources/org/gradle/resource.file").write("some resource");
usingBuildFile(buildFile).withTasks("assemble").run();
testFile("build/libs/empty.war").assertIsFile();
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class SourceFile method writeToDir.
public TestFile writeToDir(TestFile base) {
TestFile file = base.file(path, name);
writeToFile(file);
return file;
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class IntegrationTestBuildContext method file.
protected static TestFile file(String propertyName, String defaultFile) {
String defaultPath;
if (defaultFile == null) {
defaultPath = null;
} else if (new File(defaultFile).isAbsolute()) {
defaultPath = defaultFile;
} else {
defaultPath = TEST_DIR.file(defaultFile).getAbsolutePath();
}
String path = System.getProperty(propertyName, defaultPath);
if (path == null) {
throw new RuntimeException(String.format("You must set the '%s' property to run the integration tests. The default passed was: '%s'", propertyName, defaultFile));
}
return new TestFile(new File(path));
}
Aggregations