Repository navigation
Expand file tree
/
Copy pathSocketAcceptorTestCase.cpp
More file actions
118 lines (106 loc) · 3.78 KB
/
Copy pathSocketAcceptorTestCase.cpp
File metadata and controls
118 lines (106 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/****************************************************************************
** Copyright (c) 2001-2014
**
** This file is part of the QuickFIX FIX Engine
**
** This file may be distributed under the terms of the quickfixengine.org
** license as defined by quickfixengine.org and appearing in the file
** LICENSE included in the packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.quickfixengine.org/LICENSE for licensing information.
**
** Contact ask@quickfixengine.org if any conditions of this licensing are
** not clear to you.
**
****************************************************************************/
#ifdef _MSC_VER
#pragma warning( disable : 4503 4355 4786 )
#include "stdafx.h"
#else
#include "config.h"
#endif
#include <UnitTest++.h>
#include <SocketAcceptor.h>
#include <Utility.h>
#include <fix42/Logon.h>
#include <sstream>
#include "TestHelper.h"
using namespace FIX;
SUITE(SocketAcceptorTests)
{
struct receivePartialMessageFixture
{
receivePartialMessageFixture()
{
SessionSettings settings;
std::string input =
"[DEFAULT]\n"
"ConnectionType=acceptor\n"
"SocketAcceptPort=5000\n"
"SocketReuseAddress=Y\n"
"SendBufferSize=1024\n"
"ReceiveBufferSize=1024\n"
"StartTime=00:00:00\n"
"EndTime=00:00:00\n"
"UseDataDictionary=N\n"
"CheckLatency=N\n"
"[SESSION]\n"
"BeginString=FIX.4.2\n"
"SenderCompID=ISLD\n"
"TargetCompID=TW\n"
"[SESSION]\n"
"BeginString=FIX.4.1\n"
"SenderCompID=ISLD\n"
"TargetCompID=WT\n";
std::stringstream stream( input );
stream >> settings;
object = new SocketAcceptor( application, factory, settings );
object->poll();
s = createSocket( 5000, "127.0.0.1" );
object->poll();
}
~receivePartialMessageFixture()
{
object->stop( true );
delete object;
destroySocket( s );
}
TestApplication application;
MemoryStoreFactory factory;
SocketAcceptor* object;
socket_handle s;
};
TEST_FIXTURE(receivePartialMessageFixture, receivePartialMessage)
{
std::string firstPart = "8=FIX.4.29=28235=834=2369=31450"
"52=20041209-15:35:32.68749=TW50=G56=ISLD"
"60=20041209-15:35:3259=055=GE54=148=BLA000060467"
"107=BLF5167=FUT44=9740.0041=040=239=038=10"
"37=20041209004077151=10150=020=09717=67960"
"17=0068712004120909353214=011=000679606=0432=20041209"
"1=1234567810=1458=F";
std::string secondPart = "IX.4.29=34035=834=3369=31450"
"52=20041209-15:35:32.69249=TW50=G56=ISLD"
"60=20041209-15:35:3259=055=GE54=148=CME000060467"
"107=BLF5167=FUT44=9740.0041=040=239=238=10"
"37=20041209004077337=0C032=1031=9740.00151=0150=2"
"20=09717=6796017=00687220041209093532TN0002843"
"75=2004120914=011=00067960375=BLA030A16=0"
"432=200412091=1234567810=217";
FIX42::Logon logon;
logon.getHeader().set( SenderCompID("TW") );
logon.getHeader().set( TargetCompID("ISLD") );
logon.getHeader().set( MsgSeqNum(1) );
logon.getHeader().set( SendingTime() );
logon.set( HeartBtInt(30) );
CHECK( socket_send( s, logon.toString().c_str(), (int)strlen(logon.toString().c_str()) ) );
object->poll();
CHECK( socket_send( s, firstPart.c_str(), (int)strlen(firstPart.c_str()) ) );
object->poll();
CHECK( socket_send( s, secondPart.c_str(), (int)strlen(secondPart.c_str()) ) );
object->poll();
}
}