1   /*
2    * Copyright 2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */ 
16  package org.apache.commons.betwixt.expression;
17  
18  import org.apache.commons.beanutils.BasicDynaBean;
19  import org.apache.commons.beanutils.BasicDynaClass;
20  import org.apache.commons.beanutils.DynaBean;
21  import org.apache.commons.beanutils.DynaProperty;
22  
23  import junit.framework.TestCase;
24  
25  /***
26   * @author <a href='http://commons.apache.org'>Apache Commons Team</a>, <a href='http://www.apache.org'>Apache Software Foundation</a>
27   */
28  public class TestDynaBeanUpdater extends TestCase {
29  
30      public void testSimpleTest() throws Exception {
31          DynaProperty[] dynaProperties = {
32                  new DynaProperty("alpha", Integer.class),
33                  new DynaProperty("beta", String.class)};
34          BasicDynaClass dynaClass = new BasicDynaClass("ADynaBean", BasicDynaBean.class, 
35                  dynaProperties);
36          DynaBean dynaBean = dynaClass.newInstance();
37          
38          Context context = new Context();
39          context.setBean(dynaBean);
40          
41          DynaBeanUpdater dynaBeanUpdater = new DynaBeanUpdater("beta", String.class);
42          dynaBeanUpdater.update(context, "Zenith Lives");
43          
44          assertEquals("Expected dyna property set", "Zenith Lives", dynaBean.get("beta"));
45      }
46      
47  }