Package org.gradle.util

Examples of org.gradle.util.TestFile$Snapshot


        }});
    }

    @Test
    public void createsZipFile() {
        final TestFile zipFile = tmpDir.getDir().file("test.zip");

        context.checking(new Expectations(){{
            allowing(copyAction).getArchivePath();
            will(returnValue(zipFile));
        }});

        visitor.startVisit(copyAction);
        visitor.visitSpec(copySpec);

        visitor.visitDir(dir("dir"));
        visitor.visitFile(file("dir/file1"));
        visitor.visitFile(file("file2"));

        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"));
    }
View Full Code Here


        expandDir.file("file2").assertContents(equalTo("contents of file2"));
    }

    @Test
    public void wrapsFailureToOpenOutputFile() {
        final TestFile zipFile = tmpDir.createDir("test.zip");

        context.checking(new Expectations(){{
            allowing(copyAction).getArchivePath();
            will(returnValue(zipFile));
        }});
View Full Code Here

        }
    }

    @Test
    public void wrapsFailureToAddElement() {
        final TestFile zipFile = tmpDir.getDir().file("test.zip");

        context.checking(new Expectations(){{
            allowing(copyAction).getArchivePath();
            will(returnValue(zipFile));
        }});
View Full Code Here

        }});
    }
   
    @Test
    public void deletesExtraFilesFromDestinationDirectoryAtTheEndOfVisit() {
        TestFile destDir = tmpDir.createDir("dest");
        destDir.file("subdir/included.txt").createFile();
        destDir.file("subdir/extra.txt").createFile();
        destDir.file("included.txt").createFile();
        destDir.file("extra.txt").createFile();

        visitor.startVisit(action(destDir));
        visitor.visitDir(dir("subdir"));
        visitor.visitFile(file("subdir/included.txt"));
        visitor.visitFile(file("included.txt"));
        visitor.endVisit();

        destDir.assertHasDescendants("subdir/included.txt", "included.txt");
    }
View Full Code Here

        assertSetContains(collection, toSet("f1", "f2"));
    }

    @Test
    public void includesOnlyExistingFilesWhenAddedToAntBuilderAsAFileSetOrMatchingTask() {
        TestFile testDir = this.testDir.getDir();
        TestFile file1 = testDir.file("f1").touch();
        TestFile dir1 = testDir.file("dir1").createDir();
        TestFile file2 = dir1.file("f2").touch();
        TestFile missing = testDir.file("f3");
        testDir.file("f2").touch();
        testDir.file("ignored1").touch();
        dir1.file("f1").touch();
        dir1.file("ignored1").touch();
View Full Code Here

        }});
    }
   
    @Test
    public void createsTarFile() {
        final TestFile tarFile = tmpDir.getDir().file("test.tar");

        context.checking(new Expectations() {{
            allowing(copyAction).getArchivePath();
            will(returnValue(tarFile));
            allowing(copyAction).getCompression();
            will(returnValue(Compression.NONE));
        }});

        visitor.startVisit(copyAction);
        visitor.visitSpec(copySpec);

        visitor.visitFile(file("dir/file1"));
        visitor.visitFile(file("file2"));

        visitor.endVisit();

        TestFile expandDir = tmpDir.getDir().file("expanded");
        tarFile.untarTo(expandDir);
        expandDir.file("dir/file1").assertContents(equalTo("contents of dir/file1"));
        expandDir.file("file2").assertContents(equalTo("contents of file2"));
    }
View Full Code Here

        destDir.assertHasDescendants("subdir/included.txt", "included.txt");
    }

    @Test
    public void deletesExtraDirectoriesFromDestinationDirectoryAtTheEndOfVisit() {
        TestFile destDir = tmpDir.createDir("dest");
        destDir.file("included.txt").createFile();
        destDir.file("extra/extra.txt").createFile();

        visitor.startVisit(action(destDir));
        visitor.visitFile(file("included.txt"));
        visitor.endVisit();

        destDir.assertHasDescendants("included.txt");
    }
View Full Code Here

        expandDir.file("file2").assertContents(equalTo("contents of file2"));
    }

    @Test
    public void createsGzipCompressedTarFile() {
        final TestFile tarFile = tmpDir.getDir().file("test.tgz");

        context.checking(new Expectations(){{
            allowing(copyAction).getArchivePath();
            will(returnValue(tarFile));
            allowing(copyAction).getCompression();
            will(returnValue(Compression.GZIP));
        }});

        visitor.startVisit(copyAction);
        visitor.visitSpec(copySpec);

        visitor.visitFile(file("dir/file1"));
        visitor.visitFile(file("file2"));

        visitor.endVisit();

        TestFile expandDir = tmpDir.getDir().file("expanded");
        tarFile.untarTo(expandDir);
        expandDir.file("dir/file1").assertContents(equalTo("contents of dir/file1"));
        expandDir.file("file2").assertContents(equalTo("contents of file2"));
    }
View Full Code Here

        expandDir.file("file2").assertContents(equalTo("contents of file2"));
    }

    @Test
    public void createsBzip2CompressedTarFile() {
        final TestFile tarFile = tmpDir.getDir().file("test.tbz2");

        context.checking(new Expectations(){{
            allowing(copyAction).getArchivePath();
            will(returnValue(tarFile));
            allowing(copyAction).getCompression();
            will(returnValue(Compression.BZIP2));
        }});

        visitor.startVisit(copyAction);
        visitor.visitSpec(copySpec);

        visitor.visitFile(file("dir/file1"));
        visitor.visitFile(file("file2"));

        visitor.endVisit();

        TestFile expandDir = tmpDir.getDir().file("expanded");
        tarFile.untarTo(expandDir);
        expandDir.file("dir/file1").assertContents(equalTo("contents of dir/file1"));
        expandDir.file("file2").assertContents(equalTo("contents of file2"));
    }
View Full Code Here

        expandDir.file("file2").assertContents(equalTo("contents of file2"));
    }

    @Test
    public void wrapsFailureToOpenOutputFile() {
        final TestFile tarFile = tmpDir.createDir("test.tar");

        context.checking(new Expectations(){{
            allowing(copyAction).getArchivePath();
            will(returnValue(tarFile));
        }});
View Full Code Here

TOP

Related Classes of org.gradle.util.TestFile$Snapshot

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.