A class used to execute a series of tests against a server.
Пример #1
0
        /// <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);
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
        private void TestClient_ReportTestResult(
            object sender, 
            ServerTestClient.ReportResultEventArgs e)
        {
            if (InvokeRequired)
            {
                this.Invoke(new EventHandler<ServerTestClient.ReportResultEventArgs>(TestClient_ReportTestResult), sender, e);
                return;
            }

            try
            {
                if (e.Args == null || e.Args.Length == 0)
                {
                    LogMessage(e.Format);
                }
                else
                {
                    LogMessage(Utils.Format(e.Format, e.Args));
                }

                e.Stop = !m_running;

                if (!this.Test_NoDisplayUpdateMI.Checked)
                {
                    ResultsTB.ScrollToCaret();
                }
            }
            catch (Exception exception)
            {
				GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
Пример #4
0
        void TestClient_ReportTestProgress(object sender, ServerTestClient.ReportProgressEventArgs e)
        {
            if (InvokeRequired)
            {
                this.Invoke(new EventHandler<ServerTestClient.ReportProgressEventArgs>(TestClient_ReportTestProgress), sender, e);
                return;
            }

            try
            {
                if (this.Test_NoDisplayUpdateMI.Checked)
                {
                    return;
                }

                e.Stop = !m_running;

                if (!m_running)
                {
                    return;
                }
                
                TestsCompletedTB.Text = Utils.Format(
                    "{0} ({1} Failed)", 
                    e.TestCount,
                    e.FailedTestCount);

                EndpointTB.Text = Utils.Format(
                    "{0} of {1} [{2}:{3}:{4}:{5}]", 
                    e.EndpointCount,
                    e.TotalEndpointCount,
                    e.Endpoint.EndpointUrl.Scheme,
                    e.Endpoint.Description.SecurityMode, 
                    SecurityPolicies.GetDisplayName(e.Endpoint.Description.SecurityPolicyUri),
                    (e.Endpoint.Configuration.UseBinaryEncoding)?"Binary":"XML");

                IterationTB.Text = Utils.Format(
                    "{0} of {1}", 
                    e.IterationCount,
                    e.TotalIterationCount);

                TestCaseTB.Text = Utils.Format("{0}/{1}", e.Testcase.Parent, e.Testcase.Name);

                if (e.Breakpoint)
                {
                    DialogResult result = MessageBox.Show(
                        "Stopped at breakpoint. Continue?", 
                        e.Testcase.Name, 
                        MessageBoxButtons.OKCancel, 
                        MessageBoxIcon.Question, 
                        MessageBoxDefaultButton.Button1);

                    e.Stop = result != DialogResult.OK;
                    return;
                }

                double progress = (e.CurrentProgress/e.FinalProgress)*(TestCaseProgressCTRL.Maximum - TestCaseProgressCTRL.Minimum);

                if (progress < TestCaseProgressCTRL.Minimum)
                {
                    progress = TestCaseProgressCTRL.Minimum;
                }

                if (progress > TestCaseProgressCTRL.Maximum)
                {
                    progress = TestCaseProgressCTRL.Maximum;
                }

                TestCaseProgressCTRL.Value = (int)progress;
            }
            catch (Exception exception)
            {
				GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
Пример #5
0
        /// <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);
        }
Пример #6
0
        /// <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);
        }
Пример #7
0
 /// <summary>
 /// Handles the ReportTestResult event of the TestClient control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="Opc.Ua.ServerTest.ServerTestClient.ReportResultEventArgs"/> instance containing the event data.</param>
 private static void TestClient_ReportTestResult(
     object sender,
     ServerTestClient.ReportResultEventArgs e)
 {
     try
     {
         if (e.Args == null || e.Args.Length == 0)
         {
             LogMessage(e.Format);
         }
         else
         {
             LogMessage(Utils.Format(e.Format, e.Args));
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception.Message);
     }
 }