Пример #1
0
        public void TestOk()
        {
            var pipeline = PipelineFactory.CreateEmptyReceivePipeline();

            pipeline.AddDocSpec(typeof(TestSchema));

            var validator = new PipelineComponents.HttpXmlValidator.HttpXmlValidator();

            const string msgStr = @"<ns0:Test xmlns:ns0='http://BizTalk_Server_Project3.TestSchema'>
  <RequiredElement>RequiredElement_0</RequiredElement>
  <IntegerElement>10</IntegerElement>
  <OptionalElement>OptionalElement_0</OptionalElement>
</ns0:Test>";

            var message = MessageHelper.CreateFromString(msgStr);

            message.Context.Promote(new ContextProperty(SystemProperties.IsRequestResponse), "true");
            message.Context.Promote(new ContextProperty(SystemProperties.EpmRRCorrelationToken), "token");
            message.Context.Promote(new ContextProperty(SystemProperties.CorrelationToken), "token2");
            message.Context.Promote(new ContextProperty(SystemProperties.ReqRespTransmitPipelineID), "id");


            pipeline.AddComponent(validator, PipelineStage.Validate);

            var result = pipeline.Execute(message);

            Assert.AreEqual(1, result.Count);
            object status;

            Assert.IsFalse(result[0].Context.TryRead(new ContextProperty(WCFProperties.OutboundHttpStatusCode), out status));
        }
        public void TestHappyPath()
        {
            XDocument doc =
                new XDocument(
                    new XElement("Result",
                                 new XElement("param1", "param1value"),
                                 new XElement("param2", "param2value"),
                                 new XElement("param3", "param3value")
                                 )
                    );

            var mock = new Mock <IDbQueryRepository>();

            mock.Setup(s => s.Query("SELECT * FROM Test", "Key")).Returns(doc);

            var    pipeline = PipelineFactory.CreateEmptyReceivePipeline();
            string m        = "<body></body>";

            var message = MessageHelper.CreateFromString(m);

            var component = new PromoteDbQueryResult(mock.Object)
            {
                ConnectionStringConfigKey = "Key",
                ContextPropertyToPromote  = "ns#property",
                Query = "SELECT * FROM Test"
            };

            pipeline.AddComponent(component, PipelineStage.Decode);

            var result = pipeline.Execute(message);


            Assert.AreEqual("param1value", result[0].Context.Read("property", "ns").ToString());
        }
Пример #3
0
        public void TestMapUrlVariableTest()
        {
            var pipeline = PipelineFactory.CreateEmptyReceivePipeline();

            string config = @"<BtsVariablePropertyMapping>
<Variable Name='customerId' PropertyName='CustomerId' PropertyNamespace='http://mypropertyschema' />
<Variable Name='Test' PropertyName='Test' PropertyNamespace='http://mypropertyschema' />
</BtsVariablePropertyMapping>";

            var component = new HttpUrlVariableMapper
            {
                UrlTemplate             = "http://tempuri.org/Customer/{customerId}?test={test}",
                VariablePropertyMapping = config
            };

            pipeline.AddComponent(component, PipelineStage.Decode);

            var message = MessageHelper.Create("<test></test>");

            message.Context.Promote(new ContextProperty("http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties#To"), "http://tempuri.org/Customer/10?test=1");


            var output = pipeline.Execute(message);

            Assert.AreEqual(1, output.Count);

            Assert.AreEqual("10", output[0].Context.Read("CustomerId", "http://mypropertyschema"));
        }
