From 2144d2a8d876c947e7490c70229a70d31b9e2ca9 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Fri, 23 Jul 2021 14:31:17 -0500 Subject: [PATCH] Migrate AttachmentControllerTest to JUnit 5 --- .../controllers/AttachmentControllerTest.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/AttachmentControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/AttachmentControllerTest.java index d539cfacd..0985f8310 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/AttachmentControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/AttachmentControllerTest.java @@ -11,7 +11,8 @@ import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableSet; import io.dropwizard.auth.PolymorphicAuthValueFactoryProvider; -import io.dropwizard.testing.junit.ResourceTestRule; +import io.dropwizard.testing.junit5.DropwizardExtensionsSupport; +import io.dropwizard.testing.junit5.ResourceExtension; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; @@ -30,8 +31,8 @@ import org.assertj.core.api.Assertions; import org.assertj.core.api.Condition; import org.assertj.core.api.InstanceOfAssertFactories; import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.whispersystems.textsecuregcm.auth.DisabledPermittedAccount; import org.whispersystems.textsecuregcm.controllers.AttachmentControllerV1; import org.whispersystems.textsecuregcm.controllers.AttachmentControllerV2; @@ -46,7 +47,8 @@ import org.whispersystems.textsecuregcm.storage.Account; import org.whispersystems.textsecuregcm.tests.util.AuthHelper; import org.whispersystems.textsecuregcm.util.SystemMapper; -public class AttachmentControllerTest { +@ExtendWith(DropwizardExtensionsSupport.class) +class AttachmentControllerTest { private static RateLimiters rateLimiters = mock(RateLimiters.class ); private static RateLimiter rateLimiter = mock(RateLimiter.class ); @@ -71,12 +73,11 @@ public class AttachmentControllerTest { } } - @ClassRule - public static final ResourceTestRule resources; + private static final ResourceExtension resources; static { try { - resources = ResourceTestRule.builder() + resources = ResourceExtension.builder() .addProvider(AuthHelper.getAuthFilter()) .addProvider(new PolymorphicAuthValueFactoryProvider.Binder<>(ImmutableSet.of(Account.class, DisabledPermittedAccount.class))) .setMapper(SystemMapper.getMapper()) @@ -91,7 +92,7 @@ public class AttachmentControllerTest { } @Test - public void testV3Form() { + void testV3Form() { AttachmentDescriptorV3 descriptor = resources.getJerseyTest() .target("/v3/attachments/form/upload") .request() @@ -147,7 +148,7 @@ public class AttachmentControllerTest { } @Test - public void testV3FormDisabled() { + void testV3FormDisabled() { Response response = resources.getJerseyTest() .target("/v3/attachments/form/upload") .request() @@ -158,7 +159,7 @@ public class AttachmentControllerTest { } @Test - public void testV2Form() throws IOException { + void testV2Form() throws IOException { AttachmentDescriptorV2 descriptor = resources.getJerseyTest() .target("/v2/attachments/form/upload") .request() @@ -186,7 +187,7 @@ public class AttachmentControllerTest { } @Test - public void testV2FormDisabled() { + void testV2FormDisabled() { Response response = resources.getJerseyTest() .target("/v2/attachments/form/upload") .request() @@ -198,7 +199,7 @@ public class AttachmentControllerTest { @Test - public void testAcceleratedPut() { + void testAcceleratedPut() { AttachmentDescriptorV1 descriptor = resources.getJerseyTest() .target("/v1/attachments/") .request() @@ -211,7 +212,7 @@ public class AttachmentControllerTest { } @Test - public void testUnacceleratedPut() { + void testUnacceleratedPut() { AttachmentDescriptorV1 descriptor = resources.getJerseyTest() .target("/v1/attachments/") .request() @@ -224,7 +225,7 @@ public class AttachmentControllerTest { } @Test - public void testAcceleratedGet() throws MalformedURLException { + void testAcceleratedGet() throws MalformedURLException { AttachmentUri uri = resources.getJerseyTest() .target("/v1/attachments/1234") .request() @@ -235,7 +236,7 @@ public class AttachmentControllerTest { } @Test - public void testUnacceleratedGet() throws MalformedURLException { + void testUnacceleratedGet() throws MalformedURLException { AttachmentUri uri = resources.getJerseyTest() .target("/v1/attachments/1234") .request()