/*
 * BeanUtil4Test.java
 *
 * Created on 2007/03/26, 12:04
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package test.org.itscool.commons.bean;

import junit.framework.TestCase;
import org.itscool.commons.bean.BeanUtil;

/**
 *
 * @author Kano
 */
public class BeanUtil4Test extends TestCase{
    public void testGetPropertyArray(){
        byte[] array = new byte[2];
        array[0] = 10;
        array[1] = 20;
        SampleBean4 bean = new SampleBean4();
        bean.setByteArray(array);
        
        byte[] chkArray = (byte[])BeanUtil.getProperty(bean, "byteArray");
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testGetPropertyArray2(){
        Byte[] array = new Byte[2];
        array[0] = new Byte("10");
        array[1] = new Byte("20");
        SampleBean4 bean = new SampleBean4();
        bean.setByteArray2(array);
        
        Byte[] chkArray = (Byte[])BeanUtil.getProperty(bean, "byteArray2");
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testGetPropertyArray3(){
        short[] array = new short[2];
        array[0] = 10;
        array[1] = 20;
        SampleBean4 bean = new SampleBean4();
        bean.setShortArray(array);
        
        short[] chkArray = (short[])BeanUtil.getProperty(bean, "shortArray");
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testGetPropertyArray4(){
        Short[] array = new Short[2];
        array[0] = new Short("10");
        array[1] = new Short("20");
        SampleBean4 bean = new SampleBean4();
        bean.setShortArray2(array);
        
        Short[] chkArray = (Short[])BeanUtil.getProperty(bean, "shortArray2");
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testGetPropertyArray5(){
        int[] array = new int[2];
        array[0] = 10;
        array[1] = 20;
        SampleBean4 bean = new SampleBean4();
        bean.setIntArray(array);
        
        int[] chkArray = (int[])BeanUtil.getProperty(bean, "intArray");
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testGetPropertyArray6(){
        Integer[] array = new Integer[2];
        array[0] = new Integer("10");
        array[1] = new Integer("20");
        SampleBean4 bean = new SampleBean4();
        bean.setIntArray2(array);
        
        Integer[] chkArray = (Integer[])BeanUtil.getProperty(bean, "intArray2");
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    
    public void testGetPropertyArray7(){
        long[] array = new long[2];
        array[0] = 10;
        array[1] = 20;
        SampleBean4 bean = new SampleBean4();
        bean.setLongArray(array);
        
        long[] chkArray = (long[])BeanUtil.getProperty(bean, "longArray");
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testGetPropertyArray8(){
        Long[] array = new Long[2];
        array[0] = new Long("10");
        array[1] = new Long("20");
        SampleBean4 bean = new SampleBean4();
        bean.setLongArray2(array);
        
        Long[] chkArray = (Long[])BeanUtil.getProperty(bean, "longArray2");
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testGetPropertyArray9(){
        boolean[] array = new boolean[2];
        array[0] = true;
        array[1] = false;
        SampleBean4 bean = new SampleBean4();
        bean.setBooleanArray(array);
        
        boolean[] chkArray = (boolean[])BeanUtil.getProperty(bean, "booleanArray");
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testGetPropertyArray10(){
        Boolean[] array = new Boolean[2];
        array[0] = new Boolean("true");
        array[1] = new Boolean("false");
        SampleBean4 bean = new SampleBean4();
        bean.setBooleanArray2(array);
        
        Boolean[] chkArray = (Boolean[])BeanUtil.getProperty(bean, "booleanArray2");
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testGetPropertyArray11(){
        String[] array = new String[2];
        array[0] = new String("true");
        array[1] = new String("false");
        SampleBean4 bean = new SampleBean4();
        bean.setStringArray(array);
        
        String[] chkArray = (String[])BeanUtil.getProperty(bean, "stringArray");
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
}
