package com.higherfrequencytrading.chronicle.fix;
import com.higherfrequencytrading.chronicle.Excerpt;
import com.higherfrequencytrading.chronicle.StopCharTesters;
import com.higherfrequencytrading.chronicle.impl.IndexedChronicle;
import com.higherfrequencytrading.chronicle.tools.ChronicleTools;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import java.io.IOException;
import java.nio.ByteBuffer;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author peter.lawrey
*/
public class FixSocketReaderTest {
public static final String S = "8=FIX.4.4\u00019=82\u000135=A\u000134=1\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.169\u000156=PS_PROTO\u000198=0\u0001108=30\u0001141=Y\u000110=183\u0001" +
"8=FIX.4.4\u00019=134\u000135=D\u000134=2\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.474\u000156=PS_PROTO\u000111=ord-0\u000138=0\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.224\u000110=122\u0001" +
"8=FIX.4.4\u00019=134\u000135=D\u000134=3\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.480\u000156=PS_PROTO\u000111=ord-1\u000138=1\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.480\u000110=126\u0001" +
"8=FIX.4.4\u00019=134\u000135=D\u000134=4\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.486\u000156=PS_PROTO\u000111=ord-2\u000138=2\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.485\u000110=140\u0001" +
"8=FIX.4.4\u00019=134\u000135=D\u000134=5\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.492\u000156=PS_PROTO\u000111=ord-3\u000138=3\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.491\u000110=137\u0001" +
"8=FIX.4.4\u00019=134\u000135=D\u000134=6\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.497\u000156=PS_PROTO\u000111=ord-4\u000138=4\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.496\u000110=150\u0001" +
"8=FIX.4.4\u00019=134\u000135=D\u000134=7\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.502\u000156=PS_PROTO\u000111=ord-5\u000138=5\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.502\u000110=128\u0001" +
"8=FIX.4.4\u00019=134\u000135=D\u000134=8\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.508\u000156=PS_PROTO\u000111=ord-6\u000138=6\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.508\u000110=143\u0001" +
"8=FIX.4.4\u00019=134\u000135=D\u000134=9\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.513\u000156=PS_PROTO\u000111=ord-7\u000138=7\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.513\u000110=138\u0001" +
"8=FIX.4.4\u00019=135\u000135=D\u000134=10\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.518\u000156=PS_PROTO\u000111=ord-8\u000138=8\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.518\u000110=191\u0001" +
"8=FIX.4.4\u00019=135\u000135=D\u000134=11\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.524\u000156=PS_PROTO\u000111=ord-9\u000138=9\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.524\u000110=188\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=12\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.529\u000156=PS_PROTO\u000111=ord-10\u000138=10\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.529\u000110=025\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=13\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.534\u000156=PS_PROTO\u000111=ord-11\u000138=11\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.534\u000110=020\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=14\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.540\u000156=PS_PROTO\u000111=ord-12\u000138=12\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.540\u000110=017\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=15\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.546\u000156=PS_PROTO\u000111=ord-13\u000138=13\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.546\u000110=032\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=16\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.551\u000156=PS_PROTO\u000111=ord-14\u000138=14\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.550\u000110=026\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=17\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.556\u000156=PS_PROTO\u000111=ord-15\u000138=15\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.555\u000110=039\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=18\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.569\u000156=PS_PROTO\u000111=ord-16\u000138=16\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.568\u000110=050\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=19\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.574\u000156=PS_PROTO\u000111=ord-17\u000138=17\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.574\u000110=046\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=20\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.579\u000156=PS_PROTO\u000111=ord-18\u000138=18\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.579\u000110=050\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=21\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.584\u000156=PS_PROTO\u000111=ord-19\u000138=19\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.584\u000110=045\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=22\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.589\u000156=PS_PROTO\u000111=ord-20\u000138=20\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.589\u000110=040\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=23\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.594\u000156=PS_PROTO\u000111=ord-21\u000138=21\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.594\u000110=035\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=24\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.600\u000156=PS_PROTO\u000111=ord-22\u000138=22\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.599\u000110=031\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=25\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.605\u000156=PS_PROTO\u000111=ord-23\u000138=23\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.604\u000110=026\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=26\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.610\u000156=PS_PROTO\u000111=ord-24\u000138=24\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.609\u000110=030\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=27\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.616\u000156=PS_PROTO\u000111=ord-25\u000138=25\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.615\u000110=036\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=28\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.621\u000156=PS_PROTO\u000111=ord-26\u000138=26\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.621\u000110=032\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=29\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.626\u000156=PS_PROTO\u000111=ord-27\u000138=27\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.626\u000110=045\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=30\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.630\u000156=PS_PROTO\u000111=ord-28\u000138=28\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.630\u000110=029\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=31\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.635\u000156=PS_PROTO\u000111=ord-29\u000138=29\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.635\u000110=042\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=32\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.640\u000156=PS_PROTO\u000111=ord-30\u000138=30\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.639\u000110=027\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=33\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.645\u000156=PS_PROTO\u000111=ord-31\u000138=31\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.644\u000110=031\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=34\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.652\u000156=PS_PROTO\u000111=ord-32\u000138=32\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.651\u000110=030\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=35\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.657\u000156=PS_PROTO\u000111=ord-33\u000138=33\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.657\u000110=044\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=36\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.662\u000156=PS_PROTO\u000111=ord-34\u000138=34\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.662\u000110=039\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=37\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.667\u000156=PS_PROTO\u000111=ord-35\u000138=35\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.667\u000110=052\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=38\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.672\u000156=PS_PROTO\u000111=ord-36\u000138=36\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.671\u000110=046\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=39\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.677\u000156=PS_PROTO\u000111=ord-37\u000138=37\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.677\u000110=060\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=40\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.685\u000156=PS_PROTO\u000111=ord-38\u000138=38\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.685\u000110=052\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=41\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.692\u000156=PS_PROTO\u000111=ord-39\u000138=39\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.692\u000110=051\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=42\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.698\u000156=PS_PROTO\u000111=ord-40\u000138=40\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.698\u000110=048\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=43\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.704\u000156=PS_PROTO\u000111=ord-41\u000138=41\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.704\u000110=027\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=44\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.709\u000156=PS_PROTO\u000111=ord-42\u000138=42\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.709\u000110=040\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=45\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.714\u000156=PS_PROTO\u000111=ord-43\u000138=43\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.713\u000110=034\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=46\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.719\u000156=PS_PROTO\u000111=ord-44\u000138=44\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.718\u000110=047\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=47\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.724\u000156=PS_PROTO\u000111=ord-45\u000138=45\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.723\u000110=042\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=48\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.728\u000156=PS_PROTO\u000111=ord-46\u000138=46\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.728\u000110=054\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=49\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.733\u000156=PS_PROTO\u000111=ord-47\u000138=47\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.733\u000110=049\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=50\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.739\u000156=PS_PROTO\u000111=ord-48\u000138=48\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.738\u000110=054\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=51\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.747\u000156=PS_PROTO\u000111=ord-49\u000138=49\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.747\u000110=056\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=52\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.758\u000156=PS_PROTO\u000111=ord-50\u000138=50\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.757\u000110=044\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=53\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.765\u000156=PS_PROTO\u000111=ord-51\u000138=51\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.764\u000110=043\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=54\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.771\u000156=PS_PROTO\u000111=ord-52\u000138=52\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.771\u000110=041\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=55\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.776\u000156=PS_PROTO\u000111=ord-53\u000138=53\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.776\u000110=054\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=56\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.780\u000156=PS_PROTO\u000111=ord-54\u000138=54\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.780\u000110=047\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=57\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.784\u000156=PS_PROTO\u000111=ord-55\u000138=55\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.784\u000110=058\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=58\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.788\u000156=PS_PROTO\u000111=ord-56\u000138=56\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.788\u000110=069\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=59\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.792\u000156=PS_PROTO\u000111=ord-57\u000138=57\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.792\u000110=062\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=60\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.796\u000156=PS_PROTO\u000111=ord-58\u000138=58\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.796\u000110=064\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=61\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.801\u000156=PS_PROTO\u000111=ord-59\u000138=59\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.801\u000110=041\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=62\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.805\u000156=PS_PROTO\u000111=ord-60\u000138=60\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.805\u000110=034\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=63\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.811\u000156=PS_PROTO\u000111=ord-61\u000138=61\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.811\u000110=031\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=64\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.816\u000156=PS_PROTO\u000111=ord-62\u000138=62\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.816\u000110=044\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=65\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.820\u000156=PS_PROTO\u000111=ord-63\u000138=63\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.820\u000110=037\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=66\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.824\u000156=PS_PROTO\u000111=ord-64\u000138=64\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.824\u000110=048\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=67\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.828\u000156=PS_PROTO\u000111=ord-65\u000138=65\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.828\u000110=059\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=68\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.832\u000156=PS_PROTO\u000111=ord-66\u000138=66\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.832\u000110=052\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=69\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.838\u000156=PS_PROTO\u000111=ord-67\u000138=67\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.837\u000110=066\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=70\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.844\u000156=PS_PROTO\u000111=ord-68\u000138=68\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.843\u000110=054\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=71\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.877\u000156=PS_PROTO\u000111=ord-69\u000138=69\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.876\u000110=069\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=72\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.883\u000156=PS_PROTO\u000111=ord-70\u000138=70\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.882\u000110=048\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=73\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.888\u000156=PS_PROTO\u000111=ord-71\u000138=71\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.887\u000110=061\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=74\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.897\u000156=PS_PROTO\u000111=ord-72\u000138=72\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.897\u000110=065\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=75\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.916\u000156=PS_PROTO\u000111=ord-73\u000138=73\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.915\u000110=051\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=76\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.923\u000156=PS_PROTO\u000111=ord-74\u000138=74\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.923\u000110=051\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=77\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.931\u000156=PS_PROTO\u000111=ord-75\u000138=75\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.930\u000110=051\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=78\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.938\u000156=PS_PROTO\u000111=ord-76\u000138=76\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.937\u000110=068\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=79\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.945\u000156=PS_PROTO\u000111=ord-77\u000138=77\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.944\u000110=067\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=80\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.953\u000156=PS_PROTO\u000111=ord-78\u000138=78\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.952\u000110=059\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=81\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.960\u000156=PS_PROTO\u000111=ord-79\u000138=79\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.960\u000110=059\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=82\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.968\u000156=PS_PROTO\u000111=ord-80\u000138=80\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.967\u000110=059\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=83\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.975\u000156=PS_PROTO\u000111=ord-81\u000138=81\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.974\u000110=058\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=84\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.982\u000156=PS_PROTO\u000111=ord-82\u000138=82\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.982\u000110=058\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=85\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.987\u000156=PS_PROTO\u000111=ord-83\u000138=83\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.987\u000110=071\u0001" +
"8=FIX.4.4\u00019=137\u000135=D\u000134=86\u000149=MOCK_PROVIDER\u000152=20130424-13:12:27.993\u000156=PS_PROTO\u000111=ord-84\u000138=84\u000140=2\u000144=123.456\u000154=1\u000155=ABCDEF\u000160=20130424-13:12:27.993\u000110=068\u0001";
public static final String TMP = System.getProperty("java.io.tmpdir");
@Test
public void testReadMessages() throws Exception {
String path = TMP + "/testReadMessages";
ChronicleTools.deleteOnExit(path);
IndexedChronicle chronicle = new IndexedChronicle(path);
Excerpt excerpt = chronicle.createExcerpt();
FixSocketReader fsr = new FixSocketReader(null, excerpt) {
final byte[] bytes = S.getBytes("US-ASCII");
int start = 0;
@Override
protected void readMoreData(@NotNull ByteBuffer buffer) throws IOException {
int end = Math.min(bytes.length, start + 256);
buffer.put(bytes, start, end - start);
start = end;
if (end == bytes.length)
close();
}
};
FixDecoder fd = new FixDecoder(fsr);
FixDecodeListener listener = new FixDecodeListener() {
@Override
public void onField(int fid, @NotNull Excerpt value) {
String text = value.parseUTF(StopCharTesters.FIX_TEXT);
System.out.println("\t" + fid + "=" + text);
}
@Override
public void onEndOfMessage() {
System.out.println("EOM");
}
@Override
public void onEndOfBatch() {
System.out.println("EOB");
}
};
while (!fsr.isClosed()) {
fd.readMessages(listener);
}
excerpt.index(-1);
int count = 0;
while (excerpt.nextIndex()) {
int length = (int) excerpt.readStopBit();
String fix = ChronicleTools.asString(excerpt, excerpt.position(), length);
assertTrue(fix.startsWith("8=FIX"));
assertTrue(fix.endsWith(".")); // ^A is replaced with .
assertEquals(8, fix.length() - fix.lastIndexOf(".10="));
int pos = -1;
while ((pos = fix.indexOf(".10=", pos + 1)) > 0)
count++;
}
assertEquals(86, count);
chronicle.close();
}
@Test
public void testReadMessagesPerf() throws Exception {
String path = TMP + "/testReadMessages";
ChronicleTools.deleteOnExit(path);
IndexedChronicle chronicle = new IndexedChronicle(path);
Excerpt excerpt = chronicle.createExcerpt();
final int[] count = {0};
FixSocketReader fsr = new FixSocketReader(null, excerpt) {
final byte[] bytes = S.getBytes("US-ASCII");
int start = 0;
@Override
protected void readMoreData(@NotNull ByteBuffer buffer) throws IOException {
int end = Math.min(bytes.length, start + 256);
buffer.put(bytes, start, end - start);
start = end;
if (end == bytes.length)
start = 0;
}
};
FixDecoder fd = new FixDecoder(fsr);
FixDecodeListener listener = new FixDecodeListener() {
@Override
public void onField(int fid, Excerpt value) {
// String text = value.parseUTF(StopCharTesters.FIX_TEXT);
// System.out.println("\t" + fid + "=" + text);
}
@Override
public void onEndOfMessage() {
count[0]++;
}
@Override
public void onEndOfBatch() {
// System.out.println("EOB");
}
};
long start = 0;
while (!fsr.isClosed() && count[0] < 1000000) {
if (start == 0 && count[0] > 20000)
start = System.nanoTime();
fd.readMessages(listener);
}
long rate = (count[0] - 20000) * 1000000000L / (System.nanoTime() - start);
System.out.println("The decode rate was " + rate / 1000 + "Kmsg/s");
chronicle.close();
}
}