Fix samples tests to run from command line

This commit is contained in:
Dave Syer
2016-07-11 13:45:03 +01:00
parent 25f18db8fb
commit 59be4bae4a
8 changed files with 60 additions and 9 deletions

View File

@@ -30,12 +30,10 @@
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
<version>5.12.1</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
<version>5.12.1</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
@@ -49,7 +47,7 @@
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<artifactId>spock-spring</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -58,4 +56,12 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -22,10 +22,12 @@ import com.toomuchcoding.jsonassert.JsonAssertion
import org.springframework.cloud.contract.spec.Contract
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessage
import org.apache.camel.model.ModelCamelContext
import org.junit.BeforeClass;
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.SpringApplicationContextLoader
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessaging
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierObjectMapper
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration
import spock.lang.Specification
import spock.util.concurrent.PollingConditions
@@ -36,11 +38,17 @@ import javax.inject.Inject
*/
// Context configuration would end up in base class
@ContextConfiguration(classes = [CamelMessagingApplication], loader = SpringApplicationContextLoader)
@DirtiesContext
public class CamelMessagingApplicationSpec extends Specification {
// ALL CASES
@Inject ContractVerifierMessaging contractVerifierMessaging
ContractVerifierObjectMapper contractVerifierObjectMapper = new ContractVerifierObjectMapper()
@BeforeClass
void init() {
System.setProperty("org.apache.activemq.SERIALIZABLE_PACKAGES", "*")
}
def "should work for triggered based messaging"() {
given:

View File

@@ -34,7 +34,7 @@
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<artifactId>spock-spring</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -43,4 +43,12 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -25,12 +25,14 @@ import org.springframework.cloud.contract.spec.Contract
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessage
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessaging
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierObjectMapper
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration
import spock.lang.Specification
import javax.inject.Inject
// Context configuration would end up in base class
@ContextConfiguration(classes = [IntegrationMessagingApplication], loader = SpringApplicationContextLoader)
@DirtiesContext
public class IntegrationMessagingApplicationSpec extends Specification {
// ALL CASES

View File

@@ -23,9 +23,9 @@
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
<version>5.12.1</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
@@ -39,7 +39,7 @@
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<artifactId>spock-spring</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -48,4 +48,12 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -19,12 +19,15 @@ package org.springframework.cloud.contract.verifier.samples.spring
import com.jayway.jsonpath.DocumentContext
import com.jayway.jsonpath.JsonPath
import com.toomuchcoding.jsonassert.JsonAssertion
import org.junit.BeforeClass;
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.SpringApplicationContextLoader
import org.springframework.cloud.contract.spec.Contract
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessage
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessaging
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierObjectMapper
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration
import spock.lang.Specification
import spock.util.concurrent.PollingConditions
@@ -35,12 +38,18 @@ import javax.inject.Inject
*/
// Context configuration would end up in base class
@ContextConfiguration(classes = [SpringMessagingApplication], loader = SpringApplicationContextLoader)
@DirtiesContext
public class SpringApplicationSpec extends Specification {
// ALL CASES
@Inject ContractVerifierMessaging contractVerifierMessaging
ContractVerifierObjectMapper contractVerifierObjectMapper = new ContractVerifierObjectMapper()
@BeforeClass
void init() {
System.setProperty("org.apache.activemq.SERIALIZABLE_PACKAGES", "*")
}
def "should work for triggered based messaging"() {
given:
def dsl = Contract.make {

View File

@@ -29,7 +29,7 @@
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<artifactId>spock-spring</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -38,4 +38,12 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.SpringApplicationContextLoader
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessaging
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierObjectMapper
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration
import spock.lang.Specification
@@ -34,6 +35,7 @@ import javax.inject.Inject
*/
// Context configuration would end up in base class
@ContextConfiguration(classes = [StreamMessagingApplication], loader = SpringApplicationContextLoader)
@DirtiesContext
public class StreamMessagingApplicationSpec extends Specification {
// ALL CASES