@@ -72,7 +72,7 @@ public void testFromXml() {
72
72
assertEquals (wxMessage .getCreateTime (), Long .valueOf (1348831860 ));
73
73
assertEquals (wxMessage .getMsgType (), WxConsts .XmlMsgType .TEXT );
74
74
assertEquals (wxMessage .getContent (), "this is a test" );
75
- assertEquals (wxMessage .getMsgId (), Long . valueOf ( 1234567890123456L ) );
75
+ assertEquals (wxMessage .getMsgId (), "1234567890123456" );
76
76
assertEquals (wxMessage .getPicUrl (), "this is a url" );
77
77
assertEquals (wxMessage .getMediaId (), "media_id" );
78
78
assertEquals (wxMessage .getFormat (), "Format" );
@@ -442,4 +442,33 @@ public void testUploadMediaJobFinishEvent() {
442
442
assertThat (wxCpXmlMessage .getJobId ()).isEqualTo ("jobid_S0MrnndvRG5fadSlLwiBqiDDbM143UqTmKP3152FZk4" );
443
443
assertThat (wxCpXmlMessage .getEvent ()).isEqualTo (UPLOAD_MEDIA_JOB_FINISH );
444
444
}
445
+
446
+ /**
447
+ * Test both numeric and string msgId formats to ensure backward compatibility
448
+ */
449
+ public void testMsgIdStringAndNumericFormats () {
450
+ // Test with numeric msgId (old format)
451
+ String xmlWithNumeric = "<xml>"
452
+ + "<ToUserName><![CDATA[toUser]]></ToUserName>"
453
+ + "<FromUserName><![CDATA[fromUser]]></FromUserName>"
454
+ + "<CreateTime>1348831860</CreateTime>"
455
+ + "<MsgType><![CDATA[text]]></MsgType>"
456
+ + "<Content><![CDATA[this is a test]]></Content>"
457
+ + "<MsgId>1234567890123456</MsgId>"
458
+ + "</xml>" ;
459
+ WxCpXmlMessage wxMessageNumeric = WxCpXmlMessage .fromXml (xmlWithNumeric );
460
+ assertEquals (wxMessageNumeric .getMsgId (), "1234567890123456" );
461
+
462
+ // Test with string msgId (new format - the actual issue case)
463
+ String xmlWithString = "<xml>"
464
+ + "<ToUserName><![CDATA[toUser]]></ToUserName>"
465
+ + "<FromUserName><![CDATA[fromUser]]></FromUserName>"
466
+ + "<CreateTime>1348831860</CreateTime>"
467
+ + "<MsgType><![CDATA[text]]></MsgType>"
468
+ + "<Content><![CDATA[this is a test]]></Content>"
469
+ + "<MsgId>CAIQg/PKxgYY2sC9tpuAgAMg9/zKaw==</MsgId>"
470
+ + "</xml>" ;
471
+ WxCpXmlMessage wxMessageString = WxCpXmlMessage .fromXml (xmlWithString );
472
+ assertEquals (wxMessageString .getMsgId (), "CAIQg/PKxgYY2sC9tpuAgAMg9/zKaw==" );
473
+ }
445
474
}
0 commit comments