package com.eactive.eai.transformer;

import com.eactive.eai.common.util.Logger;
import com.eactive.eai.transformer.engine.TransformEngine;
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 Layout2DepthUpRefTest extends TestCase {
	protected static Logger logger = Logger.getLogger("transformer");

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

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

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

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

    public void tearDown() throws Exception {
        //
    }
    
    public void testReq() throws Exception {
  		System.out.println("Req ==============================================================");

        //----------------------------------------------------------------------
        // source message 생성
        //----------------------------------------------------------------------
    	//정상
  		String data ="1                                                                                                                                                                                                                        000000000000000000000000000000000000000000000000000000000000000000000000000000                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ";
    	//오류
  		//String data ="1                                                                                                                                                                                                                        000000000000000100000000000000000000000000000000000000000000000000000000000000                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ";

    	Message source = MessageFactory.getFactory().getMessage("EAI_TST2DEPTHREF_REQ1");
        source.setData(data.getBytes());
        System.out.println("source="+source);

        //----------------------------------------------------------------------
        // 변환 방식 1
        //----------------------------------------------------------------------
//        Transformer transformer = engine.getTransformer();
//        Message target = transformer.transform("TRANSFORM_BFG_KAB0400141BFG_RES", new Message[] { source });
//
//        System.out.println(target.toString());
//        System.out.println(target.getData());
        
    }
    public void testMapping() throws Exception {
  		System.out.println("Mapping ==============================================================");

        //----------------------------------------------------------------------
        // source message 생성
        //----------------------------------------------------------------------

  		Message source = MessageFactory.getFactory().getMessage("EAI_TST2DEPTHREF_REQ1");
  		source.setObject("EAI_TST2DEPTHREF_REQ1.tranInfoMatr1.dataBook1[0].dsticA1", "AAA".getBytes());
  		source.setObject("EAI_TST2DEPTHREF_REQ1.tranInfoMatr1.dataBook1[1].dsticA1", "BBB".getBytes());
  		source.setObject("EAI_TST2DEPTHREF_REQ1.tranInfoMatr1.dataBook1[2].dsticA1", "CCC".getBytes());

  		source.setObject("EAI_TST2DEPTHREF_REQ1.fdrtMgtInfo1.dataBook3[0].revocDte1", "111".getBytes());
  		source.setObject("EAI_TST2DEPTHREF_REQ1.fdrtMgtInfo1.dataBook3[1].revocDte1", "222".getBytes());
        System.out.println("source="+source);


        
    }
 
    
}
