/// <summary> /// Loads the configuration and initializes the form. /// </summary> public MainForm() { InitializeComponent(); this.Icon = ClientUtils.GetAppIcon(); m_configuration = GuiUtils.DoStartupChecks("Opc.Ua.ServerTestTool", ApplicationType.Client, null, true); if (m_configuration != null) { GuiUtils.OverrideUaTcpImplementation(m_configuration); GuiUtils.DisplayUaTcpImplementation(this, m_configuration); } m_configuration.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation); m_testConfiguration = ServerTestConfiguration.Load(m_configuration.Extensions); // allow UA servers to use the same certificate for HTTPS validation. ApplicationInstance.SetUaValidationForHttps(m_configuration.CertificateValidator); TestCasesCTRL.Initialize(m_testConfiguration); // get list of cached endpoints. m_endpoints = m_configuration.LoadCachedEndpoints(true); EndpointsCTRL.Initialize(m_endpoints, m_configuration); // create the test client. m_testClient = new ServerTestClient(m_configuration); m_testClient.ReportResult += new EventHandler <ServerTestClient.ReportResultEventArgs>(TestClient_ReportTestResult); m_testClient.ReportProgress += new EventHandler <ServerTestClient.ReportProgressEventArgs>(TestClient_ReportTestProgress); }
/// <summary> /// Loads the test configuration from a file. /// </summary> private void LoadConfiguration(string filePath) { // load the new configuration. m_testConfiguration = ServerTestConfiguration.Load(filePath, m_testConfiguration); // update the file list. Utils.UpdateRecentFileList("Server Test Client", filePath, 4); // update the control. TestCasesCTRL.Initialize(m_testConfiguration); }
/// <summary> /// Runs the test in a console. /// </summary> private static void RunInConsole(string endpointUrl) { ApplicationConfiguration m_configuration = GuiUtils.DoStartupChecks("Opc.Ua.ServerTestTool", ApplicationType.Client, null, true); if (m_configuration == null) { return; } GuiUtils.OverrideUaTcpImplementation(m_configuration); m_configuration.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation); ServerTestConfiguration m_testConfiguration = ServerTestConfiguration.Load(m_configuration.Extensions); m_testConfiguration.Coverage = 30; m_testConfiguration.EndpointSelection = EndpointSelection.All; m_testConfiguration.ConnectToAllEndpoints = true; // initialize the log file. m_logFilePath = null; if (m_configuration.TraceConfiguration != null) { m_logFilePath = Utils.GetAbsoluteFilePath(m_configuration.TraceConfiguration.OutputFilePath, true, false, true); FileInfo file = new FileInfo(m_logFilePath); m_logFilePath = file.DirectoryName; m_logFilePath += "\\Opc.Ua.ServerTestTool"; } if (String.IsNullOrEmpty(m_logFilePath)) { m_logFilePath = m_configuration.SourceFilePath; } if (!String.IsNullOrEmpty(m_logFilePath)) { try { m_logFilePath += "."; m_logFilePath += Utils.GetAssemblyBuildNumber(); m_logFilePath += ".log.txt"; using (StreamWriter logWriter = new StreamWriter(File.Open(m_logFilePath, FileMode.Create))) { logWriter.WriteLine(Utils.Format("Logging Started at {0:hh:mm:ss}", DateTime.Now)); } } catch (Exception exception) { Console.WriteLine(exception.Message); } } // create the test client. ServerTestClient testClient = new ServerTestClient(m_configuration); ConfiguredEndpointCollection collection = new ConfiguredEndpointCollection(); ConfiguredEndpoint endpoint = collection.Create(endpointUrl); testClient.ReportResult += new EventHandler <ServerTestClient.ReportResultEventArgs>(TestClient_ReportTestResult); testClient.Run(endpoint, m_testConfiguration); }