diff --git a/javatests/google/registry/batch/DeleteContactsAndHostsActionTest.java b/javatests/google/registry/batch/DeleteContactsAndHostsActionTest.java index fba1ffb5f..52065b2f9 100644 --- a/javatests/google/registry/batch/DeleteContactsAndHostsActionTest.java +++ b/javatests/google/registry/batch/DeleteContactsAndHostsActionTest.java @@ -88,7 +88,6 @@ import google.registry.model.reporting.HistoryEntry; import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferResponse; import google.registry.model.transfer.TransferStatus; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeResponse; import google.registry.testing.FakeSleeper; @@ -103,6 +102,7 @@ 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.junit.runners.JUnit4; @@ -112,7 +112,7 @@ public class DeleteContactsAndHostsActionTest extends MapreduceTestCase { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/batch/DeleteProberDataActionTest.java b/javatests/google/registry/batch/DeleteProberDataActionTest.java index c1d7d1064..28033c11f 100644 --- a/javatests/google/registry/batch/DeleteProberDataActionTest.java +++ b/javatests/google/registry/batch/DeleteProberDataActionTest.java @@ -43,7 +43,6 @@ import google.registry.model.poll.PollMessage; import google.registry.model.registry.Registry; import google.registry.model.registry.Registry.TldType; import google.registry.model.reporting.HistoryEntry; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeResponse; import google.registry.testing.mapreduce.MapreduceTestCase; import java.util.Set; @@ -52,6 +51,7 @@ import org.joda.time.DateTime; 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; @@ -62,7 +62,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/batch/MapreduceEntityCleanupActionTest.java b/javatests/google/registry/batch/MapreduceEntityCleanupActionTest.java index 196fd76c2..3582f3aec 100644 --- a/javatests/google/registry/batch/MapreduceEntityCleanupActionTest.java +++ b/javatests/google/registry/batch/MapreduceEntityCleanupActionTest.java @@ -46,7 +46,6 @@ import com.google.appengine.tools.pipeline.impl.model.JobRecord; import com.google.appengine.tools.pipeline.impl.model.ShardedValue; import com.google.appengine.tools.pipeline.impl.model.Slot; import com.google.common.collect.ImmutableList; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeResponse; import google.registry.testing.mapreduce.MapreduceTestCase; @@ -55,6 +54,7 @@ import java.util.Optional; import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -62,7 +62,7 @@ import org.junit.runners.JUnit4; public class MapreduceEntityCleanupActionTest extends MapreduceTestCase { - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); private static final DatastoreService datastore = getDatastoreService(); private static final FetchOptions FETCH_OPTIONS = FetchOptions.Builder.withChunkSize(200); diff --git a/javatests/google/registry/batch/RefreshDnsOnHostRenameActionTest.java b/javatests/google/registry/batch/RefreshDnsOnHostRenameActionTest.java index 4d3bb0ba5..d34cf8474 100644 --- a/javatests/google/registry/batch/RefreshDnsOnHostRenameActionTest.java +++ b/javatests/google/registry/batch/RefreshDnsOnHostRenameActionTest.java @@ -46,7 +46,6 @@ import google.registry.flows.async.AsyncFlowEnqueuer; import google.registry.flows.async.AsyncFlowMetrics; import google.registry.flows.async.AsyncFlowMetrics.OperationResult; import google.registry.model.host.HostResource; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeResponse; import google.registry.testing.FakeSleeper; @@ -61,6 +60,7 @@ 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.junit.runners.JUnit4; @@ -70,7 +70,7 @@ public class RefreshDnsOnHostRenameActionTest extends MapreduceTestCase { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/bigquery/BigqueryUtilsTest.java b/javatests/google/registry/bigquery/BigqueryUtilsTest.java index e69050434..972bc730f 100644 --- a/javatests/google/registry/bigquery/BigqueryUtilsTest.java +++ b/javatests/google/registry/bigquery/BigqueryUtilsTest.java @@ -23,12 +23,12 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME; import com.google.api.services.bigquery.model.JobReference; -import google.registry.testing.ExceptionRule; import java.util.concurrent.TimeUnit; 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; @@ -37,7 +37,7 @@ import org.junit.runners.JUnit4; public class BigqueryUtilsTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private static final DateTime DATE_0 = DateTime.parse("2014-07-17T20:35:42Z"); private static final DateTime DATE_1 = DateTime.parse("2014-07-17T20:35:42.1Z"); diff --git a/javatests/google/registry/cron/CommitLogFanoutActionTest.java b/javatests/google/registry/cron/CommitLogFanoutActionTest.java index 6f007940a..dd3df5f8f 100644 --- a/javatests/google/registry/cron/CommitLogFanoutActionTest.java +++ b/javatests/google/registry/cron/CommitLogFanoutActionTest.java @@ -20,7 +20,6 @@ import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued; import com.google.common.base.Joiner; import google.registry.model.ofy.CommitLogBucket; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.TaskQueueHelper.TaskMatcher; import google.registry.util.Retrier; import google.registry.util.TaskEnqueuer; @@ -29,6 +28,7 @@ import java.util.List; import java.util.Optional; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -40,7 +40,7 @@ public class CommitLogFanoutActionTest { private static final String QUEUE = "the-queue"; @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final AppEngineRule appEngine = AppEngineRule.builder() diff --git a/javatests/google/registry/cron/TldFanoutActionTest.java b/javatests/google/registry/cron/TldFanoutActionTest.java index 12ab330fd..1f91b3411 100644 --- a/javatests/google/registry/cron/TldFanoutActionTest.java +++ b/javatests/google/registry/cron/TldFanoutActionTest.java @@ -32,7 +32,6 @@ import com.google.common.collect.ImmutableSet; import google.registry.model.registry.Registry; import google.registry.model.registry.Registry.TldType; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeResponse; import google.registry.testing.TaskQueueHelper.TaskMatcher; import google.registry.util.Retrier; @@ -42,6 +41,7 @@ import java.util.Optional; 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; @@ -54,7 +54,7 @@ public class TldFanoutActionTest { private final FakeResponse response = new FakeResponse(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final AppEngineRule appEngine = AppEngineRule.builder() diff --git a/javatests/google/registry/dns/DnsInjectionTest.java b/javatests/google/registry/dns/DnsInjectionTest.java index cb50ffd42..6e4a6fd1d 100644 --- a/javatests/google/registry/dns/DnsInjectionTest.java +++ b/javatests/google/registry/dns/DnsInjectionTest.java @@ -26,7 +26,6 @@ import google.registry.model.ofy.Ofy; import google.registry.request.HttpException.NotFoundException; import google.registry.request.RequestModule; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import java.io.PrintWriter; @@ -37,6 +36,7 @@ import org.joda.time.DateTime; 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; @@ -51,7 +51,7 @@ public final class DnsInjectionTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/dns/DnsQueueTest.java b/javatests/google/registry/dns/DnsQueueTest.java index 57039ac5a..e0e013e5f 100644 --- a/javatests/google/registry/dns/DnsQueueTest.java +++ b/javatests/google/registry/dns/DnsQueueTest.java @@ -19,11 +19,11 @@ import static google.registry.testing.TaskQueueHelper.assertNoTasksEnqueued; import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.TaskQueueHelper.TaskMatcher; 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; @@ -38,7 +38,7 @@ public class DnsQueueTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private DnsQueue dnsQueue; diff --git a/javatests/google/registry/dns/PublishDnsUpdatesActionTest.java b/javatests/google/registry/dns/PublishDnsUpdatesActionTest.java index f119f57fa..3966883fd 100644 --- a/javatests/google/registry/dns/PublishDnsUpdatesActionTest.java +++ b/javatests/google/registry/dns/PublishDnsUpdatesActionTest.java @@ -32,7 +32,6 @@ import google.registry.model.ofy.Ofy; import google.registry.model.registry.Registry; import google.registry.request.HttpException.ServiceUnavailableException; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeLockHandler; import google.registry.testing.InjectRule; @@ -41,6 +40,7 @@ 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.junit.runners.JUnit4; @@ -58,7 +58,7 @@ public class PublishDnsUpdatesActionTest { public final InjectRule inject = new InjectRule(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final FakeClock clock = new FakeClock(DateTime.parse("1971-01-01TZ")); private final FakeLockHandler lockHandler = new FakeLockHandler(true); diff --git a/javatests/google/registry/dns/RefreshDnsActionTest.java b/javatests/google/registry/dns/RefreshDnsActionTest.java index 7848821c2..29736d486 100644 --- a/javatests/google/registry/dns/RefreshDnsActionTest.java +++ b/javatests/google/registry/dns/RefreshDnsActionTest.java @@ -27,11 +27,11 @@ import google.registry.model.domain.DomainResource; import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.NotFoundException; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; 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; @@ -46,7 +46,7 @@ public class RefreshDnsActionTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final DnsQueue dnsQueue = mock(DnsQueue.class); private final FakeClock clock = new FakeClock(); diff --git a/javatests/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java b/javatests/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java index 9475be462..3b198c7e0 100644 --- a/javatests/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java +++ b/javatests/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java @@ -45,7 +45,6 @@ import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.util.Retrier; import google.registry.util.SystemClock; import google.registry.util.SystemSleeper; @@ -57,6 +56,7 @@ 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.ArgumentCaptor; import org.mockito.Captor; @@ -85,7 +85,7 @@ public class CloudDnsWriterTest { private CloudDnsWriter writer; private ImmutableSet stubZone; - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); @Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); diff --git a/javatests/google/registry/dns/writer/dnsupdate/DnsMessageTransportTest.java b/javatests/google/registry/dns/writer/dnsupdate/DnsMessageTransportTest.java index 30e1c35fa..af474a6e3 100644 --- a/javatests/google/registry/dns/writer/dnsupdate/DnsMessageTransportTest.java +++ b/javatests/google/registry/dns/writer/dnsupdate/DnsMessageTransportTest.java @@ -22,7 +22,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.base.VerifyException; -import google.registry.testing.ExceptionRule; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.EOFException; @@ -37,6 +36,7 @@ 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.junit.runners.JUnit4; import org.xbill.DNS.ARecord; @@ -64,7 +64,7 @@ public class DnsMessageTransportTest { private DnsMessageTransport resolver; @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Before public void before() throws Exception { diff --git a/javatests/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java b/javatests/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java index 72fcbed8a..8dac2e859 100644 --- a/javatests/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java +++ b/javatests/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java @@ -42,7 +42,6 @@ import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; import google.registry.model.ofy.Ofy; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import java.util.ArrayList; @@ -53,6 +52,7 @@ 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.ArgumentCaptor; import org.mockito.Captor; @@ -77,7 +77,7 @@ public class DnsUpdateWriterTest { AppEngineRule.builder().withDatastore().withTaskQueue().build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/export/BigqueryPollJobActionTest.java b/javatests/google/registry/export/BigqueryPollJobActionTest.java index e29777d57..9844b1977 100644 --- a/javatests/google/registry/export/BigqueryPollJobActionTest.java +++ b/javatests/google/registry/export/BigqueryPollJobActionTest.java @@ -37,7 +37,6 @@ import google.registry.export.BigqueryPollJobAction.BigqueryPollJobEnqueuer; import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.NotModifiedException; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeSleeper; import google.registry.testing.TaskQueueHelper; @@ -56,6 +55,7 @@ import java.util.logging.Logger; 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; @@ -70,7 +70,7 @@ public class BigqueryPollJobActionTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private static final String PROJECT_ID = "project_id"; private static final String JOB_ID = "job_id"; diff --git a/javatests/google/registry/export/CheckSnapshotActionTest.java b/javatests/google/registry/export/CheckSnapshotActionTest.java index e4483a822..6568dc2ab 100644 --- a/javatests/google/registry/export/CheckSnapshotActionTest.java +++ b/javatests/google/registry/export/CheckSnapshotActionTest.java @@ -30,7 +30,6 @@ import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.NoContentException; import google.registry.request.HttpException.NotModifiedException; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeResponse; import google.registry.testing.InjectRule; @@ -41,6 +40,7 @@ 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.junit.runners.JUnit4; @@ -53,7 +53,7 @@ public class CheckSnapshotActionTest { @Rule public final InjectRule inject = new InjectRule(); @Rule public final AppEngineRule appEngine = AppEngineRule.builder().withTaskQueue().build(); - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); private final DatastoreBackupService backupService = mock(DatastoreBackupService.class); diff --git a/javatests/google/registry/export/DatastoreBackupInfoTest.java b/javatests/google/registry/export/DatastoreBackupInfoTest.java index 13053bd39..2d83a589f 100644 --- a/javatests/google/registry/export/DatastoreBackupInfoTest.java +++ b/javatests/google/registry/export/DatastoreBackupInfoTest.java @@ -24,7 +24,6 @@ import com.google.appengine.api.datastore.Text; import com.google.common.collect.ImmutableList; import google.registry.export.DatastoreBackupInfo.BackupStatus; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import java.util.Date; @@ -33,6 +32,7 @@ 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.junit.runners.JUnit4; @@ -41,7 +41,7 @@ import org.junit.runners.JUnit4; public class DatastoreBackupInfoTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/export/DatastoreBackupServiceTest.java b/javatests/google/registry/export/DatastoreBackupServiceTest.java index 0bdffbae5..667a0dd85 100644 --- a/javatests/google/registry/export/DatastoreBackupServiceTest.java +++ b/javatests/google/registry/export/DatastoreBackupServiceTest.java @@ -26,7 +26,6 @@ import com.google.appengine.api.modules.ModulesService; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.InjectRule; import google.registry.testing.TaskQueueHelper.TaskMatcher; import java.util.Date; @@ -34,6 +33,7 @@ import org.joda.time.DateTime; 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; @@ -42,7 +42,7 @@ import org.junit.runners.JUnit4; public class DatastoreBackupServiceTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/export/LoadSnapshotActionTest.java b/javatests/google/registry/export/LoadSnapshotActionTest.java index a7a23a56f..d4e5f24ab 100644 --- a/javatests/google/registry/export/LoadSnapshotActionTest.java +++ b/javatests/google/registry/export/LoadSnapshotActionTest.java @@ -44,7 +44,6 @@ import google.registry.export.BigqueryPollJobAction.BigqueryPollJobEnqueuer; import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.InternalServerErrorException; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.TaskQueueHelper.TaskMatcher; import java.io.IOException; @@ -53,6 +52,7 @@ import org.joda.time.DateTime; 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; import org.mockito.ArgumentCaptor; @@ -67,7 +67,7 @@ public class LoadSnapshotActionTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final BigqueryFactory bigqueryFactory = mock(BigqueryFactory.class); private final Bigquery bigquery = mock(Bigquery.class); diff --git a/javatests/google/registry/export/PublishDetailReportActionTest.java b/javatests/google/registry/export/PublishDetailReportActionTest.java index cfdf0a0df..a84ca2c3a 100644 --- a/javatests/google/registry/export/PublishDetailReportActionTest.java +++ b/javatests/google/registry/export/PublishDetailReportActionTest.java @@ -39,13 +39,13 @@ import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.InternalServerErrorException; import google.registry.storage.drive.DriveConnection; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import java.io.IOException; import java.nio.ByteBuffer; import java.util.Map; 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; @@ -54,7 +54,7 @@ import org.junit.runners.JUnit4; public class PublishDetailReportActionTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final AppEngineRule appEngine = AppEngineRule.builder() diff --git a/javatests/google/registry/export/SyncGroupMembersActionTest.java b/javatests/google/registry/export/SyncGroupMembersActionTest.java index 13aa2e08e..9050e9695 100644 --- a/javatests/google/registry/export/SyncGroupMembersActionTest.java +++ b/javatests/google/registry/export/SyncGroupMembersActionTest.java @@ -40,7 +40,6 @@ import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarContact; import google.registry.request.Response; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeSleeper; import google.registry.testing.InjectRule; @@ -48,6 +47,7 @@ import google.registry.util.Retrier; import java.io.IOException; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -66,7 +66,7 @@ public class SyncGroupMembersActionTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/export/UpdateSnapshotViewActionTest.java b/javatests/google/registry/export/UpdateSnapshotViewActionTest.java index 881477bb1..cb6262da4 100644 --- a/javatests/google/registry/export/UpdateSnapshotViewActionTest.java +++ b/javatests/google/registry/export/UpdateSnapshotViewActionTest.java @@ -36,12 +36,12 @@ import com.google.common.collect.Iterables; import google.registry.bigquery.BigqueryFactory; import google.registry.request.HttpException.InternalServerErrorException; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.TaskQueueHelper.TaskMatcher; import java.io.IOException; 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; import org.mockito.ArgumentCaptor; @@ -57,7 +57,7 @@ public class UpdateSnapshotViewActionTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final BigqueryFactory bigqueryFactory = mock(BigqueryFactory.class); private final Bigquery bigquery = mock(Bigquery.class); diff --git a/javatests/google/registry/flows/EppCommitLogsTest.java b/javatests/google/registry/flows/EppCommitLogsTest.java index ae4f2913b..f815b9f66 100644 --- a/javatests/google/registry/flows/EppCommitLogsTest.java +++ b/javatests/google/registry/flows/EppCommitLogsTest.java @@ -31,7 +31,6 @@ import google.registry.model.ofy.Ofy; import google.registry.monitoring.whitebox.EppMetric; import google.registry.testing.AppEngineRule; import google.registry.testing.EppLoader; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeHttpSession; import google.registry.testing.InjectRule; @@ -40,6 +39,7 @@ import org.joda.time.DateTime; 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; @@ -54,7 +54,7 @@ public class EppCommitLogsTest extends ShardableTestCase { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/flows/EppXmlTransformerTest.java b/javatests/google/registry/flows/EppXmlTransformerTest.java index b0ff472bd..00e25bd54 100644 --- a/javatests/google/registry/flows/EppXmlTransformerTest.java +++ b/javatests/google/registry/flows/EppXmlTransformerTest.java @@ -21,10 +21,10 @@ import static google.registry.util.ResourceUtils.readResourceBytes; import google.registry.model.eppinput.EppInput; import google.registry.model.eppoutput.EppOutput; -import google.registry.testing.ExceptionRule; import google.registry.testing.ShardableTestCase; 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 @@ import org.junit.runners.JUnit4; public class EppXmlTransformerTest extends ShardableTestCase { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testUnmarshalingEppInput() throws Exception { diff --git a/javatests/google/registry/flows/ExtensionManagerTest.java b/javatests/google/registry/flows/ExtensionManagerTest.java index 312f6b736..8068f0c2d 100644 --- a/javatests/google/registry/flows/ExtensionManagerTest.java +++ b/javatests/google/registry/flows/ExtensionManagerTest.java @@ -33,12 +33,12 @@ import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension; import google.registry.model.eppinput.EppInput; import google.registry.model.eppinput.EppInput.CommandExtension; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.util.TypeUtils; import java.util.logging.LogRecord; import java.util.logging.Logger; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -52,7 +52,7 @@ public class ExtensionManagerTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testDuplicateExtensionsForbidden() throws Exception { diff --git a/javatests/google/registry/flows/FlowTestCase.java b/javatests/google/registry/flows/FlowTestCase.java index 5e7be49c3..156743c62 100644 --- a/javatests/google/registry/flows/FlowTestCase.java +++ b/javatests/google/registry/flows/FlowTestCase.java @@ -49,7 +49,6 @@ import google.registry.model.tmch.ClaimsListShard.ClaimsListSingleton; import google.registry.monitoring.whitebox.EppMetric; import google.registry.testing.AppEngineRule; import google.registry.testing.EppLoader; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeHttpSession; import google.registry.testing.InjectRule; @@ -64,6 +63,7 @@ import java.util.Map; import org.joda.time.DateTime; import org.junit.Before; import org.junit.Rule; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -88,7 +88,7 @@ public abstract class FlowTestCase extends ShardableTestCase { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/flows/TlsCredentialsTest.java b/javatests/google/registry/flows/TlsCredentialsTest.java index f1fa913d1..a5bd6c981 100644 --- a/javatests/google/registry/flows/TlsCredentialsTest.java +++ b/javatests/google/registry/flows/TlsCredentialsTest.java @@ -19,10 +19,10 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import google.registry.request.HttpException.BadRequestException; -import google.registry.testing.ExceptionRule; import javax.servlet.http.HttpServletRequest; 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; @RunWith(JUnit4.class) public final class TlsCredentialsTest { - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); @Test public void testProvideClientCertificateHash() { diff --git a/javatests/google/registry/groups/DirectoryGroupsConnectionTest.java b/javatests/google/registry/groups/DirectoryGroupsConnectionTest.java index e56ff22d8..577acc01c 100644 --- a/javatests/google/registry/groups/DirectoryGroupsConnectionTest.java +++ b/javatests/google/registry/groups/DirectoryGroupsConnectionTest.java @@ -47,12 +47,12 @@ import com.google.api.services.groupssettings.model.Groups; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import google.registry.groups.GroupsConnection.Role; -import google.registry.testing.ExceptionRule; import java.io.IOException; 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; @@ -63,7 +63,7 @@ import org.junit.runners.JUnit4; public class DirectoryGroupsConnectionTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final Directory directory = mock(Directory.class); private final Groupssettings groupsSettings = mock(Groupssettings.class); diff --git a/javatests/google/registry/mapreduce/inputs/ChildEntityInputTest.java b/javatests/google/registry/mapreduce/inputs/ChildEntityInputTest.java index 7bb3ea64d..053cffde8 100644 --- a/javatests/google/registry/mapreduce/inputs/ChildEntityInputTest.java +++ b/javatests/google/registry/mapreduce/inputs/ChildEntityInputTest.java @@ -39,7 +39,6 @@ import google.registry.model.domain.DomainResource; import google.registry.model.index.EppResourceIndex; import google.registry.model.reporting.HistoryEntry; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; @@ -52,6 +51,7 @@ 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; @@ -65,7 +65,7 @@ public class ChildEntityInputTest { public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); DomainResource domainA; DomainResource domainB; diff --git a/javatests/google/registry/mapreduce/inputs/EppResourceInputsTest.java b/javatests/google/registry/mapreduce/inputs/EppResourceInputsTest.java index bac067a69..d32598bc4 100644 --- a/javatests/google/registry/mapreduce/inputs/EppResourceInputsTest.java +++ b/javatests/google/registry/mapreduce/inputs/EppResourceInputsTest.java @@ -39,7 +39,6 @@ import google.registry.model.domain.DomainResource; import google.registry.model.host.HostResource; import google.registry.model.index.EppResourceIndex; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; @@ -49,6 +48,7 @@ import java.util.NoSuchElementException; import java.util.Set; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -62,7 +62,7 @@ public class EppResourceInputsTest { public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @SuppressWarnings("unchecked") private T serializeAndDeserialize(T obj) throws Exception { diff --git a/javatests/google/registry/model/EppResourceUtilsTest.java b/javatests/google/registry/model/EppResourceUtilsTest.java index 9163e4731..7350efe2d 100644 --- a/javatests/google/registry/model/EppResourceUtilsTest.java +++ b/javatests/google/registry/model/EppResourceUtilsTest.java @@ -26,7 +26,6 @@ import static org.joda.time.DateTimeZone.UTC; import google.registry.model.host.HostResource; import google.registry.model.ofy.Ofy; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import org.joda.time.DateTime; @@ -34,6 +33,7 @@ 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.junit.runners.JUnit4; @@ -48,7 +48,7 @@ public class EppResourceUtilsTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/model/ModelUtilsTest.java b/javatests/google/registry/model/ModelUtilsTest.java index b8d71ed5f..6745eefd1 100644 --- a/javatests/google/registry/model/ModelUtilsTest.java +++ b/javatests/google/registry/model/ModelUtilsTest.java @@ -19,12 +19,12 @@ import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.ImmutableMap; import com.googlecode.objectify.annotation.Id; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import java.lang.reflect.Field; import java.util.Map; 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; @@ -33,7 +33,7 @@ import org.junit.runners.JUnit4; public class ModelUtilsTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public AppEngineRule appEngineRule = new AppEngineRule.Builder().build(); diff --git a/javatests/google/registry/model/billing/BillingEventTest.java b/javatests/google/registry/model/billing/BillingEventTest.java index 3820de402..22988fd26 100644 --- a/javatests/google/registry/model/billing/BillingEventTest.java +++ b/javatests/google/registry/model/billing/BillingEventTest.java @@ -32,18 +32,18 @@ import google.registry.model.domain.DomainResource; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.reporting.HistoryEntry; -import google.registry.testing.ExceptionRule; import org.joda.money.Money; import org.joda.time.DateTime; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; /** Unit tests for {@link BillingEvent}. */ public class BillingEventTest extends EntityTestCase { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final DateTime now = DateTime.now(UTC); diff --git a/javatests/google/registry/model/billing/RegistrarBillingEntryTest.java b/javatests/google/registry/model/billing/RegistrarBillingEntryTest.java index dbf3049e0..84d0ddb13 100644 --- a/javatests/google/registry/model/billing/RegistrarBillingEntryTest.java +++ b/javatests/google/registry/model/billing/RegistrarBillingEntryTest.java @@ -22,12 +22,12 @@ import static org.joda.money.CurrencyUnit.USD; import com.google.common.collect.ImmutableMap; import com.googlecode.objectify.Key; import google.registry.model.EntityTestCase; -import google.registry.testing.ExceptionRule; import org.joda.money.CurrencyMismatchException; import org.joda.money.Money; import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -36,7 +36,7 @@ import org.junit.runners.JUnit4; public final class RegistrarBillingEntryTest extends EntityTestCase { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testIndexing() throws Exception { diff --git a/javatests/google/registry/model/billing/RegistrarCreditBalanceTest.java b/javatests/google/registry/model/billing/RegistrarCreditBalanceTest.java index 2ebc841ef..8f87b4d76 100644 --- a/javatests/google/registry/model/billing/RegistrarCreditBalanceTest.java +++ b/javatests/google/registry/model/billing/RegistrarCreditBalanceTest.java @@ -28,7 +28,6 @@ import google.registry.model.EntityTestCase; import google.registry.model.billing.RegistrarCredit.CreditType; import google.registry.model.billing.RegistrarCreditBalance.BalanceMap; import google.registry.model.registrar.Registrar; -import google.registry.testing.ExceptionRule; import java.util.Map; import org.joda.money.CurrencyUnit; import org.joda.money.Money; @@ -36,12 +35,13 @@ import org.joda.time.DateTime; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; /** Unit tests for {@link RegistrarCreditBalance}. */ public class RegistrarCreditBalanceTest extends EntityTestCase { @Rule - public ExceptionRule thrown = new ExceptionRule(); + public ExpectedException thrown = ExpectedException.none(); private DateTime then = clock.nowUtc().plusDays(1); diff --git a/javatests/google/registry/model/billing/RegistrarCreditTest.java b/javatests/google/registry/model/billing/RegistrarCreditTest.java index e60440454..3a0ea0b1f 100644 --- a/javatests/google/registry/model/billing/RegistrarCreditTest.java +++ b/javatests/google/registry/model/billing/RegistrarCreditTest.java @@ -26,17 +26,17 @@ import google.registry.model.EntityTestCase; import google.registry.model.billing.RegistrarCredit.CreditType; import google.registry.model.registrar.Registrar; import google.registry.model.registry.Registry; -import google.registry.testing.ExceptionRule; import org.joda.money.CurrencyUnit; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; /** Unit tests for {@link RegistrarCredit}. */ public class RegistrarCreditTest extends EntityTestCase { @Rule - public ExceptionRule thrown = new ExceptionRule(); + public ExpectedException thrown = ExpectedException.none(); private RegistrarCredit auctionCredit; private RegistrarCredit promoCredit; diff --git a/javatests/google/registry/model/common/CursorTest.java b/javatests/google/registry/model/common/CursorTest.java index f6bae1b3c..8ffe96bd5 100644 --- a/javatests/google/registry/model/common/CursorTest.java +++ b/javatests/google/registry/model/common/CursorTest.java @@ -26,15 +26,15 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME; import google.registry.model.EntityTestCase; import google.registry.model.domain.DomainResource; import google.registry.model.registry.Registry; -import google.registry.testing.ExceptionRule; import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; /** Unit tests for {@link Cursor}. */ public class CursorTest extends EntityTestCase { - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); @Test public void testSuccess_persistScopedCursor() { diff --git a/javatests/google/registry/model/common/TimeOfYearTest.java b/javatests/google/registry/model/common/TimeOfYearTest.java index a03b24515..e6da24a00 100644 --- a/javatests/google/registry/model/common/TimeOfYearTest.java +++ b/javatests/google/registry/model/common/TimeOfYearTest.java @@ -20,10 +20,10 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Range; -import google.registry.testing.ExceptionRule; import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -36,7 +36,7 @@ public class TimeOfYearTest { private static final DateTime march1 = DateTime.parse("2012-03-01T01:02:03.0Z"); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testSuccess_fromDateTime() throws Exception { diff --git a/javatests/google/registry/model/common/TimedTransitionPropertyTest.java b/javatests/google/registry/model/common/TimedTransitionPropertyTest.java index a0ba934ba..8a2e0da31 100644 --- a/javatests/google/registry/model/common/TimedTransitionPropertyTest.java +++ b/javatests/google/registry/model/common/TimedTransitionPropertyTest.java @@ -22,13 +22,13 @@ import static org.joda.time.DateTimeZone.UTC; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableSortedMap; -import google.registry.testing.ExceptionRule; import java.util.Map; import java.util.Set; import org.joda.time.DateTime; 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; @@ -37,7 +37,7 @@ import org.junit.runners.JUnit4; public class TimedTransitionPropertyTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private static final DateTime A_LONG_TIME_AGO = new DateTime(Long.MIN_VALUE, UTC); diff --git a/javatests/google/registry/model/contact/ContactResourceTest.java b/javatests/google/registry/model/contact/ContactResourceTest.java index 6d5f9f54a..3bf05836f 100644 --- a/javatests/google/registry/model/contact/ContactResourceTest.java +++ b/javatests/google/registry/model/contact/ContactResourceTest.java @@ -36,16 +36,16 @@ import google.registry.model.eppcommon.Trid; import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferData.TransferServerApproveEntity; import google.registry.model.transfer.TransferStatus; -import google.registry.testing.ExceptionRule; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; /** Unit tests for {@link ContactResource}. */ public class ContactResourceTest extends EntityTestCase { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); ContactResource contactResource; diff --git a/javatests/google/registry/model/domain/DomainApplicationTest.java b/javatests/google/registry/model/domain/DomainApplicationTest.java index afad3a615..a083edfc8 100644 --- a/javatests/google/registry/model/domain/DomainApplicationTest.java +++ b/javatests/google/registry/model/domain/DomainApplicationTest.java @@ -39,17 +39,17 @@ import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.Trid; import google.registry.model.host.HostResource; import google.registry.model.smd.EncodedSignedMark; -import google.registry.testing.ExceptionRule; import org.joda.money.Money; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; /** Unit tests for {@link DomainApplication}. */ public class DomainApplicationTest extends EntityTestCase { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); DomainApplication domainApplication; diff --git a/javatests/google/registry/model/domain/DomainResourceTest.java b/javatests/google/registry/model/domain/DomainResourceTest.java index 1e027ab50..e78b07e8a 100644 --- a/javatests/google/registry/model/domain/DomainResourceTest.java +++ b/javatests/google/registry/model/domain/DomainResourceTest.java @@ -51,19 +51,19 @@ import google.registry.model.reporting.HistoryEntry; import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferData.TransferServerApproveEntity; import google.registry.model.transfer.TransferStatus; -import google.registry.testing.ExceptionRule; import java.util.stream.Stream; import org.joda.money.Money; import org.joda.time.DateTime; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; /** Unit tests for {@link DomainResource}. */ public class DomainResourceTest extends EntityTestCase { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); DomainResource domain; diff --git a/javatests/google/registry/model/domain/GracePeriodTest.java b/javatests/google/registry/model/domain/GracePeriodTest.java index 97e325f01..8888c2e74 100644 --- a/javatests/google/registry/model/domain/GracePeriodTest.java +++ b/javatests/google/registry/model/domain/GracePeriodTest.java @@ -24,13 +24,13 @@ import google.registry.model.billing.BillingEvent.Recurring; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.reporting.HistoryEntry; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import org.joda.money.CurrencyUnit; import org.joda.money.Money; import org.joda.time.DateTime; 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; @@ -44,7 +44,7 @@ public class GracePeriodTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final DateTime now = DateTime.now(UTC); private BillingEvent.OneTime onetime; diff --git a/javatests/google/registry/model/domain/LrpTokenEntityTest.java b/javatests/google/registry/model/domain/LrpTokenEntityTest.java index 620410901..925568eb3 100644 --- a/javatests/google/registry/model/domain/LrpTokenEntityTest.java +++ b/javatests/google/registry/model/domain/LrpTokenEntityTest.java @@ -25,10 +25,10 @@ import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; import google.registry.model.EntityTestCase; import google.registry.model.reporting.HistoryEntry; -import google.registry.testing.ExceptionRule; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; /** Unit tests for {@link LrpTokenEntity}. */ public class LrpTokenEntityTest extends EntityTestCase { @@ -37,7 +37,7 @@ public class LrpTokenEntityTest extends EntityTestCase { LrpTokenEntity redeemedToken; @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Before public void setUp() throws Exception { diff --git a/javatests/google/registry/model/host/HostResourceTest.java b/javatests/google/registry/model/host/HostResourceTest.java index a75957917..6b448cacf 100644 --- a/javatests/google/registry/model/host/HostResourceTest.java +++ b/javatests/google/registry/model/host/HostResourceTest.java @@ -33,18 +33,18 @@ import google.registry.model.eppcommon.Trid; import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferData.TransferServerApproveEntity; import google.registry.model.transfer.TransferStatus; -import google.registry.testing.ExceptionRule; import java.net.InetAddress; import org.joda.time.DateTime; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; /** Unit tests for {@link HostResource}. */ public class HostResourceTest extends EntityTestCase { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); final DateTime day3 = clock.nowUtc(); final DateTime day2 = day3.minusDays(1); diff --git a/javatests/google/registry/model/index/DomainApplicationIndexTest.java b/javatests/google/registry/model/index/DomainApplicationIndexTest.java index 67f4dcaad..a190e6924 100644 --- a/javatests/google/registry/model/index/DomainApplicationIndexTest.java +++ b/javatests/google/registry/model/index/DomainApplicationIndexTest.java @@ -30,17 +30,17 @@ import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; import google.registry.model.EntityTestCase; import google.registry.model.domain.DomainApplication; -import google.registry.testing.ExceptionRule; import org.joda.time.DateTime; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; /** Unit tests for {@link DomainApplicationIndex}. */ public class DomainApplicationIndexTest extends EntityTestCase { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Before public void init() throws Exception { diff --git a/javatests/google/registry/model/index/ForeignKeyIndexTest.java b/javatests/google/registry/model/index/ForeignKeyIndexTest.java index 6bf83216b..f338d5b22 100644 --- a/javatests/google/registry/model/index/ForeignKeyIndexTest.java +++ b/javatests/google/registry/model/index/ForeignKeyIndexTest.java @@ -26,16 +26,16 @@ import com.googlecode.objectify.Key; import google.registry.model.EntityTestCase; import google.registry.model.host.HostResource; import google.registry.model.index.ForeignKeyIndex.ForeignKeyHostIndex; -import google.registry.testing.ExceptionRule; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; /** Unit tests for {@link ForeignKeyIndex}. */ public class ForeignKeyIndexTest extends EntityTestCase { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Before public void setUp() throws Exception { diff --git a/javatests/google/registry/model/ofy/CommitLogBucketTest.java b/javatests/google/registry/model/ofy/CommitLogBucketTest.java index 19308c55d..01452512e 100644 --- a/javatests/google/registry/model/ofy/CommitLogBucketTest.java +++ b/javatests/google/registry/model/ofy/CommitLogBucketTest.java @@ -25,11 +25,11 @@ import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.annotation.Cache; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.InjectRule; 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; @@ -46,7 +46,7 @@ public class CommitLogBucketTest { public final InjectRule inject = new InjectRule(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); CommitLogBucket bucket; diff --git a/javatests/google/registry/model/ofy/CommitLogCheckpointTest.java b/javatests/google/registry/model/ofy/CommitLogCheckpointTest.java index 25d1edb05..b5073904d 100644 --- a/javatests/google/registry/model/ofy/CommitLogCheckpointTest.java +++ b/javatests/google/registry/model/ofy/CommitLogCheckpointTest.java @@ -20,10 +20,10 @@ import static org.joda.time.DateTimeZone.UTC; import com.google.common.collect.ImmutableMap; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -37,7 +37,7 @@ public class CommitLogCheckpointTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private static final DateTime T1 = START_OF_TIME; private static final DateTime T2 = START_OF_TIME.plusMillis(1); diff --git a/javatests/google/registry/model/ofy/OfyCommitLogTest.java b/javatests/google/registry/model/ofy/OfyCommitLogTest.java index b2d95fd67..ba4600ca6 100644 --- a/javatests/google/registry/model/ofy/OfyCommitLogTest.java +++ b/javatests/google/registry/model/ofy/OfyCommitLogTest.java @@ -30,7 +30,6 @@ import google.registry.model.BackupGroupRoot; import google.registry.model.ImmutableObject; import google.registry.model.common.EntityGroupRoot; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import google.registry.testing.TestObject.TestVirtualObject; @@ -38,6 +37,7 @@ import org.joda.time.DateTime; 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; @@ -51,7 +51,7 @@ public class OfyCommitLogTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/model/ofy/OfyFilterTest.java b/javatests/google/registry/model/ofy/OfyFilterTest.java index dbc803f60..f678fc912 100644 --- a/javatests/google/registry/model/ofy/OfyFilterTest.java +++ b/javatests/google/registry/model/ofy/OfyFilterTest.java @@ -28,11 +28,11 @@ import com.googlecode.objectify.ObjectifyService; import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Id; import google.registry.model.contact.ContactResource; -import google.registry.testing.ExceptionRule; import org.junit.After; 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; @@ -64,7 +64,7 @@ public class OfyFilterTest { } @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); /** * Key.create looks up kind metadata for the class of the object it is given. If this happens diff --git a/javatests/google/registry/model/ofy/OfyTest.java b/javatests/google/registry/model/ofy/OfyTest.java index b9a78d9f1..b2301cca5 100644 --- a/javatests/google/registry/model/ofy/OfyTest.java +++ b/javatests/google/registry/model/ofy/OfyTest.java @@ -48,7 +48,6 @@ import google.registry.model.eppcommon.Trid; import google.registry.model.reporting.HistoryEntry; import google.registry.testing.AppEngineRule; import google.registry.testing.DatastoreHelper; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.util.SystemClock; import java.util.ConcurrentModificationException; @@ -56,6 +55,7 @@ import org.joda.time.DateTime; 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; @@ -69,7 +69,7 @@ public class OfyTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); /** An entity to use in save and delete tests. */ private HistoryEntry someObject; diff --git a/javatests/google/registry/model/poll/PollMessageExternalKeyConverterTest.java b/javatests/google/registry/model/poll/PollMessageExternalKeyConverterTest.java index e293aea6d..5f804a92d 100644 --- a/javatests/google/registry/model/poll/PollMessageExternalKeyConverterTest.java +++ b/javatests/google/registry/model/poll/PollMessageExternalKeyConverterTest.java @@ -32,13 +32,13 @@ import google.registry.model.ofy.Ofy; import google.registry.model.poll.PollMessageExternalKeyConverter.PollMessageExternalKeyParseException; import google.registry.model.reporting.HistoryEntry; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import org.joda.time.DateTime; 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; @@ -55,7 +55,7 @@ public class PollMessageExternalKeyConverterTest { public InjectRule inject = new InjectRule(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); HistoryEntry historyEntry; FakeClock clock = new FakeClock(DateTime.parse("2007-07-07T01:01:01Z")); diff --git a/javatests/google/registry/model/rde/RdeNamingUtilsTest.java b/javatests/google/registry/model/rde/RdeNamingUtilsTest.java index 9534a1b34..2b885d67e 100644 --- a/javatests/google/registry/model/rde/RdeNamingUtilsTest.java +++ b/javatests/google/registry/model/rde/RdeNamingUtilsTest.java @@ -20,10 +20,10 @@ import static google.registry.model.rde.RdeMode.THIN; import static google.registry.model.rde.RdeNamingUtils.makePartialName; import static google.registry.model.rde.RdeNamingUtils.makeRydeFilename; -import google.registry.testing.ExceptionRule; import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -32,7 +32,7 @@ import org.junit.runners.JUnit4; public class RdeNamingUtilsTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testMakeRydeFilename_rdeDeposit() throws Exception { diff --git a/javatests/google/registry/model/rde/RdeRevisionTest.java b/javatests/google/registry/model/rde/RdeRevisionTest.java index 4b0137032..dec1a2778 100644 --- a/javatests/google/registry/model/rde/RdeRevisionTest.java +++ b/javatests/google/registry/model/rde/RdeRevisionTest.java @@ -23,10 +23,10 @@ import static google.registry.model.rde.RdeRevision.saveRevision; import com.google.common.base.VerifyException; import com.googlecode.objectify.VoidWork; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -38,7 +38,7 @@ public class RdeRevisionTest { public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testGetNextRevision_objectDoesntExist_returnsZero() throws Exception { diff --git a/javatests/google/registry/model/registrar/RegistrarTest.java b/javatests/google/registry/model/registrar/RegistrarTest.java index 9047135b6..24f37eea6 100644 --- a/javatests/google/registry/model/registrar/RegistrarTest.java +++ b/javatests/google/registry/model/registrar/RegistrarTest.java @@ -37,18 +37,18 @@ import google.registry.model.EntityTestCase; import google.registry.model.common.EntityGroupRoot; import google.registry.model.registrar.Registrar.State; import google.registry.model.registrar.Registrar.Type; -import google.registry.testing.ExceptionRule; import google.registry.util.CidrAddressBlock; import org.joda.money.CurrencyUnit; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; /** Unit tests for {@link Registrar}. */ public class RegistrarTest extends EntityTestCase { @Rule - public ExceptionRule thrown = new ExceptionRule(); + public ExpectedException thrown = ExpectedException.none(); private Registrar registrar; private RegistrarContact abuseAdminContact; diff --git a/javatests/google/registry/model/registry/RegistriesTest.java b/javatests/google/registry/model/registry/RegistriesTest.java index 0ee0d29d1..6b6e1e51d 100644 --- a/javatests/google/registry/model/registry/RegistriesTest.java +++ b/javatests/google/registry/model/registry/RegistriesTest.java @@ -20,9 +20,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; @@ -34,7 +34,7 @@ public class RegistriesTest { public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); @Rule - public ExceptionRule thrown = new ExceptionRule(); + public ExpectedException thrown = ExpectedException.none(); private void initTestTlds() { createTlds("foo", "a.b.c"); // Test a multipart tld. diff --git a/javatests/google/registry/model/registry/RegistryTest.java b/javatests/google/registry/model/registry/RegistryTest.java index 5f1a0405c..d46adc85d 100644 --- a/javatests/google/registry/model/registry/RegistryTest.java +++ b/javatests/google/registry/model/registry/RegistryTest.java @@ -40,18 +40,18 @@ import google.registry.model.registry.Registry.RegistryNotFoundException; import google.registry.model.registry.Registry.TldState; import google.registry.model.registry.label.PremiumList; import google.registry.model.registry.label.ReservedList; -import google.registry.testing.ExceptionRule; import java.math.BigDecimal; import org.joda.money.Money; import org.joda.time.DateTime; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; /** Unit tests for {@link Registry}. */ public class RegistryTest extends EntityTestCase { - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); Registry registry; diff --git a/javatests/google/registry/model/registry/label/PremiumListTest.java b/javatests/google/registry/model/registry/label/PremiumListTest.java index 06b87baed..f609868b5 100644 --- a/javatests/google/registry/model/registry/label/PremiumListTest.java +++ b/javatests/google/registry/model/registry/label/PremiumListTest.java @@ -26,10 +26,10 @@ import com.google.common.collect.ImmutableList; import google.registry.model.registry.Registry; import google.registry.model.registry.label.PremiumList.PremiumListRevision; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; 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; @@ -37,7 +37,7 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class PremiumListTest { - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); @Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); @Before diff --git a/javatests/google/registry/model/registry/label/PremiumListUtilsTest.java b/javatests/google/registry/model/registry/label/PremiumListUtilsTest.java index 30f3c1b03..0b8be7d04 100644 --- a/javatests/google/registry/model/registry/label/PremiumListUtilsTest.java +++ b/javatests/google/registry/model/registry/label/PremiumListUtilsTest.java @@ -47,12 +47,12 @@ import google.registry.model.registry.Registry; import google.registry.model.registry.label.PremiumList.PremiumListEntry; import google.registry.model.registry.label.PremiumList.PremiumListRevision; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import java.util.Map; import org.joda.money.Money; 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; @@ -60,7 +60,7 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class PremiumListUtilsTest { - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); @Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); @Before diff --git a/javatests/google/registry/model/registry/label/ReservedListTest.java b/javatests/google/registry/model/registry/label/ReservedListTest.java index af5214edc..f7e342a5b 100644 --- a/javatests/google/registry/model/registry/label/ReservedListTest.java +++ b/javatests/google/registry/model/registry/label/ReservedListTest.java @@ -43,13 +43,13 @@ import google.registry.model.ofy.Ofy; import google.registry.model.registry.Registry; import google.registry.model.registry.label.ReservedList.ReservedListEntry; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import org.joda.time.DateTime; 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; @@ -61,7 +61,7 @@ public class ReservedListTest { public final InjectRule inject = new InjectRule(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final AppEngineRule appEngine = AppEngineRule.builder() diff --git a/javatests/google/registry/model/server/KmsSecretRevisionTest.java b/javatests/google/registry/model/server/KmsSecretRevisionTest.java index d27505793..b0cab7adc 100644 --- a/javatests/google/registry/model/server/KmsSecretRevisionTest.java +++ b/javatests/google/registry/model/server/KmsSecretRevisionTest.java @@ -20,10 +20,10 @@ import static google.registry.testing.DatastoreHelper.persistResource; import com.google.common.base.Strings; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; 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; @@ -32,7 +32,7 @@ public class KmsSecretRevisionTest { @Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); private KmsSecretRevision secretRevision; diff --git a/javatests/google/registry/model/server/LockTest.java b/javatests/google/registry/model/server/LockTest.java index 897e3efe4..4f0273342 100644 --- a/javatests/google/registry/model/server/LockTest.java +++ b/javatests/google/registry/model/server/LockTest.java @@ -27,7 +27,6 @@ import static org.mockito.Mockito.when; import google.registry.model.ofy.Ofy; import google.registry.model.server.Lock.LockState; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import google.registry.util.RequestStatusChecker; @@ -36,6 +35,7 @@ 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.junit.runners.JUnit4; @@ -58,7 +58,7 @@ public class LockTest { public final InjectRule inject = new InjectRule(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private Optional acquire(String tld, Duration leaseLength, LockState expectedLockState) { Lock.lockMetrics = mock(LockMetrics.class); diff --git a/javatests/google/registry/model/smd/SignedMarkRevocationListTest.java b/javatests/google/registry/model/smd/SignedMarkRevocationListTest.java index e5020a897..db136d33a 100644 --- a/javatests/google/registry/model/smd/SignedMarkRevocationListTest.java +++ b/javatests/google/registry/model/smd/SignedMarkRevocationListTest.java @@ -22,11 +22,11 @@ import static org.joda.time.Duration.standardDays; import com.google.common.collect.ImmutableMap; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -40,7 +40,7 @@ public class SignedMarkRevocationListTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final FakeClock clock = new FakeClock(DateTime.parse("2013-01-01T00:00:00Z")); diff --git a/javatests/google/registry/model/tmch/ClaimsListShardTest.java b/javatests/google/registry/model/tmch/ClaimsListShardTest.java index 0b0cb3eb3..a50fb3df6 100644 --- a/javatests/google/registry/model/tmch/ClaimsListShardTest.java +++ b/javatests/google/registry/model/tmch/ClaimsListShardTest.java @@ -24,7 +24,6 @@ import com.googlecode.objectify.Key; import google.registry.model.tmch.ClaimsListShard.ClaimsListRevision; import google.registry.model.tmch.ClaimsListShard.UnshardedSaveException; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.InjectRule; import java.util.HashMap; import java.util.List; @@ -33,6 +32,7 @@ import org.joda.time.DateTime; 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; @@ -46,7 +46,7 @@ public class ClaimsListShardTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/model/translators/CommitLogRevisionsTranslatorFactoryTest.java b/javatests/google/registry/model/translators/CommitLogRevisionsTranslatorFactoryTest.java index 04472522b..f7467abbd 100644 --- a/javatests/google/registry/model/translators/CommitLogRevisionsTranslatorFactoryTest.java +++ b/javatests/google/registry/model/translators/CommitLogRevisionsTranslatorFactoryTest.java @@ -28,7 +28,6 @@ import google.registry.model.common.CrossTldSingleton; import google.registry.model.ofy.CommitLogManifest; import google.registry.model.ofy.Ofy; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import java.util.List; @@ -36,6 +35,7 @@ import org.joda.time.DateTime; 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; @@ -59,7 +59,7 @@ public class CommitLogRevisionsTranslatorFactoryTest { public final InjectRule inject = new InjectRule(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final FakeClock clock = new FakeClock(START_TIME); diff --git a/javatests/google/registry/pricing/PricingEngineProxyTest.java b/javatests/google/registry/pricing/PricingEngineProxyTest.java index 8b73b7cc9..0258e832a 100644 --- a/javatests/google/registry/pricing/PricingEngineProxyTest.java +++ b/javatests/google/registry/pricing/PricingEngineProxyTest.java @@ -28,7 +28,6 @@ import com.google.common.collect.ImmutableSortedMap; import google.registry.model.registry.Registry; import google.registry.model.registry.label.PremiumList; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.util.Clock; import org.joda.money.Money; @@ -36,6 +35,7 @@ import org.joda.time.DateTime; 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; @@ -44,7 +44,7 @@ import org.junit.runners.JUnit4; public class PricingEngineProxyTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final AppEngineRule appEngine = AppEngineRule.builder() diff --git a/javatests/google/registry/rdap/RdapSearchPatternTest.java b/javatests/google/registry/rdap/RdapSearchPatternTest.java index bdf708fad..1d94dd967 100644 --- a/javatests/google/registry/rdap/RdapSearchPatternTest.java +++ b/javatests/google/registry/rdap/RdapSearchPatternTest.java @@ -17,9 +17,9 @@ package google.registry.rdap; import static com.google.common.truth.Truth.assertThat; import google.registry.request.HttpException.UnprocessableEntityException; -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 RdapSearchPatternTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testNoWildcards_ok() throws Exception { diff --git a/javatests/google/registry/rde/EscrowTaskRunnerTest.java b/javatests/google/registry/rde/EscrowTaskRunnerTest.java index 334a8c66b..6e73f078e 100644 --- a/javatests/google/registry/rde/EscrowTaskRunnerTest.java +++ b/javatests/google/registry/rde/EscrowTaskRunnerTest.java @@ -30,7 +30,6 @@ import google.registry.rde.EscrowTaskRunner.EscrowTask; import google.registry.request.HttpException.NoContentException; import google.registry.request.HttpException.ServiceUnavailableException; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeLockHandler; import org.joda.time.DateTime; @@ -38,6 +37,7 @@ import org.joda.time.DateTimeZone; 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; @@ -46,7 +46,7 @@ import org.junit.runners.JUnit4; public class EscrowTaskRunnerTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final AppEngineRule appEngine = AppEngineRule.builder() diff --git a/javatests/google/registry/rde/GhostrydeTest.java b/javatests/google/registry/rde/GhostrydeTest.java index 339ab2755..d18ba5505 100644 --- a/javatests/google/registry/rde/GhostrydeTest.java +++ b/javatests/google/registry/rde/GhostrydeTest.java @@ -27,7 +27,6 @@ import com.google.common.io.ByteStreams; import google.registry.keyring.api.Keyring; import google.registry.rde.Ghostryde.DecodeResult; import google.registry.testing.BouncyCastleProviderRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeKeyringModule; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -43,6 +42,7 @@ import org.junit.Test; 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; /** Unit tests for {@link Ghostryde}. */ @@ -51,7 +51,7 @@ import org.junit.runner.RunWith; public class GhostrydeTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule(); diff --git a/javatests/google/registry/rde/HostResourceToXjcConverterTest.java b/javatests/google/registry/rde/HostResourceToXjcConverterTest.java index 3cded701c..e0926a291 100644 --- a/javatests/google/registry/rde/HostResourceToXjcConverterTest.java +++ b/javatests/google/registry/rde/HostResourceToXjcConverterTest.java @@ -27,7 +27,6 @@ import google.registry.model.domain.DomainResource; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.xjc.host.XjcHostStatusType; import google.registry.xjc.host.XjcHostStatusValueType; import google.registry.xjc.rdehost.XjcRdeHost; @@ -37,6 +36,7 @@ import org.joda.time.DateTime; 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; @@ -55,7 +55,7 @@ public class HostResourceToXjcConverterTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Before public void init() { diff --git a/javatests/google/registry/rde/RdeReportActionTest.java b/javatests/google/registry/rde/RdeReportActionTest.java index b66e1ac6a..816a36e54 100644 --- a/javatests/google/registry/rde/RdeReportActionTest.java +++ b/javatests/google/registry/rde/RdeReportActionTest.java @@ -49,7 +49,6 @@ import google.registry.model.registry.Registry; import google.registry.request.HttpException.InternalServerErrorException; import google.registry.testing.AppEngineRule; import google.registry.testing.BouncyCastleProviderRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeKeyringModule; import google.registry.testing.FakeResponse; @@ -66,6 +65,7 @@ import org.joda.time.DateTime; 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; import org.mockito.ArgumentCaptor; @@ -79,7 +79,7 @@ public class RdeReportActionTest { private static final ByteSource IIRDEA_GOOD_XML = RdeTestData.loadBytes("iirdea_good.xml"); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule(); @@ -182,9 +182,9 @@ public class RdeReportActionTest { @Test public void testRunWithLock_fetchFailed_throwsRuntimeException() throws Exception { - class ExpectedException extends RuntimeException {} - when(urlFetchService.fetch(any(HTTPRequest.class))).thenThrow(new ExpectedException()); - thrown.expect(ExpectedException.class); + class ExpectedThrownException extends RuntimeException {} + when(urlFetchService.fetch(any(HTTPRequest.class))).thenThrow(new ExpectedThrownException()); + thrown.expect(ExpectedThrownException.class); createAction().runWithLock(loadRdeReportCursor()); } diff --git a/javatests/google/registry/rde/RdeStagingActionTest.java b/javatests/google/registry/rde/RdeStagingActionTest.java index 0be2067bb..35ba811e7 100644 --- a/javatests/google/registry/rde/RdeStagingActionTest.java +++ b/javatests/google/registry/rde/RdeStagingActionTest.java @@ -53,7 +53,6 @@ import google.registry.model.ofy.Ofy; import google.registry.model.registry.Registry; import google.registry.request.HttpException.BadRequestException; import google.registry.request.RequestParameters; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeKeyringModule; import google.registry.testing.FakeLockHandler; @@ -93,6 +92,7 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -109,7 +109,7 @@ public class RdeStagingActionTest extends MapreduceTestCase { public final InjectRule inject = new InjectRule(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final FakeClock clock = new FakeClock(); private final FakeResponse response = new FakeResponse(); diff --git a/javatests/google/registry/rde/RdeUploadActionTest.java b/javatests/google/registry/rde/RdeUploadActionTest.java index f0a183979..790bb451d 100644 --- a/javatests/google/registry/rde/RdeUploadActionTest.java +++ b/javatests/google/registry/rde/RdeUploadActionTest.java @@ -61,7 +61,6 @@ import google.registry.request.HttpException.ServiceUnavailableException; import google.registry.request.RequestParameters; import google.registry.testing.AppEngineRule; import google.registry.testing.BouncyCastleProviderRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeKeyringModule; import google.registry.testing.FakeResponse; @@ -87,6 +86,7 @@ import org.joda.time.DateTime; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -115,7 +115,7 @@ public class RdeUploadActionTest { new GcsFilename("bucket", "tld_2010-10-17_full_S1_R1-report.xml.ghostryde"); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final SftpServerRule sftpd = new SftpServerRule(); diff --git a/javatests/google/registry/rde/imports/RdeContactReaderTest.java b/javatests/google/registry/rde/imports/RdeContactReaderTest.java index 21ad8b961..4d13b3511 100644 --- a/javatests/google/registry/rde/imports/RdeContactReaderTest.java +++ b/javatests/google/registry/rde/imports/RdeContactReaderTest.java @@ -25,7 +25,6 @@ import com.google.common.io.ByteStreams; import google.registry.config.RegistryConfig.ConfigModule; import google.registry.gcs.GcsUtils; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.xjc.JaxbFragment; import google.registry.xjc.rdecontact.XjcRdeContact; import google.registry.xjc.rdecontact.XjcRdeContactElement; @@ -39,6 +38,7 @@ import java.io.OutputStream; import java.util.NoSuchElementException; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -62,7 +62,7 @@ public class RdeContactReaderTest { @Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); /** Reads at least one result at 0 offset 1 maxResults */ @Test diff --git a/javatests/google/registry/rde/imports/RdeDomainReaderTest.java b/javatests/google/registry/rde/imports/RdeDomainReaderTest.java index 04413f63d..7ababc98c 100644 --- a/javatests/google/registry/rde/imports/RdeDomainReaderTest.java +++ b/javatests/google/registry/rde/imports/RdeDomainReaderTest.java @@ -28,7 +28,6 @@ import com.google.common.io.ByteStreams; import google.registry.config.RegistryConfig.ConfigModule; import google.registry.gcs.GcsUtils; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.xjc.JaxbFragment; import google.registry.xjc.rdedomain.XjcRdeDomain; import google.registry.xjc.rdedomain.XjcRdeDomainElement; @@ -43,6 +42,7 @@ import java.util.NoSuchElementException; 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; @@ -66,7 +66,7 @@ public class RdeDomainReaderTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Before public void before() { diff --git a/javatests/google/registry/rde/imports/RdeHostInputTest.java b/javatests/google/registry/rde/imports/RdeHostInputTest.java index 52fdb6bcd..e43b2f4dd 100644 --- a/javatests/google/registry/rde/imports/RdeHostInputTest.java +++ b/javatests/google/registry/rde/imports/RdeHostInputTest.java @@ -26,7 +26,6 @@ import com.google.common.io.ByteStreams; import google.registry.config.RegistryConfig.ConfigModule; import google.registry.gcs.GcsUtils; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -34,6 +33,7 @@ import java.util.List; import java.util.Optional; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -59,7 +59,7 @@ public class RdeHostInputTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); /** Number of shards cannot be negative */ @Test diff --git a/javatests/google/registry/rde/imports/RdeHostReaderTest.java b/javatests/google/registry/rde/imports/RdeHostReaderTest.java index cf25b8bcc..ac7e20e24 100644 --- a/javatests/google/registry/rde/imports/RdeHostReaderTest.java +++ b/javatests/google/registry/rde/imports/RdeHostReaderTest.java @@ -26,7 +26,6 @@ import com.google.common.io.ByteStreams; import google.registry.config.RegistryConfig.ConfigModule; import google.registry.gcs.GcsUtils; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.xjc.JaxbFragment; import google.registry.xjc.rdehost.XjcRdeHost; import google.registry.xjc.rdehost.XjcRdeHostElement; @@ -40,6 +39,7 @@ import java.io.OutputStream; import java.util.NoSuchElementException; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -59,7 +59,7 @@ public class RdeHostReaderTest { @Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); /** Reads at least one result at 0 offset 1 maxResults */ @Test diff --git a/javatests/google/registry/rde/imports/RdeImportUtilsTest.java b/javatests/google/registry/rde/imports/RdeImportUtilsTest.java index f2062d20b..c59fcfa63 100644 --- a/javatests/google/registry/rde/imports/RdeImportUtilsTest.java +++ b/javatests/google/registry/rde/imports/RdeImportUtilsTest.java @@ -48,7 +48,6 @@ import google.registry.model.index.ForeignKeyIndex; import google.registry.model.registrar.Registrar; import google.registry.model.registry.Registry.TldState; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.ShardableTestCase; import java.io.IOException; @@ -60,6 +59,7 @@ import org.junit.After; 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; @@ -81,7 +81,7 @@ public class RdeImportUtilsTest extends ShardableTestCase { public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final GcsUtils gcsUtils = mock(GcsUtils.class); diff --git a/javatests/google/registry/rde/imports/RdeParserTest.java b/javatests/google/registry/rde/imports/RdeParserTest.java index 5e7419770..dfe92a093 100644 --- a/javatests/google/registry/rde/imports/RdeParserTest.java +++ b/javatests/google/registry/rde/imports/RdeParserTest.java @@ -19,7 +19,6 @@ import static google.registry.rde.imports.RdeImportsTestData.loadBytes; import com.google.common.io.ByteSource; import google.registry.rde.imports.RdeParser.RdeHeader; -import google.registry.testing.ExceptionRule; import google.registry.xjc.rdecontact.XjcRdeContact; import google.registry.xjc.rdedomain.XjcRdeDomain; import google.registry.xjc.rdeeppparams.XjcRdeEppParams; @@ -34,6 +33,7 @@ import org.junit.After; 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; @@ -45,7 +45,7 @@ public class RdeParserTest { private InputStream xml; - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); private void checkHeader(RdeHeader header) { assertThat(header.getTld()).isEqualTo("test"); diff --git a/javatests/google/registry/rde/imports/XjcToDomainResourceConverterTest.java b/javatests/google/registry/rde/imports/XjcToDomainResourceConverterTest.java index 10c577ce8..3c2f7ebc8 100644 --- a/javatests/google/registry/rde/imports/XjcToDomainResourceConverterTest.java +++ b/javatests/google/registry/rde/imports/XjcToDomainResourceConverterTest.java @@ -50,7 +50,6 @@ import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferStatus; import google.registry.testing.AppEngineRule; import google.registry.testing.DeterministicStringGenerator; -import google.registry.testing.ExceptionRule; import google.registry.testing.InjectRule; import google.registry.util.StringGenerator; import google.registry.xjc.rdedomain.XjcRdeDomain; @@ -66,6 +65,7 @@ import org.joda.time.DateTime; 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; @@ -91,7 +91,7 @@ public class XjcToDomainResourceConverterTest { @Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/reporting/IcannHttpReporterTest.java b/javatests/google/registry/reporting/IcannHttpReporterTest.java index 3271ee4cf..a18e47d90 100644 --- a/javatests/google/registry/reporting/IcannHttpReporterTest.java +++ b/javatests/google/registry/reporting/IcannHttpReporterTest.java @@ -29,13 +29,13 @@ import com.google.api.client.util.Base64; import com.google.api.client.util.StringUtils; import com.google.common.io.ByteSource; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import java.io.IOException; import java.util.List; import java.util.Map; 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; @@ -51,7 +51,7 @@ public class IcannHttpReporterTest { private MockLowLevelHttpRequest mockRequest; - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); @Rule public AppEngineRule appEngineRule = new AppEngineRule.Builder().withDatastore().build(); diff --git a/javatests/google/registry/reporting/IcannReportingModuleTest.java b/javatests/google/registry/reporting/IcannReportingModuleTest.java index 2f5db3ef8..1050b8665 100644 --- a/javatests/google/registry/reporting/IcannReportingModuleTest.java +++ b/javatests/google/registry/reporting/IcannReportingModuleTest.java @@ -20,7 +20,6 @@ import static org.mockito.Mockito.when; import google.registry.reporting.IcannReportingModule.ReportType; import google.registry.request.HttpException.BadRequestException; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.util.Clock; import java.util.Optional; @@ -30,6 +29,7 @@ import org.joda.time.YearMonth; 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,7 +40,7 @@ public class IcannReportingModuleTest { HttpServletRequest req = mock(HttpServletRequest.class); Clock clock; - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); @Before public void setUp() { diff --git a/javatests/google/registry/request/JsonResponseTest.java b/javatests/google/registry/request/JsonResponseTest.java index aa86a0402..1f95d2487 100644 --- a/javatests/google/registry/request/JsonResponseTest.java +++ b/javatests/google/registry/request/JsonResponseTest.java @@ -18,12 +18,12 @@ import static com.google.common.truth.Truth.assertThat; import static google.registry.request.JsonResponse.JSON_SAFETY_PREFIX; import com.google.common.collect.ImmutableMap; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeResponse; import java.util.Map; import org.json.simple.JSONValue; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -32,7 +32,7 @@ import org.junit.runners.JUnit4; public class JsonResponseTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); FakeResponse fakeResponse = new FakeResponse(); JsonResponse jsonResponse = new JsonResponse(fakeResponse); diff --git a/javatests/google/registry/request/RequestModuleTest.java b/javatests/google/registry/request/RequestModuleTest.java index 86934fe10..cf99f0dad 100644 --- a/javatests/google/registry/request/RequestModuleTest.java +++ b/javatests/google/registry/request/RequestModuleTest.java @@ -20,9 +20,9 @@ import static google.registry.request.RequestModule.provideJsonPayload; import com.google.common.net.MediaType; import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.UnsupportedMediaTypeException; -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; @@ -31,7 +31,7 @@ import org.junit.runners.JUnit4; public final class RequestModuleTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testProvideJsonPayload() throws Exception { diff --git a/javatests/google/registry/request/RequestParametersTest.java b/javatests/google/registry/request/RequestParametersTest.java index 1da5f0534..7f0f3403f 100644 --- a/javatests/google/registry/request/RequestParametersTest.java +++ b/javatests/google/registry/request/RequestParametersTest.java @@ -28,11 +28,11 @@ import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableMap; import google.registry.request.HttpException.BadRequestException; -import google.registry.testing.ExceptionRule; import javax.servlet.http.HttpServletRequest; import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -41,7 +41,7 @@ import org.junit.runners.JUnit4; public class RequestParametersTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final HttpServletRequest req = mock(HttpServletRequest.class); diff --git a/javatests/google/registry/request/ResponseImplTest.java b/javatests/google/registry/request/ResponseImplTest.java index 001423bcd..e487ebc81 100644 --- a/javatests/google/registry/request/ResponseImplTest.java +++ b/javatests/google/registry/request/ResponseImplTest.java @@ -21,12 +21,12 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import google.registry.testing.ExceptionRule; import java.io.PrintWriter; import java.io.StringWriter; import javax.servlet.http.HttpServletResponse; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -35,7 +35,7 @@ import org.junit.runners.JUnit4; public class ResponseImplTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final HttpServletResponse rsp = mock(HttpServletResponse.class); diff --git a/javatests/google/registry/request/RouterTest.java b/javatests/google/registry/request/RouterTest.java index 090c29a23..e99848ea6 100644 --- a/javatests/google/registry/request/RouterTest.java +++ b/javatests/google/registry/request/RouterTest.java @@ -19,11 +19,11 @@ import static com.google.common.truth.Truth8.assertThat; import static google.registry.request.auth.Auth.AUTH_INTERNAL_ONLY; import com.google.common.base.Function; -import google.registry.testing.ExceptionRule; import java.util.Optional; import java.util.concurrent.Callable; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -32,7 +32,7 @@ import org.junit.runners.JUnit4; public final class RouterTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); //////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/javatests/google/registry/request/auth/RequestAuthenticatorTest.java b/javatests/google/registry/request/auth/RequestAuthenticatorTest.java index ff9be72e5..cb41aa25b 100644 --- a/javatests/google/registry/request/auth/RequestAuthenticatorTest.java +++ b/javatests/google/registry/request/auth/RequestAuthenticatorTest.java @@ -30,7 +30,6 @@ import google.registry.request.auth.RequestAuthenticator.AuthSettings; import google.registry.request.auth.RequestAuthenticator.UserPolicy; import google.registry.security.XsrfTokenManager; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeOAuthService; import google.registry.testing.FakeUserService; @@ -39,6 +38,7 @@ import javax.servlet.http.HttpServletRequest; 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; @@ -50,7 +50,7 @@ public class RequestAuthenticatorTest { public final AppEngineRule appEngine = AppEngineRule.builder().build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private static final AuthSettings AUTH_NONE = AuthSettings.create( ImmutableList.of(AuthMethod.INTERNAL), diff --git a/javatests/google/registry/request/lock/LockHandlerImplTest.java b/javatests/google/registry/request/lock/LockHandlerImplTest.java index 56c8beec5..b4799fb57 100644 --- a/javatests/google/registry/request/lock/LockHandlerImplTest.java +++ b/javatests/google/registry/request/lock/LockHandlerImplTest.java @@ -22,7 +22,6 @@ import static org.mockito.Mockito.verify; import google.registry.model.server.Lock; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import java.util.Optional; import java.util.concurrent.Callable; import javax.annotation.Nullable; @@ -30,6 +29,7 @@ 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.junit.runners.JUnit4; @@ -44,7 +44,7 @@ public final class LockHandlerImplTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private static class CountingCallable implements Callable { int numCalled = 0; diff --git a/javatests/google/registry/storage/drive/DriveConnectionTest.java b/javatests/google/registry/storage/drive/DriveConnectionTest.java index 6713353f4..ed902d457 100644 --- a/javatests/google/registry/storage/drive/DriveConnectionTest.java +++ b/javatests/google/registry/storage/drive/DriveConnectionTest.java @@ -34,12 +34,12 @@ import com.google.api.services.drive.model.File; import com.google.api.services.drive.model.ParentReference; import com.google.common.collect.ImmutableList; import com.google.common.net.MediaType; -import google.registry.testing.ExceptionRule; import java.util.Arrays; import java.util.List; 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; import org.mockito.ArgumentMatcher; @@ -49,7 +49,7 @@ import org.mockito.ArgumentMatcher; public class DriveConnectionTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final Drive drive = mock(Drive.class); private final Files files = mock(Files.class); diff --git a/javatests/google/registry/testing/ExceptionRule.java b/javatests/google/registry/testing/ExceptionRule.java deleted file mode 100644 index 3b48c5a23..000000000 --- a/javatests/google/registry/testing/ExceptionRule.java +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2017 The Nomulus Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package google.registry.testing; - -import static com.google.common.base.Preconditions.checkState; -import static com.google.common.base.Strings.nullToEmpty; -import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; - -import google.registry.flows.EppException; -import javax.annotation.Nullable; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -/** - * A test rule similar to JUnit's {@code ExpectedException} rule that does extra checking to ensure - * that {@link EppException} derivatives have EPP-compliant error messages. - */ -public class ExceptionRule implements TestRule { - - @Nullable - Class expectedExceptionClass; - - @Nullable - String expectedMessage; - - @Override - public Statement apply(final Statement base, Description description) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - try { - base.evaluate(); - if (expectedExceptionClass != null) { - throw new AssertionError(String.format( - "Expected test to throw %s%s", - expectedExceptionClass.getSimpleName(), - expectedMessage == null ? "" : (" with message: " + expectedMessage))); - } - } catch (Throwable e) { - if (expectedExceptionClass == null - || !(expectedExceptionClass.isAssignableFrom(e.getClass()) - && nullToEmpty(e.getMessage()).contains(nullToEmpty(expectedMessage)))) { - throw e; // We didn't expect this so pass it through. - } - if (e instanceof EppException) { - assertAboutEppExceptions().that((EppException) e).marshalsToXml(); - } - } - }}; - } - - public void expect(Class expectedExceptionClass) { - checkState(this.expectedExceptionClass == null, - "Don't use multiple `thrown.expect()` statements in your test."); - this.expectedExceptionClass = expectedExceptionClass; - } - - public void expectMessage(String expectedMessage) { - this.expectedMessage = expectedMessage; - } -} diff --git a/javatests/google/registry/tldconfig/idn/IdnTableTest.java b/javatests/google/registry/tldconfig/idn/IdnTableTest.java index a23b626c0..9a48fca52 100644 --- a/javatests/google/registry/tldconfig/idn/IdnTableTest.java +++ b/javatests/google/registry/tldconfig/idn/IdnTableTest.java @@ -17,11 +17,11 @@ package google.registry.tldconfig.idn; import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.ImmutableList; -import google.registry.testing.ExceptionRule; import java.net.URI; import java.util.Optional; 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 IdnTableTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testDigits() { diff --git a/javatests/google/registry/tmch/LordnLogTest.java b/javatests/google/registry/tmch/LordnLogTest.java index 48e51c438..df1766f90 100644 --- a/javatests/google/registry/tmch/LordnLogTest.java +++ b/javatests/google/registry/tmch/LordnLogTest.java @@ -17,12 +17,12 @@ package google.registry.tmch; import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.ImmutableList; -import google.registry.testing.ExceptionRule; import google.registry.tmch.LordnLog.Result; import java.util.Map.Entry; import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -31,7 +31,7 @@ import org.junit.runners.JUnit4; public class LordnLogTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); public static final ImmutableList EXAMPLE_FROM_RFC = ImmutableList.of( diff --git a/javatests/google/registry/tmch/LordnTaskTest.java b/javatests/google/registry/tmch/LordnTaskTest.java index 6715574e4..3c4ce60c7 100644 --- a/javatests/google/registry/tmch/LordnTaskTest.java +++ b/javatests/google/registry/tmch/LordnTaskTest.java @@ -40,7 +40,6 @@ import google.registry.model.domain.launch.LaunchNotice; import google.registry.model.ofy.Ofy; import google.registry.model.registrar.Registrar.Type; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import google.registry.testing.TaskQueueHelper.TaskMatcher; @@ -50,6 +49,7 @@ import org.joda.time.DateTime; 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; @@ -66,7 +66,7 @@ public class LordnTaskTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/tmch/NordnUploadActionTest.java b/javatests/google/registry/tmch/NordnUploadActionTest.java index 11d5a6d82..e91a82b13 100644 --- a/javatests/google/registry/tmch/NordnUploadActionTest.java +++ b/javatests/google/registry/tmch/NordnUploadActionTest.java @@ -45,7 +45,6 @@ import google.registry.model.domain.launch.LaunchNotice; import google.registry.model.ofy.Ofy; import google.registry.model.registry.Registry; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import google.registry.testing.TaskQueueHelper.TaskMatcher; @@ -56,6 +55,7 @@ import org.joda.time.DateTime; 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.ArgumentCaptor; import org.mockito.Captor; @@ -88,7 +88,7 @@ public class NordnUploadActionTest { public final InjectRule inject = new InjectRule(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Mock private URLFetchService fetchService; diff --git a/javatests/google/registry/tmch/NordnVerifyActionTest.java b/javatests/google/registry/tmch/NordnVerifyActionTest.java index e6406166f..31f5d441a 100644 --- a/javatests/google/registry/tmch/NordnVerifyActionTest.java +++ b/javatests/google/registry/tmch/NordnVerifyActionTest.java @@ -34,13 +34,13 @@ import com.google.appengine.api.urlfetch.URLFetchService; import google.registry.model.registry.Registry; import google.registry.request.HttpException.ConflictException; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeResponse; import java.net.URL; import java.util.Optional; 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.ArgumentCaptor; import org.mockito.Captor; @@ -88,7 +88,7 @@ public class NordnVerifyActionTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Mock private URLFetchService fetchService; diff --git a/javatests/google/registry/tmch/SmdrlCsvParserTest.java b/javatests/google/registry/tmch/SmdrlCsvParserTest.java index d66d78201..e27c0c9b6 100644 --- a/javatests/google/registry/tmch/SmdrlCsvParserTest.java +++ b/javatests/google/registry/tmch/SmdrlCsvParserTest.java @@ -23,11 +23,11 @@ import com.google.common.collect.ImmutableList; import com.google.common.io.CharSource; import google.registry.model.smd.SignedMarkRevocationList; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -40,7 +40,7 @@ public class SmdrlCsvParserTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final FakeClock clock = new FakeClock(); diff --git a/javatests/google/registry/tmch/TmchActionTestCase.java b/javatests/google/registry/tmch/TmchActionTestCase.java index b91ece3ae..5de75ae0e 100644 --- a/javatests/google/registry/tmch/TmchActionTestCase.java +++ b/javatests/google/registry/tmch/TmchActionTestCase.java @@ -23,11 +23,11 @@ import com.google.appengine.api.urlfetch.HTTPResponse; import com.google.appengine.api.urlfetch.URLFetchService; import google.registry.testing.AppEngineRule; import google.registry.testing.BouncyCastleProviderRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import org.junit.Before; import org.junit.Rule; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; @@ -51,7 +51,7 @@ public class TmchActionTestCase { public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/tmch/TmchCertificateAuthorityTest.java b/javatests/google/registry/tmch/TmchCertificateAuthorityTest.java index fbad7121c..c37107f29 100644 --- a/javatests/google/registry/tmch/TmchCertificateAuthorityTest.java +++ b/javatests/google/registry/tmch/TmchCertificateAuthorityTest.java @@ -24,7 +24,6 @@ import static google.registry.util.X509Utils.loadCertificate; import google.registry.model.tmch.TmchCrl; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import java.security.SignatureException; @@ -35,6 +34,7 @@ import org.joda.time.DateTime; 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; @@ -51,7 +51,7 @@ public class TmchCertificateAuthorityTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/tmch/TmchXmlSignatureTest.java b/javatests/google/registry/tmch/TmchXmlSignatureTest.java index 431109b49..4ec76676d 100644 --- a/javatests/google/registry/tmch/TmchXmlSignatureTest.java +++ b/javatests/google/registry/tmch/TmchXmlSignatureTest.java @@ -21,7 +21,6 @@ import static google.registry.tmch.TmchTestData.loadSmd; import google.registry.config.RegistryConfig.ConfigModule.TmchCaMode; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.InjectRule; import google.registry.tmch.TmchXmlSignature.CertificateSignatureException; @@ -33,6 +32,7 @@ import org.joda.time.DateTime; 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; @@ -50,7 +50,7 @@ public class TmchXmlSignatureTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/tools/AuthModuleTest.java b/javatests/google/registry/tools/AuthModuleTest.java index 9d501c7e4..d180432a7 100644 --- a/javatests/google/registry/tools/AuthModuleTest.java +++ b/javatests/google/registry/tools/AuthModuleTest.java @@ -26,11 +26,11 @@ import com.google.api.client.json.jackson2.JacksonFactory; import com.google.api.client.util.store.AbstractDataStoreFactory; import com.google.api.client.util.store.DataStore; import com.google.common.collect.ImmutableSet; -import google.registry.testing.ExceptionRule; import java.io.IOException; import java.io.Serializable; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -62,7 +62,7 @@ public class AuthModuleTest { } } - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); @Test public void test_clientScopeQualifier() { diff --git a/javatests/google/registry/tools/CommandTestCase.java b/javatests/google/registry/tools/CommandTestCase.java index b33acc0b1..70ae53864 100644 --- a/javatests/google/registry/tools/CommandTestCase.java +++ b/javatests/google/registry/tools/CommandTestCase.java @@ -31,7 +31,6 @@ import com.google.common.reflect.TypeToken; import google.registry.model.poll.PollMessage; import google.registry.testing.AppEngineRule; import google.registry.testing.CertificateSamples; -import google.registry.testing.ExceptionRule; import google.registry.tools.params.ParameterFactory; import java.io.ByteArrayOutputStream; import java.io.File; @@ -40,6 +39,7 @@ import java.io.PrintStream; import java.util.List; import org.junit.Before; import org.junit.Rule; +import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; @@ -64,7 +64,7 @@ public abstract class CommandTestCase { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public TemporaryFolder tmpDir = new TemporaryFolder(); diff --git a/javatests/google/registry/tools/MutatingCommandTest.java b/javatests/google/registry/tools/MutatingCommandTest.java index 450757f07..a56d55e7c 100644 --- a/javatests/google/registry/tools/MutatingCommandTest.java +++ b/javatests/google/registry/tools/MutatingCommandTest.java @@ -27,12 +27,12 @@ import static org.joda.time.DateTimeZone.UTC; import google.registry.model.host.HostResource; import google.registry.model.registrar.Registrar; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import java.util.Arrays; import org.joda.time.DateTime; 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; @@ -46,7 +46,7 @@ public class MutatingCommandTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); Registrar registrar1; Registrar registrar2; diff --git a/javatests/google/registry/tools/RegistryToolEnvironmentTest.java b/javatests/google/registry/tools/RegistryToolEnvironmentTest.java index 0dc8eeb84..35494f5e3 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 ExceptionRule thrown = new ExceptionRule(); + public ExpectedException thrown = ExpectedException.none(); @Test public void testGet_withoutSetup_throws() throws Exception { diff --git a/javatests/google/registry/tools/params/DateParameterTest.java b/javatests/google/registry/tools/params/DateParameterTest.java index 2fbd1e757..b811a1939 100644 --- a/javatests/google/registry/tools/params/DateParameterTest.java +++ b/javatests/google/registry/tools/params/DateParameterTest.java @@ -16,10 +16,10 @@ package google.registry.tools.params; import static com.google.common.truth.Truth.assertThat; -import google.registry.testing.ExceptionRule; import org.joda.time.DateTime; 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 DateParameterTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final DateParameter instance = new DateParameter(); diff --git a/javatests/google/registry/tools/params/DateTimeParameterTest.java b/javatests/google/registry/tools/params/DateTimeParameterTest.java index bf551862a..2f68bdf3d 100644 --- a/javatests/google/registry/tools/params/DateTimeParameterTest.java +++ b/javatests/google/registry/tools/params/DateTimeParameterTest.java @@ -18,10 +18,10 @@ import static com.google.common.truth.Truth.assertThat; import static org.joda.time.DateTimeZone.UTC; import com.beust.jcommander.ParameterException; -import google.registry.testing.ExceptionRule; import org.joda.time.DateTime; 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 DateTimeParameterTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final DateTimeParameter instance = new DateTimeParameter(); diff --git a/javatests/google/registry/tools/params/DurationParameterTest.java b/javatests/google/registry/tools/params/DurationParameterTest.java index 213b02ecd..3619378c9 100644 --- a/javatests/google/registry/tools/params/DurationParameterTest.java +++ b/javatests/google/registry/tools/params/DurationParameterTest.java @@ -17,11 +17,11 @@ package google.registry.tools.params; import static com.google.common.truth.Truth.assertThat; import com.beust.jcommander.ParameterException; -import google.registry.testing.ExceptionRule; import org.joda.time.Duration; import org.joda.time.Period; 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 DurationParameterTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final DurationParameter instance = new DurationParameter(); diff --git a/javatests/google/registry/tools/params/EnumParameterTest.java b/javatests/google/registry/tools/params/EnumParameterTest.java index 2ec1e3858..bc836aca4 100644 --- a/javatests/google/registry/tools/params/EnumParameterTest.java +++ b/javatests/google/registry/tools/params/EnumParameterTest.java @@ -17,9 +17,9 @@ package google.registry.tools.params; import static com.google.common.truth.Truth.assertThat; import google.registry.model.registry.Registry.TldState; -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 EnumParameterTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); // There's no additional functionality exposed by this (or any other) EnumParameter, but using // this in the test as EnumParameter is abstract. diff --git a/javatests/google/registry/tools/params/IntervalParameterTest.java b/javatests/google/registry/tools/params/IntervalParameterTest.java index 9902d574f..ba76d7378 100644 --- a/javatests/google/registry/tools/params/IntervalParameterTest.java +++ b/javatests/google/registry/tools/params/IntervalParameterTest.java @@ -17,11 +17,11 @@ package google.registry.tools.params; import static com.google.common.truth.Truth.assertThat; import com.beust.jcommander.ParameterException; -import google.registry.testing.ExceptionRule; import org.joda.time.DateTime; import org.joda.time.Interval; 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 IntervalParameterTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final IntervalParameter instance = new IntervalParameter(); diff --git a/javatests/google/registry/tools/params/KeyValueMapParameterTest.java b/javatests/google/registry/tools/params/KeyValueMapParameterTest.java index 8a30357fc..605475b3f 100644 --- a/javatests/google/registry/tools/params/KeyValueMapParameterTest.java +++ b/javatests/google/registry/tools/params/KeyValueMapParameterTest.java @@ -17,7 +17,6 @@ package google.registry.tools.params; import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.ImmutableMap; -import google.registry.testing.ExceptionRule; import google.registry.tools.params.KeyValueMapParameter.CurrencyUnitToStringMap; import google.registry.tools.params.KeyValueMapParameter.StringToIntegerMap; import google.registry.tools.params.KeyValueMapParameter.StringToStringMap; @@ -25,6 +24,7 @@ import org.joda.money.CurrencyUnit; import org.joda.money.IllegalCurrencyException; 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 @@ import org.junit.runners.JUnit4; public class KeyValueMapParameterTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final StringToStringMap stringToStringInstance = new StringToStringMap(); private final StringToIntegerMap stringToIntegerInstance = new StringToIntegerMap(); diff --git a/javatests/google/registry/tools/params/MoneyParameterTest.java b/javatests/google/registry/tools/params/MoneyParameterTest.java index 28b66d3e8..354955267 100644 --- a/javatests/google/registry/tools/params/MoneyParameterTest.java +++ b/javatests/google/registry/tools/params/MoneyParameterTest.java @@ -17,10 +17,10 @@ package google.registry.tools.params; import static com.google.common.truth.Truth.assertThat; import com.beust.jcommander.ParameterException; -import google.registry.testing.ExceptionRule; import org.joda.money.Money; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -29,7 +29,7 @@ import org.junit.runners.JUnit4; public class MoneyParameterTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final MoneyParameter instance = new MoneyParameter(); diff --git a/javatests/google/registry/tools/params/PathParameterTest.java b/javatests/google/registry/tools/params/PathParameterTest.java index 2cd457322..d391130a9 100644 --- a/javatests/google/registry/tools/params/PathParameterTest.java +++ b/javatests/google/registry/tools/params/PathParameterTest.java @@ -23,7 +23,6 @@ import static org.junit.Assume.assumeThat; import static org.junit.Assume.assumeTrue; import com.beust.jcommander.ParameterException; -import google.registry.testing.ExceptionRule; import java.io.File; import java.nio.file.FileSystemNotFoundException; import java.nio.file.Files; @@ -32,6 +31,7 @@ import java.nio.file.Paths; import java.nio.file.attribute.PosixFilePermissions; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -41,7 +41,7 @@ import org.junit.runners.JUnit4; public class PathParameterTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final TemporaryFolder folder = new TemporaryFolder(); diff --git a/javatests/google/registry/tools/params/PhoneNumberParameterTest.java b/javatests/google/registry/tools/params/PhoneNumberParameterTest.java index fc899ea73..bfc225fc9 100644 --- a/javatests/google/registry/tools/params/PhoneNumberParameterTest.java +++ b/javatests/google/registry/tools/params/PhoneNumberParameterTest.java @@ -16,9 +16,9 @@ package google.registry.tools.params; import static com.google.common.truth.Truth8.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 PhoneNumberParameterTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final OptionalPhoneNumberParameter instance = new OptionalPhoneNumberParameter(); diff --git a/javatests/google/registry/tools/params/YearMonthParameterTest.java b/javatests/google/registry/tools/params/YearMonthParameterTest.java index 1e32a6d96..72ad3df9f 100644 --- a/javatests/google/registry/tools/params/YearMonthParameterTest.java +++ b/javatests/google/registry/tools/params/YearMonthParameterTest.java @@ -17,10 +17,10 @@ package google.registry.tools.params; import static com.google.common.truth.Truth.assertThat; import com.beust.jcommander.ParameterException; -import google.registry.testing.ExceptionRule; import org.joda.time.YearMonth; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -29,7 +29,7 @@ import org.junit.runners.JUnit4; public class YearMonthParameterTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private final YearMonthParameter instance = new YearMonthParameter(); diff --git a/javatests/google/registry/tools/server/CreateGroupsActionTest.java b/javatests/google/registry/tools/server/CreateGroupsActionTest.java index ad8986c7d..075245b33 100644 --- a/javatests/google/registry/tools/server/CreateGroupsActionTest.java +++ b/javatests/google/registry/tools/server/CreateGroupsActionTest.java @@ -28,11 +28,11 @@ import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.InternalServerErrorException; import google.registry.request.Response; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.InjectRule; import java.util.Optional; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -48,7 +48,7 @@ public class CreateGroupsActionTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/tools/server/CreatePremiumListActionTest.java b/javatests/google/registry/tools/server/CreatePremiumListActionTest.java index 849f3ce81..3af582c63 100644 --- a/javatests/google/registry/tools/server/CreatePremiumListActionTest.java +++ b/javatests/google/registry/tools/server/CreatePremiumListActionTest.java @@ -25,12 +25,12 @@ import static javax.servlet.http.HttpServletResponse.SC_OK; import google.registry.model.registry.Registry; import google.registry.model.registry.label.PremiumList; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeJsonResponse; import org.joda.money.Money; 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,7 +41,7 @@ import org.junit.runners.JUnit4; public class CreatePremiumListActionTest { @Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); CreatePremiumListAction action; FakeJsonResponse response; diff --git a/javatests/google/registry/tools/server/DeleteEntityActionTest.java b/javatests/google/registry/tools/server/DeleteEntityActionTest.java index 4dd6c6738..880e4dcf1 100644 --- a/javatests/google/registry/tools/server/DeleteEntityActionTest.java +++ b/javatests/google/registry/tools/server/DeleteEntityActionTest.java @@ -24,11 +24,11 @@ import com.google.appengine.api.datastore.KeyFactory; import google.registry.model.registry.label.ReservedList; import google.registry.request.HttpException.BadRequestException; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeResponse; 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,7 +40,7 @@ public class DeleteEntityActionTest { public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); FakeResponse response = new FakeResponse(); DeleteEntityAction action = new DeleteEntityAction(); diff --git a/javatests/google/registry/tools/server/ListActionTestCase.java b/javatests/google/registry/tools/server/ListActionTestCase.java index 1eb37687a..ee0809004 100644 --- a/javatests/google/registry/tools/server/ListActionTestCase.java +++ b/javatests/google/registry/tools/server/ListActionTestCase.java @@ -18,12 +18,12 @@ import static com.google.common.truth.Truth.assertThat; import static javax.servlet.http.HttpServletResponse.SC_OK; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeJsonResponse; import java.util.List; import java.util.Optional; import java.util.regex.Pattern; import org.junit.Rule; +import org.junit.rules.ExpectedException; /** * Base class for tests of list actions. @@ -36,7 +36,7 @@ public class ListActionTestCase { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private FakeJsonResponse response; diff --git a/javatests/google/registry/tools/server/UpdatePremiumListActionTest.java b/javatests/google/registry/tools/server/UpdatePremiumListActionTest.java index c8a6bac1e..104028d2e 100644 --- a/javatests/google/registry/tools/server/UpdatePremiumListActionTest.java +++ b/javatests/google/registry/tools/server/UpdatePremiumListActionTest.java @@ -24,12 +24,12 @@ import static javax.servlet.http.HttpServletResponse.SC_OK; import google.registry.model.registry.Registry; import google.registry.model.registry.label.PremiumList; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeJsonResponse; import org.joda.money.Money; 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; @@ -45,7 +45,7 @@ public class UpdatePremiumListActionTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); UpdatePremiumListAction action; FakeJsonResponse response; diff --git a/javatests/google/registry/ui/forms/FormFieldExceptionTest.java b/javatests/google/registry/ui/forms/FormFieldExceptionTest.java index 93ee5d481..df22b18b0 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 ExceptionRule thrown = new ExceptionRule(); + public ExpectedException thrown = ExpectedException.none(); @Test public void testGetFieldName_multiplePropagations_joinsUsingJsonNotation() throws Exception { diff --git a/javatests/google/registry/ui/server/registrar/SendEmailUtilsTest.java b/javatests/google/registry/ui/server/registrar/SendEmailUtilsTest.java index a1b7eddf1..fea751085 100644 --- a/javatests/google/registry/ui/server/registrar/SendEmailUtilsTest.java +++ b/javatests/google/registry/ui/server/registrar/SendEmailUtilsTest.java @@ -25,7 +25,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableList; -import google.registry.testing.ExceptionRule; import google.registry.testing.InjectRule; import google.registry.util.SendEmailService; import java.util.Properties; @@ -38,6 +37,7 @@ import javax.mail.internet.MimeMessage; 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; @@ -46,7 +46,7 @@ import org.junit.runners.JUnit4; public class SendEmailUtilsTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/ui/server/registrar/SessionUtilsTest.java b/javatests/google/registry/ui/server/registrar/SessionUtilsTest.java index 4753ae5f0..eabe3493e 100644 --- a/javatests/google/registry/ui/server/registrar/SessionUtilsTest.java +++ b/javatests/google/registry/ui/server/registrar/SessionUtilsTest.java @@ -32,7 +32,6 @@ import com.google.common.testing.TestLogHandler; import google.registry.model.registrar.RegistrarContact; import google.registry.request.auth.UserAuthInfo; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.InjectRule; import java.util.logging.Level; import javax.servlet.http.HttpServletRequest; @@ -42,6 +41,7 @@ import org.junit.After; 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; @@ -51,7 +51,7 @@ public class SessionUtilsTest { @Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/util/CollectionUtilsTest.java b/javatests/google/registry/util/CollectionUtilsTest.java index 944419ea1..a60e56447 100644 --- a/javatests/google/registry/util/CollectionUtilsTest.java +++ b/javatests/google/registry/util/CollectionUtilsTest.java @@ -21,10 +21,10 @@ import static google.registry.util.CollectionUtils.partitionMap; import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import google.registry.testing.ExceptionRule; import java.util.Map; 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 @@ import org.junit.runners.JUnit4; public class CollectionUtilsTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testNullToEmptyMap_leavesNonNullAlone() { diff --git a/javatests/google/registry/util/DateTimeUtilsTest.java b/javatests/google/registry/util/DateTimeUtilsTest.java index e02bff6e2..a877e2b55 100644 --- a/javatests/google/registry/util/DateTimeUtilsTest.java +++ b/javatests/google/registry/util/DateTimeUtilsTest.java @@ -24,10 +24,10 @@ import static google.registry.util.DateTimeUtils.latestOf; import static google.registry.util.DateTimeUtils.leapSafeAddYears; import com.google.common.collect.ImmutableList; -import google.registry.testing.ExceptionRule; import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -39,7 +39,7 @@ public class DateTimeUtilsTest { START_OF_TIME, START_OF_TIME.plusDays(1), END_OF_TIME, END_OF_TIME); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testSuccess_earliestOf() { diff --git a/javatests/google/registry/util/DomainNameUtilsTest.java b/javatests/google/registry/util/DomainNameUtilsTest.java index fc0bd4b97..a8f9daa9e 100644 --- a/javatests/google/registry/util/DomainNameUtilsTest.java +++ b/javatests/google/registry/util/DomainNameUtilsTest.java @@ -17,9 +17,9 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; import static google.registry.util.DomainNameUtils.canonicalizeDomainName; -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 DomainNameUtilsTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testCanonicalizeDomainName() throws Exception { diff --git a/javatests/google/registry/util/HexDumperTest.java b/javatests/google/registry/util/HexDumperTest.java index fe9d48f69..00dfbae3c 100644 --- a/javatests/google/registry/util/HexDumperTest.java +++ b/javatests/google/registry/util/HexDumperTest.java @@ -17,10 +17,10 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; -import google.registry.testing.ExceptionRule; import java.io.StringWriter; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -29,7 +29,7 @@ import org.junit.runners.JUnit4; public class HexDumperTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testEmpty() throws Exception { diff --git a/javatests/google/registry/util/PosixTarHeaderTest.java b/javatests/google/registry/util/PosixTarHeaderTest.java index 03fdd1859..6785510ff 100644 --- a/javatests/google/registry/util/PosixTarHeaderTest.java +++ b/javatests/google/registry/util/PosixTarHeaderTest.java @@ -20,7 +20,6 @@ import static com.google.common.truth.Truth.assertWithMessage; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.testing.EqualsTester; -import google.registry.testing.ExceptionRule; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; @@ -30,6 +29,7 @@ import org.joda.time.DateTime; import org.joda.time.format.ISODateTimeFormat; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -38,7 +38,7 @@ import org.junit.runners.JUnit4; public class PosixTarHeaderTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testGnuTarBlob() throws Exception { diff --git a/javatests/google/registry/util/RetrierTest.java b/javatests/google/registry/util/RetrierTest.java index d6ef8b9c0..3f1984df2 100644 --- a/javatests/google/registry/util/RetrierTest.java +++ b/javatests/google/registry/util/RetrierTest.java @@ -16,13 +16,13 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeSleeper; import google.registry.util.Retrier.FailureReporter; import java.util.concurrent.Callable; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -31,7 +31,7 @@ import org.junit.runners.JUnit4; public class RetrierTest { @Rule - public ExceptionRule thrown = new ExceptionRule(); + public ExpectedException thrown = ExpectedException.none(); Retrier retrier = new Retrier(new FakeSleeper(new FakeClock()), 3); diff --git a/javatests/google/registry/util/SerializeUtilsTest.java b/javatests/google/registry/util/SerializeUtilsTest.java index 5aaf424c7..412807086 100644 --- a/javatests/google/registry/util/SerializeUtilsTest.java +++ b/javatests/google/registry/util/SerializeUtilsTest.java @@ -18,9 +18,9 @@ import static com.google.common.truth.Truth.assertThat; import static google.registry.util.SerializeUtils.deserialize; import static google.registry.util.SerializeUtils.serialize; -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; @@ -36,7 +36,7 @@ public class SerializeUtilsTest { } @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testSerialize_nullValue_returnsNull() throws Exception { diff --git a/javatests/google/registry/util/SqlTemplateTest.java b/javatests/google/registry/util/SqlTemplateTest.java index 9a5622d75..2d346ef73 100644 --- a/javatests/google/registry/util/SqlTemplateTest.java +++ b/javatests/google/registry/util/SqlTemplateTest.java @@ -16,9 +16,9 @@ package google.registry.util; 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 SqlTemplateTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testFillSqlTemplate() throws Exception { diff --git a/javatests/google/registry/util/TaskEnqueuerTest.java b/javatests/google/registry/util/TaskEnqueuerTest.java index 461096ad1..8a9d32c2e 100644 --- a/javatests/google/registry/util/TaskEnqueuerTest.java +++ b/javatests/google/registry/util/TaskEnqueuerTest.java @@ -27,12 +27,12 @@ import com.google.appengine.api.taskqueue.TaskOptions; import com.google.appengine.api.taskqueue.TransientFailureException; import com.google.common.collect.ImmutableList; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeSleeper; import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -43,7 +43,7 @@ public final class TaskEnqueuerTest { private static final int MAX_RETRIES = 3; @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final AppEngineRule appEngine = AppEngineRule.builder() diff --git a/javatests/google/registry/util/TeeOutputStreamTest.java b/javatests/google/registry/util/TeeOutputStreamTest.java index 2bcf2f3b1..0a6920d4d 100644 --- a/javatests/google/registry/util/TeeOutputStreamTest.java +++ b/javatests/google/registry/util/TeeOutputStreamTest.java @@ -19,11 +19,11 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Arrays.asList; import com.google.common.collect.ImmutableSet; -import google.registry.testing.ExceptionRule; import java.io.ByteArrayOutputStream; import java.io.OutputStream; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -32,7 +32,7 @@ import org.junit.runners.JUnit4; public class TeeOutputStreamTest { @Rule - public ExceptionRule thrown = new ExceptionRule(); + public ExpectedException thrown = ExpectedException.none(); private final ByteArrayOutputStream outputA = new ByteArrayOutputStream(); private final ByteArrayOutputStream outputB = new ByteArrayOutputStream(); diff --git a/javatests/google/registry/util/TypeUtilsTest.java b/javatests/google/registry/util/TypeUtilsTest.java index f8d15a9e8..6f9b3995c 100644 --- a/javatests/google/registry/util/TypeUtilsTest.java +++ b/javatests/google/registry/util/TypeUtilsTest.java @@ -16,11 +16,11 @@ package google.registry.util; import static com.google.common.truth.Truth.assertThat; -import google.registry.testing.ExceptionRule; import java.io.Serializable; import java.util.ArrayList; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -29,7 +29,7 @@ import org.junit.runners.JUnit4; public class TypeUtilsTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void test_getClassFromString_validClass() { diff --git a/javatests/google/registry/util/UrlFetchUtilsTest.java b/javatests/google/registry/util/UrlFetchUtilsTest.java index 881fb4b95..2621fa510 100644 --- a/javatests/google/registry/util/UrlFetchUtilsTest.java +++ b/javatests/google/registry/util/UrlFetchUtilsTest.java @@ -30,7 +30,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import com.google.appengine.api.urlfetch.HTTPHeader; import com.google.appengine.api.urlfetch.HTTPRequest; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.InjectRule; import java.util.Arrays; import java.util.List; @@ -38,6 +37,7 @@ import java.util.Random; 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; import org.mockito.ArgumentCaptor; @@ -51,7 +51,7 @@ public class UrlFetchUtilsTest { .build(); @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Rule public final InjectRule inject = new InjectRule(); diff --git a/javatests/google/registry/whois/WhoisReaderTest.java b/javatests/google/registry/whois/WhoisReaderTest.java index d30636782..591db9e00 100644 --- a/javatests/google/registry/whois/WhoisReaderTest.java +++ b/javatests/google/registry/whois/WhoisReaderTest.java @@ -20,13 +20,13 @@ import static google.registry.testing.LogsSubject.assertAboutLogs; import com.google.common.testing.TestLogHandler; import google.registry.testing.AppEngineRule; -import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import java.io.StringReader; import java.util.logging.Level; 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; @@ -36,7 +36,7 @@ public class WhoisReaderTest { @Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); - @Rule public final ExceptionRule thrown = new ExceptionRule(); + @Rule public final ExpectedException thrown = ExpectedException.none(); private final FakeClock clock = new FakeClock(); private final TestLogHandler testLogHandler = new TestLogHandler(); diff --git a/javatests/google/registry/xjc/XjcObjectTest.java b/javatests/google/registry/xjc/XjcObjectTest.java index cd917f199..dbaac35bc 100644 --- a/javatests/google/registry/xjc/XjcObjectTest.java +++ b/javatests/google/registry/xjc/XjcObjectTest.java @@ -22,7 +22,6 @@ import static java.nio.charset.StandardCharsets.UTF_16; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.re2j.Pattern; -import google.registry.testing.ExceptionRule; import google.registry.xjc.rde.XjcRdeDeposit; import google.registry.xjc.rde.XjcRdeDepositTypeType; import google.registry.xjc.rdecontact.XjcRdeContact; @@ -30,6 +29,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -38,7 +38,7 @@ import org.junit.runners.JUnit4; public class XjcObjectTest { @Rule - public final ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private static final String RDE_DEPOSIT_FULL = readResourceUtf8(XjcObjectTest.class, "testdata/rde_deposit_full.xml"); diff --git a/javatests/google/registry/xjc/XmlTestdataTest.java b/javatests/google/registry/xjc/XmlTestdataTest.java index 7c521872f..ffa7bfbe1 100644 --- a/javatests/google/registry/xjc/XmlTestdataTest.java +++ b/javatests/google/registry/xjc/XmlTestdataTest.java @@ -18,7 +18,6 @@ import static com.google.common.truth.Truth.assertThat; import static google.registry.xjc.XjcXmlTransformer.unmarshal; import static java.nio.charset.StandardCharsets.UTF_8; -import google.registry.testing.ExceptionRule; import google.registry.testing.TestDataHelper; import google.registry.xjc.epp.XjcEpp; import google.registry.xjc.rde.XjcRdeDeposit; @@ -27,6 +26,7 @@ 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 ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); private static class Example { final ByteArrayInputStream xmlStream; diff --git a/javatests/google/registry/xml/DateAdapterTest.java b/javatests/google/registry/xml/DateAdapterTest.java index dbc82b9ef..7b2b8c7c3 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 ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testMarshal() { diff --git a/javatests/google/registry/xml/UtcDateTimeAdapterTest.java b/javatests/google/registry/xml/UtcDateTimeAdapterTest.java index 8913ba728..a75cabb5f 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 ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); @Test public void testMarshal() { diff --git a/javatests/google/registry/xml/XmlTestUtilsTest.java b/javatests/google/registry/xml/XmlTestUtilsTest.java index cccf07a6a..cd0ef3e85 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.testing.TestDataHelper.loadFile; 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 ExceptionRule thrown = new ExceptionRule(); + public final ExpectedException thrown = ExpectedException.none(); void runTest(String file1, String file2) throws Exception { assertXmlEquals(loadFile(getClass(), file1), loadFile(getClass(), file2));