Skip to content

Commit

Permalink
Merge 6d8177a into 161def2
Browse files Browse the repository at this point in the history
  • Loading branch information
arteam committed Mar 2, 2019
2 parents 161def2 + 6d8177a commit 0c89014
Show file tree
Hide file tree
Showing 335 changed files with 1,364 additions and 1,236 deletions.
2 changes: 1 addition & 1 deletion docs/source/manual/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ tests:
private final MyApplication application = new MyApplication();
private final MyConfiguration config = new MyConfiguration();
@Before
@BeforeEach
public void setup() throws Exception {
config.setMyParam("yay");
when(environment.jersey()).thenReturn(jersey);
Expand Down
20 changes: 10 additions & 10 deletions docs/source/manual/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Next, write a test for serializing a ``Person`` instance to JSON:
import static io.dropwizard.testing.FixtureHelpers.*;
import static org.assertj.core.api.Assertions.assertThat;
import io.dropwizard.jackson.Jackson;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
public class PersonTest {
Expand Down Expand Up @@ -128,7 +128,7 @@ Next, write a test for deserializing a ``Person`` instance from JSON:
import static io.dropwizard.testing.FixtureHelpers.*;
import static org.assertj.core.api.Assertions.assertThat;
import io.dropwizard.jackson.Jackson;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
public class PersonTest {
Expand Down Expand Up @@ -174,12 +174,12 @@ loads a given resource instance in an in-memory Jersey server:
private final Person person = new Person("blah", "blah@example.com");
@Before
@BeforeEach
public void setup() {
when(dao.fetchPerson(eq("blah"))).thenReturn(person);
}
@After
@AfterEach
public void tearDown(){
// we have to reset the mock after each test because of the
// @ClassRule, or use a @Rule as mentioned below.
Expand Down Expand Up @@ -347,7 +347,7 @@ which is aware of your application's environment.
JUnit
-----
Adding ``DropwizardAppRule`` to your JUnit test class will start the app prior to any tests
running and stop it again when they've completed (roughly equivalent to having used ``@BeforeClass`` and ``@AfterClass``).
running and stop it again when they've completed (roughly equivalent to having used ``@BeforeAll`` and ``@AfterAll``).
``DropwizardAppRule`` also exposes the app's ``Configuration``,
``Environment`` and the app object itself so that these can be queried by the tests.

Expand Down Expand Up @@ -390,12 +390,12 @@ By creating a DropwizardTestSupport instance in your test you can manually start
ConfigOverride.config("server.applicationConnectors[0].port", "0") // Optional, if not using a separate testing-specific configuration file, use a randomly selected port
);
@BeforeClass
@BeforeAll
public void beforeClass() {
SUPPORT.before();
}
@AfterClass
@AfterAll
public void afterClass() {
SUPPORT.after();
}
Expand Down Expand Up @@ -436,7 +436,7 @@ before the command is ran.
private final ByteArrayOutputStream stdErr = new ByteArrayOutputStream();
private Cli cli;
@Before
@BeforeEach
public void setUp() throws Exception {
// Setup necessary mock
final JarLocation location = mock(JarLocation.class);
Expand All @@ -454,7 +454,7 @@ before the command is ran.
cli = new Cli(location, bootstrap, stdOut, stdErr);
}
@After
@AfterEach
public void teardown() {
System.setOut(originalOut);
System.setErr(originalErr);
Expand Down Expand Up @@ -493,7 +493,7 @@ which setups a Hibernate ``SessionFactory``.
private FooDAO fooDAO;
@Before
@BeforeEach
public void setUp() {
fooDAO = new FooDAO(database.getSessionFactory());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import io.dropwizard.servlets.assets.ResourceURL;
import io.dropwizard.setup.Environment;
import io.dropwizard.util.Resources;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;

import javax.servlet.ServletRegistration;
Expand All @@ -28,7 +28,7 @@ public class AssetsBundleTest {
private AssetServlet servlet = new AssetServlet("/", "/", null, null);
private String servletPath = "";

@Before
@BeforeEach
public void setUp() throws Exception {
when(environment.servlets()).thenReturn(servletEnvironment);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory;
import org.glassfish.jersey.test.spi.TestContainerException;
import org.glassfish.jersey.test.spi.TestContainerFactory;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.HttpHeaders;
Expand Down Expand Up @@ -47,6 +49,18 @@ protected TestContainerFactory getTestContainerFactory()
protected abstract String getGoodGuyValidToken();
protected abstract String getBadGuyToken();

@Override
@BeforeEach
public void setUp() throws Exception {
super.setUp();
}

@Override
@AfterEach
public void tearDown() throws Exception {
super.tearDown();
}

@Override
protected DeploymentContext configureDeployment() {
forceSet(TestProperties.CONTAINER_PORT, "0");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.dropwizard.auth;

import io.dropwizard.auth.principal.NullPrincipal;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Cookie;
Expand All @@ -22,7 +22,7 @@
import java.util.Map;
import java.util.Optional;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.CaffeineSpec;
import com.google.common.util.concurrent.MoreExecutors;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.security.Principal;
import java.util.Collections;
Expand Down Expand Up @@ -35,7 +34,7 @@ public CachingAuthenticatorTest() {
this.cached = new CachingAuthenticator<>(new MetricRegistry(), this.underlying, caff);
}

@Before
@BeforeEach
public void setUp() throws Exception {
when(underlying.authenticate(anyString())).thenReturn(Optional.of(new PrincipalImpl("principal")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.codahale.metrics.MetricRegistry;
import com.github.benmanes.caffeine.cache.CaffeineSpec;
import io.dropwizard.util.Sets;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InOrder;

import java.security.Principal;
Expand Down Expand Up @@ -32,7 +32,7 @@ public class CachingAuthorizerTest {
private final Principal principal2 = new PrincipalImpl("principal2");
private final String role = "popular_kids";

@Before
@BeforeEach
public void setUp() throws Exception {
when(underlying.authorize(any(), anyString())).thenReturn(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.ServletDeploymentContext;
import org.glassfish.jersey.test.TestProperties;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.security.Principal;
Expand All @@ -24,6 +26,18 @@

public class OptionalAuthFilterOrderingTest extends JerseyTest {

@Override
@BeforeEach
public void setUp() throws Exception {
super.setUp();
}

@Override
@AfterEach
public void tearDown() throws Exception {
super.tearDown();
}

@Override
protected DeploymentContext configureDeployment() {
forceSet(TestProperties.CONTAINER_PORT, "0");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.dropwizard.auth.basic;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import io.dropwizard.jersey.DropwizardResourceConfig;
import org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature;
import org.glassfish.jersey.test.TestProperties;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import javax.ws.rs.core.HttpHeaders;
import java.security.Principal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import io.dropwizard.auth.AuthResource;
import io.dropwizard.auth.util.AuthUtil;
import io.dropwizard.jersey.DropwizardResourceConfig;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.Arrays;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.ServletDeploymentContext;
import org.glassfish.jersey.test.TestProperties;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import javax.ws.rs.client.Entity;
import javax.ws.rs.container.ContainerRequestFilter;
Expand All @@ -32,6 +34,19 @@ public class NoAuthPolymorphicPrincipalEntityTest extends JerseyTest {
BootstrapLogging.bootstrap();
}

@Override
@BeforeEach
public void setUp() throws Exception {
super.setUp();
}

@Override
@AfterEach
public void tearDown() throws Exception {
super.tearDown();
}


@Override
protected DeploymentContext configureDeployment() {
forceSet(TestProperties.CONTAINER_PORT, "0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.ServletDeploymentContext;
import org.glassfish.jersey.test.TestProperties;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import javax.ws.rs.client.Entity;
import javax.ws.rs.container.ContainerRequestFilter;
Expand All @@ -30,6 +32,18 @@ public class NoAuthPrincipalEntityTest extends JerseyTest {
BootstrapLogging.bootstrap();
}

@Override
@BeforeEach
public void setUp() throws Exception {
super.setUp();
}

@Override
@AfterEach
public void tearDown() throws Exception {
super.tearDown();
}

@Override
protected DeploymentContext configureDeployment() {
forceSet(TestProperties.CONTAINER_PORT, "0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.ServletDeploymentContext;
import org.glassfish.jersey.test.TestProperties;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import javax.ws.rs.WebApplicationException;
import javax.ws.rs.container.ContainerRequestFilter;
Expand All @@ -40,6 +42,18 @@ public class PolymorphicPrincipalEntityTest extends JerseyTest {
BootstrapLogging.bootstrap();
}

@Override
@BeforeEach
public void setUp() throws Exception {
super.setUp();
}

@Override
@AfterEach
public void tearDown() throws Exception {
super.tearDown();
}

@Override
protected DeploymentContext configureDeployment() {
forceSet(TestProperties.CONTAINER_PORT, "0");
Expand Down
7 changes: 7 additions & 0 deletions dropwizard-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,13 @@
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit5.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.CloseableHttpClient;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -14,7 +14,7 @@ public class ConfiguredCloseableHttpClientTest {
private CloseableHttpClient closeableHttpClientMock = Mockito.mock(CloseableHttpClient.class);
private RequestConfig defaultRequestConfigMock = Mockito.mock(RequestConfig.class);

@Before
@BeforeEach
public void setUp() {
configuredClient = new ConfiguredCloseableHttpClient(closeableHttpClientMock, defaultRequestConfigMock);
}
Expand Down
Loading

0 comments on commit 0c89014

Please sign in to comment.