示例#1
0
        /// <summary>
        /// A method is used to clean the WOPI discovery process for the WOPI server.
        /// </summary>
        /// <param name="currentTestClient">A parameter represents the test client name which is running the test suite. This test client act as WOPI client and response discovery request from the WOPI server successfully.</param>
        /// <param name="sutControllerAdapterInstance">A parameter represents the IMS_WOPISUTControlAdapter instance which is used to make the WOPI server perform sending discovery request to the discovery listener.</param>
        public static void CleanUpDiscoveryProcess(string currentTestClient, IMS_WOPISUTControlAdapter sutControllerAdapterInstance)
        {
            // If the current SUT does not support MS-WOPI, the test suite will not perform any discovery process logics.
            if (!isCurrentSUTSupportWOPI)
            {
                return;
            }

            // If the test class invoke this, means the test class will uses the binding.
            long currentCleanUpStatusCounter = System.Threading.Interlocked.Decrement(ref cleanUpDiscoveryStatusCounter);

            if (currentCleanUpStatusCounter > 0)
            {
                return;
            }
            else if (0 == currentCleanUpStatusCounter)
            {
                // Clean up the WOPI discovery process record from so the WOPI server. The test suite act as WOPI client.
                if (DiscoveryProcessHelper.NeedToCleanUpDiscoveryRecord)
                {
                    DiscoveryProcessHelper.CleanUpDiscoveryRecord(currentTestClient, sutControllerAdapterInstance);
                }

                // Dispose the discovery request listener.
                DiscoveryProcessHelper.DisposeDiscoveryListener();
            }
            else
            {
                throw new InvalidOperationException(string.Format("The discovery clean up counter should not be less than zero. current value[{0}]", currentCleanUpStatusCounter));
            }
        }
        /// <summary>
        /// A method is used to perform the WOPI discovery process for the WOPI server.
        /// </summary>
        /// <param name="hostNameOfDiscoveryListener">A parameter represents the machine name which is hosting the discovery listener feature. It should be the test client name which is running the test suite.</param>
        /// <param name="sutControllerInstance">A parameter represents the IMS_WOPISUTControlAdapter instance which is used to make the WOPI server perform sending discovery request to the discovery listener.</param>
        public static void PerformDiscoveryProcess(string hostNameOfDiscoveryListener, IMS_WOPISUTControlAdapter sutControllerInstance)
        {
            if (HasPerformDiscoveryProcessSucceed)
            {
                return;
            }

            if (null == sutControllerInstance)
            {
                throw new ArgumentNullException("sutControllerInstance");
            }

            if (string.IsNullOrEmpty(hostNameOfDiscoveryListener))
            {
                throw new ArgumentNullException("hostNameOfDiscoveryListener");
            }

            // Call the "TriggerWOPIDiscovery" method of IMS_WOPISUTControlAdapter interface
            bool isDiscoverySuccessful = sutControllerInstance.TriggerWOPIDiscovery(hostNameOfDiscoveryListener);
            if (!isDiscoverySuccessful)
            {
                throw new InvalidOperationException("Could not perform the discovery process successfully.");
            }

            lock (lockObjectOfVisitDiscoveryProcessStatus)
            {
                hasPerformDiscoveryProcessSucceed = true;
            }

            DiscoveryProcessHelper.AppendLogs(typeof(DiscoveryProcessHelper), DateTime.Now, "Perform the trigger WOPI discovery process successfully.");
        }
示例#3
0
        /// <summary>
        /// A method is used to perform the discovery process
        /// </summary>
        /// <param name="currentTestClient">A parameter represents the current test client which is listening the discovery request.</param>
        /// <param name="sutControllerAdapterInstance">A parameter represents the IMS_WOPISUTControlAdapter instance which is used to make the WOPI server perform sending discovery request to the discovery listener.</param>
        /// <param name="siteInstance">A parameter represents the ITestSite instance which is used to get the test context.</param>
        public static void PerformDiscoveryProcess(string currentTestClient, IMS_WOPISUTControlAdapter sutControllerAdapterInstance, ITestSite siteInstance)
        {
            DiscoveryProcessHelper.CheckInputParameterNullOrEmpty <string>(currentTestClient, "currentTestClient", "PerformDiscoveryProcess");
            DiscoveryProcessHelper.CheckInputParameterNullOrEmpty <IMS_WOPISUTControlAdapter>(sutControllerAdapterInstance, "sutControllerAdapterInstance", "PerformDiscoveryProcess");
            DiscoveryProcessHelper.CheckInputParameterNullOrEmpty <ITestSite>(siteInstance, "siteInstance", "PerformDiscoveryProcess");

            // If the test class invoke this, means the test class will uses the WOPI discovery binding. The test suite will count all WOPI discovery usage of test classes
            System.Threading.Interlocked.Increment(ref cleanUpDiscoveryStatusCounter);

            // Start the listener, if the listen thread has been start, the DiscoverProcessHelper will not start any new listen thread.
            DiscoveryProcessHelper.StartDiscoveryListen(currentTestClient, progId);

            // Initialize the WOPI Discovery process so that the WOPI server will use the test suite as WOPI client.
            if (!DiscoveryProcessHelper.HasPerformDiscoveryProcessSucceed)
            {
                DiscoveryProcessHelper.PerformDiscoveryProcess(currentTestClient, sutControllerAdapterInstance);
            }
        }
