From fe7de7b3c287f0169a56dde32210e54b74eabfbd Mon Sep 17 00:00:00 2001 From: Scott Frederick Date: Mon, 11 Oct 2021 14:55:37 -0500 Subject: [PATCH] Migrate tests from JUnit 4 to JUnit 5 --- build.gradle | 14 ++-- spring-credhub-core/build.gradle | 6 +- .../ClientHttpConnectorFactoryTests.java | 2 +- .../ClientHttpRequestFactoryFactoryTests.java | 2 +- .../CredHubRestTemplateFactoryUnitTests.java | 8 +- .../core/CredHubWebClientFactoryTests.java | 8 +- .../CredHubCertificateTemplateUnitTests.java | 12 +-- ...HubCredentialTemplateSummaryUnitTests.java | 41 +++++---- .../CredHubCredentialTemplateUnitTests.java | 8 +- ...redHubCredentialTemplateUnitTestsBase.java | 15 ++-- ...HubTemplateDetailCertificateUnitTests.java | 83 ++++++++++--------- .../CredHubTemplateDetailJsonUnitTests.java | 71 +++++++++------- ...redHubTemplateDetailPasswordUnitTests.java | 83 ++++++++++--------- .../CredHubTemplateDetailRsaUnitTests.java | 83 ++++++++++--------- .../CredHubTemplateDetailSshUnitTests.java | 83 ++++++++++--------- .../CredHubTemplateDetailUnitTestsBase.java | 16 ++++ .../CredHubTemplateDetailUserUnitTests.java | 71 +++++++++------- .../CredHubTemplateDetailValueUnitTests.java | 71 +++++++++------- .../info/CredHubInfoTemplateUnitTests.java | 20 ++--- ...CredHubInterpolationTemplateUnitTests.java | 20 ++--- .../CredHubPermissionTemplateUnitTests.java | 15 ++-- .../CredHubPermissionV2TemplateUnitTests.java | 12 +-- .../support/CertificateSummaryDataTests.java | 2 +- .../support/CredHubRequestUnitTestsBase.java | 2 +- .../support/CredentialPathDataTests.java | 2 +- .../CredentialSummaryDataUnitTests.java | 2 +- .../support/JsonParsingUnitTestsBase.java | 4 +- ...erviceInstanceCredentialNameUnitTests.java | 2 +- .../SimpleCredentialNameUnitTests.java | 2 +- ...CertificateCredentialDetailsUnitTests.java | 2 +- ...CertificateCredentialRequestUnitTests.java | 16 ++-- ...CertificateParametersRequestUnitTests.java | 20 +++-- .../support/info/VersionInfoTests.java | 2 +- .../json/JsonCredentialDetailsUnitTests.java | 2 +- .../json/JsonCredentialRequestUnitTests.java | 6 +- .../PasswordCredentialDetailsUnitTests.java | 2 +- .../PasswordCredentialRequestUnitTests.java | 6 +- .../PasswordParametersRequestUnitTests.java | 6 +- .../CredentialPermissionUnitTests.java | 2 +- .../CredentialPermissionsUnitTests.java | 2 +- .../rsa/RsaCredentialDetailsUnitTests.java | 2 +- .../rsa/RsaCredentialRequestUnitTests.java | 16 ++-- .../rsa/RsaParametersRequestUnitTests.java | 6 +- .../ssh/SshCredentialDetailsUnitTests.java | 2 +- .../ssh/SshCredentialRequestUnitTests.java | 16 ++-- .../ssh/SshParametersRequestUnitTests.java | 6 +- .../user/UserCredentialDetailsUnitTests.java | 2 +- .../user/UserCredentialRequestUnitTests.java | 6 +- .../user/UserParametersRequestUnitTests.java | 6 +- .../ValueCredentialDetailsUnitTests.java | 2 +- .../ValueCredentialRequestUnitTests.java | 6 +- spring-credhub-integration-tests/build.gradle | 5 +- .../CertificateIntegrationTests.java | 12 +-- .../integration/CredHubIntegrationTests.java | 7 +- .../CredentialIntegrationTests.java | 12 +-- .../integration/InfoIntegrationTests.java | 6 +- .../InterpolationIntegrationTests.java | 10 +-- .../PermissionIntegrationTests.java | 12 +-- .../PermissionV2IntegrationTests.java | 12 +-- .../build.gradle | 7 +- .../ReactiveCertificateIntegrationTests.java | 12 +-- .../ReactiveCredHubIntegrationTests.java | 7 +- .../ReactiveCredentialIntegrationTests.java | 12 +-- .../ReactiveInfoIntegrationTests.java | 6 +- ...ReactiveInterpolationIntegrationTests.java | 10 +-- .../ReactivePermissionIntegrationTests.java | 12 +-- .../ReactivePermissionV2IntegrationTests.java | 12 +-- spring-credhub-starter/build.gradle | 1 + .../CredHubAutoConfigurationTests.java | 2 +- .../CredHubOAuth2AutoConfigurationTests.java | 3 +- ...CredHubTemplateAutoConfigurationTests.java | 2 +- 71 files changed, 570 insertions(+), 488 deletions(-) diff --git a/build.gradle b/build.gradle index dc7f90a..ff96104 100644 --- a/build.gradle +++ b/build.gradle @@ -33,9 +33,9 @@ ext { httpClientVersion = "4.5.13" nettyVersion = "4.1.68.Final" - junitVersion = "4.12" - mockitoVersion = "3.1.0" - assertJVersion = "3.6.1" + junitVersion = "5.7.2" + mockitoVersion = "3.9.0" + assertJVersion = "3.19.0" javadocLinks = [ "https://docs.oracle.com/javase/8/docs/api/", @@ -145,8 +145,12 @@ subprojects { } dependencies { - testCompile("junit:junit:$junitVersion") - testCompile("org.mockito:mockito-core:$mockitoVersion") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") + } + + test { + useJUnitPlatform() } } diff --git a/spring-credhub-core/build.gradle b/spring-credhub-core/build.gradle index c4d43b7..887b49d 100644 --- a/spring-credhub-core/build.gradle +++ b/spring-credhub-core/build.gradle @@ -49,8 +49,10 @@ dependencies { testImplementation("org.springframework:spring-test") testImplementation("io.projectreactor:reactor-test") - testImplementation("junit:junit") - testImplementation("org.mockito:mockito-core") + testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}") + testImplementation("org.junit.jupiter:junit-jupiter-params:${junitVersion}") + testImplementation("org.mockito:mockito-core:${mockitoVersion}") + testImplementation("org.mockito:mockito-junit-jupiter:${mockitoVersion}") testImplementation("org.assertj:assertj-core:${assertJVersion}") testImplementation("com.jayway.jsonpath:json-path:2.4.0") } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/configuration/ClientHttpConnectorFactoryTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/configuration/ClientHttpConnectorFactoryTests.java index 59ec3f0..7d382d7 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/configuration/ClientHttpConnectorFactoryTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/configuration/ClientHttpConnectorFactoryTests.java @@ -16,7 +16,7 @@ package org.springframework.credhub.configuration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.ClientOptions; import org.springframework.http.client.reactive.ClientHttpConnector; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/configuration/ClientHttpRequestFactoryFactoryTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/configuration/ClientHttpRequestFactoryFactoryTests.java index 083f9ac..7f3acf7 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/configuration/ClientHttpRequestFactoryFactoryTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/configuration/ClientHttpRequestFactoryFactoryTests.java @@ -18,7 +18,7 @@ package org.springframework.credhub.configuration; import org.apache.http.client.HttpClient; import org.apache.http.impl.client.CloseableHttpClient; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.credhub.configuration.ClientHttpRequestFactoryFactory.HttpComponents; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/CredHubRestTemplateFactoryUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/CredHubRestTemplateFactoryUnitTests.java index 30a36c7..4e72b7c 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/CredHubRestTemplateFactoryUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/CredHubRestTemplateFactoryUnitTests.java @@ -16,17 +16,17 @@ package org.springframework.credhub.core; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class CredHubRestTemplateFactoryUnitTests { @Mock diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/CredHubWebClientFactoryTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/CredHubWebClientFactoryTests.java index fae9085..afffc70 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/CredHubWebClientFactoryTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/CredHubWebClientFactoryTests.java @@ -16,10 +16,10 @@ package org.springframework.credhub.core; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.client.reactive.ClientHttpConnector; import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository; @@ -28,7 +28,7 @@ import org.springframework.web.reactive.function.client.WebClient; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class CredHubWebClientFactoryTests { @Mock diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/certificate/CredHubCertificateTemplateUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/certificate/CredHubCertificateTemplateUnitTests.java index 34eb8c8..919a59a 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/certificate/CredHubCertificateTemplateUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/certificate/CredHubCertificateTemplateUnitTests.java @@ -22,11 +22,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.core.ParameterizedTypeReference; import org.springframework.credhub.core.CredHubTemplate; @@ -48,7 +48,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.BDDMockito.given; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class CredHubCertificateTemplateUnitTests { private static final SimpleCredentialName NAME = new SimpleCredentialName("example", "certificate"); @@ -58,7 +58,7 @@ public class CredHubCertificateTemplateUnitTests { private CredHubCertificateOperations credHubTemplate; - @Before + @BeforeEach public void setUp() { this.credHubTemplate = new CredHubTemplate(this.restTemplate).certificates(); } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubCredentialTemplateSummaryUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubCredentialTemplateSummaryUnitTests.java index 0eda1f0..de5c49f 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubCredentialTemplateSummaryUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubCredentialTemplateSummaryUnitTests.java @@ -17,12 +17,13 @@ package org.springframework.credhub.core.credential; import java.util.List; +import java.util.stream.Stream; -import org.junit.experimental.theories.DataPoint; -import org.junit.experimental.theories.FromDataPoints; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; +import org.junit.jupiter.params.provider.ArgumentsSource; import org.springframework.credhub.core.CredHubException; import org.springframework.credhub.support.CredentialSummary; @@ -34,19 +35,11 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; import static org.mockito.BDDMockito.given; -@RunWith(Theories.class) public class CredHubCredentialTemplateSummaryUnitTests extends CredHubCredentialTemplateUnitTestsBase { - @DataPoint("responses") - public static ResponseEntity successfulResponse = ResponseEntity.ok() - .body(new CredentialSummaryData(new CredentialSummary(NAME))); - - @DataPoint("responses") - public static ResponseEntity httpErrorResponse = ResponseEntity - .status(HttpStatus.UNAUTHORIZED).body(new CredentialSummaryData()); - - @Theory - public void findByName(@FromDataPoints("responses") ResponseEntity expectedResponse) { + @ParameterizedTest + @ArgumentsSource(ResponseArgumentsProvider.class) + public void findByName(ResponseEntity expectedResponse) { given(this.restTemplate.getForEntity(CredHubCredentialTemplate.NAME_LIKE_URL_QUERY, CredentialSummaryData.class, NAME.getName())).willReturn(expectedResponse); @@ -66,8 +59,9 @@ public class CredHubCredentialTemplateSummaryUnitTests extends CredHubCredential } } - @Theory - public void findByPath(@FromDataPoints("responses") ResponseEntity expectedResponse) { + @ParameterizedTest + @ArgumentsSource(ResponseArgumentsProvider.class) + public void findByPath(ResponseEntity expectedResponse) { given(this.restTemplate.getForEntity(CredHubCredentialTemplate.PATH_URL_QUERY, CredentialSummaryData.class, NAME.getName())).willReturn(expectedResponse); @@ -94,4 +88,15 @@ public class CredHubCredentialTemplateSummaryUnitTests extends CredHubCredential assertThat(response).contains(expectedResponse.getBody().getCredentials().get(0)); } + static class ResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return Stream.of( + Arguments.of(ResponseEntity.ok().body(new CredentialSummaryData(new CredentialSummary(NAME)))), + Arguments.of(ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(new CredentialSummaryData()))); + } + + } + } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubCredentialTemplateUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubCredentialTemplateUnitTests.java index a879167..2b9dd72 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubCredentialTemplateUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubCredentialTemplateUnitTests.java @@ -18,9 +18,9 @@ package org.springframework.credhub.core.credential; import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.credhub.support.CredentialPath; import org.springframework.credhub.support.CredentialPathData; @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class CredHubCredentialTemplateUnitTests extends CredHubCredentialTemplateUnitTestsBase { @Test diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubCredentialTemplateUnitTestsBase.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubCredentialTemplateUnitTestsBase.java index 44a7e85..fd5574c 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubCredentialTemplateUnitTestsBase.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubCredentialTemplateUnitTestsBase.java @@ -16,30 +16,29 @@ package org.springframework.credhub.core.credential; -import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; import org.springframework.credhub.core.CredHubTemplate; import org.springframework.credhub.support.SimpleCredentialName; import org.springframework.web.client.RestTemplate; +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.STRICT_STUBS) public abstract class CredHubCredentialTemplateUnitTestsBase { protected static final SimpleCredentialName NAME = new SimpleCredentialName("example", "credential"); - @Rule - public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS); - @Mock protected RestTemplate restTemplate; protected CredHubCredentialOperations credHubTemplate; - @Before + @BeforeEach public void setUpCredHubTemplateUnitTests() { this.credHubTemplate = new CredHubTemplate(this.restTemplate).credentials(); } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailCertificateUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailCertificateUnitTests.java index 24cb497..089f19a 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailCertificateUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailCertificateUnitTests.java @@ -16,13 +16,13 @@ package org.springframework.credhub.core.credential; -import java.util.List; +import java.util.stream.Stream; -import org.junit.experimental.theories.DataPoints; -import org.junit.experimental.theories.FromDataPoints; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; +import org.junit.jupiter.params.provider.ArgumentsSource; import org.springframework.credhub.support.CredentialDetails; import org.springframework.credhub.support.CredentialDetailsData; @@ -35,7 +35,6 @@ import org.springframework.credhub.support.certificate.CertificateParameters; import org.springframework.credhub.support.certificate.CertificateParametersRequest; import org.springframework.http.ResponseEntity; -@RunWith(Theories.class) public class CredHubTemplateDetailCertificateUnitTests extends CredHubTemplateDetailUnitTestsBase { @@ -45,16 +44,6 @@ public class CredHubTemplateDetailCertificateUnitTests private static final CertificateParameters PARAMETERS = CertificateParameters.builder().commonName("common") .certificateAuthorityCredential("credential").build(); - @DataPoints("detail-responses") - public static List>> buildDetailResponses() { - return buildDetailResponses(CredentialType.CERTIFICATE, CREDENTIAL); - } - - @DataPoints("data-responses") - public static List>> buildDataResponses() { - return buildDataResponses(CredentialType.CERTIFICATE, CREDENTIAL); - } - @Override public CredentialRequest getWriteRequest() { return CertificateCredentialRequest.builder().name(NAME).value(CREDENTIAL).build(); @@ -70,46 +59,64 @@ public class CredHubTemplateDetailCertificateUnitTests return CertificateCredential.class; } - @Theory - public void write( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void write(ResponseEntity> expectedResponse) { verifyWrite(expectedResponse); } - @Theory - public void generate( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void generate(ResponseEntity> expectedResponse) { verifyGenerate(expectedResponse); } - @Theory - public void regenerate( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void regenerate(ResponseEntity> expectedResponse) { verifyRegenerate(expectedResponse); } - @Theory - public void getById( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void getById(ResponseEntity> expectedResponse) { verifyGetById(expectedResponse); } - @Theory - public void getByName( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByName(ResponseEntity> expectedResponse) { verifyGetByName(expectedResponse); } - @Theory - public void getByNameWithHistory( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByNameWithHistory(ResponseEntity> expectedResponse) { verifyGetByNameWithHistory(expectedResponse); } - @Theory - public void getByNameWithVersions( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByNameWithVersions(ResponseEntity> expectedResponse) { verifyGetByNameWithVersions(expectedResponse); } + static class DetailResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return buildDetailArguments(CredentialType.CERTIFICATE, CREDENTIAL); + } + + } + + static class DataResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return buildDataArguments(CredentialType.CERTIFICATE, CREDENTIAL); + } + + } + } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailJsonUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailJsonUnitTests.java index cab3d57..2195d96 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailJsonUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailJsonUnitTests.java @@ -16,13 +16,13 @@ package org.springframework.credhub.core.credential; -import java.util.List; +import java.util.stream.Stream; -import org.junit.experimental.theories.DataPoints; -import org.junit.experimental.theories.FromDataPoints; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; +import org.junit.jupiter.params.provider.ArgumentsSource; import org.springframework.credhub.support.CredentialDetails; import org.springframework.credhub.support.CredentialDetailsData; @@ -32,7 +32,6 @@ import org.springframework.credhub.support.json.JsonCredential; import org.springframework.credhub.support.json.JsonCredentialRequest; import org.springframework.http.ResponseEntity; -@RunWith(Theories.class) public class CredHubTemplateDetailJsonUnitTests extends CredHubTemplateDetailUnitTestsBase { private static final JsonCredential CREDENTIAL = new JsonCredential() { @@ -42,16 +41,6 @@ public class CredHubTemplateDetailJsonUnitTests extends CredHubTemplateDetailUni } }; - @DataPoints("detail-responses") - public static List>> buildDetailResponses() { - return buildDetailResponses(CredentialType.JSON, CREDENTIAL); - } - - @DataPoints("data-responses") - public static List>> buildDataResponses() { - return buildDataResponses(CredentialType.JSON, CREDENTIAL); - } - @Override public CredentialRequest getWriteRequest() { return JsonCredentialRequest.builder().name(NAME).value(CREDENTIAL).build(); @@ -62,34 +51,52 @@ public class CredHubTemplateDetailJsonUnitTests extends CredHubTemplateDetailUni return JsonCredential.class; } - @Theory - public void write( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void write(ResponseEntity> expectedResponse) { verifyWrite(expectedResponse); } - @Theory - public void getById( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void getById(ResponseEntity> expectedResponse) { verifyGetById(expectedResponse); } - @Theory - public void getByName( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByName(ResponseEntity> expectedResponse) { verifyGetByName(expectedResponse); } - @Theory - public void getByNameWithHistory( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByNameWithHistory(ResponseEntity> expectedResponse) { verifyGetByNameWithHistory(expectedResponse); } - @Theory - public void getByNameWithVersions( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByNameWithVersions(ResponseEntity> expectedResponse) { verifyGetByNameWithVersions(expectedResponse); } + static class DetailResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return buildDetailArguments(CredentialType.JSON, CREDENTIAL); + } + + } + + static class DataResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return buildDataArguments(CredentialType.JSON, CREDENTIAL); + } + + } + } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailPasswordUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailPasswordUnitTests.java index fc22f47..c257a9c 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailPasswordUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailPasswordUnitTests.java @@ -16,13 +16,13 @@ package org.springframework.credhub.core.credential; -import java.util.List; +import java.util.stream.Stream; -import org.junit.experimental.theories.DataPoints; -import org.junit.experimental.theories.FromDataPoints; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; +import org.junit.jupiter.params.provider.ArgumentsSource; import org.springframework.credhub.support.CredentialDetails; import org.springframework.credhub.support.CredentialDetailsData; @@ -35,7 +35,6 @@ import org.springframework.credhub.support.password.PasswordParameters; import org.springframework.credhub.support.password.PasswordParametersRequest; import org.springframework.http.ResponseEntity; -@RunWith(Theories.class) public class CredHubTemplateDetailPasswordUnitTests extends CredHubTemplateDetailUnitTestsBase { @@ -43,16 +42,6 @@ public class CredHubTemplateDetailPasswordUnitTests private static final PasswordParameters PARAMETERS = new PasswordParameters(); - @DataPoints("detail-responses") - public static List>> buildDetailResponses() { - return buildDetailResponses(CredentialType.PASSWORD, CREDENTIAL); - } - - @DataPoints("data-responses") - public static List>> buildDataResponses() { - return buildDataResponses(CredentialType.PASSWORD, CREDENTIAL); - } - @Override public CredentialRequest getWriteRequest() { return PasswordCredentialRequest.builder().name(NAME).value(CREDENTIAL).build(); @@ -68,46 +57,64 @@ public class CredHubTemplateDetailPasswordUnitTests return PasswordCredential.class; } - @Theory - public void write( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void write(ResponseEntity> expectedResponse) { verifyWrite(expectedResponse); } - @Theory - public void generate( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void generate(ResponseEntity> expectedResponse) { verifyGenerate(expectedResponse); } - @Theory - public void regenerate( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void regenerate(ResponseEntity> expectedResponse) { verifyRegenerate(expectedResponse); } - @Theory - public void getById( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void getById(ResponseEntity> expectedResponse) { verifyGetById(expectedResponse); } - @Theory - public void getByName( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByName(ResponseEntity> expectedResponse) { verifyGetByName(expectedResponse); } - @Theory - public void getByNameWithHistory( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByNameWithHistory(ResponseEntity> expectedResponse) { verifyGetByNameWithHistory(expectedResponse); } - @Theory - public void getByNameWithVersions( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByNameWithVersions(ResponseEntity> expectedResponse) { verifyGetByNameWithVersions(expectedResponse); } + static class DetailResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return buildDetailArguments(CredentialType.PASSWORD, CREDENTIAL); + } + + } + + static class DataResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return buildDataArguments(CredentialType.PASSWORD, CREDENTIAL); + } + + } + } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailRsaUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailRsaUnitTests.java index 8652729..297b026 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailRsaUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailRsaUnitTests.java @@ -16,13 +16,13 @@ package org.springframework.credhub.core.credential; -import java.util.List; +import java.util.stream.Stream; -import org.junit.experimental.theories.DataPoints; -import org.junit.experimental.theories.FromDataPoints; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; +import org.junit.jupiter.params.provider.ArgumentsSource; import org.springframework.credhub.support.CredentialDetails; import org.springframework.credhub.support.CredentialDetailsData; @@ -36,7 +36,6 @@ import org.springframework.credhub.support.rsa.RsaParameters; import org.springframework.credhub.support.rsa.RsaParametersRequest; import org.springframework.http.ResponseEntity; -@RunWith(Theories.class) public class CredHubTemplateDetailRsaUnitTests extends CredHubTemplateDetailUnitTestsBase { @@ -44,16 +43,6 @@ public class CredHubTemplateDetailRsaUnitTests private static final RsaParameters PARAMETERS = new RsaParameters(KeyLength.LENGTH_4096); - @DataPoints("detail-responses") - public static List>> buildDetailResponses() { - return buildDetailResponses(CredentialType.RSA, CREDENTIAL); - } - - @DataPoints("data-responses") - public static List>> buildDataResponses() { - return buildDataResponses(CredentialType.RSA, CREDENTIAL); - } - @Override public CredentialRequest getWriteRequest() { return RsaCredentialRequest.builder().name(NAME).value(CREDENTIAL).build(); @@ -69,46 +58,64 @@ public class CredHubTemplateDetailRsaUnitTests return RsaCredential.class; } - @Theory - public void write( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void write(ResponseEntity> expectedResponse) { verifyWrite(expectedResponse); } - @Theory - public void generate( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void generate(ResponseEntity> expectedResponse) { verifyGenerate(expectedResponse); } - @Theory - public void regenerate( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void regenerate(ResponseEntity> expectedResponse) { verifyRegenerate(expectedResponse); } - @Theory - public void getById( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void getById(ResponseEntity> expectedResponse) { verifyGetById(expectedResponse); } - @Theory - public void getByName( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByName(ResponseEntity> expectedResponse) { verifyGetByName(expectedResponse); } - @Theory - public void getByNameWithHistory( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByNameWithHistory(ResponseEntity> expectedResponse) { verifyGetByNameWithHistory(expectedResponse); } - @Theory - public void getByNameWithVersions( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByNameWithVersions(ResponseEntity> expectedResponse) { verifyGetByNameWithVersions(expectedResponse); } + static class DetailResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return buildDetailArguments(CredentialType.RSA, CREDENTIAL); + } + + } + + static class DataResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return buildDataArguments(CredentialType.RSA, CREDENTIAL); + } + + } + } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailSshUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailSshUnitTests.java index 43d59b1..7b61368 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailSshUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailSshUnitTests.java @@ -16,13 +16,13 @@ package org.springframework.credhub.core.credential; -import java.util.List; +import java.util.stream.Stream; -import org.junit.experimental.theories.DataPoints; -import org.junit.experimental.theories.FromDataPoints; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; +import org.junit.jupiter.params.provider.ArgumentsSource; import org.springframework.credhub.support.CredentialDetails; import org.springframework.credhub.support.CredentialDetailsData; @@ -36,7 +36,6 @@ import org.springframework.credhub.support.ssh.SshParameters; import org.springframework.credhub.support.ssh.SshParametersRequest; import org.springframework.http.ResponseEntity; -@RunWith(Theories.class) public class CredHubTemplateDetailSshUnitTests extends CredHubTemplateDetailUnitTestsBase { @@ -44,16 +43,6 @@ public class CredHubTemplateDetailSshUnitTests private static final SshParameters PARAMETERS = new SshParameters(KeyLength.LENGTH_2048, "comment"); - @DataPoints("detail-responses") - public static List>> buildDetailResponses() { - return buildDetailResponses(CredentialType.SSH, CREDENTIAL); - } - - @DataPoints("data-responses") - public static List>> buildDataResponses() { - return buildDataResponses(CredentialType.SSH, CREDENTIAL); - } - @Override public CredentialRequest getWriteRequest() { return SshCredentialRequest.builder().name(NAME).value(CREDENTIAL).build(); @@ -69,46 +58,64 @@ public class CredHubTemplateDetailSshUnitTests return SshCredential.class; } - @Theory - public void write( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void write(ResponseEntity> expectedResponse) { verifyWrite(expectedResponse); } - @Theory - public void generate( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void generate(ResponseEntity> expectedResponse) { verifyGenerate(expectedResponse); } - @Theory - public void regenerate( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void regenerate(ResponseEntity> expectedResponse) { verifyRegenerate(expectedResponse); } - @Theory - public void getById( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void getById(ResponseEntity> expectedResponse) { verifyGetById(expectedResponse); } - @Theory - public void getByName( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByName(ResponseEntity> expectedResponse) { verifyGetByName(expectedResponse); } - @Theory - public void getByNameWithHistory( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByNameWithHistory(ResponseEntity> expectedResponse) { verifyGetByNameWithHistory(expectedResponse); } - @Theory - public void getByNameWithVersions( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByNameWithVersions(ResponseEntity> expectedResponse) { verifyGetByNameWithVersions(expectedResponse); } + static class DetailResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return buildDetailArguments(CredentialType.CERTIFICATE, CREDENTIAL); + } + + } + + static class DataResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return buildDataArguments(CredentialType.CERTIFICATE, CREDENTIAL); + } + + } + } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailUnitTestsBase.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailUnitTestsBase.java index ab05b05..c276eac 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailUnitTestsBase.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailUnitTestsBase.java @@ -20,6 +20,9 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; + +import org.junit.jupiter.params.provider.Arguments; import org.springframework.core.ParameterizedTypeReference; import org.springframework.credhub.core.CredHubException; @@ -53,6 +56,19 @@ public abstract class CredHubTemplateDetailUnitTestsBase extends CredHubCr throw new IllegalStateException("Tests that verify credential generation must override this method"); } + static Stream buildDetailArguments(CredentialType type, T credential) { + return Stream.of( + Arguments.of(ResponseEntity.ok().body(new CredentialDetails<>(CREDENTIAL_ID, NAME, type, credential))), + Arguments.of(ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(new CredentialDetails<>()))); + } + + static Stream buildDataArguments(CredentialType type, T credential) { + return Stream.of( + Arguments.of(ResponseEntity.ok().body( + new CredentialDetailsData<>(new CredentialDetails<>(CREDENTIAL_ID, NAME, type, credential)))), + Arguments.of(ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(new CredentialDetailsData<>()))); + } + static List>> buildDetailResponses(CredentialType type, T credential) { return Arrays.asList(ResponseEntity.ok().body(new CredentialDetails<>(CREDENTIAL_ID, NAME, type, credential)), ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(new CredentialDetails<>())); diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailUserUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailUserUnitTests.java index 65bb42f..fdc84ee 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailUserUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailUserUnitTests.java @@ -16,13 +16,13 @@ package org.springframework.credhub.core.credential; -import java.util.List; +import java.util.stream.Stream; -import org.junit.experimental.theories.DataPoints; -import org.junit.experimental.theories.FromDataPoints; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; +import org.junit.jupiter.params.provider.ArgumentsSource; import org.springframework.credhub.support.CredentialDetails; import org.springframework.credhub.support.CredentialDetailsData; @@ -32,21 +32,10 @@ import org.springframework.credhub.support.user.UserCredential; import org.springframework.credhub.support.user.UserCredentialRequest; import org.springframework.http.ResponseEntity; -@RunWith(Theories.class) public class CredHubTemplateDetailUserUnitTests extends CredHubTemplateDetailUnitTestsBase { private static final UserCredential CREDENTIAL = new UserCredential("myname", "secret"); - @DataPoints("detail-responses") - public static List>> buildDetailResponses() { - return buildDetailResponses(CredentialType.USER, CREDENTIAL); - } - - @DataPoints("data-responses") - public static List>> buildDataResponses() { - return buildDataResponses(CredentialType.USER, CREDENTIAL); - } - @Override public CredentialRequest getWriteRequest() { return UserCredentialRequest.builder().name(NAME).value(CREDENTIAL).build(); @@ -57,34 +46,52 @@ public class CredHubTemplateDetailUserUnitTests extends CredHubTemplateDetailUni return UserCredential.class; } - @Theory - public void write( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void write(ResponseEntity> expectedResponse) { verifyWrite(expectedResponse); } - @Theory - public void getById( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void getById(ResponseEntity> expectedResponse) { verifyGetById(expectedResponse); } - @Theory - public void getByName( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByName(ResponseEntity> expectedResponse) { verifyGetByName(expectedResponse); } - @Theory - public void getByNameWithHistory( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByNameWithHistory(ResponseEntity> expectedResponse) { verifyGetByNameWithHistory(expectedResponse); } - @Theory - public void getByNameWithVersions( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByNameWithVersions(ResponseEntity> expectedResponse) { verifyGetByNameWithVersions(expectedResponse); } + static class DetailResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return buildDetailArguments(CredentialType.USER, CREDENTIAL); + } + + } + + static class DataResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return buildDataArguments(CredentialType.USER, CREDENTIAL); + } + + } + } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailValueUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailValueUnitTests.java index 5d839e4..ad319b8 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailValueUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/credential/CredHubTemplateDetailValueUnitTests.java @@ -16,13 +16,13 @@ package org.springframework.credhub.core.credential; -import java.util.List; +import java.util.stream.Stream; -import org.junit.experimental.theories.DataPoints; -import org.junit.experimental.theories.FromDataPoints; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; +import org.junit.jupiter.params.provider.ArgumentsSource; import org.springframework.credhub.support.CredentialDetails; import org.springframework.credhub.support.CredentialDetailsData; @@ -32,21 +32,10 @@ import org.springframework.credhub.support.value.ValueCredential; import org.springframework.credhub.support.value.ValueCredentialRequest; import org.springframework.http.ResponseEntity; -@RunWith(Theories.class) public class CredHubTemplateDetailValueUnitTests extends CredHubTemplateDetailUnitTestsBase { private static final ValueCredential CREDENTIAL = new ValueCredential("secret"); - @DataPoints("detail-responses") - public static List>> buildDetailResponses() { - return buildDetailResponses(CredentialType.VALUE, CREDENTIAL); - } - - @DataPoints("data-responses") - public static List>> buildDataResponses() { - return buildDataResponses(CredentialType.VALUE, CREDENTIAL); - } - @Override public CredentialRequest getWriteRequest() { return ValueCredentialRequest.builder().name(NAME).value(CREDENTIAL).build(); @@ -57,34 +46,52 @@ public class CredHubTemplateDetailValueUnitTests extends CredHubTemplateDetailUn return ValueCredential.class; } - @Theory - public void write( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void write(ResponseEntity> expectedResponse) { verifyWrite(expectedResponse); } - @Theory - public void getById( - @FromDataPoints("detail-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DetailResponseArgumentsProvider.class) + public void getById(ResponseEntity> expectedResponse) { verifyGetById(expectedResponse); } - @Theory - public void getByName( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByName(ResponseEntity> expectedResponse) { verifyGetByName(expectedResponse); } - @Theory - public void getByNameWithHistory( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByNameWithHistory(ResponseEntity> expectedResponse) { verifyGetByNameWithHistory(expectedResponse); } - @Theory - public void getByNameWithVersions( - @FromDataPoints("data-responses") ResponseEntity> expectedResponse) { + @ParameterizedTest + @ArgumentsSource(DataResponseArgumentsProvider.class) + public void getByNameWithVersions(ResponseEntity> expectedResponse) { verifyGetByNameWithVersions(expectedResponse); } + static class DetailResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return buildDetailArguments(CredentialType.VALUE, CREDENTIAL); + } + + } + + static class DataResponseArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return buildDataArguments(CredentialType.VALUE, CREDENTIAL); + } + + } + } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/info/CredHubInfoTemplateUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/info/CredHubInfoTemplateUnitTests.java index a8e0b66..494ff05 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/info/CredHubInfoTemplateUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/info/CredHubInfoTemplateUnitTests.java @@ -16,14 +16,12 @@ package org.springframework.credhub.core.info; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoJUnitRunner; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; import org.springframework.credhub.core.CredHubTemplate; @@ -35,18 +33,16 @@ import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.STRICT_STUBS) public class CredHubInfoTemplateUnitTests { - @Rule - public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS); - @Mock private RestTemplate restTemplate; private CredHubInfoOperations credHubTemplate; - @Before + @BeforeEach public void setUp() { this.credHubTemplate = new CredHubTemplate(this.restTemplate).info(); } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/interpolation/CredHubInterpolationTemplateUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/interpolation/CredHubInterpolationTemplateUnitTests.java index b1000a2..4bb6c58 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/interpolation/CredHubInterpolationTemplateUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/interpolation/CredHubInterpolationTemplateUnitTests.java @@ -19,14 +19,12 @@ package org.springframework.credhub.core.interpolation; import java.io.IOException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoJUnitRunner; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; import org.springframework.credhub.core.CredHubTemplate; @@ -42,18 +40,16 @@ import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.STRICT_STUBS) public class CredHubInterpolationTemplateUnitTests { - @Rule - public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS); - @Mock private RestTemplate restTemplate; private CredHubInterpolationOperations credHubTemplate; - @Before + @BeforeEach public void setUp() { this.credHubTemplate = new CredHubTemplate(this.restTemplate).interpolation(); } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/permission/CredHubPermissionTemplateUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/permission/CredHubPermissionTemplateUnitTests.java index e79c8ba..6e75098 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/permission/CredHubPermissionTemplateUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/permission/CredHubPermissionTemplateUnitTests.java @@ -18,11 +18,13 @@ package org.springframework.credhub.core.permission; import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.springframework.credhub.core.CredHubTemplate; import org.springframework.credhub.support.CredentialPermissions; @@ -41,7 +43,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.STRICT_STUBS) public class CredHubPermissionTemplateUnitTests { private static final SimpleCredentialName NAME = new SimpleCredentialName("example", "credential"); @@ -51,7 +54,7 @@ public class CredHubPermissionTemplateUnitTests { private CredHubPermissionOperations credHubTemplate; - @Before + @BeforeEach public void setUp() { this.credHubTemplate = new CredHubTemplate(this.restTemplate).permissions(); } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/permissionV2/CredHubPermissionV2TemplateUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/permissionV2/CredHubPermissionV2TemplateUnitTests.java index 1e62944..cd6dcbe 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/permissionV2/CredHubPermissionV2TemplateUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/permissionV2/CredHubPermissionV2TemplateUnitTests.java @@ -16,11 +16,11 @@ package org.springframework.credhub.core.permissionV2; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.credhub.core.CredHubTemplate; import org.springframework.credhub.support.CredentialPermission; @@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class CredHubPermissionV2TemplateUnitTests { private static final SimpleCredentialName PATH = new SimpleCredentialName("example", "credential", "*"); @@ -49,7 +49,7 @@ public class CredHubPermissionV2TemplateUnitTests { private CredHubPermissionV2Operations credHubTemplate; - @Before + @BeforeEach public void setUp() { this.credHubTemplate = new CredHubTemplate(this.restTemplate).permissionsV2(); } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/CertificateSummaryDataTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/CertificateSummaryDataTests.java index af3775d..00f39bf 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/CertificateSummaryDataTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/CertificateSummaryDataTests.java @@ -16,7 +16,7 @@ package org.springframework.credhub.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.certificate.CertificateSummaryData; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredHubRequestUnitTestsBase.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredHubRequestUnitTestsBase.java index 8daed6c..7aa5d2c 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredHubRequestUnitTestsBase.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredHubRequestUnitTestsBase.java @@ -17,7 +17,7 @@ package org.springframework.credhub.support; import com.jayway.jsonpath.DocumentContext; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredHubRequest.CredHubRequestBuilder; import org.springframework.credhub.support.permissions.Actor; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredentialPathDataTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredentialPathDataTests.java index 570c417..0ee7106 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredentialPathDataTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredentialPathDataTests.java @@ -16,7 +16,7 @@ package org.springframework.credhub.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredentialSummaryDataUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredentialSummaryDataUnitTests.java index 700db9e..1e28a5e 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredentialSummaryDataUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredentialSummaryDataUnitTests.java @@ -18,7 +18,7 @@ package org.springframework.credhub.support; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/JsonParsingUnitTestsBase.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/JsonParsingUnitTestsBase.java index f8a71ee..1e63eee 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/JsonParsingUnitTestsBase.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/JsonParsingUnitTestsBase.java @@ -19,7 +19,7 @@ package org.springframework.credhub.support; import java.util.Date; import com.fasterxml.jackson.databind.util.StdDateFormat; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import static org.assertj.core.api.Assertions.assertThat; @@ -46,7 +46,7 @@ public abstract class JsonParsingUnitTestsBase { Date testDate; - @Before + @BeforeEach public void setUpJsonParsing() throws Exception { this.testDate = new StdDateFormat().parse(TEST_DATE_STRING); } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/ServiceInstanceCredentialNameUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/ServiceInstanceCredentialNameUnitTests.java index 1204707..01b5b60 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/ServiceInstanceCredentialNameUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/ServiceInstanceCredentialNameUnitTests.java @@ -16,7 +16,7 @@ package org.springframework.credhub.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/SimpleCredentialNameUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/SimpleCredentialNameUnitTests.java index caf18d5..cbc2303 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/SimpleCredentialNameUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/SimpleCredentialNameUnitTests.java @@ -16,7 +16,7 @@ package org.springframework.credhub.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateCredentialDetailsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateCredentialDetailsUnitTests.java index c6c75bb..28e6a3e 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateCredentialDetailsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateCredentialDetailsUnitTests.java @@ -16,7 +16,7 @@ package org.springframework.credhub.support.certificate; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredentialDetails; import org.springframework.credhub.support.CredentialDetailsData; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateCredentialRequestUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateCredentialRequestUnitTests.java index 2d68ec3..243280c 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateCredentialRequestUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateCredentialRequestUnitTests.java @@ -17,17 +17,19 @@ package org.springframework.credhub.support.certificate; import com.jayway.jsonpath.DocumentContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredHubRequestUnitTestsBase; import org.springframework.credhub.support.JsonPathAssert; import org.springframework.credhub.support.SimpleCredentialName; import org.springframework.credhub.support.WriteMode; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; + public class CertificateCredentialRequestUnitTests extends CredHubRequestUnitTestsBase { - @Before + @BeforeEach public void setUp() { buildRequest(new CertificateCredential("cert", "ca", "private-key")); } @@ -71,11 +73,13 @@ public class CertificateCredentialRequestUnitTests extends CredHubRequestUnitTes assertNoPermissions(json); } - @Test(expected = IllegalArgumentException.class) + @Test public void serializeWithNoValues() { - buildRequest(new CertificateCredential(null, null, null)); + assertThatIllegalArgumentException().isThrownBy(() -> { + buildRequest(new CertificateCredential(null, null, null)); - toJsonPath(this.requestBuilder); + toJsonPath(this.requestBuilder); + }); } @SuppressWarnings("deprecation") diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateParametersRequestUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateParametersRequestUnitTests.java index 026df98..b1b5602 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateParametersRequestUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateParametersRequestUnitTests.java @@ -17,8 +17,8 @@ package org.springframework.credhub.support.certificate; import com.jayway.jsonpath.DocumentContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredHubRequestUnitTestsBase; import org.springframework.credhub.support.JsonPathAssert; @@ -26,10 +26,12 @@ import org.springframework.credhub.support.KeyLength; import org.springframework.credhub.support.SimpleCredentialName; import org.springframework.credhub.support.WriteMode; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; + @SuppressWarnings("deprecation") public class CertificateParametersRequestUnitTests extends CredHubRequestUnitTestsBase { - @Before + @BeforeEach public void setUp() { this.requestBuilder = CertificateParametersRequest.builder(); } @@ -132,13 +134,15 @@ public class CertificateParametersRequestUnitTests extends CredHubRequestUnitTes assertParametersNotSet(json); } - @Test(expected = IllegalArgumentException.class) + @Test public void serializeWithEmptyParameters() { - this.requestBuilder = CertificateParametersRequest.builder() - .name(new SimpleCredentialName("example", "credential")).overwrite(true) - .parameters(CertificateParameters.builder().keyLength(KeyLength.LENGTH_2048).build()); + assertThatIllegalArgumentException().isThrownBy(() -> { + this.requestBuilder = CertificateParametersRequest.builder() + .name(new SimpleCredentialName("example", "credential")).overwrite(true) + .parameters(CertificateParameters.builder().keyLength(KeyLength.LENGTH_2048).build()); - toJsonPath(this.requestBuilder); + toJsonPath(this.requestBuilder); + }); } private void assertParametersNotSet(DocumentContext json) { diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/info/VersionInfoTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/info/VersionInfoTests.java index 37d6266..7da6dad 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/info/VersionInfoTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/info/VersionInfoTests.java @@ -16,7 +16,7 @@ package org.springframework.credhub.support.info; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.JsonParsingUnitTestsBase; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/json/JsonCredentialDetailsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/json/JsonCredentialDetailsUnitTests.java index 38bbc3a..9d63603 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/json/JsonCredentialDetailsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/json/JsonCredentialDetailsUnitTests.java @@ -16,7 +16,7 @@ package org.springframework.credhub.support.json; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredentialDetails; import org.springframework.credhub.support.CredentialDetailsData; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/json/JsonCredentialRequestUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/json/JsonCredentialRequestUnitTests.java index 49e42d6..62c03a6 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/json/JsonCredentialRequestUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/json/JsonCredentialRequestUnitTests.java @@ -17,8 +17,8 @@ package org.springframework.credhub.support.json; import com.jayway.jsonpath.DocumentContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredHubRequestUnitTestsBase; import org.springframework.credhub.support.JsonPathAssert; @@ -27,7 +27,7 @@ import org.springframework.credhub.support.WriteMode; public class JsonCredentialRequestUnitTests extends CredHubRequestUnitTestsBase { - @Before + @BeforeEach public void setUp() { this.requestBuilder = JsonCredentialRequest.builder().name(new SimpleCredentialName("example", "credential")) .value(new JsonCredential() { diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordCredentialDetailsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordCredentialDetailsUnitTests.java index 253872a..1e42935 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordCredentialDetailsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordCredentialDetailsUnitTests.java @@ -16,7 +16,7 @@ package org.springframework.credhub.support.password; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredentialDetails; import org.springframework.credhub.support.CredentialDetailsData; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordCredentialRequestUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordCredentialRequestUnitTests.java index 8db6c6f..3ff91ab 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordCredentialRequestUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordCredentialRequestUnitTests.java @@ -17,8 +17,8 @@ package org.springframework.credhub.support.password; import com.jayway.jsonpath.DocumentContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredHubRequestUnitTestsBase; import org.springframework.credhub.support.JsonPathAssert; @@ -28,7 +28,7 @@ import org.springframework.credhub.support.WriteMode; @SuppressWarnings("deprecation") public class PasswordCredentialRequestUnitTests extends CredHubRequestUnitTestsBase { - @Before + @BeforeEach public void setUp() { this.requestBuilder = PasswordCredentialRequest.builder() .name(new SimpleCredentialName("example", "credential")).overwrite(true).mode(WriteMode.OVERWRITE) diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordParametersRequestUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordParametersRequestUnitTests.java index 9f6deb1..71d6abc 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordParametersRequestUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordParametersRequestUnitTests.java @@ -17,8 +17,8 @@ package org.springframework.credhub.support.password; import com.jayway.jsonpath.DocumentContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredHubRequestUnitTestsBase; import org.springframework.credhub.support.JsonPathAssert; @@ -28,7 +28,7 @@ import org.springframework.credhub.support.WriteMode; @SuppressWarnings("deprecation") public class PasswordParametersRequestUnitTests extends CredHubRequestUnitTestsBase { - @Before + @BeforeEach public void setUp() { this.requestBuilder = PasswordParametersRequest.builder(); } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionUnitTests.java index 1a3cd1a..0e68d05 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionUnitTests.java @@ -19,7 +19,7 @@ package org.springframework.credhub.support.permissions; import java.util.List; import com.jayway.jsonpath.DocumentContext; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredentialPermission; import org.springframework.credhub.support.JsonParsingUnitTestsBase; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionsUnitTests.java index 3c6f888..31e04e6 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionsUnitTests.java @@ -19,7 +19,7 @@ package org.springframework.credhub.support.permissions; import java.util.List; import com.jayway.jsonpath.DocumentContext; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredentialPermissions; import org.springframework.credhub.support.JsonParsingUnitTestsBase; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaCredentialDetailsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaCredentialDetailsUnitTests.java index 8f52a8f..ff45414 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaCredentialDetailsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaCredentialDetailsUnitTests.java @@ -16,7 +16,7 @@ package org.springframework.credhub.support.rsa; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredentialDetails; import org.springframework.credhub.support.CredentialDetailsData; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaCredentialRequestUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaCredentialRequestUnitTests.java index 1cf8fee..5d155cc 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaCredentialRequestUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaCredentialRequestUnitTests.java @@ -17,17 +17,19 @@ package org.springframework.credhub.support.rsa; import com.jayway.jsonpath.DocumentContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredHubRequestUnitTestsBase; import org.springframework.credhub.support.JsonPathAssert; import org.springframework.credhub.support.SimpleCredentialName; import org.springframework.credhub.support.WriteMode; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; + public class RsaCredentialRequestUnitTests extends CredHubRequestUnitTestsBase { - @Before + @BeforeEach public void setUp() { buildRequest(new RsaCredential("public-key", "private-key")); } @@ -70,11 +72,13 @@ public class RsaCredentialRequestUnitTests extends CredHubRequestUnitTestsBase { assertNoPermissions(json); } - @Test(expected = IllegalArgumentException.class) + @Test public void serializeWithNeitherKey() { - buildRequest(new RsaCredential(null, null)); + assertThatIllegalArgumentException().isThrownBy(() -> { + buildRequest(new RsaCredential(null, null)); - toJsonPath(this.requestBuilder); + toJsonPath(this.requestBuilder); + }); } @SuppressWarnings("deprecation") diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaParametersRequestUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaParametersRequestUnitTests.java index 140c5b0..6190c22 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaParametersRequestUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaParametersRequestUnitTests.java @@ -17,8 +17,8 @@ package org.springframework.credhub.support.rsa; import com.jayway.jsonpath.DocumentContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredHubRequestUnitTestsBase; import org.springframework.credhub.support.JsonPathAssert; @@ -29,7 +29,7 @@ import org.springframework.credhub.support.WriteMode; @SuppressWarnings("deprecation") public class RsaParametersRequestUnitTests extends CredHubRequestUnitTestsBase { - @Before + @BeforeEach public void setUp() { this.requestBuilder = RsaParametersRequest.builder(); } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshCredentialDetailsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshCredentialDetailsUnitTests.java index 76e24b0..a6ee6f1 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshCredentialDetailsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshCredentialDetailsUnitTests.java @@ -16,7 +16,7 @@ package org.springframework.credhub.support.ssh; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredentialDetails; import org.springframework.credhub.support.CredentialDetailsData; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshCredentialRequestUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshCredentialRequestUnitTests.java index 6427ffe..1d48381 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshCredentialRequestUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshCredentialRequestUnitTests.java @@ -17,17 +17,19 @@ package org.springframework.credhub.support.ssh; import com.jayway.jsonpath.DocumentContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredHubRequestUnitTestsBase; import org.springframework.credhub.support.JsonPathAssert; import org.springframework.credhub.support.SimpleCredentialName; import org.springframework.credhub.support.WriteMode; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; + public class SshCredentialRequestUnitTests extends CredHubRequestUnitTestsBase { - @Before + @BeforeEach public void setUp() { buildRequest(new SshCredential("public-key", "private-key")); } @@ -69,11 +71,13 @@ public class SshCredentialRequestUnitTests extends CredHubRequestUnitTestsBase { assertNoPermissions(json); } - @Test(expected = IllegalArgumentException.class) + @Test public void serializeWithNeitherKey() { - buildRequest(new SshCredential(null, null)); + assertThatIllegalArgumentException().isThrownBy(() -> { + buildRequest(new SshCredential(null, null)); - toJsonPath(this.requestBuilder); + toJsonPath(this.requestBuilder); + }); } @SuppressWarnings("deprecation") diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshParametersRequestUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshParametersRequestUnitTests.java index 1614f82..8ad0150 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshParametersRequestUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshParametersRequestUnitTests.java @@ -17,8 +17,8 @@ package org.springframework.credhub.support.ssh; import com.jayway.jsonpath.DocumentContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredHubRequestUnitTestsBase; import org.springframework.credhub.support.JsonPathAssert; @@ -29,7 +29,7 @@ import org.springframework.credhub.support.WriteMode; @SuppressWarnings("deprecation") public class SshParametersRequestUnitTests extends CredHubRequestUnitTestsBase { - @Before + @BeforeEach public void setUp() { this.requestBuilder = SshParametersRequest.builder(); } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserCredentialDetailsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserCredentialDetailsUnitTests.java index 7c81451..9e143d1 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserCredentialDetailsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserCredentialDetailsUnitTests.java @@ -16,7 +16,7 @@ package org.springframework.credhub.support.user; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredentialDetails; import org.springframework.credhub.support.CredentialDetailsData; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserCredentialRequestUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserCredentialRequestUnitTests.java index f3c320f..7a9c8df 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserCredentialRequestUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserCredentialRequestUnitTests.java @@ -17,8 +17,8 @@ package org.springframework.credhub.support.user; import com.jayway.jsonpath.DocumentContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredHubRequestUnitTestsBase; import org.springframework.credhub.support.JsonPathAssert; @@ -29,7 +29,7 @@ import org.springframework.credhub.support.user.UserCredentialRequest.UserCreden @SuppressWarnings("deprecation") public class UserCredentialRequestUnitTests extends CredHubRequestUnitTestsBase { - @Before + @BeforeEach public void setUp() { this.requestBuilder = UserCredentialRequest.builder().name(new SimpleCredentialName("example", "credential")) .overwrite(true).mode(WriteMode.OVERWRITE).value(new UserCredential("myname", "secret")); diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserParametersRequestUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserParametersRequestUnitTests.java index b7b71bf..afa4551 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserParametersRequestUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserParametersRequestUnitTests.java @@ -17,8 +17,8 @@ package org.springframework.credhub.support.user; import com.jayway.jsonpath.DocumentContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredHubRequestUnitTestsBase; import org.springframework.credhub.support.JsonPathAssert; @@ -29,7 +29,7 @@ import org.springframework.credhub.support.password.PasswordParameters; @SuppressWarnings("deprecation") public class UserParametersRequestUnitTests extends CredHubRequestUnitTestsBase { - @Before + @BeforeEach public void setUp() { this.requestBuilder = UserParametersRequest.builder(); } diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/value/ValueCredentialDetailsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/value/ValueCredentialDetailsUnitTests.java index f4473e3..1638507 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/value/ValueCredentialDetailsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/value/ValueCredentialDetailsUnitTests.java @@ -16,7 +16,7 @@ package org.springframework.credhub.support.value; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredentialDetails; import org.springframework.credhub.support.CredentialDetailsData; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/value/ValueCredentialRequestUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/value/ValueCredentialRequestUnitTests.java index 6f17a5d..b975529 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/value/ValueCredentialRequestUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/value/ValueCredentialRequestUnitTests.java @@ -17,8 +17,8 @@ package org.springframework.credhub.support.value; import com.jayway.jsonpath.DocumentContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.support.CredHubRequestUnitTestsBase; import org.springframework.credhub.support.JsonPathAssert; @@ -26,7 +26,7 @@ import org.springframework.credhub.support.SimpleCredentialName; public class ValueCredentialRequestUnitTests extends CredHubRequestUnitTestsBase { - @Before + @BeforeEach @SuppressWarnings("deprecation") public void setUp() { this.requestBuilder = ValueCredentialRequest.builder().name(new SimpleCredentialName("example", "credential")) diff --git a/spring-credhub-integration-tests/build.gradle b/spring-credhub-integration-tests/build.gradle index 31c8ab6..3116cf8 100644 --- a/spring-credhub-integration-tests/build.gradle +++ b/spring-credhub-integration-tests/build.gradle @@ -48,8 +48,9 @@ dependencies { compile("org.apache.httpcomponents:httpclient") } - testCompile("org.springframework.boot:spring-boot-starter-test") - testCompile("org.assertj:assertj-core") + testImplementation("org.springframework.boot:spring-boot-starter-test") + testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}") + testImplementation("org.assertj:assertj-core:${assertJVersion}") } test { diff --git a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/CertificateIntegrationTests.java b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/CertificateIntegrationTests.java index 511a65a..88d2412 100644 --- a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/CertificateIntegrationTests.java +++ b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/CertificateIntegrationTests.java @@ -18,9 +18,9 @@ package org.springframework.credhub.integration; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.core.certificate.CredHubCertificateOperations; import org.springframework.credhub.core.credential.CredHubCredentialOperations; @@ -35,7 +35,7 @@ import org.springframework.credhub.support.certificate.CertificateParametersRequ import org.springframework.credhub.support.certificate.CertificateSummary; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class CertificateIntegrationTests extends CredHubIntegrationTests { @@ -49,7 +49,7 @@ public class CertificateIntegrationTests extends CredHubIntegrationTests { private CredHubCertificateOperations certificates; - @Before + @BeforeEach public void setUp() { this.credentials = this.operations.credentials(); this.certificates = this.operations.certificates(); @@ -58,7 +58,7 @@ public class CertificateIntegrationTests extends CredHubIntegrationTests { deleteCredentialIfExists(ROOT_CERT_NAME); } - @After + @AfterEach public void tearDown() { deleteCredentialIfExists(TEST_CERT_NAME); deleteCredentialIfExists(ROOT_CERT_NAME); diff --git a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/CredHubIntegrationTests.java b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/CredHubIntegrationTests.java index b8f4856..5cb15ba 100644 --- a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/CredHubIntegrationTests.java +++ b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/CredHubIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.credhub.integration; -import org.junit.Before; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -27,10 +26,8 @@ import org.springframework.credhub.core.CredHubOperations; import org.springframework.credhub.support.CredentialName; import org.springframework.credhub.support.info.VersionInfo; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.StringUtils; -@RunWith(SpringRunner.class) @SpringBootTest(classes = { TestApplication.class }) @ActiveProfiles("test") public abstract class CredHubIntegrationTests { @@ -43,7 +40,7 @@ public abstract class CredHubIntegrationTests { @Autowired protected CredHubOperations operations; - @Before + @BeforeEach public void setupVersionInfo() { if (StringUtils.hasText(this.serverVersion)) { this.versionInfo = new VersionInfo(this.serverVersion); diff --git a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/CredentialIntegrationTests.java b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/CredentialIntegrationTests.java index 640f91c..531da33 100644 --- a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/CredentialIntegrationTests.java +++ b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/CredentialIntegrationTests.java @@ -18,9 +18,9 @@ package org.springframework.credhub.integration; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.core.credential.CredHubCredentialOperations; import org.springframework.credhub.support.CredentialDetails; @@ -35,7 +35,7 @@ import org.springframework.credhub.support.value.ValueCredential; import org.springframework.credhub.support.value.ValueCredentialRequest; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class CredentialIntegrationTests extends CredHubIntegrationTests { @@ -48,7 +48,7 @@ public class CredentialIntegrationTests extends CredHubIntegrationTests { private PasswordParameters.PasswordParametersBuilder passwordParameters; - @Before + @BeforeEach public void setUp() { this.credentials = this.operations.credentials(); @@ -58,7 +58,7 @@ public class CredentialIntegrationTests extends CredHubIntegrationTests { deleteCredentialIfExists(CREDENTIAL_NAME); } - @After + @AfterEach public void tearDown() { deleteCredentialIfExists(CREDENTIAL_NAME); diff --git a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/InfoIntegrationTests.java b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/InfoIntegrationTests.java index 7f49603..993e343 100644 --- a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/InfoIntegrationTests.java +++ b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/InfoIntegrationTests.java @@ -16,8 +16,8 @@ package org.springframework.credhub.integration; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.core.info.CredHubInfoOperations; import org.springframework.credhub.support.info.VersionInfo; @@ -28,7 +28,7 @@ public class InfoIntegrationTests extends CredHubIntegrationTests { private CredHubInfoOperations info; - @Before + @BeforeEach public void setUp() { this.info = this.operations.info(); } diff --git a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/InterpolationIntegrationTests.java b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/InterpolationIntegrationTests.java index 3f75eb4..2761010 100644 --- a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/InterpolationIntegrationTests.java +++ b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/InterpolationIntegrationTests.java @@ -21,9 +21,9 @@ import java.util.HashMap; import java.util.Map; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.core.credential.CredHubCredentialOperations; import org.springframework.credhub.core.interpolation.CredHubInterpolationOperations; @@ -46,13 +46,13 @@ public class InterpolationIntegrationTests extends CredHubIntegrationTests { private CredHubCredentialOperations credentials; - @Before + @BeforeEach public void setUp() { this.interpolation = this.operations.interpolation(); this.credentials = this.operations.credentials(); } - @After + @AfterEach public void tearDown() { deleteCredentialIfExists(CREDENTIAL_NAME); } diff --git a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/PermissionIntegrationTests.java b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/PermissionIntegrationTests.java index 979ce0f..561a651 100644 --- a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/PermissionIntegrationTests.java +++ b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/PermissionIntegrationTests.java @@ -18,9 +18,9 @@ package org.springframework.credhub.integration; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.core.credential.CredHubCredentialOperations; import org.springframework.credhub.core.permission.CredHubPermissionOperations; @@ -31,7 +31,7 @@ import org.springframework.credhub.support.permissions.Permission; import org.springframework.credhub.support.value.ValueCredentialRequest; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class PermissionIntegrationTests extends CredHubIntegrationTests { @@ -44,7 +44,7 @@ public class PermissionIntegrationTests extends CredHubIntegrationTests { private CredHubPermissionOperations permissions; - @Before + @BeforeEach public void setUp() { this.credentials = this.operations.credentials(); this.permissions = this.operations.permissions(); @@ -52,7 +52,7 @@ public class PermissionIntegrationTests extends CredHubIntegrationTests { deleteCredentialIfExists(CREDENTIAL_NAME); } - @After + @AfterEach public void tearDown() { deleteCredentialIfExists(CREDENTIAL_NAME); } diff --git a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/PermissionV2IntegrationTests.java b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/PermissionV2IntegrationTests.java index 530984c..3defce5 100644 --- a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/PermissionV2IntegrationTests.java +++ b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/PermissionV2IntegrationTests.java @@ -18,9 +18,9 @@ package org.springframework.credhub.integration; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.credhub.core.credential.CredHubCredentialOperations; import org.springframework.credhub.core.permissionV2.CredHubPermissionV2Operations; @@ -33,7 +33,7 @@ import org.springframework.credhub.support.permissions.Permission; import org.springframework.credhub.support.value.ValueCredentialRequest; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class PermissionV2IntegrationTests extends CredHubIntegrationTests { @@ -46,7 +46,7 @@ public class PermissionV2IntegrationTests extends CredHubIntegrationTests { private CredHubPermissionV2Operations permissions; - @Before + @BeforeEach public void setUp() { this.credentials = this.operations.credentials(); this.permissions = this.operations.permissionsV2(); @@ -54,7 +54,7 @@ public class PermissionV2IntegrationTests extends CredHubIntegrationTests { deleteCredentialIfExists(CREDENTIAL_NAME); } - @After + @AfterEach public void tearDown() { deleteCredentialIfExists(CREDENTIAL_NAME); } diff --git a/spring-credhub-reactive-integration-tests/build.gradle b/spring-credhub-reactive-integration-tests/build.gradle index 359de2f..4093158 100644 --- a/spring-credhub-reactive-integration-tests/build.gradle +++ b/spring-credhub-reactive-integration-tests/build.gradle @@ -41,9 +41,10 @@ dependencies { compile("org.springframework.security:spring-security-config") compile("org.springframework.security:spring-security-oauth2-client") - testCompile("org.springframework.boot:spring-boot-starter-test") - testCompile("io.projectreactor:reactor-test") - testCompile("org.assertj:assertj-core") + testImplementation("org.springframework.boot:spring-boot-starter-test") + testImplementation("io.projectreactor:reactor-test") + testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}") + testImplementation("org.assertj:assertj-core:${assertJVersion}") } test { diff --git a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveCertificateIntegrationTests.java b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveCertificateIntegrationTests.java index 01300c2..a4d5cae 100644 --- a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveCertificateIntegrationTests.java +++ b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveCertificateIntegrationTests.java @@ -18,9 +18,9 @@ package org.springframework.credhub.integration; import java.util.concurrent.atomic.AtomicReference; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.test.StepVerifier; import org.springframework.credhub.core.certificate.ReactiveCredHubCertificateOperations; @@ -32,7 +32,7 @@ import org.springframework.credhub.support.certificate.CertificateParameters; import org.springframework.credhub.support.certificate.CertificateParametersRequest; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class ReactiveCertificateIntegrationTests extends ReactiveCredHubIntegrationTests { @@ -46,7 +46,7 @@ public class ReactiveCertificateIntegrationTests extends ReactiveCredHubIntegrat private ReactiveCredHubCertificateOperations certificates; - @Before + @BeforeEach public void setUp() { this.credentials = this.operations.credentials(); this.certificates = this.operations.certificates(); @@ -55,7 +55,7 @@ public class ReactiveCertificateIntegrationTests extends ReactiveCredHubIntegrat deleteCredentialIfExists(ROOT_CERT_NAME); } - @After + @AfterEach public void tearDown() { deleteCredentialIfExists(TEST_CERT_NAME); deleteCredentialIfExists(ROOT_CERT_NAME); diff --git a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveCredHubIntegrationTests.java b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveCredHubIntegrationTests.java index a973f7d..46ad661 100644 --- a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveCredHubIntegrationTests.java +++ b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveCredHubIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.credhub.integration; -import org.junit.Before; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; import reactor.core.publisher.Mono; import org.springframework.beans.factory.annotation.Autowired; @@ -27,10 +26,8 @@ import org.springframework.credhub.core.ReactiveCredHubOperations; import org.springframework.credhub.support.CredentialName; import org.springframework.credhub.support.info.VersionInfo; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.StringUtils; -@RunWith(SpringRunner.class) @SpringBootTest(classes = { TestApplication.class }) @ActiveProfiles("test") public abstract class ReactiveCredHubIntegrationTests { @@ -43,7 +40,7 @@ public abstract class ReactiveCredHubIntegrationTests { @Autowired protected ReactiveCredHubOperations operations; - @Before + @BeforeEach public void setupVersionInfo() { if (StringUtils.hasText(this.serverVersion)) { this.versionInfo = new VersionInfo(this.serverVersion); diff --git a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveCredentialIntegrationTests.java b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveCredentialIntegrationTests.java index 55dc25e..462a6b7 100644 --- a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveCredentialIntegrationTests.java +++ b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveCredentialIntegrationTests.java @@ -18,9 +18,9 @@ package org.springframework.credhub.integration; import java.util.concurrent.atomic.AtomicReference; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.test.StepVerifier; import org.springframework.credhub.core.credential.ReactiveCredHubCredentialOperations; @@ -35,7 +35,7 @@ import org.springframework.credhub.support.value.ValueCredential; import org.springframework.credhub.support.value.ValueCredentialRequest; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class ReactiveCredentialIntegrationTests extends ReactiveCredHubIntegrationTests { @@ -48,7 +48,7 @@ public class ReactiveCredentialIntegrationTests extends ReactiveCredHubIntegrati private PasswordParameters.PasswordParametersBuilder passwordParameters; - @Before + @BeforeEach public void setUp() { this.credentials = this.operations.credentials(); @@ -58,7 +58,7 @@ public class ReactiveCredentialIntegrationTests extends ReactiveCredHubIntegrati deleteCredentialIfExists(CREDENTIAL_NAME); } - @After + @AfterEach public void tearDown() { deleteCredentialIfExists(CREDENTIAL_NAME); diff --git a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveInfoIntegrationTests.java b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveInfoIntegrationTests.java index a61b2fb..ab15cac 100644 --- a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveInfoIntegrationTests.java +++ b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveInfoIntegrationTests.java @@ -16,8 +16,8 @@ package org.springframework.credhub.integration; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.test.StepVerifier; import org.springframework.credhub.core.info.ReactiveCredHubInfoOperations; @@ -28,7 +28,7 @@ public class ReactiveInfoIntegrationTests extends ReactiveCredHubIntegrationTest private ReactiveCredHubInfoOperations info; - @Before + @BeforeEach public void setUp() { this.info = this.operations.info(); } diff --git a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveInterpolationIntegrationTests.java b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveInterpolationIntegrationTests.java index 89423c2..fac183b 100644 --- a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveInterpolationIntegrationTests.java +++ b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveInterpolationIntegrationTests.java @@ -21,9 +21,9 @@ import java.util.HashMap; import java.util.Map; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.test.StepVerifier; import org.springframework.credhub.core.credential.ReactiveCredHubCredentialOperations; @@ -45,13 +45,13 @@ public class ReactiveInterpolationIntegrationTests extends ReactiveCredHubIntegr private ReactiveCredHubCredentialOperations credentials; - @Before + @BeforeEach public void setUp() { this.interpolation = this.operations.interpolation(); this.credentials = this.operations.credentials(); } - @After + @AfterEach public void tearDown() { deleteCredentialIfExists(CREDENTIAL_NAME); } diff --git a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactivePermissionIntegrationTests.java b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactivePermissionIntegrationTests.java index 75fe7b7..b77d34e 100644 --- a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactivePermissionIntegrationTests.java +++ b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactivePermissionIntegrationTests.java @@ -16,9 +16,9 @@ package org.springframework.credhub.integration; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -32,7 +32,7 @@ import org.springframework.credhub.support.permissions.Permission; import org.springframework.credhub.support.value.ValueCredentialRequest; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class ReactivePermissionIntegrationTests extends ReactiveCredHubIntegrationTests { @@ -45,7 +45,7 @@ public class ReactivePermissionIntegrationTests extends ReactiveCredHubIntegrati private ReactiveCredHubPermissionOperations permissions; - @Before + @BeforeEach public void setUp() { this.credentials = this.operations.credentials(); this.permissions = this.operations.permissions(); @@ -54,7 +54,7 @@ public class ReactivePermissionIntegrationTests extends ReactiveCredHubIntegrati deletePermissionsIfExist(); } - @After + @AfterEach public void tearDown() { deleteCredentialIfExists(CREDENTIAL_NAME); deletePermissionsIfExist(); diff --git a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactivePermissionV2IntegrationTests.java b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactivePermissionV2IntegrationTests.java index e9556ba..59746cf 100644 --- a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactivePermissionV2IntegrationTests.java +++ b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactivePermissionV2IntegrationTests.java @@ -19,9 +19,9 @@ package org.springframework.credhub.integration; import java.util.List; import java.util.concurrent.atomic.AtomicReference; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.test.StepVerifier; import org.springframework.credhub.core.credential.ReactiveCredHubCredentialOperations; @@ -35,7 +35,7 @@ import org.springframework.credhub.support.permissions.Permission; import org.springframework.credhub.support.value.ValueCredentialRequest; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class ReactivePermissionV2IntegrationTests extends ReactiveCredHubIntegrationTests { @@ -48,7 +48,7 @@ public class ReactivePermissionV2IntegrationTests extends ReactiveCredHubIntegra private ReactiveCredHubPermissionV2Operations permissions; - @Before + @BeforeEach public void setUp() { this.credentials = this.operations.credentials(); this.permissions = this.operations.permissionsV2(); @@ -56,7 +56,7 @@ public class ReactivePermissionV2IntegrationTests extends ReactiveCredHubIntegra deleteCredentialIfExists(CREDENTIAL_NAME); } - @After + @AfterEach public void tearDown() { deleteCredentialIfExists(CREDENTIAL_NAME); } diff --git a/spring-credhub-starter/build.gradle b/spring-credhub-starter/build.gradle index 4944ba0..08ad683 100644 --- a/spring-credhub-starter/build.gradle +++ b/spring-credhub-starter/build.gradle @@ -43,5 +43,6 @@ dependencies { testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("org.springframework.boot:spring-boot-starter-web") + testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}") testImplementation("org.assertj:assertj-core:${assertJVersion}") } diff --git a/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubAutoConfigurationTests.java b/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubAutoConfigurationTests.java index 48d9e03..1bda35b 100644 --- a/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubAutoConfigurationTests.java +++ b/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubAutoConfigurationTests.java @@ -18,7 +18,7 @@ package org.springframework.credhub.autoconfig; import java.time.Duration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigureBefore; diff --git a/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubOAuth2AutoConfigurationTests.java b/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubOAuth2AutoConfigurationTests.java index c168069..7cf2a55 100644 --- a/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubOAuth2AutoConfigurationTests.java +++ b/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubOAuth2AutoConfigurationTests.java @@ -16,7 +16,7 @@ package org.springframework.credhub.autoconfig; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.FilteredClassLoader; @@ -35,7 +35,6 @@ public class CredHubOAuth2AutoConfigurationTests { private final Class[] configurations = { CredHubAutoConfiguration.class, CredHubOAuth2AutoConfiguration.class }; private final String[] oAuth2ClientProperties = { "spring.credhub.oauth2.registration-id=test-client", - "spring.security.oauth2.client.registration.credhub-client.provider=uaa", "spring.security.oauth2.client.registration.credhub-client.client-id=test-client", "spring.security.oauth2.client.registration.credhub-client.client-secret=test-secret", diff --git a/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubTemplateAutoConfigurationTests.java b/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubTemplateAutoConfigurationTests.java index 1d4ecc8..cef5c27 100644 --- a/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubTemplateAutoConfigurationTests.java +++ b/spring-credhub-starter/src/test/java/org/springframework/credhub/autoconfig/CredHubTemplateAutoConfigurationTests.java @@ -19,7 +19,7 @@ package org.springframework.credhub.autoconfig; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener;