diff --git a/javatests/google/registry/dns/PublishDnsUpdatesActionTest.java b/javatests/google/registry/dns/PublishDnsUpdatesActionTest.java index ce73e4869..69e740037 100644 --- a/javatests/google/registry/dns/PublishDnsUpdatesActionTest.java +++ b/javatests/google/registry/dns/PublishDnsUpdatesActionTest.java @@ -34,7 +34,6 @@ import org.joda.time.Duration; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; @@ -51,9 +50,6 @@ public class PublishDnsUpdatesActionTest { @Rule public final InjectRule inject = new InjectRule(); - @Rule - public final ExpectedException thrown = ExpectedException.none(); - private final FakeClock clock = new FakeClock(DateTime.parse("1971-01-01TZ")); private final DnsWriter dnsWriter = mock(DnsWriter.class); private PublishDnsUpdatesAction action; diff --git a/javatests/google/registry/model/registry/RegistriesTest.java b/javatests/google/registry/model/registry/RegistriesTest.java index 835a0b6fd..9a654cf18 100644 --- a/javatests/google/registry/model/registry/RegistriesTest.java +++ b/javatests/google/registry/model/registry/RegistriesTest.java @@ -19,9 +19,9 @@ import static google.registry.testing.DatastoreHelper.createTlds; import com.google.common.net.InternetDomainName; import google.registry.testing.AppEngineRule; +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; @@ -33,7 +33,7 @@ public class RegistriesTest { public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); @Rule - public ExpectedException thrown = ExpectedException.none(); + public ExceptionRule thrown = new ExceptionRule(); private void initTestTlds() { createTlds("foo", "a.b.c"); // Test a multipart tld. diff --git a/javatests/google/registry/monitoring/whitebox/MetricsExportActionTest.java b/javatests/google/registry/monitoring/whitebox/MetricsExportActionTest.java index b2b351b06..7c75c01bb 100644 --- a/javatests/google/registry/monitoring/whitebox/MetricsExportActionTest.java +++ b/javatests/google/registry/monitoring/whitebox/MetricsExportActionTest.java @@ -35,7 +35,6 @@ import google.registry.testing.AppEngineRule; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Matchers; import org.mockito.Mock; @@ -45,9 +44,6 @@ import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class MetricsExportActionTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Rule public final AppEngineRule appEngine = AppEngineRule.builder() .withDatastore() diff --git a/javatests/google/registry/tools/GtechToolTest.java b/javatests/google/registry/tools/GtechToolTest.java index 607076ce4..5061866e3 100644 --- a/javatests/google/registry/tools/GtechToolTest.java +++ b/javatests/google/registry/tools/GtechToolTest.java @@ -33,7 +33,6 @@ import java.util.Set; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -41,9 +40,6 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class GtechToolTest { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - @Rule public final Expect expect = Expect.create(); diff --git a/javatests/google/registry/tools/RegistryToolEnvironmentTest.java b/javatests/google/registry/tools/RegistryToolEnvironmentTest.java index ef524a4e0..f38a9923f 100644 --- a/javatests/google/registry/tools/RegistryToolEnvironmentTest.java +++ b/javatests/google/registry/tools/RegistryToolEnvironmentTest.java @@ -16,9 +16,9 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; +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; @@ -27,7 +27,7 @@ import org.junit.runners.JUnit4; public class RegistryToolEnvironmentTest { @Rule - public final ExpectedException thrown = ExpectedException.none(); + public ExceptionRule thrown = new ExceptionRule(); @Test public void testGet_withoutSetup_throws() throws Exception { diff --git a/javatests/google/registry/tools/RegistryToolTest.java b/javatests/google/registry/tools/RegistryToolTest.java index 3ce40f887..9a2450966 100644 --- a/javatests/google/registry/tools/RegistryToolTest.java +++ b/javatests/google/registry/tools/RegistryToolTest.java @@ -32,7 +32,6 @@ import java.util.Set; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -40,9 +39,6 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class RegistryToolTest { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - @Rule public final Expect expect = Expect.create(); diff --git a/javatests/google/registry/ui/forms/BUILD b/javatests/google/registry/ui/forms/BUILD index d799edcfc..e17b05193 100644 --- a/javatests/google/registry/ui/forms/BUILD +++ b/javatests/google/registry/ui/forms/BUILD @@ -21,6 +21,7 @@ java_library( "//third_party/java/re2j", "//third_party/java/truth", "//java/google/registry/ui/forms", + "//javatests/google/registry/testing", ], ) diff --git a/javatests/google/registry/ui/forms/FormFieldExceptionTest.java b/javatests/google/registry/ui/forms/FormFieldExceptionTest.java index 6232b4245..7bffdc5b8 100644 --- a/javatests/google/registry/ui/forms/FormFieldExceptionTest.java +++ b/javatests/google/registry/ui/forms/FormFieldExceptionTest.java @@ -17,9 +17,9 @@ package google.registry.ui.forms; import static com.google.common.truth.Truth.assertThat; import com.google.common.testing.NullPointerTester; +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 FormFieldExceptionTest { @Rule - public final ExpectedException thrown = ExpectedException.none(); + public ExceptionRule thrown = new ExceptionRule(); @Test public void testGetFieldName_multiplePropagations_joinsUsingJsonNotation() throws Exception { diff --git a/javatests/google/registry/xjc/XmlTestdataTest.java b/javatests/google/registry/xjc/XmlTestdataTest.java index 82223f388..171de210b 100644 --- a/javatests/google/registry/xjc/XmlTestdataTest.java +++ b/javatests/google/registry/xjc/XmlTestdataTest.java @@ -19,6 +19,7 @@ import static google.registry.util.ResourceUtils.readResourceUtf8; import static google.registry.xjc.XjcXmlTransformer.unmarshal; import static java.nio.charset.StandardCharsets.UTF_8; +import google.registry.testing.ExceptionRule; import google.registry.xjc.epp.XjcEpp; import google.registry.xjc.rde.XjcRdeDeposit; import java.io.ByteArrayInputStream; @@ -26,7 +27,6 @@ import org.junit.Rule; import org.junit.experimental.theories.DataPoints; import org.junit.experimental.theories.Theories; import org.junit.experimental.theories.Theory; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; /** @@ -37,7 +37,7 @@ import org.junit.runner.RunWith; public class XmlTestdataTest { @Rule - public final ExpectedException thrown = ExpectedException.none(); + public final ExceptionRule thrown = new ExceptionRule(); private static class Example { final ByteArrayInputStream xmlStream; @@ -151,7 +151,7 @@ public class XmlTestdataTest { @Theory public void testInvalid(Evil v) throws Exception { - thrown.expectMessage(v.error); + thrown.expect(Throwable.class, v.error); unmarshal(XjcObject.class, v.xmlStream); } } diff --git a/javatests/google/registry/xml/DateAdapterTest.java b/javatests/google/registry/xml/DateAdapterTest.java index c481ff596..2cb82ba1d 100644 --- a/javatests/google/registry/xml/DateAdapterTest.java +++ b/javatests/google/registry/xml/DateAdapterTest.java @@ -16,10 +16,10 @@ package google.registry.xml; import static com.google.common.truth.Truth.assertThat; +import google.registry.testing.ExceptionRule; import org.joda.time.LocalDate; 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 DateAdapterTest { @Rule - public final ExpectedException thrown = ExpectedException.none(); + public final ExceptionRule thrown = new ExceptionRule(); @Test public void testMarshal() { diff --git a/javatests/google/registry/xml/UtcDateTimeAdapterTest.java b/javatests/google/registry/xml/UtcDateTimeAdapterTest.java index ad894a602..b8cd0e5ae 100644 --- a/javatests/google/registry/xml/UtcDateTimeAdapterTest.java +++ b/javatests/google/registry/xml/UtcDateTimeAdapterTest.java @@ -17,11 +17,11 @@ package google.registry.xml; import static com.google.common.truth.Truth.assertThat; import static org.joda.time.DateTimeZone.UTC; +import google.registry.testing.ExceptionRule; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -30,7 +30,7 @@ import org.junit.runners.JUnit4; public class UtcDateTimeAdapterTest { @Rule - public final ExpectedException thrown = ExpectedException.none(); + public final ExceptionRule thrown = new ExceptionRule(); @Test public void testMarshal() {