diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/stream/StreamStubMessages.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/stream/StreamStubMessages.java index 4122cac3f9..f44acecb0e 100644 --- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/stream/StreamStubMessages.java +++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/stream/StreamStubMessages.java @@ -94,7 +94,7 @@ public class StreamStubMessages implements MessageVerifier> { log.debug("Found a channel named [{}] with destination [{}]", entry.getKey(), destination); } - channels.put(entry.getKey().toLowerCase(), destination); + channels.put(entry.getKey(), destination); } } if (channels.size() == 1) { diff --git a/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/messaging/stream/StreamStubMessagesSpec.groovy b/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/messaging/stream/StreamStubMessagesSpec.groovy index 8cfcd09210..fea1e10fd2 100644 --- a/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/messaging/stream/StreamStubMessagesSpec.groovy +++ b/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/messaging/stream/StreamStubMessagesSpec.groovy @@ -106,4 +106,97 @@ class StreamStubMessagesSpec extends Specification { messageInteraction << [ { StreamStubMessages stream -> stream.send("foo", [:], "verifications")}, { StreamStubMessages stream -> stream.receive("verifications")}] } + + @Issue("694") + def "should resolve input channel if input and output have same destination and receive is called and channel name is camel case"() { + given: + ApplicationContext applicationContext = Mock(ApplicationContext) + BindingServiceProperties properties = new BindingServiceProperties( + bindings: [ + input: new BindingProperties(destination: "verificationsChannel"), + output: new BindingProperties(destination: "verificationsChannel"), + ] + ) + MessageCollector collector = Stub(MessageCollector) + and: + applicationContext.getBean(BindingServiceProperties) >> properties + applicationContext.getBean(MessageCollector) >> collector + and: + StreamStubMessages messages = new StreamStubMessages(applicationContext) + when: + messages.receive("verificationsChannel") + then: + 1 * applicationContext.getBean("input", MessageChannel) >> null + } + + @Issue("694") + def "should resolve output channel if input and output have same destination and send is called and channel name is camel case"() { + given: + ApplicationContext applicationContext = Mock(ApplicationContext) + BindingServiceProperties properties = new BindingServiceProperties( + bindings: [ + input: new BindingProperties(destination: "verificationsChannel"), + output: new BindingProperties(destination: "verificationsChannel"), + ] + ) + MessageCollector collector = Stub(MessageCollector) + MessageChannel channel = Stub(MessageChannel) + and: + applicationContext.getBean(BindingServiceProperties) >> properties + applicationContext.getBean(MessageCollector) >> collector + and: + StreamStubMessages messages = new StreamStubMessages(applicationContext) + when: + messages.send("foo", [:], "verificationsChannel") + then: + 1 * applicationContext.getBean("output", MessageChannel) >> channel + } + + def "should resolve channel via destination for send and receive and channel name is camel case"() { + given: + ApplicationContext applicationContext = Mock(ApplicationContext) + BindingServiceProperties properties = new BindingServiceProperties( + bindings: [ + foo: new BindingProperties(destination: "verificationsChannel") + ] + ) + MessageCollector collector = Stub(MessageCollector) + MessageChannel channel = Stub(MessageChannel) + and: + applicationContext.getBean(BindingServiceProperties) >> properties + applicationContext.getBean(MessageCollector) >> collector + and: + StreamStubMessages messages = new StreamStubMessages(applicationContext) + when: + messageInteraction(messages) + then: + 1 * applicationContext.getBean("foo", MessageChannel) >> channel + where: + messageInteraction << [ { StreamStubMessages stream -> stream.send("foo", [:], "verificationsChannel")}, + { StreamStubMessages stream -> stream.receive("verificationsChannel")}] + } + + def "should resolve channel via channel name for send and receive and channel name is camel case"() { + given: + ApplicationContext applicationContext = Mock(ApplicationContext) + BindingServiceProperties properties = new BindingServiceProperties( + bindings: [ + verificationsChannel: new BindingProperties(destination: "bar") + ] + ) + MessageCollector collector = Stub(MessageCollector) + MessageChannel channel = Stub(MessageChannel) + and: + applicationContext.getBean(BindingServiceProperties) >> properties + applicationContext.getBean(MessageCollector) >> collector + and: + StreamStubMessages messages = new StreamStubMessages(applicationContext) + when: + messageInteraction(messages) + then: + 1 * applicationContext.getBean("verificationsChannel", MessageChannel) >> channel + where: + messageInteraction << [ { StreamStubMessages stream -> stream.send("foo", [:], "verificationsChannel")}, + { StreamStubMessages stream -> stream.receive("verificationsChannel")}] + } }