diff --git a/gtsam/nonlinear/tests/priorFactor.xml b/gtsam/nonlinear/tests/priorFactor.xml
new file mode 100644
index 000000000..0c580fb21
--- /dev/null
+++ b/gtsam/nonlinear/tests/priorFactor.xml
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+ 1
+ 0
+ - 12345
+
+
+
+
+
+
+
+
+ 6
+
+
+ 0
+
+
+
+ 6
+
+ - 1.00000000000000000e+00
+ - 1.00000000000000000e+00
+ - 1.00000000000000000e+00
+ - 1.00000000000000000e+00
+ - 1.00000000000000000e+00
+ - 1.00000000000000000e+00
+
+
+
+ 6
+
+ - 1.00000000000000000e+00
+ - 1.00000000000000000e+00
+ - 1.00000000000000000e+00
+ - 1.00000000000000000e+00
+ - 1.00000000000000000e+00
+ - 1.00000000000000000e+00
+
+
+
+ 1.00000000000000000e+00
+ 1.00000000000000000e+00
+
+
+
+
+
+
+
+ 4.11982245665682978e-01
+ -8.33737651774156818e-01
+ -3.67630462924899259e-01
+ -5.87266449276209815e-02
+ -4.26917621276207360e-01
+ 9.02381585483330806e-01
+ -9.09297426825681709e-01
+ -3.50175488374014632e-01
+ -2.24845095366152908e-01
+
+
+
+ - 4.00000000000000000e+00
+ - 5.00000000000000000e+00
+ - 6.00000000000000000e+00
+
+
+
+
+
diff --git a/gtsam/nonlinear/tests/testSerializationNonlinear.cpp b/gtsam/nonlinear/tests/testSerializationNonlinear.cpp
index 4a73cbb0b..023785f21 100644
--- a/gtsam/nonlinear/tests/testSerializationNonlinear.cpp
+++ b/gtsam/nonlinear/tests/testSerializationNonlinear.cpp
@@ -107,6 +107,53 @@ TEST (Serialization, TemplatedValues) {
EXPECT(equalsBinary(values));
}
+/**
+ * Test deserializing from a known serialization generated by code from commit
+ * 3ba65669113f41d0e56a03b4b314047776bab5c4 (>4.2a4)
+ * We only test that deserialization matches since
+ * (1) that's the main backward compatibility requirement and
+ * (2) serialized string depends on boost version
+ */
+TEST(Serialization, NoiseModelFactor1_backwards_compatibility) {
+ PriorFactor factor(
+ 12345, Pose3(Rot3::RzRyRx(Vector3(1., 2., 3.)), Point3(4., 5., 6.)),
+ noiseModel::Unit::Create(6));
+
+ // String
+ std::string expected_str =
+ "22 serialization::archive 15 1 0\n"
+ "0 0 0 0 0 0 0 1 0 12345 0 1 6 21 gtsam_noiseModel_Unit 1 0\n"
+ "1 1 0\n"
+ "2 1 0\n"
+ "3 0 0 0 0 6 0 1 0 0 0 6 1.00000000000000000e+00 1.00000000000000000e+00 "
+ "1.00000000000000000e+00 1.00000000000000000e+00 1.00000000000000000e+00 "
+ "1.00000000000000000e+00 6 1.00000000000000000e+00 "
+ "1.00000000000000000e+00 1.00000000000000000e+00 1.00000000000000000e+00 "
+ "1.00000000000000000e+00 1.00000000000000000e+00 1.00000000000000000e+00 "
+ "1.00000000000000000e+00 0 0 0 0 4.11982245665682978e-01 "
+ "-8.33737651774156818e-01 -3.67630462924899259e-01 "
+ "-5.87266449276209815e-02 -4.26917621276207360e-01 "
+ "9.02381585483330806e-01 -9.09297426825681709e-01 "
+ "-3.50175488374014632e-01 -2.24845095366152908e-01 0 0 "
+ "4.00000000000000000e+00 5.00000000000000000e+00 "
+ "6.00000000000000000e+00\n";
+ PriorFactor factor_deserialized_str = PriorFactor();
+ deserializeFromString(expected_str, factor_deserialized_str);
+ EXPECT(assert_equal(factor, factor_deserialized_str));
+
+ // XML
+ std::string expected_xml;
+ { // read from file
+ std::ifstream f("priorFactor.xml");
+ std::stringstream buffer;
+ buffer << f.rdbuf();
+ expected_xml = buffer.str();
+ }
+ PriorFactor factor_deserialized_xml = PriorFactor();
+ deserializeFromXMLFile("priorFactor.xml", factor_deserialized_xml);
+ EXPECT(assert_equal(factor, factor_deserialized_xml));
+}
+
TEST(Serialization, ISAM2) {
gtsam::ISAM2Params parameters;