Пример #4
0
        public void TestFailedPreReqRequestResponse()
        {
            var pipeline = PipelineFactory.CreateEmptyReceivePipeline();

            pipeline.AddDocSpec(typeof(TestSchema));

            var validator = new PipelineComponents.HttpXmlValidator.HttpXmlValidator();

            const string msgStr = @"<ns0:Test xmlns:ns0='http://BizTalk_Server_Project3.TestSchema'>
  <RequiredElement>RequiredElement_0</RequiredElement>
  <IntegerElement>10</IntegerElement>
  <OptionalElement>OptionalElement_0</OptionalElement>
</ns0:Test>";

            var message = MessageHelper.CreateFromString(msgStr);

            message.Context.Promote(new ContextProperty(SystemProperties.EpmRRCorrelationToken), "token");
            message.Context.Promote(new ContextProperty(SystemProperties.CorrelationToken), "token2");
            message.Context.Promote(new ContextProperty(SystemProperties.ReqRespTransmitPipelineID), "id");


            pipeline.AddComponent(validator, PipelineStage.Validate);

            var result = pipeline.Execute(message);
        }
        public void CanAddComponentToValidStage()
        {
            ReceivePipelineWrapper pipeline  = PipelineFactory.CreateEmptyReceivePipeline();
            IBaseComponent         component = new XmlDasmComp();

            pipeline.AddComponent(component, PipelineStage.Disassemble);
        }
        public void ThrowExceptionWhenComponentAddedToInvalidStage()
        {
            ReceivePipelineWrapper pipeline        = PipelineFactory.CreateEmptyReceivePipeline();
            IBaseComponent         partyResolution = new PartyRes();

            pipeline.AddComponent(partyResolution, PipelineStage.PreAssemble);
        }
        public void CreateMessageWithBodyAndNamespaceTest()
        {
            var pipeline = PipelineFactory.CreateEmptyReceivePipeline();

            pipeline.AddDocSpec(typeof(TestSchema));

            var disassembler = new PipelineComponents.HttpDisassembler.HttpDisassembler
            {
                DocumentSpecName = "BizTalkComponents.HttpDisassembler.Tests.UnitTests.TestSchema"
            };
            string testMessage = "<testmessage xmlns=\"testns\"></testmessage>";
            var    message     = MessageHelper.CreateFromString(testMessage);

            message.Context.Promote(new ContextProperty("http://BiztalkComponents.PropertySchema#TestProperty1"), "value1");
            message.Context.Promote(new ContextProperty("http://BiztalkComponents.PropertySchema#TestProperty2"), "value2");

            pipeline.AddComponent(disassembler, PipelineStage.Disassemble);

            var result = pipeline.Execute(message);

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(2, result[0].PartCount);

            var doc     = XDocument.Load(result[0].GetPart("querypart").GetOriginalDataStream());
            var bodyDoc = XDocument.Load(result[0].BodyPart.GetOriginalDataStream());

            Assert.IsTrue(result[0].Context.IsPromoted("MessageType", "http://schemas.microsoft.com/BizTalk/2003/system-properties"));
            Assert.AreEqual("testns#testmessage", result[0].Context.Read("MessageType", "http://schemas.microsoft.com/BizTalk/2003/system-properties"));
        }
        public void CreateMessageWithBodyTest()
        {
            var pipeline = PipelineFactory.CreateEmptyReceivePipeline();

            pipeline.AddDocSpec(typeof(TestSchema));

            var disassembler = new PipelineComponents.HttpDisassembler.HttpDisassembler
            {
                DocumentSpecName = "BizTalkComponents.HttpDisassembler.Tests.UnitTests.TestSchema"
            };
            string testMessage = "<testmessage></testmessage>";
            var    message     = MessageHelper.CreateFromString(testMessage);

            message.Context.Promote(new ContextProperty("http://BiztalkComponents.PropertySchema#TestProperty1"), "value1");
            message.Context.Promote(new ContextProperty("http://BiztalkComponents.PropertySchema#TestProperty2"), "value2");

            pipeline.AddComponent(disassembler, PipelineStage.Disassemble);

            var result = pipeline.Execute(message);

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(2, result[0].PartCount);

            var doc     = XDocument.Load(result[0].GetPart("querypart").GetOriginalDataStream());
            var bodyDoc = XDocument.Load(result[0].BodyPart.GetOriginalDataStream());

            Assert.AreEqual("value1", doc.Descendants("TestElement1").Single().Value);
            Assert.AreEqual("value2", doc.Descendants("TestElement2").Single().Value);
            Assert.AreEqual(testMessage, bodyDoc.ToString());
        }
