Package com.llfix.tests

Source Code of com.llfix.tests.LowLevelFIXTests

package com.llfix.tests;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.handler.codec.embedder.DecoderEmbedder;
import org.jboss.netty.handler.codec.string.StringDecoder;
import org.jboss.netty.util.CharsetUtil;
import org.junit.Assert;
import org.junit.Test;

import com.llfix.IMessageCallback;
import com.llfix.handlers.FIXFrameDecoder;
import com.llfix.handlers.FIXSessionProcessor;
import com.llfix.util.DefaultLogonManager;
import com.llfix.util.FieldAndRequirement;
import com.llfix.util.MemoryQueueFactory;

public class LowLevelFIXTests {
 
  @Test
  public void testFIXSessionProcessor(){
    final DecoderEmbedder<Map<String,String>> h = new DecoderEmbedder<Map<String,String>>(
        new FIXSessionProcessor(
            true,
            new ArrayList<FieldAndRequirement>(),
            new ArrayList<FieldAndRequirement>(),
            new DefaultLogonManager("SENDERCOMPID"),
            new ConcurrentHashMap<String, Channel>(),
            new MemoryQueueFactory<String>(),
            new IMessageCallback() {
             
              @Override
              public void onMsg(Map<String, String> msg) {
               
              }
             
              @Override
              public void onException(Throwable t) {
               
              }
            }));
   
    final Map<String,String> fix = new HashMap<String, String>();
    fix.put("8", "FIX.4.2");

    h.offer(fix);
   
  }
 

  @Test
  public void testFIXFrameDecoder() {
    final DecoderEmbedder<String> h = new DecoderEmbedder<String>(
        new FIXFrameDecoder(),
        new StringDecoder());

    final String fix1 = "8=FIX.4";
    final String fix2 = ".29=7135=A34=149=HTX_DC52=20080";
    final String fix3 = "912-13:23:19.55556=MPNLOMS4NJ98=0108=3010=208";

    h.offer(ChannelBuffers.copiedBuffer(fix1,CharsetUtil.US_ASCII));
    h.offer(ChannelBuffers.copiedBuffer(fix2,CharsetUtil.US_ASCII));
    h.offer(ChannelBuffers.copiedBuffer(fix3,CharsetUtil.US_ASCII));
   
    Assert.assertEquals(fix1+fix2+fix3,h.poll());
  }
}
TOP

Related Classes of com.llfix.tests.LowLevelFIXTests

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.