Replace ExceptionRule with ExpectedException

This is in preparation for running the automatic refactoring script that
will replace all ExpectedExceptions with use of JUnit 4.13's assertThrows/
expectThrows.

Note that I have recorded the callsites of assertions about EppExceptions
being marshallable and will edit those specific assertions back in after
running the automatic refactoring script (which do not understand these).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178812403
This commit is contained in:
mcilwain 2017-12-12 14:10:10 -08:00 committed by jianglai
parent c5515ab4e6
commit 03c782f38e
142 changed files with 285 additions and 359 deletions

View file

@ -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() {

View file

@ -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<C extends Command> {
.build();
@Rule
public final ExceptionRule thrown = new ExceptionRule();
public final ExpectedException thrown = ExpectedException.none();
@Rule
public TemporaryFolder tmpDir = new TemporaryFolder();

View file

@ -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;

View file

@ -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 {

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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.

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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;

View file

@ -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();

View file

@ -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;

View file

@ -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;