Monday, October 29, 2007

ESB in a .NET environment

Regarding for information about ESB over .NET environment, I found this two alternatives (see Jesus Rodriguez's WebLog at http://weblogs.asp.net/gsusx/archive/2007/10/09/some-thoughts-on-esb-vs-rest-dynamic-languages.aspx):

Neuron ESB:
http://www.neudesic.com/Main.aspx?SS=7&PE=75

ESB Guidance Toolkit:
http://www.codeplex.com/esb

Now I am studying both alternatives...soon I will tell you my opinion.

Friday, October 26, 2007

Unit Testing Class for Maps

Here is my class for unit testing BizTalk maps:

using Microsoft.XLANGs.BaseTypes;

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml.XPath;
using System.Xml.Xsl;

namespace MyNamespace.Test
{
  public class MapsUtil
  {
    public static void CompareMaps(TransformBase map, Stream originStream, Stream expectedStream)
    {
      XslTransform transformation = map.Transform;
      XsltArgumentList transformationArgs = map.TransformArgs;

      MemoryStream outputStream = new MemoryStream();

      XPathDocument xpathDoc = new XPathDocument(originStream);

      transformation.Transform(xpathDoc, transformationArgs, outputStream);

      outputStream.Position = 0;

      StreamUtil.CompareStreams(expectedStream, outputStream);

      expectedStream.Flush();
      expectedStream.Close();
      outputStream.Flush();
      outputStream.Close();
    }
  }
}

And here is an example that uses it:

[Test()]
public void MapTest()
{
  MyMap map = new MyMap();
  TransformBase mapping = (TransformBase)map;

  Stream originStream = DocLoader.LoadStream(MESSAGES_NAMESPACE, "NOOP1.Reply.input.xml");
  Stream expectedStream = DocLoader.LoadStream(MESSAGES_NAMESPACE, "NOOP1.Reply_output.xml");

  MapsUtil.CompareMaps(mapping, originStream, expectedStream);
}

Where CompareStreams is a class for compare two different streams and DocLoader is a class for load resources as streams.