diff --git a/pom.xml b/pom.xml
index 65d8ecaf95..72faff14f2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,7 +18,6 @@
3.2.5
3.4
- 1.7
UTF-8
diff --git a/src/main/java/io/codearte/accurest/maven/GenerateSpecsMojo.java b/src/main/java/io/codearte/accurest/maven/GenerateSpecsMojo.java
index 971f4e03ed..3b26bf5617 100644
--- a/src/main/java/io/codearte/accurest/maven/GenerateSpecsMojo.java
+++ b/src/main/java/io/codearte/accurest/maven/GenerateSpecsMojo.java
@@ -33,6 +33,9 @@ public class GenerateSpecsMojo extends AbstractMojo {
@Parameter(property = "basePackageForTests", defaultValue = "io.codearte.accurest.tests")
private String basePackageForTests;
+ @Parameter(property = "baseClassForTests", required = true)
+ private String baseClassForTests;
+
public GenerateSpecsMojo() {
}
@@ -42,9 +45,11 @@ public class GenerateSpecsMojo extends AbstractMojo {
config.setContractsDslDir(new File(baseDir, contractsDir));
config.setBasePackageForTests(basePackageForTests);
config.setGeneratedTestSourcesDir(new File(projectBuildDirectory, generatedTestSourcesDir));
+ config.setBaseClassForTests(baseClassForTests);
getLog().info("Accurest Plugin: Invoking test sources generation");
getLog().info(format("Using %s as test source directory", config.getGeneratedTestSourcesDir()));
+ getLog().info(format("Using %s as base class for tests", config.getBaseClassForTests()));
try {
TestGenerator generator = new TestGenerator(config);
diff --git a/src/test/java/io/codearte/accurest/maven/PluginIntegrationTest.java b/src/test/java/io/codearte/accurest/maven/PluginIntegrationTest.java
index a786df3778..5f3b2626f0 100644
--- a/src/test/java/io/codearte/accurest/maven/PluginIntegrationTest.java
+++ b/src/test/java/io/codearte/accurest/maven/PluginIntegrationTest.java
@@ -40,4 +40,13 @@ public class PluginIntegrationTest {
.execute("package")
.assertLogText("Accurest Plugin: Invoking test sources generation");
}
+
+ @Test
+ public void shouldBuildAndTestSimpleBootProject() throws Exception {
+ File basedir = resources.getBasedir("bootSimple");
+ maven.forProject(basedir)
+ .execute("package")
+ .assertErrorFreeLog()
+ .assertLogText("Accurest Plugin: Invoking test sources generation");
+ }
}
\ No newline at end of file
diff --git a/src/test/projects/basic-with-execution/pom.xml b/src/test/projects/basic-with-execution/pom.xml
index ccbd71803d..8f5f9d6b65 100644
--- a/src/test/projects/basic-with-execution/pom.xml
+++ b/src/test/projects/basic-with-execution/pom.xml
@@ -60,6 +60,9 @@
+
+ com.ofg.twitter.place.BaseMockMvcSpec
+
org.codehaus.gmavenplus
@@ -74,6 +77,12 @@
+
+ ${project.basedir}/src/test/groovy
+
+ **/*.groovy
+
+
${project.build.directory}/generated-test-sources/accurest
diff --git a/src/test/projects/bootSimple/pom.xml b/src/test/projects/bootSimple/pom.xml
new file mode 100644
index 0000000000..187d737361
--- /dev/null
+++ b/src/test/projects/bootSimple/pom.xml
@@ -0,0 +1,153 @@
+
+
+ 4.0.0
+
+ io.codearte.sample
+ sample-simple-boot
+ 0.0.1-SNAPSHOT
+ jar
+
+ sample-simple-boot
+ Demo project for Spring Boot
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.3.3.RELEASE
+
+
+
+
+ UTF-8
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+ org.codehaus.groovy
+ groovy-all
+
+
+
+
+ org.spockframework
+ spock-core
+ 1.0-groovy-2.4
+ test
+
+
+ com.jayway.restassured
+ rest-assured
+ 2.9.0
+ test
+
+
+ com.jayway.restassured
+ spring-mock-mvc
+ 2.9.0
+ test
+
+
+ com.github.tomakehurst
+ wiremock
+ 2.0.4-beta
+ test
+
+
+ com.toomuchcoding.jsonassert
+ jsonassert
+ 0.2.2
+ test
+
+
+ org.assertj
+ assertj-core
+ 2.3.0
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ io.codearte.accurest
+ accurest-maven-plugin
+ ${it-plugin.version}
+
+
+
+ generateStubs
+ generateSpecs
+
+
+
+
+ com.ofg.twitter.place.BaseMockMvcSpec
+
+
+
+ org.codehaus.gmavenplus
+ gmavenplus-plugin
+ 1.5
+
+
+
+ addSources
+ addTestSources
+ generateStubs
+ compile
+ testGenerateStubs
+ testCompile
+ removeStubs
+ removeTestStubs
+
+
+
+
+
+
+ ${project.basedir}/src/test/groovy
+
+ **/*.groovy
+
+
+
+ ${project.build.directory}/generated-test-sources/accurest
+
+ **/*.groovy
+
+
+
+
+
+
+ maven-surefire-plugin
+ 2.19
+
+
+ **/*Spec.java
+
+
+
+
+
+
+
+
diff --git a/src/test/projects/bootSimple/src/main/groovy/com/ofg/twitter/place/PairIdController.groovy b/src/test/projects/bootSimple/src/main/groovy/com/ofg/twitter/place/PairIdController.groovy
new file mode 100644
index 0000000000..3a7671793c
--- /dev/null
+++ b/src/test/projects/bootSimple/src/main/groovy/com/ofg/twitter/place/PairIdController.groovy
@@ -0,0 +1,36 @@
+package com.ofg.twitter.place
+
+import groovy.transform.TypeChecked
+import groovy.util.logging.Slf4j
+import org.springframework.http.MediaType
+import org.springframework.web.bind.annotation.PathVariable
+import org.springframework.web.bind.annotation.RequestBody
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RestController
+
+import static org.springframework.web.bind.annotation.RequestMethod.PUT
+
+@Slf4j
+@RestController
+@RequestMapping('/api')
+@TypeChecked
+class PairIdController {
+
+ @RequestMapping(
+ value = '{pairId}',
+ method = PUT,
+ consumes = MediaType.APPLICATION_JSON_VALUE,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ String getPlacesFromTweets(@PathVariable long pairId, @RequestBody List tweets) {
+ log.info("Inside PairIdController, doing very important logic")
+ if (tweets?.text != ["Gonna see you at Warsaw"]) {
+ throw new IllegalArgumentException("Wrong text in tweet: ${tweets?.text}")
+ }
+ return """
+ {
+ "path" : "/api/$pairId",
+ "correlationId" : 123456
+ }
+ """
+ }
+}
diff --git a/src/test/projects/bootSimple/src/main/groovy/com/ofg/twitter/place/Tweet.java b/src/test/projects/bootSimple/src/main/groovy/com/ofg/twitter/place/Tweet.java
new file mode 100644
index 0000000000..5d1e9c2835
--- /dev/null
+++ b/src/test/projects/bootSimple/src/main/groovy/com/ofg/twitter/place/Tweet.java
@@ -0,0 +1,13 @@
+package com.ofg.twitter.place;
+
+public class Tweet {
+ private String text;
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+}
diff --git a/src/test/projects/bootSimple/src/main/java/io/codearte/sample/SampleSimpleBootApplication.java b/src/test/projects/bootSimple/src/main/java/io/codearte/sample/SampleSimpleBootApplication.java
new file mode 100644
index 0000000000..1ef9cf14fa
--- /dev/null
+++ b/src/test/projects/bootSimple/src/main/java/io/codearte/sample/SampleSimpleBootApplication.java
@@ -0,0 +1,12 @@
+package io.codearte.sample;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SampleSimpleBootApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SampleSimpleBootApplication.class, args);
+ }
+}
diff --git a/src/test/projects/bootSimple/src/main/resources/application.properties b/src/test/projects/bootSimple/src/main/resources/application.properties
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/src/test/projects/bootSimple/src/test/groovy/com/ofg/twitter/place/AcceptanceSpec.groovy b/src/test/projects/bootSimple/src/test/groovy/com/ofg/twitter/place/AcceptanceSpec.groovy
new file mode 100644
index 0000000000..3c244ce6cd
--- /dev/null
+++ b/src/test/projects/bootSimple/src/test/groovy/com/ofg/twitter/place/AcceptanceSpec.groovy
@@ -0,0 +1,23 @@
+package com.ofg.twitter.place
+
+import com.ofg.twitter.place.PairIdController
+import org.springframework.http.MediaType
+import org.springframework.test.web.servlet.MockMvc
+import org.springframework.test.web.servlet.setup.MockMvcBuilders
+import spock.lang.Specification
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
+
+class AcceptanceSpec extends Specification {
+
+ def "should have controller up and running"() {
+ given:
+ MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new PairIdController()).build()
+ expect:
+ mockMvc.perform(put("/api/${1}").
+ contentType(MediaType.APPLICATION_JSON).
+ content("""[{"text":"Gonna see you at Warsaw"}]""")).
+ andExpect(status().isOk())
+ }
+}
diff --git a/src/test/projects/bootSimple/src/test/groovy/com/ofg/twitter/place/BaseMockMvcSpec.groovy b/src/test/projects/bootSimple/src/test/groovy/com/ofg/twitter/place/BaseMockMvcSpec.groovy
new file mode 100644
index 0000000000..b85a44721d
--- /dev/null
+++ b/src/test/projects/bootSimple/src/test/groovy/com/ofg/twitter/place/BaseMockMvcSpec.groovy
@@ -0,0 +1,16 @@
+package com.ofg.twitter.place
+
+import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc
+import com.ofg.twitter.place.PairIdController
+import spock.lang.Specification
+
+abstract class BaseMockMvcSpec extends Specification {
+
+ def setup() {
+ RestAssuredMockMvc.standaloneSetup(new PairIdController())
+ }
+
+ void isProperCorrelationId(Integer correlationId) {
+ assert correlationId == 123456
+ }
+}
diff --git a/src/test/projects/bootSimple/src/test/java/io/codearte/sample/SampleSimpleBootApplicationTests.java b/src/test/projects/bootSimple/src/test/java/io/codearte/sample/SampleSimpleBootApplicationTests.java
new file mode 100644
index 0000000000..345f6ef841
--- /dev/null
+++ b/src/test/projects/bootSimple/src/test/java/io/codearte/sample/SampleSimpleBootApplicationTests.java
@@ -0,0 +1,16 @@
+package io.codearte.sample;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = SampleSimpleBootApplication.class)
+public class SampleSimpleBootApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/src/test/projects/bootSimple/src/test/resources/logback-test.groovy b/src/test/projects/bootSimple/src/test/resources/logback-test.groovy
new file mode 100644
index 0000000000..315c39c794
--- /dev/null
+++ b/src/test/projects/bootSimple/src/test/resources/logback-test.groovy
@@ -0,0 +1,14 @@
+import ch.qos.logback.classic.encoder.PatternLayoutEncoder
+import ch.qos.logback.core.ConsoleAppender
+
+String console = "CONSOLE"
+String logPattern = "%d{yyyy-MM-dd HH:mm:ss.SSSZ, Europe/Warsaw} | %-5level | %X{correlationId} | %thread | %logger{1} | %m%n"
+
+appender(console, ConsoleAppender) {
+ encoder(PatternLayoutEncoder) {
+ pattern = logPattern
+ }
+}
+
+root(INFO, [console])
+logger("com.ofg", DEBUG)
diff --git a/src/test/projects/bootSimple/src/test/resources/stubs/collerate_PlacesFrom_Tweet.groovy b/src/test/projects/bootSimple/src/test/resources/stubs/collerate_PlacesFrom_Tweet.groovy
new file mode 100644
index 0000000000..826f71b791
--- /dev/null
+++ b/src/test/projects/bootSimple/src/test/resources/stubs/collerate_PlacesFrom_Tweet.groovy
@@ -0,0 +1,18 @@
+io.codearte.accurest.dsl.GroovyDsl.make {
+ priority 2
+ request {
+ method 'PUT'
+ url '/api/12'
+ headers {
+ header 'Content-Type': 'application/json'
+ }
+ body '''\
+ [{
+ "text": "Gonna see you at Warsaw"
+ }]
+'''
+ }
+ response {
+ status 200
+ }
+}
\ No newline at end of file
diff --git a/src/test/projects/bootSimple/src/test/resources/stubs/moreComplexVersion.groovy b/src/test/projects/bootSimple/src/test/resources/stubs/moreComplexVersion.groovy
new file mode 100644
index 0000000000..943fbc23b9
--- /dev/null
+++ b/src/test/projects/bootSimple/src/test/resources/stubs/moreComplexVersion.groovy
@@ -0,0 +1,21 @@
+io.codearte.accurest.dsl.GroovyDsl.make {
+ request {
+ method 'PUT'
+ url $(client(regex('^/api/[0-9]{2}$')), server('/api/12'))
+ headers {
+ header 'Content-Type': 'application/json'
+ }
+ body '''\
+ [{
+ "text": "Gonna see you at Warsaw"
+ }]
+'''
+ }
+ response {
+ body (
+ path: $(client('/api/12'), server(regex('^/api/[0-9]{2}$'))),
+ correlationId: $(client('1223456'), server(execute('isProperCorrelationId($it)')))
+ )
+ status 200
+ }
+}
\ No newline at end of file