| 2263 |
kivins |
1 |
//## begin module%1.7%.codegen_version preserve=yes
|
|
|
2 |
// Read the documentation to learn more about C++ code generator
|
|
|
3 |
// versioning.
|
|
|
4 |
//## end module%1.7%.codegen_version
|
|
|
5 |
|
|
|
6 |
//## begin module%420310A60071.cm preserve=no
|
|
|
7 |
//## end module%420310A60071.cm
|
|
|
8 |
|
|
|
9 |
//## begin module%420310A60071.cp preserve=no
|
|
|
10 |
// C O P Y R I G H T N O T I C E
|
|
|
11 |
// This material is confidential to ERG and may not be disclosed in whole
|
|
|
12 |
// or in part to any third party nor used in any manner whatsoever other
|
|
|
13 |
// than for the purposes expressly consented to by ERG in writing.
|
|
|
14 |
//
|
|
|
15 |
// This material is also copyright and may not be reproduced, stored in a
|
|
|
16 |
// retrieval system or transmitted in any form or by any means in whole or
|
|
|
17 |
// in part without the express written consent of ERG.
|
|
|
18 |
//## end module%420310A60071.cp
|
|
|
19 |
|
|
|
20 |
//## Module: Iteration%420310A60071; Pseudo Package body
|
|
|
21 |
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
|
|
|
22 |
//## Source file: Z:\MASS_Dev\Tools\TxnTestManager\src\Iteration.cpp
|
|
|
23 |
|
|
|
24 |
//## begin module%420310A60071.additionalIncludes preserve=no
|
|
|
25 |
//## end module%420310A60071.additionalIncludes
|
|
|
26 |
|
|
|
27 |
//## begin module%420310A60071.includes preserve=yes
|
|
|
28 |
#pragma warn -com
|
|
|
29 |
#include <LoggingMacros.h>
|
|
|
30 |
#pragma warn +com
|
|
|
31 |
//## end module%420310A60071.includes
|
|
|
32 |
|
|
|
33 |
// EvaluationContext
|
|
|
34 |
#include "EvaluationContext.h"
|
|
|
35 |
// TransactionStream
|
|
|
36 |
#include "TransactionStream.h"
|
|
|
37 |
// Iteration
|
|
|
38 |
#include "Iteration.h"
|
|
|
39 |
// TestScenario
|
|
|
40 |
#include "TestScenario.h"
|
|
|
41 |
// IXmlSchemaWrapperSchema
|
|
|
42 |
#include "IXmlSchemaWrapperSchema.h"
|
|
|
43 |
// IXmlSchemaWrapperString
|
|
|
44 |
#include "IXmlSchemaWrapperString.h"
|
|
|
45 |
// IXmlSchemaWrapperFactory
|
|
|
46 |
#include "IXmlSchemaWrapperFactory.h"
|
|
|
47 |
//## begin module%420310A60071.additionalDeclarations preserve=yes
|
|
|
48 |
#include <stdlib>
|
|
|
49 |
//## end module%420310A60071.additionalDeclarations
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
// Class Iteration
|
|
|
53 |
|
|
|
54 |
//## Operation: Iteration%420311980081
|
|
|
55 |
Iteration::Iteration (const std::string &projectCode, const int &iteration, XMLSchema::IXmlSchemaWrapperFactory &factory, XMLSchema::IXmlSchemaWrapperSchema &schema, const std::string &schemaHandle)
|
|
|
56 |
//## begin Iteration::Iteration%420311980081.hasinit preserve=no
|
|
|
57 |
: m_schemaHandle(schemaHandle),
|
|
|
58 |
m_schema(0),
|
|
|
59 |
m_factory(0),
|
|
|
60 |
m_projectCode( projectCode ),
|
|
|
61 |
m_iteration( iteration ),
|
|
|
62 |
m_caseRepeat( 1 ), // default
|
|
|
63 |
m_repeatDelay( 0 ), // default
|
|
|
64 |
m_batchSize( 99 ), // default
|
|
|
65 |
m_testCaseName( "TestCase" ) // default
|
|
|
66 |
|
|
|
67 |
{
|
|
|
68 |
//## begin Iteration::Iteration%420311980081.body preserve=yes
|
|
|
69 |
|
|
|
70 |
m_factory = &factory;
|
|
|
71 |
m_schema = &schema;
|
|
|
72 |
|
|
|
73 |
//## end Iteration::Iteration%420311980081.body
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
Iteration::~Iteration()
|
|
|
78 |
{
|
|
|
79 |
//## begin Iteration::~Iteration%420310A60071_dest.body preserve=yes
|
|
|
80 |
|
|
|
81 |
for ( std::map< int, TestScenario * >::iterator
|
|
|
82 |
where = m_scenario.begin();
|
|
|
83 |
where != m_scenario.end();
|
|
|
84 |
++where )
|
|
|
85 |
{
|
|
|
86 |
delete where->second;
|
|
|
87 |
where->second = 0;
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
m_schema = 0; // We don't own this object.
|
|
|
91 |
m_factory = 0; // We don't own this object.
|
|
|
92 |
|
|
|
93 |
//## end Iteration::~Iteration%420310A60071_dest.body
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
std::string & Iteration::buildBatchName (std::string &batchName, const std::string &testName)
|
|
|
97 |
{
|
|
|
98 |
//## begin TestScenario::buildBatchName%4208537A00B6.body preserve=yes
|
|
|
99 |
|
|
|
100 |
batchName.erase();
|
|
|
101 |
batchName.reserve( testName.length() );
|
|
|
102 |
|
|
|
103 |
for ( std::string::size_type index = 0; index < testName.length(); ++index )
|
|
|
104 |
{
|
|
|
105 |
if ( std::isalnum( testName[ index ] ) )
|
|
|
106 |
{
|
|
|
107 |
batchName += testName[ index ];
|
|
|
108 |
}
|
|
|
109 |
else
|
|
|
110 |
{
|
|
|
111 |
batchName += '_';
|
|
|
112 |
}
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
return ( batchName );
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
//## Other Operations (implementation)
|
|
|
119 |
//## Operation: findTestScenario%428D756A034D
|
|
|
120 |
TestScenario& Iteration::findTestScenario (const int &scenario)
|
|
|
121 |
{
|
|
|
122 |
//## begin Iteration::findTestScenario%428D756A034D.body preserve=yes
|
|
|
123 |
|
|
|
124 |
std::map< int, TestScenario * >::const_iterator
|
|
|
125 |
instance = m_scenario.find( scenario );
|
|
|
126 |
|
|
|
127 |
if ( instance != m_scenario.end() )
|
|
|
128 |
{
|
|
|
129 |
return ( *instance->second );
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
MTHROW( std::runtime_error, \
|
|
|
133 |
"Cannot find scenario " << scenario << '.' );
|
|
|
134 |
|
|
|
135 |
//## end Iteration::findTestScenario%428D756A034D.body
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
//## Operation: generate%42045A4D0198
|
|
|
139 |
const bool Iteration::generate (TransactionStream& stream, const bool &generateHeaders, EvaluationContext& evaluationContext)
|
|
|
140 |
{
|
|
|
141 |
//## begin Iteration::generate%42045A4D0198.body preserve=yes
|
|
|
142 |
bool generated = true;
|
|
|
143 |
|
|
|
144 |
|
|
|
145 |
std::string batchName;
|
|
|
146 |
buildBatchName( batchName, m_testCaseName );
|
|
|
147 |
stream.newBatch( m_batchSize, batchName );
|
|
|
148 |
|
|
|
149 |
|
|
|
150 |
for ( std::vector< TestScenario * >::iterator
|
|
|
151 |
where = m_orderedScenarioCollection.begin();
|
|
|
152 |
where != m_orderedScenarioCollection.end();
|
|
|
153 |
++where )
|
|
|
154 |
{
|
|
|
155 |
if ( !(*where)->generate(
|
|
|
156 |
stream,
|
|
|
157 |
generateHeaders,
|
|
|
158 |
evaluationContext ) )
|
|
|
159 |
{
|
|
|
160 |
generated = false;
|
|
|
161 |
break;
|
|
|
162 |
}
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
return ( generated );
|
|
|
166 |
|
|
|
167 |
//## end Iteration::generate%42045A4D0198.body
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
//## Operation: getFormatVersion%4208BDE6025B
|
|
|
171 |
const int Iteration::getFormatVersion () const
|
|
|
172 |
{
|
|
|
173 |
//## begin Iteration::getFormatVersion%4208BDE6025B.body preserve=yes
|
|
|
174 |
|
|
|
175 |
XMLSchema::IXmlSchemaWrapperString * attributeValue = 0;
|
|
|
176 |
|
|
|
177 |
try
|
|
|
178 |
{
|
|
|
179 |
attributeValue = &m_factory->createString();
|
|
|
180 |
if ( m_schema->getAttributeProperty(
|
|
|
181 |
m_schemaHandle.c_str(),
|
|
|
182 |
"",
|
|
|
183 |
"majorversion",
|
|
|
184 |
*attributeValue ) )
|
|
|
185 |
{
|
|
|
186 |
const int majorVersion = atoi( attributeValue->c_str() );
|
|
|
187 |
|
|
|
188 |
if ( m_schema->getAttributeProperty(
|
|
|
189 |
m_schemaHandle.c_str(),
|
|
|
190 |
"",
|
|
|
191 |
"minorversion",
|
|
|
192 |
*attributeValue ) )
|
|
|
193 |
{
|
|
|
194 |
const int minorVersion = atoi( attributeValue->c_str() );
|
|
|
195 |
return ( ( majorVersion << 16 ) + ( minorVersion << 8 ) );
|
|
|
196 |
}
|
|
|
197 |
}
|
|
|
198 |
}
|
|
|
199 |
__finally
|
|
|
200 |
{
|
|
|
201 |
m_factory->destroyString( *attributeValue );
|
|
|
202 |
attributeValue = 0;
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
MTHROW( std::runtime_error, \
|
|
|
206 |
"Cannot read format version from schema." );
|
|
|
207 |
|
|
|
208 |
//## end Iteration::getFormatVersion%4208BDE6025B.body
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
//## Operation: getIterationId%4203119303AD
|
|
|
212 |
const int & Iteration::getIterationId () const
|
|
|
213 |
{
|
|
|
214 |
//## begin Iteration::getIterationId%4203119303AD.body preserve=yes
|
|
|
215 |
|
|
|
216 |
return ( m_iteration );
|
|
|
217 |
|
|
|
218 |
//## end Iteration::getIterationId%4203119303AD.body
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
//## Operation: getProjectCode%4203118E02F2
|
|
|
222 |
const std::string & Iteration::getProjectCode () const
|
|
|
223 |
{
|
|
|
224 |
//## begin Iteration::getProjectCode%4203118E02F2.body preserve=yes
|
|
|
225 |
|
|
|
226 |
return ( m_projectCode );
|
|
|
227 |
|
|
|
228 |
//## end Iteration::getProjectCode%4203118E02F2.body
|
|
|
229 |
}
|
|
|
230 |
|
|
|
231 |
//## Operation: getSchema%420460A8000E
|
|
|
232 |
XMLSchema::IXmlSchemaWrapperSchema & Iteration::getSchema () const
|
|
|
233 |
{
|
|
|
234 |
//## begin Iteration::getSchema%420460A8000E.body preserve=yes
|
|
|
235 |
|
|
|
236 |
return ( *m_schema );
|
|
|
237 |
|
|
|
238 |
//## end Iteration::getSchema%420460A8000E.body
|
|
|
239 |
}
|
|
|
240 |
|
|
|
241 |
//## Operation: getSchemaWrapperFactory%42045F8B030B
|
|
|
242 |
XMLSchema::IXmlSchemaWrapperFactory & Iteration::getSchemaWrapperFactory () const
|
|
|
243 |
{
|
|
|
244 |
//## begin Iteration::getSchemaWrapperFactory%42045F8B030B.body preserve=yes
|
|
|
245 |
|
|
|
246 |
return ( *m_factory );
|
|
|
247 |
|
|
|
248 |
//## end Iteration::getSchemaWrapperFactory%42045F8B030B.body
|
|
|
249 |
}
|
|
|
250 |
|
|
|
251 |
//## Operation: getTestScenario%420312AF031E
|
|
|
252 |
TestScenario& Iteration::getTestScenario (const int &scenario)
|
|
|
253 |
{
|
|
|
254 |
//## begin Iteration::getTestScenario%420312AF031E.body preserve=yes
|
|
|
255 |
|
|
|
256 |
std::map< int, TestScenario * >::const_iterator
|
|
|
257 |
instance = m_scenario.find( scenario );
|
|
|
258 |
|
|
|
259 |
if ( instance != m_scenario.end() )
|
|
|
260 |
{
|
|
|
261 |
return ( *instance->second );
|
|
|
262 |
}
|
|
|
263 |
else
|
|
|
264 |
{
|
|
|
265 |
TestScenario * object = 0;
|
|
|
266 |
|
|
|
267 |
try
|
|
|
268 |
{
|
|
|
269 |
object = new TestScenario( scenario, *this );
|
|
|
270 |
|
|
|
271 |
m_orderedScenarioCollection.push_back( object );
|
|
|
272 |
if ( m_scenario.insert(
|
|
|
273 |
std::map< int, TestScenario * >::value_type(
|
|
|
274 |
scenario,
|
|
|
275 |
object ) ).second )
|
|
|
276 |
{
|
|
|
277 |
return ( *object );
|
|
|
278 |
}
|
|
|
279 |
else
|
|
|
280 |
{
|
|
|
281 |
MTHROW( std::runtime_error, \
|
|
|
282 |
"Cannot add scenario \"" \
|
|
|
283 |
<< scenario \
|
|
|
284 |
<< "\" to iteration " \
|
|
|
285 |
<< m_iteration \
|
|
|
286 |
<< '.' );
|
|
|
287 |
}
|
|
|
288 |
}
|
|
|
289 |
catch ( ... )
|
|
|
290 |
{
|
|
|
291 |
delete object;
|
|
|
292 |
object = 0;
|
|
|
293 |
|
|
|
294 |
throw;
|
|
|
295 |
}
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
//## end Iteration::getTestScenario%420312AF031E.body
|
|
|
299 |
}
|
|
|
300 |
|
|
|
301 |
//## Operation: getTransactionCount%420890E2017C
|
|
|
302 |
const unsigned Iteration::getTransactionCount () const
|
|
|
303 |
{
|
|
|
304 |
//## begin Iteration::getTransactionCount%420890E2017C.body preserve=yes
|
|
|
305 |
|
|
|
306 |
unsigned int count = 0;
|
|
|
307 |
|
|
|
308 |
for ( std::map< int, TestScenario * >::const_iterator
|
|
|
309 |
where = m_scenario.begin();
|
|
|
310 |
where != m_scenario.end();
|
|
|
311 |
++where )
|
|
|
312 |
{
|
|
|
313 |
count += where->second->getTransactionCount();
|
|
|
314 |
}
|
|
|
315 |
|
|
|
316 |
return ( count );
|
|
|
317 |
|
|
|
318 |
//## end Iteration::getTransactionCount%420890E2017C.body
|
|
|
319 |
}
|
|
|
320 |
|
|
|
321 |
// Additional Declarations
|
|
|
322 |
//## begin Iteration%420310A60071.declarations preserve=yes
|
|
|
323 |
|
|
|
324 |
const std::string & Iteration::getTestCaseName () const
|
|
|
325 |
{
|
|
|
326 |
//## begin Iteration::getTestCaseName %42084D300222.body preserve=yes
|
|
|
327 |
|
|
|
328 |
return ( m_testCaseName );
|
|
|
329 |
|
|
|
330 |
//## end Iteration::getTestCaseName %42084D300222.body
|
|
|
331 |
}
|
|
|
332 |
|
|
|
333 |
std::string & Iteration::setTestCaseName (const std::string &value)
|
|
|
334 |
{
|
|
|
335 |
//## begin Iteration::setTestCaseName %42084D300222.body preserve=yes
|
|
|
336 |
|
|
|
337 |
return ( m_testCaseName = value );
|
|
|
338 |
|
|
|
339 |
//## end Iteration::setTestCaseName %42084D300222.body
|
|
|
340 |
}
|
|
|
341 |
const unsigned & Iteration::getBatchSize () const
|
|
|
342 |
{
|
|
|
343 |
//## begin Iteration::getBatchSize %42084D300222.body preserve=yes
|
|
|
344 |
|
|
|
345 |
return ( m_batchSize );
|
|
|
346 |
|
|
|
347 |
//## end Iteration::getBatchSize %42084D300222.body
|
|
|
348 |
}
|
|
|
349 |
|
|
|
350 |
const unsigned & Iteration::setBatchSize (const unsigned &value)
|
|
|
351 |
{
|
|
|
352 |
//## begin Iteration::setBatchSize %42084D300222.body preserve=yes
|
|
|
353 |
|
|
|
354 |
return ( m_batchSize = value );
|
|
|
355 |
|
|
|
356 |
//## end Iteration::setBatchSize %42084D300222.body
|
|
|
357 |
}
|
|
|
358 |
|
|
|
359 |
const unsigned & Iteration::getCaseRepeat () const
|
|
|
360 |
{
|
|
|
361 |
//## begin Iteration::getCaseRepeat %42084D300222.body preserve=yes
|
|
|
362 |
|
|
|
363 |
return ( m_caseRepeat );
|
|
|
364 |
|
|
|
365 |
//## end Iteration::getCaseRepeat %42084D300222.body
|
|
|
366 |
}
|
|
|
367 |
|
|
|
368 |
const unsigned & Iteration::setCaseRepeat (const unsigned &value)
|
|
|
369 |
{
|
|
|
370 |
//## begin Iteration::setCaseRepeat %42084D300222.body preserve=yes
|
|
|
371 |
|
|
|
372 |
if (value == 0)
|
|
|
373 |
{
|
|
|
374 |
m_caseRepeat = 1;
|
|
|
375 |
}
|
|
|
376 |
else
|
|
|
377 |
{
|
|
|
378 |
m_caseRepeat = value;
|
|
|
379 |
}
|
|
|
380 |
return ( m_caseRepeat );
|
|
|
381 |
|
|
|
382 |
//## end Iteration::setCaseRepeat %42084D300222.body
|
|
|
383 |
}
|
|
|
384 |
|
|
|
385 |
const unsigned & Iteration::getRepeatDelay () const
|
|
|
386 |
{
|
|
|
387 |
//## begin Iteration::getRepeatDelay %42084D300222.body preserve=yes
|
|
|
388 |
|
|
|
389 |
return ( m_repeatDelay );
|
|
|
390 |
|
|
|
391 |
//## end Iteration::getRepeatDelay %42084D300222.body
|
|
|
392 |
}
|
|
|
393 |
|
|
|
394 |
const unsigned & Iteration::setRepeatDelay (const unsigned &value)
|
|
|
395 |
{
|
|
|
396 |
//## begin Iteration::setRepeatDelay %42084D300222.body preserve=yes
|
|
|
397 |
|
|
|
398 |
return ( m_repeatDelay = value );
|
|
|
399 |
|
|
|
400 |
//## end Iteration::setRepeatDelay %42084D300222.body
|
|
|
401 |
}
|
|
|
402 |
|
|
|
403 |
//## end Iteration%420310A60071.declarations
|
|
|
404 |
|
|
|
405 |
//## begin module%420310A60071.epilog preserve=yes
|
|
|
406 |
//## end module%420310A60071.epilog
|