@@ -71,7 +71,6 @@ public class ContractVerifierAmqpAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public MessageVerifier<Message> contractVerifierMessageExchange() {
|
||||
|
||||
return new SpringAmqpStubMessages(this.rabbitTemplate,
|
||||
new MessageListenerAccessor(this.rabbitListenerEndpointRegistry, this.simpleMessageListenerContainers, this.bindings));
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||
/**
|
||||
* Abstraction hiding details of the different sources of message listeners
|
||||
*
|
||||
* Needed because {@link org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor} adds the listners to the
|
||||
* Needed because {@link org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor} adds the listeners to the
|
||||
* {@link RabbitListenerEndpointRegistry} so that the registry is empty when wired into an auto configuration class
|
||||
* so we wrap it in the accessor to access the listeners late at runtime
|
||||
*
|
||||
@@ -38,7 +38,6 @@ class MessageListenerAccessor {
|
||||
List<SimpleMessageListenerContainer> listenerContainers = collectListenerContainers();
|
||||
//we interpret the destination as exchange name and collect all the queues bound to this exchange
|
||||
Set<String> queueNames = collectQueuesBoundToDestination(destination);
|
||||
|
||||
return getListenersByBoundQueues(listenerContainers, queueNames);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ public class ContractVerifierObjectMapper {
|
||||
public String writeValueAsString(Object payload) throws JsonProcessingException {
|
||||
if (payload instanceof String) {
|
||||
return payload.toString();
|
||||
} else if (payload instanceof byte[]) {
|
||||
return new String((byte[]) payload);
|
||||
}
|
||||
return this.objectMapper.writeValueAsString(payload);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.springframework.cloud.contract.verifier.messaging.internal
|
||||
|
||||
import spock.lang.Specification
|
||||
|
||||
class ContractVerifierObjectMapperSpec extends Specification {
|
||||
|
||||
ContractVerifierObjectMapper mapper = new ContractVerifierObjectMapper()
|
||||
|
||||
def "should convert an object into a json representation"() {
|
||||
given:
|
||||
MyClass input = new MyClass(foo: "bar")
|
||||
when:
|
||||
String result = mapper.writeValueAsString(input)
|
||||
then:
|
||||
result == '''{"foo":"bar"}'''
|
||||
}
|
||||
|
||||
def "should convert bytes into a json representation"() {
|
||||
given:
|
||||
String input = '''{"foo":"bar"}'''
|
||||
when:
|
||||
String result = mapper.writeValueAsString(input.bytes)
|
||||
then:
|
||||
result == '''{"foo":"bar"}'''
|
||||
}
|
||||
|
||||
class MyClass {
|
||||
String foo
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user