public SoapUIUtils(Act act, string soapUIDirectoryPath, string reportExportDirectoryPath, string soapUISettingFile, string soapUISettingFilePassword, string projectPassword, bool RunSoapUIProcessAsAdmin, bool SoapUIProcessRedirectStandardError, bool SoapUIProcessRedirectStandardOutput, bool SoapUIProcessUseShellExecute, bool SoapUIProcessWindowStyle, bool SoapUIProcessCreateNoWindow) { //initializing components. mAct = (ActSoapUI)act; SoapUIDirectoryPath = soapUIDirectoryPath; ReportExportDirectoryPath = reportExportDirectoryPath; SoapUISettingFile = soapUISettingFile; SoapUISettingFilePassword = soapUISettingFilePassword; ProjectPassword = projectPassword; mRunSoapUIProcessAsAdmin = RunSoapUIProcessAsAdmin; mSoapUIProcessRedirectStandardError = SoapUIProcessRedirectStandardError; mSoapUIProcessRedirectStandardOutput = SoapUIProcessRedirectStandardOutput; mSoapUIProcessUseShellExecute = SoapUIProcessUseShellExecute; mSoapUIProcessWindowStyle = SoapUIProcessWindowStyle; mSoapUIProcessCreateNoWindow = SoapUIProcessCreateNoWindow; //Creating string for the report extract folder string XMLFileName = Path.GetFileName(mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.XMLFile)).Replace(".xml", string.Empty); mTimestamp = DateTime.Now.ToString("yyyyMMdd-HHmmss"); string SolutionFolder = mAct.SolutionFolder; //SoapUIDirectoryPath = SoapUIDirectoryPath.Replace(@"~\", SolutionFolder); SoapUIDirectoryPath = amdocs.ginger.GingerCoreNET.WorkSpace.Instance.SolutionRepository.ConvertSolutionRelativePath(SoapUIDirectoryPath); //Creating Directory to extract the reports. //string targetPath = ReportExportDirectoryPath.Replace(@"~\", SolutionFolder); string targetPath = amdocs.ginger.GingerCoreNET.WorkSpace.Instance.SolutionRepository.ConvertSolutionRelativePath(ReportExportDirectoryPath); if (!System.IO.Directory.Exists(targetPath)) { System.IO.Directory.CreateDirectory(targetPath); } //ReportPathWithXMLFolder = System.IO.Path.Combine(ReportExportDirectoryPath.Replace(@"~\", SolutionFolder), mAct.Description + mTimestamp); ReportPathWithXMLFolder = System.IO.Path.Combine(amdocs.ginger.GingerCoreNET.WorkSpace.Instance.SolutionRepository.ConvertSolutionRelativePath(ReportExportDirectoryPath), mAct.Description + mTimestamp); ReportPath = ReportPathWithXMLFolder; Directory.CreateDirectory(ReportPath); mAct.LastExecutionFolderPath = ReportPath; }
public void Bind() { XMLFilePathTextBox.Init(Context.GetAsContext(mAct.Context), mAct.GetOrCreateInputParam(ActSoapUI.Fields.XMLFile), true, true, UCValueExpression.eBrowserType.File, "xml", new RoutedEventHandler(BrowseButtonXML_Click)); GingerCore.GeneralLib.BindingHandler.ActInputValueBinding(DoNotImportFile, CheckBox.IsCheckedProperty, mAct.GetOrCreateInputParam(ActSoapUI.Fields.ImportFile)); GingerCore.GeneralLib.BindingHandler.ActInputValueBinding(IgnoreReportXMLValidation, CheckBox.IsCheckedProperty, mAct.GetOrCreateInputParam(ActSoapUI.Fields.IgnoreValidation)); GingerCore.GeneralLib.BindingHandler.ActInputValueBinding(TestSuiteComboBox, ComboBox.TextProperty, mAct.GetOrCreateInputParam(ActSoapUI.Fields.TestSuite)); GingerCore.GeneralLib.BindingHandler.ActInputValueBinding(TestCaseComboBox, ComboBox.TextProperty, mAct.GetOrCreateInputParam(ActSoapUI.Fields.TestCase)); GingerCore.GeneralLib.BindingHandler.ActInputValueBinding(UIrelatedCheckBox, CheckBox.IsCheckedProperty, mAct.GetOrCreateInputParam(ActSoapUI.Fields.UIrelated)); GingerCore.GeneralLib.BindingHandler.ActInputValueBinding(TestCasePropertiesRequieredCheckBox, CheckBox.IsCheckedProperty, mAct.GetOrCreateInputParam(ActSoapUI.Fields.TestCasePropertiesRequiered)); PropertiesOrPlaceHoldersInit(); MergeAndClearList(); InitPropertiesGrid(mAct.AllProperties, "Properties", "Property Type", "Property Name", "Property Value", "Property Calculated Value"); //place holder property list TestSuitePlaceHolderGrid.Init(Context.GetAsContext(mAct.Context), mAct.TestSuitePlaceHolder, "PlaceHolder Properties", "PlaceHolder Name", "PlaceHolder Value", "PlaceHolder Calculated Value"); EndPointTextBox.Init(Context.GetAsContext(mAct.Context), mAct.GetOrCreateInputParam(ActSoapUI.Fields.EndPoint)); HostPortTextBox.Init(Context.GetAsContext(mAct.Context), mAct.GetOrCreateInputParam(ActSoapUI.Fields.HostPort)); UsernameTextBox.Init(Context.GetAsContext(mAct.Context), mAct.GetOrCreateInputParam(ActSoapUI.Fields.Username)); PasswordTextBox.Init(Context.GetAsContext(mAct.Context), mAct.GetOrCreateInputParam(ActSoapUI.Fields.Password)); DomainTextBox.Init(Context.GetAsContext(mAct.Context), mAct.GetOrCreateInputParam(ActSoapUI.Fields.Domain)); PasswordWSSUCComboBox.Init(mAct.GetOrCreateInputParam(ActSoapUI.Fields.PasswordWSSType), typeof(ActSoapUI.ePasswordWSSType), false, new SelectionChangedEventHandler(PasswordWSSComboBox_SelectionChanged)); PasswordWSSUCComboBox.ComboBox.IsEditable = true; if (!string.IsNullOrEmpty(XMLFilePathTextBox.ValueTextBox.Text)) { TestSuiteComboBox.SelectedValue = mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.TestSuite); TestCaseComboBox.SelectedValue = mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.TestCase); } SystemPropertiesVEGrid.Init(Context.GetAsContext(mAct.Context), mAct.SystemProperties, "System Properties", "Property Name", "Property Value", "Property Calculated Value"); GlobalPropertiesVEGrid.Init(Context.GetAsContext(mAct.Context), mAct.GlobalProperties, "Global Properties", "Property Name", "Property Value", "Property Calculated Value"); ExpendPopulatedExpenders(); GingerCore.GeneralLib.BindingHandler.ActInputValueBinding(AddXMLTagsToOutput, CheckBox.IsCheckedProperty, mAct.GetOrCreateInputParam(ActSoapUI.Fields.AddXMLResponse)); GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(OpenExecutionDirectoryButton, Button.IsEnabledProperty, mAct, ActSoapUI.Fields.isActionExecuted, BindingMode.OneWay); ProjectPropertiesGrid.VEGrid.AddToolbarTool("@Reset_16x16.png", "Reset Properties to default", new RoutedEventHandler(ResetProjectButton_Click)); }
//returns bool if the command successfully created and return the command string as well. public bool Command(ref string commandParam) { try { if (mAct.AllProperties.Count == 0 && mAct.TestSuitePlaceHolder.Count == 0) { //Getting the file XML to run. string XMLFiledValue = mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.XMLFile); if (XMLFiledValue.Substring(0, 1).Equals("~")) { XMLFiledValue = System.IO.Path.Combine(mAct.SolutionFolder, XMLFiledValue.Substring(2)); } commandParam = '\u0022' + XMLFiledValue + '\u0022'; } else { commandParam = '\u0022' + UpdateXMLProperty() + '\u0022'; } //The TestSuite to run, used to narrow down the tests to run if (!string.IsNullOrEmpty(mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.TestSuite))) { commandParam = commandParam + " -s" + '\u0022' + mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.TestSuite) + '\u0022'; } //The TestCase to run, used to narrow down the tests to run if (!string.IsNullOrEmpty(mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.TestCase))) { commandParam = commandParam + " -c" + '\u0022' + mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.TestCase) + '\u0022'; } //Enables SoapUI UI-related components, required if you use the UISupport class for prompting or displaying information if (Boolean.Parse((mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.UIrelated)))) { //if ((Boolean)mAct.GetValueForDriverParamWithCustomType(ActSoapUI.Fields.UIrelated, typeof(Boolean)) == true) commandParam = commandParam + " -i"; } //Overrides the endpoint if (!string.IsNullOrEmpty(mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.EndPoint))) { commandParam = commandParam + " -e" + '\u0022' + mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.EndPoint) + '\u0022'; } //The host:port to use when invoking test-requests, overrides only the host part of the endpoint set in the project file if (!string.IsNullOrEmpty(mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.HostPort))) { commandParam = commandParam + " -h" + '\u0022' + mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.HostPort) + '\u0022'; } //The username to use in any authentications, overrides any username set for any TestRequests if (!string.IsNullOrEmpty(mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.Username))) { commandParam = commandParam + " -u" + '\u0022' + mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.Username) + '\u0022'; } //The password to use in any authentications, overrides any password set for any TestRequests if (!string.IsNullOrEmpty(mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.Password))) { commandParam = commandParam + " -p" + '\u0022' + mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.Password) + '\u0022'; } //The domain to use in any authentications, overrides any domain set for any TestRequests if (!string.IsNullOrEmpty(mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.Domain))) { commandParam = commandParam + " -d" + '\u0022' + mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.Domain) + '\u0022'; } //Sets the WSS password type, either 'Text' or 'Digest' if (!(mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.PasswordWSSType).Equals("")) && !string.IsNullOrEmpty(mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.Password))) { commandParam = commandParam + " -w" + '\u0022' + mAct.GetInputParamCalculatedValue(ActSoapUI.Fields.PasswordWSSType) + '\u0022'; } //Sets system property with name=value if (mAct.SystemProperties.Count() > 0) { foreach (ActInputValue row in mAct.SystemProperties) { commandParam = commandParam + " -D" + '\u0022' + row.ItemName + "=" + row.ValueForDriver + '\u0022'; } } //Sets global property with name=value if (mAct.GlobalProperties.Count() > 0) { foreach (ActInputValue row in mAct.GlobalProperties) { commandParam = commandParam + " -G" + '\u0022' + row.ItemName + "=" + row.ValueForDriver + '\u0022'; } } //Sets the soapui-settings.xml file to use, required if you have custom proxy, ssl, http, etc setting if (!string.IsNullOrEmpty(SoapUISettingFile)) { commandParam = commandParam + " -t" + '\u0022' + SoapUISettingFile + '\u0022'; } // Sets password for soapui-settings.xml file if (!string.IsNullOrEmpty(SoapUISettingFilePassword)) { commandParam = commandParam + " -v" + '\u0022' + SoapUISettingFilePassword + '\u0022'; } //Sets project password for decryption if project is encrypted if (!string.IsNullOrEmpty(ProjectPassword)) { commandParam = commandParam + " -x" + '\u0022' + ProjectPassword + '\u0022'; } // r : Turns on printing of a small summary report (see below) // I : Do not stop if error occurs, ignore them: Execution does not stop if error occurs, but no detailed information about errors are stored to the log. (If you need full information about errors, do not use this option). // a : Turns on exporting of all test results, not only errors // M : Creates a Test Run Log Report in XML format // f : Specifies the root folder to which test results should be exported (see below) commandParam = commandParam + " -r -I -a -M -f" + '\u0022' + ReportPath + '\u0022'; return(true); } catch (Exception ex) { mAct.Error = "An Error Occurred while creating the command."; mAct.ExInfo = ex.Message; return(false); } }