public void TestSendOneWay_XML_WithProperties_InvalidProperty()
        {
            using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(
                       connectionUri.Uri.AbsolutePath, PipeDirection.InOut, 1,
                       PipeTransmissionMode.Byte, PipeOptions.Asynchronous))
            {
                string xml = "<SomeTestMessage><Element1 attribute1=\"attributeValue\"></Element1><Element2>Some element content</Element2></SomeTestMessage>";

                Message msg = GeneralTestHelper.CreateMessageWithBase64EncodedBody(xml, Encoding.UTF8);

                // Adding test properties
                AddPromotedProperty(msg, "http://schemas.microsoft.com/BizTalk/2003/zip-properties#Imaginary", "StillWorks");

                OutboundTestHelper testHelper = new OutboundTestHelper(pipeServer);

                pipeServer.BeginWaitForConnection(cb => testHelper.ClientConnected(cb), testHelper);

                outboundHandler.Execute(msg, new TimeSpan(0, 0, 10));
                //Here we wait for the event to be signalled
                testHelper.syncEvent.WaitOne(60000);
                //The event was signalled, we get the message stirng from the outBuffer
                var mockMessage = ConvertToMockMessage(testHelper.memStream);

                Assert.AreEqual(xml, mockMessage.Body, "Contents of received message is different");
                Assert.IsTrue(mockMessage.Properties.Count == 1, "Number of properties received from outbound adapter is wrong");
                Assert.AreEqual("StillWorks",
                                mockMessage.Properties["http://schemas.microsoft.com/BizTalk/2003/zip-properties#Imaginary"],
                                "The promoted property is not as expected");
            }
        }
        public void TestSendOneWay_XML_Unicode()
        {
            using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(
                       connectionUri.Uri.AbsolutePath, PipeDirection.InOut, 1,
                       PipeTransmissionMode.Byte, PipeOptions.Asynchronous))
            {
                adapter.Encoding = "Unicode";

                string xml = "<SomeTestMessage><Element1 attribute1=\"attributeValue\"></Element1><Element2>Some element content</Element2></SomeTestMessage>";

                Message msg = GeneralTestHelper.CreateMessageWithBase64EncodedBody(xml, Encoding.Unicode);

                OutboundTestHelper testHelper = new OutboundTestHelper(pipeServer);

                pipeServer.BeginWaitForConnection(cb => testHelper.ClientConnected(cb), testHelper);

                outboundHandler.Execute(msg, new TimeSpan(0, 0, 10));
                //Here we wait for the event to be signalled
                testHelper.syncEvent.WaitOne(60000);
                //The event was signalled, we get the message stirng from the outBuffer
                var mockMessage = ConvertToMockMessage(testHelper.memStream);

                Assert.AreEqual(xml, mockMessage.Body, "Contents of received message is different");
            }
        }
        public void TestSendOneWay_FlatFile_ISO88591()
        {
            using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(
                       connectionUri.Uri.AbsolutePath, PipeDirection.InOut, 1,
                       PipeTransmissionMode.Byte, PipeOptions.Asynchronous))
            {
                adapter.Encoding = "ISO-8859-1";
                string ffContent = "303330123333777;ABCD;00001;00002;2014-01-15;21:21:33.444;EFGH;";

                Message msg = GeneralTestHelper.CreateMessageWithBase64EncodedBody(ffContent, Encoding.GetEncoding("ISO-8859-1"));

                OutboundTestHelper testHelper = new OutboundTestHelper(pipeServer);

                pipeServer.BeginWaitForConnection(cb => testHelper.ClientConnected(cb), testHelper);

                outboundHandler.Execute(msg, new TimeSpan(0, 0, 10));
                //Here we wait for the event to be signalled
                testHelper.syncEvent.WaitOne(60000);
                //The event was signalled, we get the message stirng from the outBuffer
                string receivedResponse = GeneralTestHelper.GetMessageFromArray(testHelper.memStream.ToArray(),
                                                                                (int)testHelper.memStream.Length, Encoding.GetEncoding("ISO-8859-1"));

                Assert.AreEqual(ffContent, receivedResponse, "Contents of received message is different");
            }
        }
示例#4
0
        public void TestOneWay_XML()
        {
            PipeSecurity ps = new PipeSecurity();

            ps.AddAccessRule(
                new PipeAccessRule(
                    "USERS",
                    PipeAccessRights.CreateNewInstance | PipeAccessRights.ReadWrite,
                    System.Security.AccessControl.AccessControlType.Allow));

            // We first spin a pipe server to make sure that the send port will be able to connect
            using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(
                       "OneWaySend", PipeDirection.InOut, 1,
                       PipeTransmissionMode.Byte, PipeOptions.Asynchronous,
                       1024, 1024, ps))
            {
                string xml = "<SomeTestMessage><Element1 attribute1=\"attributeValue\"></Element1><Element2>Some element content</Element2></SomeTestMessage>";

                OutboundTestHelper testHelper = new OutboundTestHelper(pipeServer);

                pipeServer.BeginWaitForConnection(cb => testHelper.ClientConnected(cb), testHelper);
                //Here we spin the pipe client that will send the message to BizTalk
                using (NamedPipeClientStream pipeClient = new NamedPipeClientStream("localhost",
                                                                                    "OneWayReceive", PipeDirection.InOut, PipeOptions.Asynchronous))
                {
                    var mockMessage = new MockMessage();
                    mockMessage.Body = xml;

                    using (var memStream = new MemoryStream())
                    {
                        var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

                        formatter.Serialize(memStream, mockMessage);

                        pipeClient.Connect(10000);
                        pipeClient.Write(memStream.ToArray(), 0, (int)memStream.Length);
                        pipeClient.WriteByte(0x00);
                        pipeClient.WaitForPipeDrain();
                    }
                }
                //Here we wait for the event to be signalled
                testHelper.syncEvent.WaitOne(60000);
                //The event was signalled, we get the message stirng from the outBuffer
                var receivedMsg = TestUtils.ConvertToMockMessage(testHelper.memStream);

                Assert.AreEqual(xml, receivedMsg.Body, "Contents of the received message is different");
                Assert.IsTrue(receivedMsg.Properties.Count > 1, "Received message does not contain properties");
                Assert.IsTrue(receivedMsg.Properties.ContainsKey(
                                  "http://schemas.microsoft.com/BizTalk/2003/system-properties#BizTalkMessageID"),
                              "Received message does not contain MessageID property");
            }
        }
示例#5
0
        public void TestOneWay_XML()
        {
            PipeSecurity ps = new PipeSecurity();

            ps.AddAccessRule(
                new PipeAccessRule(
                    "USERS",
                    PipeAccessRights.CreateNewInstance | PipeAccessRights.ReadWrite,
                    System.Security.AccessControl.AccessControlType.Allow));

            // We first spin a pipe server to make sure that the send port will be able to connect
            using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(
                       "OneWaySend", PipeDirection.InOut, 1,
                       PipeTransmissionMode.Byte, PipeOptions.Asynchronous,
                       1024, 1024, ps))
            {
                string xml = "<SomeTestMessage><Element1 attribute1=\"attributeValue\"></Element1><Element2>Some element content</Element2></SomeTestMessage>";

                OutboundTestHelper testHelper = new OutboundTestHelper(pipeServer);

                pipeServer.BeginWaitForConnection(cb => testHelper.ClientConnected(cb), testHelper);
                //Here we spin the pipe client that will send the message to BizTalk
                using (NamedPipeClientStream pipeClient = new NamedPipeClientStream("localhost",
                                                                                    "OneWayReceive", PipeDirection.InOut, PipeOptions.Asynchronous))
                {
                    byte[] xmlBytes = Encoding.UTF8.GetBytes(xml);

                    pipeClient.Connect(10000);
                    pipeClient.Write(xmlBytes, 0, xmlBytes.Count());

                    pipeClient.WriteByte(0x00);//writing the EOF byte
                    pipeClient.Flush();

                    pipeClient.WaitForPipeDrain();
                }
                //Here we wait for the event to be signalled
                testHelper.syncEvent.WaitOne(60000);
                //The event was signalled, we get the message stirng from the outBuffer
                string receivedXml = Encoding.UTF8.GetString(testHelper.memStream.ToArray(), 0, (int)testHelper.memStream.Length);

                Assert.AreEqual(xml, receivedXml, "Contents of the received message is different");
            }
        }
