Migration to JUnit5 as default test runtime (#1082)

* Migrate tests to JUnit5

Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io>

* REST docs tests migrated to JUnit5

Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io>

* Migrated security and UI tests to JUnit5

Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io>

* Migrated management tests to JUnit5

Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io>

* Reflecting changes from JUnit5 migration

Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io>

* Fix RabbitMQ test detection

Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io>

* Drop support for JUnit4

Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io>
This commit is contained in:
Dominic Schabel
2021-03-15 13:40:40 +01:00
committed by GitHub
parent 82ab18cf42
commit 81defa10a6
140 changed files with 572 additions and 657 deletions

View File

@@ -37,8 +37,8 @@ import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation;
import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric;
import org.eclipse.hawkbit.rest.util.JsonBuilder;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.MediaTypes;
import org.springframework.http.MediaType;
@@ -55,12 +55,10 @@ import io.qameta.allure.Story;
public class RootControllerDocumentationTest extends AbstractApiRestDocumentation {
private static final String CONTROLLER_ID = "CONTROLLER_ID";
@Override
@Before
@BeforeEach
public void setUp() {
host = "ddi-api.host";
resourceName = "rootcontroller";
super.setUp();
}
@Test

View File

@@ -40,11 +40,12 @@ import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
import org.eclipse.hawkbit.rest.RestConfiguration;
import org.eclipse.hawkbit.rest.util.FilterHttpResponse;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
import org.junit.Before;
import org.junit.Rule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration;
import org.springframework.restdocs.JUnitRestDocumentation;
import org.springframework.restdocs.RestDocumentationContextProvider;
import org.springframework.restdocs.RestDocumentationExtension;
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler;
import org.springframework.restdocs.payload.FieldDescriptor;
@@ -65,14 +66,12 @@ import io.qameta.allure.Feature;
*
*/
@Feature("Documentation Verfication - API")
@ExtendWith(RestDocumentationExtension.class)
@ContextConfiguration(classes = { DdiApiConfiguration.class, MgmtApiConfiguration.class, RestConfiguration.class,
RepositoryApplicationConfiguration.class, TestConfiguration.class, TestSupportBinderAutoConfiguration.class })
@TestPropertySource(locations = { "classpath:/updateserver-restdocumentation-test.properties" })
public abstract class AbstractApiRestDocumentation extends AbstractRestIntegrationTest {
@Rule
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation("target/generated-snippets");
@Autowired
protected ObjectMapper objectMapper;
@@ -89,12 +88,12 @@ public abstract class AbstractApiRestDocumentation extends AbstractRestIntegrati
protected String host = "management-api.host";
@Before
protected void setUp() {
@BeforeEach
protected void setupMvc(RestDocumentationContextProvider restDocContext) {
this.document = document(resourceName + "/{method-name}", preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()));
this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
.apply(MockMvcRestDocumentation.documentationConfiguration(this.restDocumentation).uris()
.apply(MockMvcRestDocumentation.documentationConfiguration(restDocContext).uris()
.withScheme("https").withHost(host + ".com").withPort(443))
.alwaysDo(this.document).addFilter(filterHttpResponse).build();
arrayPrefix = "[]";

View File

@@ -32,8 +32,8 @@ import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric;
import org.eclipse.hawkbit.rest.documentation.DocumenationResponseFieldsSnippet;
import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.restdocs.payload.JsonFieldType;
@@ -56,11 +56,9 @@ public class DistributionSetTagResourceDocumentationTest extends AbstractApiRest
private DistributionSet distributionSet;
@Override
@Before
@BeforeEach
public void setUp() {
resourceName = "distributionsettag";
super.setUp();
distributionSet = createDistributionSet();
}

View File

@@ -37,8 +37,8 @@ import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
import org.eclipse.hawkbit.rest.util.JsonBuilder;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.restdocs.payload.JsonFieldType;
@@ -54,11 +54,9 @@ import io.qameta.allure.Story;
@Story("DistributionSetTypes Resource")
public class DistributionSetTypesDocumentationTest extends AbstractApiRestDocumentation {
@Override
@Before
@BeforeEach
public void setUp() {
this.resourceName = "distributionsettypes";
super.setUp();
}
@Test

View File

@@ -39,8 +39,8 @@ import org.eclipse.hawkbit.rest.util.JsonBuilder;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.MediaTypes;
import org.springframework.http.MediaType;
import org.springframework.restdocs.payload.JsonFieldType;
@@ -53,17 +53,14 @@ import io.qameta.allure.Story;
/**
* Documentation generation for Management API for {@link DistributionSet}.
*
*/
@Feature("Spring Rest Docs Tests - DistributionSet")
@Story("DistributionSet Resource")
public class DistributionSetsDocumentationTest extends AbstractApiRestDocumentation {
@Override
@Before
@BeforeEach
public void setUp() {
resourceName = "distributionsets";
super.setUp();
}
@Test

View File

@@ -41,8 +41,8 @@ import org.eclipse.hawkbit.rest.documentation.DocumenationResponseFieldsSnippet;
import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
import org.eclipse.hawkbit.rest.util.JsonBuilder;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.hateoas.MediaTypes;
@@ -68,11 +68,9 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
@Autowired
private RolloutTestApprovalStrategy approvalStrategy;
@Override
@Before
@BeforeEach
public void setUp() {
this.resourceName = "rollouts";
super.setUp();
arrayPrefix = "content[].";
approvalStrategy.setApprovalNeeded(false);
}

View File

@@ -31,8 +31,8 @@ import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
import org.eclipse.hawkbit.rest.util.JsonBuilder;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.restdocs.payload.JsonFieldType;
@@ -41,19 +41,15 @@ import io.qameta.allure.Feature;
import io.qameta.allure.Story;
/**
*
* Documentation generation for Management API for {@link SoftwareModuleType}.
*
*/
@Feature("Spring Rest Docs Tests - SoftwareModuleType")
@Story("Softwaremoduletypes Resource")
public class SoftwaremoduleTypesDocumentationTest extends AbstractApiRestDocumentation {
@Override
@Before
@BeforeEach
public void setUp() {
this.resourceName = "softwaremoduletypes";
super.setUp();
}
@Test

View File

@@ -40,8 +40,8 @@ import org.eclipse.hawkbit.rest.util.JsonBuilder;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.hateoas.MediaTypes;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile;
@@ -58,11 +58,9 @@ import io.qameta.allure.Story;
@Story("Softwaremodule Resource")
public class SoftwaremodulesDocumentationTest extends AbstractApiRestDocumentation {
@Override
@Before
@BeforeEach
public void setUp() {
resourceName = "softwaremodules";
super.setUp();
}
@Test

View File

@@ -32,8 +32,8 @@ import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric;
import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.restdocs.payload.JsonFieldType;
import org.springframework.restdocs.snippet.Snippet;
@@ -54,11 +54,9 @@ public class TargetFilterQueriesResourceDocumentationTest extends AbstractApiRes
private static final String EXAMPLE_TFQ_NAME = "filter1";
private static final String EXAMPLE_TFQ_QUERY = "name==*";
@Override
@Before
@BeforeEach
public void setUp() {
resourceName = "targetfilters";
super.setUp();
}
@Test

View File

@@ -42,8 +42,8 @@ import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.hateoas.MediaTypes;
@@ -68,11 +68,9 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
private final String targetId = "137";
@Override
@Before
@BeforeEach
public void setUp() {
resourceName = "targets";
super.setUp();
}
@Test

View File

@@ -33,8 +33,8 @@ import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric;
import org.eclipse.hawkbit.rest.documentation.DocumenationResponseFieldsSnippet;
import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.restdocs.payload.JsonFieldType;
@@ -57,11 +57,9 @@ public class TargetTagResourceDocumentationTest extends AbstractApiRestDocumenta
private DistributionSet distributionSet;
@Override
@Before
@BeforeEach
public void setUp() {
resourceName = "targettag";
super.setUp();
distributionSet = createDistributionSet();
}

View File

@@ -32,8 +32,8 @@ import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.restdocs.payload.FieldDescriptor;
@@ -95,11 +95,9 @@ public class TenantResourceDocumentationTest extends AbstractApiRestDocumentatio
@Autowired
protected TenantConfigurationProperties tenantConfigurationProperties;
@Override
@Before
@BeforeEach
public void setUp() {
resourceName = "tenant";
super.setUp();
}
@Test