Examples of ProjectData


Examples of net.sourceforge.cobertura.coveragedata.ProjectData

        return data;
    }

    @Test
    public void testDiff() {
        ProjectData one = buildBaseProjectData();
        ProjectData two = buildBaseProjectData();
        addSomeStuff(two, "foo", 2);
        touchAJump(two, "foo", 1, true);
        touchAJump(two, "foo", 1, false);
        touchASwitch(two, "bar", 2, 2);
        touchASwitch(two, "bar", 2, -1);
        addSomeStuff(two, "baz", 8);

        // sanity check on the raw data.
        assertEquals(1, ((JumpData) one.getClassData("foo").getLineCoverage(1)
                .getConditionData(0)).getTrueHits());
        assertEquals(0, ((JumpData) one.getClassData("foo").getLineCoverage(1)
                .getConditionData(0)).getFalseHits());
        assertEquals(2, ((JumpData) two.getClassData("foo").getLineCoverage(1)
                .getConditionData(0)).getTrueHits());
        assertEquals(1, ((JumpData) two.getClassData("foo").getLineCoverage(1)
                .getConditionData(0)).getFalseHits());

        assertEquals(1, ((SwitchData) one.getClassData("bar")
                .getLineCoverage(2).getConditionData(0)).getDefaultHits());
        assertEquals(0, ((SwitchData) one.getClassData("bar")
                .getLineCoverage(2).getConditionData(0)).getHits(0));
        assertEquals(1, ((SwitchData) one.getClassData("bar")
                .getLineCoverage(2).getConditionData(0)).getHits(1));
        // assertEquals( 0, ((SwitchData)
        // one.getClassData("bar").getLineCoverage( 2 ).getConditionData( 0 )
        // ).getHits( 2 ));
        assertEquals(2, ((SwitchData) two.getClassData("bar")
                .getLineCoverage(2).getConditionData(0)).getDefaultHits());
        assertEquals(0, ((SwitchData) two.getClassData("bar")
                .getLineCoverage(2).getConditionData(0)).getHits(0));
        assertEquals(1, ((SwitchData) two.getClassData("bar")
                .getLineCoverage(2).getConditionData(0)).getHits(1));
        assertEquals(1, ((SwitchData) two.getClassData("bar")
                .getLineCoverage(2).getConditionData(0)).getHits(2));

        ProjectDataDifferenceCalculator calc = new ProjectDataDifferenceCalculator(
                two, one);
        ProjectData diff = calc.getDifference();
        assertSame(calc.getLarger(), two);
        assertSame(calc.getSmaller(), one);
        ClassData foo = diff.getClassData("foo");
        assertEquals(3, foo.getLines().size());
        for (int i = 0; i < 2; i++) {
            LineData x = foo.getLineCoverage(i);
            assertEquals(x.getHits(), 1);
            assertEquals(x.hasBranch(), i == 1);
            if (x.hasBranch()) {
                JumpData jd = (JumpData) x.getConditionData(0);
                assertEquals(jd.getTrueHits(), 1);
                assertEquals(jd.getFalseHits(), 1);
            }
        }
        assertEquals(foo.getLineCoverage(2).getHits(), 0);
        ClassData bar = diff.getClassData("bar");
        assertEquals(3, bar.getLines().size());
        for (int i = 0; i < 3; i++) {
            LineData x = bar.getLineCoverage(i);
            assertEquals(x.getHits(), 0);
            assertEquals(x.hasBranch(), i == 2, "Switches for " + i);
            if (x.hasBranch()) {
                SwitchData sd = (SwitchData) x.getConditionData(0);
                assertEquals(1, sd.getDefaultHits());
                assertEquals(0, sd.getHits(0));
                assertEquals(0, sd.getHits(1));
                assertEquals(1, sd.getHits(2));

            }
        }
        ClassData baz = diff.getClassData("baz");
        assertEquals(8, baz.getLines().size());
        for (int i = 0; i < 8; i++) {
            LineData x = baz.getLineCoverage(i);
            assertEquals(x.getHits(), 1);
            assertFalse(x.hasBranch());
View Full Code Here

Examples of net.sourceforge.cobertura.coveragedata.ProjectData

        assertEquals(calc.getErrors().size(), 2);
    }

    @Test
    public void testDisappearingClasses() {
        ProjectData small = buildBaseProjectData();
        ProjectData large = buildBaseProjectData();
        addSomeStuff(large, "baz", 3); // ok.
        addSomeStuff(small, "zoop", 3); // not decent behavior.
        touchAJump(small, "zoop", 8, true);
        touchASwitch(small, "zoop", 9, 0);
View Full Code Here

Examples of net.sourceforge.cobertura.coveragedata.ProjectData

    }

    @Test
    public void testDisappearingLines() {
        ProjectData small = buildBaseProjectData();
        ProjectData large = buildBaseProjectData();
        addSomeStuff(large, "baz", 3);
        addSomeStuff(small, "baz", 5); // not expected behavior.
        ProjectDataDifferenceCalculator calc = new ProjectDataDifferenceCalculator(
                large, small);
        System.out.println("Errors: " + calc.getErrors());
View Full Code Here

Examples of net.sourceforge.cobertura.coveragedata.ProjectData

        dissappearingJump(true);
        dissappearingJump(false);
    }

    void dissappearingJump(boolean b) {
        ProjectData small = buildBaseProjectData();
        ProjectData large = buildBaseProjectData();
        touchAJump(small, "foo", 1, b);
        ProjectDataDifferenceCalculator calc = new ProjectDataDifferenceCalculator(
                large, small);
        assertEquals(calc.getErrors().size(), 1);
        assertTrue(calc.getErrors().get(0).indexOf("Jump") > -1);
View Full Code Here

Examples of net.sourceforge.cobertura.coveragedata.ProjectData

        assertTrue(calc.getErrors().get(0).indexOf("false") > 0);
    }

    @Test
    void testDisappearingSwitches() {
        ProjectData large = buildBaseProjectData();
        ProjectData small = buildBaseProjectData();
        small = buildBaseProjectData();
        touchASwitch(small, "bar", 2, 0);
        touchASwitch(small, "bar", 2, -1);
        touchASwitch(small, "bar", 1, 1);
        ProjectDataDifferenceCalculator calc = new ProjectDataDifferenceCalculator(
View Full Code Here

Examples of net.sourceforge.cobertura.coveragedata.ProjectData

    }

    void loadSpeciallyNamedCoverageFile(File x) {
        Object[] pair = parseNameAndIndexFromFileName(x.getName());
        Integer index = Integer.valueOf((String) pair[1]);
        ProjectData data = readCoverageFile(x);
        PackageAndProjectData ppd = new PackageAndProjectData(data,
                (String) pair[0], x);
        indexedPackageData.put(index, ppd);
    }
View Full Code Here

Examples of net.sourceforge.cobertura.coveragedata.ProjectData

                (String) pair[0], x);
        indexedPackageData.put(index, ppd);
    }

    public static ProjectData readCoberturaCoverageFile(File x) {
        ProjectData data = CoverageDataFileHandler.loadCoverageData(x);
        if (data == null) {
            throw new RuntimeException("File " + x.getName() + " is corrupt.");
        }
        return data;
    }
