This commit is contained in:
Looly 2020-07-18 08:25:24 +08:00
parent 41bbd86a14
commit 9157fa332b

View File

@ -159,7 +159,7 @@ public class XmlUtilTest {
} }
@Test @Test
public void getByPathTest(){ public void getByPathTest() {
String xmlStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + String xmlStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" + "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
" <soap:Body>\n" + " <soap:Body>\n" +
@ -172,12 +172,12 @@ public class XmlUtilTest {
Document document = XmlUtil.readXML(xmlStr); Document document = XmlUtil.readXML(xmlStr);
Object value = XmlUtil.getByXPath( Object value = XmlUtil.getByXPath(
"//soap:Envelope/soap:Body/ns2:testResponse/return", "//soap:Envelope/soap:Body/ns2:testResponse/return",
document,XPathConstants.STRING);// document, XPathConstants.STRING);//
Assert.assertEquals("2020/04/15 21:01:21", value); Assert.assertEquals("2020/04/15 21:01:21", value);
} }
@Test @Test
public void xmlToBeanTest(){ public void xmlToBeanTest() {
final TestBean testBean = new TestBean(); final TestBean testBean = new TestBean();
testBean.setReqCode("1111"); testBean.setReqCode("1111");
testBean.setAccountName("账户名称"); testBean.setAccountName("账户名称");
@ -197,7 +197,7 @@ public class XmlUtilTest {
} }
@Data @Data
public static class TestBean{ public static class TestBean {
private String ReqCode; private String ReqCode;
private String AccountName; private String AccountName;
private String Operator; private String Operator;