Tabnine Logo
HasXPath.hasXPath
Code IndexAdd Tabnine to your IDE (free)

How to use
hasXPath
method
in
org.hamcrest.xml.HasXPath

Best Java code snippets using org.hamcrest.xml.HasXPath.hasXPath (Showing top 20 results out of 315)

origin: org.hamcrest/hamcrest-all

/**
 * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node contains a node
 * at the specified <code>xPath</code>, with any content.
 * <p/>
 * For example:
 * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese"))</pre>
 * 
 * @param xPath
 *     the target xpath
 */
public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath) {
 return org.hamcrest.xml.HasXPath.hasXPath(xPath);
}
origin: org.hamcrest/hamcrest-all

/**
 * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node contains a node
 * at the specified <code>xPath</code> within the specified namespace context, with any content.
 * <p/>
 * For example:
 * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese", myNs))</pre>
 * 
 * @param xPath
 *     the target xpath
 * @param namespaceContext
 *     the namespace for matching nodes
 */
public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath, javax.xml.namespace.NamespaceContext namespaceContext) {
 return org.hamcrest.xml.HasXPath.hasXPath(xPath, namespaceContext);
}
origin: org.hamcrest/hamcrest-all

/**
 * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node has a value at the
 * specified <code>xPath</code> that satisfies the specified <code>valueMatcher</code>.
 * <p/>
 * For example:
 * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese", equalTo("Cheddar")))</pre>
 * 
 * @param xPath
 *     the target xpath
 * @param valueMatcher
 *     matcher for the value at the specified xpath
 */
public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath, org.hamcrest.Matcher<java.lang.String> valueMatcher) {
 return org.hamcrest.xml.HasXPath.hasXPath(xPath, valueMatcher);
}
origin: hamcrest/JavaHamcrest

/**
 * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node contains a node
 * at the specified <code>xPath</code>, with any content.
 * For example:
 * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese"))</pre>
 * 
 * @param xPath
 *     the target xpath
 */
public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath) {
 return org.hamcrest.xml.HasXPath.hasXPath(xPath);
}
origin: hamcrest/JavaHamcrest

/**
 * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node contains a node
 * at the specified <code>xPath</code>, with any content.
 * For example:
 * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese"))</pre>
 * 
 * @param xPath
 *     the target xpath
 */
public static Matcher<Node> hasXPath(String xPath) {
  return hasXPath(xPath, NO_NAMESPACE_CONTEXT);
}
origin: org.hamcrest/hamcrest-all

/**
 * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node has a value at the
 * specified <code>xPath</code>, within the specified <code>namespaceContext</code>, that satisfies
 * the specified <code>valueMatcher</code>.
 * <p/>
 * For example:
 * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese", myNs, equalTo("Cheddar")))</pre>
 * 
 * @param xPath
 *     the target xpath
 * @param namespaceContext
 *     the namespace for matching nodes
 * @param valueMatcher
 *     matcher for the value at the specified xpath
 */
public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath, javax.xml.namespace.NamespaceContext namespaceContext, org.hamcrest.Matcher<java.lang.String> valueMatcher) {
 return org.hamcrest.xml.HasXPath.hasXPath(xPath, namespaceContext, valueMatcher);
}
origin: hamcrest/JavaHamcrest

/**
 * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node has a value at the
 * specified <code>xPath</code> that satisfies the specified <code>valueMatcher</code>.
 * For example:
 * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese", equalTo("Cheddar")))</pre>
 * 
 * @param xPath
 *     the target xpath
 * @param valueMatcher
 *     matcher for the value at the specified xpath
 */
public static Matcher<Node> hasXPath(String xPath, Matcher<String> valueMatcher) {
  return hasXPath(xPath, NO_NAMESPACE_CONTEXT, valueMatcher);
}
origin: org.hamcrest/hamcrest-all

/**
 * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node contains a node
 * at the specified <code>xPath</code>, with any content.
 * <p/>
 * For example:
 * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese"))</pre>
 * 
 * @param xPath
 *     the target xpath
 */
@Factory
public static Matcher<Node> hasXPath(String xPath) {
  return hasXPath(xPath, NO_NAMESPACE_CONTEXT);
}
origin: org.hamcrest/hamcrest-all

