Package org.gradle.api.file

Examples of org.gradle.api.file.FileCopyDetails


        assertThat(collectDetails1.get(), sameInstance(collectDetails3.get()));
    }

    @Test
    public void initialRelativePathForFileIsSpecPathPlusFilePath() {
        FileCopyDetails copyDetails = expectActionExecutedWhenFileVisited();

        context.checking(new Expectations(){{
            allowing(spec).getDestPath();
            will(returnValue(new RelativePath(false, "spec")));
            allowing(details).getRelativePath();
            will(returnValue(new RelativePath(true, "file")));
        }});

        assertThat(copyDetails.getRelativePath(), equalTo(new RelativePath(true, "spec", "file")));
    }
View Full Code Here


        assertThat(visitDetails.getRelativePath(), equalTo(new RelativePath(false, "spec", "dir")));
    }

    @Test
    public void copyActionCanChangeFileDestinationPath() {
        FileCopyDetails copyDetails = expectActionExecutedWhenFileVisited();

        RelativePath newPath = new RelativePath(true, "new");
        copyDetails.setRelativePath(newPath);
        assertThat(copyDetails.getRelativePath(), equalTo(newPath));

        copyDetails.setPath("/a/b");
        assertThat(copyDetails.getRelativePath(), equalTo(new RelativePath(true, "a", "b")));

        copyDetails.setName("new name");
        assertThat(copyDetails.getRelativePath(), equalTo(new RelativePath(true, "a", "new name")));
    }
View Full Code Here

        visitor.visitFile(details);
    }

    @Test
    public void copyActionCanFilterContentWhenFileIsCopiedToStream() {
        final FileCopyDetails mappedDetails = expectActionExecutedWhenFileVisited();

        context.checking(new Expectations() {{
            one(details).open();
            will(returnValue(new ByteArrayInputStream("content".getBytes())));
        }});

        mappedDetails.filter(HelperUtil.toClosure("{ 'PREFIX: ' + it } "));

        ByteArrayOutputStream outstr = new ByteArrayOutputStream();
        mappedDetails.copyTo(outstr);
        assertThat(new String(outstr.toByteArray()), equalTo("PREFIX: content"));
    }
View Full Code Here

        assertThat(new String(outstr.toByteArray()), equalTo("PREFIX: content"));
    }

    @Test
    public void copyActionCanFilterContentWhenFileIsCopiedToFile() {
        final FileCopyDetails mappedDetails = expectActionExecutedWhenFileVisited();

        context.checking(new Expectations() {{
            one(details).open();
            will(returnValue(new ByteArrayInputStream("content".getBytes())));
            one(details).isDirectory();
            will(returnValue(false));
            one(details).getLastModified();
            will(returnValue(90L));
        }});

        mappedDetails.filter(HelperUtil.toClosure("{ 'PREFIX: ' + it } "));

        TestFile destDir = tmpDir.getDir().file("test.txt");
        mappedDetails.copyTo(destDir);
        destDir.assertContents(equalTo("PREFIX: content"));
    }
View Full Code Here

        destDir.assertContents(equalTo("PREFIX: content"));
    }

    @Test
    public void getSizeReturnsSizeOfFilteredContent() {
        final FileCopyDetails mappedDetails = expectActionExecutedWhenFileVisited();

        context.checking(new Expectations() {{
            one(details).open();
            will(returnValue(new ByteArrayInputStream("content".getBytes())));
        }});

        mappedDetails.filter(HelperUtil.toClosure("{ 'PREFIX: ' + it } "));

        assertThat(mappedDetails.getSize(), equalTo(15L));
    }
View Full Code Here

        }});

        visitor.visitSpec(spec);
        visitor.visitFile(details);

        FileCopyDetails copyDetails = collectDetails.get();
        return copyDetails;
    }
View Full Code Here

            public void describeTo(Description description) {
                description.appendText("exclude file");
            }

            public Object invoke(Invocation invocation) throws Throwable {
                FileCopyDetails details = (FileCopyDetails) invocation.getParameter(0);
                details.exclude();
                return null;
            }
        };
    }
View Full Code Here

            public void describeTo(Description description) {
                description.appendText("has path ").appendValue(path);
            }

            public boolean matches(Object o) {
                FileCopyDetails details = (FileCopyDetails) o;
                return details.getRelativePath().getPathString().equals(path);
            }
        };
    }
View Full Code Here

TOP

Related Classes of org.gradle.api.file.FileCopyDetails

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.