blob: 0a2608591ff9f090809b13048b6887fccff6932f [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:j="jelly:core"
xmlns:fmt="jelly:fmt"
xmlns:m="jelly:ant"
xmlns:b="jelly:beanshell"
xmlns:test="jelly:junit"
xmlns:log="jelly:log">
<test:case name="testSimple" xmlns="dummy">
<j:set var="keyvar" value="key2"/>
<fmt:bundle basename="org.apache.commons.jelly.tags.fmt.abc">
<fmt:message key="key1" var="dummyKey1"/>
<fmt:message var="dummyKey2">${keyvar}</fmt:message>
<fmt:message var="dummyKeyInvalid">invalid.key</fmt:message>
</fmt:bundle>
<m:echo>i10n content is </m:echo>
<m:echo>key1: '${dummyKey1}'</m:echo>
<m:echo>key2: '${dummyKey2}'</m:echo>
<m:echo>keyInvalid: '${dummyKeyInvalid}'</m:echo>
<test:assertEquals expected="value1" actual="${dummyKey1}" />
<test:assertEquals expected="value2" actual="${dummyKey2}" />
<test:assertEquals expected="???invalid.key???" actual="${dummyKeyInvalid}" />
</test:case>
<test:case name="testParam" xmlns="dummy">
<j:set var="keyvar" value="key3"/>
<j:set var="valuevar" value="param1"/>
<fmt:bundle basename="org.apache.commons.jelly.tags.fmt.abc">
<fmt:message var="dummyKey3">${keyvar}<fmt:param value="${valuevar}"/>
<fmt:param value="param2"/>
</fmt:message>
</fmt:bundle>
<m:echo>i10n content is </m:echo>
<m:echo>key3: '${dummyKey3}'</m:echo>
<test:assertEquals expected="value3 param1 param2" actual="${dummyKey3}" />
<fmt:bundle basename="org.apache.commons.jelly.tags.fmt.abc">
<fmt:message var="dummyKey3" key="${keyvar}"><fmt:param value="${valuevar}"/>
<fmt:param value="param2"/>
</fmt:message>
</fmt:bundle>
<m:echo>i10n content is </m:echo>
<m:echo>key3: '${dummyKey3}'</m:echo>
<test:assertEquals expected="value3 param1 param2" actual="${dummyKey3}" />
</test:case>
<test:case name="testParam2" xmlns="dummy">
<j:set var="keyvar" value="key4"/>
<j:set var="valuevar" value="param1"/>
<j:set var="intvalue" value="123"/>
<j:new className="java.lang.Integer" var="intValue">
<j:arg value="123"/>
</j:new>
<test:assertEquals expected="java.lang.Integer" actual="${intValue.class.name}" />
<fmt:bundle basename="org.apache.commons.jelly.tags.fmt.abc">
<fmt:message var="dummyKey4">${keyvar}<fmt:param value="${valuevar}"/>
<fmt:param value="param2"/>
<fmt:param value='${intValue}'/>
</fmt:message>
</fmt:bundle>
<m:echo>i10n content is </m:echo>
<m:echo>key4: '${dummyKey4}'</m:echo>
<test:assertEquals expected="value4 param1 param2 123" actual="${dummyKey4}" />
</test:case>
<test:case name="testPrefix" xmlns="dummy">
<fmt:bundle basename="org.apache.commons.jelly.tags.fmt.xyz" prefix="123.">
<fmt:message key="key1" var="dummyKey1"/>
<fmt:message var="dummyKey2">key2</fmt:message>
<fmt:message var="dummyKeyInvalid">invalid.key</fmt:message>
</fmt:bundle>
<m:echo>i10n content is </m:echo>
<m:echo>key1: '${dummyKey1}'</m:echo>
<m:echo>key2: '${dummyKey2}'</m:echo>
<m:echo>keyInvalid: '${dummyKeyInvalid}'</m:echo>
<test:assertEquals expected="value1" actual="${dummyKey1}" />
<test:assertEquals expected="value2" actual="${dummyKey2}" />
<test:assertEquals expected="???123.invalid.key???" actual="${dummyKeyInvalid}" />
</test:case>
<test:case name="testSetLocale" xmlns="dummy">
<fmt:setLocale value="zh"/>
<fmt:bundle basename="org.apache.commons.jelly.tags.fmt.xyz" prefix="123.">
<fmt:message key="key1" var="dummyKey1"/>
<fmt:message var="dummyKey2">key2</fmt:message>
<fmt:message var="dummyKeyInvalid">invalid.key</fmt:message>
</fmt:bundle>
<m:echo>i10n content is </m:echo>
<m:echo>key1: '${dummyKey1}'</m:echo>
<m:echo>key2: '${dummyKey2}'</m:echo>
<m:echo>keyInvalid: '${dummyKeyInvalid}'</m:echo>
<test:assertEquals expected="value1-zh" actual="${dummyKey1}" />
<test:assertEquals expected="value2-zh" actual="${dummyKey2}" />
<test:assertEquals expected="???123.invalid.key???" actual="${dummyKeyInvalid}" />
</test:case>
</test:suite>