PropertyFilter { static void filterProperties(Message message, Set<String> namesToClear) { ArrayList<Object> retainedProperties = messagePropertiesBuffer(); try { filterProperties(message, namesToClear, retainedProperties); } finally { retainedProperties.clear(); } }    }
@Test public void filterProperties_message_empty() { TextMessage message = new ActiveMQTextMessage(); PropertyFilter.filterProperties(message, Collections.singleton("b3")); }
@Test public void filterProperties_message_allTypes() throws JMSException { TextMessage message = newMessageWithAllTypes(); message.setStringProperty("b3", "00f067aa0ba902b7-00f067aa0ba902b7-1"); PropertyFilter.filterProperties(message, Collections.singleton("b3")); assertThat(message).isEqualToIgnoringGivenFields(newMessageWithAllTypes(), "processAsExpired"); }
@Test public void filterProperties_message_handlesOnSetException() throws JMSException { Message message = mock(Message.class); when(message.getPropertyNames()).thenReturn( Collections.enumeration(Collections.singletonList("JMS_SQS_DeduplicationId"))); when(message.getObjectProperty("JMS_SQS_DeduplicationId")).thenReturn(""); doThrow(new IllegalArgumentException()).when(message).setObjectProperty(anyString(), eq("")); assertThatCode(() -> PropertyFilter.filterProperties(message, Collections.singleton("b3"))).doesNotThrowAnyException(); }
@Test public void filterProperties_message_passesFatalOnSetException() throws JMSException { Message message = mock(Message.class); when(message.getPropertyNames()).thenReturn( Collections.enumeration(Collections.singletonList("JMS_SQS_DeduplicationId"))); when(message.getObjectProperty("JMS_SQS_DeduplicationId")).thenReturn(""); doThrow(new LinkageError()).when(message).setObjectProperty(anyString(), eq("")); assertThatThrownBy( () -> PropertyFilter.filterProperties(message, Collections.singleton("b3"))).isInstanceOf( LinkageError.class); }