当前位置: 首页>>代码示例>>Java>>正文


Java XPathExpression.evaluateExpression方法代码示例

本文整理汇总了Java中javax.xml.xpath.XPathExpression.evaluateExpression方法的典型用法代码示例。如果您正苦于以下问题:Java XPathExpression.evaluateExpression方法的具体用法?Java XPathExpression.evaluateExpression怎么用?Java XPathExpression.evaluateExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.xpath.XPathExpression的用法示例。


在下文中一共展示了XPathExpression.evaluateExpression方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test05

import javax.xml.xpath.XPathExpression; //导入方法依赖的package包/类
@Test(dataProvider = "document")
public void test05(XPath xpath, Document doc) throws XPathExpressionException {
    XPathExpression exp = xpath.compile("count(/Customers/Customer)");
    double result1 = exp.evaluateExpression(doc, Double.class);
    assertTrue(result1 == 3.0);

    int result2 = exp.evaluateExpression(doc, Integer.class);
    assertTrue(result2 == 3);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:XPathExpAnyTypeTest.java

示例2: test07

import javax.xml.xpath.XPathExpression; //导入方法依赖的package包/类
@Test(dataProvider = "document")
public void test07(XPath xpath, Document doc) throws XPathExpressionException {
    XPathExpression exp = xpath.compile("/Customers/Customer");
    XPathNodes nodes = exp.evaluateExpression(doc, XPathNodes.class);
    assertTrue(nodes.size() == 3);
    for (Node n : nodes) {
        assertEquals(n.getLocalName(), "Customer");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:XPathExpAnyTypeTest.java

示例3: test02

import javax.xml.xpath.XPathExpression; //导入方法依赖的package包/类
@Test(dataProvider = "xpath", expectedExceptions = NullPointerException.class)
public void test02(XPath xpath) throws XPathExpressionException {
    XPathExpression exp = xpath.compile("1+1");
    double result = exp.evaluateExpression((Object)null, null);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:XPathExpAnyTypeTest.java

示例4: test03

import javax.xml.xpath.XPathExpression; //导入方法依赖的package包/类
@Test(dataProvider = "xpath")
public void test03(XPath xpath) throws XPathExpressionException {
    XPathExpression exp = xpath.compile("1+1");
    int result = exp.evaluateExpression((Object)null, Integer.class);
    assertTrue(result == 2);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:XPathExpAnyTypeTest.java

示例5: test04

import javax.xml.xpath.XPathExpression; //导入方法依赖的package包/类
@Test(dataProvider = "document")
public void test04(XPath xpath, Document doc) throws XPathExpressionException {
    XPathExpression exp = xpath.compile("boolean(/Customers/Customer[@id=3])");
    boolean result1 = exp.evaluateExpression(doc, Boolean.class);
    assertTrue(result1);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:XPathExpAnyTypeTest.java

示例6: test06

import javax.xml.xpath.XPathExpression; //导入方法依赖的package包/类
@Test(dataProvider = "document")
public void test06(XPath xpath, Document doc) throws XPathExpressionException {
    XPathExpression exp = xpath.compile("string(/Customers/Customer[@id=3]/Phone/text())");
    String result1 = exp.evaluateExpression(doc, String.class);
    assertTrue(result1.equals("3333333333"));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:XPathExpAnyTypeTest.java

示例7: test08

import javax.xml.xpath.XPathExpression; //导入方法依赖的package包/类
@Test(dataProvider = "document")
public void test08(XPath xpath, Document doc) throws XPathExpressionException {
    XPathExpression exp = xpath.compile("/Customers/Customer[@id=3]");
    Node n = exp.evaluateExpression(doc, Node.class);
    assertEquals(n.getLocalName(), "Customer");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:XPathExpAnyTypeTest.java

示例8: test09

import javax.xml.xpath.XPathExpression; //导入方法依赖的package包/类
@Test(dataProvider = "document", expectedExceptions = IllegalArgumentException.class)
public void test09(XPath xpath, Document doc) throws XPathExpressionException {
    XPathExpression exp = xpath.compile("/Customers/Customer[@id=3]");
    File n = exp.evaluateExpression(doc, File.class);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:XPathExpAnyTypeTest.java

示例9: test10

import javax.xml.xpath.XPathExpression; //导入方法依赖的package包/类
@Test(dataProvider = "document")
public void test10(XPath xpath, Document doc) throws XPathExpressionException {
    XPathExpression exp = xpath.compile("boolean(/Customers/Customer[@id=3])");
    XPathEvaluationResult<?> result = exp.evaluateExpression(doc);
    verifyResult(result, true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:XPathExpAnyTypeTest.java

示例10: test11

import javax.xml.xpath.XPathExpression; //导入方法依赖的package包/类
@Test(dataProvider = "document")
public void test11(XPath xpath, Document doc) throws XPathExpressionException {
    XPathExpression exp = xpath.compile("count(/Customers/Customer)");
    XPathEvaluationResult<?> result = exp.evaluateExpression(doc);
    verifyResult(result, 3.0);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:XPathExpAnyTypeTest.java

示例11: test12

import javax.xml.xpath.XPathExpression; //导入方法依赖的package包/类
@Test(dataProvider = "document")
public void test12(XPath xpath, Document doc) throws XPathExpressionException {
    XPathExpression exp = xpath.compile("string(/Customers/Customer[@id=3]/Phone/text())");
    XPathEvaluationResult<?> result = exp.evaluateExpression(doc, XPathEvaluationResult.class);
    verifyResult(result, "3333333333");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:XPathExpAnyTypeTest.java

示例12: test13

import javax.xml.xpath.XPathExpression; //导入方法依赖的package包/类
@Test(dataProvider = "document")
public void test13(XPath xpath, Document doc) throws XPathExpressionException {
    XPathExpression exp = xpath.compile("/Customers/Customer");
    XPathEvaluationResult<?> result = exp.evaluateExpression(doc);
    verifyResult(result, "Customer");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:XPathExpAnyTypeTest.java

示例13: test14

import javax.xml.xpath.XPathExpression; //导入方法依赖的package包/类
@Test(dataProvider = "document")
public void test14(XPath xpath, Document doc) throws XPathExpressionException {
    XPathExpression exp = xpath.compile("/Customers/Customer[@id=3]");
    XPathEvaluationResult<?> result = exp.evaluateExpression(doc);
    verifyResult(result, "Customer");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:XPathExpAnyTypeTest.java


注:本文中的javax.xml.xpath.XPathExpression.evaluateExpression方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。