From a71179b5faa93cedf698d80761ea4676acfa52cb Mon Sep 17 00:00:00 2001 From: SirWayne Date: Mon, 29 Aug 2016 11:04:49 +0200 Subject: [PATCH] Remove abstract mongo db test class, because every test starts a mongo. This class is not necessary Signed-off-by: SirWayne --- .../AmqpMessageDispatcherServiceTest.java | 4 +-- .../PropertyBasedArtifactUrlHandlerTest.java | 4 +-- ...AbstractJpaIntegrationTestWithMongoDB.java | 4 +-- .../test/util/AbstractIntegrationTest.java | 15 ++++++++ .../AbstractIntegrationTestWithMongoDB.java | 34 ------------------- ...bstractRestIntegrationTestWithMongoDB.java | 4 +-- 6 files changed, 23 insertions(+), 42 deletions(-) delete mode 100644 hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTestWithMongoDB.java diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java index 103dc6c57..ee9f2b528 100644 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java @@ -37,7 +37,7 @@ import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; -import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTestWithMongoDB; +import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest; import org.eclipse.hawkbit.util.IpUtil; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -58,7 +58,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @Features("Component Tests - Device Management Federation API") @Stories("AmqpMessage Dispatcher Service Test") @SpringApplicationConfiguration(classes = { org.eclipse.hawkbit.RepositoryApplicationConfiguration.class }) -public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWithMongoDB { +public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { private static final String TENANT = "default"; diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/util/PropertyBasedArtifactUrlHandlerTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/util/PropertyBasedArtifactUrlHandlerTest.java index 92e8f390d..ea01bc0ec 100644 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/util/PropertyBasedArtifactUrlHandlerTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/util/PropertyBasedArtifactUrlHandlerTest.java @@ -16,7 +16,7 @@ import org.eclipse.hawkbit.api.UrlProtocol; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; -import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTestWithMongoDB; +import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest; import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -33,7 +33,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @Stories("Test to generate the artifact download URL") @SpringApplicationConfiguration(classes = { AmqpTestConfiguration.class, org.eclipse.hawkbit.RepositoryApplicationConfiguration.class }) -public class PropertyBasedArtifactUrlHandlerTest extends AbstractIntegrationTestWithMongoDB { +public class PropertyBasedArtifactUrlHandlerTest extends AbstractIntegrationTest { private static final String HTTPS_LOCALHOST = "https://localhost/"; private static final String HTTP_LOCALHOST = "http://localhost/"; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTestWithMongoDB.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTestWithMongoDB.java index e2e755246..d2c2a7cfa 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTestWithMongoDB.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTestWithMongoDB.java @@ -12,12 +12,12 @@ import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import org.eclipse.hawkbit.cache.TenantAwareCacheManager; -import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTestWithMongoDB; +import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.SpringApplicationConfiguration; @SpringApplicationConfiguration(classes = { org.eclipse.hawkbit.RepositoryApplicationConfiguration.class }) -public abstract class AbstractJpaIntegrationTestWithMongoDB extends AbstractIntegrationTestWithMongoDB { +public abstract class AbstractJpaIntegrationTestWithMongoDB extends AbstractIntegrationTest { @PersistenceContext protected EntityManager entityManager; 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 b8c99b57a..8f3becc4c 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 @@ -49,6 +49,8 @@ import org.springframework.core.env.Environment; import org.springframework.data.auditing.AuditingHandler; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.mongodb.core.query.Query; +import org.springframework.data.mongodb.gridfs.GridFsOperations; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ActiveProfiles; @@ -60,6 +62,8 @@ import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; +import de.flapdoodle.embed.mongo.MongodExecutable; + @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @ActiveProfiles({ "test" }) @@ -152,6 +156,12 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware { @Autowired protected TestdataFactory testdataFactory; + @Autowired + protected GridFsOperations operations; + + @Autowired + protected MongodExecutable mongodExecutable; + @Rule public final WithSpringAuthorityRule securityRule = new WithSpringAuthorityRule(); @@ -190,6 +200,11 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware { testRepositoryManagement.clearTestRepository(); } + @After + public void cleanCurrentCollection() { + operations.delete(new Query()); + } + protected DefaultMockMvcBuilder createMvcWebAppContext() { return MockMvcBuilders.webAppContextSetup(context) .addFilter(new DosFilter(100, 10, "127\\.0\\.0\\.1|\\[0:0:0:0:0:0:0:1\\]", "(^192\\.168\\.)", diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTestWithMongoDB.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTestWithMongoDB.java deleted file mode 100644 index 589cac381..000000000 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTestWithMongoDB.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.hawkbit.repository.test.util; - -import org.junit.After; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.mongodb.core.query.Query; -import org.springframework.data.mongodb.gridfs.GridFsOperations; - -import de.flapdoodle.embed.mongo.MongodExecutable; - -/** - * Test class that contains embedded MongoDB for the test. - */ -public abstract class AbstractIntegrationTestWithMongoDB extends AbstractIntegrationTest { - - @Autowired - protected GridFsOperations operations; - - @Autowired - protected MongodExecutable mongodExecutable; - - @After - public void cleanCurrentCollection() { - operations.delete(new Query()); - } - -} diff --git a/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTestWithMongoDB.java b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTestWithMongoDB.java index 70d65e141..5974917ec 100644 --- a/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTestWithMongoDB.java +++ b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTestWithMongoDB.java @@ -8,7 +8,7 @@ */ package org.eclipse.hawkbit.rest; -import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTestWithMongoDB; +import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest; import org.eclipse.hawkbit.rest.configuration.RestConfiguration; import org.eclipse.hawkbit.rest.util.FilterHttpResponse; import org.springframework.beans.factory.annotation.Autowired; @@ -20,7 +20,7 @@ import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder; */ @SpringApplicationConfiguration(classes = { RestConfiguration.class, org.eclipse.hawkbit.RepositoryApplicationConfiguration.class }) -public abstract class AbstractRestIntegrationTestWithMongoDB extends AbstractIntegrationTestWithMongoDB { +public abstract class AbstractRestIntegrationTestWithMongoDB extends AbstractIntegrationTest { @Autowired private FilterHttpResponse filterHttpResponse;