Subversion Repositories DevTools

Rev

Rev 2220 | Rev 2224 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2220 Rev 2222
Line 14... Line 14...
14
#include "DefinedVariable.h"
14
#include "DefinedVariable.h"
15
#include "DefinedVariableTable.h"
15
#include "DefinedVariableTable.h"
16
#include "EvaluationContext.h"
16
#include "EvaluationContext.h"
17
#include "FieldExpression.h"
17
#include "FieldExpression.h"
18
#include "FileCtrl.hpp"
18
#include "FileCtrl.hpp"
-
 
19
#include "GenerationProperties.h"
19
#include "ICryptographicServerProxy.h"
20
#include "ICryptographicServerProxy.h"
20
#include "InitProgress.h"
21
#include "InitProgress.h"
21
#include "IMessageDigest.h"
22
#include "IMessageDigest.h"
22
#include "ISecurityWrapperFactory.h"
23
#include "ISecurityWrapperFactory.h"
23
#include "Iteration.h"
24
#include "Iteration.h"
Line 242... Line 243...
242
			TestParametersPageControl->ActivePage = IterationParametersTabSheet;
243
			TestParametersPageControl->ActivePage = IterationParametersTabSheet;
243
 
244
 
244
			// Initialise the Database connection
245
			// Initialise the Database connection
245
			Data_Module->IntegrationDBConnection->Connected = false;
246
			Data_Module->IntegrationDBConnection->Connected = false;
246
 
247
 
-
 
248
			AnsiString connectionString;
-
 
249
			connectionString.sprintf( "Provider=OraOLEDB.Oracle.1;Data Source=%s", LoginForm->DatabaseEdit->Text );
247
			Data_Module->IntegrationDBConnection->ConnectionString = "Provider=OraOLEDB.Oracle.1;Data Source=REPOS";
250
			Data_Module->IntegrationDBConnection->ConnectionString = connectionString;
248
			Data_Module->IntegrationDBConnection->Open(LoginForm->UsernameEdit->Text, LoginForm->PasswordEdit->Text);
251
			Data_Module->IntegrationDBConnection->Open(LoginForm->UsernameEdit->Text, LoginForm->PasswordEdit->Text);
249
			if (Data_Module->IntegrationDBConnection->Connected)
252
			if (Data_Module->IntegrationDBConnection->Connected)
250
			{
253
			{
251
				MASSTxnsQuery->Active = false;
254
				MASSTxnsQuery->Active = false;
252
				TestCaseQuery->Active = false;
255
				TestCaseQuery->Active = false;
Line 707... Line 710...
707
    {
710
    {
708
        TestCaseQuery->Close();
711
        TestCaseQuery->Close();
709
    }
712
    }
710
	TestCaseTreeView->Items->Clear();
713
	TestCaseTreeView->Items->Clear();
711
 
714
 
-
 
715
	if ( ProjectsComboBox->ItemIndex != -1 )
-
 
716
	{
712
	m_currentproject = *(AnsiString *)(ProjectsComboBox->Items->Objects[ProjectsComboBox->ItemIndex]);
717
		m_currentproject = *(AnsiString *)(ProjectsComboBox->Items->Objects[ProjectsComboBox->ItemIndex]);
-
 
718
	}
713
 
719
 
714
    if (m_Registry != NULL)
720
    if (m_Registry != NULL)
715
    {
721
    {
716
		m_Registry->WriteString("MRUProjectCode", m_currentproject);
722
		m_Registry->WriteString("MRUProjectCode", m_currentproject);
717
    }
723
    }
Line 3998... Line 4004...
3998
}
4004
}
3999
//---------------------------------------------------------------------------
4005
//---------------------------------------------------------------------------
4000
 
4006
 