View Full Code Here

Examples of net.sourceforge.cobertura.coveragedata.ProjectData

                        if (x instanceof PackageDataPair) {
                            PackageData pd = (PackageData) x.getData();
                            complexity = complexityCalc.getCCNForPackage(pd);
                        }
                        if (x instanceof ProjectDataPair) {
                            ProjectData pjd = (ProjectData) x.getData();
                            complexity = complexityCalc.getCCNForProject(pjd);
                        }
                        if (complexity != null) {
                            result.put("complexity", complexity.doubleValue());
                        } else {
View Full Code Here

Examples of net.sourceforge.cobertura.coveragedata.ProjectData

public class ProjectDataHolderTest extends Assert {

    @Test
    public void testCaching() throws Exception {
        File f = File.createTempFile( "pp-pdh-unittest", null);
        ProjectDataHolder pdh = new ProjectDataHolder( new ProjectData(), f );
        pdh.saveChanges();
        assertEquals( 1, pdh.getSaves() );
        ProjectData before = pdh.getData();
        assertEquals( 1, pdh.getHits() );
        assertEquals( 0, pdh.getMisses() );
        pdh.ref.clear();
        ProjectData after = pdh.getData();
        assertEquals( 1, pdh.getHits() );
        assertEquals( 1, pdh.getMisses() );
        assertTrue( before != after );
        assertNotNull( after );
        assertNotNull( before );
        assertSame( f, pdh.getFile() );
       
        pdh = new ProjectDataHolder( new ProjectData() );
        pdh.saveChanges();
        pdh.getData();
        assertEquals( 0, pdh.getHits() );
        assertEquals( 0, pdh.getMisses() );
        assertEquals( 0, pdh.getSaves() );
View Full Code Here

Examples of net.sourceforge.cobertura.coveragedata.ProjectData

        // caching;
        PackageAndProjectData ppd = accum.getIndexedPackageData().values().iterator().next();
        Assert.assertNotNull( ppd.getFile() );
        int hits = ppd.getHits();
        int misses = ppd.getMisses();
        ProjectData before = ppd.getData();
        assertEquals( ppd.getHits(), ++hits );
        assertEquals( ppd.getMisses(), misses );
        ppd.dataRef.clear();
        ProjectData after = ppd.getData();
        assertEquals( ppd.getHits(), hits );
        assertEquals( ppd.getMisses(), ++misses );
        assertFalse( before == after );
        assertEquals( before.getLineCoverageRate(), after.getLineCoverageRate(), .000000001 );
        assertEquals( before.getNumberOfChildren(), after.getNumberOfChildren() );
       

    }
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.