issue #12 xml消息fromXml, toXml有错误

This commit is contained in:
Daniel Qian
2014-08-28 13:30:36 +08:00
parent 7cfbc05acd
commit 997f1e4005
9 changed files with 473 additions and 1 deletions

View File

@@ -0,0 +1,38 @@
package chanjarster.weixin.bean;
import org.testng.Assert;
import org.testng.annotations.Test;
@Test
public class WxXmlOutIMusicMessageTest {
public void test() {
WxXmlOutMusicMessage m = new WxXmlOutMusicMessage();
m.setTitle("title");
m.setDescription("ddfff");
m.setCreateTime(1122l);
m.setFromUserName("fromUser");
m.setToUserName("toUser");
m.setHQMusicUrl("hQMusicUrl");
m.setMusicUrl("musicUrl");
m.setThumbMediaId("thumbMediaId");
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
+ "<xml>"
+ "<ToUserName><![CDATA[toUser]]></ToUserName>"
+ "<FromUserName><![CDATA[fromUser]]></FromUserName>"
+ "<CreateTime>1122</CreateTime>"
+ "<MsgType><![CDATA[music]]></MsgType>"
+ "<Music>"
+ " <Title><![CDATA[title]]></Title>"
+ " <Description><![CDATA[ddfff]]></Description>"
+ " <ThumbMediaId><![CDATA[thumbMediaId]]></ThumbMediaId>"
+ " <MusicUrl><![CDATA[musicUrl]]></MusicUrl>"
+ " <HQMusicUrl><![CDATA[hQMusicUrl]]></HQMusicUrl>"
+ " </Music>"
+ "</xml>";
System.out.println(m.toXml());
Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", ""));
}
}