From: <mwl...@us...> - 2007-08-30 19:08:12
|
Revision: 497 http://cishell.svn.sourceforge.net/cishell/?rev=497&view=rev Author: mwlinnem Date: 2007-08-30 12:07:57 -0700 (Thu, 30 Aug 2007) Log Message: ----------- Major refactoring. Many little changes. Modified Paths: -------------- 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/service/ConfigurationFileParser.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/ReportREADME.txt trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/ConverterTester.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/ComparisonResult.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/RunningLog.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/graphcomparison/ComplexGraphComparer.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ReportGenerator.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/alltests/AllTestsReportGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/FilePassSubGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/TestReportSubGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/convgraph/GraphReportGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/readme/ReadMeReportGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/AllTestsResult.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/FilePassResult.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/TestResult.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/converter/ConvFailureInfo.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/filepass/FilePassSuccess.java Added Paths: ----------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/Converter.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/ChanceAtFault.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/ChanceAtFaultHeuristic.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/faultanalysis/FullTrustHeuristic.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/AllConvsResult.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/AllErrorsResult.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/ErrorResult.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/filepass/FilePassFailure.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/filepass/PassPhase.java Removed Paths: ------------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ConvResultMaker.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/filepass/ComparePhaseFailure.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/filepass/ConvertPhaseFailure.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/filepass/FilePassFailure.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/util/ConvUtil.java Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/Converter.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/Converter.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/Converter.java 2007-08-30 19:07:57 UTC (rev 497) @@ -0,0 +1,92 @@ +package org.cishell.testing.convertertester.core.converter.graph; + +import java.util.Hashtable; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.algorithm.AlgorithmProperty; +import org.cishell.framework.data.Data; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; + +public class Converter { + + private BundleContext bContext; + + private ServiceReference ref; + + public Converter(BundleContext bContext, ServiceReference ref) { + this.bContext = bContext; + this.ref = ref; + } + + public ServiceReference getServiceReference() { + return this.ref; + } + + public ServiceReference getRef() { + return this.ref; + } + + public boolean isLossy() { + String conversion = (String) + ref.getProperty(AlgorithmProperty.CONVERSION); + + if (conversion == null) { + return false; + //if lossiness is not defined, assume it is not lossy. + } + + if (conversion.equals(AlgorithmProperty.LOSSY)) { + return true; + } else if (conversion.equals(AlgorithmProperty.LOSSLESS)) { + return false; + } else { + //assuming lossy by default + return true; + } + } + + public String getInData() { + return (String) ref.getProperty(AlgorithmProperty.IN_DATA); + } + + public String getOutData() { + return (String) ref.getProperty(AlgorithmProperty.OUT_DATA); + } + + public String getShortName() { + return removePackagePrefix(getUniqueName()); + } + + public String getUniqueName() { + return (String) this.ref.getProperty("service.pid"); + } + + public String toString() { + return getUniqueName(); + } + + public Data[] execute(Data[] input, Hashtable parameters, + CIShellContext cContext) { + + AlgorithmFactory convAlgFactory = + (AlgorithmFactory) this.bContext.getService(this.ref); + Algorithm convAlg = convAlgFactory.createAlgorithm(input, parameters, + cContext); + + Data[] output = convAlg.execute(); + + return output; + } + + + /* + * 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); + } +} 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-08-25 20:32:52 UTC (rev 496) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java 2007-08-30 19:07:57 UTC (rev 497) @@ -6,6 +6,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; @@ -19,35 +20,47 @@ Map inDataToAlgorithm; Map fileExtensionTestConverters; Map fileExtensionCompareConverters; - ServiceReference[] converters; + Converter[] converters; BundleContext bContext; private LogService log; private static final String testOutData = "prefuse.data.Graph"; - public ConverterGraph(ServiceReference[] converters, BundleContext bContext, LogService log){ - this.converters = converters; + public ConverterGraph(ServiceReference[] converterRefs, BundleContext bContext, LogService log) { this.bContext = bContext; this.log = log; - inDataToAlgorithm = new HashMap();//<String, ArrayList<ServiceReference>>(); - fileExtensionTestConverters = new ConcurrentHashMap();//<String, ArrayList<ConverterPath>>(); + + this.converters = createConverters(converterRefs); + + inDataToAlgorithm = new HashMap();//<String, List<Convertere>>(); + fileExtensionTestConverters = new ConcurrentHashMap();//<String, List<ConverterPath>>(); fileExtensionCompareConverters = new ConcurrentHashMap();//<String, ConverterPath>(); associateAlgorithms(this.converters, this.inDataToAlgorithm); createConverterPaths(this.inDataToAlgorithm, this.fileExtensionTestConverters, this.fileExtensionCompareConverters); } + + private Converter[] createConverters(ServiceReference[] convRefs) { + List converters = new ArrayList(); + + for (int ii = 0; ii < convRefs.length; ii++) { + converters.add(new Converter(this.bContext, convRefs[ii])); + } + + return (Converter[]) converters.toArray(new Converter[0]); + } - private void associateAlgorithms(ServiceReference[] sr, Map hm){ - for(int i = 0; i < sr.length; i++){ - ServiceReference srv = sr[i]; - String s = srv.getProperty("in_data").toString(); + private void associateAlgorithms(Converter[] cs, Map hm){ + for (int i = 0; i < cs.length; i++){ + Converter c = cs[i]; + String s = c.getInData(); if(hm.get(s) == null){ - ArrayList al = new ArrayList(); - al.add(srv); - hm.put(s, al); + List l = new ArrayList(); + l.add(c); + hm.put(s, l); } else{ - ((ArrayList)hm.get(s)).add(srv); + ((List)hm.get(s)).add(c); } } } @@ -65,15 +78,15 @@ test.setInData(s); - createPaths((ArrayList)algorithms.get(s), test, s); + createPaths((List)algorithms.get(s), test, s); } } } - private ConverterPath createPaths(ArrayList algorithms, ConverterPath path, String dataType){ - ArrayList refs = removeReferences(algorithms, path); + private ConverterPath createPaths(List algorithms, ConverterPath path, String dataType){ + List cs = removeReferences(algorithms, path); addCompareCycle(path); @@ -81,11 +94,11 @@ addTestCycle(path); return path; } - while(!refs.isEmpty()){ + while(!cs.isEmpty()){ ConverterPath p = new ConverterPath(path, this.bContext); - p.addAlgorithm((ServiceReference)refs.get(0)); - refs.remove(0); - createPaths((ArrayList)this.inDataToAlgorithm.get(p.getOutData()), p, p.getOutData()); + p.add((Converter) cs.get(0)); + cs.remove(0); + createPaths((List)this.inDataToAlgorithm.get(p.getOutData()), p, p.getOutData()); } return null; @@ -93,8 +106,8 @@ private void addTestCycle(ConverterPath cp){ String firstOutData, lastInData; - firstOutData = ((ServiceReference)cp.getPath().get(0)).getProperty("out_data").toString(); - lastInData = ((ServiceReference)cp.getPath().get(cp.getPath().size()-1)).getProperty("in_data").toString(); + firstOutData = ((Converter) cp.getPath().get(0)).getOutData(); + lastInData = ((Converter)cp.getPath().get(cp.getPath().size()-1)).getInData(); if(firstOutData.equals(lastInData)){ addTestPath(cp); } @@ -103,7 +116,7 @@ private void addCompareCycle(ConverterPath cp){ if(cp.getOutData() != null){ if(cp.getOutData().equals(ConverterGraph.testOutData)){ - String key = cp.getInData() + " " + ((ServiceReference)cp.getPath().get(0)).getProperty("out_data").toString(); + String key = cp.getInData() + " " + ((Converter) cp.getPath().get(0)).getOutData(); //System.out.println(key); if(this.fileExtensionCompareConverters.get(key) == null){ @@ -122,36 +135,36 @@ } } - private static ArrayList removeReferences(ArrayList al, ConverterPath cp){ - ArrayList srs = new ArrayList(al); - srs.removeAll(cp.getPath()); - ArrayList forbidden = new ArrayList(); - for(int i = 0; i < srs.size(); i++){ - ServiceReference sr = (ServiceReference)srs.get(i); - String ss = sr.getProperty("out_data").toString(); - if(ss.startsWith("file-ext") && (!ss.equals(cp.getInData()))){ + private static List removeReferences(List al, ConverterPath cp){ + List cs = new ArrayList(al); + cs.removeAll(cp.getPath()); + 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()))){ - forbidden.add(sr); + forbidden.add(c); } } - srs.removeAll(forbidden); - return srs; + cs.removeAll(forbidden); + return cs; } private void addTestPath(ConverterPath p){ String key = p.getInData(); key += " "; - key += ((ServiceReference)p.getPath().get(0)).getProperty("out_data").toString(); + key += ((Converter)p.getPath().get(0)).getOutData(); if(this.fileExtensionTestConverters.get(key) == null){ - ArrayList paths = new ArrayList(); + List paths = new ArrayList(); paths.add(p); this.fileExtensionTestConverters.put(key, paths); } else{ - ((ArrayList)this.fileExtensionTestConverters.get(key)).add(p); + ((List)this.fileExtensionTestConverters.get(key)).add(p); } } @@ -159,7 +172,7 @@ public String printTestConverterPath(String s){ StringBuffer sb = new StringBuffer(); - ArrayList al = (ArrayList)this.fileExtensionTestConverters.get(s); + List al = (List)this.fileExtensionTestConverters.get(s); for(int i = 0; i < al.size(); i++){ ConverterPath cp = (ConverterPath)al.get(i); sb.append(cp.toString()); @@ -205,23 +218,23 @@ keySet = (String[])this.inDataToAlgorithm.keySet().toArray(keySet); for(int i = 0; i < keySet.length; i++){ String s = keySet[i]; - str.append(s + "\n"); - ArrayList al = (ArrayList)this.inDataToAlgorithm.get(s); + str.append(s + "\r\n"); + List al = (List)this.inDataToAlgorithm.get(s); for(int j = 0; j < al.size(); j++){ - ServiceReference sr = (ServiceReference)al.get(j); - str.append("\t" + sr.getProperty("service.pid") + "\n"); + Converter c = (Converter)al.get(j); + str.append("\t" + c.getUniqueName() + "\r\n"); } } - str.append("Test Paths:\n"); + str.append("Test Paths:\r\n"); str.append(printTestConverterPaths()); - str.append("Comparison Paths:\n"); + str.append("Comparison Paths:\r\n"); str.append(printComparisonConverterPaths()); str.trimToSize(); return str.toString(); } public ConverterPath[] getTestPath(String s){ - return (ConverterPath[])((ArrayList)this.fileExtensionTestConverters.get(s)).toArray(new ConverterPath[0]); + return (ConverterPath[])((List)this.fileExtensionTestConverters.get(s)).toArray(new ConverterPath[0]); } public ConverterPath[][] getTestPaths(){ @@ -241,7 +254,7 @@ public ConverterPath[] getComparePaths(){ String[] fileExtensions = (String[])this.fileExtensionCompareConverters.keySet().toArray(new String[0]); - ArrayList graphs = new ArrayList(); + List graphs = new ArrayList(); for(int i = 0; i < fileExtensions.length; i++){ graphs.add(getComparePath(fileExtensions[i])); } @@ -256,6 +269,10 @@ return this.fileExtensionTestConverters; } + public Converter[] getAllConverters() { + return this.converters; + } + public File asNWB() { File f = getTempFile(); Map nodes = assembleNodesSet(); @@ -275,7 +292,7 @@ private void writeNodeHeader(BufferedWriter bw, int numNodes) throws IOException{ bw.flush(); - bw.write("*Nodes " + numNodes + "\nid*int label*string\n"); + bw.write("*Nodes " + numNodes + "\r\nid*int label*string\r\n"); } @@ -285,14 +302,14 @@ keySet = (String[])nodes.keySet().toArray(keySet); for(int i = 0; i < keySet.length; i++){ bw.flush(); - bw.write(nodes.get(keySet[i]) + " \"" + keySet[i]+"\"\n"); + bw.write(nodes.get(keySet[i]) + " \"" + keySet[i]+"\"\r\n"); } } private void writeEdgeHeader(BufferedWriter bw, int numEdges) throws IOException{ bw.flush(); - bw.write("*DirectedEdges " + numEdges + "\nsource*int target*int\n"); + bw.write("*DirectedEdges " + numEdges + "\r\nsource*int target*int\r\n"); } @@ -304,7 +321,7 @@ for(int i = 0; i < edgeArray.length; i++){ bw.flush(); - bw.write(edgeArray[i]+"\n"); + bw.write(edgeArray[i]+"\r\n"); } } @@ -319,13 +336,13 @@ for(int i = 0; i < keySet.length; i++){ String s = keySet[i]; nodeNames.add(s); - ArrayList paths = (ArrayList)this.inDataToAlgorithm.get(s); - ServiceReference[] references = new ServiceReference[paths.size()]; - references = (ServiceReference[])paths.toArray(references); + List paths = (List)this.inDataToAlgorithm.get(s); + Converter[] convs = new Converter[paths.size()]; + convs = (Converter[])paths.toArray(convs); - for(int j = 0; j < references.length; j++){ - ServiceReference r = references[j]; - nodeNames.add(r.getProperty("service.pid").toString()); + for(int j = 0; j < convs.length; j++){ + Converter c = convs[j]; + nodeNames.add(c.getUniqueName()); } } @@ -333,7 +350,6 @@ names = (String[])nodeNames.toArray(names); for(int i = 0; i < names.length; i++){ - System.out.println(names[i] + " " + (i+1)); nodesToInt.put(names[i], new Integer(i+1)); } @@ -346,19 +362,16 @@ keySet = (String[])m.keySet().toArray(keySet); for(int i = 0; i < keySet.length; i++){ String s = keySet[i]; - System.out.println(keySet[i]); - ArrayList paths = (ArrayList)this.inDataToAlgorithm.get(s); + List paths = (List)this.inDataToAlgorithm.get(s); if(paths != null){ - ServiceReference[] references = new ServiceReference[paths.size()]; - references = (ServiceReference[])paths.toArray(references); + Converter[] convs = new Converter[paths.size()]; + convs = (Converter[])paths.toArray(convs); - for(int j = 0; j < references.length; j++){ + for(int j = 0; j < convs.length; j++){ String output1 = m.get(s).toString() + " "; - String output2 = references[j].getProperty("service.pid").toString(); + String output2 = convs[j].getUniqueName(); output1 += m.get(output2).toString(); - output2 = m.get(output2).toString() + " " + m.get(references[j].getProperty("out_data")).toString(); - System.out.println(output1); - System.out.println(output2); + output2 = m.get(output2).toString() + " " + m.get(convs[j].getOutData()); edges.add(output1); edges.add(output2); } 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-08-25 20:32:52 UTC (rev 496) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java 2007-08-30 19:07:57 UTC (rev 497) @@ -3,7 +3,6 @@ import java.util.ArrayList; import java.util.List; -import org.cishell.framework.algorithm.AlgorithmFactory; import org.cishell.framework.algorithm.AlgorithmProperty; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; @@ -16,12 +15,8 @@ private String in_data = null; private String out_data = null; - private ArrayList path; + private List path; - private boolean algPathCached = false; - private ArrayList algPath; - - public ConverterPath(BundleContext bContext, LogService log){ this.bContext = bContext; this.log = log; @@ -49,20 +44,16 @@ this.out_data = s; } - public boolean addAlgorithm(ServiceReference sr){ + public boolean add(Converter c){ boolean val = true; - if(path.contains(sr)){ -// System.out.println("Path already contains " + sr.getProperty("service.pid")); - + if(path.contains(c)){ return false; } - - path.add(sr); - invalidateAlgPath(); - this.setOutData(sr.getProperty("out_data").toString()); + path.add(c); + this.setOutData(c.getOutData()); return val; } @@ -92,48 +83,50 @@ return this.path; } - public ServiceReference getRef(int index) { - - return (ServiceReference) this.path.get(index); + //inclusive + public List getPathUpTo(Converter upToConv) { + int convIndex = -1; + for (int ii = 0; ii < this.path.size(); ii++) { + Converter aConvInPath = get(ii); + + if (aConvInPath.equals(upToConv)) { + convIndex = ii; + break; + } + } + + if (convIndex != -1) { + return this.path.subList(0, convIndex + 1); + } else { + throw new IllegalArgumentException("Attempted to get a " + + "subsection of a path up until a converter " + + "that does not exist in the original path"); + } } - public AlgorithmFactory getAlg(int index) { - - if (! algPathCached) cacheAlgPath(); - return (AlgorithmFactory) this.algPath.get(index); + public Converter get(int index) { + return (Converter) this.path.get(index); } - public ServiceReference[] getPathAsArray(){ + public ServiceReference getRef(int index) { - return (ServiceReference[])this.path.toArray(new ServiceReference[0]); + Converter c = (Converter) this.path.get(index); + ServiceReference ref = c.getRef(); + return ref; } - public AlgorithmFactory[] getPathAsAlgorithms(){ + public Converter[] getPathAsArray(){ - if (! algPathCached) cacheAlgPath(); - - return (AlgorithmFactory[]) this.algPath.toArray(new AlgorithmFactory[0]); + return (Converter[]) this.path.toArray(new Converter[0]); } - public String toString(){ - - String val = this.in_data +" -->\n"; - - for(int i = 0; i < this.path.size(); i++){ - ServiceReference sr = (ServiceReference)this.path.get(i); - val += "\t" + sr.getProperty("service.pid") + "\n"; - } - val += "--> " + this.out_data + "\n"; - return val; - } - public boolean isLossy() { String lossiness = LOSSLESS; for (int i = 0; i < this.path.size(); i++) { - ServiceReference sr = (ServiceReference) this.path.get(i); + Converter c = (Converter) this.path.get(i); - if (LOSSY.equals(sr.getProperty(CONVERSION))) { + if (c.isLossy()) { lossiness = LOSSY; } } @@ -148,51 +141,12 @@ return false; } - - public ConverterPath appendNonMutating(ConverterPath otherPath) { - - List thisConvPath = this.path; - List otherConvPath = otherPath.getPath(); - - List thisConvPathCopy = new ArrayList(thisConvPath); - thisConvPathCopy.addAll(otherConvPath); - ConverterPath combinedPath = new ConverterPath(this.bContext, this.log); - - List combinedConvPath = thisConvPathCopy; - for (int ii = 0; ii < combinedConvPath.size(); ii++) { - ServiceReference sr = (ServiceReference) combinedConvPath.get(ii); - - combinedPath.addAlgorithm(sr); - } - - return combinedPath; - } - public int size() { return this.path.size(); } public String getConverterName(int index) { - return (String) getRef(index).getProperty("service.pid"); + return (String) get(index).getUniqueName(); } - - - private void cacheAlgPath() { - this.algPath = new ArrayList(); - - for (int i = 0; i < this.path.size(); i++){ - ServiceReference sr = (ServiceReference)this.path.get(i); - - AlgorithmFactory alg = (AlgorithmFactory) this.bContext.getService(sr); - this.algPath.add(alg); - } - - this.algPathCached = true; - } - - private void invalidateAlgPath() { - - this.algPathCached = false; - } } Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/service/ConfigurationFileParser.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/service/ConfigurationFileParser.java 2007-08-25 20:32:52 UTC (rev 496) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/service/ConfigurationFileParser.java 2007-08-30 19:07:57 UTC (rev 497) @@ -193,7 +193,7 @@ if(!f.isHidden()){ if(f.isDirectory()){ output += "Directory: "; - output += f.getName()+ "\n"; + output += f.getName()+ "\r\n"; File[] files = f.listFiles(); for (int ii = 0; ii < files.length; ii++){ File ff = files[ii]; @@ -201,7 +201,7 @@ } } else{ - output += "\t" + f.getName() + "\n"; + output += "\t" + f.getName() + "\r\n"; } } return output; @@ -209,29 +209,29 @@ public String toString(){ String output = ""; - output += "Files to test:\n"; + output += "Files to test:\r\n"; Iterator iter0 = this.comparisonFiles.iterator(); while (iter0.hasNext()){ File f = (File) iter0.next(); output += asString(f,""); } - output += "\nConverters to test:\n"; + output += "\r\nConverters to test:\r\n"; Iterator iter1 = this.testConverters.iterator(); while (iter1.hasNext()){ String s = (String) iter1.next(); - output += s + "\n"; + output += s + "\r\n"; } - output += "\nConverters used to Compare files:\n"; + output += "\r\nConverters used to Compare files:\r\n"; Iterator ii2 = this.comparisonConverters.iterator(); while (ii2.hasNext()){ String s = (String) ii2.next(); - output += s +"\n"; + output += s +"\r\n"; } - output += "\nNode IDs are expected to change: " + this.nodeIDChange + "\n"; + output += "\r\nNode IDs are expected to change: " + this.nodeIDChange + "\r\n"; return output; } Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/ReportREADME.txt =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/ReportREADME.txt 2007-08-25 20:32:52 UTC (rev 496) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/ReportREADME.txt 2007-08-30 19:07:57 UTC (rev 497) @@ -5,22 +5,6 @@ There are three major reports: All Tests Report, All Converters Report, and Annotated Graph Report. -Bug Notes: The following problems (as well as others) -are known, and should be corrected. - -1. Data Manager is unable to collapse trees of - data by default. - -2. Some annoying converters output their -exceptions to the logger directly instead -of returning them. We need to redirect this -information into the reports. - -3. CIShell sometimes goofs with the numbering -of the reports, and either changes the last -digit or adds ".1" to the end of everything. - - ALL TESTS REPORT All Tests Report provides results test by test. Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/ConverterTester.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/ConverterTester.java 2007-08-25 20:32:52 UTC (rev 496) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/ConverterTester.java 2007-08-30 19:07:57 UTC (rev 497) @@ -186,8 +186,8 @@ public String toString(){ String output = ""; output += cfp.toString(); - output += testConverters.toString()+"\n"; - output += comparisonConverters.toString()+"\n"; + output += testConverters.toString()+"\r\n"; + output += comparisonConverters.toString()+"\r\n"; return output; } @@ -220,7 +220,7 @@ return true; } catch (IOException ioe) { - System.out.println("Copy Error: IOException during copy\n" + ioe.getMessage()); + System.out.println("Copy Error: IOException during copy\r\n" + ioe.getMessage()); return false; } } Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/ComparisonResult.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/ComparisonResult.java 2007-08-25 20:32:52 UTC (rev 496) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/ComparisonResult.java 2007-08-30 19:07:57 UTC (rev 497) @@ -22,8 +22,8 @@ if (comparisonSucceeded()) { return "Success!"; } else { - return "Failure: " + "\n" + - "Log:" + "\n" + + return "Failure: " + "\r\n" + + "Log:" + "\r\n" + log; } } Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/RunningLog.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/RunningLog.java 2007-08-25 20:32:52 UTC (rev 496) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/RunningLog.java 2007-08-30 19:07:57 UTC (rev 497) @@ -9,11 +9,11 @@ * @param s the text to be added to the log. */ public void append(String s) { - log += s +"\n"; + log += s +"\r\n"; } public void prepend(String s) { - log = s + "\n" + log; + log = s + "\r\n" + log; } public String getLog() { 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-08-25 20:32:52 UTC (rev 496) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConverterTester2.java 2007-08-30 19:07:57 UTC (rev 497) @@ -13,17 +13,23 @@ import org.cishell.framework.data.BasicData; import org.cishell.framework.data.Data; import org.cishell.framework.data.DataProperty; +import org.cishell.testing.convertertester.core.converter.graph.Converter; import org.cishell.testing.convertertester.core.converter.graph.ConverterGraph; import org.cishell.testing.convertertester.core.converter.graph.ConverterPath; import org.cishell.testing.convertertester.core.tester2.graphcomparison.IdsNotPreservedComparer; 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.reportgen.ConvResultMaker; 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.FullTrustHeuristic; +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; import org.cishell.testing.convertertester.core.tester2.reportgen.results.TestResult; import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; import org.osgi.service.log.LogService; /** @@ -52,28 +58,48 @@ * Tests the provided converters, and passes the results of those tests to * the report generators. Report Generators are side-effected, which takes * the place of a return value. + * @param converterRefs service reference for all the converters. * @param reportGenerators process the test results. * @param cContext the CIShell Context * @param bContext the Bundle Context */ public void execute( - ConverterGraph converterGraph, + ServiceReference[] converterRefs, ReportGenerator[] reportGenerators, CIShellContext cContext, BundleContext bContext) { + //generate all the converter paths + + ConverterGraph converterGraph = new ConverterGraph(converterRefs, + bContext, this.log); + //run the tests TestResult[] rawResults = runAllTests(converterGraph, cContext, bContext); + + System.out.println("Num Test Results coming out of runAllTests" + + ": " + rawResults.length); + AllTestsResult allTestsResult = new AllTestsResult(rawResults); + //analyze the test results to extract more useful info + + Converter[] allConverters = converterGraph.getAllConverters(); + + ChanceAtFaultHeuristic faultHeuristic = new FullTrustHeuristic(); + AllConvsResult allConvertersResult = + ConvResultMaker.generate(allTestsResult, allConverters, + faultHeuristic); + //feed test results to the report generators for (int ii = 0; ii < reportGenerators.length; ii++) { ReportGenerator reportGenerator = reportGenerators[ii]; - reportGenerator.generateReport(allTestsResult); + reportGenerator.generateReport(allTestsResult, + allConvertersResult, converterGraph.asNWB()); } } @@ -89,6 +115,8 @@ Set fileFormats = fileFormatToTestConvs.keySet(); + System.out.println("Number of file formats provided by convGraph : " + + fileFormats.size()); /* * for each file format, get the corresponding test converter paths * and comparison converter path. @@ -106,6 +134,9 @@ ConverterPath[] testConvs = (ConverterPath[]) testConvList.toArray(new ConverterPath[0]); + System.out.println("Test converters for this file format : " + + testConvs.length); + ConverterPath compareConv = (ConverterPath) fileFormatToCompareConvs.get(fileFormat); 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-08-25 20:32:52 UTC (rev 496) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java 2007-08-30 19:07:57 UTC (rev 497) @@ -9,20 +9,19 @@ import java.util.Hashtable; import java.util.List; -import org.cishell.framework.algorithm.Algorithm; -import org.cishell.framework.algorithm.AlgorithmFactory; import org.cishell.framework.data.BasicData; import org.cishell.framework.data.Data; +import org.cishell.testing.convertertester.core.converter.graph.Converter; import org.cishell.testing.convertertester.core.converter.graph.ConverterPath; import org.cishell.testing.convertertester.core.tester.graphcomparison.ComparisonResult; +import org.cishell.testing.convertertester.core.tester2.fakelogger.FakeLogCIShellContext; import org.cishell.testing.convertertester.core.tester2.fakelogger.LogEntry; -import org.cishell.testing.convertertester.core.tester2.fakelogger.FakeLogCIShellContext; import org.cishell.testing.convertertester.core.tester2.graphcomparison.NewGraphComparer; import org.cishell.testing.convertertester.core.tester2.reportgen.results.FilePassResult; import org.cishell.testing.convertertester.core.tester2.reportgen.results.converter.ConvFailureInfo; -import org.cishell.testing.convertertester.core.tester2.reportgen.results.filepass.ComparePhaseFailure; -import org.cishell.testing.convertertester.core.tester2.reportgen.results.filepass.ConvertPhaseFailure; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.filepass.FilePassFailure; import org.cishell.testing.convertertester.core.tester2.reportgen.results.filepass.FilePassSuccess; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.filepass.PassPhase; import org.osgi.service.log.LogService; import prefuse.data.Graph; @@ -53,46 +52,46 @@ testConverters, testData); if (!testPhaseResult.succeeded()) { - ConvertPhaseFailure failure = new ConvertPhaseFailure( - originalFileData, testPhaseResult.getFailInfo(), - ConvertPhaseFailure.TEST_PHASE); + FilePassFailure failure = createFailResult(originalFileData, + PassPhase.TEST_CONV_PHASE, + testPhaseResult.getFailInfo()); testResults.add(failure); continue; } Data[] resultFileData = testPhaseResult.getResult(); - // comparison conversion phase + // comparison conversion (for original file) phase - ConvertResult comparisonPhaseResult1 = convert(originalFileData, + ConvertResult comparePhaseOrigResult = convert(originalFileData, comparisonConverters, testData); - if (!comparisonPhaseResult1.succeeded()) { - ConvertPhaseFailure failure = new ConvertPhaseFailure( - originalFileData, - comparisonPhaseResult1.getFailInfo(), - ConvertPhaseFailure.TEST_PHASE); + if (!comparePhaseOrigResult.succeeded()) { + FilePassFailure failure = createFailResult(originalFileData, + PassPhase.COMPARE_CONV_ORIG_PHASE, + comparePhaseOrigResult.getFailInfo()); testResults.add(failure); continue; } - Data[] originalInMemory = comparisonPhaseResult1.getResult(); + Data[] originalInMemory = comparePhaseOrigResult.getResult(); - ConvertResult comparisonPhaseResult2 = convert(resultFileData, + //comparison conversion (for result file) phase + + ConvertResult comparePhaseResultResult = convert(resultFileData, comparisonConverters, testData); - if (!comparisonPhaseResult2.succeeded()) { - ConvertPhaseFailure failure = new ConvertPhaseFailure( - originalFileData, - comparisonPhaseResult2.getFailInfo(), - ConvertPhaseFailure.COMPARISON_PHASE); + if (!comparePhaseResultResult.succeeded()) { + FilePassFailure failure = createFailResult(originalFileData, + PassPhase.COMPARE_CONV_RESULT_PHASE, + comparePhaseResultResult.getFailInfo()); testResults.add(failure); continue; } - Data[] resultInMemory = comparisonPhaseResult2.getResult(); + Data[] resultInMemory = comparePhaseResultResult.getResult(); // graph comparison phase + Graph resultGraph = (Graph) originalInMemory[0].getData(); Graph origGraph = (Graph) resultInMemory[0].getData(); - Graph resultGraph = (Graph) originalInMemory[0].getData(); NewGraphComparer comparer = testData.getComparer(); ComparisonResult graphComparisonPhaseResult = comparer.compare( @@ -101,14 +100,15 @@ if (!graphComparisonPhaseResult.comparisonSucceeded()) { String explanation = graphComparisonPhaseResult.getLog(); - ComparePhaseFailure failure = new ComparePhaseFailure( - originalFileData, - explanation); + FilePassFailure failure = createFailResult(originalFileData, + explanation, PassPhase.COMPARE_CONV_RESULT_PHASE, + null); testResults.add(failure); continue; } - FilePassSuccess success = new FilePassSuccess(originalFileData); + FilePassSuccess success = new FilePassSuccess(originalFileData, + ""); testResults.add(success); } @@ -121,7 +121,6 @@ ConverterPath converters, TestConfigData testData) { Data[] currentData = getFilePathData(startData); - AlgorithmFactory[] converterAlgs = converters.getPathAsAlgorithms(); /* * rig up fake CISHellContext so we can get ahold of @@ -130,15 +129,16 @@ FakeLogCIShellContext fakeCContext = new FakeLogCIShellContext(testData.getContext()); - AlgorithmFactory currentConverterAlg = converterAlgs[0]; + Converter currentConverter = converters.get(0); try { - for (int ii = 0; ii < converterAlgs.length; ii++) { - currentConverterAlg = converterAlgs[ii]; + for (int ii = 0; ii < converters.size(); ii++) { + currentConverter = converters.get(ii); - Algorithm currentAlgorithm = - currentConverterAlg.createAlgorithm(currentData, - new Hashtable(), fakeCContext); - currentData = currentAlgorithm.execute(); + //no parameters used + Hashtable parameters = new Hashtable(); + + currentData = currentConverter.execute(currentData, + parameters, fakeCContext); /* * There are two ways that converters generally fail. @@ -148,21 +148,21 @@ * and return null. */ if (currentData == null || currentData[0].getData() == null) { - String converterName = converters.getConverterName(ii); + Converter converter = converters.get(ii); - String explanation = "Result data is null. \n"; + String explanation = "Result of conversion was null. \r\n"; if (fakeCContext.hasLogEntries()) { String logText = extractLogText(fakeCContext); - explanation += "Error log contains the following: \n" + + explanation += "Error log contains the following: \r\n" + logText; } else { - explanation += "No errors logged. Cause unknown. \n"; + explanation += "No errors logged. Cause unknown. \r\n"; } ConvFailureInfo failInfo = new ConvFailureInfo( - explanation, converterName); + explanation, converter); ConvertResult result = new ConvertResult(failInfo); return result; @@ -170,7 +170,7 @@ } } catch (Throwable t) { ConvFailureInfo failInfo = new ConvFailureInfo(getStackTrace(t), - currentConverterAlg.getClass().toString()); + currentConverter); ConvertResult result = new ConvertResult(failInfo); return result; } @@ -179,6 +179,20 @@ ConvertResult result = new ConvertResult(resultData); return result; } + + private FilePassFailure createFailResult(Data[] origData, + String explanation, PassPhase lastReachedPhase, + Converter failedConverter) { + FilePassFailure failure = new FilePassFailure(origData, explanation, + lastReachedPhase, failedConverter); + return failure; + } + + private FilePassFailure createFailResult(Data[] origData, + PassPhase lastReachedPhase, ConvFailureInfo failInfo) { + return createFailResult(origData, failInfo.getExplanation(), + lastReachedPhase, failInfo.getFailedConverter()); + } private class ConvertResult { @@ -248,9 +262,9 @@ Throwable e = entry.getThrowable(); String message = entry.getMessage(); - logText += message + "\n"; - logText += getStackTrace(e) + "\n"; - logText += "\n"; + logText += message + "\r\n"; + logText += getStackTrace(e) + "\r\n"; + logText += "\r\n"; } return logText; Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/ComplexGraphComparer.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/ComplexGraphComparer.java 2007-08-25 20:32:52 UTC (rev 496) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/ComplexGraphComparer.java 2007-08-30 19:07:57 UTC (rev 497) @@ -151,7 +151,6 @@ } if (! foundMatch) { - log.append("Tables do not have the same columns"); log.append("One table has the column '" + t2.getColumnName(ii) + "', while the other does " + "not."); Deleted: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ConvResultMaker.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ConvResultMaker.java 2007-08-25 20:32:52 UTC (rev 496) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ConvResultMaker.java 2007-08-30 19:07:57 UTC (rev 497) @@ -1,304 +0,0 @@ -package org.cishell.testing.convertertester.core.tester2.reportgen; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.cishell.testing.convertertester.core.converter.graph.ConverterPath; -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.cishell.testing.convertertester.core.tester2.reportgen.results.converter.ConvFilePassFailure; -import org.cishell.testing.convertertester.core.tester2.reportgen.results.converter.ConvFilePassSuccess; -import org.cishell.testing.convertertester.core.tester2.reportgen.results.filepass.ComparePhaseFailure; -import org.cishell.testing.convertertester.core.tester2.reportgen.results.filepass.ConvertPhaseFailure; -import org.cishell.testing.convertertester.core.tester2.reportgen.results.filepass.FilePassSuccess; -import org.osgi.framework.ServiceReference; - -/** - * - * @author mwlinnem - * - * - */ -public class ConvResultMaker { - - /** - * Takes an array of ConverterTester results that are organized by test, - * and returns an array of ConverterTester results organized by converter. - * This should make it easier for report generators to display - * data about how correct or incorrect each converter is, as oppose to - * which tests failed or succeeded. - * @param trs The results of testing the converters, organized by test - * @return the results of testing the converters, organized by converter - */ - public ConvResult[] generate(AllTestsResult atr) { - TestResult[] trs = atr.getTestResults(); - - //maps convert testers to their test result data. - Map resultHolder = new HashMap(); - - resultHolder = addTests(trs, resultHolder); - resultHolder = markTrusted(trs, resultHolder); - resultHolder = createConverterResults(trs, resultHolder); - - ConvResult[] results = extractResults(resultHolder); - return results; - } - - /** - * - * For each test result, go through each of the converters involved - * in the tests, letting each converter know which tests they are - * involved in. - * - * @param trs the test results - * @param rh the result holder, without converters knowing which tests - * they are used in - * @return the result holder, with converters that know which tests - * they are used in - */ - private Map addTests(TestResult[] trs, Map rh) { - for (int ii = 0; ii < trs.length; ii++) { - TestResult tr = trs[ii]; - - ConverterPath convPath = tr.getAllConverters(); - - for (int jj = 0; jj < convPath.size(); jj++) { - ConvResult ctr = getResult(rh, convPath.getRef(jj)); - ctr.addTest(tr); - } - } - - return rh; - } - - /** - * Looks for tests where each file pass succeeded. We will assume that - * each converter involved in a test where all file passes succeeded is - * very likely to be correct. If one of these converters is involved - * in a file pass that fails at some later point, we will assume - * that that converter was not at fault, but was fed erroneous data - * by previous converters. - * @param trs the converter tester results organized by test - * @param rh the result holder, which keeps track of the converter results. - * @return the result holder, which is side-effected with trust info. - */ - private Map markTrusted( TestResult[] trs, Map rh) { - for (int ii = 0; ii < trs.length; ii++) { - TestResult tr = trs[ii]; - FilePassResult[] fprs = tr.getFilePassResults(); - - //check if all file passes were successes - boolean trusted = true; - for (int jj = 0; jj < fprs.length; jj++) { - FilePassResult fpr = fprs[jj]; - if (! passed(fpr)) { - //not all were successes - trusted = false; - break; - } - } - - if (trusted && fprs.length > 0) { - //mark all converters involved as trusted. - ConverterPath allConvs = tr.getTestConverters(); - for (int kk = 0; kk < allConvs.size(); kk++) { - ConvResult ctr = getResult(rh, allConvs.getRef(kk)); - ctr.setTrusted(true); - } - } - } - - return rh; - } - - /** - * Associate each converter with the file passes that involved it, - * also keeping track of whether the file pass succeeded or not. If the - * file pass did not succeed, record what chance each converter had - * of being at fault. - * @param trs the converter tester results organized by test - * @param rh the result holder, which keeps track of the converter - * results, which now holds info on which converters are trusted. - * @return the result holder, which is side-effected with - * success/failure info - */ - private Map createConverterResults( TestResult[] trs, Map rh) { - for (int ii = 0; ii < trs.length; ii++) { - TestResult tr = trs[ii]; - FilePassResult[] fprs = tr.getFilePassResults(); - - for (int jj = 0; jj < fprs.length; jj++) { - FilePassResult fpr = fprs[jj]; - if (passed(fpr)) { - FilePassSuccess fprSuccess = (FilePassSuccess) fpr; - createPassResult(fprSuccess, rh); - } else if (failedOnConverterPhase(fpr)) { - ConvertPhaseFailure fprFailure = (ConvertPhaseFailure) fpr; - createPassResult(fprFailure, rh); - } else if (failedOnGraphComparePhase(fpr)) { - ComparePhaseFailure fprFailure = (ComparePhaseFailure) fpr; - createPassResult(fprFailure, rh); - } - } - } - - return rh; - } - - /** - * Simply gets the converter results out of the result holder. - * @param rh the result holder, which keeps track of the converter - * results, which now holds all the trust and success/failure info - * @return the converter results - */ - private ConvResult[] extractResults(Map rh) { - Collection values = rh.values(); - ConvResult[] results = - (ConvResult[]) values.toArray(new ConvResult[0]); - return results; - } - - private void createPassResult(FilePassSuccess fprSuccess, Map rh) { - ConverterPath allConvs = - fprSuccess.getParent().getAllConverters(); - - for (int kk = 0; kk < allConvs.size(); kk++) { - ConvResult ctr = getResult(rh,allConvs.getRef(kk)); - ctr.addPass(fprSuccess); - } - } - - private void createPassResult(ConvertPhaseFailure fprFailure, Map rh) { - TestResult parent = fprFailure.getParent(); - - ConverterPath testConvs = parent.getTestConverters(); - - ConverterPath compareConvs = parent.getComparisonConverters(); - - String failedConvName = fprFailure.getFailedConverter(); - - List possiblyResponsible = new ArrayList(); - List involvedButNotResponsible = new ArrayList(); - - for (int kk = 0; kk < testConvs.size(); kk++) { - ServiceReference testConvRef = testConvs.getRef(kk); - - - ConvResult ctr = getResult(rh, testConvRef); - - involvedButNotResponsible.add(ctr); - if (! ctr.isTrusted()) { - possiblyResponsible.add(ctr); - - } - - String currentConvName = (String) testConvRef.getProperty("service.pid"); - - if (fprFailure.getPhase().equals(ConvertPhaseFailure.TEST_PHASE) && - failedConvName.equals(currentConvName)) { - //reached where the converters broke - break; - } - } - - if (fprFailure.getPhase().equals(ConvertPhaseFailure.COMPARISON_PHASE)) { - for (int kk = 0; kk < compareConvs.size(); kk++) { - ServiceReference compareConvRef = testConvs.getRef(kk); - - ConvResult ctr = getResult(rh, compareConvRef); - if (ctr.isTrusted()) { - involvedButNotResponsible.add(ctr); - - } else { - possiblyResponsible.add(ctr); - } - - String currentConvName = (String) compareConvRef.getProperty("service.pid"); - if (failedConvName.equals(currentConvName)) { - //reached where the converters broke - break; - } - } - } - - float chanceEachResponsible = 1.0f / possiblyResponsible.size(); - - Iterator iter = possiblyResponsible.iterator(); - while (iter.hasNext()) { - ConvResult ctr = (ConvResult) iter.next(); - ctr.addPass(fprFailure, chanceEachResponsible); - } - - Iterator iter2 = involvedButNotResponsible.iterator(); - while (iter.hasNext()) { - ConvResult ctr = (ConvResult) iter2.next(); - //TODO: May want to give these a slight chance of being responsible. - ctr.addPass(fprFailure, 0.0f); - } - - } - - private void createPassResult(ComparePhaseFailure fprFailure, Map rh) { - ConverterPath allConvs = fprFailure - .getParent().getTestConverters(); - - List trustedConvs = new ArrayList(); - List nonTrustedConvs = new ArrayList(); - for (int ii = 0; ii < allConvs.size(); ii++) { - ConvResult ctr = getResult(rh, allConvs.getRef(ii)); - - if (! ctr.isTrusted()) { - nonTrustedConvs.add(ctr); - } else { - trustedConvs.add(ctr); - } - } - - float chanceEachResponsible = 1.0f / nonTrustedConvs.size(); - for (int ii = 0; ii < nonTrustedConvs.size(); ii++) { - ConvResult ctr = (ConvResult) nonTrustedConvs.get(ii); - ctr.addPass(fprFailure, chanceEachResponsible); - } - - for (int ii = 0; ii < trustedConvs.size(); ii++) { - ConvResult ctr = (ConvResult) trustedConvs.get(ii); - ctr.addPass(fprFailure, 0.0f); - } - } - - private ConvResult getResult(Map rh, ServiceReference conv) { - ConvResult newResult; - - Object currentTestResult = rh.get(conv); - - //check if we have recorded a converter result for this converter yet. - if (currentTestResult == null) { - //we have not yet created a converter result. Make a new one. - newResult = new ConvResult(conv); - rh.put(conv, newResult); - } else { - //We have created a converter result. Return it. - newResult = (ConvResult) currentTestResult; - } - - return newResult; - } - - private boolean passed(FilePassResult fpr) { - return fpr instanceof FilePassSuccess; - } - - private boolean failedOnConverterPhase(FilePassResult fpr) { - return fpr instanceof ConvertPhaseFailure; - } - - private boolean failedOnGraphComparePhase(FilePassResult fpr) { - return fpr instanceof ComparePhaseFailure; - } -} Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ReportGenerator.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ReportGenerator.java 2007-08-25 20:32:52 UTC (rev 496) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ReportGenerator.java 2007-08-30 19:07:57 UTC (rev 497) @@ -2,6 +2,7 @@ import java.io.File; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.AllConvsResult; import org.cishell.testing.convertertester.core.tester2.reportgen.results.AllTestsResult; @@ -10,5 +11,7 @@ public static final String FS = File.separator; public static final String TEMP_DIR = "tmp" + FS; - public void generateReport(AllTestsResult atr); + public void generateReport(AllTestsResult atr, + AllConvsResult acr, + File nwbConvGraph); } 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-08-25 20:32:52 UTC (rev 496) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allconvs/AllConvsReportGenerator.java 2007-08-30 19:07:57 UTC (rev 497) @@ -7,10 +7,10 @@ import java.util.ArrayList; import java.util.List; -import org.cishell.testing.convertertester.core.tester2.reportgen.ConvResultMaker; import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllConvsReport; 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.osgi.service.log.LogService; @@ -31,10 +31,11 @@ this.convSubGen = new ConvReportSubGenerator(this.log); } - public void generateReport(AllTestsResult atr) { + public void generateReport(AllTestsResult atr, + AllConvsResult acr, + File nwbConvGraph) { - ConvResultMaker convGen = new ConvResultMaker(); - ConvResult[] convResults = convGen.generate(atr); + ConvResult[] convResults = acr.getConvResults(); FileOutputStream reportOutStream = null; try { @@ -46,18 +47,25 @@ report.println("---------------------------------------------"); report.println("" ); - float passedPercentTotal = convResults[0].getPercentPassed(); - for (int ii = 1; ii < convResults.length; ii++) { + float passedPercentTotal = 0; + for (int ii = 0; ii < convResults.len... [truncated message content] |