Search in sources :

Example 1 with ILanguageNames

use of org.jacoco.report.ILanguageNames in project jacoco by jacoco.

the class ClassRowWriterTest method setup.

@Before
public void setup() throws Exception {
    ILanguageNames names = new ILanguageNames() {

        public String getClassName(String vmname, String vmsignature, String vmsuperclass, String[] vminterfaces) {
            return vmname;
        }

        public String getPackageName(String vmname) {
            return vmname;
        }

        public String getQualifiedClassName(String vmname) {
            throw new AssertionError();
        }

        public String getMethodName(String vmclassname, String vmmethodname, String vmdesc, String vmsignature) {
            throw new AssertionError();
        }

        public String getQualifiedMethodName(String vmclassname, String vmmethodname, String vmdesc, String vmsignature) {
            throw new AssertionError();
        }
    };
    result = new StringWriter();
    writer = new ClassRowWriter(new DelimitedWriter(result), names);
}
Also used : StringWriter(java.io.StringWriter) ILanguageNames(org.jacoco.report.ILanguageNames) Before(org.junit.Before)

Example 2 with ILanguageNames

use of org.jacoco.report.ILanguageNames in project jacoco by jacoco.

the class HTMLFormatterTest method testGetLanguageNames.

@Test
public void testGetLanguageNames() throws Exception {
    ILanguageNames names = new ILanguageNames() {

        public String getPackageName(String vmname) {
            return null;
        }

        public String getQualifiedClassName(String vmname) {
            return null;
        }

        public String getClassName(String vmname, String vmsignature, String vmsuperclass, String[] vminterfaces) {
            return null;
        }

        public String getMethodName(String vmclassname, String vmmethodname, String vmdesc, String vmsignature) {
            return null;
        }

        public String getQualifiedMethodName(String vmclassname, String vmmethodname, String vmdesc, String vmsignature) {
            return null;
        }
    };
    formatter.setLanguageNames(names);
    assertSame(names, formatter.getLanguageNames());
    output.close();
}
Also used : ILanguageNames(org.jacoco.report.ILanguageNames) Test(org.junit.Test)

Example 3 with ILanguageNames

use of org.jacoco.report.ILanguageNames in project jacoco by jacoco.

the class RulesCheckerTest method testSetLanguageNames.

@Test
public void testSetLanguageNames() throws IOException {
    Rule rule = new Rule();
    rule.setElement(ElementType.CLASS);
    Limit limit = rule.createLimit();
    limit.setValue(CounterValue.MISSEDCOUNT.name());
    limit.setMaximum("5");
    checker.setRules(Arrays.asList(rule));
    checker.setLanguageNames(new ILanguageNames() {

        public String getQualifiedClassName(String vmname) {
            return "MyClass";
        }

        public String getQualifiedMethodName(String vmclassname, String vmmethodname, String vmdesc, String vmsignature) {
            return null;
        }

        public String getPackageName(String vmname) {
            return null;
        }

        public String getMethodName(String vmclassname, String vmmethodname, String vmdesc, String vmsignature) {
            return null;
        }

        public String getClassName(String vmname, String vmsignature, String vmsuperclass, String[] vminterfaces) {
            return null;
        }
    });
    driver.sendGroup(checker.createVisitor(this));
    assertEquals(Arrays.asList("Rule violated for class MyClass: instructions missed count is 10, but expected maximum is 5"), messages);
}
Also used : ILanguageNames(org.jacoco.report.ILanguageNames) Test(org.junit.Test)

Example 4 with ILanguageNames

use of org.jacoco.report.ILanguageNames in project jacoco by jacoco.

the class PageTestBase method setup.