Пример #9
0
        public void CanCreateEmptyReceivePipeline()
        {
            ReceivePipelineWrapper receivePipeline =
                PipelineFactory.CreateEmptyReceivePipeline();

            Assert.IsNotNull(receivePipeline);
        }
        public void ThrowExceptionWhenCompponentAddedToNullStage()
        {
            ReceivePipelineWrapper pipeline        = PipelineFactory.CreateEmptyReceivePipeline();
            IBaseComponent         partyResolution = new PartyRes();

            pipeline.AddComponent(partyResolution, null);
        }
Пример #11
0
        private static ReceivePipelineWrapper GeneratePipeline()
        {
            var pipeline = PipelineFactory.CreateEmptyReceivePipeline();

            pipeline.AddComponent(new RushOrderMarker(), PipelineStage.Decode);

            return(pipeline);
        }
        public void CanAddNoTargetNSDocSpec()
        {
            ReceivePipelineWrapper pipeline =
                PipelineFactory.CreateEmptyReceivePipeline();

            pipeline.AddDocSpec(typeof(NoNS));

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

            Assert.IsNotNull(docSpec);
        }
Пример #13
0
        public void TestFullRootNodeTag()
        {
            var pipeline  = PipelineFactory.CreateEmptyReceivePipeline();
            var component = new EnsureRootNodeFullTag();

            pipeline.AddComponent(component, PipelineStage.Decode);
            var message = MessageHelper.CreateFromString(@"<TestMessage xmlns=""https://someschema""><Field1/></TestMessage>");
            var output  = pipeline.Execute(message);
            var retStr  = MessageHelper.ReadString(message);

            Assert.IsTrue(retStr.EndsWith(@"</TestMessage>"));
        }
        public void Setup()
        {
            rcvpipeline = PipelineFactory.CreateEmptyReceivePipeline();
            XmlDasmComp xmlDasmComp = new XmlDasmComp();

            rcvpipeline.AddComponent(xmlDasmComp, PipelineStage.Disassemble);

            sndpipeline = PipelineFactory.CreateEmptySendPipeline();

            if (!File.Exists(googlecredentials))
            {
            }
        }
        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);
        }
Пример #16
0
        public void TestChangeInvalidEncoding()
        {
            var pipeline = PipelineFactory.CreateEmptyReceivePipeline();

            var setCharset = new SetCharset
            {
                TargetCharset = "invalid"
            };

            var message = MessageHelper.CreateFromString("<test></test>");

            pipeline.AddComponent(setCharset, PipelineStage.Decode);
            var result = pipeline.Execute(message);
        }
        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);
        }
Пример #18
0
        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 PromoteConstantValuesWithWrongFormat()
        {
            var pipeline  = PipelineFactory.CreateEmptyReceivePipeline();
            var component = new BizTalkComponents.PipelineComponents.PromoteConstantValues.PromoteConstantValues
            {
                Enabled = true,
                PropertyValuePairArray = @"{http://test/property1,someva}"
            };

            pipeline.AddComponent(component, PipelineStage.Validate);
            var message = MessageHelper.Create("");
            var ret     = pipeline.Execute(message);

            Assert.IsTrue(message.Context.IsPromoted("property1", "http://test"));
            Assert.IsTrue(message.Context.IsPromoted("property2", "http://namespacetest"));
            Assert.IsTrue(message.Context.IsPromoted("property3", "http://testing"));
        }
        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);
        }
Пример #21
0
        public void TestInvalidXpath()
        {
            var    pipeline = PipelineFactory.CreateEmptyReceivePipeline();
            string m        = "<body></body>";

            var b64     = Convert.ToBase64String(Encoding.UTF8.GetBytes(m));
            var message = MessageHelper.CreateFromString(string.Format("<envelope><msg>{0}</msg></envelope>", b64));

            var disassembler = new PipelineComponents.Base64Disassembler.Base64Disassembler
            {
                Xpath = "/invalid/msg"
            };

            pipeline.AddComponent(disassembler, PipelineStage.Disassemble);

            var result = pipeline.Execute(message);
        }
