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

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

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

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

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

    public void tearDown() throws Exception {
        //
    }
	public void testFindItemTest() throws Exception {
		System.out.println("find Item Test ==============================================================");
		Message target = MessageFactory.getFactory().getMessage("EAI_TST00000090_RES");
		System.out.println(target);
		//byte[] bzwkData ;
		//bzwkData = (byte[]) target.getData();
		//System.out.println("["+new String(bzwkData)+"]");
		
/*
    	HashMap<String,String> values = new HashMap<String,String>();
    	values.put("HEDR_S9","TEST     ");
    	values.put("STD_SRVC_ID","ABCD");
    	
    	
        for (Iterator iter = target.iterator(); iter.hasNext();) {
			Item item = (Item) iter.next();
			if (item.getIndex() == -1) {
				continue;
			}
	        switch (item.getNodeTypeId()) {
			case Item.NODE_FIELD:
				System.out.println(item.getItemPath());
				break;
	        }
		}
    	
    	
    	
    	
    	byte[] bzwkData = new byte[0];
        if (target != null){
            for(String key : values.keySet()){
				try{
					String path ="TST_TST009999_CBSS."+key;
					String value = values.get(key);
					if (value != null){
						target.setString(path, value);
					}
				}catch(Exception e){}
            }
            bzwkData = (byte[]) target.getData();
    	}		
        System.out.println("["+new String(bzwkData)+"]");
		
*/		
		

	} 
    
}
