Examples of FileContent


Examples of com.google.code.mojo.license.util.FileContent

        assertFalse(parser.gotAnyHeader());
    }

    @Test
    public void test_has_header() throws Exception {
        HeaderParser parser = new HeaderParser(new FileContent(new File("src/test/resources/doc/doc2.txt"), System.getProperty("file.encoding")),
                HeaderType.TEXT.getDefinition(), new String[]{"copyright"});
        assertTrue(parser.gotAnyHeader());
        assertEquals(parser.getBeginPosition(), 0);
        assertEquals(parser.getEndPosition(), 43);
    }
View Full Code Here

Examples of com.google.code.mojo.license.util.FileContent

        assertEquals(parser.getEndPosition(), 43);
    }

    @Test
    public void test_has_header2() throws Exception {
        HeaderParser parser = new HeaderParser(new FileContent(new File("src/test/resources/doc/doc3.txt"), System.getProperty("file.encoding")),
                HeaderType.TEXT.getDefinition(), new String[]{"copyright"});
        assertTrue(parser.gotAnyHeader());
        assertEquals(parser.getBeginPosition(), 0);
        assertEquals(parser.getEndPosition(), 49);
    }
View Full Code Here

Examples of com.google.code.mojo.license.util.FileContent

        assertEquals(parser.getEndPosition(), 49);
    }

    @Test
    public void test_parsing_xml1() throws Exception {
        HeaderParser parser = new HeaderParser(new FileContent(new File("src/test/resources/doc/doc4.xml"), System.getProperty("file.encoding")),
                HeaderType.XML_STYLE.getDefinition(), new String[]{"copyright"});
        assertTrue(parser.gotAnyHeader());
        assertEquals(parser.getBeginPosition(), 45);
        assertEquals(parser.getEndPosition(), 862);
    }
View Full Code Here

Examples of com.google.code.mojo.license.util.FileContent

        assertEquals(parser.getEndPosition(), 862);
    }

    @Test
    public void test_parsing_xml2() throws Exception {
        HeaderParser parser = new HeaderParser(new FileContent(new File("src/test/resources/doc/doc5.xml"), System.getProperty("file.encoding")),
                HeaderType.XML_STYLE.getDefinition(), new String[]{"copyright"});
        assertTrue(parser.gotAnyHeader());
        assertEquals(parser.getBeginPosition(), 45);
        assertEquals(parser.getEndPosition(), 866);
    }
View Full Code Here

Examples of com.google.code.mojo.license.util.FileContent

        assertEquals(parser.getEndPosition(), 866);
    }

    @Test
    public void test_parsing_xml3() throws Exception {
        HeaderParser parser = new HeaderParser(new FileContent(new File("src/test/resources/doc/doc6.xml"), System.getProperty("file.encoding")),
                HeaderType.XML_STYLE.getDefinition(), new String[]{"copyright"});
        assertFalse(parser.gotAnyHeader());
    }
View Full Code Here

Examples of com.google.code.mojo.license.util.FileContent

        assertFalse(parser.gotAnyHeader());
    }

    @Test
    public void test_parsing_xml4() throws Exception {
        HeaderParser parser = new HeaderParser(new FileContent(new File("src/test/resources/doc/doc7.xml"), System.getProperty("file.encoding")),
                HeaderType.XML_STYLE.getDefinition(), new String[]{"copyright"});
        assertFalse(parser.gotAnyHeader());
    }
View Full Code Here

Examples of com.google.code.mojo.license.util.FileContent

        assertFalse(parser.gotAnyHeader());
    }

    @Test
    public void test_parsing_xml5() throws Exception {
        HeaderParser parser = new HeaderParser(new FileContent(new File("src/test/resources/doc/doc8.xml"), System.getProperty("file.encoding")),
                HeaderType.XML_STYLE.getDefinition(), new String[]{"copyright"});
        assertFalse(parser.gotAnyHeader());
    }
View Full Code Here

Examples of com.google.code.mojo.license.util.FileContent

        assertFalse(parser.gotAnyHeader());
    }

    @Test
    public void test_parsing_xml6() throws Exception {
        HeaderParser parser = new HeaderParser(new FileContent(new File("src/test/resources/doc/doc9.xml"), System.getProperty("file.encoding")),
                HeaderType.XML_STYLE.getDefinition(), new String[]{"copyright"});
        assertTrue(parser.gotAnyHeader());
        assertEquals(parser.getBeginPosition(), 45);
        assertEquals(parser.getEndPosition(), 870);
    }
View Full Code Here

Examples of com.google.code.mojo.license.util.FileContent

*/
public final class HeaderParserTest {

    @Test
    public void test_no_header() throws Exception {
        HeaderParser parser = new HeaderParser(new FileContent(new File("src/test/resources/doc/doc1.txt"), System.getProperty("file.encoding")),
                HeaderType.TEXT.getDefinition());
        assertFalse(parser.gotAnyHeader());
    }
View Full Code Here

Examples of com.mathieucarbou.mojo.license.util.FileContent

        return new Document(file, headerType);
    }

    public void updateHeader(Header header)
    {
        FileContent fileContent = readFrom(file);
        HeaderParser parser = parseHeader(fileContent, headerType);
        if(parser.gotHeader())
        {
            fileContent.delete(parser.getBeginPosition(), parser.getEndPosition());
        }
        fileContent.insert(parser.getBeginPosition(), header.buildForType(headerType));
        fileContent.write();
    }
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.