mirror of
https://github.com/google/nomulus.git
synced 2025-08-06 01:35:17 +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
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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<Void> {
|
||||
int numCalled = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue