Package org.eluder.coveralls.maven.plugin.domain

Examples of org.eluder.coveralls.maven.plugin.domain.Source


    @Test
    public void testLoadSource() throws Exception {
        File file = folder.newFile();
        TestIoUtil.writeFileContent("public class Foo {\r\n    \n}\r", file);
        DirectorySourceLoader sourceLoader = new DirectorySourceLoader(folder.getRoot(), folder.getRoot(), "UTF-8");
        Source source = sourceLoader.load(file.getName());
        assertEquals(file.getName(), source.getName());
        assertEquals("public class Foo {\n    \n}\n", source.getSource());
        assertEquals(4, source.getCoverage().length);
    }
View Full Code Here


        folder.newFolder("scripts");
        File file = folder.newFile(fileName);
        TestIoUtil.writeFileContent("math =\n  root:   Math.sqrt\n  square: square", file);

        UrlSourceLoader sourceLoader = new UrlSourceLoader(folder.getRoot().toURI().toURL(), sourceUrl, "UTF-8");
        Source source = sourceLoader.load(fileName);

        assertEquals(fileName, source.getName());
        assertEquals("math =\n  root:   Math.sqrt\n  square: square", source.getSource());
        assertEquals(3, source.getCoverage().length);
    }
View Full Code Here

   
    protected Answer<Source> sourceAnswer(final String name, final String content) {
        return new Answer<Source>() {
            @Override
            public Source answer(final InvocationOnMock invocation) throws Throwable {
                return new Source(name, content);
            }
        };
    }
View Full Code Here

    protected abstract String[][] getCoverageFixture();
   
    private Collection<Source> combineCoverage(final List<Source> sources) {
        Map<String, Source> combined = new HashMap<String, Source>();
        for (Source source : sources) {
            Source existing = combined.get(source.getName());
            if (existing == null) {
                combined.put(source.getName(), source);
            } else {
                for (int i = 0; i < source.getCoverage().length; i++) {
                    if (source.getCoverage()[i] != null) {
                        existing.addCoverage(i + 1, source.getCoverage()[i]);
                    }
                }
            }
        }
        return combined.values();
View Full Code Here

        }
        return values;
    }
   
    private static void assertCoverage(final Collection<Source> sources, final String name, final int lines, final Set<Integer> coveredLines, final Set<Integer> missedLines) {
        Source tested = null;
        for (Source source : sources) {
            if (source.getName().endsWith(name)) {
                tested = source;
                break;
            }
        }
        if (tested == null) {
            fail("Expected source " + name + " not found from coverage report");
        }
        if (tested.getCoverage().length != lines) {
            fail("Expected " + lines + " lines for " + name + " was " + tested.getCoverage().length);
        }
        for (int i = 0; i < tested.getCoverage().length; i++) {
            Integer lineNumber = i + 1;
            String message = name + " line " + lineNumber + " coverage";
            if (coveredLines.contains(lineNumber)) {
                assertTrue(message, tested.getCoverage()[i] > 0);
            } else if (missedLines.contains(lineNumber)) {
                assertTrue(message, tested.getCoverage()[i] == 0);
            } else {
                assertNull(message, tested.getCoverage()[i]);
            }
        }

    }
View Full Code Here

        assertEquals(Position.AFTER, new CoverageTracingLogger(sourceCallbackMock).getPosition());
    }
   
    @Test
    public void testLogForSources() throws Exception {
        Source source1 = new Source("Source1.java", "public class Source1 {\n    \n}\n");
        source1.addCoverage(1, 0);
        source1.addCoverage(2, 0);
        source1.addCoverage(3, 0);
        Source source2 = new Source("Source2.java", "public class Source2 {\n    new Interface() { public void run() { } };\n}\n");
        source2.addCoverage(1, 1);
        source2.addCoverage(2, 1);
        source2.addCoverage(3, 1);
        Source source2inner = new Source("Source2.java", "public class Source2 {\n    new Interface() { public void run() { } };\n}\n");
        source2inner.setClassifier("$1");
        source2inner.addCoverage(2, 1);
       
        CoverageTracingLogger coverageTracingLogger = new CoverageTracingLogger(sourceCallbackMock);
        coverageTracingLogger.onSource(source1);
        coverageTracingLogger.onSource(source2);
        coverageTracingLogger.onSource(source2inner);
View Full Code Here

TOP

Related Classes of org.eluder.coveralls.maven.plugin.domain.Source

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.