mirror of
https://github.com/google/nomulus.git
synced 2025-08-05 17:28:25 +02:00
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:
parent
c5515ab4e6
commit
03c782f38e
142 changed files with 285 additions and 359 deletions
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue