public void TestSuccessful() { var keyStr = "AAECAwQFBgcICQoLDA0ODw=="; var pipeline = PipelineFactory.CreateEmptySendPipeline(); var em = new EncryptMessage { EncryptionKey = keyStr }; pipeline.AddComponent(em, PipelineStage.Encode); var message = MessageHelper.Create("<test></test>"); var output = pipeline.Execute(message); var result = DecryptMessage(output.BodyPart.Data, keyStr); string re; using (var sr = new StreamReader(result)) { re = sr.ReadToEnd(); } re = re.Replace("\0", ""); Assert.AreEqual("<test></test>", re); }
private void btnRun_Click(object sender, EventArgs e) { string Key = txtKey.Text; string PropertyPath = txtPropertyPath.Text; string DestinationPath = txtDestinationPath.Text; string ListName = txtListName.Text; IBaseMessage message = MessageHelper.CreateFromString("<testfile/>"); message.Context.Promote(new ContextProperty(PropertyPath), Key); var component = new SharepointLookup() { Disabled = false, PropertyPath = PropertyPath, DestinationPath = DestinationPath, ListName = ListName, ThrowException = true, PromoteProperty = true }; SendPipelineWrapper sendPipeline = PipelineFactory.CreateEmptySendPipeline(); sendPipeline.AddComponent(component, PipelineStage.PreAssemble); IBaseMessage results = sendPipeline.Execute(message); string result = (string)results.Context.Read(new ContextProperty(DestinationPath)); txtResult.Text = result; }
public void CanSetSigningCertificate() { SendPipelineWrapper pipeline = PipelineFactory.CreateEmptySendPipeline(); pipeline.GroupSigningCertificate = "whatever"; Assert.IsNotNull(pipeline.GroupSigningCertificate); }
public void CanAddComponentToValidStage() { SendPipelineWrapper pipeline = PipelineFactory.CreateEmptySendPipeline(); IBaseComponent encoder = new MIME_SMIME_Encoder(); pipeline.AddComponent(encoder, PipelineStage.Encode); }
public void ThrowExceptionWhenComponentAddedToInvalidStage() { SendPipelineWrapper pipeline = PipelineFactory.CreateEmptySendPipeline(); IBaseComponent encoder = new MIME_SMIME_Encoder(); pipeline.AddComponent(encoder, PipelineStage.ResolveParty); }
public void TestCompressWithReceivedFilename() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new CompressMessage(); var msgPart2 = MessageHelper.CreatePartFromString("<testmessage2></testmessage2>"); var msgPart3 = MessageHelper.CreatePartFromString("<testmessage3></testmessage3>"); msgPart2.PartProperties.Write("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", "invoice2.xml"); msgPart3.PartProperties.Write("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", "invoice3.xml"); var msg = MessageHelper.CreateFromString("<testmessage1></testmessage1>"); msg.AddPart("invoice2", msgPart2, false); msg.AddPart("invoice3", msgPart3, false); msg.BodyPart.PartProperties.Write("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", "invoice1.xml"); pipeline.AddComponent(component, PipelineStage.Encode); var result = pipeline.Execute(msg); int i = 1; ZipArchive zipArchive = new ZipArchive(result.BodyPart.GetOriginalDataStream()); foreach (var zipEntry in zipArchive.Entries) { Assert.AreEqual(string.Format("invoice{0}.xml", i), zipEntry.Name); using (var reader = new StreamReader(zipEntry.Open(), Encoding.Unicode)) { Assert.AreEqual(string.Format("<testmessage{0}></testmessage{0}>", i), reader.ReadToEnd()); } i++; } }
public void CanCreateEmptySendPipeline() { SendPipelineWrapper sendPipeline = PipelineFactory.CreateEmptySendPipeline(); Assert.IsNotNull(sendPipeline); }
public void TestCompressWithContentType() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new CompressMessage(); var msgPart2 = MessageHelper.CreatePartFromString("<testmessage2></testmessage2>"); var msgPart3 = MessageHelper.CreatePartFromString("<testmessage3></testmessage3>"); msgPart2.ContentType = "application/xml"; msgPart3.ContentType = "application/xml"; var msg = MessageHelper.CreateFromString("<testmessage1></testmessage1>"); msg.AddPart("invoice2", msgPart2, false); msg.AddPart("invoice3", msgPart3, false); msg.BodyPart.ContentType = "application/xml"; pipeline.AddComponent(component, PipelineStage.Encode); var result = pipeline.Execute(msg); int i = 1; ZipArchive zipArchive = new ZipArchive(result.BodyPart.GetOriginalDataStream()); foreach (var zipEntry in zipArchive.Entries) { Guid g; Assert.IsTrue(Guid.TryParse(Path.GetFileNameWithoutExtension(zipEntry.Name), out g)); Assert.AreEqual(".xml", Path.GetExtension(zipEntry.Name)); using (var reader = new StreamReader(zipEntry.Open(), Encoding.Unicode)) { Assert.AreEqual(string.Format("<testmessage{0}></testmessage{0}>", i), reader.ReadToEnd()); } i++; } }
public void TestCompressSingleMessagePart() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new CompressMessage { DefaultZipEntryFileExtension = "xml" }; string messageContent = "<testmessage1></testmessage1>"; var msg = MessageHelper.CreateFromString(messageContent); pipeline.AddComponent(component, PipelineStage.Encode); var result = pipeline.Execute(msg); ZipArchive zipArchive = new ZipArchive(result.BodyPart.GetOriginalDataStream()); Assert.AreEqual(1, zipArchive.Entries.Count); ZipArchiveEntry zipEntry = zipArchive.Entries[0]; Guid g; Assert.IsTrue(Guid.TryParse(Path.GetFileNameWithoutExtension(zipEntry.Name), out g)); Assert.AreEqual(".xml", Path.GetExtension(zipEntry.Name)); using (var reader = new StreamReader(zipEntry.Open(), Encoding.Unicode)) { Assert.AreEqual(messageContent, reader.ReadToEnd()); } }
public void TestHappyPath() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); pipeline.AddDocSpec(typeof(SchemaMock)); var assembler = new PipelineComponents.Base64Assembler.Base64Assembler { DocumentSpecName = "BizTalkComponents.Base64Assembler.Tests.UnitTests.SchemaMock", DestinationXpath = "/*[local-name()='Root' and namespace-uri()='http://test.SchemaMock']/*[local-name()='Element' and namespace-uri()='']" }; var message = MessageHelper.CreateFromString("<message></message>"); pipeline.AddComponent(assembler, PipelineStage.Assemble); var result = pipeline.Execute(message); var doc = new XmlDocument(); doc.Load(result.BodyPart.GetOriginalDataStream()); var node = doc.SelectSingleNode("/*[local-name() = 'Root']/*[local-name() = 'Element']"); byte[] data = Convert.FromBase64String(node.InnerText); string decodedString = Encoding.Default.GetString(data); Assert.AreEqual("<message></message>", decodedString.Replace("\0", "")); }
public void SendHTMLFormattedEmailWithAttachment() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new EmailCustomizer { Enabled = true, FileNames = "BodyPartASFileName.xml", XSLTFilePath = TestFiles.EmailFormatterFilePath, ApplyXsltOnBodyPart = true// if it is true the XSLT file be aplied on the }; pipeline.AddComponent(component, PipelineStage.Encode); //adding MIME encoder component to the sendpipeline so we can view the structure of the output message. var mime = new MIME_SMIME_Encoder(); pipeline.AddComponent(mime, PipelineStage.Encode); //create a message with body part only. var message = MessageHelper.Create(System.IO.File.ReadAllText(TestFiles.BodyPart_FilePath), System.IO.File.ReadAllText(TestFiles.Part1_FilePath), System.IO.File.ReadAllText(TestFiles.Part2_FilePath)); var output = pipeline.Execute(message); System.IO.StreamReader reader = new System.IO.StreamReader(output.BodyPart.GetOriginalDataStream()); var ret = reader.ReadToEnd(); }
public void Setup() { rcvpipeline = PipelineFactory.CreateEmptyReceivePipeline(); XmlDasmComp xmlDasmComp = new XmlDasmComp(); rcvpipeline.AddComponent(xmlDasmComp, PipelineStage.Disassemble); sndpipeline = PipelineFactory.CreateEmptySendPipeline(); if (!File.Exists(googlecredentials)) { } }
public void Initialize() { string inputXml = @"<root> <element1>value1</element1> <element2>value2</element2> <element3>value3</element3> </root>"; msg = MessageHelper.CreateFromString(inputXml); msg.Context.Write(receivedFileName.PropertyName, receivedFileName.PropertyNamespace, originalFileName); pipeline = PipelineFactory.CreateEmptySendPipeline(); }
public void TestCompressInvalidExtension() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new CompressMessage { DefaultZipEntryFileExtension = ".xml" }; var msg = MessageHelper.CreateFromString("<testmessage1></testmessage1>"); pipeline.AddComponent(component, PipelineStage.Encode); var result = pipeline.Execute(msg); }
public void TestArrayOfEventsJSONEncoder() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new JSONEncoder { ArrayOutput = true, RemoveOuterEnvelope = true }; pipeline.AddComponent(component, PipelineStage.Encode); var message = MessageHelper.CreateFromStream(TestHelper.GetTestStream("ArrayOfEvents.xml")); var output = pipeline.Execute(message); var retStr = MessageHelper.ReadString(output); var JsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(retStr); Assert.IsTrue(JsonObj is Newtonsoft.Json.Linq.JArray); }
public void CanEnumerateComponents() { SendPipelineWrapper pipeline = PipelineFactory.CreateEmptySendPipeline(); pipeline.AddComponent(new XmlAsmComp(), PipelineStage.Assemble); pipeline.AddComponent(new MIME_SMIME_Encoder(), PipelineStage.Encode); pipeline.AddComponent(new FFAsmComp(), PipelineStage.Assemble); int numComponents = 0; foreach (IBaseComponent component in pipeline) { numComponents++; } Assert.AreEqual(3, numComponents); }
public void CanExecuteEmptyPipeline() { SendPipelineWrapper pipeline = PipelineFactory.CreateEmptySendPipeline(); // Create the input message to pass through the pipeline Stream stream = DocLoader.LoadStream("SampleDocument.xml"); IBaseMessage inputMessage = MessageHelper.CreateFromStream(stream); MessageCollection inputMessages = new MessageCollection(); inputMessages.Add(inputMessage); // Execute the pipeline, and check the output IBaseMessage outputMessage = pipeline.Execute(inputMessages); Assert.IsNotNull(outputMessage); }
public void TestEmptyRootNodeJSONEncoder() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new JSONEncoder { ArrayOutput = true, RemoveOuterEnvelope = true }; pipeline.AddComponent(component, PipelineStage.Encode); var message = MessageHelper.CreateFromStream(TestHelper.GetTestStream("EmptyEvents.xml")); var output = pipeline.Execute(message); var stream = new StreamReader(output.BodyPart.GetOriginalDataStream(), Encoding.UTF8); var retStr = stream.ReadToEnd(); var JsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(retStr); Assert.IsTrue(JsonObj is Newtonsoft.Json.Linq.JArray); }
public void TestPromoteNewGuid() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new PromoteNewGuid { DestinationProperty = "http://tempuri.org#Property" }; pipeline.AddComponent(component, PipelineStage.PreAssemble); var message = MessageHelper.Create("<test></test>"); var output = pipeline.Execute(message); Guid g; Assert.IsTrue(Guid.TryParse(output.Context.Read(new ContextProperty("http://tempuri.org#Property")) as string, out g)); }
public void TestInvalidXpath() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); pipeline.AddDocSpec(typeof(SchemaMock)); var assembler = new PipelineComponents.Base64Assembler.Base64Assembler { DocumentSpecName = "BizTalkComponents.Base64Assembler.Tests.UnitTests.SchemaMock", DestinationXpath = "/*[local-name()='RootInvalid' and namespace-uri()='http://test.SchemaMock']/*[local-name()='Element' and namespace-uri()='']" }; var message = MessageHelper.CreateFromString("<message></message>"); pipeline.AddComponent(assembler, PipelineStage.Assemble); var result = pipeline.Execute(message); }
public void Test() { var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (config.AppSettings.Settings["SharePointSite"] == null) { config.AppSettings.Settings.Add("SharePointSite", "https://TestUrl.org"); } else { config.AppSettings.Settings["SharePointSite"].Value = "https://TestUrl.org"; } string Key = "274"; string DestinationPath = "https://Test.Schemas.PropertySchema#Destination"; IBaseMessage message = MessageHelper.CreateFromString("<Test/>"); message.Context.Write("Key", "https://Test.Schemas.PropertySchema", Key); message.Context.Write("DestinationPath", "https://Test.Schemas.PropertySchema", DestinationPath); var component = new SharepointLookup() { Disabled = false, PropertyPath = "https://Test.Schemas.PropertySchema#Key", DestinationPath = "https://Test.Schemas.PropertySchema#DestinationPath", ListName = "TestList", ThrowException = true, PromoteProperty = true }; SendPipelineWrapper sendPipeline = PipelineFactory.CreateEmptySendPipeline(); sendPipeline.AddComponent(component, PipelineStage.PreAssemble); IBaseMessage results = sendPipeline.Execute(message); Assert.AreEqual(Key, results.Context.Read("StoreId", "https://Test.Schemas.PropertySchema")); Assert.IsTrue(results.Context.IsPromoted("DestinationPath", "https://Test.Schemas.PropertySchema")); }
public void CanProvideStageIDsInContext() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var stages = new List <Guid>(); pipeline.AddComponent(new SendStageTest(stages), PipelineStage.PreAssemble); pipeline.AddComponent(new SendStageTest(stages), PipelineStage.Assemble); pipeline.AddComponent(new SendStageTest(stages), PipelineStage.Encode); var inputMessage = MessageHelper.CreateFromString("<sample/>"); var collection = new MessageCollection(); collection.Add(inputMessage); var outputMessage = pipeline.Execute(collection); Assert.AreEqual(3, stages.Count); Assert.AreEqual(PipelineStage.PreAssemble.ID, stages[0]); Assert.AreEqual(PipelineStage.Assemble.ID, stages[1]); Assert.AreEqual(PipelineStage.Encode.ID, stages[2]); }
public void SendPlainTextWithAttachment() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new EmailCustomizer { Enabled = true, FileNames = "BodyPart.xml", EmailBody = "This is a plain text e-mail with body part as attachment.\nRegards" }; pipeline.AddComponent(component, PipelineStage.Encode); //adding MIME encoder component to the sendpipeline so we can view the structure of the output message. var mime = new MIME_SMIME_Encoder(); pipeline.AddComponent(mime, PipelineStage.Encode); //create a message with body part only. var message = MessageHelper.Create(System.IO.File.ReadAllText(TestFiles.BodyPart_FilePath)); var output = pipeline.Execute(message); System.IO.StreamReader reader = new System.IO.StreamReader(output.BodyPart.GetOriginalDataStream()); var ret = reader.ReadToEnd(); }
public void TestLargeFileJSONEncoder() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new JSONEncoder { ArrayOutput = true, RemoveOuterEnvelope = true }; pipeline.AddComponent(component, PipelineStage.Encode); var doc = new XmlDocument(); var stream = TestHelper.GetTestStream("large.xml"); doc.Load(stream); stream.Seek(0, SeekOrigin.Begin); var message = MessageHelper.CreateFromStream(stream); var output = pipeline.Execute(message); var retStr = MessageHelper.ReadString(output); var JsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(retStr); Assert.IsTrue(JsonObj is Newtonsoft.Json.Linq.JArray); Assert.AreEqual(doc.DocumentElement.ChildNodes.Count, (JsonObj as Newtonsoft.Json.Linq.JArray).Count); }
public void Assemble_EmptyMessage_MessageUpdated() { // arrange var encoding = Encoding.UTF8; var pipeline = PipelineFactory.CreateEmptySendPipeline(); pipeline.AddComponent(new UnwrapStringAssembler { EncodingName = "utf-8" }, PipelineStage.Assemble); var inStream = new MemoryStream(encoding.GetBytes("<string><![CDATA[]]></string>")); var inMessage = MessageHelper.CreateFromStream(inStream); // act var outMessage = pipeline.Execute(new[] { inMessage }); using (var sr = new StreamReader(outMessage.BodyPart.Data, encoding, false, 1024, true)) { var result = sr.ReadToEnd(); // assert Assert.AreEqual("", result); } }
public void Execute_ContextPropertyExists_PropertyPromoted() { // arrange var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new PromoteContextPropertyComponent { PropertyName = "name", PropertySchema = "schema", }; pipeline.AddComponent(component, PipelineStage.PreAssemble); var message = MessageHelper.Create("<test></test>"); message.Context.Write("name", "schema", "banan"); // act var result = pipeline.Execute(message); // assert Assert.AreEqual("banan", result.Context.Read("name", "schema")); Assert.IsTrue(result.Context.IsPromoted("name", "schema")); }
public void SendPlainTextAndAttachParts() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new EmailCustomizer { Enabled = true, FileNames = "BodyPart.xml||Part2.xml",// string array for parts' filenames separated by |, adding empty text results in skipping the corespondant part from being attached. EmailBody = "This is a plain text e-mail with several parts attached.\nRegards" }; pipeline.AddComponent(component, PipelineStage.Encode); //adding MIME encoder component to the sendpipeline so we can view the structure of the output message. var mime = new MIME_SMIME_Encoder(); pipeline.AddComponent(mime, PipelineStage.Encode); //create a message with body part only. var message = MessageHelper.Create(System.IO.File.ReadAllText(TestFiles.BodyPart_FilePath), System.IO.File.ReadAllText(TestFiles.Part1_FilePath), System.IO.File.ReadAllText(TestFiles.Part2_FilePath)); var output = pipeline.Execute(message); System.IO.StreamReader reader = new System.IO.StreamReader(output.BodyPart.GetOriginalDataStream()); var ret = reader.ReadToEnd(); }
public void Test() { IBaseMessage message = MessageHelper.CreateFromString("<test/>"); message.Context.Write("property1", "namespace1", "filename1.txt"); message.Context.Write("property2", "namespace2", "123"); var component = new SetHttpHeaders() { Disabled = false, DestinationPath = "MyNamespace#HttpHeaders", HeaderNames = "FileName;StoreID", PromoteProperty = true, PropertyPaths = "namespace1#property1;namespace2#property2" }; SendPipelineWrapper SendPipeline = PipelineFactory.CreateEmptySendPipeline(); SendPipeline.AddComponent(component, PipelineStage.PreAssemble); IBaseMessage results = SendPipeline.Execute(message); Assert.AreEqual("FileName:filename1.txt StoreID:123", results.Context.Read("HttpHeaders", "MyNamespace")); }
internal SendPipelineBuilder() { _pipeline = PipelineFactory.CreateEmptySendPipeline(); }
public void CanExecuteBtfAssembler() { SendPipelineWrapper pipeline = PipelineFactory.CreateEmptySendPipeline(); pipeline.GroupSigningCertificate = "9302859B216AB1E97A2EB4F94E894A128E4A3B6E"; MIME_SMIME_Encoder mime = new MIME_SMIME_Encoder(); mime.SignatureType = MIME_SMIME_Encoder.SMIME_SignatureType.BlobSign; mime.SendBodyPartAsAttachment = true; mime.AddSigningCertToMessage = true; mime.EnableEncryption = false; mime.ContentTransferEncoding = MIME_SMIME_Encoder.MIMETransferEncodingType.SevenBit; pipeline.AddComponent(mime, PipelineStage.Encode); BTFAsmComp asm = new BTFAsmComp(); asm.DesignProp_epsFromAddress = "asdasd"; asm.DesignProp_epsFromAddressType = "asdad"; asm.DesignProp_epsToAddress = "eweww"; asm.DesignProp_epsToAddressType = " asdd"; asm.DesignProp_isReliable = true; asm.DesignProp_propTopic = "wewew"; asm.DesignProp_svcDeliveryRctRqtSendBy = 4; asm.DesignProp_svcDeliveryRctRqtSendToAddress = "ddd"; asm.DesignProp_svcDeliveryRctRqtSendToAddressType = "sss"; pipeline.AddComponent(asm, PipelineStage.Assemble); pipeline.AddDocSpec(typeof(BTF2Schemas.btf2_endpoints_header)); pipeline.AddDocSpec(typeof(BTF2Schemas.btf2_envelope)); pipeline.AddDocSpec(typeof(BTF2Schemas.btf2_manifest_header)); pipeline.AddDocSpec(typeof(BTF2Schemas.btf2_process_header)); pipeline.AddDocSpec(typeof(BTF2Schemas.btf2_receipt_header)); pipeline.AddDocSpec(typeof(BTF2Schemas.btf2_services_header)); pipeline.AddDocSpec(typeof(SampleSchemas.SimpleBody)); string body = @"<o:Body xmlns:o='http://SampleSchemas.SimpleBody'> this is a body</o:Body>"; MessageCollection inputMessages = new MessageCollection(); IBaseMessage inputMsg = MessageHelper.CreateFromString(body); inputMsg.Context.Write("PassThroughBTF", "http://schemas.microsoft.com/BizTalk/2003/mime-properties", false); inputMessages.Add(inputMsg); inputMsg.BodyPart.PartProperties.Write("ContentTransferEncoding", "http://schemas.microsoft.com/BizTalk/2003/mime-properties", "7bit"); IBaseMessage output = pipeline.Execute(inputMessages); byte[] buffer = new byte[64 * 1024]; Stream input = output.BodyPart.Data; int bytesRead; Stream outputs = new FileStream("c:\\temp\\t.xml", FileMode.Truncate, FileAccess.Write); using ( outputs ) { while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0) { outputs.Write(buffer, 0, bytesRead); } } }