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 TransformJsonHangulTest extends TestCase {
	protected static Logger logger = Logger.getLogger("transformer");

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

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

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

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

    public void tearDown() throws Exception {
        //
    }
    
    
    public void testJsonToEbcdic() throws Exception {
    	System.out.println("Json TO Ebcdic ==============================================================");
    	
    	//----------------------------------------------------------------------
    	// source message 생성
    	//----------------------------------------------------------------------
    	String data ="";
    	data = "{\"BFE_KFK124F440_REQ1\" : {\"InData\":{\"의뢰인성명\":\"홍길동\",\"출금계좌번호\":\"11111\",\"입금계좌번호\":\"33333\",\"스타샷거래구분코드\":null,\"적요\":\"\",\"출금내역메모입력여부\":null,\"송금인입력수취인명\":\"\",\"CMS코드번호3\":null,\"CMS코드번호1\":null,\"CMS코드번호2\":null,\"본인입금계좌여부\":null,\"이체금액\":\"44444\",\"비밀번호\":\"2222\",\"출금내역메모\":null}}}";
    	
    	
    	System.out.println(data);
    	Message source = MessageFactory.getFactory().getMessage("BFE_KFK124F440_REQ1");
    	
    	source.setData(data);
    	
    	System.out.println(source.toString());
    	
    	//----------------------------------------------------------------------
    	// 변환 방식 1
    	//----------------------------------------------------------------------
    	Transformer transformer = engine.getTransformer();
    	Message target = transformer.transform("TRANSFORM_BFE_KFK124F440BFE_REQ", new Message[] { source });
    	System.out.println(target.toString());
    	System.out.println(new String((byte[])target.getData()));
    	
    }    
    
    
}