Пример #22
0
        public void TestChangeEncoding()
        {
            var pipeline = PipelineFactory.CreateEmptyReceivePipeline();

            var setCharset = new SetCharset
            {
                TargetCharset = "iso-8859-1"
            };

            var message = MessageHelper.CreateFromString("<test></test>");

            pipeline.AddComponent(setCharset, PipelineStage.Decode);
            var result = pipeline.Execute(message);

            Assert.AreEqual(1, result.Count);

            Assert.AreEqual("iso-8859-1", result[0].BodyPart.Charset);
        }
        public void AddUNH25()
        {
            var pipeline  = PipelineFactory.CreateEmptyReceivePipeline();
            var component = new EFactSchemaCustomizer
            {
                CharSet           = "utf-8",
                Enabled           = true,
                EfactDelimiters   = "0x3A, 0x2B, 0x2C, 0x3F, 0x20, 0x27",
                RootNodeExtension = "Test",
            };

            pipeline.AddComponent(component, PipelineStage.Decode);

            var stream  = new FileStream(@"D:\TFS\Ovako\Repos\INT0063.SalesOrder\Tests\Test Files\201709080520528498.edi", FileMode.Open);
            var message = MessageHelper.CreateFromStream(stream);
            var output  = pipeline.Execute(message);
            var test    = MessageHelper.ReadString(message);
        }
        public void TestNoMatchThrow()
        {
            var pipeline  = PipelineFactory.CreateEmptyReceivePipeline();
            var component = new SetPropertyFromXPath
            {
                PropertyPath    = "http://tempuri.org#MyProp",
                XPath           = "/root/test/wrong",
                PromoteProperty = true,
                ThrowIfNoMatch  = true
            };

            pipeline.AddComponent(component, PipelineStage.Decode);

            var message = MessageHelper.Create("<root><test>TestValue</test></root>");

            message.Context.Promote(new ContextProperty("http://tempuri.org#Source"), "Test");

            var output = pipeline.Execute(message);
        }
Пример #25
0
        public void CanProvideStageIDsInContext()
        {
            var pipeline = PipelineFactory.CreateEmptyReceivePipeline();
            var stages   = new List <Guid>();

            pipeline.AddComponent(new ReceiveStageTest(stages), PipelineStage.Decode);
            pipeline.AddComponent(new ReceiveStageTest(stages), PipelineStage.Disassemble);
            pipeline.AddComponent(new ReceiveStageTest(stages), PipelineStage.Validate);
            pipeline.AddComponent(new ReceiveStageTest(stages), PipelineStage.ResolveParty);

            var inputMessage   = MessageHelper.CreateFromString("<sample/>");
            var outputMessages = pipeline.Execute(inputMessage);

            Assert.AreEqual(4, stages.Count);
            Assert.AreEqual(PipelineStage.Decode.ID, stages[0]);
            Assert.AreEqual(PipelineStage.Disassemble.ID, stages[1]);
            Assert.AreEqual(PipelineStage.Validate.ID, stages[2]);
            Assert.AreEqual(PipelineStage.ResolveParty.ID, stages[3]);
        }
