I try to test message sending and receiving via spring-cloud-stream using MessageCollector.
When i am using native java serialization for stream cloud all works fine, but when i change serialization to json, MessageCollector returns me GenericMessage with string payload instead of SomeObject payload.
Configuration is
cloud.stream.default.contentType=application/json
Test case:
Message outMsg = new GenericMessage<SomeObject>(new SomeObject(1));
someChannel.send(outMsg);
GenericMessage<SomeObject> inMsg = (GenericMessage<SomeObject>) messageCollector.forChannel(someChannel).poll();
Assert.assertTrue(inMsg.getPayload() instanceof SomeObject);
As a result Assertions is false. inMsg contains string payload (the string contains valid json representation of SomeObject).
And my question is: How can i receive GenericMessage with SomeObject payload from MessageCollector?
production environment works fine without explicitly mapping to SomeObject.