package com.eactive.eai.transformer;

import com.eactive.eai.common.util.Logger;
import com.eactive.eai.transformer.engine.TransformEngine;
import com.eactive.eai.transformer.engine.Transformer;
import com.eactive.eai.transformer.message.Message;
import com.eactive.eai.transformer.message.MessageFactory;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;


public class TransformJsonApiTest extends TestCase {
	protected static Logger logger = Logger.getLogger("transformer");

	TransformEngine engine = null;
    
    
    public TransformJsonApiTest(String name) {
        super(name);
    }

    public static Test suite() {
        /*
        * the dynamic way
        */
        return new TestSuite(TransformJsonApiTest.class);
    }

    public void setUp() throws Exception {
        // 변환 초기화
        engine = TransformEngine.getInstance();

        if (!engine.isStarted()) {
            engine.start();
        }
    }

    public void tearDown() throws Exception {
        //
    }

    public void testFlatToJsonTransform() throws Exception {

        //----------------------------------------------------------------------
        // source message 생성
        //----------------------------------------------------------------------
    	String data ="T991587760U100001138                                ";
        Message source = MessageFactory.getFactory().getMessage("CAR_EDLKO1201200_REQ1");
        source.setData(data.getBytes());
        System.out.println(source);

        //----------------------------------------------------------------------
        // 변환 방식 1
        //----------------------------------------------------------------------
        Transformer transformer = engine.getTransformer();
        Message target = transformer.transform("TRANSFORM_CAR_EDLKO1201200CAR_REQ", new Message[] { source });

        
//        System.out.println(target);
        System.out.println(target.toString());
        System.out.println("testFlatToJsonTransform >> [["+target.getData()+"]]");
        
    }    
    
    

    
}
