Working with new stream for the verifier side

This commit is contained in:
Marcin Grzejszczak
2020-01-29 20:26:59 +01:00
parent 403d369b44
commit 343e8b477c
5 changed files with 9 additions and 64 deletions

View File

@@ -43,8 +43,7 @@ class StreamOutputDestinationMessageReceiver
try {
OutputDestination outputDestination = this.context
.getBean(OutputDestination.class);
return outputDestination.receive(timeUnit.toMillis(timeout),
destination);
return outputDestination.receive(timeUnit.toMillis(timeout), destination);
}
catch (Exception e) {
log.error("Exception occurred while trying to read a message from "

View File

@@ -42,7 +42,7 @@ class StreamStubMessagesWithDestinationsSpec extends Specification {
when:
messages.receive("verifications")
then:
1 * output.receive(5000, 0) >> null
1 * output.receive(5000, 'verifications') >> null
}
@Issue("694")
@@ -59,7 +59,7 @@ class StreamStubMessagesWithDestinationsSpec extends Specification {
when:
messages.send("foo", [:], "verifications")
then:
1 * input.send(_, 0)
1 * input.send(_, 'verifications')
}
def "should resolve channel via destination for send"() {
@@ -77,7 +77,7 @@ class StreamStubMessagesWithDestinationsSpec extends Specification {
when:
messages.send("foo", [:], "verifications")
then:
1 * input.send(_, 0)
1 * input.send(_, 'verifications')
}
def "should resolve channel via destination for receive"() {
@@ -95,6 +95,6 @@ class StreamStubMessagesWithDestinationsSpec extends Specification {
when:
messages.receive("verifications")
then:
1 * output.receive(5000, 0) >> null
1 * output.receive(5000, 'verifications') >> null
}
}

View File

@@ -67,18 +67,6 @@
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
<!-- Stream dependencies -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
<type>test-jar</type>
<scope>test</scope>
<classifier>test-binder</classifier>
</dependency>
</dependencies>
<build>
<plugins>

View File

@@ -20,18 +20,12 @@ import spock.lang.Specification
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.autoconfigure.ImportAutoConfiguration
import org.springframework.boot.test.context.SpringBootContextLoader
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.cloud.contract.stubrunner.StubFinder
import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner
import org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties
import org.springframework.cloud.stream.annotation.StreamListener
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration
import org.springframework.cloud.stream.messaging.Sink
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.stereotype.Component
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.context.ContextConfiguration
/**
@@ -48,9 +42,6 @@ class MocoHttpServerStubSpec extends Specification {
@Autowired
StubFinder stubFinder
@Autowired
MyListener myListener
def 'should successfully receive a response from a stub'() {
given:
String url = stubFinder.findStubUrl('fraudDetectionServerMoco').toString()
@@ -62,42 +53,12 @@ class MocoHttpServerStubSpec extends Specification {
"${url.toString()}/name2".toURL().text
then:
thrown(IOException)
when:
stubFinder.trigger("send_order")
then:
myListener.model?.description == "This is the order description"
when:
myListener.model = null
stubFinder.trigger("send_order2")
then:
myListener.model?.description == "This is the order description"
}
@Configuration
@EnableAutoConfiguration
@ImportAutoConfiguration(TestChannelBinderConfiguration.class)
static class MocoConfig {
@Bean
MyListener myListener() {
return new MyListener()
}
}
@Component
static class MyListener {
Model model
@StreamListener(Sink.INPUT)
void listen(Model data) {
this.model = data
}
}
static class Model {
String uuid
String description
}
}

View File

@@ -37,6 +37,7 @@ import org.springframework.cloud.stream.binder.test.TestChannelBinderConfigurati
import org.springframework.context.annotation.Configuration
import org.springframework.messaging.Message
import org.springframework.test.context.ContextConfiguration
/**
* @author Marcin Grzejszczak
*/
@@ -52,11 +53,6 @@ class StreamStubRunnerSpec extends Specification {
@Autowired
MessageVerifier<Message<?>> messaging
def setup() {
// ensure that message were taken from the queue
messaging.receive('returnBook', 100, TimeUnit.MILLISECONDS)
}
def 'should download the stub and register a route for it'() {
when:
// tag::client_send[]
@@ -219,10 +215,11 @@ class StreamStubRunnerSpec extends Specification {
}
// end::sample_dsl_3[]
@ImportAutoConfiguration(TestChannelBinderConfiguration.class)
@Configuration
@EnableAutoConfiguration
protected static class Config {}
protected static class Config {
}
}