/*
 * BeanUtil3Test.java
 *
 * Created on 2007/03/26, 11:41
 *
 * 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 BeanUtil3Test extends TestCase{
    public void testSetPropertyArray(){
        byte[] array = new byte[2];
        array[0] = 10;
        array[1] = 20;
        SampleBean4 bean = new SampleBean4();
        BeanUtil.setProperty(bean, "byteArray", array);
        
        byte[] chkArray = bean.getByteArray();
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testSetPropertyArray2(){
        Byte[] array = new Byte[2];
        array[0] = new Byte("10");
        array[1] = new Byte("20");
        SampleBean4 bean = new SampleBean4();
        BeanUtil.setProperty(bean, "byteArray2", array);
        
        Byte[] chkArray = bean.getByteArray2();
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testSetPropertyArray3(){
        short[] array = new short[2];
        array[0] = 10;
        array[1] = 10;
        SampleBean4 bean = new SampleBean4();
        BeanUtil.setProperty(bean, "shortArray", array);
        
        short[] chkArray = bean.getShortArray();
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testSetPropertyArray4(){
        Short[] array = new Short[2];
        array[0] = new Short("10");
        array[1] = new Short("10");
        SampleBean4 bean = new SampleBean4();
        BeanUtil.setProperty(bean, "shortArray2", array);
        
        Short[] chkArray = bean.getShortArray2();
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testSetPropertyArray5(){
        int[] array = new int[2];
        array[0] = 10;
        array[1] = 10;
        SampleBean4 bean = new SampleBean4();
        BeanUtil.setProperty(bean, "intArray", array);
        
        int[] chkArray = bean.getIntArray();
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testSetPropertyArray6(){
        Integer[] array = new Integer[2];
        array[0] = new Integer("10");
        array[1] = new Integer("10");
        SampleBean4 bean = new SampleBean4();
        BeanUtil.setProperty(bean, "intArray2", array);
        
        Integer[] chkArray = bean.getIntArray2();
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testSetPropertyArray7(){
        double[] array = new double[2];
        array[0] = 10.9999;
        array[1] = 20.9999;
        SampleBean4 bean = new SampleBean4();
        BeanUtil.setProperty(bean, "doubleArray", array);
        
        double[] chkArray = bean.getDoubleArray();
        assertEquals("array instance", array, chkArray);
//        assertEquals("array[0]", array[0], chkArray[0]);
//        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testSetPropertyArray8(){
        Double[] array = new Double[2];
        array[0] = new Double("10.9999");
        array[1] = new Double("20.9999");
        SampleBean4 bean = new SampleBean4();
        BeanUtil.setProperty(bean, "doubleArray2", array);
        
        Double[] chkArray = bean.getDoubleArray2();
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testSetPropertyArray9(){
        String[] array = new String[2];
        array[0] = new String("10.9999");
        array[1] = new String("20.9999");
        SampleBean4 bean = new SampleBean4();
        BeanUtil.setProperty(bean, "stringArray", array);
        
        String[] chkArray = bean.getStringArray();
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testSetPropertyArray10(){
        boolean[] array = new boolean[2];
        array[0] = true;
        array[1] = false;
        SampleBean4 bean = new SampleBean4();
        BeanUtil.setProperty(bean, "booleanArray", array);
        
        boolean[] chkArray = bean.getBooleanArray();
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testSetPropertyArray11(){
        Boolean[] array = new Boolean[2];
        array[0] = new Boolean("true");
        array[1] = new Boolean("false");
        SampleBean4 bean = new SampleBean4();
        BeanUtil.setProperty(bean, "booleanArray2", array);
        
        Boolean[] chkArray = bean.getBooleanArray2();
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testSetPropertyArray12(){
        long[] array = new long[2];
        array[0] = 10;
        array[1] = 10;
        SampleBean4 bean = new SampleBean4();
        BeanUtil.setProperty(bean, "longArray", array);
        
        long[] chkArray = bean.getLongArray();
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
    
    public void testSetPropertyArray13(){
        Long[] array = new Long[2];
        array[0] = new Long("10");
        array[1] = new Long("10");
        SampleBean4 bean = new SampleBean4();
        BeanUtil.setProperty(bean, "longArray2", array);
        
        Long[] chkArray = bean.getLongArray2();
        assertEquals("array instance", array, chkArray);
        assertEquals("array[0]", array[0], chkArray[0]);
        assertEquals("array[1]", array[1], chkArray[1]);
    }
}
