File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
main/java/com/ibm/eventstreams/connect/mqsource/processor
test/java/com/ibm/eventstreams/connect/mqsource Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,13 @@ public ConnectHeaders convertJmsPropertiesToKafkaHeaders(final Message message)
48
48
49
49
jmsPropertyKeys .forEach (key -> {
50
50
try {
51
- connectHeaders .addString (key .toString (), message .getObjectProperty (key .toString ()).toString ());
51
+ String value = "" ;
52
+ if (message .getObjectProperty (key .toString ()) != null )
53
+ {
54
+ value = message .getObjectProperty (key .toString ()).toString ();
55
+ }
56
+ connectHeaders .addString (key .toString (), value );
57
+ //connectHeaders.addString(key.toString(), message.getObjectProperty(key.toString()).toString());
52
58
} catch (final JMSException e ) {
53
59
// Not failing the message processing if JMS properties cannot be read for some
54
60
// reason.
Original file line number Diff line number Diff line change @@ -44,22 +44,23 @@ public class JmsToKafkaHeaderConverterTest {
44
44
@ Test
45
45
public void convertJmsPropertiesToKafkaHeaders () throws JMSException {
46
46
47
- final List <String > keys = Arrays .asList ("facilityCountryCode" , "facilityNum" );
47
+ final List <String > keys = Arrays .asList ("facilityCountryCode" , "facilityNum" , "nullProperty" );
48
48
49
49
final Enumeration <String > keyEnumeration = Collections .enumeration (keys );
50
50
51
51
// Arrange
52
52
when (message .getPropertyNames ()).thenReturn (keyEnumeration );
53
53
when (message .getObjectProperty ("facilityCountryCode" )).thenReturn ("US" );
54
54
when (message .getObjectProperty ("facilityNum" )).thenReturn ("12345" );
55
+ when (message .getObjectProperty ("nullProperty" )).thenReturn (null );
55
56
56
57
// Act
57
58
final ConnectHeaders actualConnectHeaders = jmsToKafkaHeaderConverter
58
59
.convertJmsPropertiesToKafkaHeaders (message );
59
60
60
61
61
62
//Verify
62
- assertEquals ("Both custom JMS properties were copied to kafka successfully." , 2 , actualConnectHeaders .size ());
63
+ assertEquals ("Both custom JMS properties were copied to kafka successfully." , 3 , actualConnectHeaders .size ());
63
64
64
65
65
66
}
You can’t perform that action at this time.
0 commit comments