diff --git a/src/test/java/org/apache/ibatis/parsing/XPathParserTest.java b/src/test/java/org/apache/ibatis/parsing/XPathParserTest.java
index c9771b5add9..336a82a4a2f 100644
--- a/src/test/java/org/apache/ibatis/parsing/XPathParserTest.java
+++ b/src/test/java/org/apache/ibatis/parsing/XPathParserTest.java
@@ -179,14 +179,31 @@ private String getXmlString(String resource) throws IOException {
}
}
+ enum EnumTest {
+ YES, NO
+ }
+
private void testEvalMethod(XPathParser parser) {
assertEquals((Long) 1970L, parser.evalLong("/employee/birth_date/year"));
+ assertEquals((Long) 1970L, parser.evalNode("/employee/birth_date/year").getLongBody());
assertEquals((short) 6, (short) parser.evalShort("/employee/birth_date/month"));
assertEquals((Integer) 15, parser.evalInteger("/employee/birth_date/day"));
+ assertEquals((Integer) 15, parser.evalNode("/employee/birth_date/day").getIntBody());
assertEquals((Float) 5.8f, parser.evalFloat("/employee/height"));
+ assertEquals((Float) 5.8f, parser.evalNode("/employee/height").getFloatBody());
assertEquals((Double) 5.8d, parser.evalDouble("/employee/height"));
+ assertEquals((Double) 5.8d, parser.evalNode("/employee/height").getDoubleBody());
+ assertEquals((Double) 5.8d, parser.evalNode("/employee").evalDouble("height"));
assertEquals("${id_var}", parser.evalString("/employee/@id"));
+ assertEquals("${id_var}", parser.evalNode("/employee/@id").getStringBody());
+ assertEquals("${id_var}", parser.evalNode("/employee").evalString("@id"));
assertEquals(Boolean.TRUE, parser.evalBoolean("/employee/active"));
+ assertEquals(Boolean.TRUE, parser.evalNode("/employee/active").getBooleanBody());
+ assertEquals(Boolean.TRUE, parser.evalNode("/employee").evalBoolean("active"));
+ assertEquals(EnumTest.YES, parser.evalNode("/employee/active").getEnumAttribute(EnumTest.class, "bot"));
+ assertEquals((Float) 3.2f, parser.evalNode("/employee/active").getFloatAttribute("score"));
+ assertEquals((Double) 3.2d, parser.evalNode("/employee/active").getDoubleAttribute("score"));
+
assertEquals("${id_var}", parser.evalNode("/employee/@id").toString().trim());
assertEquals(7, parser.evalNodes("/employee/*").size());
XNode node = parser.evalNode("/employee/height");
@@ -196,7 +213,7 @@ private void testEvalMethod(XPathParser parser) {
@Test
void formatXNodeToString() {
- XPathParser parser = new XPathParser("100Tom30BMWAudiBenz");
+ XPathParser parser = new XPathParser("100Tom30BMWAudiBenz");
String usersNodeToString = parser.evalNode("/users").toString();
String userNodeToString = parser.evalNode("/users/user").toString();
String carsNodeToString = parser.evalNode("/users/user/cars").toString();
@@ -208,9 +225,9 @@ void formatXNodeToString() {
" Tom\n" +
" 30\n" +
" \n" +
- " BMW\n" +
- " Audi\n" +
- " Benz\n" +
+ " BMW\n" +
+ " Audi\n" +
+ " Benz\n" +
" \n" +
" \n" +
"\n";
@@ -221,17 +238,17 @@ void formatXNodeToString() {
" Tom\n" +
" 30\n" +
" \n" +
- " BMW\n" +
- " Audi\n" +
- " Benz\n" +
+ " BMW\n" +
+ " Audi\n" +
+ " Benz\n" +
" \n" +
"\n";
String carsNodeToStringExpect =
"\n" +
- " BMW\n" +
- " Audi\n" +
- " Benz\n" +
+ " BMW\n" +
+ " Audi\n" +
+ " Benz\n" +
"\n";
assertEquals(usersNodeToStringExpect, usersNodeToString);
diff --git a/src/test/java/resources/nodelet_test.xml b/src/test/java/resources/nodelet_test.xml
index 5a1a7272b66..2c1b444a1df 100644
--- a/src/test/java/resources/nodelet_test.xml
+++ b/src/test/java/resources/nodelet_test.xml
@@ -1,6 +1,6 @@