From: <mwl...@us...> - 2007-09-10 16:38:07
|
Revision: 510 http://cishell.svn.sourceforge.net/cishell/?rev=510&view=rev Author: mwlinnem Date: 2007-09-10 09:38:02 -0700 (Mon, 10 Sep 2007) Log Message: ----------- Added "All Errors Report". Still pretty rough. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF Added Paths: ----------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/AllErrorReportGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/AllErrorReport.java Modified: trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java 2007-09-08 04:11:12 UTC (rev 509) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java 2007-09-10 16:38:02 UTC (rev 510) @@ -14,11 +14,13 @@ import org.cishell.testing.convertertester.core.tester2.ConverterTester2; import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.allconvs.AllConvsReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.allerrors.AllErrorReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.alltests.AllTestsReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.convgraph.AnnotatedGraphReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.convgraph.GraphReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.readme.ReadMeReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllConvsReport; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllErrorReport; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllTestsReport; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.ConvReport; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.FilePassReport; @@ -117,6 +119,8 @@ new AllTestsReportGenerator(this.log); AllConvsReportGenerator allConvGen = new AllConvsReportGenerator(this.log); + AllErrorReportGenerator allErrGen = + new AllErrorReportGenerator(this.log); GraphReportGenerator origGraphGen = new GraphReportGenerator(this.log); AnnotatedGraphReportGenerator graphGen = @@ -131,8 +135,8 @@ ConverterTester2 ct = new ConverterTester2(log); ct.execute(convRefs, new ReportGenerator[] - {allGen, allConvGen, graphGen, origGraphGen, - readmeGen}, + {allGen, allConvGen, allErrGen, + graphGen, origGraphGen, readmeGen}, cContext, bContext); /* * report generators have now been supplied with the test @@ -178,7 +182,6 @@ null); addReturn(allConvReportData); - //return each converter report ConvReport[] convReports = allConvReport.getConverterReports(); for (int ii = 0; ii < convReports.length; ii++) { @@ -193,6 +196,15 @@ addFilePasses(trs, convReportData); } + //return all errors report + + AllErrorReport allErrorReport = + allErrGen.getAllErrorsReport(); + File allErrReportFile = allErrorReport.getReportFile(); + Data allErrReport = createReportData(allErrReportFile, + allErrorReport.getName(), null); + addReturn(allErrReport); + //return annotated graph report File graphReportFile = graphGen.getGraphReport(); Modified: trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF 2007-09-08 04:11:12 UTC (rev 509) +++ trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF 2007-09-10 16:38:02 UTC (rev 510) @@ -21,11 +21,14 @@ org.cishell.testing.convertertester.core.tester, org.cishell.testing.convertertester.core.tester.graphcomparison, org.cishell.testing.convertertester.core.tester2, + org.cishell.testing.convertertester.core.tester2.fakelogger, org.cishell.testing.convertertester.core.tester2.graphcomparison, org.cishell.testing.convertertester.core.tester2.reportgen, org.cishell.testing.convertertester.core.tester2.reportgen.allconvs, + org.cishell.testing.convertertester.core.tester2.reportgen.allerrors, org.cishell.testing.convertertester.core.tester2.reportgen.alltests, org.cishell.testing.convertertester.core.tester2.reportgen.convgraph, + org.cishell.testing.convertertester.core.tester2.reportgen.faultanalysis, org.cishell.testing.convertertester.core.tester2.reportgen.readme, org.cishell.testing.convertertester.core.tester2.reportgen.reports, org.cishell.testing.convertertester.core.tester2.reportgen.results, Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/AllErrorReportGenerator.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/AllErrorReportGenerator.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/AllErrorReportGenerator.java 2007-09-10 16:38:02 UTC (rev 510) @@ -0,0 +1,210 @@ +package org.cishell.testing.convertertester.core.tester2.reportgen.allerrors; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.cishell.testing.convertertester.core.converter.graph.Converter; +import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.faultanalysis.ChanceAtFault; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllConvsReport; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllErrorReport; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.ConvReport; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.AllConvsResult; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.AllTestsResult; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.ConvResult; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.FilePassResult; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.TestResult; +import org.osgi.service.log.LogService; + +public class AllErrorReportGenerator implements ReportGenerator { + public static final String TEMP_FILE_PATH = "All-Errors-Report.txt"; + + private LogService log; + + private AllErrorReport allErrorsReport; + + public AllErrorReportGenerator(LogService log) { + this.log = log; + } + + public void generateReport(AllTestsResult atr, + AllConvsResult acr, + File nwbConvGraph) { + + Map explnToCafs = getChanceAtFaultsByExpln(acr); + + FileOutputStream reportOutStream = null; + try { + File reportFile = + new File(ReportGenerator.TEMP_DIR + TEMP_FILE_PATH); + reportOutStream = new FileOutputStream(reportFile); + PrintStream report = new PrintStream(reportOutStream); + + report.println("All Errors Report"); + report.println("---------------------------------------------"); + report.println("" ); + + Set explnSet = explnToCafs.keySet(); + String[] explns = (String[]) explnSet.toArray(new String[0]); + Arrays.sort(explns); + + for (int ii = 0; ii < explns.length; ii++) { + + report.println("------------"); + report.println("Error " + ii); + + String expln = explns[ii]; + + report.println(expln); + report.println(""); + + List CafsWithSameExpln = (List) explnToCafs.get(expln); + Map testToPassesToCafs = + categorizeByTestAndPass(CafsWithSameExpln); + Set tests = testToPassesToCafs.keySet(); + + Iterator testIter = tests.iterator(); + while (testIter.hasNext()) { + TestResult test = (TestResult) testIter.next(); + + report.println(test.getName()); + + Map passToCafs + = (Map) testToPassesToCafs.get(test); + + Set passes = passToCafs.keySet(); + Iterator passIter = passes.iterator(); + while (passIter.hasNext()) { + FilePassResult pass = (FilePassResult) passIter.next(); + + report.println(" " + pass.getName()); + + List cafs = (List) passToCafs.get(pass); + + Converter[] involvedConvs = pass.getConvertersInvolved(); + for (int jj = 0; jj < involvedConvs.length; jj++) { + Converter involvedConv = involvedConvs[jj]; + + ChanceAtFault associatedCaf = + getCafAssociatedWithProvidedConverter( + cafs, involvedConv); + + if (associatedCaf.getChanceAtFault() > 0.0f) { + report.println(" " + + involvedConv.getShortName() + " (%" + + associatedCaf.getChanceAtFault() + + " Chance At Fault)"); + } else { + report.println(" " + + involvedConv.getShortName()); + } + } + } + } + } + report.flush(); + + reportOutStream.close(); + + this.allErrorsReport = new AllErrorReport(reportFile, + "All Errors Report"); + + } catch (IOException e) { + + this.log.log(LogService.LOG_ERROR, "Unable to generate all converters report.", e); + try { + if (reportOutStream != null) reportOutStream.close(); + } catch (IOException e2) { + this.log.log(LogService.LOG_ERROR, "Unable to generate all converters report.", e); + } + } + } + + //expln = explanation + private Map getChanceAtFaultsByExpln(AllConvsResult acr) { + Map explnToCafs = new HashMap(); + + ConvResult[] crs = acr.getConvResults(); + for (int ii = 0; ii < crs.length; ii++) { + ConvResult cr = crs[ii]; + + ChanceAtFault[] cafs = cr.getAllChanceAtFaults(); + for (int jj = 0; jj < cafs.length; jj++) { + ChanceAtFault caf = cafs[jj]; + + String expln = caf.getExplanation(); + + if(explnToCafs.get(expln) != null) { + ((List)explnToCafs.get(expln)).add(caf); + } + else { + List cafsWithSameExpln = new ArrayList(); + cafsWithSameExpln.add(caf); + explnToCafs.put(expln, cafsWithSameExpln); + } + } + } + + return explnToCafs; + } + + //Map<test, Map<pass, List<cafs>>> + private Map categorizeByTestAndPass(List cafList) { + Map testToPassesToCafs = new HashMap(); + for (int ii = 0; ii < cafList.size(); ii++) { + ChanceAtFault caf = (ChanceAtFault) cafList.get(ii); + FilePassResult pass = caf.getFailedFilePass(); + TestResult test = pass.getParent(); + + Map passToCafs; + List cafs; + + passToCafs = (Map) testToPassesToCafs.get(test); + + if(passToCafs == null) { + passToCafs = new HashMap(); + + cafs = new ArrayList(); + } else { + cafs = (List) passToCafs.get(pass); + + if (cafs == null) { + cafs = new ArrayList(); + } + } + + cafs.add(caf); + passToCafs.put(pass, cafs); + testToPassesToCafs.put(test, passToCafs); + } + + return testToPassesToCafs; + } + + public AllErrorReport getAllErrorsReport() { + return this.allErrorsReport; + } + + public ChanceAtFault getCafAssociatedWithProvidedConverter( + List cafs, Converter conv) { + Iterator cafIter = cafs.iterator(); + while (cafIter.hasNext()) { + ChanceAtFault caf = (ChanceAtFault) cafIter.next(); + + if (caf.getConverter() == conv) { + return caf; + } + } + + return null; + } +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/AllErrorReport.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/AllErrorReport.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/AllErrorReport.java 2007-09-10 16:38:02 UTC (rev 510) @@ -0,0 +1,21 @@ +package org.cishell.testing.convertertester.core.tester2.reportgen.reports; + +import java.io.File; + +public class AllErrorReport implements Report { + + private File file; + private String name; + + public AllErrorReport(File file, String name) { + this.file = file; + this.name = name; + } + public String getName() { + return this.name; + } + + public File getReportFile() { + return this.file; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |