2525import com .azure .messaging .servicebus .ServiceBusProcessorClient ;
2626import com .azure .messaging .servicebus .ServiceBusReceivedMessage ;
2727import org .apache .camel .CamelContext ;
28+ import org .apache .camel .Exchange ;
2829import org .apache .camel .ProducerTemplate ;
2930import org .apache .camel .builder .RouteBuilder ;
3031import org .apache .camel .component .azure .servicebus .ServiceBusConstants ;
@@ -47,6 +48,7 @@ public class ServiceBusProducerIT extends BaseServiceBusTestSupport {
4748 private static final String DIRECT_SEND_TO_SESSION_QUEUE_URI = "direct:sendToQueueSessions" ;
4849 private static final Map <String , Object > PROPAGATED_HEADERS = new HashMap <>();
4950 private static final Pattern MESSAGE_BODY_PATTERN = Pattern .compile ("^message-[0-4]$" );
51+ private static final String APPLICATION_JSON_CONTENT_TYPE = "application/json" ;
5052
5153 static {
5254 PROPAGATED_HEADERS .put ("booleanHeader" , true );
@@ -60,6 +62,7 @@ public class ServiceBusProducerIT extends BaseServiceBusTestSupport {
6062 PROPAGATED_HEADERS .put ("stringHeader" , "stringHeader" );
6163 PROPAGATED_HEADERS .put ("timestampHeader" , new Date ());
6264 PROPAGATED_HEADERS .put ("uuidHeader" , UUID .randomUUID ());
65+ PROPAGATED_HEADERS .put (Exchange .CONTENT_TYPE , APPLICATION_JSON_CONTENT_TYPE );
6366 }
6467
6568 private ProducerTemplate producerTemplate ;
@@ -120,6 +123,7 @@ void camelSendsMessageToServiceBusQueue() throws InterruptedException {
120123 assertTrue (MESSAGE_BODY_PATTERN .matcher (messageBody ).matches ());
121124 Map <String , Object > applicationProperties = message .getApplicationProperties ();
122125 assertEquals (PROPAGATED_HEADERS , applicationProperties );
126+ assertEquals (APPLICATION_JSON_CONTENT_TYPE , message .getContentType ());
123127 });
124128 }
125129 }
@@ -148,6 +152,7 @@ void camelSendsMessageBatchToServiceBusQueue() throws InterruptedException {
148152 assertTrue (MESSAGE_BODY_PATTERN .matcher (messageBody ).matches ());
149153 Map <String , Object > applicationProperties = message .getApplicationProperties ();
150154 assertEquals (PROPAGATED_HEADERS , applicationProperties );
155+ assertEquals (APPLICATION_JSON_CONTENT_TYPE , message .getContentType ());
151156 });
152157 }
153158 }
@@ -170,6 +175,7 @@ void camelSendsMessageToServiceBusTopic() throws InterruptedException {
170175 assertTrue (MESSAGE_BODY_PATTERN .matcher (messageBody ).matches ());
171176 Map <String , Object > applicationProperties = message .getApplicationProperties ();
172177 assertEquals (PROPAGATED_HEADERS , applicationProperties );
178+ assertEquals (APPLICATION_JSON_CONTENT_TYPE , message .getContentType ());
173179 });
174180 }
175181 }
@@ -194,6 +200,7 @@ void camelSchedulesServiceBusMessage() throws InterruptedException {
194200 assertTrue (MESSAGE_BODY_PATTERN .matcher (messageBody ).matches ());
195201 Map <String , Object > applicationProperties = message .getApplicationProperties ();
196202 assertEquals (PROPAGATED_HEADERS , applicationProperties );
203+ assertEquals (APPLICATION_JSON_CONTENT_TYPE , message .getContentType ());
197204 assertInstanceOf (OffsetDateTime .class , message .getScheduledEnqueueTime ());
198205 });
199206 }
@@ -225,6 +232,7 @@ void camelSchedulesServiceBusMessageBatch() throws InterruptedException {
225232 assertTrue (MESSAGE_BODY_PATTERN .matcher (messageBody ).matches ());
226233 Map <String , Object > applicationProperties = message .getApplicationProperties ();
227234 assertEquals (PROPAGATED_HEADERS , applicationProperties );
235+ assertEquals (APPLICATION_JSON_CONTENT_TYPE , message .getContentType ());
228236 assertInstanceOf (OffsetDateTime .class , message .getScheduledEnqueueTime ());
229237 });
230238 }
@@ -252,6 +260,7 @@ void camelSendsMessageToServiceBusSessionEnabledQueue() throws InterruptedExcept
252260 assertTrue (MESSAGE_BODY_PATTERN .matcher (messageBody ).matches ());
253261 Map <String , Object > applicationProperties = message .getApplicationProperties ();
254262 assertEquals (PROPAGATED_HEADERS , applicationProperties );
263+ assertEquals (APPLICATION_JSON_CONTENT_TYPE , message .getContentType ());
255264 });
256265 }
257266 }
@@ -280,6 +289,7 @@ void camelSendsMessageBatchToServiceBusSessionEnabledQueue() throws InterruptedE
280289 assertTrue (MESSAGE_BODY_PATTERN .matcher (messageBody ).matches ());
281290 Map <String , Object > applicationProperties = message .getApplicationProperties ();
282291 assertEquals (PROPAGATED_HEADERS , applicationProperties );
292+ assertEquals (APPLICATION_JSON_CONTENT_TYPE , message .getContentType ());
283293 });
284294 }
285295 }
@@ -324,6 +334,7 @@ void camelSchedulesServiceBusMessageWithSessions() throws InterruptedException {
324334 assertTrue (MESSAGE_BODY_PATTERN .matcher (messageBody ).matches ());
325335 Map <String , Object > applicationProperties = message .getApplicationProperties ();
326336 assertEquals (PROPAGATED_HEADERS , applicationProperties );
337+ assertEquals (APPLICATION_JSON_CONTENT_TYPE , message .getContentType ());
327338 assertInstanceOf (OffsetDateTime .class , message .getScheduledEnqueueTime ());
328339 });
329340 }
@@ -355,6 +366,7 @@ void camelSchedulesServiceBusMessageBatchWIthSessions() throws InterruptedExcept
355366 assertTrue (MESSAGE_BODY_PATTERN .matcher (messageBody ).matches ());
356367 Map <String , Object > applicationProperties = message .getApplicationProperties ();
357368 assertEquals (PROPAGATED_HEADERS , applicationProperties );
369+ assertEquals (APPLICATION_JSON_CONTENT_TYPE , message .getContentType ());
358370 assertInstanceOf (OffsetDateTime .class , message .getScheduledEnqueueTime ());
359371 });
360372 }
0 commit comments