| <?xml version="1.0"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You 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:dynabean="jelly:dynabean" |
| xmlns:test="jelly:junit" |
| xmlns:log="jelly:log"> |
| |
| <test:case name="simpleDynaBean"> |
| |
| <dynabean:dynaclass var="CustomerType" name ="CustomerDynaClass"> |
| <dynabean:property name="name" type="String" /> |
| <dynabean:property name="address" type="String" /> |
| </dynabean:dynaclass> |
| |
| <dynabean:dynabean var="customer" dynaclass="${CustomerType}"/> |
| |
| <dynabean:set var="customer" property="name" value="Customer 1" /> |
| <dynabean:set var="customer" property="address" value="Address of Customer 1" /> |
| |
| <test:assertEquals expected="Customer 1" actual="${customer.name}"/> |
| <test:assertEquals expected="Address of Customer 1" actual="${customer.address}"/> |
| <test:assertEquals expected="CustomerDynaClass" actual="${customer.dynaClass.name}"/> |
| |
| </test:case> |
| |
| |
| <test:case name="nestedDynaBean"> |
| |
| <dynabean:dynaclass var="AddressType" name="AddressDynaClass"> |
| <dynabean:property name="city" type="String" /> |
| <dynabean:property name="street" type="String" /> |
| <dynabean:property name="housenumber" type="Integer" /> |
| </dynabean:dynaclass> |
| |
| <dynabean:dynaclass var="CustomerType" name="CustomerDynaClass"> |
| <dynabean:property name="name" type="String" /> |
| <dynabean:property name="address" type="org.apache.commons.beanutils.DynaBean"/> |
| </dynabean:dynaclass> |
| |
| |
| <dynabean:dynabean var="customer" dynaclass="${CustomerType}" /> |
| <dynabean:dynabean var="address" dynaclass="${AddressType}" /> |
| |
| <dynabean:set var="customer" property="name" value="Customer 1" /> |
| <dynabean:set var="customer" property="address" value="${address}" /> |
| <dynabean:set var="customer" property="address.city" value="London" /> |
| <dynabean:set var="customer" property="address.street" value="Downing Street" /> |
| <dynabean:set var="customer" property="address.housenumber" value="10" /> |
| |
| <test:assertEquals expected="Customer 1" actual="${customer.name}"/> |
| <test:assertEquals expected="London" actual="${customer.address.city}"/> |
| <test:assertEquals expected="Downing Street" actual="${customer.address.street}"/> |
| |
| <!-- #### JellyUnit needs to support type coercion for this to work... |
| <test:assertEquals expected="10" actual="${customer.address.housenumber}"/> |
| --> |
| |
| |
| </test:case> |
| |
| </test:suite> |