1   /*
2    * Copyright 2002-2009 the original author or authors.
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  
17  package net.sf.json;
18  
19  import java.util.ArrayList;
20  import java.util.HashMap;
21  import java.util.List;
22  import java.util.Map;
23  
24  import net.sf.ezmorph.bean.MorphDynaBean;
25  import net.sf.ezmorph.bean.MorphDynaClass;
26  
27  /**
28   * @author Andres Almiray <aalmiray@users.sourceforge.net>
29   */
30  public class TestJSONArrayStaticBuilders_Collection_DynaBean extends
31        AbstractJSONArrayStaticBuildersTestCase {
32     public static void main( String[] args ) {
33        junit.textui.TestRunner.run( TestJSONArrayStaticBuilders_Collection_DynaBean.class );
34     }
35  
36     public TestJSONArrayStaticBuilders_Collection_DynaBean( String name ) {
37        super( name );
38     }
39  
40     protected Object getSource() {
41        Map map = new HashMap();
42        String[] props = getProperties();
43        for( int i = 0; i < props.length; i++ ){
44           map.put( props[i], PropertyConstants.getPropertyClass( props[i] ) );
45        }
46        map.put( "class", Class.class );
47        map.put( "pexcluded", String.class );
48        MorphDynaClass dynaClass = new MorphDynaClass( map );
49        MorphDynaBean dynaBean = null;
50        try{
51           dynaBean = (MorphDynaBean) dynaClass.newInstance();
52           for( int i = 0; i < props.length; i++ ){
53              dynaBean.set( props[i], PropertyConstants.getPropertyValue( props[i] ) );
54           }
55           dynaBean.set( "class", Object.class );
56           dynaBean.set( "pexcluded", "" );
57        }catch( Exception e ){
58           throw new RuntimeException( e );
59        }
60  
61        List list = new ArrayList();
62        list.add( dynaBean );
63        return list;
64     }
65  }