示例#6
0
        public void TestOneWay_FlatFile()
        {
            PipeSecurity ps = new PipeSecurity();

            ps.AddAccessRule(new PipeAccessRule("USERS", PipeAccessRights.ReadWrite, System.Security.AccessControl.AccessControlType.Allow));
            //We first spin a pipe server to make sure that the send port will be able to connect
            using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(
                       "OneWaySend", PipeDirection.InOut, 1,
                       PipeTransmissionMode.Byte, PipeOptions.Asynchronous,
                       1024, 1024, ps))
            {
                string ffContent = "303330123333777;ABCD;00001;00002;2014-01-15;21:21:33.444;EFGH;";

                OutboundTestHelper testHelper = new OutboundTestHelper(pipeServer);

                pipeServer.BeginWaitForConnection(cb => testHelper.ClientConnected(cb), testHelper);
                //Here we spin the pipe client that will send the message to BizTalk
                using (NamedPipeClientStream pipeClient = new NamedPipeClientStream("localhost",
                                                                                    "OneWayReceive", PipeDirection.InOut, PipeOptions.Asynchronous))
                {
                    var mockMessage = new MockMessage();
                    mockMessage.Body = ffContent;

                    using (var memStream = new MemoryStream())
                    {
                        var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

                        formatter.Serialize(memStream, mockMessage);

                        pipeClient.Connect(10000);
                        pipeClient.Write(memStream.ToArray(), 0, (int)memStream.Length);
                        pipeClient.WriteByte(0x00);
                        pipeClient.WaitForPipeDrain();
                    }
                }
                //Here we wait for the event to be signalled
                testHelper.syncEvent.WaitOne(60000);
                //The event was signalled, we get the message stirng from the outBuffer
                var receivedMsg = TestUtils.ConvertToMockMessage(testHelper.memStream);

                Assert.AreEqual(ffContent, receivedMsg.Body, "Contents of the received message is different");
            }
        }
示例#7
0
        public void TestOneWay_FlatFile()
        {
            PipeSecurity ps = new PipeSecurity();

            ps.AddAccessRule(new PipeAccessRule("USERS", PipeAccessRights.ReadWrite, System.Security.AccessControl.AccessControlType.Allow));
            //We first spin a pipe server to make sure that the send port will be able to connect
            using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(
                       "OneWaySend", PipeDirection.InOut, 1,
                       PipeTransmissionMode.Byte, PipeOptions.Asynchronous,
                       1024, 1024, ps))
            {
                string ffContent = "303330123333777;ABCD;00001;00002;2014-01-15;21:21:33.444;EFGH;";

                OutboundTestHelper testHelper = new OutboundTestHelper(pipeServer);

                pipeServer.BeginWaitForConnection(cb => testHelper.ClientConnected(cb), testHelper);
                //Here we spin the pipe client that will send the message to BizTalk
                using (NamedPipeClientStream pipeClient = new NamedPipeClientStream("localhost",
                                                                                    "OneWayReceive", PipeDirection.InOut, PipeOptions.Asynchronous))
                {
                    byte[] flatBytes = Encoding.UTF8.GetBytes(ffContent);

                    pipeClient.Connect(10000);
                    pipeClient.Write(flatBytes, 0, flatBytes.Count());
                    //pipeClient.Flush();

                    pipeClient.WriteByte(0x00);//writing the EOF byte
                    pipeClient.Flush();

                    pipeClient.WaitForPipeDrain();
                }
                //Here we wait for the event to be signalled
                testHelper.syncEvent.WaitOne(60000);
                //The event was signalled, we get the message stirng from the outBuffer
                string receivedMsg = Encoding.UTF8.GetString(testHelper.memStream.ToArray(), 0, (int)testHelper.memStream.Length);

                Assert.AreEqual(ffContent, receivedMsg, "Contents of the received message is different");
            }
        }