package com.eactive.eai.transformer;

import org.apache.commons.lang3.time.StopWatch;

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 com.eactive.eai.transformer.util.IConv;

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


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

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

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

    public void setUp() throws Exception {
        engine = TransformEngine.getInstance();

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

    public void tearDown() throws Exception {
        //
    }
    
    public void testTransformExtended() throws Exception {
    	System.out.println("\n\n<<================================== testTransform EBCDIC to XML ==================================>> \n");
    	String data = "KMA01THKJIBR01   202009070000002KPPRTS012KB09840201807309999123120020116        029IT서비스개발부      IT서비IT Service Development Department                             07320 서울 영등포구 여의대로 24 전국경제인연합회회관 30층                                                                                                                                    24, Yeoui-daero, Yeongdeungpo-gu, Seoul, Korea                                                                                                                                                            01    02-2073-4119    1588-9999       02) 2073-6470   555                                                                                                                                        2018168693여의도                                19840    1706200201    000000308500  9020020919        403301                              153809101040485482     315169001022886149                                                                                                                                                               20200907144457920378282960402012062220170626012IT서비스믜                                        kbg125340@kbfg.com                                                        ";
		StopWatch stopWatch = new StopWatch();
		stopWatch.start();
		
		Message source = MessageFactory.getFactory().getMessage("KJI_KJI06DA860_REQ1");
		source.setData(IConv.asciiToEBCDIC(data));
		System.out.println(source);

		Transformer transformer = engine.getTransformer();
		Message target = transformer.transform("TRANSFORM_KJI_KJI06DA860KJI_REQ", new Message[] { source });
		
		System.out.println(target.toString());
		System.out.println("[" + target.getData() + "]");
		stopWatch.stop();
		System.out.println("    elapsed       : " + stopWatch.toString());
    }
    
}
