blob: 6cd34c02f675553d61b8893014a969aaa323a228 [file] [log] [blame]
<?xml version="1.0"?>
<!--
Copyright 2002,2004 The Apache Software Foundation.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<test:suite
xmlns:html="jelly:html"
xmlns:j="jelly:core"
xmlns:x="jelly:xml"
xmlns:test="jelly:junit">
<test:case name="testSimpleParse">
<html:parse var="doc" html="index.html"/>
<test:assert xpath="$doc/html/head/title"/>
<test:assert xpath="$doc/html/body/IMG[@URI='foo']"/>
</test:case>
<test:case name="testUpperCase">
<html:parse var="doc" html="index.html" element="upper" attribute="upper"/>
<test:assert xpath="$doc/HTML/HEAD/TITLE"/>
<test:assert xpath="$doc/HTML/BODY/IMG[@URI='foo']"/>
</test:case>
<test:case name="testLowerCase">
<html:parse var="doc" html="index.html" element="lower" attribute="lower"/>
<test:assert xpath="$doc/html/head/title"/>
<test:assert xpath="$doc/html/body/img[@uri='foo']"/>
</test:case>
<test:case name="testMixedCase">
<html:parse var="doc" html="index.html" element="upper" attribute="lower"/>
<test:assert xpath="$doc/HTML/HEAD/TITLE"/>
<test:assert xpath="$doc/HTML/BODY/IMG[@uri='foo']"/>
</test:case>
<test:case name="testInlineHtml">
<html:parse var="doc">
<html>
<head>
<title>Jelly - Jelly : Java and XML based processing engine</title>
<meta name="author" value="James Strachan"/>
<meta name="email" value="jstrachan@apache.org" />
</head>
<body>
</body>
</html>
</html:parse>
<test:assert xpath="$doc/html/head/title"/>
<j:set var="title"><x:expr select="$doc/html/head/title" /></j:set>
<test:assertEquals expected="Jelly - Jelly : Java and XML based processing engine"
actual="${title}" />
</test:case>
<test:case name="testInlineFromVar">
<!-- this will turn the HTML markup from XML events into text -->
<j:set var="html" encode="false">
<html>
<head>
<title>Jelly - Jelly : Java and XML based processing engine</title>
<meta name="author" value="James Strachan"/>
<meta name="email" value="jstrachan@apache.org" />
</head>
<body>
</body>
</html>
</j:set>
<!-- parse the text as markup -->
<html:parse var="doc" text="${html}"/>
<test:assert xpath="$doc/html/head/title"/>
<j:set var="title"><x:expr select="$doc/html/head/title" /></j:set>
<test:assertEquals
expected="Jelly - Jelly : Java and XML based processing engine"
actual="${title}" />
</test:case>
</test:suite>