From b02f66fd222e6860f0cc68af16f3e9cf9e663b98 Mon Sep 17 00:00:00 2001 From: Dominic Schabel Date: Tue, 16 Feb 2021 09:37:36 +0100 Subject: [PATCH] JUnit5 support (#67) * First preparation for JUnit5 Signed-off-by: Dominic Schabel * Migrated all tests to JUnit5 Signed-off-by: Dominic Schabel --- hawkbit-extension-artifact-repository-gcs/pom.xml | 2 +- .../artifact/repository/GcsRepositoryTest.java | 11 ++++++----- hawkbit-extension-artifact-repository-mongo/pom.xml | 2 +- .../repository/MongoDBArtifactStoreTest.java | 7 ++----- hawkbit-extension-artifact-repository-s3/pom.xml | 2 +- .../artifact/repository/S3RepositoryTest.java | 13 +++++++------ 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/hawkbit-extension-artifact-repository-gcs/pom.xml b/hawkbit-extension-artifact-repository-gcs/pom.xml index 1691357..3289bf3 100644 --- a/hawkbit-extension-artifact-repository-gcs/pom.xml +++ b/hawkbit-extension-artifact-repository-gcs/pom.xml @@ -59,7 +59,7 @@ io.qameta.allure - allure-junit4 + allure-junit5 test diff --git a/hawkbit-extension-artifact-repository-gcs/src/test/java/org/eclipse/hawkbit/artifact/repository/GcsRepositoryTest.java b/hawkbit-extension-artifact-repository-gcs/src/test/java/org/eclipse/hawkbit/artifact/repository/GcsRepositoryTest.java index 653455d..56820be 100644 --- a/hawkbit-extension-artifact-repository-gcs/src/test/java/org/eclipse/hawkbit/artifact/repository/GcsRepositoryTest.java +++ b/hawkbit-extension-artifact-repository-gcs/src/test/java/org/eclipse/hawkbit/artifact/repository/GcsRepositoryTest.java @@ -29,9 +29,9 @@ import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact; import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash; -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.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; @@ -47,11 +47,12 @@ import io.qameta.allure.Description; import io.qameta.allure.Feature; import io.qameta.allure.Story; +import org.mockito.junit.jupiter.MockitoExtension; /** * Test class for the {@link GcsRepository}. */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) @Feature("Unit Tests - GCS Repository") @Story("GCS Artifact Repository") public class GcsRepositoryTest { @@ -70,7 +71,7 @@ public class GcsRepositoryTest { private ArgumentCaptor blobCaptor; private GcsRepository gcsRepositoryUnderTest; - @Before + @BeforeEach public void before() { gcsStorageMock = mock(Storage.class); gcsRepositoryUnderTest = new GcsRepository(gcsStorageMock, gcpProperties); diff --git a/hawkbit-extension-artifact-repository-mongo/pom.xml b/hawkbit-extension-artifact-repository-mongo/pom.xml index 793c634..a5b9774 100644 --- a/hawkbit-extension-artifact-repository-mongo/pom.xml +++ b/hawkbit-extension-artifact-repository-mongo/pom.xml @@ -65,7 +65,7 @@ io.qameta.allure - allure-junit4 + allure-junit5 test diff --git a/hawkbit-extension-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/MongoDBArtifactStoreTest.java b/hawkbit-extension-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/MongoDBArtifactStoreTest.java index ac600a7..e5c9ae3 100644 --- a/hawkbit-extension-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/MongoDBArtifactStoreTest.java +++ b/hawkbit-extension-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/MongoDBArtifactStoreTest.java @@ -18,15 +18,13 @@ import java.security.NoSuchAlgorithmException; import java.util.Random; +import io.qameta.allure.Description; import org.eclipse.hawkbit.artifact.TestConfiguration; import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact; import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Description; -import org.springframework.test.context.junit4.SpringRunner; import com.google.common.io.BaseEncoding; @@ -36,7 +34,6 @@ @Feature("Component Tests - Repository") @Story("Artifact Store MongoDB") -@RunWith(SpringRunner.class) @SpringBootTest(classes = {MongoDBArtifactStoreAutoConfiguration.class, TestConfiguration.class}, properties = { "spring.mongodb.embedded.version=3.5.5", "spring.mongodb.embedded.features=sync_delay,no_http_interface_arg"}) diff --git a/hawkbit-extension-artifact-repository-s3/pom.xml b/hawkbit-extension-artifact-repository-s3/pom.xml index e2b5b36..4601e8c 100644 --- a/hawkbit-extension-artifact-repository-s3/pom.xml +++ b/hawkbit-extension-artifact-repository-s3/pom.xml @@ -56,7 +56,7 @@ io.qameta.allure - allure-junit4 + allure-junit5 test diff --git a/hawkbit-extension-artifact-repository-s3/src/test/java/org/eclipse/hawkbit/artifact/repository/S3RepositoryTest.java b/hawkbit-extension-artifact-repository-s3/src/test/java/org/eclipse/hawkbit/artifact/repository/S3RepositoryTest.java index c84b034..87d4d00 100644 --- a/hawkbit-extension-artifact-repository-s3/src/test/java/org/eclipse/hawkbit/artifact/repository/S3RepositoryTest.java +++ b/hawkbit-extension-artifact-repository-s3/src/test/java/org/eclipse/hawkbit/artifact/repository/S3RepositoryTest.java @@ -30,14 +30,13 @@ import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact; import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.model.ObjectMetadata; @@ -49,13 +48,15 @@ import io.qameta.allure.Description; import io.qameta.allure.Feature; import io.qameta.allure.Story; +import org.mockito.junit.jupiter.MockitoExtension; /** * Test class for the {@link S3Repository}. */ -@RunWith(MockitoJUnitRunner.class) + @Feature("Unit Tests - S3 Repository") @Story("S3 Artifact Repository") +@ExtendWith(MockitoExtension.class) public class S3RepositoryTest { private static final String TENANT = "test_tenant"; @@ -81,7 +82,7 @@ public class S3RepositoryTest { private final S3RepositoryProperties s3Properties = new S3RepositoryProperties(); private S3Repository s3RepositoryUnderTest; - @Before + @BeforeEach public void before() { amazonS3Mock = mock(AmazonS3.class); s3RepositoryUnderTest = new S3Repository(amazonS3Mock, s3Properties);