|
From: <mwl...@us...> - 2007-08-22 17:26:18
|
Revision: 493
http://cishell.svn.sourceforge.net/cishell/?rev=493&view=rev
Author: mwlinnem
Date: 2007-08-22 10:26:12 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
Improved graph comparer errors, and altered converter reports to have more readable /informative names.
Modified Paths:
--------------
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/ComparisonResult.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/DefaultGraphComparer.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/GraphUtil.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/RunningLog.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java
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/SimpleGraphComparer.java
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/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/TestReportSubGenerator.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/convgraph/GraphReportGenerator.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/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.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/ComplexGraphComparer.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/util/
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/util/ConvUtil.java
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/ComparisonResult.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/ComparisonResult.java 2007-08-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/ComparisonResult.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -3,17 +3,10 @@
public class ComparisonResult {
private boolean succeeded;
- private String explanation;
private RunningLog log;
public ComparisonResult(boolean succeeded, RunningLog log) {
- this(succeeded, "", log);
- }
-
- public ComparisonResult(boolean succeeded, String explanation,
- RunningLog log) {
this.succeeded = succeeded;
- this.explanation = explanation;
this.log = log;
}
@@ -21,10 +14,6 @@
return succeeded;
}
- public String explanation() {
- return explanation;
- }
-
public String getLog() {
return log.toString();
}
@@ -33,8 +22,8 @@
if (comparisonSucceeded()) {
return "Success!";
} else {
- return "Failure: " + explanation + "\n" +
- "Log:" + "\n" +
+ return "Failure: " + "\n" +
+ "Log:" + "\n" +
log;
}
}
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/DefaultGraphComparer.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/DefaultGraphComparer.java 2007-08-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/DefaultGraphComparer.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -24,51 +24,55 @@
log = new RunningLog();
if (g1 == null || g2 == null) {
- return new ComparisonResult(false, "At least one of the provided" +
- " graphs was null.", log);
+ log.prepend("At least one of the provided graphs was null");
+ return new ComparisonResult(false, log);
}
//basic tests
if (! isSameDirectedness(g1, g2)) {
- return new ComparisonResult(false, "Directedness not of the " +
- "same type.", log);
+ log.prepend("Directedness not of the same type");
+ return new ComparisonResult(false, log);
} else if (! isEqualNodeCount(g1, g2)) {
- return new ComparisonResult(false, "Node counts not equal.", log);
+ log.prepend("Node counts not equal.");
+ return new ComparisonResult(false, log);
} else if (! isEqualEdgeCount(g1, g2)) {
- return new ComparisonResult(false, "Edge counts not equal.", log);
+ log.prepend("Edge counts not equal.");
+ return new ComparisonResult(false, log);
}
//complex tests
if (idsPreserved) {
//tests for when graph IDs are preserved across the conversion
if (! areEqual(g1, g2, true)) {
- return new ComparisonResult(false, "Graphs do not have the " +
- "same contents.", log);
+ log.prepend("Graphs do not have the same contents.");
+ return new ComparisonResult(false, log);
}
} else {
//tests for when graph IDs are NOT preserved across the conversion
- 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);
-
+ if (! nodeDegreeFrequenciesEqual(g1, g2)) {
+ log.prepend("The number of nodes with a certain number of " +
+ "edges is not the same in both graphs");
+ return new ComparisonResult(false, 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 (! haveSameNodeAttributes(g1, g2)) {
+ log.prepend("Node attributes are not the same in both graphs");
+ return new ComparisonResult(false, log);
+ }
if (! haveSameEdgeAttributes(g1, g2))
- return new ComparisonResult(false, "Edge attributes are not " +
- "the same in both graphs.", log);
+ log.prepend("Edge attributes are not the same in both graphs");
+ return new ComparisonResult(false, log);
}
//all tests passed
- return new ComparisonResult(true, "All tests succeeded.", log);
+ log.prepend("All tests succeeded.");
+ return new ComparisonResult(true, log);
}
private boolean isSameDirectedness(Graph g1, Graph g2) {
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/GraphUtil.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/GraphUtil.java 2007-08-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/GraphUtil.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -36,7 +36,17 @@
}
public static Table getSorted(Table t) {
- Sort tSort = new Sort(getColumnNames(t));
+ return getSortedByColumns(t, getColumnNames(t));
+ }
+
+ public static Table getSortedByColumns(Table t, String[] columnNames) {
+ for (int ii = 0; ii < columnNames.length; ii++) {
+ String columnName = columnNames[ii];
+ if (t.getColumn(columnName) == null) {
+ System.out.println("WTF, cannot find column " + columnName);
+ }
+ }
+ Sort tSort = new Sort(columnNames);
Table sortedTable = t.select(ExpressionParser.predicate("TRUE"),
tSort);
return sortedTable;
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/RunningLog.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/RunningLog.java 2007-08-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester/graphcomparison/RunningLog.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -12,6 +12,10 @@
log += s +"\n";
}
+ public void prepend(String s) {
+ log = s + "\n" + log;
+ }
+
public String getLog() {
return log;
}
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-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -99,7 +99,8 @@
origGraph, resultGraph);
if (!graphComparisonPhaseResult.comparisonSucceeded()) {
- String explanation = graphComparisonPhaseResult.getLog();
+ String explanation =
+ graphComparisonPhaseResult.getLog();
ComparePhaseFailure failure = new ComparePhaseFailure(
originalFileData,
explanation);
Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/ComplexGraphComparer.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/ComplexGraphComparer.java (rev 0)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/ComplexGraphComparer.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -0,0 +1,184 @@
+package org.cishell.testing.convertertester.core.tester2.graphcomparison;
+
+import java.util.Iterator;
+
+import org.cishell.testing.convertertester.core.tester.graphcomparison.GraphUtil;
+import org.cishell.testing.convertertester.core.tester.graphcomparison.RunningLog;
+
+import prefuse.data.Table;
+import prefuse.data.Tuple;
+
+public abstract class ComplexGraphComparer extends SimpleGraphComparer {
+
+ private RunningLog log;
+
+ public ComplexGraphComparer () {
+
+ this.log = new RunningLog();
+ }
+
+ protected RunningLog getLog() {
+ return this.log;
+ }
+
+ protected void clearLog() {
+ this.log = new RunningLog();
+ }
+
+ protected boolean areEqualWhenSorted(Table t1, Table t2) {
+
+ if (! haveSameColumns(t1, t2)) {
+ return false;
+ }
+
+ String[] colNames = GraphUtil.getColumnNames(t1);
+
+ boolean result = areEqual(GraphUtil.getSortedByColumns(t1, colNames),
+ GraphUtil.getSortedByColumns(t2, colNames));
+ return result;
+ }
+
+ /*
+ * Cares about the order of nodes and edges as well.
+ */
+ protected 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;
+ }
+
+ protected 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 = null;
+ boolean foundMatchingColumn = false;
+ for (int kk = 0; kk < tu2.getColumnCount(); kk++) {
+
+ if (tu2.getColumnName(kk).equals(tu1.getColumnName(ii))) {
+ columnContents2 = tu2.get(kk);
+ foundMatchingColumn = true;
+ break;
+ }
+ }
+
+ //TODO: Possibly remove this, since it SHOULD be guaranteed
+ //not to happen by a check run before this algorithm
+ if (! foundMatchingColumn) {
+ log.append("Only one graph has the column " +
+ tu1.getColumnName(ii));
+
+ log.append("example tuples: ");
+ log.append(tu1.toString() + " : " + tu2.toString());
+ return false;
+ }
+
+ String columnName = tu1.getColumnName(ii);
+
+ if (columnContents1 == null && columnContents2 == null) {
+ //nulls are equal to each other!
+ continue;
+ } else if (columnContents1 == null) {
+ log.append("Column contents not equal!");
+ log.append("For the column " + columnName + "," +
+ "field in first tuple is null while " +
+ "the other is " + columnContents2.toString());
+ log.append(tu1 + " : " + tu2);
+ return false;
+ } else if (columnContents2 == null) {
+ log.append("Column contents not equal!");
+ log.append("For the column " + columnName + "," +
+ "field in first tuple is " +
+ columnContents1.toString() + ", while " +
+ "the other is null");
+ log.append(tu1 + " : " + tu2);
+ return false;
+ } else if (! columnContents1.equals(columnContents2)){
+ log.append("Column contents not equal!");
+ log.append("For the column " + columnName + "," +
+ "field in first tuple is " +
+ columnContents1.toString() + ", while " +
+ "the other is " + columnContents2.toString());
+ String contents1Class = columnContents1.getClass().toString();
+ String contents2Class = columnContents2.getClass().toString();
+ log.append("Field 1 class: " + contents1Class);
+ log.append("Field 2 class: " + contents2Class);
+ log.append(tu1 + " : " + tu2);
+ //neither are null, but they are still not equal.
+ return false;
+ }
+ }
+
+ //all column contents are equal.
+ return true;
+ }
+
+ protected boolean haveSameColumns(Table t1, Table t2) {
+ return firstHasColumnsOfSecond(t2, t1) &&
+ firstHasColumnsOfSecond(t1, t2);
+ }
+
+ protected boolean firstHasColumnsOfSecond(Table t1, Table t2) {
+
+ for (int ii = 0; ii < t2.getColumnCount(); ii++) {
+ String t2Name = t2.getColumnName(ii);
+
+ boolean foundMatch = false;
+ for (int kk = 0; kk < t1.getColumnCount(); kk++) {
+ String t1Name = t1.getColumnName(kk);
+
+ if (t2Name.equals(t1Name)) {
+ foundMatch = true;
+ break;
+ }
+ }
+
+ if (! foundMatch) {
+ log.append("Tables do not have the same columns");
+ log.append("One table has the column '" +
+ t2.getColumnName(ii) + "', while the other does " +
+ "not.");
+
+ String[] t1ColNames = GraphUtil.getColumnNames(t1);
+ String[] t2ColNames = GraphUtil.getColumnNames(t2);
+
+
+ log.append("t1 columns: " + format(t1ColNames));
+ log.append("t2 columns: " + format(t2ColNames));
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ protected String format(String[] strings) {
+ String result = "[";
+ for (int ii = 0; ii < strings.length; ii++) {
+ if (ii < strings.length - 1) {
+ result += strings[ii] + ", ";
+ } else {
+ result += strings[ii];
+ }
+ }
+ result += "]";
+ return result;
+ }
+}
Modified: 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 2007-08-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/IdsNotPreservedComparer.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -11,17 +11,18 @@
import prefuse.data.Graph;
import prefuse.data.Node;
+import prefuse.data.Schema;
import prefuse.data.Table;
import prefuse.data.Tuple;
import prefuse.util.collections.IntIterator;
-public class IdsNotPreservedComparer extends SimpleGraphComparer {
+public class IdsNotPreservedComparer extends ComplexGraphComparer {
private RunningLog log;
public ComparisonResult compare(Graph g1, Graph g2) {
- this.log = new RunningLog();
-
+ super.clearLog();
+ this.log = super.getLog();
ComparisonResult simpleCompareResult = super.compare(g1, g2);
if (! simpleCompareResult.comparisonSucceeded()) {
@@ -30,10 +31,12 @@
log.append(simpleCompareResult.getLog());
- if (! nodeDegreeFrequenciesEqual(g1, g2))
- return new ComparisonResult(false, "The number of nodes" +
+ if (! nodeDegreeFrequenciesEqual(g1, g2)) {
+ log.prepend("The number of nodes" +
"with a certain number of edges is not the same in" +
- "both graphs.", log);
+ "both graphs.");
+ return new ComparisonResult(false, log);
+ }
/*
* TODO: we could really use a graph isomorphism comparison right
@@ -41,16 +44,22 @@
* a lot through.
*/
- if (! haveSameNodeAttributes(g1, g2))
- return new ComparisonResult(false, "Node attributes are not " +
- "the same in both graphs.", log);
+ if (! haveSameNodeAttributes(g1, g2)) {
+ log.prepend("Node attributes are not " +
+ "the same in both graphs.");
+ return new ComparisonResult(false, log);
+ }
- if (! haveSameEdgeAttributes(g1, g2))
- return new ComparisonResult(false, "Edge attributes are not " +
- "the same in both graphs.", log);
+ if (! haveSameEdgeAttributes(g1, g2)) {
+ log.prepend("Edge attributes are not " +
+ "the same in both graphs.");
+ return new ComparisonResult(false, log);
+ }
//all tests passed
- return new ComparisonResult(true, "All tests succeeded.", log);
+
+ log.prepend("All comparison tests succeeded");
+ return new ComparisonResult(true, log);
}
/*
@@ -136,100 +145,7 @@
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.
@@ -254,4 +170,6 @@
}
return tCopy;
}
+
+
}
Modified: 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/IdsPreservedComparer.java 2007-08-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/IdsPreservedComparer.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -15,12 +15,13 @@
import prefuse.data.Tuple;
import prefuse.util.collections.IntIterator;
- public class IdsPreservedComparer extends SimpleGraphComparer {
+ public class IdsPreservedComparer extends ComplexGraphComparer {
private RunningLog log;
public ComparisonResult compare(Graph g1, Graph g2) {
- this.log = new RunningLog();
+ super.clearLog();
+ this.log = super.getLog();
ComparisonResult simpleCompareResult = super.compare(g1, g2);
@@ -31,98 +32,16 @@
log.append(simpleCompareResult.getLog());
if (! areEqual(g1, g2, true)) {
- return new ComparisonResult(false, "Graphs do not have the " +
- "same contents.", log);
+ log.prepend("Graphs do not have the same contents");
+ return new ComparisonResult(false, log);
}
//all tests passed
- return new ComparisonResult(true, "All tests succeeded.", log);
+ log.prepend("All comparison tests succeeded.");
+ return new ComparisonResult(true, 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
@@ -154,90 +73,4 @@
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;
- }
}
Modified: 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/LossyComparer.java 2007-08-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/LossyComparer.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -17,14 +17,16 @@
this.log = new RunningLog();
if (g1 == null || g2 == null) {
- return new ComparisonResult(false, "At least one of the provided" +
- " graphs was null.", log);
+ log.prepend("At least one of the provided graphs was null");
+ return new ComparisonResult(false, log);
}
if (! isEqualNodeCount(g1, g2)) {
- return new ComparisonResult(false, "Node counts not equal.", log);
+ log.prepend("Node counts not equal.");
+ return new ComparisonResult(false, log);
} else if (! isEqualEdgeCount(g1, g2)) {
- return new ComparisonResult(false, "Edge counts not equal.", log);
+ log.prepend("Edge counts not equal.");
+ return new ComparisonResult(false, log);
}
//all tests succeeded.
Modified: 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/graphcomparison/SimpleGraphComparer.java 2007-08-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/graphcomparison/SimpleGraphComparer.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -15,17 +15,19 @@
this.log = new RunningLog();
if (g1 == null || g2 == null) {
- return new ComparisonResult(false, "At least one of the provided" +
- " graphs was null.", log);
+ log.prepend("At least one of the provided graphs was null");
+ return new ComparisonResult(false, log);
}
//basic tests
if (! isSameDirectedness(g1, g2)) {
- return new ComparisonResult(false, "Directedness not of the " +
- "same type.", log);
+ log.prepend("Directedness not of the same type");
+ return new ComparisonResult(false, log);
} else if (! isEqualNodeCount(g1, g2)) {
- return new ComparisonResult(false, "Node counts not equal.", log);
+ log.prepend("Node counts not equal.");
+ return new ComparisonResult(false, log);
} else if (! isEqualEdgeCount(g1, g2)) {
- return new ComparisonResult(false, "Edge counts not equal.", log);
+ log.prepend("Edge counts not equal");
+ return new ComparisonResult(false, log);
}
//all tests succeeded.
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-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/ConvResultMaker.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -222,7 +222,6 @@
String currentConvName = (String) compareConvRef.getProperty("service.pid");
if (failedConvName.equals(currentConvName)) {
//reached where the converters broke
- System.out.println("Reached the end in compare phase");
break;
}
}
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-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allconvs/AllConvsReportGenerator.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -94,14 +94,14 @@
report.println("Trusted Converters...");
for (int ii = 0; ii < trustedConvs.size(); ii++) {
ConvResult cr = (ConvResult) trustedConvs.get(ii);
- report.println(" " + cr.getName());
+ report.println(" " + cr.getNameNoPackage());
}
report.println("");
report.println("Non-Trusted Converters...");
for (int ii = 0; ii < nonTrustedConvs.size(); ii++) {
ConvResult cr = (ConvResult) nonTrustedConvs.get(ii);
- report.println(" " + cr.getName());
+ report.println(" " + cr.getNameNoPackage());
}
report.println("");
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-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allconvs/ConvReportSubGenerator.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -32,7 +32,7 @@
ConvResult convResult = cr;
ServiceReference conv = convResult.getRef();
- File reportFile = new File(ReportGenerator.TEMP_DIR + cr.getName());
+ File reportFile = new File(ReportGenerator.TEMP_DIR + cr.getNameWithPackage());
reportOutStream = new FileOutputStream(reportFile);
PrintStream report = new PrintStream(reportOutStream);
@@ -40,7 +40,7 @@
report.println("Converter Report");
report.println("--------------------------------------");
report.println("");
- report.println(conv.getProperty("service.pid"));
+ report.println(cr.getNameWithPackage());
report.println("");
if (convResult.isTrusted()) {
report.println("Trusted");
@@ -64,7 +64,7 @@
TestResult[] involvedTests = cr.getTests();
for (int ii = 0; ii < involvedTests.length; ii++) {
TestResult tr = involvedTests[ii];
- report.println(" " + tr.getFullName());
+ report.println(" " + tr.getNameWithSuccess());
}
report.println("");
@@ -89,12 +89,10 @@
TestReport[] testReports = (TestReport[]) testReportsList
.toArray(new TestReport[0]);
- System.out.println("Converter " + cr.getName()
- + " is associate with " + testReports.length + " tests");
String summary = "";
this.convReport = new ConvReport(reportFile, new TestReport[0], cr
- .getName(), summary);
+ .getNameNoPackageWithTrust(), summary);
report.println("");
report.flush();
reportOutStream.close();
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-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/AllTestsReportGenerator.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -58,7 +58,7 @@
report.println("Completely Passed Tests...");
for (int ii = 0; ii < passedTRs.length; ii++) {
TestResult passedTR = passedTRs[ii];
- report.println(" " + passedTR.getFullName());
+ report.println(" " + passedTR.getNameWithSuccess());
}
report.println("");
@@ -66,7 +66,7 @@
report.println("Partially Passed Tests...");
for (int ii = 0; ii < pPassedTRs.length; ii++) {
TestResult pPassedTR = pPassedTRs[ii];
- report.println(" " + pPassedTR.getFullName());
+ report.println(" " + pPassedTR.getNameWithSuccess());
}
report.println("");
@@ -75,7 +75,7 @@
TestResult[] failedTRs = atr.getFailedTestResults();
for (int ii = 0; ii < failedTRs.length; ii++) {
TestResult failedTR = failedTRs[ii];
- report.println(" " + failedTR.getFullName());
+ report.println(" " + failedTR.getNameWithSuccess());
}
report.println("");
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-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/alltests/TestReportSubGenerator.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -13,6 +13,7 @@
import org.cishell.testing.convertertester.core.tester2.reportgen.reports.TestReport;
import org.cishell.testing.convertertester.core.tester2.reportgen.results.FilePassResult;
import org.cishell.testing.convertertester.core.tester2.reportgen.results.TestResult;
+import org.cishell.testing.convertertester.core.tester2.util.ConvUtil;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
@@ -57,7 +58,8 @@
for (int ii = 0; ii < testConvs.size(); ii++) {
ServiceReference ref = testConvs.getRef(ii);
String name = ref.getProperty("service.pid").toString();
- report.println(" " + name);
+ String nameWithoutPackage = ConvUtil.removePackagePrefix(name);
+ report.println(" " + nameWithoutPackage);
}
report.println("");
@@ -66,7 +68,8 @@
for (int ii = 0; ii < compareConvs.size(); ii++) {
ServiceReference ref = compareConvs.getRef(ii);
String name = ref.getProperty("service.pid").toString();
- report.println(" " + name);
+ String nameWithoutPackage = ConvUtil.removePackagePrefix(name);
+ report.println(" " + nameWithoutPackage);
}
report.println("");
@@ -119,7 +122,7 @@
// String summary = "%" + percentSuccessful + " Successful";
String summary = "";
- this.testReport = new TestReport(reportFile, tr.getFullName(),
+ this.testReport = new TestReport(reportFile, tr.getNameWithSuccess(),
new FilePassReport[0],
new FilePassReport[0],
// (FilePassReport[]) successfulFPReports.toArray(new FilePassReport[0]),
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-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/convgraph/GraphReportGenerator.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -51,7 +51,7 @@
boolean wroteAttributes = false;
for (int ii = 0; ii < convs.length ; ii++) {
ConvResult cr = convs[ii];
- if (cr.getName().equals(convName)) {
+ if (cr.getNameWithPackage().equals(convName)) {
int trusted;
if (cr.isTrusted()) {
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-08-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/ConvResult.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -8,9 +8,9 @@
import org.cishell.testing.convertertester.core.tester2.reportgen.results.filepass.FilePassFailure;
import org.cishell.testing.convertertester.core.tester2.reportgen.results.filepass.FilePassSuccess;
+import org.cishell.testing.convertertester.core.tester2.util.ConvUtil;
import org.osgi.framework.ServiceReference;
-
public class ConvResult {
private ServiceReference conv;
@@ -59,10 +59,41 @@
this.tests.add(tr);
}
- public String getName() {
+ /**
+ * Returns the full unique name of the converter, including the package
+ * it is found in.
+ * @return full unique name
+ */
+ public String getNameWithPackage() {
return (String) this.getRef().getProperty("service.pid");
}
+ /**
+ * Returns a shortened version of the name, which does not contain the
+ * package. This name is not guaranteed to be unique, but is easier
+ * for humans to read.
+ * @return The shortened name
+ */
+ public String getNameNoPackage() {
+ return ConvUtil.removePackagePrefix(getNameWithPackage());
+ }
+
+ /**
+ * Returns the shortened name, with either "Trusted" or "Not Trusted"
+ * prepended to the front.
+ * @return The shortened name with trust information.
+ */
+ public String getNameNoPackageWithTrust() {
+ String nameNoPackageWithTrust = " - " + getNameNoPackage() ;
+ if (isTrusted()) {
+ nameNoPackageWithTrust = "Trusted" + nameNoPackageWithTrust;
+ } else {
+ nameNoPackageWithTrust = "Not Trusted" + nameNoPackageWithTrust;
+ }
+
+ return nameNoPackageWithTrust;
+ }
+
public TestResult[] getTests() {
return (TestResult[]) this.tests.toArray(new TestResult[0]);
}
Modified: 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/TestResult.java 2007-08-20 17:46:46 UTC (rev 492)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/results/TestResult.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -96,7 +96,7 @@
return this.name;
}
- public String getFullName() {
+ public String getNameWithSuccess() {
return getName() + " - " + getSummary();
}
Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/util/ConvUtil.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/util/ConvUtil.java (rev 0)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/util/ConvUtil.java 2007-08-22 17:26:12 UTC (rev 493)
@@ -0,0 +1,12 @@
+package org.cishell.testing.convertertester.core.tester2.util;
+
+public class ConvUtil {
+
+ /*
+ * Returns everything after the last period in the OSGi service pid.
+ */
+ public static String removePackagePrefix(String pid) {
+ int startIndex = pid.lastIndexOf(".") + 1;
+ return pid.substring(startIndex);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|