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"));
        }
        public void ThrowExceptionWhenInputMsgIsNull()
        {
            ReceivePipelineWrapper pipeline =
                PipelineFactory.CreateReceivePipeline(typeof(ReceivePipeline1));

            pipeline.Execute(null);
        }
Beispiel #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 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());
        }
        private static Stream Parse(Disassembler component, Stream inputDocument)
        {
            ReceivePipelineWrapper pipeline = Pipelines.Receive()
                                              .WithDisassembler(component);
            MessageCollection output = pipeline.Execute(
                MessageHelper.CreateFromStream(inputDocument)
                );

            if (output.Count > 0)
            {
                return(output[0].BodyPart.GetOriginalDataStream());
            }
            return(null);
        }
Beispiel #6
0
        public void Receive_WithPromotedProps()
        {
            ReceivePipelineWrapper pipeline = Pipelines.Xml.Receive()
                                              .WithSpec <Schema2_WPP>();

            IBaseMessage input = MessageHelper.CreateFromStream(
                DocLoader.LoadStream("SampleDocument.xml")
                );
            MessageCollection output = pipeline.Execute(input);

            Property2 prop  = new Property2();
            object    value = output[0].Context.Read(prop.QName.Name, prop.QName.Namespace);

            Assert.AreEqual("Field2_0", value);
        }
Beispiel #7
0
        public void Receive_FullPipeline()
        {
            FFDisassembler ff = Disassembler.FlatFile()
                                .WithDocumentSpec <Schema3_FF>();
            ReceivePipelineWrapper pipeline = Pipelines.Receive()
                                              .WithDisassembler(ff);

            IBaseMessage input = MessageHelper.CreateFromStream(
                DocLoader.LoadStream("CSV_FF_RecvInput.txt")
                );

            MessageCollection output = pipeline.Execute(input);

            Assert.AreEqual(1, output.Count);
        }
        public void CanExecuteEmptyPipeline()
        {
            ReceivePipelineWrapper pipeline =
                PipelineFactory.CreateEmptyReceivePipeline();

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

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

            Assert.IsNotNull(outputMessages);
            Assert.IsTrue(outputMessages.Count > 0);
        }
        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 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);
        }