In the past I have noticed that system testers find it difficult to test middleware applications such as those implemented using BizTalk. System testers generally don’t want to read BizTalk xml messages dumped out to disk, they like to be able to query for their test results via some form of GUI. Many are adept at writing SQL to return result sets containing the test data they want to analyze.
I came up with the idea of using BAM relationships between different activities within a single view to log before and after snapshots of BizTalk messages. So when messages were transformed by maps, orchestrations or the BRE system testers could test those transforms. You can then give system testers’ access to the BAM Portal Website where they could view and query these before and after snapshots and match the actuals against the expected results to pass or fail their tests.
This solution for system testing only works for certain scenarios’ with certain types of schemas as each message logged cannot contain repeating records if it is to be logged to BAM.
So what am I on about? Take a single record schema which validates an xml message like the one below as I said before this technique won’t work with messages which contain multiple records.
<ns1:SampleTransaction TransactionID=”123456″ ProductName=”ABC” Amount=”1234.56″ Quantity=”24″ xmlns:ns1=”http://SynbogalooSamples/SampleTransaction/1.0.0.0″ />
Each time a map, orchestration or business rules were applied to a message I wanted to send messages to BAM so I was basically just logging messages to BAM each time the contents of the message changed. I used BAM relationships to associate the message before it was transformed to the message after it was transformed so the tester could assess whether the transformation worked.
OK this was all easy but very time consuming using the Excel add-in to create the xlsb files for each schema so I wrote a simple xlsb file generator. Note: For this code to work with schemas that have xsd types other than DateTime, Integer, Double and String you will need to add to the switch statement in the CreateActivity method.
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;
namespace BAMXslbGenerator
{
class Program
{
private const string UCName = “Name”;
private const string LCName = “name”;
private const string View = “View”;
private const string BAMDefinition = “BAMDefinition”;
private const string BAMDefinitionNamespace = “http://schemas.microsoft.com/BizTalkServer/2004/10/BAM“;
private const string Extension = “Extension”;
private const string OWC = “OWC”;
private const string OWCNamespace = “urn:schemas-microsoft-com:office:excel”;
private const string ActivityView = “ActivityView”;
private const string ActivityRef = “ActivityRef”;
private const string Activity = “Activity”;
private const string Alias = “Alias”;
private const string CheckpointRef = “CheckpointRef”;
private const string Id = “ID”;
private const string Checkpoint = “Checkpoint”;
private const string XpathToAttribute =
“(//*[local-name()=’element’])[last()]/*[local-name()=’complexType’]/*[local-name()=’attribute’]”;
private const string DataType = “DataType”;
private const string DataLength = “DataLength”;
private const string Length = “length”;
private const string MaxLength = “maxLength”;
private const string XpathToLength = “*[local-name()=’simpleType’]/*[local-name()=’restriction’]/*[local-name()=’length’]/@value”;
private const string XpathToMaxLength = “*[local-name()=’simpleType’]/*[local-name()=’restriction’]/*[local-name()=’maxLength’]/@value”;
private const string SqlDateTime = “DATETIME”;
private const string SqlNvarchar = “NVARCHAR”;
private const string SqlInt = “INT”;
private const string SqlFloat = “FLOAT”;
private const string XsdDateTime = “xs:dateTime”;
private const string XsdString = “xs:string”;
private const string XsdInteger = “xs:int”;
private const string XsdDouble = “xs:double”;
private static StringBuilder xlsbText = null;
static void Main(string[] args)
{