示例#4
0
        /// <summary>
        /// A method is used to clean up the WOPI discovery record for the WOPI server. For removing the record successfully, the WOPI server can be triggered the WOPI discovery process again.
        /// </summary>
        /// <param name="wopiClientName">A parameter represents the WOPI client name which should have been discovered by WOPI server</param>
        /// <param name="sutControllerInstance">A parameter represents the IMS_WOPISUTControlAdapter instance which is used to make the WOPI server clean up discovery record for the specified WOPI client.</param>
        public static void CleanUpDiscoveryRecord(string wopiClientName, IMS_WOPISUTControlAdapter sutControllerInstance)
        {
            DiscoveryProcessHelper.CheckInputParameterNullOrEmpty <IMS_WOPISUTControlAdapter>(sutControllerInstance, "sutControllerInstance", "CleanUpDiscoveryRecord");

            if (!NeedToCleanUpDiscoveryRecord)
            {
                return;
            }

            lock (lockObjectOfVisitDiscoveryProcessStatus)
            {
                if (hasPerformDiscoveryProcessSucceed && !hasPerformCleanUpForDiscovery)
                {
                    bool isDiscoveryRecordRemoveSuccessful = sutControllerInstance.RemoveWOPIDiscoveryRecord(wopiClientName);
                    if (!isDiscoveryRecordRemoveSuccessful)
                    {
                        throw new InvalidOperationException("Could not remove the discovery record successfully, need to remove that manually.");
                    }

                    hasPerformCleanUpForDiscovery = true;
                }
            }
        }
示例#5
0
        /// <summary>
        /// A method is used to perform the WOPI discovery process for the WOPI server.
        /// </summary>
        /// <param name="hostNameOfDiscoveryListener">A parameter represents the machine name which is hosting the discovery listener feature. It should be the test client name which is running the test suite.</param>
        /// <param name="sutControllerInstance">A parameter represents the IMS_WOPISUTControlAdapter instance which is used to make the WOPI server perform sending discovery request to the discovery listener.</param>
        public static void PerformDiscoveryProcess(string hostNameOfDiscoveryListener, IMS_WOPISUTControlAdapter sutControllerInstance)
        {
            if (HasPerformDiscoveryProcessSucceed)
            {
                return;
            }

            if (null == sutControllerInstance)
            {
                throw new ArgumentNullException("sutControllerInstance");
            }

            if (string.IsNullOrEmpty(hostNameOfDiscoveryListener))
            {
                throw new ArgumentNullException("hostNameOfDiscoveryListener");
            }

            // Call the "TriggerWOPIDiscovery" method of IMS_WOPISUTControlAdapter interface
            bool isDiscoverySuccessful = sutControllerInstance.TriggerWOPIDiscovery(hostNameOfDiscoveryListener);

            if (!isDiscoverySuccessful)
            {
                throw new InvalidOperationException("Could not perform the discovery process successfully.");
            }

            lock (lockObjectOfVisitDiscoveryProcessStatus)
            {
                hasPerformDiscoveryProcessSucceed = true;
            }

            DiscoveryProcessHelper.AppendLogs(typeof(DiscoveryProcessHelper), DateTime.Now, "Perform the trigger WOPI discovery process successfully.");
        }
