MessageProperties { @Nullable static String getPropertyIfString(Message message, String name) { try { Object o = message.getObjectProperty(name); if (o instanceof String) return o.toString(); return null; } catch (Throwable t) { propagateIfFatal(t); log(t, "error getting property {0} from message {1}", name, message); return null; } }    }
@Test public void getPropertyIfString() throws Exception { message.setStringProperty("b3", "1"); assertThat(MessageProperties.getPropertyIfString(message, "b3")) .isEqualTo("1"); }
@Test public void getPropertyIfString_notString() throws Exception { message.setByteProperty("b3", (byte) 0); assertThat(MessageProperties.getPropertyIfString(message, "b3")) .isNull(); }
@Test public void getPropertyIfString_null() { assertThat(MessageProperties.getPropertyIfString(message, "b3")).isNull(); }