From: <mwl...@us...> - 2007-07-20 18:19:59
|
Revision: 426 http://svn.sourceforge.net/cishell/?rev=426&view=rev Author: mwlinnem Date: 2007-07-20 11:19:57 -0700 (Fri, 20 Jul 2007) Log Message: ----------- Initial import. Added Paths: ----------- trunk/testing/META-INF/ trunk/testing/META-INF/MANIFEST.MF trunk/testing/OSGI-INF/ trunk/testing/OSGI-INF/algorithm.properties trunk/testing/OSGI-INF/component.xml trunk/testing/OSGI-INF/l10n/ trunk/testing/OSGI-INF/l10n/bundle_en.properties trunk/testing/OSGI-INF/metatype/ trunk/testing/OSGI-INF/metatype/METADATA.XML trunk/testing/build.properties trunk/testing/src/ trunk/testing/src/org/ trunk/testing/src/org/cishell/ trunk/testing/src/org/cishell/testing/ trunk/testing/src/org/cishell/testing/convertertester/ trunk/testing/src/org/cishell/testing/convertertester/algorithm/ trunk/testing/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java trunk/testing/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmFactory.java Added: trunk/testing/META-INF/MANIFEST.MF =================================================================== --- trunk/testing/META-INF/MANIFEST.MF (rev 0) +++ trunk/testing/META-INF/MANIFEST.MF 2007-07-20 18:19:57 UTC (rev 426) @@ -0,0 +1,18 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: ConverterTester Algorithm +Bundle-SymbolicName: org.cishell.testing.convertertester.algorithm +Bundle-Version: 0.0.1 +Bundle-ClassPath: . +Bundle-Localization: plugin +Import-Package: org.cishell.framework, + org.cishell.framework.algorithm, + org.cishell.framework.data, + org.cishell.testing.convertertester.core.tester, + org.osgi.framework;version="1.3.0", + org.osgi.service.component;version="1.0.0", + org.osgi.service.log;version="1.3.0", + org.osgi.service.metatype;version="1.1.0", + org.osgi.service.prefs;version="1.1.0" +X-AutoStart: true +Service-Component: OSGI-INF/component.xml Added: trunk/testing/OSGI-INF/algorithm.properties =================================================================== --- trunk/testing/OSGI-INF/algorithm.properties (rev 0) +++ trunk/testing/OSGI-INF/algorithm.properties 2007-07-20 18:19:57 UTC (rev 426) @@ -0,0 +1,7 @@ +#menu_path=Visualization/SubMenu/additions +label=My Algorithm +description=This algorithm does this and this... +in_data=file:mime/type or java.lang.ClassName or null +out_data=file:mime/type or java.lang.ClassName or null +service.pid=org.my.algorithm.MyAlgorithm +remoteable=false Added: trunk/testing/OSGI-INF/component.xml =================================================================== --- trunk/testing/OSGI-INF/component.xml (rev 0) +++ trunk/testing/OSGI-INF/component.xml 2007-07-20 18:19:57 UTC (rev 426) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component name="org.my.algorithm.MyAlgorithm.component" immediate="false"> + <implementation class="org.cishell.testing.convertertester.algorithm"/> + <properties entry="OSGI-INF/algorithm.properties"/> + <reference name="LOG" interface="org.osgi.service.log.LogService"/> + <reference name="MTS" interface="org.osgi.service.metatype.MetaTypeService"/> + + <service> + <provide interface= + "org.cishell.framework.algorithm.AlgorithmFactory"/> + </service> +</component> \ No newline at end of file Added: trunk/testing/OSGI-INF/l10n/bundle_en.properties =================================================================== --- trunk/testing/OSGI-INF/l10n/bundle_en.properties (rev 0) +++ trunk/testing/OSGI-INF/l10n/bundle_en.properties 2007-07-20 18:19:57 UTC (rev 426) @@ -0,0 +1,7 @@ +#Localization variables for OSGI-INF/metatatype/METADATA.XML +# +#Samples: +#input=Input +#desc=Enter an integer (that will be converted to a string) +#name=Input->String +#name_desc=Converts inputted integer to string Added: trunk/testing/OSGI-INF/metatype/METADATA.XML =================================================================== --- trunk/testing/OSGI-INF/metatype/METADATA.XML (rev 0) +++ trunk/testing/OSGI-INF/metatype/METADATA.XML 2007-07-20 18:19:57 UTC (rev 426) @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0"> + <OCD name="My Algorithm" id="org.my.algorithm.MyAlgorithm.OCD" + description="This algorithm does this and this... "> + </OCD> + <Designate pid="org.my.algorithm.MyAlgorithm"> + <Object ocdref="org.my.algorithm.MyAlgorithm.OCD" /> + </Designate> +</metatype:MetaData> Added: trunk/testing/build.properties =================================================================== --- trunk/testing/build.properties (rev 0) +++ trunk/testing/build.properties 2007-07-20 18:19:57 UTC (rev 426) @@ -0,0 +1,5 @@ +source.. = src/ +output.. = build/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/ Added: trunk/testing/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java =================================================================== --- trunk/testing/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java (rev 0) +++ trunk/testing/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java 2007-07-20 18:19:57 UTC (rev 426) @@ -0,0 +1,29 @@ +package org.cishell.testing.convertertester.algorithm; + +import java.util.Dictionary; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.data.Data; +import org.cishell.testing.convertertester.core.tester.ConverterTester; +import org.osgi.framework.BundleContext; + +public class ConverterTesterAlgorithm implements Algorithm { + Data[] data; + Dictionary parameters; + CIShellContext context; + ConverterTester tester; + + public ConverterTesterAlgorithm(Data[] data, Dictionary parameters, + CIShellContext csContext, BundleContext bContext ) { + this.data = data; + this.parameters = parameters; + this.context = csContext; + + this.tester = new ConverterTester(bContext, csContext); + } + + public Data[] execute() { + return null; + } +} \ No newline at end of file Added: trunk/testing/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmFactory.java =================================================================== --- trunk/testing/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmFactory.java (rev 0) +++ trunk/testing/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmFactory.java 2007-07-20 18:19:57 UTC (rev 426) @@ -0,0 +1,37 @@ +package org.cishell.testing.convertertester.algorithm; + +import java.util.Dictionary; + +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.osgi.framework.BundleContext; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.metatype.MetaTypeProvider; +import org.osgi.service.metatype.MetaTypeService; + + +public class ConverterTesterAlgorithmFactory implements AlgorithmFactory { + private MetaTypeProvider provider; + private BundleContext bContext; + + protected void activate(ComponentContext ctxt) { + //You may delete all references to metatype service if + //your algorithm does not require parameters and return + //null in the createParameters() method + MetaTypeService mts = (MetaTypeService)ctxt.locateService("MTS"); + this.bContext = ctxt.getBundleContext(); + provider = mts.getMetaTypeInformation(this.bContext.getBundle()); + } + protected void deactivate(ComponentContext ctxt) { + provider = null; + } + + public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { + return new ConverterTesterAlgorithm(data, parameters, context, bContext); + } + public MetaTypeProvider createParameters(Data[] data) { + return provider; + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2007-07-24 19:39:12
|
Revision: 430 http://svn.sourceforge.net/cishell/?rev=430&view=rev Author: mwlinnem Date: 2007-07-24 12:39:05 -0700 (Tue, 24 Jul 2007) Log Message: ----------- Was in wrong directory. Removed Paths: ------------- trunk/testing/META-INF/ trunk/testing/OSGI-INF/ trunk/testing/build.properties trunk/testing/src/ Deleted: trunk/testing/build.properties =================================================================== --- trunk/testing/build.properties 2007-07-24 19:25:33 UTC (rev 429) +++ trunk/testing/build.properties 2007-07-24 19:39:05 UTC (rev 430) @@ -1,5 +0,0 @@ -source.. = src/ -output.. = build/ -bin.includes = META-INF/,\ - .,\ - OSGI-INF/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2007-08-06 19:14:56
|
Revision: 460 http://cishell.svn.sourceforge.net/cishell/?rev=460&view=rev Author: mwlinnem Date: 2007-08-06 12:14:53 -0700 (Mon, 06 Aug 2007) Log Message: ----------- Initial commit for most of this. Converter Tester Phase II rough working version. Needs lots of improvement but does the basics. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java trunk/testing/org.cishell.testing.convertertester.commandline/src/org/cishell/testing/convertertester/commandline/Activator.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/tester/ConverterTester.java Added Paths: ----------- trunk/testing/org.cishell.testing.convertertester.commandline/src/org/cishell/testing/convertertester/commandline/OldActivator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/filetypes.conf trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/OldTestResult.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ 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/TestConfigData.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestResult.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestRunner.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/ComparePhaseFailure.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/ConvertPhaseFailure.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/FilePassResult.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/FilePassSuccess.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/IdsNotPreservedComparer.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/IdsPreservedComparer.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/LossyComparer.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/NewGraphComparer.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/SimpleGraphComparer.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ConvResultGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ConverterReportGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/OverviewReportGenerator.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/SampleResultReportGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/TestSuiteReportGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvBasedResult.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvFailureInfo.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvFilePass.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvFilePassFailure.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvFilePassSuccess.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-08-06 15:41:41 UTC (rev 459) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java 2007-08-06 19:14:53 UTC (rev 460) @@ -6,45 +6,55 @@ 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.BasicData; import org.cishell.framework.data.Data; -import org.cishell.testing.convertertester.core.tester.ConverterTester; +import org.cishell.framework.data.DataProperty; +import org.cishell.testing.convertertester.core.tester2.ConverterTester2; +import org.cishell.testing.convertertester.core.tester2.reportgen.ConverterReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.OverviewReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.SampleResultReportGenerator; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.osgi.framework.BundleContext; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceReference; +import org.osgi.service.log.LogService; -//TODO: OMG Fix this whole thing as soon as possible. +//TODO: Only just barely usable to run converter tester from GUI. +//TODO: Make it nice eventually -public class ConverterTesterAlgorithm implements Algorithm { +public class ConverterTesterAlgorithm implements Algorithm, AlgorithmProperty { private static File currentDir; - Data[] data; - Dictionary parameters; - CIShellContext context; - ConverterTester tester; + private Data[] data; + private Dictionary parameters; + private CIShellContext cContext; + private BundleContext bContext; + private LogService logger; public ConverterTesterAlgorithm(Data[] data, Dictionary parameters, - CIShellContext csContext, BundleContext bContext ) { + CIShellContext cContext, BundleContext bContext ) { this.data = data; this.parameters = parameters; - this.context = csContext; + this.cContext = cContext; + this.bContext = bContext; - this.tester = new ConverterTester(bContext, csContext); -// ServiceReference ctReference = bContext.getServiceReference(ConverterTester.class.getName()); -// this.tester = (ConverterTester) bContext.getService(ctReference); + this.logger = (LogService) cContext.getService( + LogService.class.getName()); } public Data[] execute() { -// int counter = PlatformUI.getWorkbench().getWorkbenchWindowCount(); -// System.out.println("counter is "+counter); -// ?? why getActiveWorkbenchWindow() didn't work?? Data[] returnDM; final IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); - if (windows.length ==0){ + if (windows.length == 0) { return null; } @@ -103,21 +113,71 @@ } } dialog.setFilterPath(currentDir.getPath()); - dialog.setText("Select a File"); + dialog.setText("Select a File: Too bad we aren't using it, haha!"); String fileName = dialog.open(); if (fileName == null) { return; } - - File file = new File(fileName); try { - tester.runTests(file); + ConverterTester2 ct = new ConverterTester2(logger); + ServiceReference[] refs = getServiceReferences(); + OverviewReportGenerator overviewGen = + new OverviewReportGenerator(); + SampleResultReportGenerator sampleGen = + new SampleResultReportGenerator(10, 5); + ConverterReportGenerator convGen = + new ConverterReportGenerator(); + + ct.execute(refs, cContext, bContext, logger, + new ReportGenerator[] {overviewGen, sampleGen, convGen}); + + File overviewReport = overviewGen.getReport(); + BasicData overviewReportData = + createReportData(overviewReport, "Overview"); + returnList.add(overviewReportData); + + + File sampleReport = sampleGen.getReport(); + BasicData sampleReportData = + createReportData(sampleReport, "Sample Test Results"); + returnList.add(sampleReportData); + + + File convReport = convGen.getReport(); + BasicData convReportData = + createReportData(convReport, "Basic Converter Results"); + returnList.add(convReportData); + } catch (Exception e) { System.out.println("Why oh why am I catching type Exception?"); System.out.println(e); + e.printStackTrace(); } } } + private BasicData createReportData(Object report, String label) { + BasicData reportData = new BasicData(report, "file:text/plain"); + Dictionary metadata = reportData.getMetaData(); + metadata.put(DataProperty.LABEL, label); + metadata.put(DataProperty.TYPE, DataProperty.TEXT_TYPE); + return reportData; + } + + private ServiceReference[] getServiceReferences() { + String filter = "(&("+ALGORITHM_TYPE+"="+TYPE_CONVERTER+"))";// + + + try { + ServiceReference[] refs = bContext.getServiceReferences( + AlgorithmFactory.class.getName(), filter); + + return refs; + } catch (InvalidSyntaxException e) { + System.out.println("OOPS!"); + System.out.println(e); + return null; + } + } + } \ No newline at end of file Modified: trunk/testing/org.cishell.testing.convertertester.commandline/src/org/cishell/testing/convertertester/commandline/Activator.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.commandline/src/org/cishell/testing/convertertester/commandline/Activator.java 2007-08-06 15:41:41 UTC (rev 459) +++ trunk/testing/org.cishell.testing.convertertester.commandline/src/org/cishell/testing/convertertester/commandline/Activator.java 2007-08-06 19:14:53 UTC (rev 460) @@ -6,16 +6,24 @@ import org.cishell.framework.CIShellContext; import org.cishell.framework.LocalCIShellContext; -import org.cishell.testing.convertertester.core.tester.ConverterTester; +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.algorithm.AlgorithmProperty; +import org.cishell.testing.convertertester.core.tester2.ConverterTester2; +import org.cishell.testing.convertertester.core.tester2.reportgen.OverviewReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceReference; +import org.osgi.service.log.LogService; -public class Activator implements BundleActivator{ - private ConverterTester ct; +public class Activator implements BundleActivator, AlgorithmProperty { + private ConverterTester2 ct; private BundleContext b; private CIShellContext c; private File configFile; + private LogService logger; public static final String QUIT = "q"; @@ -23,11 +31,27 @@ this.b = b; this.c = new LocalCIShellContext(b); + this.logger = (LogService) c.getService( + LogService.class.getName()); startCommandLine(); } + public ServiceReference[] getServiceReferences() { + String filter = "(&("+ALGORITHM_TYPE+"="+TYPE_CONVERTER+"))";// + + try { + ServiceReference[] refs = b.getServiceReferences( + AlgorithmFactory.class.getName(), filter); + + return refs; + } catch (InvalidSyntaxException e) { + System.out.println("OOPS!"); + System.out.println(e); + return null; + } + } + public void stop(BundleContext b){ System.out.println("Goodbye!"); @@ -62,29 +86,17 @@ } } - private void processConfigurationFile(File f) - throws FileNotFoundException { + private void processConfigurationFile(File f) throws FileNotFoundException { System.out.println("Processing " + f.getName()); - if(!f.isHidden() && (f.getName().charAt(0) != '.')){ - if(f.isDirectory()){ - File[] files = f.listFiles(); - for (int ii = 0; ii < files.length; ii++) { - File ff = files[ii]; - processConfigurationFile(ff); - } - } - else{ - try{ - ct = new ConverterTester(b, c, f); - System.out.println(ct); - ct.testFiles(); - ct.printResults(); - }catch(Exception ex){ - System.out.println("Failed to create " + - "ConverterTester\n\n"); - ex.printStackTrace(); - } - } + try { + ServiceReference[] refs = getServiceReferences(); + ct = new ConverterTester2(this.logger); + ReportGenerator overview = new OverviewReportGenerator(); + ct.execute(refs, c, b, logger, new ReportGenerator[] {overview}); + System.out.println(ct); + } catch (Exception ex) { + System.out.println("Failed to create " + "ConverterTester\n\n"); + ex.printStackTrace(); } } } Added: trunk/testing/org.cishell.testing.convertertester.commandline/src/org/cishell/testing/convertertester/commandline/OldActivator.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.commandline/src/org/cishell/testing/convertertester/commandline/OldActivator.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.commandline/src/org/cishell/testing/convertertester/commandline/OldActivator.java 2007-08-06 19:14:53 UTC (rev 460) @@ -0,0 +1,91 @@ +package org.cishell.testing.convertertester.commandline; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Scanner; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.LocalCIShellContext; +import org.cishell.testing.convertertester.core.tester.ConverterTester; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + + +public class OldActivator implements BundleActivator{ + private ConverterTester ct; + private BundleContext b; + private CIShellContext c; + private File configFile; + + public static final String QUIT = "q"; + + public void start(BundleContext b){ + this.b = b; + this.c = new LocalCIShellContext(b); + + startCommandLine(); + } + + + + public void stop(BundleContext b){ + System.out.println("Goodbye!"); + + b = null; + c = null; + configFile = null; + ct = null; + } + + public void startCommandLine(){ + Scanner in = new Scanner(System.in); + while(true) { + System.out.println("Welcome to NWB's Converter Tester"); + System.out.println( "Please enter the name of a configuration " + + "file or\n a directory of configuration files (" + QUIT + + ") to quit): "); + + String s = in.nextLine(); + if(s.trim().equalsIgnoreCase(QUIT)) + break; + try{ + configFile = new File(s); + processConfigurationFile(configFile); + } + catch (NullPointerException ex){ + System.out.println("Invalid file name");; + } + catch(FileNotFoundException fnfe){ + System.out.println("Could not find the specified " + + "configuration file"); + } + } + } + + private void processConfigurationFile(File f) + throws FileNotFoundException { + System.out.println("Processing " + f.getName()); + if(!f.isHidden() && (f.getName().charAt(0) != '.')){ + if(f.isDirectory()){ + File[] files = f.listFiles(); + for (int ii = 0; ii < files.length; ii++) { + File ff = files[ii]; + processConfigurationFile(ff); + } + } + else{ + try{ + ct = new ConverterTester(b, c, f); + System.out.println(ct); + ct.testFiles(); + ct.printResults(); + }catch(Exception ex){ + System.out.println("Failed to create " + + "ConverterTester\n\n"); + ex.printStackTrace(); + } + } + } + } +} + 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-08-06 15:41:41 UTC (rev 459) +++ trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF 2007-08-06 19:14:53 UTC (rev 460) @@ -15,4 +15,7 @@ org.osgi.service.metatype;version="1.1.0", org.osgi.service.prefs;version="1.1.0" Require-Bundle: org.prefuse.lib -Export-Package: org.cishell.testing.convertertester.core.tester +Export-Package: org.cishell.testing.convertertester.core.tester, + org.cishell.testing.convertertester.core.tester2, + org.cishell.testing.convertertester.core.tester2.reportgen, + org.cishell.testing.convertertester.core.tester2.reportgen.results Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/filetypes.conf =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/filetypes.conf (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/filetypes.conf 2007-08-06 19:14:53 UTC (rev 460) @@ -0,0 +1,6 @@ +file:text/edge=Edge Files +file:text/graphml+xml=GraphML Files +file:application/pajek=Net Files +file:text/nwb=NWB Files +file:text/treeml+xml=TreeML Files +file:text/xgmml_xml=XGMML Files 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-06 15:41:41 UTC (rev 459) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/ConverterTester.java 2007-08-06 19:14:53 UTC (rev 460) @@ -121,6 +121,7 @@ System.out.println("Converting " + f.getCanonicalPath()); Data inData = new BasicData(f.getCanonicalPath(),""); Data dm = cnv.convert(inData); + if(dm != null){ Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/OldTestResult.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/OldTestResult.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/OldTestResult.java 2007-08-06 19:14:53 UTC (rev 460) @@ -0,0 +1,17 @@ +package org.cishell.testing.convertertester.core.tester; + +public abstract class OldTestResult { + public abstract String getType(); + public abstract String[] getTestConverterNames(); + public abstract String[] getComparisonConverterNames(); + + public boolean hasExplanation() {return false;} + public boolean hasFailedConverterName() {return false;} + public boolean hasOriginalGraphName() {return false;} + public boolean hasResultingGraphNames() {return false;} + + public String getExplanation() {return "";} + public String getFailedConverterName() {return "";} + public String getOriginalGraphName() {return "";} + public String[] getResultGraphNames() {return new String[0];} +} Added: 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 (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConverterTester2.java 2007-08-06 19:14:53 UTC (rev 460) @@ -0,0 +1,214 @@ +package org.cishell.testing.convertertester.core.tester2; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.algorithm.AlgorithmProperty; +import org.cishell.framework.data.BasicData; +import org.cishell.framework.data.Data; +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.filepassresults.FilePassResult; +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.ReportGenerator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.service.log.LogService; + +/** + * Test Suites are arrays of test paths, where each test path starts + * from the same file format. + * + * Compare Paths are paths of converters that convert from the original file + * format to the in-memory comparison format. For each test suite there + * is a single corresponding compare path. + * + * @author mwlinnem + * + */ +public class ConverterTester2 implements AlgorithmProperty { + + private LogService log; + + private TestFileKeeper testFileKeeper; + private TestRunner testRunner; + + + public ConverterTester2(LogService log) { + this.log = log; + this.testFileKeeper = + new TestFileKeeper(TestFileKeeper.DEFAULT_ROOT_DIR, log); + this.testRunner = new DefaultTestRunner(log); + } + + + /** + * 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 the converters to be tested + * @param cContext the CIShell Context + * @param bContext the Bundle Context + * @param log The log written to should an error occur (other than the + * errors resulting from the converters, which are included in the test + * results) + * @param reportGenerators process the test results. + */ + public void execute(ServiceReference[] converterRefs, + CIShellContext cContext, + BundleContext bContext, + LogService log, + ReportGenerator[] reportGenerators) { + + this.log = log; + + //generate test paths + + ConverterGraph converterGraph = new ConverterGraph(converterRefs); + + ConverterPath[][] testSuites = converterGraph.getTestPaths(); + ConverterPath[] comparePaths = converterGraph.getComparePaths(); + + //run tests on test paths + + TestResult[] results = runTests(testSuites, comparePaths, + cContext, bContext); + + //generate reports based on test results + + for (int ii = 0; ii < reportGenerators.length; ii++) { + ReportGenerator reportGenerator = reportGenerators[ii]; + + reportGenerator.generateReport(results); + } + } + + + public TestResult[] runTests(ConverterPath[][] testSuites, + ConverterPath[] comparePaths, CIShellContext cContext, + BundleContext bContext) { + + List testResults = new ArrayList(); + + for (int ii = 0; ii < testSuites.length; ii++) { + ConverterPath[] testSuite = testSuites[ii]; + ConverterPath testSuiteComparePath = comparePaths[ii]; + + for (int jj = 0; jj < testSuite.length; jj++) { + ConverterPath testPath = testSuite[jj]; + + TestResult testResult = runATest(testPath, + testSuiteComparePath, cContext, bContext); + + if (testResult != null) { + testResults.add(testResult); + } + } + + } + + return (TestResult[]) testResults.toArray(new TestResult[0]); + } + + + private TestResult runATest(ConverterPath testConvs, + ConverterPath comparisonConvs, CIShellContext cContext, + BundleContext bContext) { + + ServiceReference[] testConvRefs = testConvs.getPathAsArray(); + ServiceReference[] compareConvRefs = comparisonConvs.getPathAsArray(); + + AlgorithmFactory[] testConvAlgs = extractAlgorithms( + testConvRefs, bContext); + AlgorithmFactory[] compareConvAlgs = extractAlgorithms( + compareConvRefs, bContext); + + if (testConvRefs.length <= 0) { + System.out.println("Must have at least one test converter.."); + return null; + } + + //get test files corresponding to the format these converters accept. + + String fileFormat = + (String) testConvRefs[0].getProperty(AlgorithmProperty.OUT_DATA); + String[] testFilePaths = testFileKeeper.getTestFilePaths(fileFormat); + Data[][] fileData = wrapInData(testFilePaths, fileFormat); + + //determine how we will compare the graphs + + boolean areLossy = areLossy(testConvRefs) && areLossy(compareConvRefs); + boolean preserveIds = false; //TODO: determine this somehow + NewGraphComparer comparer = getComparer(areLossy, preserveIds); + + //pack all the data relevant to the test into a single object. + TestConfigData testData = new TestConfigData(comparer, testConvAlgs, + compareConvAlgs, cContext, fileData); + + //run the test + FilePassResult[] results = this.testRunner.runTest(testData); + + //return the results of the test + return new TestResult(results); + } + + + private AlgorithmFactory[] extractAlgorithms(ServiceReference[] convRefs, + BundleContext bContext) { + AlgorithmFactory[] results = new AlgorithmFactory[convRefs.length]; + for (int ii = 0; ii < convRefs.length; ii++) { + results[ii] = (AlgorithmFactory) bContext.getService(convRefs[ii]); + } + return results; + } + + + private Data[][] wrapInData(String[] testFilePaths, String format) { + + Data[][] results = new Data[testFilePaths.length][1]; + for (int ii = 0; ii < testFilePaths.length; ii++) { + String filePath = testFilePaths[ii]; + + results[ii] = + new Data[] {new BasicData(new File(filePath), format)}; + } + + return results; + } + + + private boolean areLossy(ServiceReference[] refs) { + + String lossiness = LOSSLESS; + for (int i=0; i < refs.length; i++) { + if (LOSSY.equals(refs[i].getProperty(CONVERSION))) { + lossiness = LOSSY; + } + } + + boolean result = lossiness.equals(LOSSY); + return result; + } + + + private NewGraphComparer getComparer(boolean areLossy, + boolean idsPreserved) { + + if (areLossy) { + return new LossyComparer(); + } else if (! idsPreserved) { + return new IdsNotPreservedComparer(); + } else { + return new IdsPreservedComparer(); + } + } + + +} Added: 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 (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java 2007-08-06 19:14:53 UTC (rev 460) @@ -0,0 +1,219 @@ +package org.cishell.testing.convertertester.core.tester2; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +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.tester.graphcomparison.ComparisonResult; +import org.cishell.testing.convertertester.core.tester2.filepassresults.ComparePhaseFailure; +import org.cishell.testing.convertertester.core.tester2.filepassresults.ConvertPhaseFailure; +import org.cishell.testing.convertertester.core.tester2.filepassresults.FilePassResult; +import org.cishell.testing.convertertester.core.tester2.filepassresults.FilePassSuccess; +import org.cishell.testing.convertertester.core.tester2.graphcomparison.NewGraphComparer; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.ConvFailureInfo; +import org.osgi.service.log.LogService; + +import prefuse.data.Graph; + +public class DefaultTestRunner implements TestRunner { + + private LogService log; + + public DefaultTestRunner(LogService log) { + this.log = log; + } + + public FilePassResult[] runTest(TestConfigData testData) { + + Data[][] testFileData = testData.getTestFileData(); + AlgorithmFactory[] testConverters = testData.getTestConverters(); + AlgorithmFactory[] comparisonConverters = testData + .getComparisonConverters(); + + + // list of FilePassResult + final List testResults = new ArrayList(); + + for (int ii = 0; ii < testFileData.length; ii++) { + Data[] originalFileData = testFileData[ii]; + + // test conversion phase + + ConvertResult testPhaseResult = convert(originalFileData, + testConverters, testData); + + if (!testPhaseResult.succeeded()) { + ConvertPhaseFailure failure = new ConvertPhaseFailure( + originalFileData, testConverters, comparisonConverters, + testPhaseResult.getFailInfo(), + ConvertPhaseFailure.TEST_PHASE); + testResults.add(failure); + continue; + } + Data[] resultFileData = testPhaseResult.getResult(); + + // comparison conversion phase + + ConvertResult comparisonPhaseResult1 = convert(originalFileData, + comparisonConverters, testData); + + if (!comparisonPhaseResult1.succeeded()) { + ConvertPhaseFailure failure = new ConvertPhaseFailure( + originalFileData, testConverters, comparisonConverters, + comparisonPhaseResult1.getFailInfo(), + ConvertPhaseFailure.TEST_PHASE); + testResults.add(failure); + continue; + } + Data[] originalInMemory = comparisonPhaseResult1.getResult(); + + ConvertResult comparisonPhaseResult2 = convert(resultFileData, + comparisonConverters, testData); + + if (!comparisonPhaseResult2.succeeded()) { + ConvertPhaseFailure failure = new ConvertPhaseFailure( + originalFileData, testConverters, comparisonConverters, + comparisonPhaseResult2.getFailInfo(), + ConvertPhaseFailure.COMPARISON_PHASE); + testResults.add(failure); + continue; + } + Data[] resultInMemory = comparisonPhaseResult2.getResult(); + + // graph comparison phase + + Graph origGraph = (Graph) resultInMemory[0].getData(); + Graph resultGraph = (Graph) originalInMemory[0].getData(); + + NewGraphComparer comparer = testData.getComparer(); + ComparisonResult graphComparisonPhaseResult = comparer.compare( + origGraph, resultGraph); + + if (!graphComparisonPhaseResult.comparisonSucceeded()) { + String explanation = graphComparisonPhaseResult.getLog(); + ComparePhaseFailure failure = new ComparePhaseFailure( + originalFileData, testConverters, comparisonConverters, + explanation); + testResults.add(failure); + continue; + } + + FilePassSuccess success = new FilePassSuccess(originalFileData, + testConverters, comparisonConverters); + testResults.add(success); + } + + FilePassResult[] result = new FilePassResult[testResults.size()]; + result = (FilePassResult[]) testResults.toArray(result); + return result; + } + + private ConvertResult convert(Data[] startData, + AlgorithmFactory[] converters, TestConfigData testData) { + + // validator takes a string file path, all others just take files or + // graphs or whatever); + Data[] currentData = getFilePathData(startData); + + AlgorithmFactory currentConverter = converters[0]; + try { + for (int ii = 0; ii < converters.length; ii++) { + currentConverter = converters[ii]; + Algorithm currentAlgorithm = currentConverter.createAlgorithm( + currentData, new Hashtable(), testData.getContext()); + currentData = currentAlgorithm.execute(); + + if (currentData == null) { + ConvFailureInfo failInfo = new ConvFailureInfo( + "null result data", currentConverter); + ConvertResult result = new ConvertResult(failInfo); + return result; + } + + BasicData currentDataImpl = (BasicData) currentData[0]; + if (currentDataImpl.getData() == null) { + ConvFailureInfo failInfo = new ConvFailureInfo( + "null result data contents", currentConverter); + ConvertResult result = new ConvertResult(failInfo); + return result; + } + } + } catch (Throwable t) { + ConvFailureInfo failInfo = new ConvFailureInfo(t.toString() + + getStackTrace(t), currentConverter); + ConvertResult result = new ConvertResult(failInfo); + return result; + } + + Data[] resultData = currentData; + ConvertResult result = new ConvertResult(resultData); + return result; + } + + private class ConvertResult { + + private boolean succeeded; + + private Data[] result; + + private ConvFailureInfo failInfo; + + public ConvertResult(Data[] result) { + this.result = result; + + this.succeeded = true; + } + + public ConvertResult(ConvFailureInfo failInfo) { + this.failInfo = failInfo; + + this.succeeded = false; + } + + public boolean succeeded() { + return this.succeeded; + } + + public Data[] getResult() { + return result; + } + + public ConvFailureInfo getFailInfo() { + return this.failInfo; + } + } + + private String getStackTrace(Throwable t) { + final Writer writer = new StringWriter(); + final PrintWriter printWriter = new PrintWriter(writer); + t.printStackTrace(printWriter); + return writer.toString(); + + } + + private Data[] getFilePathData(Data[] fileData) { + BasicData basicData = (BasicData) fileData[0]; + String format = basicData.getFormat(); + File actualFile = (File) basicData.getData(); + try { + String filePath = actualFile.getCanonicalPath(); + BasicData result = new BasicData(filePath, format); + return new Data[] { result }; + } catch (IOException e) { + System.out.println(e); + e.printStackTrace(); + + return null; + } + + } +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestConfigData.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestConfigData.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestConfigData.java 2007-08-06 19:14:53 UTC (rev 460) @@ -0,0 +1,48 @@ +package org.cishell.testing.convertertester.core.tester2; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.data.Data; +import org.cishell.testing.convertertester.core.tester2.graphcomparison.NewGraphComparer; + +public class TestConfigData { + + private NewGraphComparer comparer; + private AlgorithmFactory[] testConverters; + private AlgorithmFactory[] comparisonConverters; + private CIShellContext context; + private Data[][] testFileData; + + public TestConfigData(NewGraphComparer comparer, + AlgorithmFactory[] testConverters, + AlgorithmFactory[] comparisonConverters, + CIShellContext context, + Data[][] testFileData) { + this.comparer = comparer; + this.testConverters = testConverters; + this.comparisonConverters = comparisonConverters; + this.context = context; + this.testFileData = testFileData; + } + + public NewGraphComparer getComparer() { + return this.comparer; + } + + public AlgorithmFactory[] getComparisonConverters() { + return this.comparisonConverters; + } + + public CIShellContext getContext() { + return this.context; + } + + public AlgorithmFactory[] getTestConverters() { + return this.testConverters; + } + + public Data[][] getTestFileData() { + return this.testFileData; + } + +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-08-06 19:14:53 UTC (rev 460) @@ -0,0 +1,102 @@ +package org.cishell.testing.convertertester.core.tester2; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.osgi.service.log.LogService; + +public class TestFileKeeper { + + public static final String DEFAULT_ROOT_DIR = "workspace/org.cishell." + + "testing.convertertester.core.new/src/org/cishell/testing/" + + "convertertester/core/test_files/"; + + public static final String CONF_FILE_NAME = "filetypes.conf"; + + public static final Pattern LINE_FORMAT = + Pattern.compile("^file:[^=]*?=[^=]*$"); + + private Map formatToDir = new HashMap(); + private LogService log; + + public TestFileKeeper(String rootDir, LogService log) { + this.log = log; + + String line; + BufferedReader reader = null; + try { + String filePath = System.getProperty("user.home") + "/" + + rootDir + CONF_FILE_NAME; + reader = new BufferedReader(new FileReader(filePath)); + while ((line = reader.readLine()) != null) { + + Matcher matcher = LINE_FORMAT.matcher(line); + if (matcher.matches()) { + String[] splitLine = line.split("="); + + String fileFormat = splitLine[0]; + String dir = splitLine[1]; + + String testFilePath = System.getProperty("user.home") + + "/" + rootDir + dir; + + formatToDir.put(fileFormat, testFilePath); + } else { + this.log.log(LogService.LOG_ERROR, "the line '" + line + + "' is not formatted correctly"); + } + } + } catch (IOException e) { + this.log.log(LogService.LOG_ERROR, "Incorrect directory for " + + "test file specified", e); + e.printStackTrace(); + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + this.log.log(LogService.LOG_ERROR, "Cannot close reader.", + e); + } + } + } + } + + //TODO: maybe make it cache the files instead of getting them every time? + public String[] getTestFilePaths(String format) { + + List results = new ArrayList(); + + String testFileDirPath = (String) this.formatToDir.get(format); + if (testFileDirPath == null) { + this.log.log(LogService.LOG_ERROR, "Could not load directory " + + "for files of format " + format); + return new String[0]; + } + File testFileDir = new File(testFileDirPath); + File[] dirContents = testFileDir.listFiles(); + + for (int ii = 0; ii < dirContents.length; ii++) { + if (! dirContents[ii].isHidden()) { + try { + String fullTestFilePath = dirContents[ii].getCanonicalPath(); + results.add(fullTestFilePath); + } catch (IOException e) { + this.log.log(LogService.LOG_ERROR, "Could not open " + + "file " + dirContents[ii], e); + } + } + } + + return (String[]) results.toArray(new String[0]); + } + +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestResult.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestResult.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestResult.java 2007-08-06 19:14:53 UTC (rev 460) @@ -0,0 +1,77 @@ +package org.cishell.testing.convertertester.core.tester2; + +import org.cishell.testing.convertertester.core.tester2.filepassresults.FilePassResult; + +public class TestResult { + + private FilePassResult[] fprs; + + private boolean cachedSuccesses = false; + private boolean[] successes; + + + + public TestResult(FilePassResult[] fprs) { + this.fprs = fprs; + this.successes = new boolean[fprs.length]; + } + + public FilePassResult[] getFilePassResults() { + return fprs; + } + + public boolean allSucceeded() { + if (! cachedSuccesses) cacheSuccesses(); + + boolean allSucceeded = true; + for (int ii = 0; ii < successes.length; ii++) { + if (successes[ii] == false) { + allSucceeded = false; + break; + } + } + + return allSucceeded; + } + + public boolean allFailed() { + if (! cachedSuccesses) cacheSuccesses(); + + boolean allFailed = true; + for (int ii = 0; ii < successes.length; ii++) { + if (successes[ii] == true) { + allFailed = false; + break; + } + } + + return allFailed; + } + + public boolean someSucceeded() { + return ! allFailed(); + } + + public boolean someFailed() { + return ! allSucceeded(); + } + + private void cacheSuccesses() { + for (int ii = 0; ii < fprs.length; ii++) { + FilePassResult fpr = fprs[ii]; + + if (fpr.getType().equals(FilePassResult.SUCCESS)) { + this.successes[ii] = true; + } else { + this.successes[ii] = false; + } + } + + this.cachedSuccesses = true; + } + + + + + +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestRunner.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestRunner.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestRunner.java 2007-08-06 19:14:53 UTC (rev 460) @@ -0,0 +1,7 @@ +package org.cishell.testing.convertertester.core.tester2; + +import org.cishell.testing.convertertester.core.tester2.filepassresults.FilePassResult; + +public interface TestRunner { + public FilePassResult[] runTest(TestConfigData testData); +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/ComparePhaseFailure.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/ComparePhaseFailure.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/ComparePhaseFailure.java 2007-08-06 19:14:53 UTC (rev 460) @@ -0,0 +1,27 @@ +package org.cishell.testing.convertertester.core.tester2.filepassresults; + +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.data.Data; + +public class ComparePhaseFailure extends FilePassResult { + + private String explanation; + + public ComparePhaseFailure( + Data[] originalData, + AlgorithmFactory[] testConverters, + AlgorithmFactory[] comparisonConverters, + String explanation) { + super(originalData, testConverters, comparisonConverters); + this.explanation = explanation; + } + + public String getExplanation() { + return this.explanation; + } + + public String getType() { + return FilePassResult.COMPARE_FAILURE; + } + +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/ConvertPhaseFailure.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/ConvertPhaseFailure.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/ConvertPhaseFailure.java 2007-08-06 19:14:53 UTC (rev 460) @@ -0,0 +1,44 @@ +package org.cishell.testing.convertertester.core.tester2.filepassresults; + +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.data.Data; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.ConvFailureInfo; + +public class ConvertPhaseFailure extends FilePassResult { + + public static final String TEST_PHASE = "test conversion phase"; + public static final String COMPARISON_PHASE = "comparison conversion phase"; + + private String explanation; + private AlgorithmFactory failedConverter; + private String phase; + + public ConvertPhaseFailure( + Data[] originalData, + AlgorithmFactory[] testConverters, + AlgorithmFactory[] comparisonConverters, + ConvFailureInfo convertFailInfo, + String phase) { + super(originalData, testConverters, comparisonConverters); + this.explanation = convertFailInfo.getExplanation(); + this.failedConverter = convertFailInfo.getFailedConverter(); + this.phase = phase; + } + + public String getPhase() { + return this.phase; + } + + public String getExplanation() { + return this.explanation; + } + + public AlgorithmFactory getFailedConverter() { + return this.failedConverter; + } + + public String getType() { + return FilePassResult.CONVERT_FAILURE; + } + +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/FilePassResult.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/FilePassResult.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/FilePassResult.java 2007-08-06 19:14:53 UTC (rev 460) @@ -0,0 +1,60 @@ +package org.cishell.testing.convertertester.core.tester2.filepassresults; + +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.data.Data; + +public abstract class FilePassResult { + + public static final String SUCCESS = "success"; + public static final String CONVERT_FAILURE = "convert failure"; + public static final String COMPARE_FAILURE = "compare failure"; + + private AlgorithmFactory[] testConverters; + private AlgorithmFactory[] comparisonConverters; + private AlgorithmFactory[] allConverters; + private Data[] originalData; + + public FilePassResult( + Data[] originalData, + AlgorithmFactory[] testConverters, + AlgorithmFactory[] comparisonConverters) { + this.originalData = originalData; + this.testConverters = testConverters; + this.comparisonConverters = comparisonConverters; + } + + public AlgorithmFactory[] getTestConverters() { + return this.testConverters; + } + + public AlgorithmFactory[] getComparisonConverters() { + return this.comparisonConverters; + } + + public AlgorithmFactory[] getAllConverters() { + if (this.allConverters == null) { + initializeAllConverters(); + } + + return this.allConverters; + } + + public Data[] getOriginalData() { + return this.originalData; + } + + public abstract String getType(); + + private void initializeAllConverters() { + this.allConverters = new AlgorithmFactory[testConverters.length + + comparisonConverters.length]; + for (int ii = 0; ii < testConverters.length; ii++) { + allConverters[ii] = testConverters[ii]; + } + + int startIndex = testConverters.length; + for (int ii = startIndex; ii < startIndex + comparisonConverters.length; ii++) { + allConverters[ii] = comparisonConverters[ii - startIndex]; + } + } +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/FilePassSuccess.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/FilePassSuccess.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/FilePassSuccess.java 2007-08-06 19:14:53 UTC (rev 460) @@ -0,0 +1,18 @@ +package org.cishell.testing.convertertester.core.tester2.filepassresults; + +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.data.Data; + +public class FilePassSuccess extends FilePassResult { + + public FilePassSuccess( + Data[] originalData, + AlgorithmFactory[] testConverters, + AlgorithmFactory[] comparisonConverters) { + super(originalData, testConverters, comparisonConverters); + } + + public String getType() { + return FilePassResult.SUCCESS; + } +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/IdsNotPreservedComparer.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/IdsNotPreservedComparer.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/IdsNotPreservedComparer.java 2007-08-06 19:14:53 UTC (rev 460) @@ -0,0 +1,257 @@ +package org.cishell.testing.convertertester.core.tester2.graphcomparison; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.cishell.testing.convertertester.core.tester.graphcomparison.ComparisonResult; +import org.cishell.testing.convertertester.core.tester.graphcomparison.GraphUtil; +import org.cishell.testing.convertertester.core.tester.graphcomparison.RunningLog; + +import prefuse.data.Graph; +import prefuse.data.Node; +import prefuse.data.Table; +import prefuse.data.Tuple; +import prefuse.util.collections.IntIterator; + +public class IdsNotPreservedComparer extends SimpleGraphComparer { + + private RunningLog log; + + public ComparisonResult compare(Graph g1, Graph g2) { + this.log = new RunningLog(); + + ComparisonResult simpleCompareResult = super.compare(g1, g2); + + if (! simpleCompareResult.comparisonSucceeded()) { + return simpleCompareResult; + } + + log.append(simpleCompareResult.getLog()); + + if (! nodeDegreeFrequenciesEqual(g1, g2)) + return new ComparisonResult(false, "The number of nodes" + + "with a certain number of edges is not the same in" + + "both graphs.", log); + + /* + * TODO: we could really use a graph isomorphism comparison right + * here. nodeDegreeFrequencies will catch some errors, but lets + * a lot through. + */ + + if (! haveSameNodeAttributes(g1, g2)) + return new ComparisonResult(false, "Node attributes are not " + + "the same in both graphs.", log); + + if (! haveSameEdgeAttributes(g1, g2)) + return new ComparisonResult(false, "Edge attributes are not " + + "the same in both graphs.", log); + + //all tests passed + return new ComparisonResult(true, "All tests succeeded.", log); + } + + /* + * Tests whether there are an equal numbers of nodes with the same + * number of edges in each graph, e.g. 5 nodes with 1 edge, 12 nodes + * with 2 edges etc.. . + * + * Possibly useful when graph IDs are modified by the conversion. + */ + private boolean nodeDegreeFrequenciesEqual(Graph g1, Graph g2) { + Set e1 = getNodeDegreeFrequencies(g1); + Set e2 = getNodeDegreeFrequencies(g2); + + boolean result = e1.equals(e2); + return result; + } + + /* + * Helper method for nodeDegreeFrequenciesEqual + */ + private Set getNodeDegreeFrequencies(Graph g) { + Map nodeDegreeFrequencies + = new HashMap(); + + /* + * TODO: (might want to shortcut all of this by counting from 0 to + * numberOfNodes) + */ + Table nodeTable = g.getNodeTable(); + for (IntIterator ii = nodeTable.rows(); ii.hasNext();) { + int nodeID = ii.nextInt(); + Node node = g.getNode(nodeID); + + int numEdges = g.getInDegree(node) + g.getOutDegree(node); + + Integer currentFrequency = + (Integer) nodeDegreeFrequencies.get(new Integer(numEdges)); + if (currentFrequency == null) { + /* + * A node with this number of edges has not been recorded yet, + * so we set the number of occurrences to one. + */ + nodeDegreeFrequencies.put(new Integer(numEdges), + new Integer(1)); + } else { + /* + * A node with this number of edges has been recorded, so + * we increment the number of occurrences by one. + */ + nodeDegreeFrequencies.put(new Integer(numEdges), + currentFrequency); + } + } + + //convert the result to a more usable format. + Set nodeFrequencyPairs + = nodeDegreeFrequencies.entrySet(); + + return nodeFrequencyPairs; + } + + + private boolean haveSameNodeAttributes(Graph g1, Graph g2) { + Table t1 = getStrippedNodeTable(g1); + Table t2 = getStrippedNodeTable(g2); + boolean result = areEqualWhenSorted(t1, t2); + return result; + } + + /* + * Determines whether the two graphs have the same edge attributes. + * That is, for every edge in table A there is an edge in table B with + * the exactly the same attribute values, and vice versa. Has no regard + * for source and target IDs, or the order the edgesappear in the edge + * tables. + */ + private boolean haveSameEdgeAttributes(Graph g1, Graph g2) { + //remove the IDs + Table t1 = getStrippedEdgeTable(g1.getEdgeTable()); + Table t2 = getStrippedEdgeTable(g2.getEdgeTable()); + + boolean result = areEqualWhenSorted(t1, t2); + return result; + } + + /* + * These methods do what .equals() should do for their respective objects: + * Actually compare the contents to see if they are .equals() to each + * other. The default methods instead appear to be doing a memory + * location comparison. + */ + + private boolean areEqual(Graph g1, Graph g2, boolean sort) { + Table nodeTable1 = g1.getNodeTable(); + Table nodeTable2 = g2.getNodeTable(); + + if (sort) { + if (! areEqualWhenSorted(nodeTable1, nodeTable2)) + return false; + } else { + if (! areEqual(nodeTable1, nodeTable2)) + return false; + } + + Table edgeTable1 = g1.getEdgeTable(); + Table edgeTable2 = g2.getEdgeTable(); + + if (sort) { + if (! areEqualWhenSorted(edgeTable1, edgeTable2)) + return false; + } else { + if (! areEqual(edgeTable1, edgeTable2)) + return false; + } + + return true; + } + + private boolean areEqualWhenSorted(Table t1, Table t2) { + boolean result = areEqual(GraphUtil.getSorted(t1), + GraphUtil.getSorted(t2)); + return result; + } + + /* + * Cares about the order of nodes and edges as well. + */ + private boolean areEqual(Table t1, Table t2) { + Iterator tuplesIterator1 = t1.tuples(); + Iterator tuplesIterator2 = t2.tuples(); + + while (tuplesIterator1.hasNext()) { + Tuple tuple1 = (Tuple) tuplesIterator1.next(); + Tuple tuple2 = (Tuple) tuplesIterator2.next(); + + if (! areEqual(tuple1, tuple2)) { + return false; + } + } + + return true; + } + + private boolean areEqual(Tuple tu1, Tuple tu2) { + if (tu1.getColumnCount() != tu2.getColumnCount()) { + log.append("Number of columns in tuples differ."); + log.append("First tuple: " + tu1); + log.append("Second tuple: " + tu2); + return false; + } + + for (int ii = 0; ii < tu1.getColumnCount(); ii++) { + Object columnContents1 = tu1.get(ii); + Object columnContents2 = tu2.get(ii); + + if (columnContents1 == null && columnContents2 == null) { + //nulls are equal to each other! + continue; + } else if (columnContents1 == null) { + //one is null and the other is not. + log.append("Bad pair of tuples!"); + log.append(tu1 + " : " + tu2); + return false; + } else if (columnContents2 == null) { + //one is null and the other is not. + log.append("Bad pair of tuples!"); + log.append(tu1 + " : " + tu2); + return false; + } else if (! tu1.get(ii).equals(tu2.get(ii))){ + log.append("Bad pair of tuples!"); + log.append(tu1 + " : " + tu2); + //neither are null, but they are still not equal. + return false; + } + } + + //all column contents are equal. + return true; + } + + /** + * Removes source and target columns from a copied version of the table. + * + * Helper method for haveSameEdgeAttributes + * + * @param t the original table + * @return a stripped copy of the original table + */ + private Table getStrippedEdgeTable(Table t) { + Table tCopy = GraphUtil.copyTable(t); + tCopy.removeColumn(Graph.DEFAULT_SOURCE_KEY); + tCopy.removeColumn(Graph.DEFAULT_TARGET_KEY); + return tCopy; + } + + private Table getStrippedNodeTable(Graph g) { + Table tCopy = GraphUtil.copyTable(g.getNodeTable()); + String nodeKeyField = g.getNodeKeyField(); + if (nodeKeyField != null) { + tCopy.removeColumn(nodeKeyField); + } + return tCopy; + } +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/IdsPreservedComparer.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/IdsPreserve... [truncated message content] |
From: <mwl...@us...> - 2007-08-15 19:55:29
|
Revision: 469 http://cishell.svn.sourceforge.net/cishell/?rev=469&view=rev Author: mwlinnem Date: 2007-08-15 12:55:26 -0700 (Wed, 15 Aug 2007) Log Message: ----------- Massive update for Converter Tester Phase II. 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/ConverterLoaderImpl.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterTesterImpl.java 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/test_files/NET Files/TestFile3.net trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile4.net trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile5.net trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile6.net trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile7.net trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile8.net trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile9.net trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/filetypes.conf 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/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/TestConfigData.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestRunner.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ReportGenerator.java Added 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/allconvs/ 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/ 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/ 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/reports/ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/AllConvsReport.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/AllTestsReport.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/ConvReport.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/FilePassReport.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/Report.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/TestReport.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/ConvResult.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/ 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/converter/ConvFilePass.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/converter/ConvFilePassFailure.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/converter/ConvFilePassSuccess.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/filepass/ 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/reportgen/results/filepass/FilePassSuccess.java Removed Paths: ------------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NWB Files/TestFile9.net trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestResult.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/filepassresults/ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ConvResultGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ConverterReportGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/OverviewReportGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/SampleResultReportGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/TestSuiteReportGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvBasedResult.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvFailureInfo.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvFilePass.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvFilePassFailure.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvFilePassSuccess.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-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java 2007-08-15 19:55:26 UTC (rev 469) @@ -11,14 +11,18 @@ 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.ConverterGraph; import org.cishell.testing.convertertester.core.tester2.ConverterTester2; -import org.cishell.testing.convertertester.core.tester2.reportgen.ConverterReportGenerator; -import org.cishell.testing.convertertester.core.tester2.reportgen.OverviewReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; -import org.cishell.testing.convertertester.core.tester2.reportgen.SampleResultReportGenerator; -import org.eclipse.swt.SWT; +import org.cishell.testing.convertertester.core.tester2.reportgen.allconvs.AllConvsReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.alltests.AllTestsReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.convgraph.GraphReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllConvsReport; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllTestsReport; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.ConvReport; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.FilePassReport; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.TestReport; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.FileDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.osgi.framework.BundleContext; @@ -36,7 +40,7 @@ private Dictionary parameters; private CIShellContext cContext; private BundleContext bContext; - private LogService logger; + private LogService log; public ConverterTesterAlgorithm(Data[] data, Dictionary parameters, CIShellContext cContext, BundleContext bContext ) { @@ -45,7 +49,7 @@ this.cContext = cContext; this.bContext = bContext; - this.logger = (LogService) cContext.getService( + this.log = (LogService) cContext.getService( LogService.class.getName()); } @@ -59,7 +63,7 @@ } Display display = PlatformUI.getWorkbench().getDisplay(); - DataUpdater dataUpdater = new DataUpdater (windows[0]); + DataUpdater dataUpdater = new DataUpdater (windows[0], this.log); if (Thread.currentThread() != display.getThread()) { display.syncExec(dataUpdater); @@ -95,76 +99,145 @@ boolean loadFileSuccess = false; IWorkbenchWindow window; ArrayList returnList = new ArrayList(); + LogService log; - DataUpdater (IWorkbenchWindow window){ + DataUpdater (IWorkbenchWindow window, LogService log){ + this.log = log; this.window = window; } public void run (){ - FileDialog dialog = new FileDialog(window.getShell(), SWT.OPEN); - if (currentDir == null) { - currentDir = new File(System.getProperty("user.dir") + File.separator + "sampledata"); - - if (!currentDir.exists()) { - currentDir = new File(System.getProperty("user.home") + File.separator + "anything"); - } else { - currentDir = new File(System.getProperty("user.dir") + File.separator + "sampledata" + File.separator + "anything"); - } - } - dialog.setFilterPath(currentDir.getPath()); - dialog.setText("Select a File: Too bad we aren't using it, haha!"); - String fileName = dialog.open(); - if (fileName == null) { - return; - } +// FileDialog dialog = new FileDialog(window.getShell(), SWT.OPEN); +// if (currentDir == null) { +// currentDir = new File(System.getProperty("user.dir") + File.separator + "sampledata"); +// +// if (!currentDir.exists()) { +// currentDir = new File(System.getProperty("user.home") + File.separator + "anything"); +// } else { +// currentDir = new File(System.getProperty("user.dir") + File.separator + "sampledata" + File.separator + "anything"); +// } +// } +// dialog.setFilterPath(currentDir.getPath()); +// dialog.setText("Select a File: Too bad we aren't using it, haha!"); +// String fileName = dialog.open(); +// if (fileName == null) { +// return; +// } try { - ConverterTester2 ct = new ConverterTester2(logger); + ConverterTester2 ct = new ConverterTester2(log); ServiceReference[] refs = getServiceReferences(); - OverviewReportGenerator overviewGen = - new OverviewReportGenerator(); - SampleResultReportGenerator sampleGen = - new SampleResultReportGenerator(10, 5); - ConverterReportGenerator convGen = - new ConverterReportGenerator(); - - ct.execute(refs, cContext, bContext, logger, - new ReportGenerator[] {overviewGen, sampleGen, convGen}); - File overviewReport = overviewGen.getReport(); - BasicData overviewReportData = - createReportData(overviewReport, "Overview"); - returnList.add(overviewReportData); + ConverterGraph converterGraph = new ConverterGraph(refs, bContext, log); + File nwbGraph = converterGraph.asNWB(); - File sampleReport = sampleGen.getReport(); - BasicData sampleReportData = - createReportData(sampleReport, "Sample Test Results"); - returnList.add(sampleReportData); + AllTestsReportGenerator allGen = new AllTestsReportGenerator(this.log); + AllConvsReportGenerator allConvGen = new AllConvsReportGenerator(this.log); + GraphReportGenerator graphGen = new GraphReportGenerator(nwbGraph, this.log); - - File convReport = convGen.getReport(); - BasicData convReportData = - createReportData(convReport, "Basic Converter Results"); - returnList.add(convReportData); + ct.execute(converterGraph, new ReportGenerator[] {allGen, allConvGen, graphGen}, cContext, bContext); + AllTestsReport allReport = allGen.getAllTestsReport(); + File allReportFile = allReport.getAllTestsReport(); + Data allReportData = createReportData(allReportFile, + allReport.getName() , null); + addReturn(allReportData); + + TestReport[] sTestReports = allReport.getSuccessfulTestReports(); + addFilePasses(sTestReports, allReportData); + + TestReport[] ppTestReports = allReport.getPartialSuccessTestReports(); + addFilePasses(ppTestReports, allReportData); + + TestReport[] fTestReports = allReport.getFailedTestReports(); + addFilePasses(fTestReports, allReportData); + + //all conv report + + AllConvsReport allConvReport = allConvGen.getAllConvsReport(); + File allConvReportFile = allConvReport.getReport(); + Data allConvReportData = createReportData(allConvReportFile, allConvReport.getName(), + null); + addReturn(allConvReportData); + + ConvReport[] convReports = allConvReport.getConverterReports(); + for (int ii = 0; ii < convReports.length; ii++) { + ConvReport convReport = convReports[ii]; + File convReportFile = convReport.getReport(); + Data convReportData = createReportData(convReportFile, convReport.getName(), allConvReportData); + addReturn(convReportData); + + TestReport[] trs = convReport.getTestReports(); + addFilePasses(trs, convReportData); + } + + File graphReportFile = graphGen.getGraphReport(); + Data graphReport = createReportData(graphReportFile, "Annotated Graph Report", null, + "file:text/nwb", DataProperty.NETWORK_TYPE); + addReturn(graphReport); + } catch (Exception e) { System.out.println("Why oh why am I catching type Exception?"); System.out.println(e); e.printStackTrace(); } } - } - - private BasicData createReportData(Object report, String label) { - BasicData reportData = new BasicData(report, "file:text/plain"); + + private void addReturn(Data report) { + this.returnList.add(report); + } + + + private void addFilePasses(TestReport[] testReports, Data allReportData) { + for (int ii = 0; ii < testReports.length; ii++) { + TestReport tr = testReports[ii]; + File testReportFile = tr.getTestReport(); + System.out.println("In algorithm, file pass name is : " + tr.getName()); + System.out.println("In algorithm FILE name is : " + testReportFile.getName()); + Data testReportData = createReportData(testReportFile, + tr.getName(), allReportData); + addReturn(testReportData); + + FilePassReport[] sFilePassReports = tr.getSuccessfulFilePassReports(); + for (int kk = 0; kk < sFilePassReports.length; kk++) { + FilePassReport fp = sFilePassReports[kk]; + File fpFile = fp.getFilePassReport(); + Data fpData = createReportData(fpFile, fp.getName(), + testReportData); + addReturn(fpData); + } + + FilePassReport[] fFilePassReports = tr.getFailedFilePassReports(); + for (int kk = 0; kk < fFilePassReports.length; kk++) { + FilePassReport fp = fFilePassReports[kk]; + File fpFile = fp.getFilePassReport(); + Data fpData = createReportData(fpFile, fp.getName(), + testReportData); + addReturn(fpData); + } + } + } + + private Data createReportData(Object report, String label, Data parent, String format, String type) { + Data reportData = new BasicData(report, format); Dictionary metadata = reportData.getMetaData(); metadata.put(DataProperty.LABEL, label); - metadata.put(DataProperty.TYPE, DataProperty.TEXT_TYPE); + metadata.put(DataProperty.TYPE, type); + if (parent != null) { + metadata.put(DataProperty.PARENT, parent); + } return reportData; - } + } + + private Data createReportData(Object report, String label, Data parent) { + return createReportData(report, label, parent, "file:text/plain", DataProperty.TEXT_TYPE); + } + } + + private ServiceReference[] getServiceReferences() { String filter = "(&("+ALGORITHM_TYPE+"="+TYPE_CONVERTER+"))";// + @@ -179,5 +252,8 @@ 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-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmFactory.java 2007-08-15 19:55:26 UTC (rev 469) @@ -32,6 +32,6 @@ return new ConverterTesterAlgorithm(data, parameters, context, bContext); } public MetaTypeProvider createParameters(Data[] data) { - return provider; + return null; } } \ No newline at end of file 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-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF 2007-08-15 19:55:26 UTC (rev 469) @@ -15,7 +15,18 @@ org.osgi.service.metatype;version="1.1.0", org.osgi.service.prefs;version="1.1.0" Require-Bundle: org.prefuse.lib -Export-Package: org.cishell.testing.convertertester.core.tester, +Export-Package: org.cishell.testing.convertertester.core.converter, + org.cishell.testing.convertertester.core.converter.graph, + org.cishell.testing.convertertester.core.service, + org.cishell.testing.convertertester.core.tester, + org.cishell.testing.convertertester.core.tester.graphcomparison, org.cishell.testing.convertertester.core.tester2, + org.cishell.testing.convertertester.core.tester2.graphcomparison, org.cishell.testing.convertertester.core.tester2.reportgen, - org.cishell.testing.convertertester.core.tester2.reportgen.results + org.cishell.testing.convertertester.core.tester2.reportgen.allconvs, + org.cishell.testing.convertertester.core.tester2.reportgen.alltests, + org.cishell.testing.convertertester.core.tester2.reportgen.convgraph, + 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 Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java 2007-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java 2007-08-15 19:55:26 UTC (rev 469) @@ -15,6 +15,7 @@ import org.osgi.framework.ServiceEvent; import org.osgi.framework.ServiceListener; import org.osgi.framework.ServiceReference; +import org.osgi.service.log.LogService; @@ -23,12 +24,14 @@ public final static String SERVICE_LIST = "SERVICE_LIST"; private Map converterList; private BundleContext bContext; + private LogService log; private CIShellContext ciContext; - public ConverterLoaderImpl(BundleContext bContext, CIShellContext cContext){ + public ConverterLoaderImpl(BundleContext bContext, CIShellContext cContext, LogService log){ this.ciContext = cContext; this.bContext = bContext; + this.log = log; converterList = new Hashtable(); @@ -51,20 +54,8 @@ ServiceReference[] refs = bContext.getServiceReferences( AlgorithmFactory.class.getName(), filter); - // ConverterGraph g = new ConverterGraph(refs); - // System.out.println(g.printComparisonConverterPaths()); - /* System.out.println(g.printComparisonConverterPaths() + "\n" + - g.getComparePaths().length + "\n" + g.printTestConverterPaths() + "\n"); - int length = 0; - for(int i = 0; i < g.getTestPaths().length; i++){ - for(int j = 0; j < g.getTestPaths()[i].length; j++){ - length++; - } - } - System.out.println(length + " " + g.getTestPaths().length); - */ - // System.out.println(g); - + ConverterGraph g = new ConverterGraph(refs, bContext, this.log); + if (refs != null) { for (int i = 0; i < refs.length; ++i) { Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterTesterImpl.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterTesterImpl.java 2007-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterTesterImpl.java 2007-08-15 19:55:26 UTC (rev 469) @@ -117,7 +117,7 @@ if (factory != null) { Algorithm alg = factory.createAlgorithm(dm, parameters, context); - System.out.println("Entering: " + refs[i].getProperty(Constants.SERVICE_PID)+ "-->"); +// System.out.println("Entering: " + refs[i].getProperty(Constants.SERVICE_PID)+ "-->"); dm = alg.execute(); if(dm == null){ throw new RuntimeException("Error after " + refs[i].getProperty(Constants.SERVICE_PID)); 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-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java 2007-08-15 19:55:26 UTC (rev 469) @@ -6,13 +6,13 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; +import org.osgi.service.log.LogService; public class ConverterGraph { prefuse.data.Graph converterGraph; @@ -21,11 +21,13 @@ Map fileExtensionCompareConverters; ServiceReference[] converters; BundleContext bContext; + private LogService log; private static final String testOutData = "prefuse.data.Graph"; - public ConverterGraph(ServiceReference[] converters, BundleContext bContext){ + public ConverterGraph(ServiceReference[] converters, BundleContext bContext, LogService log){ this.converters = converters; this.bContext = bContext; + this.log = log; inDataToAlgorithm = new HashMap();//<String, ArrayList<ServiceReference>>(); fileExtensionTestConverters = new ConcurrentHashMap();//<String, ArrayList<ConverterPath>>(); fileExtensionCompareConverters = new ConcurrentHashMap();//<String, ConverterPath>(); @@ -59,7 +61,7 @@ if(s.startsWith("file-ext")){ - ConverterPath test = new ConverterPath(this.bContext); + ConverterPath test = new ConverterPath(this.bContext, this.log); test.setInData(s); @@ -93,7 +95,6 @@ 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(); - //System.out.println(firstOutData + " " + lastInData); if(firstOutData.equals(lastInData)){ addTestPath(cp); } @@ -255,7 +256,7 @@ return this.fileExtensionTestConverters; } - public File asNWB(){ + public File asNWB() { File f = getTempFile(); Map nodes = assembleNodesSet(); TreeSet output = assembleEdges(nodes); 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-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java 2007-08-15 19:55:26 UTC (rev 469) @@ -7,18 +7,25 @@ import org.cishell.framework.algorithm.AlgorithmProperty; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; +import org.osgi.service.log.LogService; public class ConverterPath implements AlgorithmProperty { - private String in_data; + + private BundleContext bContext; + private LogService log; + private String in_data = null; private String out_data = null; + private ArrayList path; - private BundleContext bContext; - boolean algPathCached = false; - ArrayList algPath; + private boolean algPathCached = false; + private ArrayList algPath; - public ConverterPath(BundleContext bContext){ + + public ConverterPath(BundleContext bContext, LogService log){ this.bContext = bContext; + this.log = log; + path = new ArrayList(); } @@ -69,6 +76,17 @@ return this.out_data; } + public String getAcceptedFileFormat() { + if (size() > 0) { + return (String) getRef(0).getProperty(AlgorithmProperty.OUT_DATA); + } else { + this.log.log(LogService.LOG_ERROR, "Converter Path cannot " + + "determine accepted file format if there are no " + + "converters inside it. Returning null String."); + return ""; + } + } + public List getPath(){ return this.path; @@ -138,7 +156,7 @@ List thisConvPathCopy = new ArrayList(thisConvPath); thisConvPathCopy.addAll(otherConvPath); - ConverterPath combinedPath = new ConverterPath(this.bContext); + ConverterPath combinedPath = new ConverterPath(this.bContext, this.log); List combinedConvPath = thisConvPathCopy; for (int ii = 0; ii < combinedConvPath.size(); ii++) { @@ -154,6 +172,10 @@ return this.path.size(); } + + public String getConverterName(int index) { + return (String) getRef(index).getProperty("service.pid"); + } private void cacheAlgPath() { @@ -173,5 +195,4 @@ this.algPathCached = false; } - } Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile3.net =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile3.net 2007-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile3.net 2007-08-15 19:55:26 UTC (rev 469) @@ -11,7 +11,6 @@ 550 "ph" 551 "SMO" 552 "ci" -//I thought I would add a comment here. 553 "CI" 554 "CIA" 555 "CIR" Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile4.net =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile4.net 2007-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile4.net 2007-08-15 19:55:26 UTC (rev 469) @@ -11,7 +11,6 @@ 550 "ph" 551 "SMO" 552 "ci" -//I thought I would add a comment here. 553 "CI" 554 "CIA" 555 "CIR" Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile5.net =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile5.net 2007-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile5.net 2007-08-15 19:55:26 UTC (rev 469) @@ -11,7 +11,6 @@ 550 "ph" 551 "SMO" 552 "ci" -//I thought I would add a comment here. 553 "CI" 554 "CIA" 555 "CIR" Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile6.net =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile6.net 2007-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile6.net 2007-08-15 19:55:26 UTC (rev 469) @@ -1,5 +1,5 @@ *Vertices -541 "SLP Friend" ellipse 0.987 0.5 +541 "SLP Friend" 0.987 0.5 ellipse 542 "wg" 543 "WG" 544 "en" @@ -11,7 +11,6 @@ 550 "ph" 551 "SMO" 552 "ci" -//I thought I would add a comment here. 553 "CI" 554 "CIA" 555 "CIR" Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile7.net =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile7.net 2007-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile7.net 2007-08-15 19:55:26 UTC (rev 469) @@ -6,12 +6,11 @@ 545 "EN" 546 "hh" 547 "HH" -548 "ptc" 0.987 ellipse 0.5 0.7 +548 "ptc" 0.987 0.5 0.7 549 "PTC" 550 "ph" 551 "SMO" 552 "ci" -//I thought I would add a comment here. 553 "CI" 554 "CIA" 555 "CIR" Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile8.net =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile8.net 2007-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile8.net 2007-08-15 19:55:26 UTC (rev 469) @@ -5,7 +5,7 @@ 544 "en" 545 "EN" 546 "hh" -547 "HH" 0.987 0.5 0.5 box r 3.5 x_fact 7 s_size 1 lc red font "Arial Black" lphi 5 lr 3 +547 "HH" 0.987 0.5 0.5 box r 3.5 x_fact 7 s_size 1 lc red lphi 5 lr 3 549 "PTC" 550 "ph" 551 "SMO" Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile9.net =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile9.net 2007-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NET Files/TestFile9.net 2007-08-15 19:55:26 UTC (rev 469) @@ -5,11 +5,10 @@ 544 "en" 545 "EN" 546 "hh" -547 "HH" 0.987 0.5 0.5 box r 3.5 x_fact 7 s_size 1 lc red font "Arial Black" lphi 5 lr 3 +547 "HH" 0.987 0.5 0.5 box r 3.5 x_fact 7 s_size 1 lc red lphi 5 lr 3 549 "PTC" 550 "ph" 551 "SMO" -//I thought I would add a comment here. 552 "ci" 553 "CI" 554 "CIA" @@ -35,7 +34,6 @@ 574 "en" 575 "EN" 576 "hh" -577 578 "ptc" 579 "PTC" 580 "ph" Deleted: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NWB Files/TestFile9.net =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NWB Files/TestFile9.net 2007-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/NWB Files/TestFile9.net 2007-08-15 19:55:26 UTC (rev 469) @@ -1,11 +0,0 @@ -*Vertices 6 - 1 "Ada" 0.1646 0.2144 0.5000 - 2 "Cora" 0.0481 0.3869 0.5000 - 3 "Louise" 0.3472 0.1913 0.5000 - 4 "Jean" 0.1063 0.5935 0.5000 - 5 "Helen" 0.2892 0.6688 0.5000 - 6 "Martha" 0.4630 0.5179 0.5000 -*Arcs -1 2 -2 5 2.5 -4 5 Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/filetypes.conf =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/filetypes.conf 2007-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/filetypes.conf 2007-08-15 19:55:26 UTC (rev 469) @@ -1,6 +1,6 @@ file:text/edge=Edge Files file:text/graphml+xml=GraphML Files -file:application/pajek=NET Files +file:application/pajeknet=NET Files file:text/nwb=NWB Files file:text/treeml+xml=TreeML Files -file:text/xgmml_xml=XGMML Files +file:text/xgmml+xml=XGMML Files 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-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/ConverterTester.java 2007-08-15 19:55:26 UTC (rev 469) @@ -18,6 +18,7 @@ import org.cishell.testing.convertertester.core.tester.graphcomparison.DefaultGraphComparer; import org.cishell.testing.convertertester.core.tester.graphcomparison.GraphComparer; import org.osgi.framework.BundleContext; +import org.osgi.service.log.LogService; import prefuse.data.Graph; @@ -27,6 +28,7 @@ private ConverterLoaderImpl cli; private Converter comparisonConverters; private GraphComparer dgc; + private LogService log; //private Map<String, Exception> fileErrors; private static final String tempDir = "converterTesterTemp"; private File temporaryStorage; @@ -34,9 +36,10 @@ //string, comparisonresult private Map results; - public ConverterTester(BundleContext b, CIShellContext c){ + public ConverterTester(BundleContext b, CIShellContext c, LogService log){ this.cContext = c; - cli = new ConverterLoaderImpl(b, this.cContext); + this.log = log; + cli = new ConverterLoaderImpl(b, this.cContext, this.log); cfp = new ConfigurationFileParser(); } @@ -50,7 +53,7 @@ public ConverterTester(BundleContext b, CIShellContext c, File configFile) throws Exception{ cContext = c; - cli = new ConverterLoaderImpl(b, cContext); + cli = new ConverterLoaderImpl(b, cContext, this.log); cfp = new ConfigurationFileParser(configFile); testConverters = cli.getConverter(cfp.getTestConverters()); comparisonConverters = cli.getConverter(cfp.getComparisonConverters()); @@ -60,7 +63,7 @@ public ConverterTester(BundleContext b, CIShellContext c, String configFileName) throws Exception { cContext = c; - cli = new ConverterLoaderImpl(b,cContext); + cli = new ConverterLoaderImpl(b,cContext, this.log); cfp = new ConfigurationFileParser(new File(configFileName)); testConverters = cli.getConverter(cfp.getTestConverters()); comparisonConverters = cli.getConverter(cfp.getComparisonConverters()); 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-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConverterTester2.java 2007-08-15 19:55:26 UTC (rev 469) @@ -2,33 +2,31 @@ import java.io.File; import java.util.ArrayList; +import java.util.Dictionary; +import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.Set; import org.cishell.framework.CIShellContext; -import org.cishell.framework.algorithm.AlgorithmFactory; import org.cishell.framework.algorithm.AlgorithmProperty; 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.ConverterGraph; import org.cishell.testing.convertertester.core.converter.graph.ConverterPath; -import org.cishell.testing.convertertester.core.tester2.filepassresults.FilePassResult; 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.ReportGenerator; +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; /** - * Test Suites are arrays of test paths, where each test path starts - * from the same file format. - * - * Compare Paths are paths of converters that convert from the original file - * format to the in-memory comparison format. For each test suite there - * is a single corresponding compare path. - * * @author mwlinnem * */ @@ -39,7 +37,6 @@ private TestFileKeeper testFileKeeper; private TestRunner testRunner; - public ConverterTester2(LogService log) { this.log = log; this.testFileKeeper = @@ -47,71 +44,80 @@ this.testRunner = new DefaultTestRunner(log); } - /** * 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 the converters to be tested + * @param reportGenerators process the test results. * @param cContext the CIShell Context * @param bContext the Bundle Context - * @param log The log written to should an error occur (other than the - * errors resulting from the converters, which are included in the test - * results) - * @param reportGenerators process the test results. */ - public void execute(ServiceReference[] converterRefs, + public void execute( + ConverterGraph converterGraph, + ReportGenerator[] reportGenerators, CIShellContext cContext, - BundleContext bContext, - LogService log, - ReportGenerator[] reportGenerators) { + BundleContext bContext) { - this.log = log; + //run the tests - //generate test paths + TestResult[] rawResults = + runAllTests(converterGraph, cContext, bContext); + AllTestsResult allTestsResult = new AllTestsResult(rawResults); - ConverterGraph converterGraph = new ConverterGraph(converterRefs); + //feed test results to the report generators - ConverterPath[][] testSuites = converterGraph.getTestPaths(); - ConverterPath[] comparePaths = converterGraph.getComparePaths(); - - //run tests on test paths - - TestResult[] results = runTests(testSuites, comparePaths, - cContext, bContext); - - //generate reports based on test results - for (int ii = 0; ii < reportGenerators.length; ii++) { ReportGenerator reportGenerator = reportGenerators[ii]; - reportGenerator.generateReport(results); + reportGenerator.generateReport(allTestsResult); } } - - public TestResult[] runTests(ConverterPath[][] testSuites, - ConverterPath[] comparePaths, CIShellContext cContext, - BundleContext bContext) { + public TestResult[] runAllTests(ConverterGraph convGraph, + CIShellContext cContext, BundleContext bContext) { + + + Map fileFormatToTestConvs = convGraph.getTestMap(); + Map fileFormatToCompareConvs = convGraph.getCompareMap(); + List testResults = new ArrayList(); - for (int ii = 0; ii < testSuites.length; ii++) { - ConverterPath[] testSuite = testSuites[ii]; - ConverterPath testSuiteComparePath = comparePaths[ii]; + Set fileFormats = fileFormatToTestConvs.keySet(); + + /* + * for each file format, get the corresponding test converter paths + * and comparison converter path. + */ + + Iterator iter = fileFormats.iterator(); + while(iter.hasNext()) { + String fileFormat = (String) iter.next(); - for (int jj = 0; jj < testSuite.length; jj++) { - ConverterPath testPath = testSuite[jj]; + ArrayList testConvList = + (ArrayList) fileFormatToTestConvs.get(fileFormat); + + ConverterPath[] testConvs = + (ConverterPath[]) testConvList.toArray(new ConverterPath[0]); + + ConverterPath compareConv = + (ConverterPath) fileFormatToCompareConvs.get(fileFormat); + + /* + * 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++) { + ConverterPath testConv = testConvs[kk]; - TestResult testResult = runATest(testPath, - testSuiteComparePath, cContext, bContext); + TestResult testResult = + runATest(testConv, compareConv, cContext, bContext); if (testResult != null) { testResults.add(testResult); } } - } return (TestResult[]) testResults.toArray(new TestResult[0]); @@ -119,57 +125,34 @@ private TestResult runATest(ConverterPath testConvs, - ConverterPath comparisonConvs, CIShellContext cContext, + ConverterPath compareConvs, CIShellContext cContext, BundleContext bContext) { - ServiceReference[] testConvRefs = testConvs.getPathAsArray(); - ServiceReference[] compareConvRefs = comparisonConvs.getPathAsArray(); + //get test file data corresponding to the format these converters accept. - AlgorithmFactory[] testConvAlgs = extractAlgorithms( - testConvRefs, bContext); - AlgorithmFactory[] compareConvAlgs = extractAlgorithms( - compareConvRefs, bContext); - - if (testConvRefs.length <= 0) { - System.out.println("Must have at least one test converter.."); - return null; - } - - //get test files corresponding to the format these converters accept. - - String fileFormat = - (String) testConvRefs[0].getProperty(AlgorithmProperty.OUT_DATA); + String fileFormat = testConvs.getAcceptedFileFormat(); String[] testFilePaths = testFileKeeper.getTestFilePaths(fileFormat); - Data[][] fileData = wrapInData(testFilePaths, fileFormat); + Data[][] testFileData = wrapInData(testFilePaths, fileFormat); //determine how we will compare the graphs - boolean areLossy = areLossy(testConvRefs) && areLossy(compareConvRefs); - boolean preserveIds = false; //TODO: determine this somehow - NewGraphComparer comparer = getComparer(areLossy, preserveIds); + boolean isLossy = testConvs.isLossy() && compareConvs.isLossy(); + boolean preserveIDs = testConvs.preservesIDs() && + compareConvs.preservesIDs(); + + NewGraphComparer comparer = getComparer(isLossy, preserveIDs); //pack all the data relevant to the test into a single object. - TestConfigData testData = new TestConfigData(comparer, testConvAlgs, - compareConvAlgs, cContext, fileData); + TestConfigData testBasicData = new TestConfigData(comparer, testConvs, + compareConvs, cContext, testFileData); //run the test - FilePassResult[] results = this.testRunner.runTest(testData); + FilePassResult[] results = this.testRunner.runTest(testBasicData); //return the results of the test - return new TestResult(results); + return new TestResult(results, testConvs, compareConvs); } - - - private AlgorithmFactory[] extractAlgorithms(ServiceReference[] convRefs, - BundleContext bContext) { - AlgorithmFactory[] results = new AlgorithmFactory[convRefs.length]; - for (int ii = 0; ii < convRefs.length; ii++) { - results[ii] = (AlgorithmFactory) bContext.getService(convRefs[ii]); - } - return results; - } - - + private Data[][] wrapInData(String[] testFilePaths, String format) { Data[][] results = new Data[testFilePaths.length][1]; @@ -178,26 +161,14 @@ results[ii] = new Data[] {new BasicData(new File(filePath), format)}; + + Dictionary metadata = results[ii][0].getMetaData(); + metadata.put(DataProperty.LABEL, filePath); } return results; } - - private boolean areLossy(ServiceReference[] refs) { - - String lossiness = LOSSLESS; - for (int i=0; i < refs.length; i++) { - if (LOSSY.equals(refs[i].getProperty(CONVERSION))) { - lossiness = LOSSY; - } - } - - boolean result = lossiness.equals(LOSSY); - return result; - } - - private NewGraphComparer getComparer(boolean areLossy, boolean idsPreserved) { @@ -210,5 +181,4 @@ } } - } 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-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java 2007-08-15 19:55:26 UTC (rev 469) @@ -13,13 +13,14 @@ 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.ConverterPath; import org.cishell.testing.convertertester.core.tester.graphcomparison.ComparisonResult; -import org.cishell.testing.convertertester.core.tester2.filepassresults.ComparePhaseFailure; -import org.cishell.testing.convertertester.core.tester2.filepassresults.ConvertPhaseFailure; -import org.cishell.testing.convertertester.core.tester2.filepassresults.FilePassResult; -import org.cishell.testing.convertertester.core.tester2.filepassresults.FilePassSuccess; import org.cishell.testing.convertertester.core.tester2.graphcomparison.NewGraphComparer; -import org.cishell.testing.convertertester.core.tester2.reportgen.results.ConvFailureInfo; +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.FilePassSuccess; import org.osgi.service.log.LogService; import prefuse.data.Graph; @@ -35,14 +36,12 @@ public FilePassResult[] runTest(TestConfigData testData) { Data[][] testFileData = testData.getTestFileData(); - AlgorithmFactory[] testConverters = testData.getTestConverters(); - AlgorithmFactory[] comparisonConverters = testData + ConverterPath testConverters = testData.getTestConverters(); + ConverterPath comparisonConverters = testData .getComparisonConverters(); + List testResults = new ArrayList(); - // list of FilePassResult - final List testResults = new ArrayList(); - for (int ii = 0; ii < testFileData.length; ii++) { Data[] originalFileData = testFileData[ii]; @@ -53,8 +52,7 @@ if (!testPhaseResult.succeeded()) { ConvertPhaseFailure failure = new ConvertPhaseFailure( - originalFileData, testConverters, comparisonConverters, - testPhaseResult.getFailInfo(), + originalFileData, testPhaseResult.getFailInfo(), ConvertPhaseFailure.TEST_PHASE); testResults.add(failure); continue; @@ -68,7 +66,7 @@ if (!comparisonPhaseResult1.succeeded()) { ConvertPhaseFailure failure = new ConvertPhaseFailure( - originalFileData, testConverters, comparisonConverters, + originalFileData, comparisonPhaseResult1.getFailInfo(), ConvertPhaseFailure.TEST_PHASE); testResults.add(failure); @@ -81,7 +79,7 @@ if (!comparisonPhaseResult2.succeeded()) { ConvertPhaseFailure failure = new ConvertPhaseFailure( - originalFileData, testConverters, comparisonConverters, + originalFileData, comparisonPhaseResult2.getFailInfo(), ConvertPhaseFailure.COMPARISON_PHASE); testResults.add(failure); @@ -101,14 +99,13 @@ if (!graphComparisonPhaseResult.comparisonSucceeded()) { String explanation = graphComparisonPhaseResult.getLog(); ComparePhaseFailure failure = new ComparePhaseFailure( - originalFileData, testConverters, comparisonConverters, + originalFileData, explanation); testResults.add(failure); continue; } - FilePassSuccess success = new FilePassSuccess(originalFileData, - testConverters, comparisonConverters); + FilePassSuccess success = new FilePassSuccess(originalFileData); testResults.add(success); } @@ -118,38 +115,45 @@ } private ConvertResult convert(Data[] startData, - AlgorithmFactory[] converters, TestConfigData testData) { + ConverterPath converters, TestConfigData testData) { - // validator takes a string file path, all others just take files or - // graphs or whatever); Data[] currentData = getFilePathData(startData); - - AlgorithmFactory currentConverter = converters[0]; + AlgorithmFactory[] converterAlgs = converters.getPathAsAlgorithms(); + + AlgorithmFactory currentConverterAlg = converterAlgs[0]; try { - for (int ii = 0; ii < converters.length; ii++) { - currentConverter = converters[ii]; - Algorithm currentAlgorithm = currentConverter.createAlgorithm( - currentData, new Hashtable(), testData.getContext()); + for (int ii = 0; ii < converterAlgs.length; ii++) { + currentConverterAlg = converterAlgs[ii]; + Algorithm currentAlgorithm = + currentConverterAlg.createAlgorithm(currentData, + new Hashtable(), testData.getContext()); currentData = currentAlgorithm.execute(); if (currentData == null) { + String converterName = converters.getConverterName(ii); ConvFailureInfo failInfo = new ConvFailureInfo( - "null result data", currentConverter); + "Result data is null. " + + "Check NWB GUI Console for specific error.", + converterName); ConvertResult result = new ConvertResult(failInfo); return result; } - BasicData currentDataImpl = (BasicData) currentData[0]; + Data currentDataImpl = (Data) currentData[0]; if (currentDataImpl.getData() == null) { + String converterName = converters.getConverterName(ii); ConvFailureInfo failInfo = new ConvFailureInfo( - "null result data contents", currentConverter); + "Contents of result data is null. " + + "Check NWB GUI Console for specific error.", + converterName); ConvertResult result = new ConvertResult(failInfo); return result; } } } catch (Throwable t) { ConvFailureInfo failInfo = new ConvFailureInfo(t.toString() - + getStackTrace(t), currentConverter); + + getStackTrace(t), + currentConverterAlg.getClass().toString()); ConvertResult result = new ConvertResult(failInfo); return result; } @@ -201,12 +205,12 @@ } private Data[] getFilePathData(Data[] fileData) { - BasicData basicData = (BasicData) fileData[0]; - String format = basicData.getFormat(); - File actualFile = (File) basicData.getData(); + Data Data = (Data) fileData[0]; + String format = Data.getFormat(); + File actualFile = (File) Data.getData(); try { String filePath = actualFile.getCanonicalPath(); - BasicData result = new BasicData(filePath, format); + Data result = new BasicData(filePath, format); return new Data[] { result }; } catch (IOException e) { this.log.log(LogService.LOG_ERROR, "Could not get file path " + Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestConfigData.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestConfigData.java 2007-08-10 17:32:32 UTC (rev 468) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestConfigData.java 2007-08-15 19:55:26 UTC (rev 469) @@ -1,21 +1,21 @@ package org.cishell.testing.convertertester.core.tester2; import org.cishell.framework.CIShellContext; -import org.cishell.framework.algorithm.AlgorithmFactory; import org.cishell.framework.data.Data; +import org.cishell.testing.convertertester.core.converter.graph.ConverterPath; import org.cishell.testing.convertertester.core.tester2.graphcomparison.NewGraphComparer; public class TestConfigData { private NewGraphComparer comparer; - private AlgorithmFactory[] testConverters; - private AlgorithmFactory[] comparisonConverters; + priva... [truncated message content] |
From: <mwl...@us...> - 2007-08-15 21:16:04
|
Revision: 472 http://cishell.svn.sourceforge.net/cishell/?rev=472&view=rev Author: mwlinnem Date: 2007-08-15 14:16:01 -0700 (Wed, 15 Aug 2007) Log Message: ----------- Reports no longer dumped into users home directory. Removed platform specific file separators. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.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 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-08-15 20:29:01 UTC (rev 471) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java 2007-08-15 21:16:01 UTC (rev 472) @@ -51,10 +51,18 @@ this.log = (LogService) cContext.getService( LogService.class.getName()); + } public Data[] execute() { + this.log.log(LogService.LOG_WARNING, "-------NOTICE-------" + "\n" + + "The Converter Tester will take " + + "approximately 30 seconds to run all the tests, and around " + + "20 seconds to display all the results. Thank you for " + + "waiting :)" + "\n" + + "-----END NOTICE-----"); + Data[] returnDM; final IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); @@ -107,8 +115,6 @@ } public void run (){ - -// FileDialog dialog = new FileDialog(window.getShell(), SWT.OPEN); // if (currentDir == null) { // currentDir = new File(System.getProperty("user.dir") + File.separator + "sampledata"); // Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-08-15 20:29:01 UTC (rev 471) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-08-15 21:16:01 UTC (rev 472) @@ -16,9 +16,16 @@ public class TestFileKeeper { //TODO: How should we expose this to the user? - public static final String DEFAULT_ROOT_DIR = "workspace/org.cishell." - + "testing.convertertester.core.new/src/org/cishell/testing/" - + "convertertester/core/test_files/"; + static { + String fs = File.separator; + + DEFAULT_ROOT_DIR = "workspace" + fs + "org.cishell." + + "testing.convertertester.core.new" + fs + "src" + fs + + "org" + fs + "cishell" + fs + "testing" + fs + + "convertertester" + fs + "core" + fs + "test_files" + fs; + } + + public static final String DEFAULT_ROOT_DIR; public static final String CONF_FILE_NAME = "filetypes.conf"; 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-15 20:29:01 UTC (rev 471) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ReportGenerator.java 2007-08-15 21:16:01 UTC (rev 472) @@ -1,9 +1,14 @@ package org.cishell.testing.convertertester.core.tester2.reportgen; +import java.io.File; + import org.cishell.testing.convertertester.core.tester2.reportgen.results.AllTestsResult; public interface ReportGenerator { + public static final String FS = File.separator; + public static final String TEMP_DIR = "tmp" + FS; + public void generateReport(AllTestsResult atr); } 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-15 20:29:01 UTC (rev 471) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allconvs/AllConvsReportGenerator.java 2007-08-15 21:16:01 UTC (rev 472) @@ -36,7 +36,8 @@ FileOutputStream reportOutStream = null; try { - File reportFile = new File(TEMP_FILE_PATH); + new File(TEMP_DIR); + File reportFile = new File(TEMP_DIR + TEMP_FILE_PATH); reportOutStream = new FileOutputStream(reportFile); PrintStream report = new PrintStream(reportOutStream); 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-08-15 20:29:01 UTC (rev 471) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allconvs/ConvReportSubGenerator.java 2007-08-15 21:16:01 UTC (rev 472) @@ -7,11 +7,10 @@ import java.util.ArrayList; import java.util.List; +import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.ConvReport; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.TestReport; import org.cishell.testing.convertertester.core.tester2.reportgen.results.ConvResult; -import org.cishell.testing.convertertester.core.tester2.reportgen.results.FilePassResult; -import org.cishell.testing.convertertester.core.tester2.reportgen.results.TestResult; import org.osgi.framework.ServiceReference; public class ConvReportSubGenerator { @@ -25,7 +24,7 @@ ConvResult convResult = cr; ServiceReference conv = convResult.getRef(); - File reportFile = new File(cr.getName()); + File reportFile = new File(ReportGenerator.TEMP_DIR + cr.getName()); reportOutStream = new FileOutputStream(reportFile); PrintStream report = new PrintStream(reportOutStream); Modified: 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/AllTestsReportGenerator.java 2007-08-15 20:29:01 UTC (rev 471) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/AllTestsReportGenerator.java 2007-08-15 21:16:01 UTC (rev 472) @@ -27,12 +27,15 @@ public AllTestsReportGenerator(LogService log) { this.log = log; this.testResultSubGen = new TestReportSubGenerator(); + + //TODO: Make this not a huge hack + new File(TEMP_DIR).mkdir(); } public void generateReport(AllTestsResult atr) { FileOutputStream reportOutStream = null; try { - File reportFile = new File(TEMP_FILE_PATH); + File reportFile = new File(TEMP_DIR + TEMP_FILE_PATH); reportOutStream = new FileOutputStream(reportFile); PrintStream report = new PrintStream(reportOutStream); Modified: 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/FilePassSubGenerator.java 2007-08-15 20:29:01 UTC (rev 471) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/FilePassSubGenerator.java 2007-08-15 21:16:01 UTC (rev 472) @@ -5,9 +5,9 @@ import java.io.IOException; import java.io.PrintStream; +import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.FilePassReport; import org.cishell.testing.convertertester.core.tester2.reportgen.results.FilePassResult; -import org.cishell.testing.convertertester.core.tester2.reportgen.results.TestResult; public class FilePassSubGenerator { @@ -17,7 +17,7 @@ public void generateSubreport(FilePassResult fpr) { FileOutputStream reportOutStream = null; try { - File reportFile = new File(fpr.getName()); + File reportFile = new File(ReportGenerator.TEMP_DIR + fpr.getName()); reportOutStream = new FileOutputStream(reportFile); PrintStream report = new PrintStream(reportOutStream); Modified: 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/alltests/TestReportSubGenerator.java 2007-08-15 20:29:01 UTC (rev 471) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/TestReportSubGenerator.java 2007-08-15 21:16:01 UTC (rev 472) @@ -8,6 +8,7 @@ import java.util.List; import org.cishell.testing.convertertester.core.converter.graph.ConverterPath; +import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.FilePassReport; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.TestReport; import org.cishell.testing.convertertester.core.tester2.reportgen.results.FilePassResult; @@ -27,7 +28,7 @@ public void generateSubreport(TestResult tr) { FileOutputStream reportOutStream = null; try { - File reportFile = new File(tr.getName()); + File reportFile = new File(ReportGenerator.TEMP_DIR + tr.getName()); reportOutStream = new FileOutputStream(reportFile); PrintStream report = new PrintStream(reportOutStream); @@ -144,6 +145,6 @@ private void namePass(String prefix, FilePassResult fp, TestResult parent, int index) { - fp.setName(prefix + " Pass " + index + " of " + fp); + fp.setName(prefix + " Pass " + index + " of " + parent.getName() + " . "); } } Modified: 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/convgraph/GraphReportGenerator.java 2007-08-15 20:29:01 UTC (rev 471) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/convgraph/GraphReportGenerator.java 2007-08-15 21:16:01 UTC (rev 472) @@ -19,7 +19,7 @@ private ConvResultMaker convGen = new ConvResultMaker(); private LogService log; - private File annotatedNWBGraph = new File("annotated-converter-graph.nwb"); + private File annotatedNWBGraph = new File(TEMP_DIR + "annotated-converter-graph.nwb"); private String NODE_LINE = "^\\d+? \".*?\"$"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2007-08-15 22:45:12
|
Revision: 473 http://cishell.svn.sourceforge.net/cishell/?rev=473&view=rev Author: mwlinnem Date: 2007-08-15 15:44:39 -0700 (Wed, 15 Aug 2007) Log Message: ----------- Added readme report that explains some basic stuff about all the reports. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ConvResultMaker.java Added Paths: ----------- 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/tester2/reportgen/readme/ 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/reports/ReadMeReport.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-08-15 21:16:01 UTC (rev 472) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java 2007-08-15 22:44:39 UTC (rev 473) @@ -17,10 +17,12 @@ import org.cishell.testing.convertertester.core.tester2.reportgen.allconvs.AllConvsReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.alltests.AllTestsReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.convgraph.GraphReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.readme.ReadMeReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllConvsReport; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllTestsReport; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.ConvReport; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.FilePassReport; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.ReadMeReport; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.TestReport; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbenchWindow; @@ -142,9 +144,18 @@ AllTestsReportGenerator allGen = new AllTestsReportGenerator(this.log); AllConvsReportGenerator allConvGen = new AllConvsReportGenerator(this.log); GraphReportGenerator graphGen = new GraphReportGenerator(nwbGraph, this.log); + ReadMeReportGenerator readmeGen = new ReadMeReportGenerator(); - ct.execute(converterGraph, new ReportGenerator[] {allGen, allConvGen, graphGen}, cContext, bContext); + ct.execute(converterGraph, new ReportGenerator[] {allGen, allConvGen, graphGen, readmeGen}, cContext, bContext); + // readme report + ReadMeReport readmeReport = readmeGen.getReadMe(); + File readmeFile = readmeReport.getReportFile(); + Data readMeData = createReportData(readmeFile, + readmeReport.getName(), null); + addReturn(readMeData); + + //all tests report AllTestsReport allReport = allGen.getAllTestsReport(); File allReportFile = allReport.getAllTestsReport(); Data allReportData = createReportData(allReportFile, @@ -184,6 +195,8 @@ "file:text/nwb", DataProperty.NETWORK_TYPE); addReturn(graphReport); + + } catch (Exception e) { System.out.println("Why oh why am I catching type Exception?"); System.out.println(e); 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-08-15 21:16:01 UTC (rev 472) +++ trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF 2007-08-15 22:44:39 UTC (rev 473) @@ -26,6 +26,7 @@ org.cishell.testing.convertertester.core.tester2.reportgen.allconvs, org.cishell.testing.convertertester.core.tester2.reportgen.alltests, org.cishell.testing.convertertester.core.tester2.reportgen.convgraph, + org.cishell.testing.convertertester.core.tester2.reportgen.readme, 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, Added: 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 (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/ReportREADME.txt 2007-08-15 22:44:39 UTC (rev 473) @@ -0,0 +1,78 @@ +So I used to have a pretty long readme but it was +accidentally deleted, so now I'll just cover the basics +until I get motivated to do this thing all over again. + +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. +It is hierarchically structured, with a general +overview at the root, which has each of the +test reports hanging from it, which in turn +have each of their file pass reports hanging +from them. + +Each test tests a single conversion path by +running a bunch of files through it then +comparing the original file to the resulting +file (just like how we used to do it with +the configuration files). + +Each file pass report represents the +results from a single test file being +passed through the test's converters. +File pass reports hang from their +corresponding test reports. + +ALL CONVERTERS REPORT + +All Converters Report provides results +from the point of view of each converter. +It has a general overview at the root, +with details about each converter +hanging from it. + +The two most interesting pieces of information +generated by this report are whether or +not a converter is "Trusted" and its +"Chance of Flaw" of "Chance Correct". +Converters are said to be trusted if they +are involved in a test where all the file passes +are successful. Chance correct is calculated +using an interesting algorithm involving trust. +For each failed file pass it looks at all the +converters involved, removes those that are +trusted, and says that the resulting converters +each have an equal likelihood of being at fault. +If a converter is not trusted, the more +failures it is involved in the more likely it +is to be broken, increasing its "Chance of Flaw". + +ANNOTATED GRAPH REPORT + +This is basically the converter graph annotated +with converter test results, allowing us to +visualize how likely to be broken each converter +is. Each converter has attributes for how likely +it is to be correct, and whether or not it is +trusted. + + Modified: 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-15 21:16:01 UTC (rev 472) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ConvResultMaker.java 2007-08-15 22:44:39 UTC (rev 473) @@ -106,7 +106,7 @@ if (trusted && fprs.length > 0) { //mark all converters involved as trusted. - ConverterPath allConvs = tr.getAllConverters(); + ConverterPath allConvs = tr.getTestConverters(); for (int kk = 0; kk < allConvs.size(); kk++) { ConvResult ctr = getResult(rh, allConvs.getRef(kk)); ctr.setTrusted(true); Added: 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/readme/ReadMeReportGenerator.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/readme/ReadMeReportGenerator.java 2007-08-15 22:44:39 UTC (rev 473) @@ -0,0 +1,29 @@ +package org.cishell.testing.convertertester.core.tester2.reportgen.readme; + +import java.io.File; + +import org.cishell.testing.convertertester.core.tester2.TestFileKeeper; +import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.ReadMeReport; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.Report; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.AllTestsResult; + +public class ReadMeReportGenerator implements ReportGenerator { + + private ReadMeReport readme; + + public void generateReport(AllTestsResult atr) { + //TODO: TOTAL HACK, CHANCE AS SOON AS POSSIBLE + String readmePath = (System.getProperty("user.home") + "/" + + TestFileKeeper.DEFAULT_ROOT_DIR + "ReportREADME.txt"); + System.out.println("ReadMe path is: " + readmePath); + File readmeFile = new File(readmePath); + + this.readme = new ReadMeReport(readmeFile, "README", ""); + } + + public ReadMeReport getReadMe() { + return this.readme; + } + +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/ReadMeReport.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/ReadMeReport.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/ReadMeReport.java 2007-08-15 22:44:39 UTC (rev 473) @@ -0,0 +1,29 @@ +package org.cishell.testing.convertertester.core.tester2.reportgen.reports; + +import java.io.File; + + +public class ReadMeReport implements Report { + + private File file; + private String name; + private String summary; + + public ReadMeReport(File file, String name, String summary) { + this.file = file; + this.name = name; + this.summary = summary; + } + public String getName() { + return this.name; + } + + public String getShortSummary() { + return this.summary; + } + + public File getReportFile() { + return this.file; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2007-08-30 20:39:40
|
Revision: 504 http://cishell.svn.sourceforge.net/cishell/?rev=504&view=rev Author: mwlinnem Date: 2007-08-30 13:39:35 -0700 (Thu, 30 Aug 2007) Log Message: ----------- Added report that simply outputs the unmodified converter graph. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConverterTester2.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/readme/ReadMeReportGenerator.java Removed Paths: ------------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterNode.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-08-30 20:38:58 UTC (rev 503) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java 2007-08-30 20:39:35 UTC (rev 504) @@ -11,11 +11,11 @@ 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.ConverterGraph; import org.cishell.testing.convertertester.core.tester2.ConverterTester2; import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.allconvs.AllConvsReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.alltests.AllTestsReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.convgraph.AnnotatedGraphReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.convgraph.GraphReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.readme.ReadMeReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllConvsReport; @@ -35,7 +35,8 @@ //TODO: Maybe let the user specify which converters he/she wants to test, or other things //TODO: Make it progress-trackable -public class ConverterTesterAlgorithm implements Algorithm, AlgorithmProperty { +public class ConverterTesterAlgorithm implements Algorithm, + AlgorithmProperty { private CIShellContext cContext; private BundleContext bContext; @@ -62,7 +63,8 @@ Data[] returnDM; - final IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); + final IWorkbenchWindow[] windows = + PlatformUI.getWorkbench().getWorkbenchWindows(); if (windows.length == 0) { return null; } @@ -111,16 +113,26 @@ //initialize all the report generators - AllTestsReportGenerator allGen = new AllTestsReportGenerator(this.log); - AllConvsReportGenerator allConvGen = new AllConvsReportGenerator(this.log); - GraphReportGenerator graphGen = new GraphReportGenerator(this.log); - ReadMeReportGenerator readmeGen = new ReadMeReportGenerator(); + AllTestsReportGenerator allGen = + new AllTestsReportGenerator(this.log); + AllConvsReportGenerator allConvGen = + new AllConvsReportGenerator(this.log); + GraphReportGenerator origGraphGen = + new GraphReportGenerator(this.log); + AnnotatedGraphReportGenerator graphGen = + new AnnotatedGraphReportGenerator(this.log); + ReadMeReportGenerator readmeGen = + new ReadMeReportGenerator(this.log); - //execute the tests, and provide the results to the report generators + /* + * execute the tests, and provide the results to the + * report generators + */ ConverterTester2 ct = new ConverterTester2(log); ct.execute(convRefs, new ReportGenerator[] - {allGen, allConvGen, graphGen, readmeGen}, + {allGen, allConvGen, graphGen, origGraphGen, + readmeGen}, cContext, bContext); /* * report generators have now been supplied with the test @@ -143,29 +155,38 @@ allReport.getName() , null); addReturn(allReportData); - TestReport[] sTestReports = allReport.getSuccessfulTestReports(); + TestReport[] sTestReports = + allReport.getSuccessfulTestReports(); addFilePasses(sTestReports, allReportData); - TestReport[] ppTestReports = allReport.getPartialSuccessTestReports(); + TestReport[] ppTestReports = + allReport.getPartialSuccessTestReports(); addFilePasses(ppTestReports, allReportData); - TestReport[] fTestReports = allReport.getFailedTestReports(); + TestReport[] fTestReports = + allReport.getFailedTestReports(); addFilePasses(fTestReports, allReportData); //return all converters report - AllConvsReport allConvReport = allConvGen.getAllConvsReport(); + AllConvsReport allConvReport = + allConvGen.getAllConvsReport(); File allConvReportFile = allConvReport.getReport(); - Data allConvReportData = createReportData(allConvReportFile, allConvReport.getName(), + Data allConvReportData = + createReportData(allConvReportFile, + allConvReport.getName(), null); addReturn(allConvReportData); //return each converter report - ConvReport[] convReports = allConvReport.getConverterReports(); + ConvReport[] convReports = + allConvReport.getConverterReports(); for (int ii = 0; ii < convReports.length; ii++) { ConvReport convReport = convReports[ii]; File convReportFile = convReport.getReport(); - Data convReportData = createReportData(convReportFile, convReport.getName(), allConvReportData); + Data convReportData = + createReportData(convReportFile, + convReport.getName(), allConvReportData); addReturn(convReportData); TestReport[] trs = convReport.getTestReports(); @@ -175,11 +196,23 @@ //return annotated graph report File graphReportFile = graphGen.getGraphReport(); - Data graphReport = createReportData(graphReportFile, "Annotated Graph Report", null, + Data graphReport = createReportData(graphReportFile, + "Annotated Converter Graph", null, "file:text/nwb", DataProperty.NETWORK_TYPE); addReturn(graphReport); + + //return original graph report + + File origGraphReportFile = origGraphGen.getGraphReport(); + Data origGraphReport = createReportData( + origGraphReportFile, + "Original Converter Graph", null, + "file:text/nwb", DataProperty.NETWORK_TYPE); + addReturn(origGraphReport); + } catch (Exception e) { - this.log.log(LogService.LOG_ERROR, "Converter Tester Failed.", e); + this.log.log(LogService.LOG_ERROR, "Converter Tester Failed.", + e); e.printStackTrace(); } } @@ -195,20 +228,20 @@ /** * Returns file pass reports associated with tests or converters. - * @param testReports reports to be returned as children or test or converter + * @param testReports reports to be returned as children or test or + * converter * @param parent the parent of the file pass */ private void addFilePasses(TestReport[] testReports, Data parent) { for (int ii = 0; ii < testReports.length; ii++) { TestReport tr = testReports[ii]; File testReportFile = tr.getTestReport(); -// System.out.println("In algorithm, file pass name is : " + tr.getName()); -// System.out.println("In algorithm FILE name is : " + testReportFile.getName()); Data testReportData = createReportData(testReportFile, tr.getName(), parent); addReturn(testReportData); - FilePassReport[] sFilePassReports = tr.getSuccessfulFilePassReports(); + FilePassReport[] sFilePassReports = + tr.getSuccessfulFilePassReports(); for (int kk = 0; kk < sFilePassReports.length; kk++) { FilePassReport fp = sFilePassReports[kk]; File fpFile = fp.getFilePassReport(); @@ -217,7 +250,8 @@ addReturn(fpData); } - FilePassReport[] fFilePassReports = tr.getFailedFilePassReports(); + FilePassReport[] fFilePassReports = + tr.getFailedFilePassReports(); for (int kk = 0; kk < fFilePassReports.length; kk++) { FilePassReport fp = fFilePassReports[kk]; File fpFile = fp.getFilePassReport(); @@ -233,14 +267,16 @@ * returned from the algorithm. * * @param report the report to be turned into data - * @param label how the report will be labeled in the data manager window + * @param label how the report will be labeled in the data manager + * window * @param parent which report this report will hang from * (null if it is not a child of any report) * @param format The file format or class name of the report * @param type whether the report is a network or text file * @return the report encapsulated in data, ready to be returned. */ - private Data createReportData(Object report, String label, Data parent, String format, String type) { + private Data createReportData(Object report, String label, + Data parent, String format, String type) { Data reportData = new BasicData(report, format); Dictionary metadata = reportData.getMetaData(); metadata.put(DataProperty.LABEL, label); @@ -252,22 +288,26 @@ } /** - * Alternate version of createReportData that assumes the report is a plain text file + * Alternate version of createReportData that assumes the report + * is a plain text file * @param report the report to be turned into data - * @param label how the report will be labeled in the data manager window + * @param label how the report will be labeled in the data manager + * window * @param parent which report this report will hang from * (null if it is not a child of any report) * @return the report encapsulated in data, ready to be returned. */ - private Data createReportData(Object report, String label, Data parent) { - return createReportData(report, label, parent, "file:text/plain", DataProperty.TEXT_TYPE); + private Data createReportData(Object report, String label, + Data parent) { + return createReportData(report, label, parent, "file:text/plain", + DataProperty.TEXT_TYPE); } } private ServiceReference[] getConverterReferences() { - String filter = "(&("+ALGORITHM_TYPE+"="+TYPE_CONVERTER+"))";// + + String filter = "(&("+ALGORITHM_TYPE+"="+TYPE_CONVERTER+"))"; try { ServiceReference[] refs = bContext.getServiceReferences( Deleted: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterNode.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterNode.java 2007-08-30 20:38:58 UTC (rev 503) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterNode.java 2007-08-30 20:39:35 UTC (rev 504) @@ -1,32 +0,0 @@ -package org.cishell.testing.convertertester.core.converter.graph; - -public class ConverterNode { - String name; - int id; - - public ConverterNode(String s, int i){ - name = s; - id = i; - } - - public String getName(){ - return name; - } - - public int getID(){ - return id; - } - - public void setName(String s){ - name = s; - } - - public void setID(int i){ - id = i; - } - - public String toString(){ - return name + " " + id; - } - -} 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-30 20:38:58 UTC (rev 503) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConverterTester2.java 2007-08-30 20:39:35 UTC (rev 504) @@ -79,9 +79,6 @@ 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 Modified: 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/readme/ReadMeReportGenerator.java 2007-08-30 20:38:58 UTC (rev 503) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/readme/ReadMeReportGenerator.java 2007-08-30 20:39:35 UTC (rev 504) @@ -5,14 +5,18 @@ import org.cishell.testing.convertertester.core.tester2.TestFileKeeper; import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.ReadMeReport; -import org.cishell.testing.convertertester.core.tester2.reportgen.reports.Report; import org.cishell.testing.convertertester.core.tester2.reportgen.results.AllConvsResult; import org.cishell.testing.convertertester.core.tester2.reportgen.results.AllTestsResult; +import org.osgi.service.log.LogService; public class ReadMeReportGenerator implements ReportGenerator { + private LogService log; private ReadMeReport readme; + public ReadMeReportGenerator(LogService log) { + this.log = log; + } /** * Instead of actually generating the report in-line, we just * load a file with the report text inside it, and return it as is. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2007-09-10 16:38:07
|
Revision: 510 http://cishell.svn.sourceforge.net/cishell/?rev=510&view=rev Author: mwlinnem Date: 2007-09-10 09:38:02 -0700 (Mon, 10 Sep 2007) Log Message: ----------- Added "All Errors Report". Still pretty rough. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF Added Paths: ----------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/AllErrorReportGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/AllErrorReport.java Modified: trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java 2007-09-08 04:11:12 UTC (rev 509) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java 2007-09-10 16:38:02 UTC (rev 510) @@ -14,11 +14,13 @@ import org.cishell.testing.convertertester.core.tester2.ConverterTester2; import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.allconvs.AllConvsReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.allerrors.AllErrorReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.alltests.AllTestsReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.convgraph.AnnotatedGraphReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.convgraph.GraphReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.readme.ReadMeReportGenerator; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllConvsReport; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllErrorReport; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllTestsReport; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.ConvReport; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.FilePassReport; @@ -117,6 +119,8 @@ new AllTestsReportGenerator(this.log); AllConvsReportGenerator allConvGen = new AllConvsReportGenerator(this.log); + AllErrorReportGenerator allErrGen = + new AllErrorReportGenerator(this.log); GraphReportGenerator origGraphGen = new GraphReportGenerator(this.log); AnnotatedGraphReportGenerator graphGen = @@ -131,8 +135,8 @@ ConverterTester2 ct = new ConverterTester2(log); ct.execute(convRefs, new ReportGenerator[] - {allGen, allConvGen, graphGen, origGraphGen, - readmeGen}, + {allGen, allConvGen, allErrGen, + graphGen, origGraphGen, readmeGen}, cContext, bContext); /* * report generators have now been supplied with the test @@ -178,7 +182,6 @@ null); addReturn(allConvReportData); - //return each converter report ConvReport[] convReports = allConvReport.getConverterReports(); for (int ii = 0; ii < convReports.length; ii++) { @@ -193,6 +196,15 @@ addFilePasses(trs, convReportData); } + //return all errors report + + AllErrorReport allErrorReport = + allErrGen.getAllErrorsReport(); + File allErrReportFile = allErrorReport.getReportFile(); + Data allErrReport = createReportData(allErrReportFile, + allErrorReport.getName(), null); + addReturn(allErrReport); + //return annotated graph report File graphReportFile = graphGen.getGraphReport(); Modified: trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF 2007-09-08 04:11:12 UTC (rev 509) +++ trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF 2007-09-10 16:38:02 UTC (rev 510) @@ -21,11 +21,14 @@ org.cishell.testing.convertertester.core.tester, org.cishell.testing.convertertester.core.tester.graphcomparison, org.cishell.testing.convertertester.core.tester2, + org.cishell.testing.convertertester.core.tester2.fakelogger, org.cishell.testing.convertertester.core.tester2.graphcomparison, org.cishell.testing.convertertester.core.tester2.reportgen, org.cishell.testing.convertertester.core.tester2.reportgen.allconvs, + org.cishell.testing.convertertester.core.tester2.reportgen.allerrors, org.cishell.testing.convertertester.core.tester2.reportgen.alltests, org.cishell.testing.convertertester.core.tester2.reportgen.convgraph, + org.cishell.testing.convertertester.core.tester2.reportgen.faultanalysis, org.cishell.testing.convertertester.core.tester2.reportgen.readme, org.cishell.testing.convertertester.core.tester2.reportgen.reports, org.cishell.testing.convertertester.core.tester2.reportgen.results, Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/AllErrorReportGenerator.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/AllErrorReportGenerator.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/AllErrorReportGenerator.java 2007-09-10 16:38:02 UTC (rev 510) @@ -0,0 +1,210 @@ +package org.cishell.testing.convertertester.core.tester2.reportgen.allerrors; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.cishell.testing.convertertester.core.converter.graph.Converter; +import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.faultanalysis.ChanceAtFault; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllConvsReport; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllErrorReport; +import org.cishell.testing.convertertester.core.tester2.reportgen.reports.ConvReport; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.AllConvsResult; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.AllTestsResult; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.ConvResult; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.FilePassResult; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.TestResult; +import org.osgi.service.log.LogService; + +public class AllErrorReportGenerator implements ReportGenerator { + public static final String TEMP_FILE_PATH = "All-Errors-Report.txt"; + + private LogService log; + + private AllErrorReport allErrorsReport; + + public AllErrorReportGenerator(LogService log) { + this.log = log; + } + + public void generateReport(AllTestsResult atr, + AllConvsResult acr, + File nwbConvGraph) { + + Map explnToCafs = getChanceAtFaultsByExpln(acr); + + FileOutputStream reportOutStream = null; + try { + File reportFile = + new File(ReportGenerator.TEMP_DIR + TEMP_FILE_PATH); + reportOutStream = new FileOutputStream(reportFile); + PrintStream report = new PrintStream(reportOutStream); + + report.println("All Errors Report"); + report.println("---------------------------------------------"); + report.println("" ); + + Set explnSet = explnToCafs.keySet(); + String[] explns = (String[]) explnSet.toArray(new String[0]); + Arrays.sort(explns); + + for (int ii = 0; ii < explns.length; ii++) { + + report.println("------------"); + report.println("Error " + ii); + + String expln = explns[ii]; + + report.println(expln); + report.println(""); + + List CafsWithSameExpln = (List) explnToCafs.get(expln); + Map testToPassesToCafs = + categorizeByTestAndPass(CafsWithSameExpln); + Set tests = testToPassesToCafs.keySet(); + + Iterator testIter = tests.iterator(); + while (testIter.hasNext()) { + TestResult test = (TestResult) testIter.next(); + + report.println(test.getName()); + + Map passToCafs + = (Map) testToPassesToCafs.get(test); + + Set passes = passToCafs.keySet(); + Iterator passIter = passes.iterator(); + while (passIter.hasNext()) { + FilePassResult pass = (FilePassResult) passIter.next(); + + report.println(" " + pass.getName()); + + List cafs = (List) passToCafs.get(pass); + + Converter[] involvedConvs = pass.getConvertersInvolved(); + for (int jj = 0; jj < involvedConvs.length; jj++) { + Converter involvedConv = involvedConvs[jj]; + + ChanceAtFault associatedCaf = + getCafAssociatedWithProvidedConverter( + cafs, involvedConv); + + if (associatedCaf.getChanceAtFault() > 0.0f) { + report.println(" " + + involvedConv.getShortName() + " (%" + + associatedCaf.getChanceAtFault() + + " Chance At Fault)"); + } else { + report.println(" " + + involvedConv.getShortName()); + } + } + } + } + } + report.flush(); + + reportOutStream.close(); + + this.allErrorsReport = new AllErrorReport(reportFile, + "All Errors Report"); + + } catch (IOException e) { + + this.log.log(LogService.LOG_ERROR, "Unable to generate all converters report.", e); + try { + if (reportOutStream != null) reportOutStream.close(); + } catch (IOException e2) { + this.log.log(LogService.LOG_ERROR, "Unable to generate all converters report.", e); + } + } + } + + //expln = explanation + private Map getChanceAtFaultsByExpln(AllConvsResult acr) { + Map explnToCafs = new HashMap(); + + ConvResult[] crs = acr.getConvResults(); + for (int ii = 0; ii < crs.length; ii++) { + ConvResult cr = crs[ii]; + + ChanceAtFault[] cafs = cr.getAllChanceAtFaults(); + for (int jj = 0; jj < cafs.length; jj++) { + ChanceAtFault caf = cafs[jj]; + + String expln = caf.getExplanation(); + + if(explnToCafs.get(expln) != null) { + ((List)explnToCafs.get(expln)).add(caf); + } + else { + List cafsWithSameExpln = new ArrayList(); + cafsWithSameExpln.add(caf); + explnToCafs.put(expln, cafsWithSameExpln); + } + } + } + + return explnToCafs; + } + + //Map<test, Map<pass, List<cafs>>> + private Map categorizeByTestAndPass(List cafList) { + Map testToPassesToCafs = new HashMap(); + for (int ii = 0; ii < cafList.size(); ii++) { + ChanceAtFault caf = (ChanceAtFault) cafList.get(ii); + FilePassResult pass = caf.getFailedFilePass(); + TestResult test = pass.getParent(); + + Map passToCafs; + List cafs; + + passToCafs = (Map) testToPassesToCafs.get(test); + + if(passToCafs == null) { + passToCafs = new HashMap(); + + cafs = new ArrayList(); + } else { + cafs = (List) passToCafs.get(pass); + + if (cafs == null) { + cafs = new ArrayList(); + } + } + + cafs.add(caf); + passToCafs.put(pass, cafs); + testToPassesToCafs.put(test, passToCafs); + } + + return testToPassesToCafs; + } + + public AllErrorReport getAllErrorsReport() { + return this.allErrorsReport; + } + + public ChanceAtFault getCafAssociatedWithProvidedConverter( + List cafs, Converter conv) { + Iterator cafIter = cafs.iterator(); + while (cafIter.hasNext()) { + ChanceAtFault caf = (ChanceAtFault) cafIter.next(); + + if (caf.getConverter() == conv) { + return caf; + } + } + + return null; + } +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/AllErrorReport.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/AllErrorReport.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/AllErrorReport.java 2007-09-10 16:38:02 UTC (rev 510) @@ -0,0 +1,21 @@ +package org.cishell.testing.convertertester.core.tester2.reportgen.reports; + +import java.io.File; + +public class AllErrorReport implements Report { + + private File file; + private String name; + + public AllErrorReport(File file, String name) { + this.file = file; + this.name = name; + } + public String getName() { + return this.name; + } + + public File getReportFile() { + return this.file; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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] |
From: <mwl...@us...> - 2007-09-20 21:42:56
|
Revision: 536 http://cishell.svn.sourceforge.net/cishell/?rev=536&view=rev Author: mwlinnem Date: 2007-09-20 14:42:54 -0700 (Thu, 20 Sep 2007) Log Message: ----------- Improved UI for path filters. Removed System.out.printlns. 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/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/ConverterTester2.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java Added Paths: ----------- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/pathfilter/HopFilter.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-20 21:26:54 UTC (rev 535) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java 2007-09-20 21:42:54 UTC (rev 536) @@ -6,12 +6,12 @@ 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.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.algorithm.pathfilter.HopFilter; 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; @@ -31,7 +31,6 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.osgi.framework.BundleContext; -import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.ServiceReference; import org.osgi.service.log.LogService; @@ -158,7 +157,8 @@ new ReportGenerator[] {allGen, allConvGen, allErrGen, graphGen, origGraphGen, readmeGen}, - cContext, bContext); + cContext, bContext, + new HopFilter(numHops)); } else { ct.execute(convRefs, new ReportGenerator[] 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-20 21:26:54 UTC (rev 535) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmFactory.java 2007-09-20 21:42:54 UTC (rev 536) @@ -72,18 +72,21 @@ AttributeDefinition.STRING, converterNames, converterNames)); + + 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)); 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)); + AttributeDefinition.INTEGER, + "6")); - 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; Added: trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/pathfilter/HopFilter.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/pathfilter/HopFilter.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/pathfilter/HopFilter.java 2007-09-20 21:42:54 UTC (rev 536) @@ -0,0 +1,36 @@ +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 HopFilter implements PathFilter { + + private int maxNumHops; + + public HopFilter(int maxNumHops) { + 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.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/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-20 21:26:54 UTC (rev 535) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterGraph.java 2007-09-20 21:42:54 UTC (rev 536) @@ -48,13 +48,9 @@ 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) { @@ -105,7 +101,6 @@ 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(inDataFormat); @@ -126,20 +121,12 @@ 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(!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); @@ -161,7 +148,6 @@ if(cp.getOutData() != null){ if(cp.getOutData().equals(ConverterGraph.testOutData)){ String key = cp.getInData() + " " + ((Converter) cp.getPath().get(0)).getOutData(); - //System.out.println(key); if(this.fileExtensionCompareConverters.get(key) == null){ @@ -188,20 +174,9 @@ } 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()); - } - 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++){ @@ -269,7 +244,6 @@ keySet = (String[])this.fileExtensionCompareConverters.keySet().toArray(keySet); for(int i = 0; i < keySet.length; i++){ String s = keySet[i]; - //System.out.println(s); sb.append(printComparisonConverterPath(s)); } sb.trimToSize(); 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-20 21:26:54 UTC (rev 535) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java 2007-09-20 21:42:54 UTC (rev 536) @@ -127,7 +127,6 @@ Converter c = (Converter) this.path.get(i); if (c.isLossy()) { - System.out.println("FOUND A LOSSY CONVERTER!"); lossiness = LOSSY; } } 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-20 21:26:54 UTC (rev 535) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConverterTester2.java 2007-09-20 21:42:54 UTC (rev 536) @@ -80,14 +80,12 @@ 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, testPathFilter, cContext, bContext); @@ -97,7 +95,6 @@ Converter[] allConverters = converterGraph.getAllConverters(); - System.out.println("Running conv result maker..."); ChanceAtFaultHeuristic faultHeuristic = new ErrorProximityHeuristic(); AllConvsResult allConvertersResult = 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-20 21:26:54 UTC (rev 535) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java 2007-09-20 21:42:54 UTC (rev 536) @@ -132,7 +132,6 @@ Converter currentConverter = null; try { for (int ii = 0; ii < converters.size(); ii++) { - //System.out.println("Going into converter " + ii); currentConverter = converters.get(ii); //no parameters used This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-03-05 15:34:30
|
Revision: 643 http://cishell.svn.sourceforge.net/cishell/?rev=643&view=rev Author: mwlinnem Date: 2008-03-05 07:34:19 -0800 (Wed, 05 Mar 2008) Log Message: ----------- Various changed I don't recall. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConvResultMaker.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/reportgen/allconvs/AllConvsReportGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/ConvertedDataSubGenerator.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/reports/FilePassReport.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/filepass/FilePassFailure.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/filepass/FilePassSuccess.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/util/FormatUtil.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 2008-03-04 23:53:10 UTC (rev 642) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java 2008-03-05 15:34:19 UTC (rev 643) @@ -1,6 +1,7 @@ package org.cishell.testing.convertertester.algorithm; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Dictionary; @@ -295,15 +296,8 @@ Data fpData = createReportData(fpFile, fp.getName(), testReportData); addReturn(fpData); - ConvertedDataReport[] cdrs = fp.getConvertedDataReports(); - if (cdrs != null) { - for (int mm = 0; mm < cdrs.length; mm++) { - File cdrFile = cdrs[mm].getReport(); - Data cdrData = createReportData(cdrFile, cdrs[mm].getName(), fpData); - addReturn(cdrData); + addAllConvertedDataReports(fp, fpData); } - } - } FilePassReport[] fFilePassReports = tr.getFailedFilePassReports(); @@ -313,18 +307,44 @@ Data fpData = createReportData(fpFile, fp.getName(), testReportData); addReturn(fpData); - ConvertedDataReport[] cdrs = fp.getConvertedDataReports(); - if (cdrs != null) { - for (int mm = 0; mm < cdrs.length; mm++) { - File cdrFile = cdrs[mm].getReport(); - Data cdrData = createReportData(cdrFile, cdrs[mm].getName(), fpData); - addReturn(cdrData); + addAllConvertedDataReports(fp, fpData); } - } - } } } + private void addConvertedDataReports(ConvertedDataReport[] cdrs, Data fpData) { + if (cdrs != null) { + for (int mm = 0; mm < cdrs.length; mm++) { + File cdrFile = cdrs[mm].getReport(); + Data cdrData = createReportData(cdrFile, cdrs[mm].getName(), fpData); + addReturn(cdrData); + } + } + } + + private void addAllConvertedDataReports(FilePassReport fp, Data fpData) { + try { + ConvertedDataReport[] testCDRs = fp.getTestConvertedDataReports(); + File testDummyParentFile = File.createTempFile("testdummyfile", ""); + Data testDummyParentData = createReportData(testDummyParentFile, "test phase", fpData); + addReturn(testDummyParentData); + addConvertedDataReports(testCDRs, testDummyParentData); + ConvertedDataReport[] origCompareCDRs = fp.getOrigCompareConvertedDataReports(); + File origCompareDummyParentFile = File.createTempFile("origcomparedummyfile", ""); + Data origCompareDummyParentData = createReportData(origCompareDummyParentFile, "compare phase for original file", fpData); + addReturn(origCompareDummyParentData); + addConvertedDataReports(origCompareCDRs, origCompareDummyParentData); + ConvertedDataReport[] resultCompareCDRs = fp.getResultCompareConvertedDataReports(); + File resultCompareDummyParentFile = File.createTempFile("origresultdummyfile", ""); + Data resultCompareDummyParentData = createReportData(resultCompareDummyParentFile, "compare phase for resulting file", fpData); + addReturn(resultCompareDummyParentData); + addConvertedDataReports(resultCompareCDRs, resultCompareDummyParentData); + } catch (IOException e) { + this.log.log(LogService.LOG_WARNING, "Unable to write converted data reports due to IO Error"); + } + + } + /** * Wraps the report with metadata in a form that is ready to be * returned from the algorithm. @@ -372,6 +392,8 @@ return createReportData(report, label, parent, "file:text/plain", DataProperty.TEXT_TYPE); } + + } 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 2008-03-04 23:53:10 UTC (rev 642) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConvResultMaker.java 2008-03-05 15:34:19 UTC (rev 643) @@ -20,9 +20,9 @@ public class ConvResultMaker { - //must succeed at least 3 times in the file pass + //must succeed at least x 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 + //must be tested by at least x% of file passes in test private static float MINIMUM_PERCENT_FILE_PASSES_REACHED_TO_BE_TRUSTED = .8f; public static AllConvsResult generate(AllTestsResult atr, @@ -65,7 +65,7 @@ //determine which converters always succeeded. int FAILED = -1; - int NEVER_TESTED = 0; + int NEVER_TESTED = 0; // array entries are 0 by default int[] trusted = new int[tr.getAllConverters().length]; for (int jj = 0; jj < fprs.length; jj++) { @@ -94,8 +94,7 @@ ConverterPath testConvs = tr.getTestConverters(); if (fprs.length > 0) { //mark trusted converters. - - + for (int kk = 0; kk < testConvs.size(); kk++) { Converter c = testConvs.get(kk); float percentFilePassesThisConvParticipatedIn = @@ -106,22 +105,6 @@ 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/DefaultTestRunner.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java 2008-03-04 23:53:10 UTC (rev 642) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java 2008-03-05 15:34:19 UTC (rev 643) @@ -6,7 +6,6 @@ import java.io.StringWriter; import java.io.Writer; import java.util.ArrayList; -import java.util.Arrays; import java.util.Dictionary; import java.util.Hashtable; import java.util.List; @@ -52,49 +51,62 @@ // test conversion phase ConvertResult testPhaseResult = convert(originalFileData, - testConverters, testData, null); + testConverters, testData); + Data[][] allDataFromTestPhase = testPhaseResult.getAllData(); + if (!testPhaseResult.succeeded()) { FilePassFailure failure = createFailResult(originalFileData, PassPhase.TEST_CONV_PHASE, testPhaseResult.getFailInfo(), - testPhaseResult.getAllData()); + allDataFromTestPhase, + null, + null); testResults.add(failure); continue; } Data[] resultFileData = testPhaseResult.getResult(); - Data[][] allDataFromTestPhase = testPhaseResult.getAllData(); + // comparison conversion (for original file) phase ConvertResult comparePhaseOrigResult = convert(originalFileData, - comparisonConverters, testData, allDataFromTestPhase); + comparisonConverters, testData); + Data[][] allDataFromOrigComparePhase = comparePhaseOrigResult.getAllData(); + if (!comparePhaseOrigResult.succeeded()) { FilePassFailure failure = createFailResult(originalFileData, PassPhase.COMPARE_CONV_ORIG_PHASE, comparePhaseOrigResult.getFailInfo(), - comparePhaseOrigResult.getAllData()); + allDataFromTestPhase, + allDataFromOrigComparePhase, + null); testResults.add(failure); continue; } Data[] originalInMemory = comparePhaseOrigResult.getResult(); - Data[][] allDataFromTestAndComparisonPhases = comparePhaseOrigResult.getAllData(); + //comparison conversion (for result file) phase ConvertResult comparePhaseResultResult = convert(resultFileData, - comparisonConverters, testData, allDataFromTestAndComparisonPhases); + comparisonConverters, testData); + Data[][] allDataFromResultComparePhase = comparePhaseResultResult.getAllData(); + if (!comparePhaseResultResult.succeeded()) { FilePassFailure failure = createFailResult(originalFileData, PassPhase.COMPARE_CONV_RESULT_PHASE, comparePhaseResultResult.getFailInfo(), - comparePhaseResultResult.getAllData()); + allDataFromTestPhase, + allDataFromOrigComparePhase, + allDataFromResultComparePhase); testResults.add(failure); continue; } Data[] resultInMemory = comparePhaseResultResult.getResult(); + // graph comparison phase @@ -111,13 +123,15 @@ FilePassFailure failure = createFailResult(originalFileData, explanation, PassPhase.GRAPH_COMPARE_PHASE, null, - comparePhaseResultResult.getAllData()); + allDataFromTestPhase, + allDataFromOrigComparePhase, + allDataFromResultComparePhase); testResults.add(failure); continue; } FilePassSuccess success = new FilePassSuccess(originalFileData, - "", comparePhaseResultResult.getAllData()); + "", allDataFromTestPhase, allDataFromOrigComparePhase, allDataFromResultComparePhase); testResults.add(success); } @@ -127,20 +141,19 @@ } private ConvertResult convert(Data[] startData, - ConverterPath converters, TestConfigData testData, Data[][] previousData) { + ConverterPath converters, TestConfigData testData) { Data[] currentData = getFilePathData(startData); List dataSoFar = new ArrayList(); - if (previousData != null) { - dataSoFar.addAll(Arrays.asList(previousData)); - } - if (startData != null) { - dataSoFar.add(startData); - } +// if (startData != null) { +// alterMetaData(startData); +// dataSoFar.add(startData); +// } + /* - * rig up fake CISHellContext so we can get ahold of + * rig up fake CIShellContext so we can get ahold of * errors sent to logger. */ FakeLogCIShellContext fakeCContext = @@ -148,14 +161,14 @@ - dataSoFar.add(currentData); + //dataSoFar.add(currentData); Converter currentConverter = null; try { for (int ii = 0; ii < converters.size(); ii++) { currentConverter = converters.get(ii); - //no parameters used - Hashtable parameters = new Hashtable(); + + Hashtable parameters = new Hashtable(); //no parameters used currentData = currentConverter.execute(currentData, parameters, fakeCContext); @@ -207,16 +220,16 @@ private FilePassFailure createFailResult(Data[] origData, String explanation, PassPhase lastReachedPhase, - Converter failedConverter, Data[][] allData) { + Converter failedConverter, Data[][] testData, Data[][] origCompareData, Data[][] resultCompareData) { FilePassFailure failure = new FilePassFailure(origData, explanation, - lastReachedPhase, failedConverter, allData); + lastReachedPhase, failedConverter, testData, origCompareData, resultCompareData); return failure; } private FilePassFailure createFailResult(Data[] origData, - PassPhase lastReachedPhase, ConvFailureInfo failInfo, Data[][] allData) { + PassPhase lastReachedPhase, ConvFailureInfo failInfo, Data[][] testData, Data[][] origCompareData, Data[][] resultCompareData) { return createFailResult(origData, failInfo.getExplanation(), - lastReachedPhase, failInfo.getFailedConverter(), allData); + lastReachedPhase, failInfo.getFailedConverter(), testData, origCompareData, resultCompareData); } private class ConvertResult { @@ -312,6 +325,44 @@ Dictionary md = datum.getMetaData(); if (md.get(DataProperty.LABEL) == null) { md.put(DataProperty.LABEL, "result of " + converter.getShortName()); + } else { + alterMetaData(data); + md.put(DataProperty.LABEL, md.get(DataProperty.LABEL) + ": result of " + converter.getShortName()); } } + + private String getFileName(String fileLabel) { + + //index variables will be -1 if index is not found. + int descriptionEndIndex = fileLabel.lastIndexOf(":"); + int filePathEndIndex = fileLabel.lastIndexOf(File.separator); + + //doesn't matter if either variable is -1, since startIndex will be + //zero and none of the string will be cut off the front. + int startIndex = Math.max(descriptionEndIndex, filePathEndIndex) + 1; + + String fileNameWithExtension = fileLabel.substring(startIndex); + + + + int endIndex = fileNameWithExtension.length(); // don't cut any off the end. + + + String fileNameWithoutExtension = fileNameWithExtension.substring(0, endIndex); + + String fileName = fileNameWithoutExtension; + return fileName; + } + + + private void alterMetaData(Data[] origFileData) { + Data data = origFileData[0]; + Dictionary metadata = data.getMetaData(); + String label = (String) metadata.get(DataProperty.LABEL); + if (label != null) { + metadata.put(DataProperty.LABEL, getFileName(label)); + } else { + metadata.put(DataProperty.LABEL, "null"); + } + } } 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 2008-03-04 23:53:10 UTC (rev 642) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allconvs/AllConvsReportGenerator.java 2008-03-05 15:34:19 UTC (rev 643) @@ -50,38 +50,50 @@ report.println("---------------------------------------------"); report.println("" ); + int numTested = 0; + float passedPercentTotal = 0; for (int ii = 0; ii < convResults.length; ii++) { if (convResults[ii].wasTested()) { + if (convResults[ii].wasTested()) { + numTested++; passedPercentTotal += convResults[ii].getPercentPassed(); + } } } - float avgPercentPassed = - passedPercentTotal / convResults.length; + float avgPercentPassed = 0; + if (numTested != 0) { + avgPercentPassed = + passedPercentTotal / (float) numTested; + } float chanceCorrectTotal = 0.0f; for (int ii = 0; ii < convResults.length; ii++) { - if (convResults[ii].wasTested()) { + if (convResults[ii].wasTested()) { chanceCorrectTotal += convResults[ii].getChanceCorrect(); } } + float avgChanceCorrect = 0; + if (numTested != 0) { + avgChanceCorrect = chanceCorrectTotal / ((float) numTested); + } - float avgChanceCorrect = - chanceCorrectTotal / ((float) convResults.length); - List convReportsList = new ArrayList(); List trustedConvs = new ArrayList(); List nonTrustedConvs = new ArrayList(); + List nonTestedConvs = new ArrayList(); for (int ii = 0; ii < convResults.length; ii++) { ConvResult cr = convResults[ii]; if (cr.isTrusted()) { trustedConvs.add(cr); + } else if (cr.wasTested()) { + nonTrustedConvs.add(cr); } else { - nonTrustedConvs.add(cr); + nonTestedConvs.add(cr); } } @@ -90,6 +102,8 @@ trustedConvs.size()); report.println(" # of Non-Trusted Converters : " + nonTrustedConvs.size()); + report.println(" # of Untested Converters :" + + nonTestedConvs.size()); report.println(" Total # of Converters : " + convResults.length); @@ -114,7 +128,7 @@ } report.println(""); - report.println("Non-Trusted Converters..."); + report.println("Non-Trusted Tested Converters..."); for (int ii = 0; ii < nonTrustedConvs.size(); ii++) { ConvResult cr = (ConvResult) nonTrustedConvs.get(ii); Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/ConvertedDataSubGenerator.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/ConvertedDataSubGenerator.java 2008-03-04 23:53:10 UTC (rev 642) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/ConvertedDataSubGenerator.java 2008-03-05 15:34:19 UTC (rev 643) @@ -27,9 +27,13 @@ Data firstData = convertedData[0]; Object fileData = firstData.getData(); if (fileData != null && fileData instanceof File) { - this.convertedDataReport = new ConvertedDataReport((File) fileData,(String) firstData.getMetaData().get(DataProperty.LABEL) + "for " + fpr.getName()); + this.convertedDataReport = + new ConvertedDataReport((File) fileData,(String) firstData.getMetaData().get(DataProperty.LABEL) + + " for " + fpr.getName() + " of " + tr.getName()); } else { - this.convertedDataReport = new ConvertedDataReport((String) firstData.getMetaData().get(DataProperty.LABEL) + " for " + fpr.getName() + " of " + tr.getName()); + this.convertedDataReport = + new ConvertedDataReport((String) firstData.getMetaData().get(DataProperty.LABEL) + + " for " + fpr.getName() + " of " + tr.getName()); } } Modified: 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/FilePassSubGenerator.java 2008-03-04 23:53:10 UTC (rev 642) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/FilePassSubGenerator.java 2008-03-05 15:34:19 UTC (rev 643) @@ -47,20 +47,20 @@ writeReport(report, fpr); - Data[][] allData = fpr.getAllData(); + Data[][] testData = fpr.getTestData(); + Data[][] origCompareData = fpr.getOrigCompareData(); + Data[][] resultCompareData = fpr.getResultCompareData(); - ConvertedDataReport[] convDataReports = null; - if (allData != null) { - convDataReports = new ConvertedDataReport[allData.length]; - - for (int ii = 0; ii < allData.length; ii++) { - Data[] data = allData[ii]; - convDataSubGenerator.generateSubreport(tr, fpr, data); - convDataReports[ii] =convDataSubGenerator.getReport(); - } - } - this.filePassReport = new FilePassReport(reportFile, fpr.getName() + " for " + tr.getName(), convDataReports); + ConvertedDataReport[] testConvDataReports = genConvDataReports(tr, fpr, testData); + ConvertedDataReport[] origCompareConvDataReports = genConvDataReports(tr, fpr,origCompareData); + ConvertedDataReport[] resultCompareConvDataReports = genConvDataReports(tr, fpr,resultCompareData); + + this.filePassReport = new FilePassReport(reportFile, fpr.getName() + " for " + tr.getName(), + testConvDataReports, + origCompareConvDataReports, + resultCompareConvDataReports); + } catch (IOException e) { this.log.log(LogService.LOG_ERROR, "Unable to generate file pass report.", e); @@ -68,10 +68,22 @@ } finally { closeStream(reportOutStream); } - + } + + private ConvertedDataReport[] genConvDataReports(TestResult tr, FilePassResult fpr, Data[][] data) { + if (data != null) { + ConvertedDataReport[] testConvDataReports = new ConvertedDataReport[data.length]; - - + for (int ii = 0; ii < data.length; ii++) { + Data[] datum = data[ii]; + convDataSubGenerator.generateSubreport(tr, fpr, datum); + testConvDataReports[ii] =convDataSubGenerator.getReport(); + } + + return testConvDataReports; + } else { + return new ConvertedDataReport[0]; + } } public FilePassReport getFilePassReport() { Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/FilePassReport.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/FilePassReport.java 2008-03-04 23:53:10 UTC (rev 642) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/reports/FilePassReport.java 2008-03-05 15:34:19 UTC (rev 643) @@ -8,12 +8,20 @@ private String name; - private ConvertedDataReport[] convertedDataReports; + private ConvertedDataReport[] testConvertedDataReports; + private ConvertedDataReport[] origCompareConvertedDataReports; + private ConvertedDataReport[] resultCompareConvertedDataReports; - public FilePassReport (File filePassReport, String name, ConvertedDataReport[] convertedDataReports) { + public FilePassReport (File filePassReport, + String name, + ConvertedDataReport[] testConvertedDataReports, + ConvertedDataReport[] origCompareConvertedDataReports, + ConvertedDataReport[] resultCompareConvertedDataReports) { this.filePassReport = filePassReport; this.name = name; - this.convertedDataReports = convertedDataReports; + this.testConvertedDataReports = testConvertedDataReports; + this.origCompareConvertedDataReports = origCompareConvertedDataReports; + this.resultCompareConvertedDataReports = resultCompareConvertedDataReports; } public File getFilePassReport() { @@ -24,7 +32,16 @@ return this.name; } - public ConvertedDataReport[] getConvertedDataReports() { - return this.convertedDataReports; + public ConvertedDataReport[] getTestConvertedDataReports() { + return this.testConvertedDataReports; } + + public ConvertedDataReport[] getOrigCompareConvertedDataReports() { + return this.origCompareConvertedDataReports; + } + + public ConvertedDataReport[] getResultCompareConvertedDataReports() { + return this.resultCompareConvertedDataReports; + } + } Modified: 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/FilePassResult.java 2008-03-04 23:53:10 UTC (rev 642) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/FilePassResult.java 2008-03-05 15:34:19 UTC (rev 643) @@ -23,7 +23,10 @@ private String explanation; private PassPhase lastReachedPhase; private Converter failedConverter; - private Data[][] allData; + + private Data[][] testData; + private Data[][] origCompareData; + private Data[][] resultCompareData; //variables not set by constructor @@ -42,13 +45,16 @@ private List chanceAtFaults; public FilePassResult(Data[] originalData, String explanation, - PassPhase lastReachedPhase, Converter failedConverter, Data[][] allData) { + PassPhase lastReachedPhase, Converter failedConverter, Data[][] testData, Data[][] origCompareData, Data[][] resultCompareData) { this.originalData = originalData; this.explanation = explanation; this.lastReachedPhase = lastReachedPhase; this.failedConverter = failedConverter; - this.allData = allData; + this.testData = testData; + this.origCompareData = origCompareData; + this.resultCompareData = resultCompareData; + chanceAtFaults = new ArrayList(); } @@ -97,10 +103,18 @@ return this.originalData; } - public Data[][] getAllData() { - return this.allData; + public Data[][] getTestData() { + return this.testData; } + public Data[][] getOrigCompareData() { + return this.origCompareData; + } + + public Data[][] getResultCompareData() { + return this.resultCompareData; + } + public String getOriginalFileLabel() { return (String) getOriginalData()[0].getMetaData().get(DataProperty.LABEL); } Modified: 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/FilePassFailure.java 2008-03-04 23:53:10 UTC (rev 642) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/filepass/FilePassFailure.java 2008-03-05 15:34:19 UTC (rev 643) @@ -7,8 +7,8 @@ public class FilePassFailure extends FilePassResult { public FilePassFailure(Data[] originalData, String explanation, - PassPhase phaseReached, Converter failedConverter, Data[][] allData) { + PassPhase phaseReached, Converter failedConverter, Data[][] testData, Data[][] origCompareData, Data[][] resultCompareData) { super(originalData, explanation, phaseReached, - failedConverter, allData); + failedConverter, testData, origCompareData, resultCompareData); } } Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/filepass/FilePassSuccess.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/filepass/FilePassSuccess.java 2008-03-04 23:53:10 UTC (rev 642) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/filepass/FilePassSuccess.java 2008-03-05 15:34:19 UTC (rev 643) @@ -5,7 +5,7 @@ public class FilePassSuccess extends FilePassResult { - public FilePassSuccess(Data[] originalData, String explanation, Data[][] allData) { - super(originalData, explanation, PassPhase.SUCCEEDED_PHASE, null, allData); + public FilePassSuccess(Data[] originalData, String explanation, Data[][] testData, Data[][] origCompareData, Data[][] resultCompareData) { + super(originalData, explanation, PassPhase.SUCCEEDED_PHASE, null, testData, origCompareData, resultCompareData); } } Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/util/FormatUtil.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/util/FormatUtil.java 2008-03-04 23:53:10 UTC (rev 642) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/util/FormatUtil.java 2008-03-05 15:34:19 UTC (rev 643) @@ -10,11 +10,11 @@ * @return */ public static float formatToPercent(float decimal) { - float temp = decimal; temp *= 100f; temp *= Math.pow(10.0, NUM_DECIMALS); - temp = Math.round(temp) / (float) (Math.pow(10.0, NUM_DECIMALS)); + temp = Math.round(temp); + temp = temp / (float) (Math.pow(10.0, NUM_DECIMALS)); float percent = temp; return percent; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-03-26 21:30:24
|
Revision: 724 http://cishell.svn.sourceforge.net/cishell/?rev=724&view=rev Author: mwlinnem Date: 2008-03-26 14:29:56 -0700 (Wed, 26 Mar 2008) Log Message: ----------- Updated to conform to CIShell 1.0. Removed some old stuff that we aren't using anymore. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.algorithm/META-INF/MANIFEST.MF 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/Converter.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/reportgen/alltests/ConvertedDataSubGenerator.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/FilePassResult.java Removed Paths: ------------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterTesterImpl.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/service/ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/ConfigurationFileConstants.java 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/OldTestResult.java Modified: trunk/testing/org.cishell.testing.convertertester.algorithm/META-INF/MANIFEST.MF =================================================================== --- trunk/testing/org.cishell.testing.convertertester.algorithm/META-INF/MANIFEST.MF 2008-03-26 21:12:15 UTC (rev 723) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/META-INF/MANIFEST.MF 2008-03-26 21:29:56 UTC (rev 724) @@ -4,11 +4,10 @@ Bundle-SymbolicName: org.cishell.testing.convertertester.algorithm Bundle-Version: 0.0.1 Bundle-ClassPath: . -Bundle-Localization: plugin Import-Package: org.cishell.app.service.datamanager, - org.cishell.framework, - org.cishell.framework.algorithm, - org.cishell.framework.data, + org.cishell.framework;version="1.0.0", + org.cishell.framework.algorithm;version="1.0.0", + org.cishell.framework.data;version="1.0.0", org.cishell.reference.app.service.datamanager, org.cishell.reference.app.service.scheduler, org.cishell.reference.gui.common, 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 2008-03-26 21:12:15 UTC (rev 723) +++ trunk/testing/org.cishell.testing.convertertester.core.new/META-INF/MANIFEST.MF 2008-03-26 21:29:56 UTC (rev 724) @@ -14,10 +14,7 @@ org.osgi.service.metatype;version="1.1.0", org.osgi.service.prefs;version="1.1.0" Require-Bundle: org.prefuse.lib -Export-Package: org.cishell.testing.convertertester.core.converter, - org.cishell.testing.convertertester.core.converter.graph, - org.cishell.testing.convertertester.core.service, - org.cishell.testing.convertertester.core.tester, +Export-Package: org.cishell.testing.convertertester.core.converter.graph, org.cishell.testing.convertertester.core.tester.graphcomparison, org.cishell.testing.convertertester.core.tester2, org.cishell.testing.convertertester.core.tester2.fakelogger, Deleted: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java 2008-03-26 21:12:15 UTC (rev 723) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterLoaderImpl.java 2008-03-26 21:29:56 UTC (rev 724) @@ -1,146 +0,0 @@ -package org.cishell.testing.convertertester.core.converter; - -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Map; - -import org.cishell.framework.CIShellContext; -import org.cishell.framework.algorithm.AlgorithmFactory; -import org.cishell.framework.algorithm.AlgorithmProperty; -import org.cishell.service.conversion.Converter; -import org.cishell.service.conversion.DataConversionService; -import org.cishell.testing.convertertester.core.converter.graph.ConverterGraph; -import org.osgi.framework.BundleContext; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceEvent; -import org.osgi.framework.ServiceListener; -import org.osgi.framework.ServiceReference; -import org.osgi.service.log.LogService; - - - -public class ConverterLoaderImpl implements AlgorithmProperty, DataConversionService, ServiceListener{ - -public final static String SERVICE_LIST = "SERVICE_LIST"; - private Map converterList; - private BundleContext bContext; - private LogService log; - private CIShellContext ciContext; - - - public ConverterLoaderImpl(BundleContext bContext, CIShellContext cContext, LogService log){ - this.ciContext = cContext; - this.bContext = bContext; - this.log = log; - converterList = new Hashtable(); - - - - String filter = "(&("+ALGORITHM_TYPE+"="+TYPE_CONVERTER+"))"; - //printConverters(bContext); - - try { - this.bContext.addServiceListener(this, filter); - } catch (InvalidSyntaxException e) { - e.printStackTrace(); - } - assembleGraph(); - } - - private void assembleGraph() { - try { - String filter = "(&("+ALGORITHM_TYPE+"="+TYPE_CONVERTER+"))";// + - - - ServiceReference[] refs = bContext.getServiceReferences( - AlgorithmFactory.class.getName(), filter); - ConverterGraph g = new ConverterGraph(refs, bContext, this.log); - - if (refs != null) { - for (int i = 0; i < refs.length; ++i) { - - this.converterList.put(refs[i].getProperty("service.pid").toString(), refs[i]); - - } - } - } catch (InvalidSyntaxException e) { - throw new RuntimeException(e); - } - } - - - - - - public void serviceChanged(ServiceEvent event) { - ServiceReference inServiceRef = event.getServiceReference(); - - - if (event.getType() == ServiceEvent.MODIFIED) { - this.converterList.put(inServiceRef.getProperty("service.pid").toString(), inServiceRef); - } - else if(event.getType() == ServiceEvent.REGISTERED) { - this.converterList.put(inServiceRef.getProperty("service.pid").toString(), inServiceRef); - } - else if(event.getType() == ServiceEvent.UNREGISTERING) { - System.out.println("Unregistering service: " + inServiceRef); - this.converterList.remove(inServiceRef.getProperty("service.pid").toString()); - - } - } - - - - public Converter[] findConverters(String inFormat, String outFormat, int maxHops, String maxComplexity) { - // TODO Auto-generated method stub - return null; - } - - public Converter[] findConverters(String inFormat, String outFormat) { - // TODO Auto-generated method stub - return null; - } - - - - public Converter getConverter(String[] converterChain) throws Exception{ - ArrayList services = new ArrayList(); - for(int ii = 0; ii < converterChain.length; ii++){ - String s = converterChain[ii]; - ServiceReference ref = (ServiceReference) this.converterList.get(s); - if(ref == null){ - throw new Exception("Converter: " + s + " cannot be found"); - } - services.add(ref); - } - return new ConverterTesterImpl(this.bContext, this.ciContext, (ServiceReference[])services.toArray(new ServiceReference[0])); - } - - private static void printConverters(BundleContext bContext){ - String filter = "(&("+ALGORITHM_TYPE+"="+TYPE_CONVERTER+"))"; - try{ - - ServiceReference[] refs = bContext.getAllServiceReferences(AlgorithmFactory.class.getName(), filter); - for(int ii = 0; ii < refs.length; ii++){ - ServiceReference ref = refs[ii]; - System.out.println("\t"+ref.getProperty("service.pid")); - } - - } - catch(Exception ex){ - System.err.println(ex); - } - - } - - public org.cishell.framework.data.Data convert(org.cishell.framework.data.Data data, String outFormat) { - // TODO Auto-generated method stub - return null; - } - - public Converter[] findConverters(org.cishell.framework.data.Data data, String outFormat) { - // TODO Auto-generated method stub - return null; - } - -} Deleted: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterTesterImpl.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterTesterImpl.java 2008-03-26 21:12:15 UTC (rev 723) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/ConverterTesterImpl.java 2008-03-26 21:29:56 UTC (rev 724) @@ -1,169 +0,0 @@ -package org.cishell.testing.convertertester.core.converter; - -import java.util.Dictionary; -import java.util.Enumeration; -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.BasicData; -import org.cishell.framework.data.Data; -import org.cishell.service.conversion.Converter; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.ServiceReference; -import org.osgi.service.metatype.MetaTypeProvider; - - - -public class ConverterTesterImpl implements Converter, AlgorithmFactory, AlgorithmProperty{ - private ServiceReference[] refs; - private BundleContext bContext; - private Dictionary props; - private CIShellContext cContext; - - public ConverterTesterImpl(BundleContext bContext, CIShellContext cContext, ServiceReference[] refs) { - this.bContext = bContext; - this.cContext = cContext; - this.refs = refs; - - props = new Hashtable(); - - props.put(IN_DATA, refs[0].getProperty(IN_DATA)); - props.put(OUT_DATA, refs[refs.length-1].getProperty(OUT_DATA)); - props.put(LABEL, props.get(IN_DATA) + " -> " + props.get(OUT_DATA)); - - String lossiness = LOSSLESS; - for (int i=0; i < refs.length; i++) { - if (LOSSY.equals(refs[i].getProperty(CONVERSION))) { - lossiness = LOSSY; - } - } - //TODO: Do the same thing for complexity - props.put(CONVERSION, lossiness); - } - - public Data convert(Data inDM) { - Data[] dm = new Data[]{inDM}; - - AlgorithmFactory factory = getAlgorithmFactory(); - Algorithm alg = factory.createAlgorithm(dm, new Hashtable(), cContext); - - dm = alg.execute(); - - Object outData = null; - if (dm != null && dm.length > 0) { - outData = dm[0].getData(); - } - - if (outData != null) { - Dictionary props = inDM.getMetaData(); - Dictionary newProps = new Hashtable(); - - for (Enumeration e=props.keys(); e.hasMoreElements();) { - Object key = e.nextElement(); - newProps.put(key, props.get(key)); - } - - String outFormat = (String)getProperties().get(AlgorithmProperty.OUT_DATA); - return new BasicData(newProps, outData, outFormat); - } else { - return null; - } - } - - public AlgorithmFactory getAlgorithmFactory() { - // TODO Auto-generated method stub - return this; - } - - public ServiceReference[] getConverterChain() { - // TODO Auto-generated method stub - return this.refs; - } - - public Dictionary getProperties() { - // TODO Auto-generated method stub - return this.props; - } - - public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { - // TODO Auto-generated method stub - return new ConverterAlgorithm(data,parameters,context); - } - - public MetaTypeProvider createParameters(Data[] data) { - // TODO Auto-generated method stub - return null; - } - - private class ConverterAlgorithm implements Algorithm { - Data[] inDM; - CIShellContext context; - Dictionary parameters; - - public ConverterAlgorithm(Data[] dm, Dictionary parameters, CIShellContext context) { - this.inDM = dm; - this.parameters = parameters; - this.context = context; - } - - public Data[] execute() { - Data[] dm = inDM; - for (int i=0; i < refs.length; i++) { - AlgorithmFactory factory = (AlgorithmFactory)bContext.getService(refs[i]); - - if (factory != null) { - Algorithm alg = factory.createAlgorithm(dm, parameters, context); -// System.out.println("Entering: " + refs[i].getProperty(Constants.SERVICE_PID)+ "-->"); - dm = alg.execute(); - if(dm == null){ - throw new RuntimeException("Error after " + refs[i].getProperty(Constants.SERVICE_PID)); - - } - } else { - throw new RuntimeException("Missing subconverter: " - + refs[i].getProperty(Constants.SERVICE_PID)); - } - } - - return dm; - } - } - - public int hashCode() { - return toString().hashCode(); - } - - public String toString() { - String str =""; - ServiceReference[] refs = this.refs; - for (int ii = 0; ii < refs.length; ii++) { - ServiceReference ref = refs[ii]; - str += ref.getProperty(Constants.SERVICE_ID) + " " + ref.getProperty(Constants.SERVICE_PID) + "-> "; - } - return str; - } - - public boolean equals(Object o) { - boolean equals = false; - if (o instanceof Converter) { - ServiceReference[] otherServiceReference = ((Converter)o).getConverterChain(); - if (refs.length == otherServiceReference.length) { - for (int i = 0; i < otherServiceReference.length; i++) { - if (refs[i].getProperty(Constants.SERVICE_ID).equals( - otherServiceReference[i].getProperty(Constants.SERVICE_ID))) { - equals = true; - } else { - equals = false; - break; - } - } - } - } - return equals; - } - -} Modified: 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 2008-03-26 21:12:15 UTC (rev 723) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/Converter.java 2008-03-26 21:29:56 UTC (rev 724) @@ -4,6 +4,7 @@ import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.algorithm.AlgorithmExecutionException; import org.cishell.framework.algorithm.AlgorithmFactory; import org.cishell.framework.algorithm.AlgorithmProperty; import org.cishell.framework.data.Data; @@ -69,7 +70,7 @@ } public Data[] execute(Data[] input, Hashtable parameters, - CIShellContext cContext) { + CIShellContext cContext) throws AlgorithmExecutionException { AlgorithmFactory convAlgFactory = (AlgorithmFactory) this.bContext.getService(this.ref); Deleted: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/ConfigurationFileConstants.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/ConfigurationFileConstants.java 2008-03-26 21:12:15 UTC (rev 723) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/ConfigurationFileConstants.java 2008-03-26 21:29:56 UTC (rev 724) @@ -1,10 +0,0 @@ -package org.cishell.testing.convertertester.core.tester; - -public class ConfigurationFileConstants { - public static final String TEST_GRAPHS = "test_graphs="; - public static final String TEST_CONVERTERS = "test_converters="; - public static final String COMPARISON_CONVERTERS = "comparison_converters="; - public static final String NODE_ID_CHANGE = "nodeid_change="; - public static final String EXTENSION = "extension="; - -} Deleted: 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 2008-03-26 21:12:15 UTC (rev 723) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/ConverterTester.java 2008-03-26 21:29:56 UTC (rev 724) @@ -1,239 +0,0 @@ -package org.cishell.testing.convertertester.core.tester; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.channels.FileChannel; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.cishell.framework.CIShellContext; -import org.cishell.framework.data.BasicData; -import org.cishell.framework.data.Data; -import org.cishell.service.conversion.Converter; -import org.cishell.testing.convertertester.core.converter.ConverterLoaderImpl; -import org.cishell.testing.convertertester.core.service.ConfigurationFileParser; -import org.cishell.testing.convertertester.core.tester.graphcomparison.DefaultGraphComparer; -import org.cishell.testing.convertertester.core.tester.graphcomparison.GraphComparer; -import org.osgi.framework.BundleContext; -import org.osgi.service.log.LogService; - -import prefuse.data.Graph; - -public class ConverterTester { - private CIShellContext cContext; - private ConfigurationFileParser cfp; - private ConverterLoaderImpl cli; - private Converter comparisonConverters; - private GraphComparer dgc; - private LogService log; - //private Map<String, Exception> fileErrors; - private static final String tempDir = "converterTesterTemp"; - private File temporaryStorage; - private Converter testConverters; - //string, comparisonresult - private Map results; - - public ConverterTester(BundleContext b, CIShellContext c, LogService log){ - this.cContext = c; - this.log = log; - cli = new ConverterLoaderImpl(b, this.cContext, this.log); - cfp = new ConfigurationFileParser(); - } - - public void runTests(File configFile) throws Exception{ - cfp.parseFile(configFile); - testConverters = cli.getConverter(cfp.getTestConverters()); - comparisonConverters = cli.getConverter(cfp.getComparisonConverters()); - results = new HashMap(); - setupDirectory(); - } - - public ConverterTester(BundleContext b, CIShellContext c, File configFile) throws Exception{ - cContext = c; - cli = new ConverterLoaderImpl(b, cContext, this.log); - cfp = new ConfigurationFileParser(configFile); - testConverters = cli.getConverter(cfp.getTestConverters()); - comparisonConverters = cli.getConverter(cfp.getComparisonConverters()); - results = new HashMap(); - setupDirectory(); - } - - public ConverterTester(BundleContext b, CIShellContext c, String configFileName) throws Exception { - cContext = c; - cli = new ConverterLoaderImpl(b,cContext, this.log); - cfp = new ConfigurationFileParser(new File(configFileName)); - testConverters = cli.getConverter(cfp.getTestConverters()); - comparisonConverters = cli.getConverter(cfp.getComparisonConverters()); - results = new HashMap(); - setupDirectory(); - } - - - private void setupDirectory() throws IOException{ - - temporaryStorage = new File(System.getProperty("user.home") + File.separator + - tempDir); - /*+ File.separator + - )) + - "Temp");*/ - temporaryStorage.mkdir(); - int index = cfp.getConfigFile().lastIndexOf("."); - String s; - if(index > 0) - s = cfp.getConfigFile().substring(0, index); - else - s = cfp.getConfigFile(); - temporaryStorage = new File(temporaryStorage.getCanonicalPath()+File.separator+s+"Temp"); - temporaryStorage.mkdir(); - } - - - private void compareFiles(File sourceFile, File convertedFile){ - System.out.println("Comparing: " + sourceFile.getName() + " and " + convertedFile.getName()); - try{ - dgc = new DefaultGraphComparer(); - results.put(sourceFile.getName() + " " + - convertedFile.getName(), - dgc.compare((Graph)convertFile(sourceFile,this.comparisonConverters).getData(), - (Graph)convertFile(convertedFile,this.comparisonConverters).getData(), - ! cfp.getNodeIDChange())); - - } - catch(Exception ex){ - System.out.println("Could not compare the files. We caught a " + ex.getClass().getName() + " exception"); - ex.printStackTrace(); - } - } - - public void compareFiles(){ - File[] files = temporaryStorage.listFiles(); - for (int ii = 0; ii < files.length; ii++){ - File f = files[ii]; - compareFiles(f,f); - } - } - - private Data convertFile(File f, Converter cnv) throws Exception{ - - try{ - //String s = f.getName(); - //String extension = this.testConverters.getProperties().get(AlgorithmProperty.OUT_DATA).toString(); - System.out.println("Converting " + f.getCanonicalPath()); - Data inData = new BasicData(f.getCanonicalPath(),""); - Data dm = cnv.convert(inData); - - - - if(dm != null){ - System.out.println("Successfully Converted "); - return dm; - } - return null; - } - catch(Exception ex){ - System.out.println("Could not Convert"); - //this.fileErrors.put(s, ex); - //ex.printStackTrace(); - throw ex; - //return null; - } - } - - - public void testFile(File f){ - - - if(!f.isHidden()){ - System.out.println("Testing " + f.getName()); - if(f.isDirectory()){ - File[] files = f.listFiles(); - for (int ii = 0; ii < files.length; ii++) { - File ff = files[ii]; - testFile(ff); - } - } - else{ - try{ - Data dm = convertFile(f,this.testConverters); - if(dm != null){ - writeAsFile(dm, f.getName()); - compareFiles(f,(File)dm.getData()); - } - else { - System.out.println("Could not test the files. The resulting data was null."); - } - }catch(Exception ex){ - System.out.println("Could not test the files."); - } - } - } - - } - - public void testFiles(){ - //System.out.println(this.cfp.getFiles().length); - - File[] files = this.cfp.getFiles(); - for(int i = 0; i < files.length; i++){ - File f = files[i]; - this.testFile(f); - } - } - - public String toString(){ - String output = ""; - output += cfp.toString(); - output += testConverters.toString()+"\r\n"; - output += comparisonConverters.toString()+"\r\n"; - return output; - } - - private void writeAsFile(Data inDM, String fileName){ - String s = fileName.substring(0,fileName.lastIndexOf(".")); - if(inDM != null){ - try{ - copy((File)inDM.getData(), new File(temporaryStorage.getCanonicalPath()+ - File.separator+"converted"+ - s+ this.cfp.getExtension())); - }catch(Exception ex){ - ex.printStackTrace(); - } - - } - } - - private boolean copy(File in, File out) { - try { - FileInputStream fis = new FileInputStream(in); - FileOutputStream fos = new FileOutputStream(out); - - FileChannel readableChannel = fis.getChannel(); - FileChannel writableChannel = fos.getChannel(); - - writableChannel.truncate(0); - writableChannel.transferFrom(readableChannel, 0, readableChannel.size()); - fis.close(); - fos.close(); - return true; - } - catch (IOException ioe) { - System.out.println("Copy Error: IOException during copy\r\n" + ioe.getMessage()); - return false; - } - } - - public void printResults(){ - System.out.println("There are " + this.results.size() + " results"); - Iterator iter = this.results.keySet().iterator(); - while (iter.hasNext()){ - String s = (String) iter.next(); - System.out.println(s); - System.out.println("\t"+this.results.get(s)); - } - } - - -} Deleted: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/OldTestResult.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/OldTestResult.java 2008-03-26 21:12:15 UTC (rev 723) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/OldTestResult.java 2008-03-26 21:29:56 UTC (rev 724) @@ -1,17 +0,0 @@ -package org.cishell.testing.convertertester.core.tester; - -public abstract class OldTestResult { - public abstract String getType(); - public abstract String[] getTestConverterNames(); - public abstract String[] getComparisonConverterNames(); - - public boolean hasExplanation() {return false;} - public boolean hasFailedConverterName() {return false;} - public boolean hasOriginalGraphName() {return false;} - public boolean hasResultingGraphNames() {return false;} - - public String getExplanation() {return "";} - public String getFailedConverterName() {return "";} - public String getOriginalGraphName() {return "";} - public String[] getResultGraphNames() {return new String[0];} -} 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 2008-03-26 21:12:15 UTC (rev 723) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/ConverterTester2.java 2008-03-26 21:29:56 UTC (rev 724) @@ -212,7 +212,7 @@ results[ii] = new Data[] {new BasicData(new File(filePath), format)}; - Dictionary metadata = results[ii][0].getMetaData(); + Dictionary metadata = results[ii][0].getMetadata(); metadata.put(DataProperty.LABEL, filePath); } 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 2008-03-26 21:12:15 UTC (rev 723) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java 2008-03-26 21:29:56 UTC (rev 724) @@ -322,7 +322,7 @@ } Data datum = data[0]; - Dictionary md = datum.getMetaData(); + Dictionary md = datum.getMetadata(); if (md.get(DataProperty.LABEL) == null) { md.put(DataProperty.LABEL, "result of " + converter.getShortName()); } else { @@ -357,7 +357,7 @@ private void alterMetaData(Data[] origFileData) { Data data = origFileData[0]; - Dictionary metadata = data.getMetaData(); + Dictionary metadata = data.getMetadata(); String label = (String) metadata.get(DataProperty.LABEL); if (label != null) { metadata.put(DataProperty.LABEL, getFileName(label)); Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/ConvertedDataSubGenerator.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/ConvertedDataSubGenerator.java 2008-03-26 21:12:15 UTC (rev 723) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/ConvertedDataSubGenerator.java 2008-03-26 21:29:56 UTC (rev 724) @@ -28,11 +28,11 @@ Object fileData = firstData.getData(); if (fileData != null && fileData instanceof File) { this.convertedDataReport = - new ConvertedDataReport((File) fileData,(String) firstData.getMetaData().get(DataProperty.LABEL) + + new ConvertedDataReport((File) fileData,(String) firstData.getMetadata().get(DataProperty.LABEL) + " for " + fpr.getName() + " of " + tr.getName()); } else { this.convertedDataReport = - new ConvertedDataReport((String) firstData.getMetaData().get(DataProperty.LABEL) + + new ConvertedDataReport((String) firstData.getMetadata().get(DataProperty.LABEL) + " for " + fpr.getName() + " of " + tr.getName()); } } Modified: 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/FilePassResult.java 2008-03-26 21:12:15 UTC (rev 723) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/FilePassResult.java 2008-03-26 21:29:56 UTC (rev 724) @@ -116,7 +116,7 @@ } public String getOriginalFileLabel() { - return (String) getOriginalData()[0].getMetaData().get(DataProperty.LABEL); + return (String) getOriginalData()[0].getMetadata().get(DataProperty.LABEL); } public String getOriginalFileShortLabel() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |