Example #1
0
        void SetDnsConfigurationTestWithTransofrmation(XmlTransformation transformation)
        {
            RunTest <DNSInformation>(
                new Backup <DNSInformation>(
                    () =>
            {
                XmlNamespacesTransformer transformer = new XmlNamespacesTransformer(transformation);
                SetBreakingBehaviour(transformer);

                return(GetOriginalDnsConfiguration());
            }),
                () =>
            {
                SetDnsConfiguration();
            },
                (originalInformation) =>
            {
                RestoreOriginalDnsConfiguration(originalInformation);

                ResetBreakingBehaviour();
            });
        }
        protected void SearchDeviceScopeTypesTestWithTransofrmation(XmlTransformation transformation)
        {
            RunTest(
                () =>
            {
                Scope[] scopes      = GetScopes();
                string missingScope = DiscoveryUtils.GetMissingMandatoryScope(scopes);
                Assert(string.IsNullOrEmpty(missingScope),
                       string.Format(Resources.ErrorMissingMandatoryScope_Format, missingScope),
                       "Validating device scopes");

                XmlNamespacesTransformer transformer = new XmlNamespacesTransformer(transformation, false);

                SoapMessage <WSD.ProbeMatchesType> probeMatch = ProbeDeviceStep(
                    true,
                    //new DiscoveryUtils.DiscoveryType[][] { DiscoveryUtils.GetOnvif10Type() },
                    null,
                    DiscoveryUtils.GetManadatoryScopes(), null, transformer.ProcessMessage);

                string reason = null;
                Assert(ValidateProbeMatchMessage(probeMatch, out reason), reason, Resources.StepValidateProbeMatch_Title);
            });
        }
Example #3
0
        void SubscribeTestWithTransformation(XmlTransformation transformation)
        {
            EndpointReferenceType subscriptionReference = null;
            int terminationTime = 10;

            RunTest <object>(
                () => null,
                () =>
            {
                EnsureNotificationProducerClientCreated();
                FaultException exc11, exc12;
                Subscribe(out exc11, out exc12, ref terminationTime);

                XmlNamespacesTransformer transformer = new XmlNamespacesTransformer(transformation);
                EnsureNotificationProducerClientCreated();
                SetBreakingBehaviour(_notificationProducerClient.Endpoint, transformer);

                FaultException exc21, exc22;
                Subscribe(out exc21, out exc22, ref terminationTime);

                BeginStep("Check if reaction to request was the same");
                bool ok            = true;
                StringBuilder dump = new StringBuilder();

                Action <FaultException, FaultException, string> compareFaults = new Action <FaultException, FaultException, string>(
                    (exc1, exc2, descr) =>
                {
                    if (exc1 == null)
                    {
                        if (exc2 == null)
                        {
                            // ok
                        }
                        else
                        {
                            ok = false;
                            dump.AppendFormat(
                                "Fault has been received in response to {0} request only when sending without transformation{1}",
                                descr, Environment.NewLine);
                        }
                    }
                    else
                    {
                        if (exc2 == null)
                        {
                            ok = false;
                            dump.AppendFormat(
                                "Fault has been received in response to {0} request only when sending with transformation{1}",
                                descr, Environment.NewLine);
                        }
                        else
                        {
                            // Both not null.
                            // Compare types
                            if (exc1.GetType().GUID != exc2.GetType().GUID)
                            {
                                ok = false;
                                dump.AppendFormat(
                                    "Faults received in response to {0} request have different types{1}",
                                    descr, Environment.NewLine);
                            }
                        }
                    }
                }
                    );

                compareFaults(exc11, exc21, "first");

                FaultException <UnacceptableInitialTerminationTimeFaultType> invalidTerminationTimeFault1 =
                    exc11 as FaultException <UnacceptableInitialTerminationTimeFaultType>;
                FaultException <UnacceptableInitialTerminationTimeFaultType> invalidTerminationTimeFault2 =
                    exc21 as FaultException <UnacceptableInitialTerminationTimeFaultType>;

                if (invalidTerminationTimeFault1 != null && invalidTerminationTimeFault2 != null)
                {
                    compareFaults(exc12, exc22, "second");
                }

                if (!ok)
                {
                    throw new AssertException(dump.ToStringTrimNewLine());
                }

                StepPassed();
            },
                (o) =>
            {
                ResetBreakingBehaviour(_notificationProducerClient.Endpoint);

                if (subscriptionReference != null)
                {
                    if (_subscriptionManagerClient == null)
                    {
                        CreateSubscriptionManagerClient(subscriptionReference);
                    }
                    ReleaseSubscriptionManager(terminationTime * 1000);
                }
            });
        }
Example #4
0
        void SubscribeTestWithTransofrmation(XmlTransformation transformation)
        {
            EndpointReferenceType subscriptionReference = null;
            int terminationTime = 10;

            RunTest <object>(
                () => null,
                () =>
            {
                Proxies.Event.Subscribe request = new Subscribe();
                request.InitialTerminationTime  = "PT10S";

                // Some endpoint reference. There is no information if the DUT must
                // immediately validate it.
                request.ConsumerReference               = new EndpointReferenceType();
                request.ConsumerReference.Address       = new AttributedURIType();
                request.ConsumerReference.Address.Value = _subscriberAddress;

                // request.Filter is null - CR 63

                SubscribeResponse response = null;

                bool retry = false;

                XmlNamespacesTransformer transformer = new XmlNamespacesTransformer(transformation);
                EnsureNotificationProducerClientCreated();
                SetBreakingBehaviour(_notificationProducerClient.Endpoint, transformer);

                try
                {
                    response = Subscribe(request);
                }
                catch (FaultException exc)
                {
                    FaultException <UnacceptableInitialTerminationTimeFaultType> invalidTerminationTimeFault =
                        exc as FaultException <UnacceptableInitialTerminationTimeFaultType>;

                    if (invalidTerminationTimeFault != null)
                    {
                        LogStepEvent(string.Format("Exception of type FaultException<UnacceptableInitialTerminationTimeFaultType> received. Try to subscribe with new parameters"));
                        StepPassed();

                        string duration = string.Empty;
                        terminationTime = GetRecommendedDuration(invalidTerminationTimeFault, out duration);

                        retry = true;
                        request.InitialTerminationTime = duration;
                    }
                    else
                    {
                        //throw;
                        StepPassed();
                        return;
                    }
                }

                if (retry)
                {
                    response = Subscribe(request, "Retry subscribe");
                }

                subscriptionReference = response.SubscriptionReference;

                //
                // validate EndPointReference
                //
                Assert(subscriptionReference != null, "The DUT did not return SubscriptionReference",
                       "Check if the DUT returned SubscriptionReference");

                Assert(subscriptionReference.Address != null && subscriptionReference.Address.Value != null,
                       "SubscriptionReference does not contain address",
                       "Check if SubscriptionReference contains address");

                Assert(subscriptionReference.Address.Value.IsValidUrl(), "URL passed in SubscriptionReference is not valid",
                       "Check that URL specified is valid");


                Assert(response.CurrentTimeSpecified, "Current time is not specified",
                       "Check that CurrentTime is specified");
                Assert(response.TerminationTimeSpecified, "Termination time is not specified",
                       "Check that TerminationTime is specified");

                Assert(response.CurrentTime.AddSeconds(terminationTime) <= response.TerminationTime,
                       "TerminationTime < CurrentTime + InitialTerminationTime",
                       "Validate times");
            },
                (o) =>
            {
                ResetBreakingBehaviour(_notificationProducerClient.Endpoint);

                if (subscriptionReference != null)
                {
                    if (_subscriptionManagerClient == null)
                    {
                        CreateSubscriptionManagerClient(subscriptionReference);
                    }
                    ReleaseSubscriptionManager(terminationTime * 1000);
                }
            });
        }