public void testBuild() { WxXmlOutVoiceMessage m = WxXmlOutMessage.VOICE().mediaId("ddfefesfsdfef").fromUser("from").touser("to").build(); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<xml>" + "<ToUserName><![CDATA[to]]></ToUserName>" + "<FromUserName><![CDATA[from]]></FromUserName>" + "<CreateTime>1122</CreateTime>" + "<MsgType><![CDATA[voice]]></MsgType>" + "<Voice><MediaId><![CDATA[ddfefesfsdfef]]></MediaId></Voice>" + "</xml>"; System.out.println(m.toXml()); Assert.assertEquals( m.toXml().replaceAll("\\s", "").replaceAll("<CreateTime>.*?</CreateTime>", ""), expected.replaceAll("\\s", "").replaceAll("<CreateTime>.*?</CreateTime>", "")); }
public void testBuild() { WxXmlOutTextMessage m = WxXmlOutMessage.TEXT().content("content").fromUser("from").touser("to").build(); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<xml>" + "<ToUserName><![CDATA[to]]></ToUserName>" + "<FromUserName><![CDATA[from]]></FromUserName>" + "<CreateTime>1122</CreateTime>" + "<MsgType><![CDATA[text]]></MsgType>" + "<Content><![CDATA[content]]></Content>" + "</xml>"; System.out.println(m.toXml()); Assert.assertEquals( m.toXml().replaceAll("\\s", "").replaceAll("<CreateTime>.*?</CreateTime>", ""), expected.replaceAll("\\s", "").replaceAll("<CreateTime>.*?</CreateTime>", "")); }