public void CanExecuteLoadedPipeline()
        {
            ReceivePipelineWrapper pipeline =
                PipelineFactory.CreateReceivePipeline(typeof(ReceivePipeline1));

            // Create the input message to pass through the pipeline
            Stream       stream       = DocLoader.LoadStream("SampleDocument.xml");
            IBaseMessage inputMessage = MessageHelper.CreateFromStream(stream);

            // Add the necessary schemas to the pipeline, so that
            // disassembling works
            pipeline.AddDocSpec(typeof(Schema1_NPP));
            pipeline.AddDocSpec(typeof(Schema2_WPP));

            // Execute the pipeline, and check the output
            MessageCollection outputMessages = pipeline.Execute(inputMessage);

            Assert.IsNotNull(outputMessages);
            Assert.IsTrue(outputMessages.Count > 0);
            // check we promoted properties correctly
            const string ns = "http://SampleSchemas.PropSchema1";

            Assert.IsTrue(PropertyExists(outputMessages[0], ns, "Property1"));
            Assert.IsTrue(PropertyExists(outputMessages[0], ns, "Property1"));
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a pipeline component to the disassembling stage
        /// </summary>
        /// <param name="disassembler">The component to add</param>
        /// <returns>This instance</returns>
        public ReceivePipelineBuilder WithDisassembler(Disassembler disassembler)
        {
            if (disassembler == null)
            {
                throw new ArgumentNullException("disassembler");
            }
            _pipeline.AddComponent(disassembler.End(), PipelineStage.Disassemble);

            foreach (Type schemaType in disassembler.KnownSchemas)
            {
                _pipeline.AddDocSpec(schemaType);
            }

            return(this);
        }
Esempio n. 3
0
        protected void ContextPropertyExtractorPromotesConstant(ReceivePipelineWrapper pipeline)
        {
            const string content = "<ns0:Root xmlns:ns0=\"http://schemas.microsoft.com/BizTalk/2003/Any\"><message>content</message></ns0:Root>";

            using (var stream = new StringStream(content))
            {
                pipeline.AddDocSpec(typeof(Any));
                var microPipeline = (MicroPipelineComponent)pipeline.GetComponent(PipelineStage.Decode, 1);
                microPipeline.Components = new[] {
                    new ContextPropertyExtractor {
                        Extractors = new[] {
                            new ConstantExtractor(BizTalkFactoryProperties.EnvironmentTag.QName, "tag", ExtractionMode.Promote)
                        }
                    }
                };

                var inputMessage = MessageHelper.CreateFromStream(stream);
                inputMessage.GetProperty(BizTalkFactoryProperties.EnvironmentTag).Should().BeNull();
                inputMessage.IsPromoted(BizTalkFactoryProperties.EnvironmentTag).Should().BeFalse();

                var outputMessages = pipeline.Execute(inputMessage);

                outputMessages[0].GetProperty(BizTalkFactoryProperties.EnvironmentTag).Should().Be("tag");
                outputMessages[0].IsPromoted(BizTalkFactoryProperties.EnvironmentTag).Should().BeTrue();
                using (var reader = new StreamReader(outputMessages[0].BodyPart.Data))
                {
                    var readOuterXml = reader.ReadToEnd();
                    readOuterXml.Should().Be(content);
                }
                outputMessages[0].GetProperty(BizTalkFactoryProperties.EnvironmentTag).Should().Be("tag");
                outputMessages[0].IsPromoted(BizTalkFactoryProperties.EnvironmentTag).Should().BeTrue();
            }
        }
        public void CanExecutePipelineWithMultiMsgOutput()
        {
            ReceivePipelineWrapper pipeline = PipelineFactory.CreateEmptyReceivePipeline();

            pipeline.AddComponent(new XmlDasmComp(), PipelineStage.Disassemble);

            pipeline.AddDocSpec(typeof(SimpleBody));
            pipeline.AddDocSpec(typeof(SimpleEnv));

            Stream       stream       = DocLoader.LoadStream("Env_Batch_Input.xml");
            IBaseMessage inputMessage = MessageHelper.CreateFromStream(stream);

            MessageCollection outputMessages = pipeline.Execute(inputMessage);

            Assert.IsNotNull(outputMessages);
            Assert.AreEqual(3, outputMessages.Count);
        }
        public void CanAddNoTargetNSDocSpec()
        {
            ReceivePipelineWrapper pipeline =
                PipelineFactory.CreateEmptyReceivePipeline();

            pipeline.AddDocSpec(typeof(NoNS));

            IDocumentSpec docSpec = pipeline.GetKnownDocSpecByType("Root");

            Assert.IsNotNull(docSpec);
        }
        public void TestGoogleBucket()
        {
            IBaseMessage msg = MessageHelper.CreateFromString(Resource.GoogleBucketEntry_1);

            rcvpipeline.AddDocSpec(typeof(Schemas.BucketClaimCheck));



            MessageCollection messages = rcvpipeline.Execute(msg);

            IBaseMessage message = messages[0];



            ClaimCheckPipelineComponent claimCheckPipelineComponent = new ClaimCheckPipelineComponent();

            claimCheckPipelineComponent.Enabled            = true;
            claimCheckPipelineComponent.ClientId           = "111382948100122064143";
            claimCheckPipelineComponent.ServiceAccountName = "*****@*****.**";
            FileInfo credentials  = new FileInfo(googlecredentials);
            var      jsonfilepath = credentials.FullName;

            claimCheckPipelineComponent.ServiceAccountKey = jsonfilepath;



            sndpipeline.AddComponent(claimCheckPipelineComponent, PipelineStage.Encode);

            IBaseMessage sendmessage = sndpipeline.Execute(messages);



            Diff myDiff = DiffBuilder.Compare(Input.FromString(Resource.GoogleBucketResult))
                          .WithTest(Input.FromStream(sendmessage.BodyPart.Data))
                          .CheckForIdentical().Build();


            Assert.IsFalse(myDiff.HasDifferences());
        }
        public void CanAddDocSpecByName()
        {
            ReceivePipelineWrapper pipeline = PipelineFactory.CreateEmptyReceivePipeline();

            pipeline.AddDocSpec("SampleSchemas.Schema1_NPP+Root", "SampleSchemas");

            IDocumentSpec docSpec =
                pipeline.GetKnownDocSpecByName(typeof(Schema1_NPP.Root).AssemblyQualifiedName);

            Assert.IsNotNull(docSpec);

            docSpec = pipeline.GetKnownDocSpecByType("http://SampleSchemas.Schema1_NPP#Root");
            Assert.IsNotNull(docSpec);
        }
        private static ReceivePipelineWrapper GeneratePipeline(string customPropertyNamespace, bool excludeSystemProperties)
        {
            PropertyMessageDecoder propertyMessageDecoder = new PropertyMessageDecoder();

            propertyMessageDecoder.CustomPropertyNamespace = customPropertyNamespace;
            propertyMessageDecoder.ExcludeSystemProperties = excludeSystemProperties;

            ReceivePipelineWrapper pipeline = PipelineFactory.CreateEmptyReceivePipeline();

            pipeline.AddComponent(propertyMessageDecoder, PipelineStage.Decode);
            pipeline.AddComponent(new Microsoft.BizTalk.Component.XmlDasmComp(), PipelineStage.Disassemble);
            pipeline.AddDocSpec(typeof(PropertyMessage));

            return(pipeline);
        }
        public void CanExecutePipelineWithFlatFile()
        {
            ReceivePipelineWrapper pipeline =
                PipelineFactory.CreateReceivePipeline(typeof(CSV_FF_RecvPipeline));

            // Create the input message to pass through the pipeline
            Stream       stream       = DocLoader.LoadStream("CSV_FF_RecvInput.txt");
            IBaseMessage inputMessage = MessageHelper.CreateFromStream(stream);

            inputMessage.BodyPart.Charset = "UTF-8";

            // Add the necessary schemas to the pipeline, so that
            // disassembling works
            pipeline.AddDocSpec(typeof(Schema3_FF));

            // Execute the pipeline, and check the output
            MessageCollection outputMessages = pipeline.Execute(inputMessage);

            Assert.IsNotNull(outputMessages);
            Assert.IsTrue(outputMessages.Count > 0);
        }
        public void ThrowExceptionWhenNullDocSpecAdded()
        {
            ReceivePipelineWrapper pipeline = PipelineFactory.CreateEmptyReceivePipeline();

            pipeline.AddDocSpec(null);
        }