|
From: <mwl...@us...> - 2007-09-20 21:07:18
|
Revision: 531
http://cishell.svn.sourceforge.net/cishell/?rev=531&view=rev
Author: mwlinnem
Date: 2007-09-20 14:07:14 -0700 (Thu, 20 Sep 2007)
Log Message:
-----------
Way too many changes to list. User can now filter reports by converter or by test path length. Handle lossiness correctly now. Lots of little changes to reports.
Modified Paths:
--------------
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/ConverterTesterAlgorithmFactory.java
trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConvResultMaker.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConverterTester2.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/fakelogger/FakeLogService.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allconvs/AllConvsReportGenerator.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allconvs/ConvReportSubGenerator.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/DefaultErrorSourceAnalyzer.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvResult.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/TestResult.java
Added Paths:
-----------
trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmUtil.java
trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/pathfilter/
trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/pathfilter/ConvAndHopFilter.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/pathfilter/
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/pathfilter/PathFilter.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/ErrorProximityHeuristic.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/WeightedTrustHeuristic.java
Removed Paths:
-------------
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/WeightedFullTrustHeuristic.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-18 03:11:08 UTC (rev 530)
+++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -11,6 +11,7 @@
import org.cishell.framework.data.BasicData;
import org.cishell.framework.data.Data;
import org.cishell.framework.data.DataProperty;
+import org.cishell.testing.convertertester.algorithm.pathfilter.ConvAndHopFilter;
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;
@@ -44,6 +45,10 @@
private BundleContext bContext;
private LogService log;
+ private boolean testAllConvs;
+ private String selectedConvName;
+ private int numHops;
+
public ConverterTesterAlgorithm(Data[] data, Dictionary parameters,
CIShellContext cContext, BundleContext bContext ) {
this.cContext = cContext;
@@ -52,6 +57,14 @@
this.log = (LogService) cContext.getService(
LogService.class.getName());
+
+ this.testAllConvs = ((Boolean) parameters.get(
+ ConverterTesterAlgorithmFactory.TEST_ALL_CONVS_PARAM_ID)).booleanValue();
+ this.selectedConvName = ((String) parameters.get(
+ ConverterTesterAlgorithmFactory.SELECTED_CONVERTER_PARAM_ID));
+ this.numHops = ((Integer) parameters.get(
+ ConverterTesterAlgorithmFactory.NUM_HOPS_PARAM_ID)).intValue();
+
}
public Data[] execute() {
@@ -59,7 +72,7 @@
"\r\n" +
"-------NOTICE-------" + "\r\n" +
"The Converter Tester will take " +
- "approximately 30 seconds to run all the tests. \r\n" +
+ "some time to run all the tests. \r\n" +
"Thank you for waiting :)" + "\r\n" +
"-----END NOTICE----- \r\n");
@@ -108,8 +121,11 @@
public void run () {
try {
+ System.out.println("getting converter references....");
//get all the converters
- ServiceReference[] convRefs = getConverterReferences();
+ ServiceReference[] convRefs =
+ ConverterTesterAlgorithmUtil.
+ getConverterReferences(bContext);
@@ -132,17 +148,32 @@
* execute the tests, and provide the results to the
* report generators
*/
+
+ System.out.println("Executing tests...");
+
ConverterTester2 ct = new ConverterTester2(log);
- ct.execute(convRefs,
- new ReportGenerator[]
- {allGen, allConvGen, allErrGen,
- graphGen, origGraphGen, readmeGen},
- cContext, bContext);
+
+ if (testAllConvs) {
+ ct.execute(convRefs,
+ new ReportGenerator[]
+ {allGen, allConvGen, allErrGen,
+ graphGen, origGraphGen, readmeGen},
+ cContext, bContext);
+ } else {
+ ct.execute(convRefs,
+ new ReportGenerator[]
+ {allGen, allConvGen, allErrGen,
+ graphGen, origGraphGen, readmeGen},
+ cContext, bContext,
+ new ConvAndHopFilter(selectedConvName, numHops));
+ }
/*
* report generators have now been supplied with the test
* results, and their reports can now be extracted.
*/
+ System.out.println("Returning reports...");
+
//return readme report
ReadMeReport readmeReport = readmeGen.getReadMe();
@@ -319,23 +350,5 @@
- private ServiceReference[] getConverterReferences() {
- String filter = "(&("+ALGORITHM_TYPE+"="+TYPE_CONVERTER+"))";
-
- try {
- ServiceReference[] refs = bContext.getServiceReferences(
- AlgorithmFactory.class.getName(), filter);
-
- return refs;
- } catch (InvalidSyntaxException e) {
- this.log.log(LogService.LOG_ERROR, "Invalid syntax '" + filter +
- "' for filtering service references. Attempted to " +
- "obtain all converter references.", e);
- return null;
- }
- }
-
-
-
}
\ No newline at end of file
Modified: trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmFactory.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmFactory.java 2007-09-18 03:11:08 UTC (rev 530)
+++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmFactory.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -1,30 +1,110 @@
package org.cishell.testing.convertertester.algorithm;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Dictionary;
+import java.util.List;
import org.cishell.framework.CIShellContext;
import org.cishell.framework.algorithm.Algorithm;
import org.cishell.framework.algorithm.AlgorithmFactory;
import org.cishell.framework.data.Data;
+import org.cishell.reference.service.metatype.BasicAttributeDefinition;
+import org.cishell.reference.service.metatype.BasicMetaTypeProvider;
+import org.cishell.reference.service.metatype.BasicObjectClassDefinition;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentContext;
+import org.osgi.service.metatype.AttributeDefinition;
+import org.osgi.service.metatype.MetaTypeInformation;
import org.osgi.service.metatype.MetaTypeProvider;
+import org.osgi.service.metatype.MetaTypeService;
+import org.osgi.service.metatype.ObjectClassDefinition;
public class ConverterTesterAlgorithmFactory implements AlgorithmFactory {
+
+ public static final String SELECTED_CONVERTER_PARAM_ID = "selectedConverter";
+ public static final String NUM_HOPS_PARAM_ID = "numHops";
+ public static final String TEST_ALL_CONVS_PARAM_ID = "testAllConvs";
private BundleContext bContext;
+ private MetaTypeInformation originalProvider;
+ private String pid;
protected void activate(ComponentContext ctxt) {
this.bContext = ctxt.getBundleContext();;
+ MetaTypeService mts = (MetaTypeService)ctxt.locateService("MTS");
+ this.pid = (String) ctxt.getServiceReference().getProperty(org.osgi.framework.Constants.SERVICE_PID);
+ this.originalProvider = mts.getMetaTypeInformation(ctxt.getBundleContext().getBundle());
}
protected void deactivate(ComponentContext ctxt) {
+ originalProvider = null;
}
public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) {
return new ConverterTesterAlgorithm(data, parameters, context, bContext);
}
public MetaTypeProvider createParameters(Data[] data) {
- return null;
+
+ String[] converterNames = extractConverterNames(
+ ConverterTesterAlgorithmUtil.
+ getConverterReferences(bContext));
+
+
+
+ ObjectClassDefinition oldDefinition = originalProvider.getObjectClassDefinition(this.pid, null);
+
+ BasicObjectClassDefinition definition;
+ try {
+ definition = new BasicObjectClassDefinition(oldDefinition.getID(), oldDefinition.getName(), oldDefinition.getDescription(), oldDefinition.getIcon(16));
+ } catch (IOException e) {
+ definition = new BasicObjectClassDefinition(oldDefinition.getID(), oldDefinition.getName(), oldDefinition.getDescription(), null);
+ }
+
+ definition.addAttributeDefinition(ObjectClassDefinition.REQUIRED,
+ new BasicAttributeDefinition(SELECTED_CONVERTER_PARAM_ID,
+ "Converter To Test",
+ "The converter that you wish to test",
+ AttributeDefinition.STRING,
+ converterNames,
+ converterNames));
+
+ definition.addAttributeDefinition(ObjectClassDefinition.REQUIRED,
+ new BasicAttributeDefinition(NUM_HOPS_PARAM_ID,
+ "Max Test Path Length",
+ "What is the maximum length a test path should have to be included",
+ AttributeDefinition.INTEGER));
+
+ definition.addAttributeDefinition(ObjectClassDefinition.REQUIRED,
+ new BasicAttributeDefinition(TEST_ALL_CONVS_PARAM_ID,
+ "Test All Converters?",
+ "Should we test all the converters or just the one selected?",
+ AttributeDefinition.BOOLEAN));
+
+ MetaTypeProvider provider = new BasicMetaTypeProvider(definition);
+ return provider;
}
+
+ private String[] extractConverterNames(ServiceReference[] converterRefs) {
+ List converterNames = new ArrayList();
+ for (int ii = 0; ii < converterRefs.length; ii++) {
+ ServiceReference converterRef = converterRefs[ii];
+
+ String converterName = removePackagePrefix(
+ (String) converterRef.getProperty("service.pid"));
+ converterNames.add(converterName);
+ }
+
+ return (String[]) converterNames.toArray(new String[0]);
+ }
+
+ /*
+ * Returns everything after the last period in the OSGi service pid.
+ */
+ private String removePackagePrefix(String pid) {
+ int startIndex = pid.lastIndexOf(".") + 1;
+ return pid.substring(startIndex);
+ }
}
\ No newline at end of file
Added: trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmUtil.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmUtil.java (rev 0)
+++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmUtil.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -0,0 +1,28 @@
+package org.cishell.testing.convertertester.algorithm;
+
+import org.cishell.framework.algorithm.AlgorithmFactory;
+import org.cishell.framework.algorithm.AlgorithmProperty;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+
+public class ConverterTesterAlgorithmUtil implements AlgorithmProperty {
+ public static ServiceReference[] getConverterReferences(
+ BundleContext bContext) {
+ String filter = "(&("+ALGORITHM_TYPE+"="+TYPE_CONVERTER+"))";
+
+ try {
+ ServiceReference[] refs = bContext.getServiceReferences(
+ AlgorithmFactory.class.getName(), filter);
+
+ return refs;
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid syntax '" + filter +
+ "' for filtering service references. Attempted to " +
+ "obtain all converter references.");
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
Added: trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/pathfilter/ConvAndHopFilter.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/pathfilter/ConvAndHopFilter.java (rev 0)
+++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/pathfilter/ConvAndHopFilter.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -0,0 +1,39 @@
+package org.cishell.testing.convertertester.algorithm.pathfilter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.cishell.testing.convertertester.core.converter.graph.ConverterPath;
+import org.cishell.testing.convertertester.core.tester2.pathfilter.PathFilter;
+
+public class ConvAndHopFilter implements PathFilter {
+
+ private String mustHaveConvName;
+ private int maxNumHops;
+
+ public ConvAndHopFilter(String mustHaveConvName, int maxNumHops) {
+ this.mustHaveConvName = mustHaveConvName;
+ this.maxNumHops = maxNumHops;
+ }
+
+ public ConverterPath[] filter(ConverterPath[] testPaths) {
+ if (testPaths != null) {
+ List filteredTestPaths = new ArrayList();
+ for (int ii = 0; ii < testPaths.length; ii++) {
+ ConverterPath testPath = testPaths[ii];
+
+ if (testPath.containsConverterNamed(this.mustHaveConvName) &&
+ testPath.size() <= this.maxNumHops) {
+ filteredTestPaths.add(testPath);
+ }
+ }
+
+ return (ConverterPath[])
+ filteredTestPaths.toArray(new ConverterPath[0]);
+
+ } else {
+ return new ConverterPath[0];
+ }
+ }
+
+}
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-18 03:11:08 UTC (rev 530)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF 2007-09-20 21:07:14 UTC (rev 531)
@@ -23,9 +23,11 @@
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.pathfilter,
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.allerrors.analyzer,
org.cishell.testing.convertertester.core.tester2.reportgen.alltests,
org.cishell.testing.convertertester.core.tester2.reportgen.convgraph,
org.cishell.testing.convertertester.core.tester2.reportgen.faultanalysis,
@@ -33,4 +35,5 @@
org.cishell.testing.convertertester.core.tester2.reportgen.reports,
org.cishell.testing.convertertester.core.tester2.reportgen.results,
org.cishell.testing.convertertester.core.tester2.reportgen.results.converter,
- org.cishell.testing.convertertester.core.tester2.reportgen.results.filepass
+ org.cishell.testing.convertertester.core.tester2.reportgen.results.filepass,
+ org.cishell.testing.convertertester.core.tester2.util
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java 2007-09-18 03:11:08 UTC (rev 530)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -48,10 +48,13 @@
fileExtensionCompareConverters =
new ConcurrentHashMap();//<String, ConverterPath>();
+ System.out.println("Deriving data formats...");
deriveDataFormats(this.converters, this.dataFormats);
+ System.out.println("Associating Converters...");
associateConverters(this.converters, this.inDataToConverters, this.outDataToConverters);
+ System.out.println("Creating converter paths...");
createConverterPaths(this.inDataToConverters, this.fileExtensionTestConverters, this.fileExtensionCompareConverters);
-
+ System.out.println("Done creating converter paths...");
}
private Converter[] createConverters(ServiceReference[] convRefs) {
@@ -82,50 +85,67 @@
Converter c = cs[i];
String inDataFormat = c.getInData();
- addValueToListAssociatedWithKey(inDataToConvs, inDataFormat, c);
+ addUniqueValueToListAssociatedWithKey(
+ inDataToConvs, inDataFormat, c);
String outDataFormat = c.getOutData();
- addValueToListAssociatedWithKey(outDataToConvs, outDataFormat, c);
+ addUniqueValueToListAssociatedWithKey(
+ outDataToConvs, outDataFormat, c);
}
}
- private void createConverterPaths(Map algorithms, Map testPaths,
- Map comparePaths){
- String[] keySet = new String[algorithms.keySet().size()];
- keySet = (String[])algorithms.keySet().toArray(keySet);
- for(int i = 0; i < keySet.length; i++){
- String s = keySet[i];
- if(s.startsWith("file-ext")){
+ private void createConverterPaths(Map inDataToConverters,
+ Map fileExtToTestConverters, Map fileExtToCompareConverters){
+ String[] inDataFormats = new String[inDataToConverters.keySet().size()];
+
+ inDataFormats =
+ (String[])inDataToConverters.keySet().toArray(inDataFormats);
+
+ for(int i = 0; i < inDataFormats.length; i++){
+ String inDataFormat = inDataFormats[i];
+ if(inDataFormat.startsWith("file-ext")){
-
+ System.out.println("Creating paths for format: " + inDataFormat);
ConverterPath test = new ConverterPath(this.bContext, this.log);
- test.setInData(s);
+ test.setInData(inDataFormat);
- createPaths((List)algorithms.get(s), test, s);
+ createPaths((List)inDataToConverters.get(inDataFormat),
+ test);
}
}
}
- private ConverterPath createPaths(List algorithms, ConverterPath path, String dataType){
- List cs = removeReferences(algorithms, path);
+ private void createPaths(List allConvsForFormat, ConverterPath currentPath) {
+ List nextConvs = removeReferences(allConvsForFormat, currentPath);
- addCompareCycle(path);
+ addCompareCycle(currentPath);
- if(path.getInData().equals(path.getOutData())){
- addTestCycle(path);
- return path;
+ if(currentPath.getInData().equals(currentPath.getOutData())){
+ //base case
+ addTestCycle(currentPath);
+ System.out.println("**--Path Completed--**");
+ List path = currentPath.getPath();
+ System.out.println("Path is...");
+ for (int ii = 0; ii < path.size(); ii++) {
+ Converter c = (Converter) path.get(ii);
+ System.out.println(" " + c.getShortName());
+ }
+ System.out.println("(End Path)");
+ return;
}
- while(!cs.isEmpty()){
- ConverterPath p = new ConverterPath(path, this.bContext);
- p.add((Converter) cs.get(0));
- cs.remove(0);
- createPaths((List)this.inDataToConverters.get(p.getOutData()), p, p.getOutData());
+ while(!nextConvs.isEmpty()){
+ ConverterPath newPath = new ConverterPath(currentPath, this.bContext);
+ Converter nextConv = (Converter) nextConvs.get(0);
+ System.out.println("Adding " + nextConv.getShortName());
+ newPath.add(nextConv);
+ nextConvs.remove(0);
+ createPaths((List)this.inDataToConverters.get(newPath.getOutData()), newPath);
}
- return null;
+ return;
}
private void addTestCycle(ConverterPath cp){
@@ -159,21 +179,35 @@
}
}
- private static List removeReferences(List al, ConverterPath cp){
+ private static List removeReferences(List allConvsForFormat,
+ ConverterPath currentPath){
List cs;
- if (al != null) {
- cs = new ArrayList(al);
+ if (allConvsForFormat != null) {
+ cs = new ArrayList(allConvsForFormat);
} else {
cs = new ArrayList();
}
+ System.out.println("Current path is....");
+ for (int ii = 0; ii < currentPath.size(); ii++) {
+ System.out.println(currentPath.get(ii).getShortName());
+ }
- cs.removeAll(cp.getPath());
+ System.out.println("^^^^ cs prior to removing loop causing convs");
+ for (int ii = 0; ii < cs.size(); ii++) {
+ System.out.println(((Converter) cs.get(ii)).getShortName());
+ }
+ cs.removeAll(currentPath.getPath());
+ System.out.println("^^^^ cs after removing loop causing convs");
+ for (int ii = 0; ii < cs.size(); ii++) {
+ System.out.println(((Converter) cs.get(ii)).getShortName());
+ }
+ //do we really want to be removing these?
List forbidden = new ArrayList();
for(int i = 0; i < cs.size(); i++){
Converter c = (Converter) cs.get(i);
String outData = c.getOutData();
- if(outData.startsWith("file-ext") && (!outData.equals(cp.getInData()))){
+ if(outData.startsWith("file-ext") && (!outData.equals(currentPath.getInData()))){
forbidden.add(c);
}
@@ -496,7 +530,23 @@
m.put(key, listOfValues);
}
else{
- ((List)m.get(key)).add(value);
+ List values = (List) m.get(key);
+ values.add(value);
}
}
+
+ private void addUniqueValueToListAssociatedWithKey(Map m, Object key, Object value) {
+
+ if(m.get(key) == null){
+ List listOfValues = new ArrayList();
+ listOfValues.add(value);
+ m.put(key, listOfValues);
+ }
+ else{
+ List values = (List) m.get(key);
+ if (! values.contains(value)) {
+ values.add(value);
+ }
+ }
+ }
}
\ No newline at end of file
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java 2007-09-18 03:11:08 UTC (rev 530)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -127,6 +127,7 @@
Converter c = (Converter) this.path.get(i);
if (c.isLossy()) {
+ System.out.println("FOUND A LOSSY CONVERTER!");
lossiness = LOSSY;
}
}
@@ -146,6 +147,19 @@
return this.path.size();
}
+ public boolean containsConverterNamed(String convName) {
+ for (int ii = 0; ii < this.path.size(); ii++) {
+ Converter conv = (Converter) this.path.get(ii);
+
+ if (conv.getShortName().equals(convName) ||
+ conv.getUniqueName().equals(convName)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
public String getConverterName(int index) {
return (String) get(index).getUniqueName();
}
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConvResultMaker.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConvResultMaker.java 2007-09-18 03:11:08 UTC (rev 530)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConvResultMaker.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -20,6 +20,11 @@
public class ConvResultMaker {
+ //must succeed at least 3 times in the file pass
+ private static int MINIMUM_SUCCESSES_TO_BE_TRUSTED = 3;
+ //must be tested by at least 2/3rds of file passes in test
+ private static float MINIMUM_PERCENT_FILE_PASSES_REACHED_TO_BE_TRUSTED = .8f;
+
public static AllConvsResult generate(AllTestsResult atr,
Converter[] allConvs, ChanceAtFaultHeuristic faultHeuristic) {
@@ -56,26 +61,67 @@
TestResult tr = trs[ii];
FilePassResult[] fprs = tr.getFilePassResults();
- //check if all file passes were successes
- boolean trusted = true;
+ //determine which converters always succeeded.
+
+ int FAILED = -1;
+ int NEVER_TESTED = 0;
+
+ int[] trusted = new int[tr.getAllConverters().length];
for (int jj = 0; jj < fprs.length; jj++) {
FilePassResult fpr = fprs[jj];
- if (! fpr.succeeded()) {
- //not all were successes
- trusted = false;
- break;
+
+ if (fpr.succeeded()) {
+ for (int kk = 0; kk < trusted.length; kk++) {
+ if (trusted[kk] != FAILED) {
+ trusted[kk] += 1;
+ }
+ }
+ } else if (fpr.failedWhileComparingGraphs()) {
+ for (int kk = 0; kk < trusted.length; kk++) {
+ trusted[kk] = FAILED;
+ }
+ } else if (fpr.failedWhileConverting()) {
+ Converter[] convsInvolved = fpr.getConvertersInvolved();
+ for (int kk = 0; kk < convsInvolved.length; kk++) {
+ trusted[kk] = FAILED;
+ }
}
- }
+
+ }
- if (trusted && fprs.length > 0) {
- //mark all converters involved as trusted.
+ Converter[] allConvs = tr.getAllConverters();
+ ConverterPath testConvs = tr.getTestConverters();
+ if (fprs.length > 0) {
+ //mark trusted converters.
- ConverterPath testConvs = tr.getTestConverters();
+
for (int kk = 0; kk < testConvs.size(); kk++) {
- Converter conv = testConvs.get(kk);
- trustedConverters.add(conv);
+ Converter c = testConvs.get(kk);
+ float percentFilePassesThisConvParticipatedIn =
+ trusted[kk] / (float) fprs.length;
+ if (trusted[kk] >= MINIMUM_SUCCESSES_TO_BE_TRUSTED &&
+ percentFilePassesThisConvParticipatedIn >=
+ MINIMUM_PERCENT_FILE_PASSES_REACHED_TO_BE_TRUSTED) {
+ trustedConverters.add(c);
+ }
}
+// ConverterPath testConvs = tr.getAllConverters();
+// for (int kk = 0; kk < testConvs.length; kk++) {
+// Converter conv = testConvs[kk];
+// if (trusted[kk] == ALWAYS_SUCCEEDED) {
+// trustedConverters.add(conv);
+// }
+// }
+
+// //technically I wouldn't trust the comparison
+// //converters here, but I'm adding this because
+// //it makes the results easier to understand.
+// ConverterPath compareConvs = tr.getComparisonConverters();
+// for (int kk = 0; kk < compareConvs.size(); kk++) {
+// Converter conv = compareConvs.get(kk);
+// trustedConverters.add(conv);
+// }
}
}
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConverterTester2.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConverterTester2.java 2007-09-18 03:11:08 UTC (rev 530)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConverterTester2.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -20,9 +20,10 @@
import org.cishell.testing.convertertester.core.tester2.graphcomparison.IdsPreservedComparer;
import org.cishell.testing.convertertester.core.tester2.graphcomparison.LossyComparer;
import org.cishell.testing.convertertester.core.tester2.graphcomparison.NewGraphComparer;
+import org.cishell.testing.convertertester.core.tester2.pathfilter.PathFilter;
import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator;
import org.cishell.testing.convertertester.core.tester2.reportgen.faultanalysis.ChanceAtFaultHeuristic;
-import org.cishell.testing.convertertester.core.tester2.reportgen.faultanalysis.WeightedFullTrustHeuristic;
+import org.cishell.testing.convertertester.core.tester2.reportgen.faultanalysis.ErrorProximityHeuristic;
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.FilePassResult;
@@ -53,6 +54,15 @@
this.testRunner = new DefaultTestRunner(log);
}
+ public void execute(
+ ServiceReference[] converterRefs,
+ ReportGenerator[] reportGenerators,
+ CIShellContext cContext,
+ BundleContext bContext) {
+ execute(converterRefs, reportGenerators, cContext, bContext,
+ new AcceptAllFilter());
+ }
+
/**
* Tests the provided converters, and passes the results of those tests to
* the report generators. Report Generators are side-effected, which takes
@@ -66,17 +76,20 @@
ServiceReference[] converterRefs,
ReportGenerator[] reportGenerators,
CIShellContext cContext,
- BundleContext bContext) {
+ BundleContext bContext,
+ PathFilter testPathFilter) {
//generate all the converter paths
+ System.out.println("Generating converter graph paths etc...");
ConverterGraph converterGraph = new ConverterGraph(converterRefs,
bContext, this.log);
//run the tests
+ System.out.println("Running actual tests...");
TestResult[] rawResults =
- runAllTests(converterGraph, cContext, bContext);
+ runAllTests(converterGraph, testPathFilter, cContext, bContext);
AllTestsResult allTestsResult = new AllTestsResult(rawResults);
@@ -84,8 +97,9 @@
Converter[] allConverters = converterGraph.getAllConverters();
+ System.out.println("Running conv result maker...");
ChanceAtFaultHeuristic faultHeuristic =
- new WeightedFullTrustHeuristic();
+ new ErrorProximityHeuristic();
AllConvsResult allConvertersResult =
ConvResultMaker.generate(allTestsResult, allConverters,
faultHeuristic);
@@ -100,8 +114,11 @@
}
}
- public TestResult[] runAllTests(ConverterGraph convGraph,
- CIShellContext cContext, BundleContext bContext) {
+ public TestResult[] runAllTests(
+ ConverterGraph convGraph,
+ PathFilter testPathFilter,
+ CIShellContext cContext,
+ BundleContext bContext) {
@@ -129,6 +146,9 @@
ConverterPath[] testConvs =
(ConverterPath[]) testConvList.toArray(new ConverterPath[0]);
+ ConverterPath[] filteredTestConvs =
+ testPathFilter.filter(testConvs);
+
ConverterPath compareConv =
(ConverterPath) fileFormatToCompareConvs.get(fileFormat);
@@ -136,17 +156,19 @@
* For each test converter, use that test converter and
* the corresponding comparison converter to run a test.
*/
-
- for (int kk = 0; kk < testConvs.length; kk++) {
- numTestsSoFar++;
- ConverterPath testConv = testConvs[kk];
-
- TestResult testResult =
- runATest(testConv, compareConv, cContext, bContext,
- numTestsSoFar);
-
- if (testResult != null) {
- testResults.add(testResult);
+ if (filteredTestConvs != null &&
+ compareConv != null) {
+ for (int kk = 0; kk < filteredTestConvs.length; kk++) {
+ numTestsSoFar++;
+ ConverterPath testConv = filteredTestConvs[kk];
+
+ TestResult testResult =
+ runATest(testConv, compareConv, cContext, bContext,
+ numTestsSoFar);
+
+ if (testResult != null) {
+ testResults.add(testResult);
+ }
}
}
}
@@ -167,7 +189,7 @@
//determine how we will compare the graphs
- boolean isLossy = testConvs.isLossy() && compareConvs.isLossy();
+ boolean isLossy = testConvs.isLossy() || compareConvs.isLossy();
boolean preserveIDs = testConvs.preservesIDs() &&
compareConvs.preservesIDs();
@@ -181,7 +203,8 @@
FilePassResult[] results = this.testRunner.runTest(testBasicData);
//return the results of the test
- return new TestResult(results, testConvs, compareConvs, numTestsSoFar);
+ return new TestResult(results, testConvs, compareConvs,
+ numTestsSoFar);
}
private Data[][] wrapInData(String[] testFilePaths, String format) {
@@ -212,4 +235,12 @@
}
}
+ private class AcceptAllFilter implements PathFilter {
+
+ public ConverterPath[] filter(ConverterPath[] testPaths) {
+ return testPaths;
+ }
+
+ }
+
}
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java 2007-09-18 03:11:08 UTC (rev 530)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -129,7 +129,7 @@
FakeLogCIShellContext fakeCContext =
new FakeLogCIShellContext(testData.getContext());
- Converter currentConverter = converters.get(0);
+ Converter currentConverter = null;
try {
for (int ii = 0; ii < converters.size(); ii++) {
//System.out.println("Going into converter " + ii);
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/fakelogger/FakeLogService.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/fakelogger/FakeLogService.java 2007-09-18 03:11:08 UTC (rev 530)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/fakelogger/FakeLogService.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -20,7 +20,7 @@
}
public void log(int level, String message) {
- if (level == LOG_ERROR) {
+ if (level == LOG_ERROR | level == LOG_WARNING) {
this.logMessages.add(new LogEntry(message));
} else {
this.realLog.log(level, message);
@@ -28,7 +28,7 @@
}
public void log(int level, String message, Throwable exception) {
- if (level == LOG_ERROR) {
+ if (level == LOG_ERROR | level == LOG_WARNING) {
this.logMessages.add(new LogEntry(message, exception));
} else {
this.realLog.log(level, message, exception);
@@ -36,7 +36,7 @@
}
public void log(ServiceReference sr, int level, String message) {
- if (level == LOG_ERROR) {
+ if (level == LOG_ERROR | level == LOG_WARNING) {
this.logMessages.add(new LogEntry(message));
} else {
this.realLog.log(sr, level, message);
@@ -45,7 +45,7 @@
public void log(ServiceReference sr, int level, String message,
Throwable exception) {
- if (level == LOG_ERROR) {
+ if (level == LOG_ERROR | level == LOG_WARNING) {
this.logMessages.add(new LogEntry(message, exception));
} else {
this.realLog.log(sr, level, message, exception);
Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/pathfilter/PathFilter.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/pathfilter/PathFilter.java (rev 0)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/pathfilter/PathFilter.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -0,0 +1,7 @@
+package org.cishell.testing.convertertester.core.tester2.pathfilter;
+
+import org.cishell.testing.convertertester.core.converter.graph.ConverterPath;
+
+public interface PathFilter {
+ public ConverterPath[] filter (ConverterPath[] testPaths);
+}
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allconvs/AllConvsReportGenerator.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allconvs/AllConvsReportGenerator.java 2007-09-18 03:11:08 UTC (rev 530)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allconvs/AllConvsReportGenerator.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -5,6 +5,7 @@
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator;
@@ -37,6 +38,7 @@
File nwbConvGraph) {
ConvResult[] convResults = acr.getConvResults();
+ Arrays.sort(convResults, ConvResult.COMPARE_BY_CORRECTNESS);
FileOutputStream reportOutStream = null;
try {
@@ -111,8 +113,6 @@
//generate corresponding sub-report
this.convSubGen.generate(cr);
- ConvReport convReport = this.convSubGen.getConvReport();
- convReportsList.add(convReport);
}
}
report.println("");
@@ -127,8 +127,6 @@
//generate corresponding sub-report
this.convSubGen.generate(cr);
- ConvReport convReport = this.convSubGen.getConvReport();
- convReportsList.add(convReport);
}
}
@@ -142,20 +140,19 @@
report.println(" " + cr.getShortName());
this.convSubGen.generate(cr);
- ConvReport convReport = this.convSubGen.getConvReport();
- convReportsList.add(convReport);
}
}
report.println("");
-// for (int ii = 0; ii < convResults.length; ii++) {
-// this.convSubGen.generate(convResults[ii]);
-// ConvReport convReport = this.convSubGen.getConvReport();
-// convReportsList.add(convReport);
-// }
+ for (int ii = 0; ii < convResults.length; ii++) {
+ this.convSubGen.generate(convResults[ii]);
+ ConvReport convReport = this.convSubGen.getConvReport();
+ convReportsList.add(convReport);
+ }
ConvReport[] convReports =
(ConvReport[]) convReportsList.toArray(new ConvReport[0]);
+
this.allConvsReport =
new AllConvsReport(reportFile, convReports,
"All Converters Report");
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allconvs/ConvReportSubGenerator.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allconvs/ConvReportSubGenerator.java 2007-09-18 03:11:08 UTC (rev 530)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allconvs/ConvReportSubGenerator.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -123,7 +123,7 @@
}
this.convReport = new ConvReport(reportFile, new TestReport[0],
- cr.getShortNameWithStatus());
+ cr.getShortNameWithCorrectness());
report.println("");
report.flush();
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/DefaultErrorSourceAnalyzer.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/DefaultErrorSourceAnalyzer.java 2007-09-18 03:11:08 UTC (rev 530)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/DefaultErrorSourceAnalyzer.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -114,8 +114,24 @@
normalizedCafs.add(normPC);
}
- return (ChanceAtFault[])
- normalizedCafs.toArray(new ChanceAtFault[0]);
+ ChanceAtFault[] uniqueNormalizedCafs =
+ removeDuplicateConverters(normalizedCafs);
+
+ return uniqueNormalizedCafs;
}
}
+
+ private ChanceAtFault[] removeDuplicateConverters(List cafs) {
+ List newCafs = new ArrayList();
+ List newCafConvs = new ArrayList();
+ for (int ii = 0; ii < cafs.size(); ii++) {
+ ChanceAtFault caf = (ChanceAtFault) cafs.get(ii);
+ if (! newCafConvs.contains(caf.getConverter())) {
+ newCafs.add(caf);
+ newCafConvs.add(caf.getConverter());
+ }
+ }
+
+ return (ChanceAtFault[]) newCafs.toArray(new ChanceAtFault[0]);
+ }
}
Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/ErrorProximityHeuristic.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/ErrorProximityHeuristic.java (rev 0)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/ErrorProximityHeuristic.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -0,0 +1,151 @@
+package org.cishell.testing.convertertester.core.tester2.reportgen.faultanalysis;
+
+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.results.FilePassResult;
+
+public class ErrorProximityHeuristic implements ChanceAtFaultHeuristic {
+
+ public static final float FAULT_REDUCTION_PER_DEGREE_REMOVED = .33333f;
+ public static final float FAULT_REDUCTION_FOR_TRUST = .5f;
+
+ public ChanceAtFault[] determine(FilePassResult failFP,
+ Converter[] involvedCs,
+ Converter[] trustedCs) {
+
+ List trustedCList = Arrays.asList(trustedCs);
+
+ //assign fault scores to each converter
+
+ Map convToFaultScore = new HashMap();
+
+ if (failFP.failedWhileConverting()) {
+
+ //assign fault such that the closer a converter is to the failed
+ //converter, the more likely it is to be at fault
+
+ final float startingFaultScore = 1.0f;
+
+ float currentFaultScore = startingFaultScore;
+
+
+ for (int ii = 0; ii < involvedCs.length; ii++) {
+ Converter involvedC = (Converter) involvedCs[ii];
+
+ Float oldFaultScore = (Float) convToFaultScore.get(involvedC);
+
+ Float newFaultScore;
+ if (oldFaultScore == null) {
+ // first occurrence of this converter
+ newFaultScore = new Float(currentFaultScore);
+ } else {
+ // converter occurred once before (at least)
+ // the same thing for now
+ newFaultScore = new Float(currentFaultScore);
+ }
+
+ convToFaultScore.put(involvedC, newFaultScore);
+
+ currentFaultScore /= FAULT_REDUCTION_PER_DEGREE_REMOVED;
+ }
+ } else if (failFP.failedWhileComparingGraphs()) {
+ //assign fault evenly across all converters
+
+ Float faultScore = new Float(1);
+
+ for (int ii = 0; ii < involvedCs.length; ii++) {
+ Converter involvedC = (Converter) involvedCs[ii];
+
+ Float oldFaultScore = (Float) convToFaultScore.get(involvedC);
+
+ Float newFaultScore;
+ if (oldFaultScore == null) {
+ newFaultScore = faultScore;
+ } else {
+ // converter occurred once before (at least)
+ // the same thing for now
+ newFaultScore = faultScore;
+ }
+
+ convToFaultScore.put(involvedC, newFaultScore);
+ }
+ }
+
+
+ Set convsInvolved = convToFaultScore.keySet();
+
+ //reduce fault score of trusted converters
+
+ Iterator convIter1 = convsInvolved.iterator();
+ while (convIter1.hasNext()) {
+ Converter convInvolved = (Converter) convIter1.next();
+ Float convFaultScore =
+ (Float) convToFaultScore.get(convInvolved);
+
+ if (trustedCList.contains(convInvolved)) {
+ Float newConvFaultScore =
+ new Float(convFaultScore.floatValue() *
+ FAULT_REDUCTION_FOR_TRUST);
+ convToFaultScore.put(convInvolved, newConvFaultScore);
+ }
+ }
+
+ //determine total fault score
+
+ float faultScoresTotal = 0.0f;
+
+ Iterator convIter2 = convsInvolved.iterator();
+ while (convIter2.hasNext()) {
+ Converter convInvolved = (Converter) convIter2.next();
+ Float convFaultScore =
+ (Float) convToFaultScore.get(convInvolved);
+
+ faultScoresTotal += convFaultScore.floatValue();
+ }
+
+ //normalize fault scores to total 1.
+
+ Iterator convIter3 = convsInvolved.iterator();
+ while (convIter3.hasNext()) {
+ Converter convInvolved = (Converter) convIter3.next();
+ Float convFaultScore =
+ (Float) convToFaultScore.get(convInvolved);
+
+ float normalizedFaultScore;
+ if (faultScoresTotal != 0.0f) {
+ normalizedFaultScore =
+ convFaultScore.floatValue() / faultScoresTotal;
+ } else {
+ normalizedFaultScore = 0.0f;
+ }
+
+ Float newConvFaultScore = new Float(normalizedFaultScore);
+
+ convToFaultScore.put(convInvolved, newConvFaultScore);
+ }
+
+ //return chance each converter is at fault, based on fault scores.
+
+ List resultCAFList = new ArrayList();
+ for (int ii = 0; ii < involvedCs.length; ii++) {
+ Converter involvedC = involvedCs[ii];
+
+ Float convFaultScore = (Float) convToFaultScore.get(involvedC);
+
+
+ ChanceAtFault resultCAF = new ChanceAtFault(failFP, involvedC,
+ convFaultScore.floatValue());
+
+ resultCAFList.add(resultCAF);
+ }
+
+ return (ChanceAtFault[]) resultCAFList.toArray(new ChanceAtFault[0]);
+ }
+}
Deleted: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/WeightedFullTrustHeuristic.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/WeightedFullTrustHeuristic.java 2007-09-18 03:11:08 UTC (rev 530)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/WeightedFullTrustHeuristic.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -1,166 +0,0 @@
-package org.cishell.testing.convertertester.core.tester2.reportgen.faultanalysis;
-
-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.results.FilePassResult;
-
-/**
- *
- * @author mwlinnem
- *
- * A less naive approach to assessing likelihood of fault,
- * that gives higher weight to the converter that caused the error for
- * failures in conversion, and increases chance at fault for converters
- * involved more than once in the conversion path
- */
-public class WeightedFullTrustHeuristic implements ChanceAtFaultHeuristic{
-
- public static final Float TRUSTED_FAULT_SCORE = new Float(0);
- public static final Float DEFAULT_FAULT_SCORE = new Float(1);
- public static final Float FAILED_CONV_FAULT_SCORE = new Float(2);
-
- public ChanceAtFault[] determine(FilePassResult failFP,
- Converter[] involvedCs,
- Converter[] trustedCs) {
-
- List trustedCList = Arrays.asList(trustedCs);
-
- //eliminate converters that are trusted
-
- List unTrustedCs = new ArrayList();
- for (int ii = 0; ii < involvedCs.length; ii++) {
- Converter c = involvedCs[ii];
-
- if (! trustedCList.contains(c)) {
- unTrustedCs.add(c);
- }
- }
-
- //assign fault scores to each untrusted converter
-
- Map convToFaultScore = new HashMap();
-
- float totalFaultScore = 0.0f;
- for (int ii = 0; ii < unTrustedCs.size(); ii++) {
- Converter untrustedC = (Converter) unTrustedCs.get(ii);
-
- Float oldFaultScore = (Float) convToFaultScore.get(untrustedC);
- Float newFaultScore;
- if (oldFaultScore == null) {
- //first occurrence of this converter
-
- if (! isConvThatFailed(untrustedC, failFP)) {
- newFaultScore = DEFAULT_FAULT_SCORE;
- } else {
- newFaultScore = FAILED_CONV_FAULT_SCORE;
- }
-
- } else {
- //converter has occurred before
-
- newFaultScore = new Float(oldFaultScore.floatValue() +
- DEFAULT_FAULT_SCORE.floatValue());
- }
-
- convToFaultScore.put(untrustedC, newFaultScore);
- totalFaultScore += newFaultScore.floatValue();
- }
-
- //return chance each converter is at fault, based on fault scores.
-
-
- List resultCAFList = new ArrayList();
-
-
-
-
- for (int ii = 0; ii < involvedCs.length; ii++) {
- Converter involvedC = involvedCs[ii];
-
- Float faultScore = (Float) convToFaultScore.get(involvedC);
- //if there is no associated score...
- if (faultScore == null) {
- //this converter must have been removed because it was
- //trusted, so give it the fault score for trusted converters.
- faultScore = TRUSTED_FAULT_SCORE;
- }
-
- float normalizedFaultScore;
- if (totalFaultScore != 0.0f) {
- normalizedFaultScore =
- faultScore.floatValue() / totalFaultScore;
- } else {
- normalizedFaultScore = 0.0f;
- }
-
- ChanceAtFault resultCAF = new ChanceAtFault(failFP, involvedC,
- normalizedFaultScore);
-
- resultCAFList.add(resultCAF);
- }
-
- return (ChanceAtFault[]) resultCAFList.toArray(new ChanceAtFault[0]);
-
-
-
-
-//
-// //easier to deal with as a list
-// List trustedCList = Arrays.asList(trustedCs);
-//
-// //eliminate converters involved twice in the file pass
-//
-// Set uniqueInvolvedCs = new HashSet();
-// for (int ii = 0; ii < involvedCs.length; ii++) {
-// uniqueInvolvedCs.add(involvedCs[ii]);
-// }
-// //eliminate converters that are trusted
-//
-// List uniqueUntrustedCs = new ArrayList();
-// Iterator iter = uniqueInvolvedCs.iterator();
-// while (iter.hasNext()) {
-// Converter c = (Converter) iter.next();
-// if (! trustedCList.contains(c)) {
-// //converter isn't trusted
-// //add it to the list
-// uniqueUntrustedCs.add(c);
-// } else {
-// //converter is trusted
-// //do nothing
-// }
-// }
-//
-// float chanceEachAtFault = 1.0f / uniqueUntrustedCs.size();
-//
-// List chanceAtFaultList = new ArrayList();
-// for (int ii = 0; ii < involvedCs.length; ii++) {
-// Converter c = involvedCs[ii];
-//
-// ChanceAtFault chanceAtFault = null;
-// if (uniqueUntrustedCs.contains(c)) {
-// chanceAtFault =
-// new ChanceAtFault((FilePassFailure) failFP, c, chanceEachAtFault);
-// } else {
-// chanceAtFault =
-// new ChanceAtFault((FilePassFailure) failFP, c, 0.0f);
-// }
-//
-// chanceAtFaultList.add(chanceAtFault);
-// }
-//
-// return (ChanceAtFault[])
-// chanceAtFaultList.toArray(new ChanceAtFault[0]);
- }
-
- private boolean isConvThatFailed(Converter c, FilePassResult failFP) {
- return failFP.failedWhileConverting() &&
- failFP.getFailedConverter() == c;
- }
-}
Copied: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/WeightedTrustHeuristic.java (from rev 525, trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/WeightedFullTrustHeuristic.java)
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/WeightedTrustHeuristic.java (rev 0)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/WeightedTrustHeuristic.java 2007-09-20 21:07:14 UTC (rev 531)
@@ -0,0 +1,170 @@
+package org.cishell.testing.convertertester.core.tester2.reportgen.faultanalysis;
+
+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.results.FilePassResult;
+
+/**
+ *
+ * @author mwlinnem
+ *
+ * A less naive approach to assessing likelihood of fault,
+ * that gives higher weight to the converter that caused the error for
+ * failures in conversion, and increases chance at fault for converters
+ * involved more than once in the conversion path
+ */
+public class WeightedTrustHeuristic implements ChanceAtFaultHeuristic{
+
+ public static final Float DEFAULT_FAULT_SCORE = new Float(1);
+
+ public static final float TRUSTED_CONV_PENALTY_REDUCTION = .1f;
+
+ public static final float FAILED_CONV_PENALTY = 3.0f;
+ public static final float REPEAT_PENALTY = .5f;
+
+ public ChanceAtFault[] determine(FilePassResult failFP,
+ Converter[] involvedCs,
+ Converter[] trustedCs) {
+
+ List trustedCList = Arrays.asList(trustedCs);
+
+ //assign fault scores to each converter
+
+ Map convToFaultScore = new HashMap();
+
+ for (int ii = 0; ii < involvedCs.length; ii++) {
+ Converter involvedC = (Converter) involvedCs[ii];
+
+ Float oldFaultScore = (Float) convToFaultScore.get(involvedC);
+ Float newFaultScore;
+ if (oldFaultScore == null) {
+ //first occurrence of this converter
+
+ newFaultScore = DEFAULT_FAULT_SCORE;
+ if (isConvThatFailed(involvedC, failFP)) {
+ newFaultScore = new Float(newFaultScore.floatValue() *
+ FAILED_CONV_PENALTY);
+ }
+
+ } else {
+ //converter has occurred before
+
+ newFaultScore = new Float(oldFaultScore.floatValue() +
+ DEFAULT_FAULT_SCORE.floatValue() * REPEAT_PENALTY);
+ }
+
+ convToFaultScore.put(involvedC, newFaultScore);
+
+ }
+
+
+
+ //reduce fault scores of trusted converters
+
+ float faultScoresTotal = 0.0f;
+
+ Set convs = convToFaultScore.keySet();
+ Iterator convIter = convs.iterator();
+ while (convIter.hasNext()) {
+ Converter convInvolved = (Converter) convIter.next();
+ Float convFaultScore =
+ (Float) convToFaultScore.get(convInvolved);
+
+ if (trustedCList.contains(convInvolved)) {
+ convFaultScore = new Float(convFaultScore.floatValue() *
+ TRUSTED_CONV_PENALTY_REDUCTION);
+ }
+
+ convToFaultScore.put(convInvolved, convFaultScore);
+ faultScoresTotal += convFaultScore.floatValue();
+ }
+
+ List resultCAFList = new ArrayList();
+
+
+ //return chance each converter is at fault, based on fault scores.
+
+ for (int ii = 0; ii < involvedCs.length; ii++) {
+ Converter involvedC = involvedCs[ii];
+
+ Float faultScore = (Float) convToFaultScore.get(involvedC);
+
+ float normalizedFaultScore;
+ if (faultScoresTotal != 0.0f) {
+ normalizedFaultScore =
+ faultScore.floatValue() / faultScoresTotal;
+ } else {
+ normalizedFaultScore = 0.0f;
+ }
+
+ ChanceAtFault resultCAF = new ChanceAtFault(failFP, involvedC,
+ normalizedFaultScore);
+
+ resultCAFList.add(resultCAF);
+ }
+
+ return (ChanceAtFault[]) resultCAFList.toArray(new ChanceAtFault[0]);
+
+
+
+
+//
+// //easier to deal with as a list
+// List trustedCList = Arrays.asList(trustedCs);
+//
+// //eliminate converters involved twice in the file pass
+//
+// Set uniqueInvolvedCs = new HashSet();
+// for (int ii = 0; ii < involvedCs.length; ii++) {
+// uniqueInvolvedCs.add(involvedCs[ii]);
+// }
+// //eliminate converters that are trusted
+//
+// List uniqueUntrustedCs = new ArrayList();
+// Iterator iter = uniqueInvolvedCs.iterator();
+// while (iter.hasNext()) {
+// Converter c = (Converter) iter.next();
+// if (! trustedCList.contains(c)) {
+// //converter isn't trusted
+// //add it to the list
+// uniqueUntrustedCs.add(c);
+// } else {
+// //converter is trusted
+// //do nothing
+// }
+// }
+//
+// float chanceEachAtFault = 1.0f / uniqueUntrustedCs.size();
+//
+// List chanceAtFaultList = new ArrayList();
+// for (int ii = 0; ii < involvedCs.length; ii++) {
+// Converter c = involvedCs[ii];
+//
+// ChanceAtFault chanceAtFault = null;
+// if (uniqueUntrustedCs.contains(c)) {
+// chanceAtFault =
+// new ChanceAtFault((FilePassFailure) failFP, c, chanceEachAtFault);
+// } else {
+// chanceAtFault =
+// new ChanceAtFault((FilePassFailure) failFP, c, 0.0f);
+// }
+//
+// chanceAtFaultList.add(chanceAtFault);
+// }
+//
+// return (ChanceAtFault[])
+// chanceAtFaultList.toArray(new ChanceAtFault[0]);
+ }
+
+ private boolean isConvThatFailed(Converter c, FilePassResult failFP) {
+ return failFP.failedWhileConverting() &&
+ failFP.getFailedConverter() == c;
+ }
+}
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvResult.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvResult.java 2007-09-18 03:11:08 UTC (rev 530)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvResult.java 2007-09-20 21:07:14 UTC...
[truncated message content] |