示例#6
0
        /// <summary>
        /// This method is used to initialize the share test case helper. This method will also initialize all helpers which are required to initialize during test suite running.
        /// </summary>
        /// <param name="siteInstance">A parameter represents the ITestSite instance.</param>
        public static void InitializeHelper(ITestSite siteInstance)
        {
            TestSuiteHelper.CheckInputParameterNullOrEmpty <ITestSite>(siteInstance, "siteInstance", "InitializeHelper");

            if (string.IsNullOrEmpty(currentTestClientName))
            {
                currentTestClientName = Common.GetConfigurationPropertyValue("TestClientName", siteInstance);
            }

            if (null == wopiSutControlAdapter)
            {
                wopiSutControlAdapter = siteInstance.GetAdapter <IMS_WOPISUTControlAdapter>();
            }

            if (null == wopiSutManagedCodeControlAdapter)
            {
                wopiSutManagedCodeControlAdapter = siteInstance.GetAdapter <IMS_WOPIManagedCodeSUTControlAdapter>();
            }

            if (null == wopiProtocolAdapter)
            {
                wopiProtocolAdapter = siteInstance.GetAdapter <IMS_WOPIAdapter>();
            }

            InitializeRequiredHelpers(wopiSutManagedCodeControlAdapter, siteInstance);

            if (string.IsNullOrEmpty(relativeSourceFileUrl))
            {
                relativeSourceFileUrl = Common.GetConfigurationPropertyValue("NormalFile", siteInstance);
            }

            progId = Common.GetConfigurationPropertyValue("ProgIdForDiscoveryProcess", siteInstance);

            // Setting the endpoint name according to the current http transport.
            if (string.IsNullOrEmpty(currentSharedTestCasesEndpointName))
            {
                TransportProtocol currentTransport = Common.GetConfigurationPropertyValue <TransportProtocol>("TransportType", siteInstance);
                switch (currentTransport)
                {
                case TransportProtocol.HTTP:
                {
                    currentSharedTestCasesEndpointName = Common.GetConfigurationPropertyValue("SharedTestCaseEndPointNameForHTTP", siteInstance);
                    break;
                }

                case TransportProtocol.HTTPS:
                {
                    currentSharedTestCasesEndpointName = Common.GetConfigurationPropertyValue("SharedTestCaseEndPointNameForHTTPS", siteInstance);
                    break;
                }

                default:
                {
                    throw new InvalidOperationException(string.Format("The test suite only support HTTP or HTTPS transport. Current:[{0}]", currentTransport));
                }
                }
            }

            // Set the protocol name of current test suite
            siteInstance.DefaultProtocolDocShortName = WopiProtocolShortName;

            hasInitializedHelperStatus = true;
        }
        /// <summary>
        /// A method is used to clean up the WOPI discovery record for the WOPI server. For removing the record successfully, the WOPI server can be triggered the WOPI discovery process again.
        /// </summary>
        /// <param name="wopiClientName">A parameter represents the WOPI client name which should have been discovered by WOPI server</param>
        /// <param name="sutControllerInstance">A parameter represents the IMS_WOPISUTControlAdapter instance which is used to make the WOPI server clean up discovery record for the specified WOPI client.</param>
        public static void CleanUpDiscoveryRecord(string wopiClientName, IMS_WOPISUTControlAdapter sutControllerInstance)
        {
            DiscoveryProcessHelper.CheckInputParameterNullOrEmpty<IMS_WOPISUTControlAdapter>(sutControllerInstance, "sutControllerInstance", "CleanUpDiscoveryRecord");

            if (!NeedToCleanUpDiscoveryRecord)
            {
                return;
            }

            lock (lockObjectOfVisitDiscoveryProcessStatus)
            {
               if (hasPerformDiscoveryProcessSucceed && !hasPerformCleanUpForDiscovery)
               {
                   bool isDiscoveryRecordRemoveSuccessful = sutControllerInstance.RemoveWOPIDiscoveryRecord(wopiClientName);
                   if (!isDiscoveryRecordRemoveSuccessful)
                   {
                       throw new InvalidOperationException("Could not remove the discovery record successfully, need to remove that manually.");
                   }

                   hasPerformCleanUpForDiscovery = true;
               }
            }
        }
        /// <summary>
        /// A method is used to clean the WOPI discovery process for the WOPI server.
        /// </summary>
        /// <param name="currentTestClient">A parameter represents the test client name which is running the test suite. This test client act as WOPI client and response discovery request from the WOPI server successfully.</param>
        /// <param name="sutControllerAdapterInstance">A parameter represents the IMS_WOPISUTControlAdapter instance which is used to make the WOPI server perform sending discovery request to the discovery listener.</param>
        public static void CleanUpDiscoveryProcess(string currentTestClient, IMS_WOPISUTControlAdapter sutControllerAdapterInstance)
        {
            // If the current SUT does not support MS-WOPI, the test suite will not perform any discovery process logics.
            if (!isCurrentSUTSupportWOPI)
            {
                return;
            }

            // If the test class invoke this, means the test class will uses the binding.
            long currentCleanUpStatusCounter = System.Threading.Interlocked.Decrement(ref cleanUpDiscoveryStatusCounter);

            if (currentCleanUpStatusCounter > 0)
            {
                return;
            }
            else if (0 == currentCleanUpStatusCounter)
            {
                // Clean up the WOPI discovery process record from so the WOPI server. The test suite act as WOPI client.
                if (DiscoveryProcessHelper.NeedToCleanUpDiscoveryRecord)
                {
                    DiscoveryProcessHelper.CleanUpDiscoveryRecord(currentTestClient, sutControllerAdapterInstance);
                }

                // Dispose the discovery request listener.
                DiscoveryProcessHelper.DisposeDiscoveryListener();
            }
            else
            {
                throw new InvalidOperationException(string.Format("The discovery clean up counter should not be less than zero. current value[{0}]", currentCleanUpStatusCounter));
            }
        }
        /// <summary>
        /// A method is used to perform the discovery process
        /// </summary>
        /// <param name="currentTestClient">A parameter represents the current test client which is listening the discovery request.</param>
        /// <param name="sutControllerAdapterInstance">A parameter represents the IMS_WOPISUTControlAdapter instance which is used to make the WOPI server perform sending discovery request to the discovery listener.</param>
        /// <param name="siteInstance">A parameter represents the ITestSite instance which is used to get the test context.</param>
        public static void PerformDiscoveryProcess(string currentTestClient, IMS_WOPISUTControlAdapter sutControllerAdapterInstance, ITestSite siteInstance)
        {
            DiscoveryProcessHelper.CheckInputParameterNullOrEmpty<string>(currentTestClient, "currentTestClient", "PerformDiscoveryProcess");
            DiscoveryProcessHelper.CheckInputParameterNullOrEmpty<IMS_WOPISUTControlAdapter>(sutControllerAdapterInstance, "sutControllerAdapterInstance", "PerformDiscoveryProcess");
            DiscoveryProcessHelper.CheckInputParameterNullOrEmpty<ITestSite>(siteInstance, "siteInstance", "PerformDiscoveryProcess");

            // If the test class invoke this, means the test class will uses the WOPI discovery binding. The test suite will count all WOPI discovery usage of test classes
            System.Threading.Interlocked.Increment(ref cleanUpDiscoveryStatusCounter);

            // Start the listener, if the listen thread has been start, the DiscoverProcessHelper will not start any new listen thread.
            DiscoveryProcessHelper.StartDiscoveryListen(currentTestClient, progId);

            // Initialize the WOPI Discovery process so that the WOPI server will use the test suite as WOPI client.
            if (!DiscoveryProcessHelper.HasPerformDiscoveryProcessSucceed)
            {
                DiscoveryProcessHelper.PerformDiscoveryProcess(currentTestClient, sutControllerAdapterInstance);
            }
        }
        /// <summary>
        /// This method is used to initialize the share test case helper. This method will also initialize all helpers which are required to initialize during test suite running.
        /// </summary>
        /// <param name="siteInstance">A parameter represents the ITestSite instance.</param>
        public static void InitializeHelper(ITestSite siteInstance)
        {
            TestSuiteHelper.CheckInputParameterNullOrEmpty<ITestSite>(siteInstance, "siteInstance", "InitializeHelper");

            if (string.IsNullOrEmpty(currentTestClientName))
            {
                currentTestClientName = Common.GetConfigurationPropertyValue("TestClientName", siteInstance);
            }

            if (null == wopiSutControlAdapter)
            {
                wopiSutControlAdapter = siteInstance.GetAdapter<IMS_WOPISUTControlAdapter>();
            }

            if (null == wopiSutManagedCodeControlAdapter)
            {
                wopiSutManagedCodeControlAdapter = siteInstance.GetAdapter<IMS_WOPIManagedCodeSUTControlAdapter>();
            }

            if (null == wopiProtocolAdapter)
            {
                wopiProtocolAdapter = siteInstance.GetAdapter<IMS_WOPIAdapter>();
            }

            InitializeRequiredHelpers(wopiSutManagedCodeControlAdapter, siteInstance);

            if (string.IsNullOrEmpty(relativeSourceFileUrl))
            {
                relativeSourceFileUrl = Common.GetConfigurationPropertyValue("NormalFile", siteInstance);
            }

            progId = Common.GetConfigurationPropertyValue("ProgIdForDiscoveryProcess", siteInstance);

            // Setting the endpoint name according to the current http transport.
            if (string.IsNullOrEmpty(currentSharedTestCasesEndpointName))
            {
                TransportProtocol currentTransport = Common.GetConfigurationPropertyValue<TransportProtocol>("TransportType", siteInstance);
                switch (currentTransport)
                {
                    case TransportProtocol.HTTP:
                        {
                            currentSharedTestCasesEndpointName = Common.GetConfigurationPropertyValue("SharedTestCaseEndPointNameForHTTP", siteInstance);
                            break;
                        }

                    case TransportProtocol.HTTPS:
                        {
                            currentSharedTestCasesEndpointName = Common.GetConfigurationPropertyValue("SharedTestCaseEndPointNameForHTTPS", siteInstance);
                            break;
                        }

                    default:
                        {
                            throw new InvalidOperationException(string.Format("The test suite only support HTTP or HTTPS transport. Current:[{0}]", currentTransport));
                        }
                }
            }

            // Set the protocol name of current test suite
            siteInstance.DefaultProtocolDocShortName = WopiProtocolShortName;

            hasInitializedHelperStatus = true;
        }