Add Rest configuration for test
Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -8,20 +8,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.autoconfigure.web;
|
package org.eclipse.hawkbit.autoconfigure.web;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.ddi.EnableDdiApi;
|
import org.eclipse.hawkbit.ddi.EnableDdiApi;
|
||||||
import org.eclipse.hawkbit.mgmt.annotation.EnableMgmtApi;
|
import org.eclipse.hawkbit.mgmt.annotation.EnableMgmtApi;
|
||||||
import org.eclipse.hawkbit.rest.util.FilterHttpResponse;
|
|
||||||
import org.eclipse.hawkbit.rest.util.HttpResponseFactoryBean;
|
|
||||||
import org.eclipse.hawkbit.rest.util.RequestResponseContextHolder;
|
|
||||||
import org.eclipse.hawkbit.system.annotation.EnableSystemApi;
|
import org.eclipse.hawkbit.system.annotation.EnableSystemApi;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auto-Configuration for enabling the REST-Resources.
|
* Auto-Configuration for enabling the REST-Resources.
|
||||||
@@ -32,29 +24,4 @@ import org.springframework.web.context.WebApplicationContext;
|
|||||||
@Import({ EnableDdiApi.class, EnableMgmtApi.class, EnableSystemApi.class })
|
@Import({ EnableDdiApi.class, EnableMgmtApi.class, EnableSystemApi.class })
|
||||||
public class ResourceControllerAutoConfiguration {
|
public class ResourceControllerAutoConfiguration {
|
||||||
|
|
||||||
/**
|
|
||||||
* Create filter for {@link HttpServletResponse}.
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public FilterHttpResponse filterHttpResponse() {
|
|
||||||
return new FilterHttpResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create factory bean for {@link HttpServletResponse}.
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public HttpResponseFactoryBean httpResponseFactoryBean() {
|
|
||||||
return new HttpResponseFactoryBean();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create factory bean for {@link HttpServletResponse}.
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
@Scope(value = WebApplicationContext.SCOPE_REQUEST)
|
|
||||||
public RequestResponseContextHolder requestResponseContextHolder() {
|
|
||||||
return new RequestResponseContextHolder();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.rest.configuration.RestConfiguration;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,6 +27,7 @@ import org.springframework.stereotype.Controller;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
|
@Import(RestConfiguration.class)
|
||||||
public @interface EnableDdiApi {
|
public @interface EnableDdiApi {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang3.RandomUtils;
|
import org.apache.commons.lang3.RandomUtils;
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB;
|
|
||||||
import org.eclipse.hawkbit.TestDataUtil;
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
import org.eclipse.hawkbit.WithUser;
|
import org.eclipse.hawkbit.WithUser;
|
||||||
import org.eclipse.hawkbit.eventbus.event.DownloadProgressEvent;
|
import org.eclipse.hawkbit.eventbus.event.DownloadProgressEvent;
|
||||||
@@ -36,13 +35,13 @@ import org.eclipse.hawkbit.repository.model.Artifact;
|
|||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTestWithMongoDB;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Sort.Direction;
|
import org.springframework.data.domain.Sort.Direction;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
|
||||||
import org.springframework.test.web.servlet.MvcResult;
|
import org.springframework.test.web.servlet.MvcResult;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
@@ -57,10 +56,9 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
/**
|
/**
|
||||||
* Test artifact downloads from the controller.
|
* Test artifact downloads from the controller.
|
||||||
*/
|
*/
|
||||||
@ActiveProfiles({ "im", "test" })
|
|
||||||
@Features("Component Tests - Direct Device Integration API")
|
@Features("Component Tests - Direct Device Integration API")
|
||||||
@Stories("Artifact Download Resource")
|
@Stories("Artifact Download Resource")
|
||||||
public class DdiArtifactDownloadTest extends AbstractIntegrationTestWithMongoDB {
|
public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMongoDB {
|
||||||
|
|
||||||
public DdiArtifactDownloadTest() {
|
public DdiArtifactDownloadTest() {
|
||||||
LOG = LoggerFactory.getLogger(DdiArtifactDownloadTest.class);
|
LOG = LoggerFactory.getLogger(DdiArtifactDownloadTest.class);
|
||||||
|
|||||||
@@ -22,18 +22,17 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
|
||||||
import org.eclipse.hawkbit.TestDataUtil;
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
import org.eclipse.hawkbit.repository.model.Action;
|
import org.eclipse.hawkbit.repository.model.Action;
|
||||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.hateoas.MediaTypes;
|
import org.springframework.hateoas.MediaTypes;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
|
||||||
|
|
||||||
import ru.yandex.qatools.allure.annotations.Description;
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
import ru.yandex.qatools.allure.annotations.Features;
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
@@ -42,10 +41,9 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
/**
|
/**
|
||||||
* Test cancel action from the controller.
|
* Test cancel action from the controller.
|
||||||
*/
|
*/
|
||||||
@ActiveProfiles({ "im", "test" })
|
|
||||||
@Features("Component Tests - Direct Device Integration API")
|
@Features("Component Tests - Direct Device Integration API")
|
||||||
@Stories("Cancel Action Resource")
|
@Stories("Cancel Action Resource")
|
||||||
public class DdiCancelActionTest extends AbstractIntegrationTest {
|
public class DdiCancelActionTest extends AbstractRestIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Test of the controller can continue a started update even after a cancel command if it so desires.")
|
@Description("Test of the controller can continue a started update even after a cancel command if it so desires.")
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang3.RandomUtils;
|
import org.apache.commons.lang3.RandomUtils;
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB;
|
|
||||||
import org.eclipse.hawkbit.TestDataUtil;
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
import org.eclipse.hawkbit.repository.model.Action;
|
import org.eclipse.hawkbit.repository.model.Action;
|
||||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||||
@@ -35,6 +34,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
|||||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
|
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTestWithMongoDB;
|
||||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.fest.assertions.core.Condition;
|
import org.fest.assertions.core.Condition;
|
||||||
@@ -45,7 +45,6 @@ import org.springframework.data.domain.Sort;
|
|||||||
import org.springframework.data.domain.Sort.Direction;
|
import org.springframework.data.domain.Sort.Direction;
|
||||||
import org.springframework.hateoas.MediaTypes;
|
import org.springframework.hateoas.MediaTypes;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
|
||||||
|
|
||||||
import ru.yandex.qatools.allure.annotations.Description;
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
import ru.yandex.qatools.allure.annotations.Features;
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
@@ -54,10 +53,9 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
/**
|
/**
|
||||||
* Test deployment base from the controller.
|
* Test deployment base from the controller.
|
||||||
*/
|
*/
|
||||||
@ActiveProfiles({ "im", "test" })
|
|
||||||
@Features("Component Tests - Direct Device Integration API")
|
@Features("Component Tests - Direct Device Integration API")
|
||||||
@Stories("Deployment Action Resource")
|
@Stories("Deployment Action Resource")
|
||||||
public class DdiDeploymentBaseTest extends AbstractIntegrationTestWithMongoDB {
|
public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoDB {
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
@Description("Ensures that artifacts are not found, when softare module does not exists.")
|
@Description("Ensures that artifacts are not found, when softare module does not exists.")
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB;
|
|
||||||
import org.eclipse.hawkbit.TestDataUtil;
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
import org.eclipse.hawkbit.WithSpringAuthorityRule;
|
import org.eclipse.hawkbit.WithSpringAuthorityRule;
|
||||||
import org.eclipse.hawkbit.WithUser;
|
import org.eclipse.hawkbit.WithUser;
|
||||||
@@ -32,6 +31,7 @@ import org.eclipse.hawkbit.repository.model.Action;
|
|||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
|
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTestWithMongoDB;
|
||||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
|
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
|
||||||
@@ -39,7 +39,6 @@ import org.eclipse.hawkbit.util.IpUtil;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.hateoas.MediaTypes;
|
import org.springframework.hateoas.MediaTypes;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
|
||||||
|
|
||||||
import ru.yandex.qatools.allure.annotations.Description;
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
import ru.yandex.qatools.allure.annotations.Features;
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
@@ -48,10 +47,9 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
/**
|
/**
|
||||||
* Test the root controller resources.
|
* Test the root controller resources.
|
||||||
*/
|
*/
|
||||||
@ActiveProfiles({ "im", "test" })
|
|
||||||
@Features("Component Tests - Direct Device Integration API")
|
@Features("Component Tests - Direct Device Integration API")
|
||||||
@Stories("Root Poll Resource")
|
@Stories("Root Poll Resource")
|
||||||
public class DdiRootControllerTest extends AbstractIntegrationTestWithMongoDB {
|
public class DdiRootControllerTest extends AbstractRestIntegrationTestWithMongoDB {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Ensures that targets cannot be created e.g. in plug'n play scenarios when tenant does not exists but can be created if the tenant exists.")
|
@Description("Ensures that targets cannot be created e.g. in plug'n play scenarios when tenant does not exists but can be created if the tenant exists.")
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.rest.configuration.RestConfiguration;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,6 +31,7 @@ import org.springframework.stereotype.Controller;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
|
@Import(RestConfiguration.class)
|
||||||
public @interface EnableMgmtApi {
|
public @interface EnableMgmtApi {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
|
||||||
import org.eclipse.hawkbit.TestDataUtil;
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
import org.eclipse.hawkbit.WithUser;
|
import org.eclipse.hawkbit.WithUser;
|
||||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||||
@@ -37,6 +36,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
|||||||
import org.eclipse.hawkbit.repository.model.DsMetadataCompositeKey;
|
import org.eclipse.hawkbit.repository.model.DsMetadataCompositeKey;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@@ -55,7 +55,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
|
|
||||||
@Features("Component Tests - Management API")
|
@Features("Component Tests - Management API")
|
||||||
@Stories("Distribution Set Resource")
|
@Stories("Distribution Set Resource")
|
||||||
public class MgmtDistributionSetResourceTest extends AbstractIntegrationTest {
|
public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("This test verifies the call of all Software Modules that are assiged to a Distribution Set through the RESTful API.")
|
@Description("This test verifies the call of all Software Modules that are assiged to a Distribution Set through the RESTful API.")
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
|
||||||
import org.eclipse.hawkbit.WithUser;
|
import org.eclipse.hawkbit.WithUser;
|
||||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
|
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@@ -51,7 +51,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
*/
|
*/
|
||||||
@Features("Component Tests - Management API")
|
@Features("Component Tests - Management API")
|
||||||
@Stories("Distribution Set Type Resource")
|
@Stories("Distribution Set Type Resource")
|
||||||
public class MgmtDistributionSetTypeResourceTest extends AbstractIntegrationTest {
|
public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.mgmt.rest.resource;
|
|||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB;
|
|
||||||
import org.eclipse.hawkbit.TestDataUtil;
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
import org.eclipse.hawkbit.cache.CacheConstants;
|
import org.eclipse.hawkbit.cache.CacheConstants;
|
||||||
import org.eclipse.hawkbit.cache.DownloadArtifactCache;
|
import org.eclipse.hawkbit.cache.DownloadArtifactCache;
|
||||||
@@ -20,6 +19,7 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
|||||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
|
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTestWithMongoDB;
|
||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -33,7 +33,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
|
|
||||||
@Features("Component Tests - Management API")
|
@Features("Component Tests - Management API")
|
||||||
@Stories("Download Resource")
|
@Stories("Download Resource")
|
||||||
public class MgmtDownloadResourceTest extends AbstractIntegrationTestWithMongoDB {
|
public class MgmtDownloadResourceTest extends AbstractRestIntegrationTestWithMongoDB {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier(CacheConstants.DOWNLOAD_ID_CACHE)
|
@Qualifier(CacheConstants.DOWNLOAD_ID_CACHE)
|
||||||
@@ -58,9 +58,8 @@ public class MgmtDownloadResourceTest extends AbstractIntegrationTestWithMongoDB
|
|||||||
@Test
|
@Test
|
||||||
@Description("This test verifies the call of download artifact without a valid download id fails.")
|
@Description("This test verifies the call of download artifact without a valid download id fails.")
|
||||||
public void testNoDownloadIdAvailable() throws Exception {
|
public void testNoDownloadIdAvailable() throws Exception {
|
||||||
mvc.perform(
|
mvc.perform(get(MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE
|
||||||
get(MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE + MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING,
|
+ MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING, downloadIdNotAvailable))
|
||||||
downloadIdNotAvailable))
|
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -68,16 +67,14 @@ public class MgmtDownloadResourceTest extends AbstractIntegrationTestWithMongoDB
|
|||||||
@Test
|
@Test
|
||||||
@Description("This test verifies the call of download artifact works and the download id will be removed.")
|
@Description("This test verifies the call of download artifact works and the download id will be removed.")
|
||||||
public void testDownload() throws Exception {
|
public void testDownload() throws Exception {
|
||||||
mvc.perform(
|
mvc.perform(get(MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE
|
||||||
get(MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE + MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING,
|
+ MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING, downloadIdSha1)).andDo(MockMvcResultPrinter.print())
|
||||||
downloadIdSha1))
|
.andExpect(status().isOk());
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
|
||||||
|
|
||||||
// because cache is empty
|
// because cache is empty
|
||||||
mvc.perform(
|
mvc.perform(get(MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE
|
||||||
get(MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE + MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING,
|
+ MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING, downloadIdSha1)).andDo(MockMvcResultPrinter.print())
|
||||||
downloadIdSha1))
|
.andExpect(status().isNotFound());
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
|
||||||
import org.eclipse.hawkbit.TestDataUtil;
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
import org.eclipse.hawkbit.WithUser;
|
import org.eclipse.hawkbit.WithUser;
|
||||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||||
@@ -34,6 +33,7 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
|||||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupConditionBuilder;
|
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupConditionBuilder;
|
||||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
|
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.eclipse.hawkbit.rest.util.SuccessCondition;
|
import org.eclipse.hawkbit.rest.util.SuccessCondition;
|
||||||
@@ -52,7 +52,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
*/
|
*/
|
||||||
@Features("Component Tests - Management API")
|
@Features("Component Tests - Management API")
|
||||||
@Stories("Rollout Resource")
|
@Stories("Rollout Resource")
|
||||||
public class MgmtRolloutResourceTest extends AbstractIntegrationTest {
|
public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RolloutManagement rolloutManagement;
|
private RolloutManagement rolloutManagement;
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB;
|
|
||||||
import org.eclipse.hawkbit.HashGeneratorUtils;
|
import org.eclipse.hawkbit.HashGeneratorUtils;
|
||||||
import org.eclipse.hawkbit.TestDataUtil;
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
import org.eclipse.hawkbit.WithUser;
|
import org.eclipse.hawkbit.WithUser;
|
||||||
@@ -46,6 +45,7 @@ import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
|||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||||
import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey;
|
import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey;
|
||||||
|
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTestWithMongoDB;
|
||||||
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
|
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
|
||||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
@@ -71,7 +71,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
*/
|
*/
|
||||||
@Features("Component Tests - Management API")
|
@Features("Component Tests - Management API")
|
||||||
@Stories("Software Module Resource")
|
@Stories("Software Module Resource")
|
||||||
public class MgmtSoftwareModuleResourceTest extends AbstractIntegrationTestWithMongoDB {
|
public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestWithMongoDB {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void assertPreparationOfRepo() {
|
public void assertPreparationOfRepo() {
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
|
||||||
import org.eclipse.hawkbit.WithUser;
|
import org.eclipse.hawkbit.WithUser;
|
||||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
|
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@@ -48,7 +48,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
*/
|
*/
|
||||||
@Features("Component Tests - Management API")
|
@Features("Component Tests - Management API")
|
||||||
@Stories("Software Module Type Resource")
|
@Stories("Software Module Type Resource")
|
||||||
public class MgmtSoftwareModuleTypeResourceTest extends AbstractIntegrationTest {
|
public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
|
||||||
import org.eclipse.hawkbit.TestDataUtil;
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
import org.eclipse.hawkbit.WithUser;
|
import org.eclipse.hawkbit.WithUser;
|
||||||
import org.eclipse.hawkbit.exception.SpServerError;
|
import org.eclipse.hawkbit.exception.SpServerError;
|
||||||
@@ -46,6 +45,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
|||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||||
|
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||||
import org.eclipse.hawkbit.rest.exception.MessageNotReadableException;
|
import org.eclipse.hawkbit.rest.exception.MessageNotReadableException;
|
||||||
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
|
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
|
||||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||||
@@ -76,7 +76,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
*/
|
*/
|
||||||
@Features("Component Tests - Management API")
|
@Features("Component Tests - Management API")
|
||||||
@Stories("Target Resource")
|
@Stories("Target Resource")
|
||||||
public class MgmtTargetResourceTest extends AbstractIntegrationTest {
|
public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||||
|
|
||||||
private static final String TARGET_DESCRIPTION_TEST = "created in test";
|
private static final String TARGET_DESCRIPTION_TEST = "created in test";
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ import org.springframework.test.context.ActiveProfiles;
|
|||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder;
|
||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
@@ -181,11 +182,10 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected TenantAwareCacheManager cacheManager;
|
protected TenantAwareCacheManager cacheManager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected TenantConfigurationManagement tenantConfigurationManagement;
|
protected TenantConfigurationManagement tenantConfigurationManagement;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected RolloutManagement rolloutManagement;
|
protected RolloutManagement rolloutManagement;
|
||||||
|
|
||||||
@@ -223,12 +223,7 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() throws Exception {
|
public void before() throws Exception {
|
||||||
mvc = MockMvcBuilders.webAppContextSetup(context)
|
mvc = createMvcWebAppContext().build();
|
||||||
.addFilter(new DosFilter(100, 10, "127\\.0\\.0\\.1|\\[0:0:0:0:0:0:0:1\\]", "(^192\\.168\\.)",
|
|
||||||
"X-Forwarded-For"))
|
|
||||||
.addFilter(new ExcludePathAwareShallowETagFilter(
|
|
||||||
"/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", "/*/controller/artifacts/**"))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
standardDsType = securityRule.runAsPrivileged(() -> systemManagement.getTenantMetadata().getDefaultDsType());
|
standardDsType = securityRule.runAsPrivileged(() -> systemManagement.getTenantMetadata().getDefaultDsType());
|
||||||
|
|
||||||
@@ -245,6 +240,14 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware {
|
|||||||
runtimeType = securityRule.runAsPrivileged(() -> softwareManagement.updateSoftwareModuleType(runtimeType));
|
runtimeType = securityRule.runAsPrivileged(() -> softwareManagement.updateSoftwareModuleType(runtimeType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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\\.)",
|
||||||
|
"X-Forwarded-For"))
|
||||||
|
.addFilter(new ExcludePathAwareShallowETagFilter(
|
||||||
|
"/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", "/*/controller/artifacts/**"));
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() {
|
public static void beforeClass() {
|
||||||
createTestdatabaseAndStart();
|
createTestdatabaseAndStart();
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
* 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.rest.configuration;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.rest.util.FilterHttpResponse;
|
||||||
|
import org.eclipse.hawkbit.rest.util.HttpResponseFactoryBean;
|
||||||
|
import org.eclipse.hawkbit.rest.util.RequestResponseContextHolder;
|
||||||
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for Rest api.
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class RestConfiguration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create filter for {@link HttpServletResponse}.
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public FilterHttpResponse filterHttpResponse() {
|
||||||
|
return new FilterHttpResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create factory bean for {@link HttpServletResponse}.
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public FactoryBean<HttpServletResponse> httpResponseFactoryBean() {
|
||||||
|
return new HttpResponseFactoryBean();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create factory bean for {@link HttpServletResponse}.
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@Scope(value = WebApplicationContext.SCOPE_REQUEST)
|
||||||
|
public RequestResponseContextHolder requestResponseContextHolder() {
|
||||||
|
return new RequestResponseContextHolder();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,10 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
*/
|
*/
|
||||||
public class RequestResponseContextHolder {
|
public class RequestResponseContextHolder {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private HttpServletRequest httpServletRequest;
|
private HttpServletRequest httpServletRequest;
|
||||||
|
|
||||||
@Resource(name = HttpResponseFactoryBean.FACTORY_BEAN_NAME)
|
|
||||||
private HttpServletResponse httpServletResponse;
|
private HttpServletResponse httpServletResponse;
|
||||||
|
|
||||||
public HttpServletRequest getHttpServletRequest() {
|
public HttpServletRequest getHttpServletRequest() {
|
||||||
@@ -32,4 +30,14 @@ public class RequestResponseContextHolder {
|
|||||||
public HttpServletResponse getHttpServletResponse() {
|
public HttpServletResponse getHttpServletResponse() {
|
||||||
return httpServletResponse;
|
return httpServletResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setHttpServletRequest(final HttpServletRequest httpServletRequest) {
|
||||||
|
this.httpServletRequest = httpServletRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Resource(name = HttpResponseFactoryBean.FACTORY_BEAN_NAME)
|
||||||
|
public void setHttpServletResponse(final HttpServletResponse httpServletResponse) {
|
||||||
|
this.httpServletResponse = httpServletResponse;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* 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.rest;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||||
|
import org.eclipse.hawkbit.rest.configuration.RestConfiguration;
|
||||||
|
import org.eclipse.hawkbit.rest.util.FilterHttpResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||||
|
import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract Test for Rest tests.
|
||||||
|
*/
|
||||||
|
@SpringApplicationConfiguration(classes = { RestConfiguration.class })
|
||||||
|
public abstract class AbstractRestIntegrationTest extends AbstractIntegrationTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FilterHttpResponse filterHttpResponse;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DefaultMockMvcBuilder createMvcWebAppContext() {
|
||||||
|
return super.createMvcWebAppContext().addFilter(filterHttpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* 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.rest;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB;
|
||||||
|
import org.eclipse.hawkbit.rest.configuration.RestConfiguration;
|
||||||
|
import org.eclipse.hawkbit.rest.util.FilterHttpResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||||
|
import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract Test for Rest tests.
|
||||||
|
*/
|
||||||
|
@SpringApplicationConfiguration(classes = { RestConfiguration.class })
|
||||||
|
public abstract class AbstractRestIntegrationTestWithMongoDB extends AbstractIntegrationTestWithMongoDB {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FilterHttpResponse filterHttpResponse;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DefaultMockMvcBuilder createMvcWebAppContext() {
|
||||||
|
return super.createMvcWebAppContext().addFilter(filterHttpResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,8 +13,10 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.rest.configuration.RestConfiguration;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,6 +27,7 @@ import org.springframework.stereotype.Controller;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
|
@Import(RestConfiguration.class)
|
||||||
public @interface EnableSystemApi {
|
public @interface EnableSystemApi {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user