Ejemplo n.º 1
0
        /// <summary>
        /// 获取路径标识
        /// </summary>
        /// <param name="wcftype"></param>
        /// <returns></returns>
        public static string GetWcfAddressMark(WCFBindingType wcftype)
        {
            switch (wcftype)
            {
            case WCFManager.WCFBindingType.BasicHttpBinding: return("http");

            case WCFManager.WCFBindingType.NetTcpBinding: return("net.tcp");

            default: return("http");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 生成binding
        /// </summary>
        /// <param name="wcftype"></param>
        /// <returns></returns>
        public static Binding CreateBinding(WCFBindingType wcftype)
        {
            XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas();

            quotas.MaxStringContentLength = int.MaxValue;

            switch (wcftype)
            {
            case WCFBindingType.BasicHttpBinding:
            {
                var binding = new BasicHttpBinding()
                {
                    MaxReceivedMessageSize = int.MaxValue
                };
                binding.Security.Mode  = BasicHttpSecurityMode.None;
                binding.ReaderQuotas   = quotas;
                binding.ReceiveTimeout = binding.SendTimeout = WCFTimeout;
                return(binding);
            }

            case WCFBindingType.NetTcpBinding:
            {
                var binding = new NetTcpBinding()
                {
                    MaxReceivedMessageSize = int.MaxValue
                };
                binding.Security.Mode  = SecurityMode.None;
                binding.ReaderQuotas   = quotas;
                binding.ReceiveTimeout = binding.SendTimeout = WCFTimeout;
                return(binding);
            }

            default: {
                var binding = new NetTcpBinding()
                {
                    MaxReceivedMessageSize = int.MaxValue
                };
                binding.Security.Mode  = SecurityMode.None;
                binding.ReaderQuotas   = quotas;
                binding.ReceiveTimeout = binding.SendTimeout = WCFTimeout;
                return(binding);
            }
            }
        }
        private void ConfigureBinding(WCFBindingType bindingType, string relativePath, int port)
        {
            //	<services>
            //		<service name="NewRelic.Agent.IntegrationTestHelpers.ApplicationLibraries.Wcf.WcfService">
            //			<endpoint address="___relativePath___" contract="IWcfService" binding="___bindingType___">
            //			</endpoint>
            //	 </service>
            //	</services>

            //Clean out any bindings that are in the Web.Config
            CommonUtils.DeleteXmlNode(_hostedWebCore.WebConfigPath, "",
                                      new[] { "configuration", "system.serviceModel" }, "services");

            //services node
            CommonUtils.AddXmlNode(_hostedWebCore.WebConfigPath, "",
                                   new[] { "configuration", "system.serviceModel" }, "services", string.Empty);

            //services/service/Name
            CommonUtils.ModifyOrCreateXmlAttribute(_hostedWebCore.WebConfigPath, "",
                                                   new[] { "configuration", "system.serviceModel", "services", "service" },
                                                   "name", "NewRelic.Agent.IntegrationTestHelpers.ApplicationLibraries.Wcf.WcfService");

            //services/service/endpoint - Address
            CommonUtils.ModifyOrCreateXmlAttribute(_hostedWebCore.WebConfigPath, "",
                                                   new[] { "configuration", "system.serviceModel", "services", "service", "endpoint" },
                                                   "address", relativePath);

            //services/service/endpoint - contract
            CommonUtils.ModifyOrCreateXmlAttribute(_hostedWebCore.WebConfigPath, "",
                                                   new[] { "configuration", "system.serviceModel", "services", "service", "endpoint" },
                                                   "contract", "IWcfService");

            //services/service/endpoint - binding
            CommonUtils.ModifyOrCreateXmlAttribute(_hostedWebCore.WebConfigPath, "",
                                                   new[] { "configuration", "system.serviceModel", "services", "service", "endpoint" },
                                                   "binding", _bindingTypeNames[bindingType]);

            if (bindingType == WCFBindingType.WebHttp)
            {
                CommonUtils.ModifyOrCreateXmlAttribute(_hostedWebCore.WebConfigPath, "",
                                                       new[] { "configuration", "system.serviceModel", "services", "service", "endpoint" },
                                                       "behaviorConfiguration", "webHttpBehavior");
            }
        }
        public WCFTestBase(ConsoleDynamicMethodFixtureFW fixture, ITestOutputHelper output,
                           WCFBindingType bindingToTest,
                           IEnumerable <WCFInvocationMethod> clientInvocationsToTest,
                           IEnumerable <WCFInvocationMethod> serviceInvocationsToTest,
                           TracingTestOption tracingTestOption,
                           HostingModel hostingModelOption,
                           ASPCompatibilityMode aspCompatModeOption,
                           IWCFLogHelpers logHelpersImpl
                           )
        {
            _fixture            = fixture;
            _fixture.TestLogger = output;

            _bindingToTest = bindingToTest;
            _clientInvocationMethodsToTest  = clientInvocationsToTest.ToArray();
            _serviceInvocationMethodsToTest = serviceInvocationsToTest.ToArray();
            _tracingTestOption      = tracingTestOption;
            _hostingModelOption     = hostingModelOption;
            _aspCompatibilityOption = aspCompatModeOption;

            _relativePath = $"Test_{_bindingToTest}";

            LogHelpers = logHelpersImpl;

            _fixture.Actions
            (
                setupConfiguration: () =>
            {
                _fixture.RemoteApplication.NewRelicConfig.SetLogLevel("finest");
                _fixture.RemoteApplication.NewRelicConfig.SetRequestTimeout(TimeSpan.FromSeconds(10));
                _fixture.RemoteApplication.NewRelicConfig.ForceTransactionTraces();
                _fixture.RemoteApplication.NewRelicConfig.SetOrDeleteDistributedTraceEnabled(_tracingTestOption == TracingTestOption.DT ? true : null as bool?);
                _fixture.RemoteApplication.NewRelicConfig.SetCATEnabled(_tracingTestOption == TracingTestOption.CAT);

                GenerateFixtureCommands();

                _fixture.SetTimeout(TimeSpan.FromMinutes(5));
            }
            );


            _fixture.Initialize();
        }
Ejemplo n.º 5
0
        public static Uri GetEndpointAddress(WCFBindingType bindingTypeEnum, int port, string relativeUrl)
        {
            relativeUrl = relativeUrl.TrimStart('/');
            switch (bindingTypeEnum)
            {
            case WCFBindingType.BasicHttp:
            case WCFBindingType.WSHttp:
            case WCFBindingType.WebHttp:
            case WCFBindingType.Custom:
            case WCFBindingType.CustomClass:
                return(new Uri($@"http://*****:*****@"net.tcp://localhost:{port}/{relativeUrl}"));

            default:
                throw new NotSupportedException($"Binding Type {bindingTypeEnum}");
            }
        }
 public WCFServiceTestBase(ConsoleDynamicMethodFixtureFW fixture, ITestOutputHelper output, WCFBindingType bindingToTest, TracingTestOption tracingTestOption, HostingModel hostingModelOption, ASPCompatibilityMode aspCompatModeOption, IWCFLogHelpers logHelpersImpl)
     : base(fixture, output, bindingToTest, new[] { WCFInvocationMethod.Sync }, _instrumentedSvcInvocMethods, tracingTestOption, hostingModelOption, aspCompatModeOption, logHelpersImpl)
 {
 }
 public WCFClient_Self(ConsoleDynamicMethodFixtureFW fixture, ITestOutputHelper output, WCFBindingType bindingType, TracingTestOption tracingTestOption)
     : base(fixture, output, bindingType, tracingTestOption, HostingModel.Self, ASPCompatibilityMode.Disabled, new WCFLogHelpers_SelfHosted(fixture))
 {
 }
 public WCFClient_IIS_ASPDisabled(ConsoleDynamicMethodFixtureFW fixture, ITestOutputHelper output, WCFBindingType bindingType, TracingTestOption tracingTestOption)
     : base(fixture, output, bindingType, tracingTestOption, ASPCompatibilityMode.Disabled)
 {
 }
 public WCFClient_IIS(ConsoleDynamicMethodFixtureFW fixture, ITestOutputHelper output, WCFBindingType bindingType, TracingTestOption tracingTestOption, ASPCompatibilityMode aspCompatOption)
     : base(fixture, output, bindingType, tracingTestOption, HostingModel.IIS, aspCompatOption, new WCFLogHelpers_IISHosted(fixture))
 {
 }
Ejemplo n.º 10
0
 public WCFService_IIS_ASPEnabled(ConsoleDynamicMethodFixtureFWLatest fixture, ITestOutputHelper output, WCFBindingType bindingType, TracingTestOption tracingTestOption)
     : base(fixture, output, bindingType, tracingTestOption, ASPCompatibilityMode.Enabled)
 {
 }