package test.org.itscool.commons.document;

import junit.framework.TestCase;

import org.itscool.commons.document.BeanToXmlDocument;

public class BeanToXmlDocumentTest extends TestCase{
    
    public void test1(){
        try{
            SampleBean1 bean = new SampleBean1();
            bean.setId(1);
            bean.setName("aaa");
            BeanToXmlDocument beanToXml = new BeanToXmlDocument("sample");
            beanToXml.addElement(bean);
            System.out.println(beanToXml.parseText("UTF-8")+"\n");
            //DocumentBeanParser.parseBean();
        }catch(Exception e){
            fail(e.getMessage());
        }
    }
    
    public void test2(){
        try{
            SampleBean1 bean = new SampleBean1();
            bean.setId(1);
            bean.setName("aaa");
            
            SampleParent1 parent = new SampleParent1();
            parent.setName("parent");
            parent.setBean(bean);
            
            BeanToXmlDocument beanToXml = new BeanToXmlDocument("sample");
            beanToXml.addElement(parent);
            System.out.println(beanToXml.parseText("UTF-8")+"\n");
            //DocumentBeanParser.parseBean();
        }catch(Exception e){
            fail(e.getMessage());
        }
    }
    
    public void test3(){
        try{
            SampleBean1 bean = new SampleBean1();
            bean.setName(null);
            BeanToXmlDocument beanToXml = new BeanToXmlDocument("sample");
            beanToXml.addElement(bean);
            System.out.println(beanToXml.parseText("UTF-8")+"\n");
            //DocumentBeanParser.parseBean();
        }catch(Exception e){
            fail(e.getMessage());
        }
    }
}
