From cf849bc07362fedd4d03d6b7b9a59d57f4ce625a Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Mon, 1 Aug 2016 08:40:49 -0700 Subject: [PATCH] Fix XmlTestUtilsTest in open source build The ExpectedException @Rule does not appear to be be able to catch AssertionError in the version of JUnit we're tracking in the open source world. This caused the expected exceptions to get passed through and treated as failures. The solution is to just use our forked version of ExpectedException, which is ExceptionRule. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=128988393 --- javatests/google/registry/xml/BUILD | 1 + javatests/google/registry/xml/XmlTestUtilsTest.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/javatests/google/registry/xml/BUILD b/javatests/google/registry/xml/BUILD index 7d52b899a..7fa0234a5 100644 --- a/javatests/google/registry/xml/BUILD +++ b/javatests/google/registry/xml/BUILD @@ -23,6 +23,7 @@ java_library( "//third_party/java/truth", "//java/google/registry/util", "//java/google/registry/xml", + "//javatests/google/registry/testing", ], ) diff --git a/javatests/google/registry/xml/XmlTestUtilsTest.java b/javatests/google/registry/xml/XmlTestUtilsTest.java index 6dddd5325..d1311f0d8 100644 --- a/javatests/google/registry/xml/XmlTestUtilsTest.java +++ b/javatests/google/registry/xml/XmlTestUtilsTest.java @@ -17,9 +17,9 @@ package google.registry.xml; import static google.registry.util.ResourceUtils.readResourceUtf8; import static google.registry.xml.XmlTestUtils.assertXmlEquals; +import google.registry.testing.ExceptionRule; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -28,7 +28,7 @@ import org.junit.runners.JUnit4; public class XmlTestUtilsTest { @Rule - public final ExpectedException thrown = ExpectedException.none(); + public final ExceptionRule thrown = new ExceptionRule(); void runTest(String file1, String file2) throws Exception { String s1 = readResourceUtf8(getClass(), "testdata/" + file1); @@ -46,12 +46,12 @@ public class XmlTestUtilsTest { thrown.expect(AssertionError.class); runTest("simple.xml", "twoextensions_feeThenLaunch.xml"); } - + @Test public void testMultipleElementsInDifferentNamespaces() throws Exception { runTest("twoextensions_feeThenLaunch.xml", "twoextensions_launchThenFee.xml"); } - + @Test public void testMultipleElementsInDifferentNamespaces_differentValues() throws Exception { thrown.expect(AssertionError.class);