gpt4 book ai didi

org.springframework.test.web.servlet.result.XpathResultMatchers.()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 01:15:05 28 4
gpt4 key购买 nike

本文整理了Java中org.springframework.test.web.servlet.result.XpathResultMatchers.<init>()方法的一些代码示例,展示了XpathResultMatchers.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XpathResultMatchers.<init>()方法的具体详情如下:
包路径:org.springframework.test.web.servlet.result.XpathResultMatchers
类名称:XpathResultMatchers
方法名:<init>

XpathResultMatchers.<init>介绍

[英]Protected constructor, not for direct instantiation. Use MockMvcResultMatchers#xpath(String,Object...) or MockMvcResultMatchers#xpath(String,Map,Object...).
[中]受保护的构造函数,不用于直接实例化。使用MockMvcResultMatchers#xpath(字符串、对象…)或MockMvcResultMatchers#xpath(字符串、映射、对象…)。

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Access to response body assertions using an XPath expression to
 * inspect a specific subset of the body.
 * <p>The XPath expression can be a parameterized string using formatting
 * specifiers as defined in {@link String#format(String, Object...)}.
 * @param expression the XPath expression, optionally parameterized with arguments
 * @param args arguments to parameterize the XPath expression with
 */
public static XpathResultMatchers xpath(String expression, Object... args) throws XPathExpressionException {
  return new XpathResultMatchers(expression, null, args);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Access to response body assertions using an XPath expression to
 * inspect a specific subset of the body.
 * <p>The XPath expression can be a parameterized string using formatting
 * specifiers as defined in {@link String#format(String, Object...)}.
 * @param expression the XPath expression, optionally parameterized with arguments
 * @param namespaces namespaces referenced in the XPath expression
 * @param args arguments to parameterize the XPath expression with
 */
public static XpathResultMatchers xpath(String expression, Map<String, String> namespaces, Object... args)
    throws XPathExpressionException {
  return new XpathResultMatchers(expression, namespaces, args);
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void node() throws Exception {
  new XpathResultMatchers("/foo/bar", null).node(Matchers.notNullValue()).match(getStubMvcResult());
}

代码示例来源:origin: spring-projects/spring-framework

@Test(expected = AssertionError.class)
public void nodeNoMatch() throws Exception {
  new XpathResultMatchers("/foo/bar", null).node(Matchers.nullValue()).match(getStubMvcResult());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void doesNotExist() throws Exception {
  new XpathResultMatchers("/foo/Bar", null).doesNotExist().match(getStubMvcResult());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void string() throws Exception {
  new XpathResultMatchers("/foo/bar[1]", null).string("111").match(getStubMvcResult());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void nodeCount() throws Exception {
  new XpathResultMatchers("/foo/bar", null).nodeCount(2).match(getStubMvcResult());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void exists() throws Exception {
  new XpathResultMatchers("/foo/bar", null).exists().match(getStubMvcResult());
}

代码示例来源:origin: spring-projects/spring-framework

@Test(expected = AssertionError.class)
public void nodeCountNoMatch() throws Exception {
  new XpathResultMatchers("/foo/bar", null).nodeCount(1).match(getStubMvcResult());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void number() throws Exception {
  new XpathResultMatchers("/foo/bar[1]", null).number(111.0).match(getStubMvcResult());
}

代码示例来源:origin: spring-projects/spring-framework

@Test(expected = AssertionError.class)
public void doesNotExistNoMatch() throws Exception {
  new XpathResultMatchers("/foo/bar", null).doesNotExist().match(getStubMvcResult());
}

代码示例来源:origin: spring-projects/spring-framework

@Test(expected = AssertionError.class)
public void stringNoMatch() throws Exception {
  new XpathResultMatchers("/foo/bar[1]", null).string("112").match(getStubMvcResult());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void booleanValue() throws Exception {
  new XpathResultMatchers("/foo/bar[2]", null).booleanValue(true).match(getStubMvcResult());
}

代码示例来源:origin: spring-projects/spring-framework

@Test(expected = AssertionError.class)
public void existsNoMatch() throws Exception {
  new XpathResultMatchers("/foo/Bar", null).exists().match(getStubMvcResult());
}

代码示例来源:origin: spring-projects/spring-framework

@Test(expected = AssertionError.class)
public void numberNoMatch() throws Exception {
  new XpathResultMatchers("/foo/bar[1]", null).number(111.1).match(getStubMvcResult());
}

代码示例来源:origin: spring-projects/spring-framework

@Test(expected = AssertionError.class)
public void booleanValueNoMatch() throws Exception {
  new XpathResultMatchers("/foo/bar[2]", null).booleanValue(false).match(getStubMvcResult());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void stringEncodingDetection() throws Exception {
  String content = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
      "<person><name>Jürgen</name></person>";
  byte[] bytes = content.getBytes(StandardCharsets.UTF_8);
  MockHttpServletResponse response = new MockHttpServletResponse();
  response.addHeader("Content-Type", "application/xml");
  StreamUtils.copy(bytes, response.getOutputStream());
  StubMvcResult result = new StubMvcResult(null, null, null, null, null, null, response);
  new XpathResultMatchers("/person/name", null).string("Jürgen").match(result);
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Access to response body assertions using an XPath expression to
 * inspect a specific subset of the body.
 * <p>The XPath expression can be a parameterized string using formatting
 * specifiers as defined in {@link String#format(String, Object...)}.
 * @param expression the XPath expression, optionally parameterized with arguments
 * @param args arguments to parameterize the XPath expression with
 */
public static XpathResultMatchers xpath(String expression, Object... args) throws XPathExpressionException {
  return new XpathResultMatchers(expression, null, args);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-test

/**
 * Access to response body assertions using an XPath expression to
 * inspect a specific subset of the body.
 * <p>The XPath expression can be a parameterized string using formatting
 * specifiers as defined in {@link String#format(String, Object...)}.
 * @param expression the XPath expression, optionally parameterized with arguments
 * @param args arguments to parameterize the XPath expression with
 */
public static XpathResultMatchers xpath(String expression, Object... args) throws XPathExpressionException {
  return new XpathResultMatchers(expression, null, args);
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Access to response body assertions using an XPath expression to
 * inspect a specific subset of the body.
 * <p>The XPath expression can be a parameterized string using formatting
 * specifiers as defined in {@link String#format(String, Object...)}.
 * @param expression the XPath expression, optionally parameterized with arguments
 * @param namespaces namespaces referenced in the XPath expression
 * @param args arguments to parameterize the XPath expression with
 */
public static XpathResultMatchers xpath(String expression, Map<String, String> namespaces, Object... args)
    throws XPathExpressionException {
  return new XpathResultMatchers(expression, namespaces, args);
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com