クラス XpathExpectationsHelper
java.lang.ObjectSE
org.springframework.test.util.XpathExpectationsHelper
XPath 式を介してアサーションを適用するためのヘルパークラス。
- 導入:
- 3.2
- 作成者:
- Rossen Stoyanchev
コンストラクターの概要
コンストラクターメソッドのサマリー
修飾子と型メソッド説明void
assertBoolean
(byte[] content, StringSE encoding, boolean expectedValue) XPath 式を適用し、結果のコンテンツをブール値としてアサートします。void
assertNode
(byte[] content, StringSE encoding, Matcher<? super NodeSE> matcher) コンテンツを解析し、XPath 式をNode
SE として評価し、指定されたMatcher<Node>
でそれをアサートします。void
assertNodeCount
(byte[] content, StringSE encoding, int expectedCount) XPath 式を適用し、結果のコンテンツを整数としてアサートします。void
assertNodeCount
(byte[] content, StringSE encoding, Matcher<? super IntegerSE> matcher) XPath 式を適用し、結果のコンテンツを特定の Hamcrest マッチャーでアサートします。void
assertNodeList
(byte[] content, StringSE encoding, Matcher<? super NodeListSE> matcher) コンテンツを解析し、XPath 式をNodeList
SE として評価し、指定されたMatcher<NodeList>
でそれをアサートします。void
assertNumber
(byte[] content, StringSE encoding, DoubleSE expectedValue) XPath 式を適用し、結果のコンテンツを Double としてアサートします。void
assertNumber
(byte[] content, StringSE encoding, Matcher<? super DoubleSE> matcher) XPath 式を適用し、結果のコンテンツを特定の Hamcrest マッチャーでアサートします。void
assertString
(byte[] content, StringSE encoding, StringSE expectedValue) XPath 式を適用し、結果のコンテンツを文字列としてアサートします。void
assertString
(byte[] content, StringSE encoding, Matcher<? super StringSE> matcher) XPath 式を適用し、結果のコンテンツを特定の Hamcrest マッチャーでアサートします。void
doesNotExist
(byte[] content, StringSE encoding) XPath 式を適用し、結果のコンテンツが存在しないことを表明します。<T> T
evaluateXpath
(byte[] content, StringSE encoding, ClassSE<T> targetClass) XPath を評価し、結果の値を返します。protected <T> T
evaluateXpath
(DocumentSE document, QNameSE evaluationType, ClassSE<T> expectedClass) 指定されたドキュメントに XPath 式を適用します。void
XPath 式を適用し、結果のコンテンツが存在することをアサートします。protected XPathExpressionSE
コンパイルされた XPath 式を返します。protected DocumentSE
parseXmlByteArray
(byte[] xml, StringSE encoding) 指定された XML コンテンツをDocument
SE に解析します。
コンストラクターの詳細
XpathExpectationsHelper
public XpathExpectationsHelper(StringSE expression, @Nullable MapSE<StringSE, StringSE> namespaces, ObjectSE... args) throws XPathExpressionExceptionSEXpathExpectationsHelper コンストラクター。- パラメーター:
expression
- XPath 式namespaces
- XPath 式で参照される XML 名前空間、またはnull
args
-String.format(String, Object...)
SE で定義されたフォーマット指定子を使用して XPath 式をパラメーター化する引数- 例外:
XPathExpressionExceptionSE
- 式のコンパイルが失敗した場合
メソッドの詳細
getXpathExpression
コンパイルされた XPath 式を返します。assertNode
public void assertNode(byte[] content, @Nullable StringSE encoding, Matcher<? super NodeSE> matcher) throws ExceptionSE コンテンツを解析し、XPath 式をNode
SE として評価し、指定されたMatcher<Node>
でそれをアサートします。- 例外:
ExceptionSE
assertNodeList
public void assertNodeList(byte[] content, @Nullable StringSE encoding, Matcher<? super NodeListSE> matcher) throws ExceptionSE コンテンツを解析し、XPath 式をNodeList
SE として評価し、指定されたMatcher<NodeList>
でそれをアサートします。- 例外:
ExceptionSE
- 導入:
- 5.2.2
exists
XPath 式を適用し、結果のコンテンツが存在することをアサートします。- 例外:
ExceptionSE
- コンテンツの解析または式の評価が失敗した場合
doesNotExist
XPath 式を適用し、結果のコンテンツが存在しないことを表明します。- 例外:
ExceptionSE
- コンテンツの解析または式の評価が失敗した場合
assertNodeCount
public void assertNodeCount(byte[] content, @Nullable StringSE encoding, Matcher<? super IntegerSE> matcher) throws ExceptionSE XPath 式を適用し、結果のコンテンツを特定の Hamcrest マッチャーでアサートします。- 例外:
ExceptionSE
- コンテンツの解析または式の評価が失敗した場合
assertNodeCount
public void assertNodeCount(byte[] content, @Nullable StringSE encoding, int expectedCount) throws ExceptionSE XPath 式を適用し、結果のコンテンツを整数としてアサートします。- 例外:
ExceptionSE
- コンテンツの解析または式の評価が失敗した場合
assertString
public void assertString(byte[] content, @Nullable StringSE encoding, Matcher<? super StringSE> matcher) throws ExceptionSE XPath 式を適用し、結果のコンテンツを特定の Hamcrest マッチャーでアサートします。- 例外:
ExceptionSE
- コンテンツの解析または式の評価が失敗した場合
assertString
public void assertString(byte[] content, @Nullable StringSE encoding, StringSE expectedValue) throws ExceptionSE XPath 式を適用し、結果のコンテンツを文字列としてアサートします。- 例外:
ExceptionSE
- コンテンツの解析または式の評価が失敗した場合
assertNumber
public void assertNumber(byte[] content, @Nullable StringSE encoding, Matcher<? super DoubleSE> matcher) throws ExceptionSE XPath 式を適用し、結果のコンテンツを特定の Hamcrest マッチャーでアサートします。- 例外:
ExceptionSE
- コンテンツの解析または式の評価が失敗した場合
assertNumber
public void assertNumber(byte[] content, @Nullable StringSE encoding, DoubleSE expectedValue) throws ExceptionSE XPath 式を適用し、結果のコンテンツを Double としてアサートします。- 例外:
ExceptionSE
- コンテンツの解析または式の評価が失敗した場合
assertBoolean
public void assertBoolean(byte[] content, @Nullable StringSE encoding, boolean expectedValue) throws ExceptionSE XPath 式を適用し、結果のコンテンツをブール値としてアサートします。- 例外:
ExceptionSE
- コンテンツの解析または式の評価が失敗した場合
evaluateXpath
@Nullable public <T> T evaluateXpath(byte[] content, @Nullable StringSE encoding, ClassSE<T> targetClass) throws ExceptionSE XPath を評価し、結果の値を返します。- パラメーター:
content
- 評価するコンテンツencoding
- 使用するエンコーディング (必要に応じて)targetClass
- ターゲットクラス。Number、String、Boolean、org.w3c.Node、NodeList のいずれか- 例外:
ExceptionSE
- コンテンツの解析または式の評価が失敗した場合- 導入:
- 5.1
parseXmlByteArray
指定された XML コンテンツをDocument
SE に解析します。- パラメーター:
xml
- 解析するコンテンツencoding
- メタデータとして提供される場合、オプションのコンテンツエンコーディング (たとえば HTTP ヘッダー)- 戻り値:
- 解析されたドキュメント
- 例外:
ExceptionSE
evaluateXpath
@Nullable protected <T> T evaluateXpath(DocumentSE document, QNameSE evaluationType, ClassSE<T> expectedClass) throws XPathExpressionExceptionSE 指定されたドキュメントに XPath 式を適用します。- 例外:
XPathExpressionExceptionSE
- 式の評価が失敗した場合