From 8d78cea9d259816c82ac2f9152783471aa2c2d73 Mon Sep 17 00:00:00 2001 From: Avgustin Marinov Date: Fri, 4 Oct 2024 16:51:10 +0300 Subject: [PATCH] Web env none in tests where not needed (#1871) Signed-off-by: Marinov Avgustin --- .../amqp/AmqpMessageDispatcherServiceTest.java | 2 +- .../jpa/event/RepositoryEntityEventTest.java | 2 +- .../test/util/AbstractIntegrationTest.java | 2 +- .../rest/AbstractRestIntegrationTest.java | 4 +++- .../org/eclipse/hawkbit/app/mgmt/CorsTest.java | 17 +++++++++-------- .../java/org/eclipse/hawkbit/app/CorsTest.java | 17 +++++++++-------- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java index 44c3ee9f60..f907347c0c 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java @@ -69,7 +69,7 @@ @ActiveProfiles({ "test" }) @Feature("Component Tests - Device Management Federation API") @Story("AmqpMessage Dispatcher Service Test") -@SpringBootTest(classes = { RepositoryApplicationConfiguration.class }) +@SpringBootTest(classes = { RepositoryApplicationConfiguration.class }, webEnvironment = SpringBootTest.WebEnvironment.NONE) class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { private static final String TENANT = "default"; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java index 71174ca14f..8aa9e204a1 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java @@ -50,7 +50,7 @@ @Feature("Component Tests - Repository") @Story("Entity Events") -@SpringBootTest(classes = { RepositoryTestConfiguration.class }) +@SpringBootTest(classes = { RepositoryTestConfiguration.class }, webEnvironment = SpringBootTest.WebEnvironment.NONE) public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { @Autowired diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java index 50faa886c1..3998dfbfed 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java @@ -95,7 +95,7 @@ @ActiveProfiles({ "test" }) @ExtendWith({ JUnitTestLoggerExtension.class , SharedSqlTestDatabaseExtension.class }) @WithUser(principal = "bumlux", allSpPermissions = true, authorities = { CONTROLLER_ROLE, SYSTEM_ROLE }) -@SpringBootTest +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) @ContextConfiguration(classes = { TestConfiguration.class}) @Import(TestChannelBinderConfiguration.class) // destroy the context after each test class because otherwise we get problem diff --git a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTest.java b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTest.java index bb3439468c..92cedf2da3 100644 --- a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTest.java +++ b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTest.java @@ -16,6 +16,7 @@ import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; @@ -29,10 +30,11 @@ /** * Abstract Test for Rest tests. */ -@WebAppConfiguration +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK) @ContextConfiguration(classes = { RestConfiguration.class, RepositoryApplicationConfiguration.class, TestConfiguration.class}) @Import(TestChannelBinderConfiguration.class) +@WebAppConfiguration @AutoConfigureMockMvc public abstract class AbstractRestIntegrationTest extends AbstractIntegrationTest { diff --git a/hawkbit-runtime/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/CorsTest.java b/hawkbit-runtime/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/CorsTest.java index 47755699f8..fcc0183d22 100644 --- a/hawkbit-runtime/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/CorsTest.java +++ b/hawkbit-runtime/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/CorsTest.java @@ -27,14 +27,15 @@ import io.qameta.allure.Feature; import io.qameta.allure.Story; -@SpringBootTest(properties = { - "hawkbit.dmf.rabbitmq.enabled=false", - "hawkbit.server.security.cors.enabled=true", - "hawkbit.server.security.cors.allowedOrigins=" - + CorsTest.ALLOWED_ORIGIN_FIRST + "," - + CorsTest.ALLOWED_ORIGIN_SECOND, - "hawkbit.server.security.cors.exposedHeaders=" - + HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN}) +@SpringBootTest( + properties = { + "hawkbit.dmf.rabbitmq.enabled=false", + "hawkbit.server.security.cors.enabled=true", + "hawkbit.server.security.cors.allowedOrigins=" + + CorsTest.ALLOWED_ORIGIN_FIRST + "," + + CorsTest.ALLOWED_ORIGIN_SECOND, + "hawkbit.server.security.cors.exposedHeaders=" + + HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN}) @Feature("Integration Test - Security") @Story("CORS") public class CorsTest extends AbstractSecurityTest { diff --git a/hawkbit-runtime/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java b/hawkbit-runtime/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java index 9b0576650a..c9d5e54130 100644 --- a/hawkbit-runtime/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java +++ b/hawkbit-runtime/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java @@ -27,14 +27,15 @@ import io.qameta.allure.Feature; import io.qameta.allure.Story; -@SpringBootTest(properties = { - "hawkbit.dmf.rabbitmq.enabled=false", - "hawkbit.server.security.cors.enabled=true", - "hawkbit.server.security.cors.allowedOrigins=" - + CorsTest.ALLOWED_ORIGIN_FIRST + "," - + CorsTest.ALLOWED_ORIGIN_SECOND, - "hawkbit.server.security.cors.exposedHeaders=" - + HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN}) +@SpringBootTest( + properties = { + "hawkbit.dmf.rabbitmq.enabled=false", + "hawkbit.server.security.cors.enabled=true", + "hawkbit.server.security.cors.allowedOrigins=" + + CorsTest.ALLOWED_ORIGIN_FIRST + "," + + CorsTest.ALLOWED_ORIGIN_SECOND, + "hawkbit.server.security.cors.exposedHeaders=" + + HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN}) @Feature("Integration Test - Security") @Story("CORS") public class CorsTest extends AbstractSecurityTest {