package test.org.itscool.commons.document;

import junit.framework.TestCase;

import org.itscool.commons.document.BeanToJsonDocument;

public class BeanToJsonDocumentTest extends TestCase{
    
    public void test1(){
        try{
            SampleBean1 bean = new SampleBean1();
            bean.setId(1);
            bean.setName("aaa");
            BeanToJsonDocument beanToXml = new BeanToJsonDocument("root");
            beanToXml.addElement(bean);
            System.out.println(beanToXml.parseText()+"\n");
            //DocumentBeanParser.parseBean();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    
    public void test2(){
        try{
            SampleBean1 bean = new SampleBean1();
            bean.setId(1);
            bean.setName("aaa");
            
            SampleParent1 parent = new SampleParent1();
            parent.setName("parent");
            parent.setBean(bean);
            
            BeanToJsonDocument beanToXml = new BeanToJsonDocument("root");
            beanToXml.addElement(parent);
            System.out.println(beanToXml.parseText()+"\n");
            //DocumentBeanParser.parseBean();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    
    public void test3(){
        try{
            SampleBean1 bean = new SampleBean1();
            bean.setName(null);
            BeanToJsonDocument beanToXml = new BeanToJsonDocument("root");
            beanToXml.addElement(bean);
            System.out.println(beanToXml.parseText()+"\n");
            //DocumentBeanParser.parseBean();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
