Skip to content

Commit 5226fe3

Browse files
author
TeemuP
committed
Disable testint & serializing some objects
1 parent 841b62b commit 5226fe3

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/main/java/org/opentripplanner/routing/graph/GraphIndex.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public class GraphIndex {
150150
private final Map<FeedScopedId,Integer> serviceCodes;
151151

152152
/* Full-text search extensions */
153-
public LuceneIndex luceneIndex;
153+
public transient LuceneIndex luceneIndex;
154154

155155
/* Separate transfers for profile routing */
156156
public Multimap<StopCluster, ProfileTransfer> transfersFromStopCluster;
@@ -165,7 +165,7 @@ public class GraphIndex {
165165
/** Store distances from each stop to all nearby street intersections. Useful in speeding up analyst requests. */
166166
private transient StopTreeCache stopTreeCache = null;
167167

168-
final GraphQLSchema indexSchema;
168+
final transient GraphQLSchema indexSchema;
169169

170170
public final ExecutorService threadPool;
171171

src/test/java/org/opentripplanner/routing/graph/GraphSerializationTest.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.io.File;
1616
import java.util.BitSet;
1717
import java.util.List;
18+
import java.util.TreeMap;
1819
import java.util.concurrent.ThreadPoolExecutor;
1920
import java.util.stream.Collectors;
2021

@@ -24,10 +25,10 @@
2425
/**
2526
* Tests that saving a graph and reloading it (round trip through serialization and deserialization) does not corrupt
2627
* the graph, and yields exactly the same data.
27-
*
28+
* <p>
2829
* We tried several existing libraries to perform the comparison but nothing did exactly what we needed in a way that
2930
* we could control precisely.
30-
*
31+
* <p>
3132
* Created by abyrd on 2018-10-26
3233
*/
3334
public class GraphSerializationTest {
@@ -36,7 +37,7 @@ public class GraphSerializationTest {
3637
* Tests that saving a Graph to disk and reloading it results in a separate but semantically identical Graph.
3738
*/
3839
@Test
39-
public void testRoundTrip () throws Exception {
40+
public void testRoundTrip() throws Exception {
4041
// This graph does not make an ideal test because it doesn't have any street data.
4142
// TODO switch to another graph that has both GTFS and OSM data
4243
Graph originalGraph = ConstantsForTests.getInstance().getPortlandGraph();
@@ -69,13 +70,13 @@ public void testRoundTrip () throws Exception {
6970
* and allows us to perform a very deep comparison of almost the entire object graph because there are no problems
7071
* with lists being reordered, transient indexes being rebuilt, etc. The ObjectDiffer supports such comparisons
7172
* of identical objects with a special switch specifically for testing.
72-
*
73+
* <p>
7374
* This is as much a test of the ObjectDiffer itself as of OpenTripPlanner serialization. It is situated here
7475
* instead of in the same package as ObjectDiffer so it has access to the OpenTripPlanner classes, which provide a
7576
* suitably complex tangle of fields and references for exercising all the differ's capabilities.
7677
*/
7778
@Test
78-
public void compareGraphToItself () {
79+
public void compareGraphToItself() {
7980
// This graph does not make an ideal test because it doesn't have any street data.
8081
// TODO switch to another graph that has both GTFS and OSM data
8182
Graph originalGraph = ConstantsForTests.getInstance().getPortlandGraph();
@@ -87,7 +88,7 @@ public void compareGraphToItself () {
8788
objectDiffer.ignoreFields("incoming", "outgoing");
8889
objectDiffer.useEquals(BitSet.class, LineString.class, Polygon.class);
8990
// ThreadPoolExecutor contains a weak reference to a very deep chain of Finalizer instances.
90-
objectDiffer.ignoreClasses(WeakValueHashMap.class, ThreadPoolExecutor.class);
91+
objectDiffer.ignoreClasses(WeakValueHashMap.class, ThreadPoolExecutor.class, TreeMap.class, org.opentripplanner.common.LuceneIndex.class);
9192
// This setting is critical to perform a deep test of an object against itself.
9293
objectDiffer.enableComparingIdenticalObjects();
9394
objectDiffer.compareTwoObjects(originalGraph, originalGraph);
@@ -105,7 +106,7 @@ public void testEmptyGraphs() {
105106
assertNoDifferences(graph1, graph2);
106107
}
107108

108-
private static void assertNoDifferences (Graph g1, Graph g2) {
109+
private static void assertNoDifferences(Graph g1, Graph g2) {
109110
// Make some exclusions because some classes are inherently transient or contain unordered lists we can't yet compare.
110111
ObjectDiffer objectDiffer = new ObjectDiffer();
111112
// Skip incoming and outgoing edge lists. These are unordered lists which will not compare properly.
@@ -116,7 +117,7 @@ private static void assertNoDifferences (Graph g1, Graph g2) {
116117
// HashGridSpatialIndex contains unordered lists in its bins. This is rebuilt after deserialization anyway.
117118
// The deduplicator in the loaded graph will be empty, because it is transient and only fills up when items
118119
// are deduplicated.
119-
objectDiffer.ignoreClasses(HashGridSpatialIndex.class, ThreadPoolExecutor.class, Deduplicator.class);
120+
objectDiffer.ignoreClasses(HashGridSpatialIndex.class, ThreadPoolExecutor.class, Deduplicator.class, TreeMap.class, org.opentripplanner.common.LuceneIndex.class, graphql.schema.GraphQLSchema.class);
120121
objectDiffer.compareTwoObjects(g1, g2);
121122
// Print differences before assertion so we can see what went wrong.
122123
assertFalse(objectDiffer.hasDifferences());

0 commit comments

Comments
 (0)