4001
void __fastcall TMainForm::GenerateTestTestCaseBtnClick(TObject *Sender)
4007
void __fastcall TMainForm::GenerateTestTestCaseBtnClick(TObject *Sender)
4002
{
4008
{
4003
	/**
-
 
4004
	 *	TODO:
-
 
4005
	 *	These need to be read from a form for run-time configuration.  Allow
-
 
4006
	 *	profiles for SC and TDS, storing current values in the registry.
-
 
4007
	 */
-
 
4008
	const bool				generateHeaders	= false;
-
 
4009
	std::string				folder;
-
 
4010
	const std::string		batchPrefix;
-
 
4011
	const std::string		batchSuffix		= ".devud";
-
 
4012
	const bool				buildManifest	= true;
-
 
4013
	const std::string		manifestPrefix	= "udMan";
-
 
4014
	const std::string		manifestSuffix	= ".txt";
-
 
4015
	const std::string		securityServer	= "CryptoServer";
4009
	if ( GenerationPropertiesForm->ShowModal() == mrOk )
4016
	const unsigned short	keyNumber		= 5;
-
 
4017
	const unsigned short	keyVersion		= -2;
-
 
4018
 
-
 
4019
	if ( m_Registry )
-
 
4020
	{
4010
	{
4021
		if ( m_Registry->ValueExists( "MRUGenerationDir" ) )
4011
		const bool				generateHeaders	= GenerationPropertiesForm->GenerateHeadersCheckBox->Checked;
4022
		{
-
 
4023
			folder = m_Registry->ReadString( "MRUGenerationDir" ).c_str();
4012
		std::string				folder			= GenerationPropertiesForm->GenerationFolderDirectoryEdit->Text.c_str();
4024
		}
-
 
4025
	}
-
 
-
 
4013
		const std::string		batchPrefix		= GenerationPropertiesForm->DrainFilePrefixEdit->Text.c_str();
-
 
4014
		const std::string		batchSuffix		= GenerationPropertiesForm->DrainFileSuffixEdit->Text.c_str();
-
 
4015
		const bool				buildManifest	= GenerationPropertiesForm->BuildManifestCheckBox->Checked;
-
 
4016
		const std::string		manifestPrefix	= GenerationPropertiesForm->ManifestPrefixEdit->Text.c_str();
-
 
4017
		const std::string		manifestSuffix	= GenerationPropertiesForm->ManifestSuffixEdit->Text.c_str();
-
 
4018
		const std::string		securityServer	= GenerationPropertiesForm->SecurityServerPipeEdit->Text.c_str();
-
 
4019
		const unsigned short	keyNumber		= GenerationPropertiesForm->KeyNumberEdit->Text.ToInt();
-
 
4020
		const unsigned short	keyVersion		= -2;
4026
 
4021
 
4027
	/**
4022
		/**
4028
		Create a transaction stream into our generation folder, and generate
4023
			Create a transaction stream into our generation folder, and generate
4029
		the transactions into it.  We need to know whether we have to prepend
4024
			the transactions into it.  We need to know whether we have to prepend
4030
		header (i.e., whether it is a .xdr which has a header, or a .devud which
4025
			header (i.e., whether it is a .xdr which has a header, or a .devud which
4031
		doesn't).
4026
			doesn't).
4032
	 */
4027
		 */
4033
 
4028
 
4034
	const TCursor				Save_Cursor					= Screen->Cursor;
4029
		const TCursor				Save_Cursor					= Screen->Cursor;
4035
	bool						transactionOpen				= false;
4030
		bool						transactionOpen				= false;
4036
	ICryptographicServerProxy *	cryptographicServerProxy	= 0;
4031
		ICryptographicServerProxy *	cryptographicServerProxy	= 0;
4037
	IMessageDigest *			messageDigest				= 0;
4032
		IMessageDigest *			messageDigest				= 0;
4038
 
4033
 
4039
	try
4034
		try
4040
	{
-
 
4041
		if ( m_securityWrapperFactory )
-
 
4042
		{
4035
		{
4043
			cryptographicServerProxy = m_securityWrapperFactory
-
 
4044
				->createCryptographicServerProxy( securityServer.c_str() );
-
 
4045
			if ( cryptographicServerProxy )
4036
			if ( m_securityWrapperFactory )
4046
			{
4037
			{
-
 
4038
				cryptographicServerProxy = m_securityWrapperFactory
-
 
4039
					->createCryptographicServerProxy( securityServer.c_str() );
-
 
4040
				if ( cryptographicServerProxy )
-
 
4041
				{
-
 
4042
					if ( cryptographicServerProxy->getModuleCount() )
-
 
4043
					{
-
 
4044
						/**
-
 
4045
						 *	We don't know which module will be used to compute the
-
 
4046
						 *	MAC (security doesn't tell us), so until they do we
-
 
4047
						 *	assume its the first module.
-
 
4048
						 */
-
 
4049
						const unsigned int serialNumber =
-
 
4050
							cryptographicServerProxy->getSerialNumber( 0 );
-
 
4051
 
-
 
4052
						/**
-
 
4053
							We now need to turn the 4-byte serial number into an
-
 
4054
							8-byte diversifier.  Apparently, we must do this by
-
 
4055
							writing the serial number into the lower 4-bytes in big
-
 
4056
							endian.  An API is being added to crypto to do this:
-
 
4057
							until it is there we need to do it ourselves.
-
 
4058
						 */
-
 
4059
						unsigned char buffer[ 8 ];
-
 
4060
 
-
 
4061
						buffer[ 0 ] = 0;
-
 
4062
						buffer[ 1 ] = 0;
-
 
4063
						buffer[ 2 ] = 0;
-
 
4064
						buffer[ 3 ] = 0;
-
 
4065
						buffer[ 4 ] = ( serialNumber >> 24 ) & 0xFF;
-
 
4066
						buffer[ 5 ] = ( serialNumber >> 16 ) & 0xFF;
-
 
4067
						buffer[ 6 ] = ( serialNumber >>  8 ) & 0xFF;
-
 
4068
						buffer[ 7 ] = ( serialNumber       ) & 0xFF;
-
 
4069
 
4047
				messageDigest = m_securityWrapperFactory
4070
						messageDigest = m_securityWrapperFactory
4048
					->createMessageDigest(
4071
							->createMessageDigest(
4049
						*cryptographicServerProxy,
4072
								*cryptographicServerProxy,
4050
						keyNumber,
4073
								keyNumber,
4051
						keyVersion );
4074
								keyVersion,
-
 
4075
								buffer,
-
 
4076
								sizeof( buffer ) );
-
 
4077
					}
-
 
4078
					else
-
 
4079
					{
-
 
4080
						MWARNING( "Cryptographic server has no modules." );
-
 
4081
					}
-
 
4082
				}
4052
			}
4083
			}
4053
		}
-
 
4054
 
4084
 
4055
		Screen->Cursor = crHourGlass;
4085
			Screen->Cursor = crHourGlass;
4056
		Data_Module->IntegrationDBConnection->BeginTrans();
4086
			Data_Module->IntegrationDBConnection->BeginTrans();
4057
		transactionOpen = true;
4087
			transactionOpen = true;
-
 
4088
 
-
 
4089
			TransactionStream stream(
-
 
4090
				folder,
-
 
4091
				batchPrefix,
-
 
4092
				batchSuffix,
-
 
4093
				buildManifest,
-
 
4094
				manifestPrefix,
-
 
4095
				manifestSuffix );
-
 
4096
			Iteration iteration(
-
 
4097
				m_currentproject.c_str(),
-
 
4098
				m_currentiteration,
-
 
4099
				*XMLSchema->GetSchemaWrapperFactory(),
-
 
4100
				*XMLSchema->GetSchema(),
-
 
4101
				m_schema_handle );
-
 
4102
			DefinedVariableTable	definedVariableTable;
-
 
4103
			SequenceCollection		sequences;
-
 
4104
			TimeEstimate			timeEstimate( *MainStatusBar->Panels->Items[ 0 ] );
-
 
4105
			EvaluationContext		context(
-
 
4106
				definedVariableTable,
-
 
4107
				sequences,
-
 
4108
				*m_progressBar,
-
 
4109
				messageDigest,
-
 
4110
				cryptographicServerProxy,
-
 
4111
				timeEstimate );
-
 
4112
 
-
 
4113
			buildExecutionSchedule(
-
 
4114
				iteration,
-
 
4115
				TestCaseQuery->FieldByName( "TESTCASE_ID" )->AsString.c_str() );
-
 
4116
			loadLegacyVariables(
-
 
4117
				definedVariableTable,
-
 
4118
				m_currentproject.c_str(),
-
 
4119
				m_currentiteration );
-
 
4120
			readSequences(
-
 
4121
				sequences,
-
 
4122
				m_currentproject.c_str(),
-
 
4123
				m_currentiteration );
4058
 
4124
 
4059
		TransactionStream stream(
-
 
4060
			folder,
-
 
4061
			batchPrefix,
-
 
4062
			batchSuffix,
-
 
4063
			buildManifest,
-
 
4064
			manifestPrefix,
-
 
4065
			manifestSuffix );
-
 
4066
		Iteration iteration(
-
 
4067
			m_currentproject.c_str(),
-
 
4068
			m_currentiteration,
-
 
4069
			*XMLSchema->GetSchemaWrapperFactory(),
-
 
4070
			*XMLSchema->GetSchema(),
-
 
4071
			m_schema_handle );
-
 
4072
		DefinedVariableTable	definedVariableTable;
-
 
4073
		SequenceCollection		sequences;
-
 
4074
		TimeEstimate			timeEstimate( *MainStatusBar->Panels->Items[ 0 ] );
-
 
4075
		EvaluationContext		context(
-
 
4076
			definedVariableTable,
-
 
4077
			sequences,
-
 
4078
			*m_progressBar,
-
 
4079
			messageDigest,
-
 
4080
			timeEstimate );
-
 
4081
 
-
 
4082
		buildExecutionSchedule(
-
 
4083
			iteration,
-
 
4084
			TestCaseQuery->FieldByName( "TESTCASE_ID" )->AsString.c_str() );
-
 
4085
		loadLegacyVariables(
-
 
4086
			definedVariableTable,
-
 
4087
			m_currentproject.c_str(),
-
 
4088
			m_currentiteration );
-
 
4089
		readSequences(
-
 
4090
			sequences,
-
 
4091
			m_currentproject.c_str(),
-
 
4092
			m_currentiteration );
-
 
4093
 
-
 
4094
		try
4125
			try
4095
		{
-
 
4096
			const int count = iteration.getTransactionCount();
-
 
4097
			m_progressBar->open( count );
-
 
4098
			timeEstimate.start( count );
-
 
4099
			
-
 
4100
			if ( iteration.generate(
-
 
4101
					stream,
-
 
4102
					generateHeaders,
-
 
4103
					context ) )
-
 
4104
			{
4126
			{
-
 
4127
				const int count = iteration.getTransactionCount();
-
 
4128
				m_progressBar->open( count );
-
 
4129
				timeEstimate.start( count );
-
 
4130
			
-
 
4131
				if ( iteration.generate(
-
 
4132
						stream,
-
 
4133
						generateHeaders,
-
 
4134
						context ) )
-
 
4135
				{
4105
				writeSequences(
4136
					writeSequences(
4106
					sequences,
4137
						sequences,
4107
					m_currentproject.c_str(),
4138
						m_currentproject.c_str(),
4108
					m_currentiteration );
4139
						m_currentiteration );
4109
 
4140
 
4110
				Data_Module->IntegrationDBConnection->CommitTrans();
4141
					Data_Module->IntegrationDBConnection->CommitTrans();
4111
				transactionOpen = false;
4142
					transactionOpen = false;
-
 
4143
				}
-
 
4144
			}
-
 
4145
			__finally
-
 
4146
			{
-
 
4147
				timeEstimate.stop();
-
 
4148
				m_progressBar->close();
4112
			}
4149
			}
4113
		}
4150
		}
4114
		__finally
4151
		__finally
4115
		{
4152
		{
4116
			timeEstimate.stop();
-
 
4117
			m_progressBar->close();
-
 
4118
		}
-
 
4119
	}
-
 
4120
	__finally
-
 
4121
	{
-
 
4122
		if ( messageDigest )
4153
			if ( messageDigest )
4123
		{
4154
			{
4124
			m_securityWrapperFactory
4155
				m_securityWrapperFactory
4125
				->destroyMessageDigest( *messageDigest );
4156
					->destroyMessageDigest( *messageDigest );
4126
			messageDigest = 0;
4157
				messageDigest = 0;
4127
		}
4158
			}
4128
		if ( cryptographicServerProxy )
4159
			if ( cryptographicServerProxy )
4129
		{
4160
			{
4130
			m_securityWrapperFactory
4161
				m_securityWrapperFactory
4131
				->destroyCryptographicServerProxy( *cryptographicServerProxy );
4162
					->destroyCryptographicServerProxy( *cryptographicServerProxy );
4132
			cryptographicServerProxy = 0;
4163
				cryptographicServerProxy = 0;
4133
		}
4164
			}
4134
 
4165
 
4135
		if ( transactionOpen )
4166
			if ( transactionOpen )
4136
		{
4167
			{
4137
			Data_Module->IntegrationDBConnection->RollbackTrans();
4168
				Data_Module->IntegrationDBConnection->RollbackTrans();
-
 
4169
			}
-
 
4170
			Screen->Cursor = Save_Cursor;
4138
		}
4171
		}
4139
		Screen->Cursor = Save_Cursor;
-
 
4140
	}
4172
	}
4141
}
4173
}
4142
//---------------------------------------------------------------------------
4174
//---------------------------------------------------------------------------
4143
 
4175
 
4144
const unsigned __fastcall TMainForm::countTransactionsInIteration( const char * project, const int & iteration )
4176
const unsigned __fastcall TMainForm::countTransactionsInIteration( const char * project, const int & iteration )