wang-jiahua commented on code in PR #10974:
URL: https://github.com/apache/rocketmq/pull/10974#discussion_r3877217177
##########
store/src/test/java/org/apache/rocketmq/store/timer/TimerMessageStoreTest.java:
##########
@@ -179,6 +179,30 @@ private static PutMessageResult
transformTimerMessage(TimerMessageStore timerMes
return null;
}
+ @Test
+ public void testConvertMessagePropertiesStringMatchesProperties() throws
Exception {
+ final TimerMessageStore timerMessageStore =
createTimerMessageStore(null, true);
+
+ MessageExtBrokerInner msgExt = buildMessage(3000,
"TimerTest_testConvertMessage", false);
+ MessageAccessor.putProperty(msgExt, MessageConst.PROPERTY_REAL_TOPIC,
msgExt.getTopic());
+ MessageAccessor.putProperty(msgExt,
MessageConst.PROPERTY_REAL_QUEUE_ID, "0");
+
msgExt.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties()));
+ msgExt.setTopic(TimerMessageStore.TIMER_TOPIC);
+
+ // delivered message: internal properties are cleared from both the
map and the wire data
+ MessageExtBrokerInner delivered =
timerMessageStore.convertMessage(msgExt, false);
+ assertEquals("TimerTest_testConvertMessage", delivered.getTopic());
+
assertFalse(delivered.getPropertiesString().contains(MessageConst.PROPERTY_REAL_TOPIC));
+
assertFalse(delivered.getPropertiesString().contains(MessageConst.PROPERTY_REAL_QUEUE_ID));
+
assertEquals(MessageDecoder.messageProperties2String(delivered.getProperties()),
delivered.getPropertiesString());
+
+ // rolled message: keeps REAL_TOPIC and stays consistent between the
map and the wire data
+ MessageExtBrokerInner rolled =
timerMessageStore.convertMessage(msgExt, true);
+ assertEquals(TimerMessageStore.TIMER_TOPIC, rolled.getTopic());
+
assertTrue(rolled.getPropertiesString().contains(MessageConst.PROPERTY_REAL_TOPIC));
+
assertEquals(MessageDecoder.messageProperties2String(rolled.getProperties()),
rolled.getPropertiesString());
Review Comment:
Added the `PROPERTY_REAL_QUEUE_ID` assertion to the rolled-message branch so
the test covers both retained properties (commit 20b4dc7).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]