package test.org.itscool.commons.document;

import java.util.ArrayList;

import junit.framework.TestCase;

import org.itscool.commons.document.BeanToJsonDocument;

import test.org.itscool.commons.bean.BeanSampleEx;

public class BeanToJsonDocument2Test extends TestCase{
    public void test1(){
        try{
            BeanSampleEx bean = new BeanSampleEx();
            bean.setId(100);
            bean.setName("aho aho");
            bean.setAFlag(true);
            //新しいXMLドキュメントを作成します
            BeanToJsonDocument beanToXml = new BeanToJsonDocument("root");
            beanToXml.addElement(bean);
            
            String text = beanToXml.parseText();
            System.out.println("----test3----");
            System.out.println(text);
        }catch(Exception e){
            fail(e.getMessage());
            e.printStackTrace();
        }
    }
    
    public void testParse3(){
        try{
            BeanSampleEx bean = new BeanSampleEx();
            bean.setId(100);
            bean.setName("hanako");
            bean.setAFlag(true);
            
            BeanSampleEx bean2 = new BeanSampleEx();
            bean2.setId(200);
            bean2.setName("tarou");
            bean2.setAFlag(false);
            
            ArrayList list = new ArrayList();
            list.add(bean);
            list.add(bean2);
            
            BeanToJsonDocument beanToXml = new BeanToJsonDocument("root");
            
            beanToXml.addElement(list);
            
            String text = beanToXml.parseText();
            System.out.println("----test3----");
            System.out.println(text);
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
