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 junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;


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

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

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

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

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

    public void tearDown() throws Exception {
        //
    }
    
	public void testAscToUjsonOdd() throws Exception {
		System.out.println("ODD ASCII ==============================================================");

		// ----------------------------------------------------------------------
		// source message 생성
		// ----------------------------------------------------------------------
		String data = "0229IGN0040210301005000C34120060509341500400071296807200509341572000000000E1006541908                    00000100                              0000000                00000000000000000000000000000000000000 00000000 0000            000";
		StopWatch stopWatch = new StopWatch();
		stopWatch.start();
		Message source = MessageFactory.getFactory().getMessage("BFE_EEH0200301005_RES1");
		source.setData(data.getBytes());
		System.out.println(source);

		Transformer transformer = engine.getTransformer();
		Message target = transformer.transform("TRANSFORM_BFE_EEH0200301005BFE_RES", new Message[] { source });
		System.out.println(target.toString());
		System.out.println("[" + target.getData() + "]");
		
		stopWatch.stop();
		System.out.println("    elapsed       : " + stopWatch.toString());
	}
	
	public void testAscToUjsonCommon() throws Exception {
		System.out.println("COMMON ASCII ==============================================================");

		// ----------------------------------------------------------------------
		// source message 생성
		// ----------------------------------------------------------------------
		String data = "0229IGN0040210301005000C34120060509341500400071296807200509341572000000000E1006541908                    00000101                              0000000                00000000000000000000000000000000000000 00000000 0000            000";
		StopWatch stopWatch = new StopWatch();
		stopWatch.start();
		Message source = MessageFactory.getFactory().getMessage("BFE_EEH0200301005_RES1");
		source.setData(data.getBytes());
		System.out.println(source);

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