diff --git a/activity-tracker-root/activity-tracker-boot-starter/src/test/java/io/fourfinance/activity_tracker/autoconfigure/ActivityTrackerAutoConfigurationDisabledTest.java b/activity-tracker-root/activity-tracker-boot-starter/src/test/java/io/fourfinance/activity_tracker/autoconfigure/ActivityTrackerAutoConfigurationDisabledTest.java index a2d414fa..69700122 100644 --- a/activity-tracker-root/activity-tracker-boot-starter/src/test/java/io/fourfinance/activity_tracker/autoconfigure/ActivityTrackerAutoConfigurationDisabledTest.java +++ b/activity-tracker-root/activity-tracker-boot-starter/src/test/java/io/fourfinance/activity_tracker/autoconfigure/ActivityTrackerAutoConfigurationDisabledTest.java @@ -2,26 +2,23 @@ import static org.assertj.core.api.BDDAssertions.then; +import io.fourfinance.activity_tracker.testapp.TestApplication; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.ConfigFileApplicationContextInitializer; -import org.springframework.boot.test.IntegrationTest; -import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import io.fourfinance.activity_tracker.testapp.TestApplication; - @RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(value = TestApplication.class, initializers = ConfigFileApplicationContextInitializer.class) -@IntegrationTest("com.ofg.infra.microservice.track-activity.enabled = false") +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = TestApplication.class, + value = "com.ofg.infra.microservice.track-activity.enabled = false") public class ActivityTrackerAutoConfigurationDisabledTest { @Autowired ApplicationContext context; - - @Test + + @Test public void shouldNotLoadUserActivityTrackingBeans() throws Exception { //when boolean trackUserActivityAspectPresent = context.containsBean("trackUserActivityAspect"); diff --git a/activity-tracker-root/activity-tracker-boot-starter/src/test/java/io/fourfinance/activity_tracker/autoconfigure/ActivityTrackerAutoConfigurationEnabledTest.java b/activity-tracker-root/activity-tracker-boot-starter/src/test/java/io/fourfinance/activity_tracker/autoconfigure/ActivityTrackerAutoConfigurationEnabledTest.java index b212aa06..90a9b9bf 100644 --- a/activity-tracker-root/activity-tracker-boot-starter/src/test/java/io/fourfinance/activity_tracker/autoconfigure/ActivityTrackerAutoConfigurationEnabledTest.java +++ b/activity-tracker-root/activity-tracker-boot-starter/src/test/java/io/fourfinance/activity_tracker/autoconfigure/ActivityTrackerAutoConfigurationEnabledTest.java @@ -2,23 +2,22 @@ import static org.assertj.core.api.BDDAssertions.then; +import io.fourfinance.activity_tracker.testapp.TestApplication; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.ConfigFileApplicationContextInitializer; -import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer; import org.springframework.context.ApplicationContext; +import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import io.fourfinance.activity_tracker.testapp.TestApplication; - @RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(value = TestApplication.class, initializers = ConfigFileApplicationContextInitializer.class) +@ContextConfiguration(classes = TestApplication.class, initializers = ConfigFileApplicationContextInitializer.class) public class ActivityTrackerAutoConfigurationEnabledTest { @Autowired ApplicationContext context; - + @Test public void shouldLoadUserActivityTrackingBeans() throws Exception { //when diff --git a/build.gradle b/build.gradle index b7619a01..a4d05825 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } //for sonarqube plugin } dependencies { - classpath "org.springframework.boot:spring-boot-gradle-plugin:1.3.8.RELEASE" + classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.5.RELEASE" classpath 'com.toomuchcoding:uptodate-gradle-plugin:+' classpath "com.ofg:micro-common-release:0.1.18" classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:+" @@ -53,35 +53,12 @@ apply from: "${rootProject.buildDir}/release/gradle/release.gradle" //NOTE: All release and publishing modifications (including further scmVersion closure) should be put AFTER the apply of publish.gradle and/or release.gradle // (to be not overridden by the default values applied in those files) - allprojects { repositories { mavenLocal() mavenCentral() jcenter() } - - configurations { - all { - resolutionStrategy { - exclude group: 'log4j', module: 'log4j' - force 'org.apache.httpcomponents:httpclient:4.5.2' - force 'org.jboss.logging:jboss-logging:3.3.0.Final' - - eachDependency { DependencyResolveDetails details -> - if (details.requested.group == 'org.slf4j') { details.useVersion '1.7.21' } - if (details.requested.group == 'com.fasterxml.jackson.core') { details.useVersion '2.6.7' } - - // To prevent an accidental usage of groovy-all.jar and groovy.jar in different versions - // all modularized Groovy jars are replaced with groovy-all.jar by default. - if (details.requested.group == 'org.codehaus.groovy' && details.requested.name != "groovy-all") { - details.useTarget("org.codehaus.groovy:groovy-all:${details.requested.version}") - } - if (details.requested.group == 'org.aspectj') { details.useVersion '1.8.9' } - } - } - } - } } task addHashFile << { @@ -105,7 +82,7 @@ configure(srcSubprojects) { dependencyManagement { imports { - mavenBom 'org.springframework.cloud:spring-cloud-starter-parent:Brixton.SR7' + mavenBom 'org.springframework.cloud:spring-cloud-starter-parent:Camden.SR6' } dependencies { @@ -122,11 +99,11 @@ configure(srcSubprojects) { dependency "ch.qos.logback:logback-core:1.1.7" dependency "ch.qos.logback:logback-classic:1.1.7" dependency "com.jayway.restassured:rest-assured:2.9.0" - dependency "com.github.tomakehurst:wiremock:2.1.6" + dependency "com.github.tomakehurst:wiremock:2.1.7" dependency "cglib:cglib-nodep:3.2.5" dependency "org.objenesis:objenesis:2.5.1" - dependencySet(group:'org.spockframework', version: '1.0-groovy-2.4') { + dependencySet(group:'org.spockframework', version: '1.1-groovy-2.4-rc-4') { entry "spock-core" entry "spock-spring" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index b2690c65..fafcb411 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 95fd4b9e..f9e5c035 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -#Wed Mar 22 17:42:55 CET 2017 +#Fri Mar 31 18:58:36 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/micro-deps/build.gradle b/micro-deps/build.gradle index 7d989e95..3faea8de 100755 --- a/micro-deps/build.gradle +++ b/micro-deps/build.gradle @@ -64,6 +64,9 @@ project(':micro-deps-root:micro-deps-spring-config') { compile 'org.springframework.cloud:spring-cloud-starter-zookeeper-discovery' compile 'org.springframework.cloud:spring-cloud-starter-sleuth' compile 'io.reactivex:rxjava' + compile 'org.eclipse.jetty:jetty-server' + compile 'org.eclipse.jetty:jetty-servlet' + compile 'org.eclipse.jetty:jetty-servlets' testCompile 'org.codehaus.groovy:groovy-all' testCompile "org.spockframework:spock-core" diff --git a/micro-deps/micro-deps-jax-rs-jersey/src/test/java/com/ofg/infrastructure/jerseys/JerseyTest.java b/micro-deps/micro-deps-jax-rs-jersey/src/test/java/com/ofg/infrastructure/jerseys/JerseyTest.java index e77cd7b7..c6c9f79d 100644 --- a/micro-deps/micro-deps-jax-rs-jersey/src/test/java/com/ofg/infrastructure/jerseys/JerseyTest.java +++ b/micro-deps/micro-deps-jax-rs-jersey/src/test/java/com/ofg/infrastructure/jerseys/JerseyTest.java @@ -1,5 +1,7 @@ package com.ofg.infrastructure.jerseys; +import static org.junit.Assert.assertEquals; + import com.ofg.infrastructure.discovery.ServiceResolver; import com.ofg.infrastructure.discovery.util.MicroDepsService; import com.ofg.infrastructure.jaxrs.JaxRsApi; @@ -13,18 +15,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.boot.test.TestRestTemplate; -import org.springframework.boot.test.WebIntegrationTest; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import static org.junit.Assert.assertEquals; - @RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration({JerseyApplication.class}) -@WebIntegrationTest(randomPort = true) +@SpringBootTest(classes = JerseyApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class JerseyTest { private static final String CONFIG = "{\"ctx\": {\"this\": \"com/ofg/infrastructure/jaxrs\"}}"; private static final Logger log = LoggerFactory.getLogger(JerseyTest.class); @@ -47,7 +45,7 @@ public void restTemplate() { @Test public void jersey() throws Exception { TestingServer server = new TestingServer(); - MicroDepsService service = new MicroDepsService(server.getConnectString(), "ctx", "localhost", port, CONFIG).start(); + MicroDepsService service = new MicroDepsService(server.getConnectString(), "ctx", "localhost", port, CONFIG).start(); ServiceResolver sr = service.getServiceResolver(); JaxRsServiceResolver subj = new JerseyServiceResolver(sr, new ClientConfig()); JaxRsApi resource = subj.getLocator(JaxRsApi.class).get(); diff --git a/micro-deps/micro-deps-spring-test-config/src/main/groovy/com/ofg/infrastructure/base/MvcIntegrationSpec.groovy b/micro-deps/micro-deps-spring-test-config/src/main/groovy/com/ofg/infrastructure/base/MvcIntegrationSpec.groovy index 9b27d380..ed342bc6 100755 --- a/micro-deps/micro-deps-spring-test-config/src/main/groovy/com/ofg/infrastructure/base/MvcIntegrationSpec.groovy +++ b/micro-deps/micro-deps-spring-test-config/src/main/groovy/com/ofg/infrastructure/base/MvcIntegrationSpec.groovy @@ -12,7 +12,6 @@ import org.springframework.web.context.WebApplicationContext import spock.lang.Specification import static com.ofg.config.BasicProfiles.TEST - /** * Base for specifications that use Spring's {@link MockMvc}. Provides also {@link WebApplicationContext}, * {@link ApplicationContext}. The latter you can use to specify what diff --git a/micro-deps/micro-deps-spring-test-config/src/main/groovy/com/ofg/infrastructure/base/dsl/WireMockHttpRequestMapper.groovy b/micro-deps/micro-deps-spring-test-config/src/main/groovy/com/ofg/infrastructure/base/dsl/WireMockHttpRequestMapper.groovy index ce97676b..0ebbe5c8 100755 --- a/micro-deps/micro-deps-spring-test-config/src/main/groovy/com/ofg/infrastructure/base/dsl/WireMockHttpRequestMapper.groovy +++ b/micro-deps/micro-deps-spring-test-config/src/main/groovy/com/ofg/infrastructure/base/dsl/WireMockHttpRequestMapper.groovy @@ -5,7 +5,7 @@ import com.github.tomakehurst.wiremock.client.WireMock import groovy.transform.CompileStatic /** - * A class that contains static helper methods that map HTTP methods with given path + * A class that contains static helper methods that map HTTP methods with given path */ @CompileStatic class WireMockHttpRequestMapper { @@ -33,5 +33,5 @@ class WireMockHttpRequestMapper { static RemoteMappingBuilder wireMockHead(String path) { return WireMock.head(WireMock.urlEqualTo(path)) } - + } diff --git a/micro-infra-camel/build.gradle b/micro-infra-camel/build.gradle index 555ead04..89971fea 100644 --- a/micro-infra-camel/build.gradle +++ b/micro-infra-camel/build.gradle @@ -18,4 +18,8 @@ dependencies { testCompile "org.springframework:spring-test" testCompile 'cglib:cglib-nodep:3.1' testCompile 'org.objenesis:objenesis:2.1' + + testCompile 'org.eclipse.jetty:jetty-server' + testCompile 'org.eclipse.jetty:jetty-servlet' + testCompile 'org.eclipse.jetty:jetty-servlets' } \ No newline at end of file diff --git a/micro-infra-camel/src/main/java/com/ofg/infrastructure/camel/CorrelationIdInterceptor.java b/micro-infra-camel/src/main/java/com/ofg/infrastructure/camel/CorrelationIdInterceptor.java index c142edc4..18d1023d 100644 --- a/micro-infra-camel/src/main/java/com/ofg/infrastructure/camel/CorrelationIdInterceptor.java +++ b/micro-infra-camel/src/main/java/com/ofg/infrastructure/camel/CorrelationIdInterceptor.java @@ -65,8 +65,12 @@ private Span getCorrelationId(Exchange exchange) { log.debug("No spanId has been set in request inbound message. Creating new one."); spanId = idGenerator.nextLong(); } - return builder().spanId(spanId).traceId(firstNonNull(oldTraceId, traceId)) - .name(notSampledName).parent(parentId).processId(processID).build(); + Span.SpanBuilder spanBuilder = builder().spanId(spanId).traceId(firstNonNull(oldTraceId, traceId)) + .name(notSampledName).processId(processID); + if (parentId != null) { + spanBuilder.parent(parentId); + } + return spanBuilder.build(); } private Long firstNonNull(Long first, Long second) { diff --git a/micro-infra-spring-base/build.gradle b/micro-infra-spring-base/build.gradle index 2600ddc2..9d86a325 100644 --- a/micro-infra-spring-base/build.gradle +++ b/micro-infra-spring-base/build.gradle @@ -30,8 +30,10 @@ dependencies { testCompile "org.spockframework:spock-core" testRuntime "org.spockframework:spock-spring" + testCompile "org.springframework.boot:spring-boot-starter-jetty" testCompile 'info.solidsoft.spock:spock-global-unroll' - testCompile "org.springframework:spring-test" + testCompile 'org.springframework.boot:spring-boot-starter-test' + testCompile 'org.hamcrest:hamcrest-library:1.3' testCompile 'org.hibernate:hibernate-validator:5.1.3.Final' testCompile 'com.jayway.jsonpath:json-path-assert:2.0.0' diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/base/MicroserviceMvcWiremockSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/base/MicroserviceMvcWiremockSpec.groovy index ae61940a..bc0b2ccd 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/base/MicroserviceMvcWiremockSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/base/MicroserviceMvcWiremockSpec.groovy @@ -2,13 +2,11 @@ package com.ofg.infrastructure.base import com.ofg.infrastructure.web.correlationid.HeadersSettingFilter import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.SpringApplicationContextLoader -import org.springframework.cloud.sleuth.Tracer +import org.springframework.boot.test.context.SpringBootTest import org.springframework.cloud.sleuth.instrument.web.TraceFilter -import org.springframework.test.context.ContextConfiguration import org.springframework.test.web.servlet.setup.ConfigurableMockMvcBuilder -@ContextConfiguration(classes = [ServiceDiscoveryStubbingApplicationConfiguration], loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [ServiceDiscoveryStubbingApplicationConfiguration]) abstract class MicroserviceMvcWiremockSpec extends MvcWiremockIntegrationSpec { @Autowired TraceFilter traceFilter diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/healthcheck/MicroserviceConfigurationControllerSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/healthcheck/MicroserviceConfigurationControllerSpec.groovy index adc2fa8b..cdcfabf8 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/healthcheck/MicroserviceConfigurationControllerSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/healthcheck/MicroserviceConfigurationControllerSpec.groovy @@ -5,18 +5,16 @@ import com.ofg.infrastructure.base.MvcCorrelationIdSettingIntegrationSpec import com.ofg.infrastructure.base.ServiceDiscoveryStubbingApplicationConfiguration import org.junit.ClassRule import org.junit.contrib.java.lang.system.ProvideSystemProperty -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.http.MediaType -import org.springframework.test.context.ContextConfiguration import spock.lang.Shared -import static org.hamcrest.Matchers.* -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content +import static org.hamcrest.Matchers.equalTo +import static org.hamcrest.Matchers.is import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.* -@ContextConfiguration(classes = [BaseConfiguration, HealthCheckConfiguration, ServiceDiscoveryStubbingApplicationConfiguration], loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [BaseConfiguration, HealthCheckConfiguration, ServiceDiscoveryStubbingApplicationConfiguration]) class MicroserviceConfigurationControllerSpec extends MvcCorrelationIdSettingIntegrationSpec { @Shared @ClassRule @@ -29,7 +27,7 @@ class MicroserviceConfigurationControllerSpec extends MvcCorrelationIdSettingInt expect: mockMvc.perform(get('/microservice.json')) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andExpect(jsonPath('$.pl.this', is(equalTo('foo/bar/registration')))) .andExpect(jsonPath('$.pl.dependencies.confirmation.path', is(equalTo('foo/bar/security/confirmation')))) .andExpect(jsonPath('$.pl.dependencies.foo-bar.path', is(equalTo('com/ofg/foo/bar')))) diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/healthcheck/PingClientTest.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/healthcheck/PingClientTest.groovy index 26322af7..3e1ac90f 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/healthcheck/PingClientTest.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/healthcheck/PingClientTest.groovy @@ -7,15 +7,14 @@ import com.ofg.infrastructure.discovery.ServiceResolverConfiguration import com.ofg.infrastructure.discovery.web.MockServerConfiguration import com.ofg.infrastructure.web.resttemplate.fluent.ServiceRestClientConfiguration import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.SpringApplicationContextLoader -import org.springframework.test.context.ContextConfiguration -import spock.lang.Unroll import static com.github.tomakehurst.wiremock.client.WireMock.aResponse import static com.ofg.infrastructure.base.dsl.WireMockHttpRequestMapper.wireMockGet -@ContextConfiguration(classes = [BaseConfiguration, MockServerConfiguration, ServiceResolverConfiguration, - CollaboratorsConfiguration, ServiceRestClientConfiguration], loader = SpringApplicationContextLoader) +import org.springframework.boot.test.context.SpringBootTest + +@SpringBootTest(classes = [BaseConfiguration, MockServerConfiguration, ServiceResolverConfiguration, + CollaboratorsConfiguration, ServiceRestClientConfiguration]) class PingClientTest extends MvcWiremockIntegrationSpec { @Autowired diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/healthcheck/PingControllerMvcSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/healthcheck/PingControllerMvcSpec.groovy index 655aebc2..d39734ed 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/healthcheck/PingControllerMvcSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/healthcheck/PingControllerMvcSpec.groovy @@ -5,11 +5,10 @@ import com.ofg.infrastructure.base.MvcCorrelationIdSettingIntegrationSpec import com.ofg.infrastructure.base.ServiceDiscoveryStubbingApplicationConfiguration import org.junit.ClassRule import org.junit.contrib.java.lang.system.ProvideSystemProperty -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Import import org.springframework.http.HttpMethod -import org.springframework.test.context.ContextConfiguration import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder import spock.lang.Shared @@ -18,7 +17,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status -@ContextConfiguration(classes = TestConfig, loader = SpringApplicationContextLoader) +@SpringBootTest(classes = TestConfig) class PingControllerMvcSpec extends MvcCorrelationIdSettingIntegrationSpec { @Shared @ClassRule diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/tracing/TracingPropertiesEnablerSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/tracing/TracingPropertiesEnablerSpec.groovy index 51794544..31c35ecd 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/tracing/TracingPropertiesEnablerSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/tracing/TracingPropertiesEnablerSpec.groovy @@ -1,11 +1,10 @@ package com.ofg.infrastructure.tracing import com.ofg.config.BasicProfiles -import org.springframework.boot.test.EnvironmentTestUtils +import org.springframework.boot.test.util.EnvironmentTestUtils import org.springframework.context.ConfigurableApplicationContext import org.springframework.context.annotation.AnnotationConfigApplicationContext import spock.lang.Specification -import spock.lang.Unroll class TracingPropertiesEnablerSpec extends Specification { diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/correlationid/CorrelationIdAspectSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/correlationid/CorrelationIdAspectSpec.groovy index f6c36dc4..24bcd1f7 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/correlationid/CorrelationIdAspectSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/correlationid/CorrelationIdAspectSpec.groovy @@ -2,7 +2,9 @@ package com.ofg.infrastructure.web.correlationid import com.ofg.infrastructure.base.BaseConfiguration import com.ofg.infrastructure.base.MicroserviceMvcWiremockSpec +import com.ofg.infrastructure.discovery.ServiceResolverConfiguration import com.ofg.infrastructure.discovery.web.HttpMockServer +import com.ofg.infrastructure.web.resttemplate.fluent.EnableServiceRestClient import com.ofg.infrastructure.web.resttemplate.fluent.ServiceRestClient import groovy.transform.CompileStatic import groovy.transform.PackageScope @@ -10,12 +12,11 @@ import groovy.transform.TypeChecked import org.junit.ClassRule import org.junit.contrib.java.lang.system.ProvideSystemProperty import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Import import org.springframework.http.MediaType import org.springframework.scheduling.annotation.EnableAsync -import org.springframework.test.context.ContextConfiguration import org.springframework.test.web.servlet.MvcResult import org.springframework.test.web.servlet.request.MockMvcRequestBuilders import org.springframework.web.bind.annotation.RequestMapping @@ -23,7 +24,6 @@ import org.springframework.web.bind.annotation.RequestMethod import org.springframework.web.bind.annotation.RestController import org.springframework.web.context.request.async.WebAsyncTask import spock.lang.Shared -import spock.lang.Unroll import java.util.concurrent.Callable @@ -35,7 +35,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status -@ContextConfiguration(classes = [BaseConfiguration, CorrelationIdAspectSpecConfiguration], loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [BaseConfiguration, CorrelationIdAspectSpecConfiguration]) class CorrelationIdAspectSpec extends MicroserviceMvcWiremockSpec { @Shared @ClassRule @@ -72,8 +72,9 @@ class CorrelationIdAspectSpec extends MicroserviceMvcWiremockSpec { @CompileStatic @Configuration - @Import(AspectTestingController) + @Import([AspectTestingController, ServiceResolverConfiguration]) @EnableAsync + @EnableServiceRestClient static class CorrelationIdAspectSpecConfiguration { } diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/correlationid/CorrelationIdAsyncSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/correlationid/CorrelationIdAsyncSpec.groovy index 93ab02ad..f4050346 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/correlationid/CorrelationIdAsyncSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/correlationid/CorrelationIdAsyncSpec.groovy @@ -2,21 +2,22 @@ package com.ofg.infrastructure.web.correlationid import com.ofg.infrastructure.base.BaseConfiguration import com.ofg.infrastructure.base.MicroserviceMvcWiremockSpec +import com.ofg.infrastructure.discovery.ServiceResolverConfiguration import groovy.transform.CompileStatic import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.cloud.sleuth.Span import org.springframework.cloud.sleuth.trace.SpanContextHolder import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Import import org.springframework.scheduling.annotation.Async import org.springframework.scheduling.annotation.EnableAsync -import org.springframework.test.context.ContextConfiguration import spock.util.concurrent.PollingConditions import java.util.concurrent.atomic.AtomicReference -@ContextConfiguration(classes = [BaseConfiguration, CorrelationIdAsyncSpecConfiguration], loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [BaseConfiguration, CorrelationIdAsyncSpecConfiguration]) class CorrelationIdAsyncSpec extends MicroserviceMvcWiremockSpec { @Autowired AsyncClass asyncClass @@ -43,6 +44,7 @@ class CorrelationIdAsyncSpec extends MicroserviceMvcWiremockSpec { @CompileStatic @Configuration @EnableAsync + @Import([ServiceResolverConfiguration]) static class CorrelationIdAsyncSpecConfiguration { @Bean AsyncClass asyncClass() { diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/correlationid/CorrelationIdFilterSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/correlationid/CorrelationIdFilterSpec.groovy index db422242..b4132143 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/correlationid/CorrelationIdFilterSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/correlationid/CorrelationIdFilterSpec.groovy @@ -3,7 +3,7 @@ import com.ofg.infrastructure.base.BaseConfiguration import com.ofg.infrastructure.base.ConfigurationWithoutServiceDiscovery import com.ofg.infrastructure.base.MvcCorrelationIdSettingIntegrationSpec import org.slf4j.MDC -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.http.MediaType import org.springframework.test.context.ContextConfiguration import org.springframework.test.web.servlet.MvcResult @@ -13,7 +13,7 @@ import spock.lang.Ignore import static com.ofg.infrastructure.correlationid.CorrelationIdHolder.CORRELATION_ID_HEADER import static com.ofg.infrastructure.correlationid.CorrelationIdHolder.OLD_CORRELATION_ID_HEADER -@ContextConfiguration(classes = [BaseConfiguration, ConfigurationWithoutServiceDiscovery], loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [BaseConfiguration, ConfigurationWithoutServiceDiscovery]) class CorrelationIdFilterSpec extends MvcCorrelationIdSettingIntegrationSpec { private Random random = new Random(); diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/exception/CustomControllerAdviceMvcSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/exception/CustomControllerAdviceMvcSpec.groovy index c2b711e1..2fc32619 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/exception/CustomControllerAdviceMvcSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/exception/CustomControllerAdviceMvcSpec.groovy @@ -2,7 +2,7 @@ package com.ofg.infrastructure.web.exception import com.ofg.infrastructure.base.BaseConfiguration import com.ofg.infrastructure.base.ConfigurationWithoutServiceDiscovery import com.ofg.infrastructure.base.MvcCorrelationIdSettingIntegrationSpec -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.test.context.ContextConfiguration @@ -12,7 +12,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status -@ContextConfiguration(classes = [Config, BaseConfiguration, ConfigurationWithoutServiceDiscovery], loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [Config, BaseConfiguration, ConfigurationWithoutServiceDiscovery]) class CustomControllerAdviceMvcSpec extends MvcCorrelationIdSettingIntegrationSpec { def "should apply custom logic when application uses its own @ControllerAdvice"() { diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/exception/ExceptionHandlingMvcSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/exception/ExceptionHandlingMvcSpec.groovy index f0f16336..cc733ad3 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/exception/ExceptionHandlingMvcSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/exception/ExceptionHandlingMvcSpec.groovy @@ -3,7 +3,7 @@ package com.ofg.infrastructure.web.exception import com.ofg.infrastructure.base.BaseConfiguration import com.ofg.infrastructure.base.ConfigurationWithoutServiceDiscovery import com.ofg.infrastructure.base.MvcCorrelationIdSettingIntegrationSpec -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Import @@ -16,7 +16,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status -@ContextConfiguration(classes = TestConfig, loader = SpringApplicationContextLoader) +@SpringBootTest(classes = TestConfig) class ExceptionHandlingMvcSpec extends MvcCorrelationIdSettingIntegrationSpec { def "should return bad request error for invalid field"() { diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/logging/FeignCallObfuscatingLoggerSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/logging/FeignCallObfuscatingLoggerSpec.groovy index 9a6066a4..0a98f75c 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/logging/FeignCallObfuscatingLoggerSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/logging/FeignCallObfuscatingLoggerSpec.groovy @@ -6,29 +6,23 @@ import ch.qos.logback.core.Appender import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder import com.ofg.infrastructure.base.BaseConfiguration import com.ofg.infrastructure.base.MicroserviceMvcWiremockSpec +import com.ofg.infrastructure.discovery.ServiceResolverConfiguration import com.ofg.infrastructure.discovery.web.HttpMockServer import com.ofg.infrastructure.web.logging.config.LogsConfig -import feign.Feign -import feign.FeignException -import feign.Headers -import feign.RequestLine -import feign.Response +import com.ofg.infrastructure.web.resttemplate.fluent.EnableServiceRestClient +import feign.* import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.context.properties.EnableConfigurationProperties -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.Configuration import org.springframework.http.MediaType -import org.springframework.test.context.ContextConfiguration import java.util.regex.Pattern -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.get -import static com.github.tomakehurst.wiremock.client.WireMock.post -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching +import static com.github.tomakehurst.wiremock.client.WireMock.* -@ContextConfiguration(classes = [RequestLoggingSpecConfiguration, BaseConfiguration], loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [RequestLoggingSpecConfiguration, BaseConfiguration, ServiceResolverConfiguration]) class FeignCallObfuscatingLoggerSpec extends MicroserviceMvcWiremockSpec { private static final String JSON_REQ_RESOURCE_NAME = 'requestLogging/message_req.json' @@ -332,5 +326,6 @@ class FeignCallObfuscatingLoggerSpec extends MicroserviceMvcWiremockSpec { @Configuration @EnableObfuscatedLogging @EnableConfigurationProperties + @EnableServiceRestClient static class RequestLoggingSpecConfiguration {} } diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/logging/RequestLoggingClientInterceptorSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/logging/RequestLoggingClientInterceptorSpec.groovy index 6b5f3a28..6bff7fb7 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/logging/RequestLoggingClientInterceptorSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/logging/RequestLoggingClientInterceptorSpec.groovy @@ -6,24 +6,22 @@ import ch.qos.logback.core.Appender import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder import com.ofg.infrastructure.base.BaseConfiguration import com.ofg.infrastructure.base.MicroserviceMvcWiremockSpec +import com.ofg.infrastructure.discovery.ServiceResolverConfiguration import com.ofg.infrastructure.discovery.web.HttpMockServer import com.ofg.infrastructure.web.resttemplate.custom.ResponseException +import com.ofg.infrastructure.web.resttemplate.fluent.EnableServiceRestClient import com.ofg.infrastructure.web.resttemplate.fluent.ServiceRestClient import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.Configuration import org.springframework.http.MediaType -import org.springframework.test.context.ContextConfiguration import java.util.regex.Pattern -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.get -import static com.github.tomakehurst.wiremock.client.WireMock.post -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching +import static com.github.tomakehurst.wiremock.client.WireMock.* -@ContextConfiguration(classes = [RequestLoggingSpecConfiguration, BaseConfiguration], loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [RequestLoggingSpecConfiguration, BaseConfiguration, ServiceResolverConfiguration]) class RequestLoggingClientInterceptorSpec extends MicroserviceMvcWiremockSpec { @Autowired private ServiceRestClient serviceRestClient @@ -201,6 +199,7 @@ class RequestLoggingClientInterceptorSpec extends MicroserviceMvcWiremockSpec { @Configuration @EnableObfuscatedLogging + @EnableServiceRestClient static class RequestLoggingSpecConfiguration {} private void callGet(String path, Map requestHeaders) { diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/logging/RequestLoggingControllerFilterSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/logging/RequestLoggingControllerFilterSpec.groovy index 98042dfe..b4c5860e 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/logging/RequestLoggingControllerFilterSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/logging/RequestLoggingControllerFilterSpec.groovy @@ -12,7 +12,7 @@ import com.ofg.infrastructure.web.view.ViewConfiguration import groovy.transform.CompileStatic import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.http.HttpHeaders @@ -35,8 +35,8 @@ import java.util.regex.Pattern import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get -@ContextConfiguration(classes = [RequestLoggingSpecConfiguration, BaseConfiguration, ConfigurationWithoutServiceDiscovery, ViewConfiguration], - loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [RequestLoggingSpecConfiguration, BaseConfiguration, ConfigurationWithoutServiceDiscovery, + ViewConfiguration]) class RequestLoggingControllerFilterSpec extends MvcIntegrationSpec { private static final String JSON_REQ_RESOURCE_NAME = 'requestLogging/message_req.json' diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/RestOperationsMetricsAspectIntegrationSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/RestOperationsMetricsAspectIntegrationSpec.groovy index 726fc72b..b2a0669e 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/RestOperationsMetricsAspectIntegrationSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/RestOperationsMetricsAspectIntegrationSpec.groovy @@ -8,7 +8,7 @@ import com.ofg.infrastructure.web.resttemplate.custom.RestTemplate import com.ofg.infrastructure.web.resttemplate.fluent.ServiceRestClientConfiguration import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.EnableAutoConfiguration -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.Bean import org.springframework.context.annotation.EnableAspectJAutoProxy import org.springframework.context.support.PropertySourcesPlaceholderConfigurer @@ -27,7 +27,7 @@ import java.util.concurrent.Callable import static com.github.tomakehurst.wiremock.client.WireMock.* -@ContextConfiguration(classes = [ServiceRestClientConfiguration, ServiceDiscoveryConfiguration, Config], loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [ServiceRestClientConfiguration, ServiceDiscoveryConfiguration, Config]) @TestPropertySource(properties = 'rest.client.metrics.enabled=true') class RestOperationsMetricsAspectIntegrationSpec extends MvcWiremockIntegrationSpec { diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientCustomizationByNameSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientCustomizationByNameSpec.groovy index 4dbf881c..2bb202a0 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientCustomizationByNameSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientCustomizationByNameSpec.groovy @@ -8,14 +8,14 @@ import com.ofg.infrastructure.web.resttemplate.RestOperationsMetricsAspect import groovy.transform.CompileStatic import groovy.transform.InheritConstructors import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.EnableAspectJAutoProxy import org.springframework.context.annotation.Import import org.springframework.test.context.ContextConfiguration -@ContextConfiguration(classes = CustomConfig, loader = SpringApplicationContextLoader) +@SpringBootTest(classes = CustomConfig) class ServiceRestClientCustomizationByNameSpec extends MvcCorrelationIdSettingIntegrationSpec { @Autowired diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientCustomizationSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientCustomizationSpec.groovy index 121000b4..2ae36401 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientCustomizationSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientCustomizationSpec.groovy @@ -7,7 +7,7 @@ import com.ofg.infrastructure.web.resttemplate.custom.RestTemplate import com.ofg.infrastructure.web.resttemplate.fluent.config.ServiceRestClientConfigurerAdapter import groovy.transform.CompileStatic import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.ApplicationContext import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.EnableAspectJAutoProxy @@ -16,7 +16,7 @@ import org.springframework.http.converter.HttpMessageConverter import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter import org.springframework.test.context.ContextConfiguration -@ContextConfiguration(classes = CustomConfig, loader = SpringApplicationContextLoader) +@SpringBootTest(classes = CustomConfig) class ServiceRestClientCustomizationSpec extends MvcCorrelationIdSettingIntegrationSpec { static diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientIntegrationSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientIntegrationSpec.groovy index 454905e0..203a32d9 100755 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientIntegrationSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientIntegrationSpec.groovy @@ -15,7 +15,7 @@ import org.junit.contrib.java.lang.system.ProvideSystemProperty import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.http.ResponseEntity import org.springframework.test.context.ActiveProfiles import org.springframework.test.context.ContextConfiguration @@ -27,7 +27,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse import static com.ofg.infrastructure.base.dsl.WireMockHttpRequestMapper.wireMockGet @ActiveProfiles(['stub', BasicProfiles.TEST]) -@ContextConfiguration(classes = [BaseConfiguration, ServiceDiscoveryStubbingApplicationConfiguration], loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [BaseConfiguration, ServiceDiscoveryStubbingApplicationConfiguration]) class ServiceRestClientIntegrationSpec extends MvcWiremockIntegrationSpec { private static final ServiceAlias COLLABORATOR_ALIAS = new ServiceAlias('foo-bar') diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientWebIntegrationSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientWebIntegrationSpec.groovy index 0c917ab8..5a80c8f5 100755 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientWebIntegrationSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/ServiceRestClientWebIntegrationSpec.groovy @@ -13,7 +13,7 @@ import org.hamcrest.Matchers import org.junit.ClassRule import org.junit.contrib.java.lang.system.ProvideSystemProperty import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.cloud.sleuth.instrument.web.TraceFilter import org.springframework.context.annotation.Configuration import org.springframework.test.context.ActiveProfiles @@ -28,7 +28,7 @@ import spock.lang.Shared import java.util.concurrent.Executors @ActiveProfiles(['stub', BasicProfiles.TEST]) -@ContextConfiguration(classes = [BaseConfiguration, SampleController, ServiceDiscoveryStubbingApplicationConfiguration], loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [BaseConfiguration, SampleController, ServiceDiscoveryStubbingApplicationConfiguration]) class ServiceRestClientWebIntegrationSpec extends MvcWiremockIntegrationSpec { private static final ServiceAlias COLLABORATOR_ALIAS = new ServiceAlias('foo-bar') diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/TwoRestOperationsImplementationsSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/TwoRestOperationsImplementationsSpec.groovy index be323a85..73bb611b 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/TwoRestOperationsImplementationsSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/resttemplate/fluent/TwoRestOperationsImplementationsSpec.groovy @@ -7,13 +7,12 @@ import com.ofg.infrastructure.discovery.ServiceResolver import groovy.transform.CompileStatic import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.* import org.springframework.core.io.Resource -import org.springframework.test.context.ContextConfiguration import org.springframework.web.client.RestOperations -@ContextConfiguration(classes = Config, loader = SpringApplicationContextLoader) +@SpringBootTest(classes = Config) class TwoRestOperationsImplementationsSpec extends MvcCorrelationIdSettingIntegrationSpec { @Autowired diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/AcceptingUnquotedFieldsInJsonSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/AcceptingUnquotedFieldsInJsonSpec.groovy index 13931a4b..439c599b 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/AcceptingUnquotedFieldsInJsonSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/AcceptingUnquotedFieldsInJsonSpec.groovy @@ -3,7 +3,7 @@ package com.ofg.infrastructure.web.view import com.ofg.infrastructure.base.BaseConfiguration import com.ofg.infrastructure.base.ConfigurationWithoutServiceDiscovery import com.ofg.infrastructure.base.MvcCorrelationIdSettingIntegrationSpec -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.ApplicationContextInitializer import org.springframework.context.ConfigurableApplicationContext import org.springframework.context.annotation.Bean @@ -19,9 +19,9 @@ import static com.ofg.config.BasicProfiles.DEVELOPMENT import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status +@SpringBootTest() @ContextConfiguration(classes = [Config, BaseConfiguration, ConfigurationWithoutServiceDiscovery, ViewConfiguration], - loader = SpringApplicationContextLoader, - initializers = PropertyMockingApplicationContextInitializer.class) + initializers = PropertyMockingApplicationContextInitializer.class) @ActiveProfiles(DEVELOPMENT) class AcceptingUnquotedFieldsInJsonSpec extends MvcCorrelationIdSettingIntegrationSpec { @@ -32,7 +32,7 @@ class AcceptingUnquotedFieldsInJsonSpec extends MvcCorrelationIdSettingIntegrati mockMvc.perform(post("/test") .contentType(MediaType.APPLICATION_JSON) .content(REQUEST_JSON_BODY)) - .andExpect(status().isCreated()) + .andExpect(status().isCreated()) } @Configuration diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/JsonIgnoreUnknownPropertySpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/JsonIgnoreUnknownPropertySpec.groovy index 3048c4e6..d47a76c8 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/JsonIgnoreUnknownPropertySpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/JsonIgnoreUnknownPropertySpec.groovy @@ -3,7 +3,7 @@ package com.ofg.infrastructure.web.view import com.ofg.infrastructure.base.BaseConfiguration import com.ofg.infrastructure.base.ConfigurationWithoutServiceDiscovery import com.ofg.infrastructure.base.MvcCorrelationIdSettingIntegrationSpec -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.test.context.ContextConfiguration @@ -12,8 +12,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status -@ContextConfiguration(classes = [JsonIgnoreUnknownPropertySpec.Config, BaseConfiguration, ConfigurationWithoutServiceDiscovery], - loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [Config, BaseConfiguration, ConfigurationWithoutServiceDiscovery]) class JsonIgnoreUnknownPropertySpec extends MvcCorrelationIdSettingIntegrationSpec { private static final String JSON_WITH_ADDITIONAL_FIELDS = '{"sampleField":"sampleValue", "unknownField":"unknownValue"}' diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/NoPrettyPrintingInProductionEnvironmentSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/NoPrettyPrintingInProductionEnvironmentSpec.groovy index beed0078..d23485aa 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/NoPrettyPrintingInProductionEnvironmentSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/NoPrettyPrintingInProductionEnvironmentSpec.groovy @@ -3,7 +3,7 @@ package com.ofg.infrastructure.web.view import com.ofg.infrastructure.base.BaseConfiguration import com.ofg.infrastructure.base.ConfigurationWithoutServiceDiscovery import com.ofg.infrastructure.base.MvcIntegrationSpec -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.io.ClassPathResource @@ -14,8 +14,7 @@ import static com.ofg.config.BasicProfiles.PRODUCTION import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content -@ContextConfiguration(classes = [Config, BaseConfiguration, ConfigurationWithoutServiceDiscovery], - loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [Config, BaseConfiguration, ConfigurationWithoutServiceDiscovery]) @ActiveProfiles(value = PRODUCTION, inheritProfiles = false) class NoPrettyPrintingInProductionEnvironmentSpec extends MvcIntegrationSpec { diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/PrettyPrintingInDevelopmentEnvironmentSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/PrettyPrintingInDevelopmentEnvironmentSpec.groovy index 5b159867..0688fb9c 100755 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/PrettyPrintingInDevelopmentEnvironmentSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/PrettyPrintingInDevelopmentEnvironmentSpec.groovy @@ -3,7 +3,7 @@ package com.ofg.infrastructure.web.view import com.ofg.infrastructure.base.BaseConfiguration import com.ofg.infrastructure.base.ConfigurationWithoutServiceDiscovery import com.ofg.infrastructure.base.MvcCorrelationIdSettingIntegrationSpec -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.io.ClassPathResource @@ -13,8 +13,7 @@ import org.springframework.test.context.ContextConfiguration import static com.ofg.config.BasicProfiles.DEVELOPMENT import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get -@ContextConfiguration(classes = [Config, BaseConfiguration, ConfigurationWithoutServiceDiscovery], - loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [Config, BaseConfiguration, ConfigurationWithoutServiceDiscovery]) @ActiveProfiles(DEVELOPMENT) class PrettyPrintingInDevelopmentEnvironmentSpec extends MvcCorrelationIdSettingIntegrationSpec { diff --git a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/SentJSONObjectsShouldBeCorrectlyDeserializedSpec.groovy b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/SentJSONObjectsShouldBeCorrectlyDeserializedSpec.groovy index e4659762..b2eac613 100644 --- a/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/SentJSONObjectsShouldBeCorrectlyDeserializedSpec.groovy +++ b/micro-infra-spring-base/src/test/groovy/com/ofg/infrastructure/web/view/SentJSONObjectsShouldBeCorrectlyDeserializedSpec.groovy @@ -3,7 +3,7 @@ package com.ofg.infrastructure.web.view import com.ofg.infrastructure.base.BaseConfiguration import com.ofg.infrastructure.base.ConfigurationWithoutServiceDiscovery import com.ofg.infrastructure.base.MvcCorrelationIdSettingIntegrationSpec -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.http.HttpStatus @@ -13,8 +13,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status -@ContextConfiguration(classes = [Config, BaseConfiguration, ConfigurationWithoutServiceDiscovery], - loader = SpringApplicationContextLoader) +@SpringBootTest(classes = [Config, BaseConfiguration, ConfigurationWithoutServiceDiscovery]) class SentJSONObjectsShouldBeCorrectlyDeserializedSpec extends MvcCorrelationIdSettingIntegrationSpec { def "should correctly deserialize request to SampleBean instance when valid JSON document is sent to controller"() { diff --git a/micro-infra-spring-config/src/test/groovy/com/ofg/infrastructure/property/decrypt/EncryptorTestUtil.groovy b/micro-infra-spring-config/src/test/groovy/com/ofg/infrastructure/property/decrypt/EncryptorTestUtil.groovy index df5d2e43..f369e330 100644 --- a/micro-infra-spring-config/src/test/groovy/com/ofg/infrastructure/property/decrypt/EncryptorTestUtil.groovy +++ b/micro-infra-spring-config/src/test/groovy/com/ofg/infrastructure/property/decrypt/EncryptorTestUtil.groovy @@ -4,6 +4,7 @@ import groovy.transform.CompileStatic import groovy.transform.PackageScope import groovy.transform.ToString import groovy.transform.TupleConstructor +import org.springframework.boot.Banner import org.springframework.boot.builder.SpringApplicationBuilder import org.springframework.security.crypto.encrypt.TextEncryptor @@ -31,7 +32,7 @@ class EncryptorTestUtil { def context = new SpringApplicationBuilder(DecryptingPropertyTestApp) .web(false) - .showBanner(false) + .bannerMode(Banner.Mode.OFF) .run() def encryptor = context.getBean(TextEncryptor) diff --git a/stub-runner/stub-runner/build.gradle b/stub-runner/stub-runner/build.gradle index 514a94cd..884e9195 100644 --- a/stub-runner/stub-runner/build.gradle +++ b/stub-runner/stub-runner/build.gradle @@ -18,6 +18,9 @@ dependencies { compile 'ch.qos.logback:logback-classic' compile 'args4j:args4j:2.32' compile 'com.nurkiewicz.asyncretry:asyncretry-jdk7:0.0.6' + compile 'org.eclipse.jetty:jetty-server' + compile 'org.eclipse.jetty:jetty-servlet' + compile 'org.eclipse.jetty:jetty-servlets' compile "org.eclipse.aether:aether-api:${aetherVersion}" compile "org.eclipse.aether:aether-impl:${aetherVersion}"