dion 2004/08/11 23:25:01
Modified: jelly/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml
suite.jelly
Log:
*** keyword substitution change ***
Revision Changes Path
1.8 +283 -283
jakarta-commons/jelly/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/suite.jelly
Index: suite.jelly
===================================================================
RCS file:
/home/cvs/jakarta-commons/jelly/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/suite.jelly,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- suite.jelly 12 Aug 2004 06:24:50 -0000 1.7
+++ suite.jelly 12 Aug 2004 06:25:01 -0000 1.8
@@ -1,283 +1,283 @@
-<?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:j="jelly:core"
- xmlns:x="jelly:xml"
- xmlns:test="jelly:junit">
-
-
- <test:case name="testUriParse">
- <x:parse var="doc" xml="dummy.xml"/>
-
- <test:assert xpath="$doc/dummy/[EMAIL PROTECTED]'2']"/>
- </test:case>
-
- <test:case name="testBodyParse">
-
- <x:parse var="doc">
- <foo>
- <bar a="1"/>
- </foo>
- </x:parse>
-
- <test:assert xpath="$doc/foo/[EMAIL PROTECTED]'1']"/>
- </test:case>
-
- <test:case name="testTextParse">
-
- <j:set var="text" encode="false">
- <foo>
- <bar a="1"/>
- </foo>
- </j:set>
-
- <x:parse var="doc" text="${text}"/>
-
- <test:assert xpath="$doc/foo/[EMAIL PROTECTED]'1']"/>
- </test:case>
-
- <test:case name="testElementAndAttribute">
-
- <x:parse var="doc">
- <x:element name="foo">
- <x:attribute name="x">1234</x:attribute>
-
- <x:element name="bar">
- <x:attribute name="y">ABC</x:attribute>
- hello
- </x:element>
- </x:element>
- </x:parse>
-
- <test:assert xpath="$doc/foo"/>
- <test:assert xpath="$doc/[EMAIL PROTECTED]'1234']"/>
- <test:assert xpath="count($doc/bar) = 0"/>
-
- <!-- test nested element and attributes -->
- <test:assert xpath="$doc/[EMAIL PROTECTED]'1234']/[EMAIL PROTECTED]'ABC']"/>
- <test:assert xpath="$doc/[EMAIL PROTECTED]'1234']/[EMAIL
PROTECTED]'ABC']='hello'"/>
- </test:case>
-
- <test:case name="testBadElementAndAttribute">
-
-
- <j:catch var="ex">
- <x:element name="foo">
- some text
- <x:attribute name="x">1234</x:attribute>
- </x:element>
- </j:catch>
-
-
- <test:assert test="${ex != null}">
- We should have created an exception as some text is output before the
attributes
- </test:assert>
- </test:case>
-
- <test:case name="assertXPathTests">
-
- <x:parse var="doc">
- <foo>
- <bar>cheese</bar>
- </foo>
- </x:parse>
-
-
- <test:assert xpath="$doc/foo/bar">This should never fail</test:assert>
- <test:assert xpath="$doc/foo/bar = 'cheese'">This should never
fail</test:assert>
-
- <j:catch var="ex">
- <test:assert xpath="$doc/foo/xyz">This should always fail</test:assert>
- </j:catch>
-
- <test:assert test="${ex != null}">We should have created an
exception</test:assert>
-
- The exception was: ${ex.message}
- </test:case>
-
- <!-- test the use of namespaces with XPath -->
- <test:case name="assertXPathWithNamespaceTests" xmlns:a="fooURI"
xmlns:z="doesNotMatch" xmlns="different">
-
- <x:parse var="doc">
- <foo xmlns="fooURI">
- <bar>cheese</bar>
- </foo>
- </x:parse>
-
- <test:assert xpath="$doc/a:foo/a:bar">This should never fail</test:assert>
- <test:assert xpath="$doc/b:foo/b:bar" xmlns:b="fooURI">This should never
fail</test:assert>
-
- <j:catch var="ex">
- <test:assert xpath="$doc/z:foo/z:bar">This should always
fail</test:assert>
- </j:catch>
-
- <test:assert test="${ex != null}">We should have created an
exception</test:assert>
-
- <j:catch var="ex">
- <test:assert xpath="$doc/foo/bar">This should always fail, since foo is
not in the empty namespace</test:assert>
- </j:catch>
-
- <test:assert test="${ex != null}">We should have created an
exception</test:assert>
-
- <!--
- || now lets test that the default namespace 'different' is ignored by
the XPath expressions
- || since XPath should ignore the default namespace - you must use a
prefix in XPath to denote
- || a namespace
- -->
- <test:assert xpath="$doc/*[local-name()='foo']"/>
- </test:case>
-
- <!-- test xpath sorting -->
- <test:case name="testXpathSorting">
- <x:parse var="nums">
- <a>
- <b v="3"/>
- <b v="2"/>
- <b v="1"/>
- <b v="11"/>
- <b v="1.4"/>
- <b v="1.2"/>
- </a>
- </x:parse>
-
- <x:parse var="deeper">
- <a>
- <b><c><d>3<e>1</e></d></c></b>
- <b><c><d>2<e>11</e></d></c></b>
- <b><c><d>1</d></c></b>
- <b><c><d>11</d></c></b>
- </a>
- </x:parse>
-
- <!-- test ascending -->
- <j:set var="result" value=""/>
- <x:forEach select="$nums/a/b" var="x" sort="number(@v)">
- <x:set var="num" select="$x/@v"/>
- <j:set var="result" value="${result} ${num.get(0).getText()}"/>
- </x:forEach>
-
- <test:assertEquals expected=" 1 1.2 1.4 2 3 11" actual="${result}"/>
-
- <!-- test descending -->
- <j:set var="result" value=""/>
- <x:forEach select="$nums/a/b" var="x" sort="number(@v)" descending="true">
- <x:set var="num" select="$x/@v"/>
- <j:set var="result" value="${result} ${num.get(0).getText()}"/>
- </x:forEach>
-
- <test:assertEquals expected=" 11 3 2 1.4 1.2 1" actual="${result}"/>
-
- <!-- test deeper nesting -->
- <j:set var="result" value=""/>
- <x:forEach select="$deeper/a/b" var="x" sort="number(c/d/text())">
- <j:set var="result" value="${result} ${x.getStringValue()}"/>
- </x:forEach>
-
- <test:assertEquals expected=" 1 211 31 11" actual="${result}"/>
-
- <!-- test sort as strings -->
- <j:set var="result" value=""/>
- <x:forEach select="$nums/a/b" var="x" sort="@v">
- <x:set var="num" select="$x/@v"/>
- <j:set var="result" value="${result} ${num.get(0).getText()}"/>
- </x:forEach>
-
- <test:assertEquals expected=" 1 1.2 1.4 11 2 3" actual="${result}"/>
-
- <!-- test x:set with sort -->
- <j:set var="result" value=""/>
- <x:set var="rset" select="$nums/a/b" sort="number(@v)"/>
- <j:forEach var="num" items="${rset.iterator()}">
- <j:set var="result" value="${result} ${num.attributeValue('v')}"/>
- </j:forEach>
-
- <test:assertEquals expected=" 1 1.2 1.4 2 3 11" actual="${result}"/>
-
- <!-- test x:set with sort -->
- <j:set var="result" value=""/>
- <x:set var="rset" select="$nums/a/b"/>
- <x:sort list="${rset}" sort="number(@v)"/>
- <j:forEach var="num" items="${rset.iterator()}">
- <j:set var="result" value="${result} ${num.attributeValue('v')}"/>
- </j:forEach>
-
- <test:assertEquals expected=" 1 1.2 1.4 2 3 11" actual="${result}"/>
-
- </test:case>
-
-
- <test:case name="testComment">
-
- <x:parse var="doc">
- <foo>
- <!-- this will not be output -->
-
- <x:comment text="this is a comment"/>
- </foo>
- </x:parse>
-
- <test:assert xpath="$doc/foo"/>
-
- <j:set var="t"><x:copyOf select="$doc/foo/comment()"/></j:set>
-
- <test:assertEquals expected="<!--this is a comment-->"
actual="${t.trim()}"/>
-
- </test:case>
-
- <test:case name="testCommentWithTextAttribute">
-
- <x:parse var="doc">
- <foo>
- <!-- this will not be output -->
-
- <x:comment text="this is a comment"/>
- </foo>
- </x:parse>
-
- <test:assert xpath="$doc/foo"/>
-
- <j:set var="t"><x:copyOf select="$doc/foo/comment()"/></j:set>
-
- <test:assertEquals expected="<!--this is a comment-->"
actual="${t.trim()}"/>
- </test:case>
-
- <test:case name="testFileParse">
- <j:new var="theSuite" className="java.io.File">
- <j:arg
value="${basedir}/src/test/org/apache/commons/jelly/tags/xml/suite.jelly"/>
- </j:new>
- exists = ${theSuite.exists()}, readable = ${theSuite.canRead()},
class=${theSuite.class.name}
- <!-- this test fails with beanutils 1.6
- <x:parse var="suite" xml="${theSuite}"/> -->
- </test:case>
-
-
- <test:case name="testSetSingleNode">
- <x:parse var="blopElements">
- <root>
- <blop>blop1</blop>
- <blop>blop0</blop></root>
- </x:parse>
- <x:set var="blopSingle" select="$blopElements/root/blop" sort="text()"
single="true"/>
- <!-- should return the second -->
- <j:invokeStatic var="eltClass" className="java.lang.Class"
method="forName"><j:arg value="org.dom4j.Element"/></j:invokeStatic>
- <test:assert test="${eltClass.isAssignableFrom(blopSingle.getClass())}"/>
- <j:set var="blopSingleText"><x:expr select="$blopSingle/text()"/></j:set>
- <test:assertEquals actual="${blopSingleText}" expected="blop0"/>
- </test:case>
-
-
-</test:suite>
+<?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:j="jelly:core"
+ xmlns:x="jelly:xml"
+ xmlns:test="jelly:junit">
+
+
+ <test:case name="testUriParse">
+ <x:parse var="doc" xml="dummy.xml"/>
+
+ <test:assert xpath="$doc/dummy/[EMAIL PROTECTED]'2']"/>
+ </test:case>
+
+ <test:case name="testBodyParse">
+
+ <x:parse var="doc">
+ <foo>
+ <bar a="1"/>
+ </foo>
+ </x:parse>
+
+ <test:assert xpath="$doc/foo/[EMAIL PROTECTED]'1']"/>
+ </test:case>
+
+ <test:case name="testTextParse">
+
+ <j:set var="text" encode="false">
+ <foo>
+ <bar a="1"/>
+ </foo>
+ </j:set>
+
+ <x:parse var="doc" text="${text}"/>
+
+ <test:assert xpath="$doc/foo/[EMAIL PROTECTED]'1']"/>
+ </test:case>
+
+ <test:case name="testElementAndAttribute">
+
+ <x:parse var="doc">
+ <x:element name="foo">
+ <x:attribute name="x">1234</x:attribute>
+
+ <x:element name="bar">
+ <x:attribute name="y">ABC</x:attribute>
+ hello
+ </x:element>
+ </x:element>
+ </x:parse>
+
+ <test:assert xpath="$doc/foo"/>
+ <test:assert xpath="$doc/[EMAIL PROTECTED]'1234']"/>
+ <test:assert xpath="count($doc/bar) = 0"/>
+
+ <!-- test nested element and attributes -->
+ <test:assert xpath="$doc/[EMAIL PROTECTED]'1234']/[EMAIL PROTECTED]'ABC']"/>
+ <test:assert xpath="$doc/[EMAIL PROTECTED]'1234']/[EMAIL
PROTECTED]'ABC']='hello'"/>
+ </test:case>
+
+ <test:case name="testBadElementAndAttribute">
+
+
+ <j:catch var="ex">
+ <x:element name="foo">
+ some text
+ <x:attribute name="x">1234</x:attribute>
+ </x:element>
+ </j:catch>
+
+
+ <test:assert test="${ex != null}">
+ We should have created an exception as some text is output before the
attributes
+ </test:assert>
+ </test:case>
+
+ <test:case name="assertXPathTests">
+
+ <x:parse var="doc">
+ <foo>
+ <bar>cheese</bar>
+ </foo>
+ </x:parse>
+
+
+ <test:assert xpath="$doc/foo/bar">This should never fail</test:assert>
+ <test:assert xpath="$doc/foo/bar = 'cheese'">This should never
fail</test:assert>
+
+ <j:catch var="ex">
+ <test:assert xpath="$doc/foo/xyz">This should always fail</test:assert>
+ </j:catch>
+
+ <test:assert test="${ex != null}">We should have created an
exception</test:assert>
+
+ The exception was: ${ex.message}
+ </test:case>
+
+ <!-- test the use of namespaces with XPath -->
+ <test:case name="assertXPathWithNamespaceTests" xmlns:a="fooURI"
xmlns:z="doesNotMatch" xmlns="different">
+
+ <x:parse var="doc">
+ <foo xmlns="fooURI">
+ <bar>cheese</bar>
+ </foo>
+ </x:parse>
+
+ <test:assert xpath="$doc/a:foo/a:bar">This should never fail</test:assert>
+ <test:assert xpath="$doc/b:foo/b:bar" xmlns:b="fooURI">This should never
fail</test:assert>
+
+ <j:catch var="ex">
+ <test:assert xpath="$doc/z:foo/z:bar">This should always
fail</test:assert>
+ </j:catch>
+
+ <test:assert test="${ex != null}">We should have created an
exception</test:assert>
+
+ <j:catch var="ex">
+ <test:assert xpath="$doc/foo/bar">This should always fail, since foo is
not in the empty namespace</test:assert>
+ </j:catch>
+
+ <test:assert test="${ex != null}">We should have created an
exception</test:assert>
+
+ <!--
+ || now lets test that the default namespace 'different' is ignored by
the XPath expressions
+ || since XPath should ignore the default namespace - you must use a
prefix in XPath to denote
+ || a namespace
+ -->
+ <test:assert xpath="$doc/*[local-name()='foo']"/>
+ </test:case>
+
+ <!-- test xpath sorting -->
+ <test:case name="testXpathSorting">
+ <x:parse var="nums">
+ <a>
+ <b v="3"/>
+ <b v="2"/>
+ <b v="1"/>
+ <b v="11"/>
+ <b v="1.4"/>
+ <b v="1.2"/>
+ </a>
+ </x:parse>
+
+ <x:parse var="deeper">
+ <a>
+ <b><c><d>3<e>1</e></d></c></b>
+ <b><c><d>2<e>11</e></d></c></b>
+ <b><c><d>1</d></c></b>
+ <b><c><d>11</d></c></b>
+ </a>
+ </x:parse>
+
+ <!-- test ascending -->
+ <j:set var="result" value=""/>
+ <x:forEach select="$nums/a/b" var="x" sort="number(@v)">
+ <x:set var="num" select="$x/@v"/>
+ <j:set var="result" value="${result} ${num.get(0).getText()}"/>
+ </x:forEach>
+
+ <test:assertEquals expected=" 1 1.2 1.4 2 3 11" actual="${result}"/>
+
+ <!-- test descending -->
+ <j:set var="result" value=""/>
+ <x:forEach select="$nums/a/b" var="x" sort="number(@v)" descending="true">
+ <x:set var="num" select="$x/@v"/>
+ <j:set var="result" value="${result} ${num.get(0).getText()}"/>
+ </x:forEach>
+
+ <test:assertEquals expected=" 11 3 2 1.4 1.2 1" actual="${result}"/>
+
+ <!-- test deeper nesting -->
+ <j:set var="result" value=""/>
+ <x:forEach select="$deeper/a/b" var="x" sort="number(c/d/text())">
+ <j:set var="result" value="${result} ${x.getStringValue()}"/>
+ </x:forEach>
+
+ <test:assertEquals expected=" 1 211 31 11" actual="${result}"/>
+
+ <!-- test sort as strings -->
+ <j:set var="result" value=""/>
+ <x:forEach select="$nums/a/b" var="x" sort="@v">
+ <x:set var="num" select="$x/@v"/>
+ <j:set var="result" value="${result} ${num.get(0).getText()}"/>
+ </x:forEach>
+
+ <test:assertEquals expected=" 1 1.2 1.4 11 2 3" actual="${result}"/>
+
+ <!-- test x:set with sort -->
+ <j:set var="result" value=""/>
+ <x:set var="rset" select="$nums/a/b" sort="number(@v)"/>
+ <j:forEach var="num" items="${rset.iterator()}">
+ <j:set var="result" value="${result} ${num.attributeValue('v')}"/>
+ </j:forEach>
+
+ <test:assertEquals expected=" 1 1.2 1.4 2 3 11" actual="${result}"/>
+
+ <!-- test x:set with sort -->
+ <j:set var="result" value=""/>
+ <x:set var="rset" select="$nums/a/b"/>
+ <x:sort list="${rset}" sort="number(@v)"/>
+ <j:forEach var="num" items="${rset.iterator()}">
+ <j:set var="result" value="${result} ${num.attributeValue('v')}"/>
+ </j:forEach>
+
+ <test:assertEquals expected=" 1 1.2 1.4 2 3 11" actual="${result}"/>
+
+ </test:case>
+
+
+ <test:case name="testComment">
+
+ <x:parse var="doc">
+ <foo>
+ <!-- this will not be output -->
+
+ <x:comment text="this is a comment"/>
+ </foo>
+ </x:parse>
+
+ <test:assert xpath="$doc/foo"/>
+
+ <j:set var="t"><x:copyOf select="$doc/foo/comment()"/></j:set>
+
+ <test:assertEquals expected="<!--this is a comment-->"
actual="${t.trim()}"/>
+
+ </test:case>
+
+ <test:case name="testCommentWithTextAttribute">
+
+ <x:parse var="doc">
+ <foo>
+ <!-- this will not be output -->
+
+ <x:comment text="this is a comment"/>
+ </foo>
+ </x:parse>
+
+ <test:assert xpath="$doc/foo"/>
+
+ <j:set var="t"><x:copyOf select="$doc/foo/comment()"/></j:set>
+
+ <test:assertEquals expected="<!--this is a comment-->"
actual="${t.trim()}"/>
+ </test:case>
+
+ <test:case name="testFileParse">
+ <j:new var="theSuite" className="java.io.File">
+ <j:arg
value="${basedir}/src/test/org/apache/commons/jelly/tags/xml/suite.jelly"/>
+ </j:new>
+ exists = ${theSuite.exists()}, readable = ${theSuite.canRead()},
class=${theSuite.class.name}
+ <!-- this test fails with beanutils 1.6
+ <x:parse var="suite" xml="${theSuite}"/> -->
+ </test:case>
+
+
+ <test:case name="testSetSingleNode">
+ <x:parse var="blopElements">
+ <root>
+ <blop>blop1</blop>
+ <blop>blop0</blop></root>
+ </x:parse>
+ <x:set var="blopSingle" select="$blopElements/root/blop" sort="text()"
single="true"/>
+ <!-- should return the second -->
+ <j:invokeStatic var="eltClass" className="java.lang.Class"
method="forName"><j:arg value="org.dom4j.Element"/></j:invokeStatic>
+ <test:assert test="${eltClass.isAssignableFrom(blopSingle.getClass())}"/>
+ <j:set var="blopSingleText"><x:expr select="$blopSingle/text()"/></j:set>
+ <test:assertEquals actual="${blopSingleText}" expected="blop0"/>
+ </test:case>
+
+
+</test:suite>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]