object-differ

Compares Java object trees for serialization round-trip tests

License

License

MIT
GroupId

GroupId

com.conveyal
ArtifactId

ArtifactId

object-differ
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

object-differ
Compares Java object trees for serialization round-trip tests
Project URL

Project URL

https://github.com/conveyal/object-differ
Source Code Management

Source Code Management

https://github.com/conveyal/object-differ

Download object-differ

How to add to project

<!-- https://jarcasting.com/artifacts/com.conveyal/object-differ/ -->
<dependency>
    <groupId>com.conveyal</groupId>
    <artifactId>object-differ</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.conveyal/object-differ/
implementation 'com.conveyal:object-differ:1.1.0'
// https://jarcasting.com/artifacts/com.conveyal/object-differ/
implementation ("com.conveyal:object-differ:1.1.0")
'com.conveyal:object-differ:jar:1.1.0'
<dependency org="com.conveyal" name="object-differ" rev="1.1.0">
  <artifact name="object-differ" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.conveyal', module='object-differ', version='1.1.0')
)
libraryDependencies += "com.conveyal" % "object-differ" % "1.1.0"
[com.conveyal/object-differ "1.1.0"]

Dependencies

compile (4)

Group / Artifact Type Version
net.sf.trove4j : trove4j jar 3.0.3
com.google.guava : guava jar 24.0-jre
org.slf4j : slf4j-api jar 1.7.25
ch.qos.logback : logback-classic jar 1.2.3

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

kryo-tools

These are shared classes enabling Kryo serialization in a couple of projects: OTP and R5.

In package com.conveyal.kryo we define some custom serializers which are reused in both projects. This introduces transitive dependencies on Trove, Guava, and Kryo itself.

The package com.conveyal.object_differ contains library classes that check whether two Java object graphs are identical, for use in serialization round-trip tests. This diffing functionality is actually independent of Kryo and should remain so, but we only use it in serialization tests so it's bundled here with Kryo serializers in a single module.

This performs a semantic equality check between two object graphs in Java. This is intended for use in testing that a round trip through serialization and deserialization reproduces an identical transportation network representation, and that the processs of building that transportation network is reproducible. A system that can do a generalized semantic comparison of any tree of objects is quite complex. Here we try to implement only the minimum feature set needed for our use case in serialization tests.

This code used to be embedded in the R5 project but is now a separate Maven / Git project so that it can be reused in multiple projects, including R5 and OpenTripPlanner.

The object differ started out as a copy of the one supplied by @csolem via the Entur OTP branch at https://github.com/entur/OpenTripPlanner/tree/protostuff_poc but has been mostly rewritten at this point.

To use it in a Maven project include the following dependency:

        <dependency>
            <groupId>com.conveyal</groupId>
            <artifactId>kryo-tools</artifactId>
            <version>1.2.0</version>
            <scope>test</scope>
        </dependency>

This project was renamed from object-differ when serializers were added, so artifacts with versions 1.0 and 1.1 exist with that name.

TODO: configuration and usage information, testing on complex objects within OTP.

Using object-differ with Java 11+ Modules

The object differ works by reflection, which is by default not allowed under the Java module system. Applications depending on the kryo-tools object differ will not work without some adjustments. Rather than simply opening large amounts of classes to reflection all the time, a more targeted solution is to add exceptions only when running your tests (since object-differ is only really intended for testing and not needed during normal program execution). See this article:

https://sormuras.github.io/blog/2018-09-11-testing-in-the-modular-world.html#white-box-modular-testing-with-extra-java-command-line-options

com.conveyal

Conveyal

Urban transport analysis

Versions

Version
1.1.0
1.0.0