/**
 * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node has a value at the
 * specified <code>xPath</code> that satisfies the specified <code>valueMatcher</code>.
 * <p/>
 * For example:
 * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese", equalTo("Cheddar")))</pre>
 * 
 * @param xPath
 *     the target xpath
 * @param valueMatcher
 *     matcher for the value at the specified xpath
 */
@Factory
public static Matcher<Node> hasXPath(String xPath, Matcher<String> valueMatcher) {
  return hasXPath(xPath, NO_NAMESPACE_CONTEXT, valueMatcher);
}
origin: hamcrest/JavaHamcrest

@Test public void
matchesWithNamespace() {
  assertMatches(hasXPath("//cheese:foreignSomething", ns), xml);
  assertMatches(hasXPath("//cheese:foreignSomething/@milk", ns, equalTo("camel")), xml);
  assertMatches(hasXPath("//cheese:foreignSomething/text()", ns, equalTo("Caravane")), xml);
}
origin: hamcrest/JavaHamcrest

@Test public void
failsIfNodeIsMissingInNamespace() {
  assertDoesNotMatch(hasXPath("//cheese:foreignSomething", equalTo("Badger")), xml);
  assertDoesNotMatch(hasXPath("//cheese:foreignSomething"), xml);
}
origin: hamcrest/JavaHamcrest

@Test public void
describesItself() {
  assertDescription("an XML document with XPath /some/path \"Cheddar\"",
           hasXPath("/some/path", equalTo("Cheddar")));
  
  assertDescription("an XML document with XPath /some/path",
           hasXPath("/some/path"));
}
origin: hamcrest/JavaHamcrest

@Test public void
failsIfNodeIsMissing() {
  assertDoesNotMatch(hasXPath("/root/something[3]/cheese", ns, equalTo("Cheddar")), xml);
  assertDoesNotMatch(hasXPath("//something[@id='c']/cheese", ns), xml);
}
origin: hamcrest/JavaHamcrest

@Test public void
appliesMatcherToXPathInDocument() {
  assertMatches(hasXPath("/root/something[2]/cheese", equalTo("Cheddar")), xml);
  assertMatches(hasXPath("//something[1]/cheese", containsString("dam")), xml);
  assertMatches(hasXPath("//something[2]/cheese", not(containsString("dam"))), xml);
  assertMatches(hasXPath("/root/@type", equalTo("food")), xml);
  assertMatches(hasXPath("//something[@id='b']/cheese", equalTo("Cheddar")), xml);
  assertMatches(hasXPath("//something[@id='b']/cheese"), xml);
}
origin: hamcrest/JavaHamcrest

@Test public void
throwsIllegalArgumentExceptionIfGivenIllegalExpression() {
  try {
    hasXPath("\\g:dfgd::DSgf/root/something[2]/cheese", equalTo("blah"));
    fail("Expected exception");
  } catch (IllegalArgumentException expectedException) {
    // expected exception
  }
}
origin: hamcrest/JavaHamcrest

@Test public void
describesIncorrectNodeValueMismatch() {
  assertMismatchDescription("was \"Edam\"", hasXPath("//something[1]/cheese", equalTo("parmesan")), xml);
}
origin: hamcrest/JavaHamcrest

@Test public void
matchesEmptyElementInNamespace() {
  assertMatches(hasXPath("//cheese:emptySomething", ns), xml);
}
origin: hamcrest/JavaHamcrest

@Test public void
describesMissingNodeMismatch() {
  assertMismatchDescription("xpath returned no results.", hasXPath("//honky"), xml);
}
origin: hamcrest/JavaHamcrest

@Test public void
matchesEmptyElement() {
  assertMatches(hasXPath("//emptySomething"), xml);
}
origin: hamcrest/JavaHamcrest

@Test public void
copesWithNullsAndUnknownTypes() {
  Matcher<Node> matcher = hasXPath("//irrelevant");
  
  assertNullSafe(matcher);
  assertUnknownTypeSafe(matcher);
}
org.hamcrest.xmlHasXPathhasXPath

Javadoc

Creates a matcher of org.w3c.dom.Nodes that matches when the examined node contains a node at the specified xPath, with any content. For example:
assertThat(xml, hasXPath("/root/something[2]/cheese"))

Popular methods of HasXPath

  • <init>
  • compiledXPath
  • evaluated

Popular in Java

  • Parsing JSON documents to java classes using gson
  • scheduleAtFixedRate (ScheduledExecutorService)
  • compareTo (BigDecimal)
  • getApplicationContext (Context)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now