Пример #1
0
        public void CanExecutePipelineWithMultiInputMsgs()
        {
            SendPipelineWrapper pipeline =
                PipelineFactory.CreateSendPipeline(typeof(Env_SendPipeline));

            // Create the input message to pass through the pipeline
            string body =
                @"<o:Body xmlns:o='http://SampleSchemas.SimpleBody'>
               this is a body</o:Body>";

            // Add the necessary schemas to the pipeline, so that
            // assembling works
            pipeline.AddDocSpec(typeof(SimpleBody));
            pipeline.AddDocSpec(typeof(SimpleEnv));

            // original code:
            // MessageCollection inputMessages = new MessageCollection();
            // inputMessages.Add(MessageHelper.CreateFromString(body));
            // inputMessages.Add(MessageHelper.CreateFromString(body));
            // inputMessages.Add(MessageHelper.CreateFromString(body));

            // Execute the pipeline, and check the output
            // we get a single message batched with all the
            // messages grouped into the envelope's body
            IBaseMessage outputMessage = pipeline.Execute(
                MessageHelper.CreateFromString(body),
                MessageHelper.CreateFromString(body),
                MessageHelper.CreateFromString(body)
                );

            Assert.IsNotNull(outputMessage);
        }
Пример #2
0
        public void CanCreateSendPipelineFromType()
        {
            SendPipelineWrapper sendPipeline =
                PipelineFactory.CreateSendPipeline(typeof(XMLTransmit));

            Assert.IsNotNull(sendPipeline);
        }
Пример #3
0
        public void CanCreateTransaction()
        {
            SendPipelineWrapper pipeline =
                PipelineFactory.CreateSendPipeline(typeof(XMLTransmit));

            using (TransactionControl control = pipeline.EnableTransactions())
            {
                // 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));

                MessageCollection inputMessages = new MessageCollection();
                inputMessages.Add(inputMessage);

                // Execute the pipeline, and check the output
                IBaseMessage outputMessage = pipeline.Execute(inputMessages);

                Assert.IsNotNull(outputMessage);
                control.SetComplete();
            }
        }
Пример #4
0
        public void ThrowExceptionWhenInputMsgCollectionIsEmpty()
        {
            SendPipelineWrapper pipeline =
                PipelineFactory.CreateSendPipeline(typeof(XMLTransmit));

            pipeline.Execute(new MessageCollection());
        }
Пример #5
0
        public void ThrowExceptionWhenInputMsgIsNull()
        {
            SendPipelineWrapper pipeline =
                PipelineFactory.CreateSendPipeline(typeof(XMLTransmit));

            pipeline.Execute((MessageCollection)null);
        }
        public void TestPipeline()
        {
            IBaseMessage msg = MessageHelper.CreateFromString(Resource.GoogleBucketEntry_1);

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



            MessageCollection messages = rcvpipeline.Execute(msg);

            IBaseMessage message = messages[0];



            SendPipelineWrapper snddirectpipeline = PipelineFactory.CreateSendPipeline(typeof(Pipelines.ClaimCheckSendPipeline));



            IBaseMessage sendmessage = snddirectpipeline.Execute(messages);



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


            Assert.IsFalse(myDiff.HasDifferences());
        }
Пример #7
0
        public void CanExecutePipelineWithFlatFile()
        {
            SendPipelineWrapper pipeline =
                PipelineFactory.CreateSendPipeline(typeof(CSV_FF_SendPipeline));

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

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

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

            MessageCollection inputMessages = new MessageCollection();

            inputMessages.Add(inputMessage);

            // Execute the pipeline, and check the output
            IBaseMessage outputMessage = pipeline.Execute(inputMessages);

            Assert.IsNotNull(outputMessage);
        }
Пример #8
0
 public void ThrowExceptionWhenNullSendPipelineCreated()
 {
     PipelineFactory.CreateSendPipeline(null);
 }
Пример #9
0
 public void ThrowExceptionWhenInvalidTypeForSendPipeline()
 {
     PipelineFactory.CreateSendPipeline(typeof(XMLReceive));
 }
Пример #10
0
        /// <summary>
        /// TestStepBase.Execute() implementation
        /// </summary>
        /// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
        public override void Execute(Context context)
        {
            if (_docSpecsRawList.Count > 0)
            {
                var ds = new List <Type>(_docSpecsRawList.Count);
                foreach (var docSpec in _docSpecsRawList)
                {
                    var ass = AssemblyHelper.LoadAssembly((string)docSpec.AssemblyPath);
                    context.LogInfo("Loading DocumentSpec {0} from location {1}.", docSpec.TypeName, ass.Location);
                    var type = ass.GetType(docSpec.TypeName);

                    ds.Add(type);
                }
                _docSpecs = ds.ToArray();
            }

            context.LogInfo("Loading pipeline {0} from location {1}.", _pipelineTypeName, _pipelineAssemblyPath);
            var pipelineType = ObjectCreator.GetType(_pipelineTypeName, _pipelineAssemblyPath);

            var pipelineWrapper = PipelineFactory.CreateSendPipeline(pipelineType);

            if (!string.IsNullOrEmpty(_instanceConfigFile))
            {
                pipelineWrapper.ApplyInstanceConfig(_instanceConfigFile);
            }

            if (null != _docSpecs)
            {
                foreach (Type docSpec in _docSpecs)
                {
                    pipelineWrapper.AddDocSpec(docSpec);
                }
            }

            var mc = new MessageCollection();

            FileInfo[] contexts = null;
            if (!string.IsNullOrEmpty(_inputContextDir) && !string.IsNullOrEmpty(_inputContextSearchPattern))
            {
                var cdi = new DirectoryInfo(_inputContextDir);
                contexts = cdi.GetFiles(_inputContextSearchPattern);
            }

            var di    = new DirectoryInfo(_sourceDir);
            int index = 0;

            foreach (FileInfo fi in di.GetFiles(_searchPattern))
            {
                Stream stream       = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read);
                var    inputMessage = MessageHelper.CreateFromStream(stream);
                if (!string.IsNullOrEmpty(_sourceEncoding))
                {
                    inputMessage.BodyPart.Charset = _sourceEncoding;
                }

                // Load context file, add to message context.
                if ((null != contexts) && (contexts.Length > index))
                {
                    string cf = contexts[index].FullName;
                    if (System.IO.File.Exists(cf))
                    {
                        MessageInfo mi = MessageInfo.Deserialize(cf);
                        mi.MergeIntoMessage(inputMessage);
                    }
                }

                mc.Add(inputMessage);
                index++;
            }

            var outputMsg = pipelineWrapper.Execute(mc);

            PersistMessageHelper.PersistMessage(outputMsg, _destination);

            if (!string.IsNullOrEmpty(_outputContextFile))
            {
                var omi = BizTalkMessageInfoFactory.CreateMessageInfo(outputMsg, _destination);
                MessageInfo.Serialize(omi, _outputContextFile);
            }
        }
 internal SendPipelineBuilder(Type type)
 {
     _pipeline = PipelineFactory.CreateSendPipeline(type);
 }