protected void setup() throws Exception {
    output = new MemoryMultiReportOutput();
    rootFolder = new ReportOutputFolder(output);
    final Resources resources = new Resources(rootFolder);
    final Table table = new Table();
    table.add("Element", null, new LabelColumn(), true);
    context = new IHTMLReportContext() {

        public ILanguageNames getLanguageNames() {
            return new JavaNames();
        }

        public Resources getResources() {
            return resources;
        }

        public Table getTable() {
            return table;
        }

        public String getFooterText() {
            return "CustomFooter";
        }

        public ILinkable getSessionsPage() {
            return new LinkableStub("sessions.html", "Sessions", Styles.EL_SESSION);
        }

        public String getOutputEncoding() {
            return "UTF-8";
        }

        public IIndexUpdate getIndexUpdate() {
            return new IIndexUpdate() {

                public void addClass(ILinkable link, long classid) {
                }
            };
        }

        public Locale getLocale() {
            return Locale.ENGLISH;
        }
    };
    support = new HTMLSupport();
}
Also used : ReportOutputFolder(org.jacoco.report.internal.ReportOutputFolder) Locale(java.util.Locale) HTMLSupport(org.jacoco.report.internal.html.HTMLSupport) IIndexUpdate(org.jacoco.report.internal.html.index.IIndexUpdate) Table(org.jacoco.report.internal.html.table.Table) LinkableStub(org.jacoco.report.internal.html.LinkableStub) LabelColumn(org.jacoco.report.internal.html.table.LabelColumn) ILinkable(org.jacoco.report.internal.html.ILinkable) ILanguageNames(org.jacoco.report.ILanguageNames) MemoryMultiReportOutput(org.jacoco.report.MemoryMultiReportOutput) Resources(org.jacoco.report.internal.html.resources.Resources) IHTMLReportContext(org.jacoco.report.internal.html.IHTMLReportContext) JavaNames(org.jacoco.report.JavaNames)

Example 5 with ILanguageNames

use of org.jacoco.report.ILanguageNames in project jacoco by jacoco.

the class SessionsPage method executionDataTable.

private void executionDataTable(final HTMLElement body) throws IOException {
    final HTMLElement table = body.table(Styles.COVERAGETABLE);
    {
        final HTMLElement tr = table.thead().tr();
        tr.td().text("Class");
        tr.td().text("Id");
    }
    final HTMLElement tbody = table.tbody();
    final ILanguageNames names = context.getLanguageNames();
    for (final ExecutionData e : executionData) {
        final HTMLElement tr = tbody.tr();
        final String link = index.getLinkToClass(e.getId());
        final String qualifiedName = names.getQualifiedClassName(e.getName());
        if (link == null) {
            tr.td().span(Styles.EL_CLASS).text(qualifiedName);
        } else {
            tr.td().a(link, Styles.EL_CLASS).text(qualifiedName);
        }
        final String id = String.format("%016x", Long.valueOf(e.getId()));
        tr.td().code().text(id);
    }
}
Also used : HTMLElement(org.jacoco.report.internal.html.HTMLElement) ILanguageNames(org.jacoco.report.ILanguageNames) ExecutionData(org.jacoco.core.data.ExecutionData)

Aggregations

ILanguageNames (org.jacoco.report.ILanguageNames)6 Test (org.junit.Test)3 StringWriter (java.io.StringWriter)1 Locale (java.util.Locale)1 ExecutionData (org.jacoco.core.data.ExecutionData)1 JavaNames (org.jacoco.report.JavaNames)1 MemoryMultiReportOutput (org.jacoco.report.MemoryMultiReportOutput)1 ReportOutputFolder (org.jacoco.report.internal.ReportOutputFolder)1 HTMLElement (org.jacoco.report.internal.html.HTMLElement)1 HTMLSupport (org.jacoco.report.internal.html.HTMLSupport)1 IHTMLReportContext (org.jacoco.report.internal.html.IHTMLReportContext)1 ILinkable (org.jacoco.report.internal.html.ILinkable)1 LinkableStub (org.jacoco.report.internal.html.LinkableStub)1 IIndexUpdate (org.jacoco.report.internal.html.index.IIndexUpdate)1 Resources (org.jacoco.report.internal.html.resources.Resources)1 LabelColumn (org.jacoco.report.internal.html.table.LabelColumn)1 Table (org.jacoco.report.internal.html.table.Table)1 Before (org.junit.Before)1