Пример #26
0
        public void TestMissingRequiredField()
        {
            var pipeline = PipelineFactory.CreateEmptyReceivePipeline();

            pipeline.AddDocSpec(typeof(TestSchema));

            var validator = new PipelineComponents.HttpXmlValidator.HttpXmlValidator();

            const string msgStr = @"<ns0:Test xmlns:ns0='http://BizTalk_Server_Project3.TestSchema'>
  <IntegerElement>10</IntegerElement>
  <OptionalElement>OptionalElement_0</OptionalElement>
</ns0:Test>";

            var message = MessageHelper.CreateFromString(msgStr);

            message.Context.Promote(new ContextProperty(SystemProperties.IsRequestResponse), "true");
            message.Context.Promote(new ContextProperty(SystemProperties.EpmRRCorrelationToken), "token");
            message.Context.Promote(new ContextProperty(SystemProperties.CorrelationToken), "token2");
            message.Context.Promote(new ContextProperty(SystemProperties.ReqRespTransmitPipelineID), "id");


            pipeline.AddComponent(validator, PipelineStage.Validate);

            var result = pipeline.Execute(message);

            Assert.AreEqual(1, result.Count);
            Assert.IsTrue(result[0].Context.IsPromoted(new ContextProperty(SystemProperties.IsRequestResponse)));
            Assert.IsTrue(result[0].Context.IsPromoted(new ContextProperty(SystemProperties.RouteDirectToTP)));
            Assert.IsTrue(result[0].Context.IsPromoted(new ContextProperty(SystemProperties.EpmRRCorrelationToken)));
            Assert.IsTrue(result[0].Context.IsPromoted(new ContextProperty(SystemProperties.CorrelationToken)));
            Assert.IsTrue(result[0].Context.IsPromoted(new ContextProperty(SystemProperties.ReqRespTransmitPipelineID)));
            Assert.AreEqual("400", result[0].Context.Read(new ContextProperty(WCFProperties.OutboundHttpStatusCode)));

            string msg;

            using (var sr = new StreamReader(result[0].BodyPart.GetOriginalDataStream()))
            {
                msg = sr.ReadToEnd();
            }

            Assert.IsFalse(string.IsNullOrWhiteSpace(msg));
        }
        public void InjectMessageContextAsComment()
        {
            var pipeline  = PipelineFactory.CreateEmptyReceivePipeline();
            var component = new MessageContextCopier {
                Enabled = true,
                ShowPropertyInfoAsNodes = true,
                SelectedProperties      = "http://schemas.microsoft.com/BizTalk/2003/file-properties#ReceivedFileName;http://schemas.microsoft.com/BizTalk/2003/system-properties#SchemaStrongName;"
            };

            pipeline.AddComponent(component, PipelineStage.Decode);
            var message = MessageHelper.CreateFromString(@"<TestMessage><node1><node2>value</node2></node1></TestMessage>");

            message.Context.Promote(new ContextProperty(FileProperties.ReceivedFileName), "FileName");
            message.Context.Write(new ContextProperty(SystemProperties.SchemaStrongName), "testschema");
            message.Context.Promote(new ContextProperty(SystemProperties.IsRequestResponse), "true");
            var output = pipeline.Execute(message);
            var retStr = MessageHelper.ReadString(message);

            Assert.IsFalse(retStr.Contains(@"<messagecontex>"));
        }
        public void TestJsonArrayJSONDecoder()
        {
            var pipeline  = PipelineFactory.CreateEmptyReceivePipeline();
            var component = new JSONDecoder {
                ArrayNodeName     = "Event",
                RootNode          = "Events",
                RootNodeNamespace = "Http://JsonDecoderTester/TestEvents"
            };

            pipeline.AddComponent(component, PipelineStage.Decode);
            var message = MessageHelper.CreateFromStream(TestHelper.GetTestStream("large.json"));
            var output  = pipeline.Execute(message);
            var retstr  = MessageHelper.ReadString(output[0]);
            var doc     = new XmlDocument();

            doc.LoadXml(retstr);
            var arr = doc.SelectNodes("/*[local-name()='Events']/*[local-name()='Event']");

            Assert.AreEqual(arr.Count, doc.DocumentElement.ChildNodes.Count);
        }
Пример #29
0
        public void TestPromoteKeyValueLookupResultInvalidKey()
        {
            var component = new SharepointPromoteKeyValueLookupResult(mock.Object)
            {
                DestinationPropertyPath = "NS#DestProp",
                ListName           = "TestList",
                SourcePropertyPath = "NS#SrcProp"
            };

            var    pipeline = PipelineFactory.CreateEmptyReceivePipeline();
            string m        = "<body></body>";

            var message = MessageHelper.CreateFromString(m);

            message.Context.Promote("SrcProp", "NS", "NonExisting");

            pipeline.AddComponent(component, PipelineStage.Decode);

            var result = pipeline.Execute(message);
        }
        public void UnknownDocType()
        {
            var pipeline = PipelineFactory.CreateEmptyReceivePipeline();

            pipeline.AddDocSpec(typeof(TestSchema));

            var disassembler = new PipelineComponents.HttpDisassembler.HttpDisassembler
            {
                DocumentSpecName = "Schema"
            };

            var message = MessageHelper.CreateFromString(string.Empty);

            message.Context.Promote(new ContextProperty("http://BiztalkComponents.PropertySchema#TestProperty1"), "value1");
            message.Context.Promote(new ContextProperty("http://BiztalkComponents.PropertySchema#TestProperty2"), "value2");

            pipeline.AddComponent(disassembler, PipelineStage.Disassemble);

            var result = pipeline.Execute(message);
        }