programming4us
 
Applications Server
 

BizTalk Server 2009 : Testing Business Rules

6/20/2013 7:53:23 PM

Once all business policies and their required vocabularies are defined, you need to test and debug them before deploying them in production.

Because of the nonsequential nature of business processes, the Business Rules Composer doesn't provide the same testing, tracing, and debugging functionality as procedural development environments such as Visual Studio. Nonetheless, it does provide a testing tool, shown in Figure 1.

Figure 1. The Business Rule Composer testing tool interface

You can simply select fact instances for the testing tool to assert into the engine for your policy or select a FactCreator[] that the testing tool will instantiate and call to create the facts required for the policy execution. The testing tool then uses the DebugTrackingInterceptor[] to track the execution of the Business Rule Engine and display it in the output window.

[] A fact creator, used to generate facts for policy testing, implements the Microsoft.RuleEngine. IFactCreator interface. The fact creator needs to implement the GetFactTypes and CreateFacts methods, which return an array of object types and objects respectively for a given rule set.

[] The Business Rule Engine allows for the registration of tracking interceptors that implement the Microsoft.RuleEngine.IRuleSetTrackingInterceptor interface to be notified along with the execution of the engine and track its progress.

The following extract of output was produced by the Business Rule Composer testing tool when testing the Loans Processing policy from the Loans Sample in the SDK. It shows the details of the tracked information by the DebugTrackingInterceptor.

RULE ENGINE TRACE for RULESET: LoanProcessing 5/19/2009 12:46:13 PM

FACT ACTIVITY 5/19/2009 12:46:13 PM
Rule Engine Instance Identifier: fb330399-15f0-4dc7-9137-4463a32f580e
Ruleset Name: LoanProcessing
Operation: Assert


Object Type: DataConnection:Northwind:CustInfo
Object Instance Identifier: 782

FACT ACTIVITY 5/19/2009 12:46:13 PM
Rule Engine Instance Identifier: fb330399-15f0-4dc7-9137-4463a32f580e
Ruleset Name: LoanProcessing
Operation: Assert
Object Type: TypedXmlDocument:Microsoft.Samples.BizTalk.LoansProcessor.Case
Object Instance Identifier: 778

FACT ACTIVITY 5/19/2009 12:46:13 PM
Rule Engine Instance Identifier: fb330399-15f0-4dc7-9137-4463a32f580e
Ruleset Name: LoanProcessing
Operation: Assert
Object Type: TypedXmlDocument:Microsoft.Samples.BizTalk.LoansProcessor.Case:Root
Object Instance Identifier: 777

CONDITION EVALUATION TEST (MATCH) 5/19/2009 12:46:13 PM
Rule Engine Instance Identifier: fb330399-15f0-4dc7-9137-4463a32f580e
Ruleset Name: LoanProcessing
Test Expression: NOT(TypedXmlDocument:Microsoft.Samples.BizTalk.LoansProcessor.Case:
                                                    Root.Income/BasicSalary > 0)
Left Operand Value: 12
Right Operand Value: 0
Test Result: False

CONDITION EVALUATION TEST (MATCH) 5/19/2009 12:46:13 PM
Rule Engine Instance Identifier: fb330399-15f0-4dc7-9137-4463a32f580e
Ruleset Name: LoanProcessing
Test Expression: NOT(TypedXmlDocument:Microsoft.Samples.BizTalk.LoansProcessor.Case:
                                                    Root.Income/OtherIncome > 0)
Left Operand Value: 10
Right Operand Value: 0
Test Result: False

CONDITION EVALUATION TEST (MATCH) 5/19/2009 12:46:13 PM
Rule Engine Instance Identifier: fb330399-15f0-4dc7-9137-4463a32f580e
Ruleset Name: LoanProcessing
Test Expression: TypedXmlDocument:Microsoft.Samples.BizTalk.LoansProcessor.Case:
                                            Root.PlaceOfResidence/TimeInMonths >= 3
Left Operand Value: 15
Right Operand Value: 3
Test Result: True
[.. cut for brevity ..]

					  

If you are testing or executing policies outside of BizTalk or in a component consumed within BizTalk, you can specify an alternative custom interceptor that implements the IRuleSetTrackingInterceptor interface.[] Creating your custom interceptor allows you to track and log as much information as your application requires. It allows you to step through the rule processing and view fact details through the facts you pass to the policy. The following code snippet demonstrates how to invoke your custom interceptor—MyInterceptorClass.

[] A custom tracking interceptor that implements the Microsoft.RuleEngine. IRuleSetTrackingInterceptor interface needs to implement the SetTrackingConfig, TrackAgendaUpdate, TrackConditionEvaluation, TrackFactActivity, TrackRuleFiring, and TrackRuleSetEngineAssociation methods, which allow it to intercept the execution sequence, agenda, and facts updates for a specified rule set.

...
xmlDocument = IncomingXMLMessage.XMLCase;
typedXmlDocument = new
Microsoft.RuleEngine.TypedXmlDocument("Microsoft.Samples.BizTalk.LoansProcessor.
                                                                 Case",xmlDocument);
policy = new Microsoft.RuleEngine.Policy("LoanProcessing");
policy.Execute(typedXmlDocument,new MyInterceptorClass());
OutgoingXMLMessage.XMLCase = xmlDocument;
policy.Dispose();
...

					  

The RuleTesterApp project accompanying this book implements a simple rule testing tool. The tool's user interface allows the user to load XML policy definitions, specify the destination trace output file, and then execute those policies. To experiment with your own custom tracking interceptor, instantiate your interceptor in the method FireRule RulesTesterFrm class on line 267 instead of the current instantiation of the DebugTrackingInterceptor.

...
 // Change the following line to instantiate your own custom Tracking Interceptor
DebugTrackingInterceptor dti = new DebugTrackingInterceptor(traceFileName);
try
{
   for( int i = 0 ; i < policies.Length; i++ )
  {
      string PolicyName = policies[i].Trim();
      lblProcessing.Text = PolicyName;
      ProcessingTxtBx.Text = ProcessingTxtBx.Text + "Processing ... " + policies[i]
                             + " " + DateTime.Now + "\r\n";
      Application.DoEvents();
      Microsoft.RuleEngine.Policy tstPolicy = new
                                            Microsoft.RuleEngine.Policy(PolicyName);
      ArrayList shortTermFacts = null;
      shortTermFacts =GetFacts(PolicyName);
      shortTermFacts.Add(doc1);
      // Change the following line to pass in your own custom Tracking Interceptor
      // to the rule set Execute method
      tstPolicy.Execute(shortTermFacts.ToArray(), dti);
      tstPolicy = null;
   }
}
...		  
 
Others
 
- Migrating to Configuration Manager 2007 : Migrating Hardware Inventory Customizations, Troubleshooting Upgrade Issues
- Migrating to Configuration Manager 2007 : Side-by-Side Migrations
- Microsoft Dynamic GP 2010 : System and Company Setup (part 7) - Company setup - Posting setup, E-mail setup
- Microsoft Dynamic GP 2010 : System and Company Setup (part 6) - Company setup - Shipping Methods, Credit Cards
- Microsoft Dynamic GP 2010 : System and Company Setup (part 5) - Company setup - Company setup, Fiscal Periods
- Microsoft Dynamic GP 2010 : System and Company Setup (part 4) - Company setup - Multicurrency, Taxes
- Microsoft Dynamic GP 2010 : System and Company Setup (part 3) - Company setup - Account setup
- Microsoft Dynamic GP 2010 : System and Company Setup (part 2)
- Microsoft Dynamic GP 2010 : System and Company Setup (part 1)
- Administering with Windows PowerShell and Active Directory Administrative Center (part 4)
 
 
REVIEW
 
- First look: Apple Watch

- 10 Amazing Tools You Should Be Using with Dropbox

- Sigma 24mm f/1.4 DG HSM Art

- Canon EF11-24mm f/4L USM

- Creative Sound Blaster Roar 2

- Alienware 17 - Dell's Alienware laptops

- Smartwatch : Wellograph

- Xiaomi Redmi 2
 
VIDEO TUTORIAL
 
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
 
Popular tags
 
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS
 
Top 10
 
- Setup Free Media Server To Stream Videos To DLNA Compatible TV, Xbox 360 & PS3 (Play Station 3)
- How To Install Android Market & Google Apps On Kindle Fire
- How To Make Ubuntu Look Like Windows 7
- How To Add A New Account in MS Outlook 2013
- Get Android & Mac OS X Style Gadgets For Windows 7 & Windows 8 With XWidget
- How To Activate Microsoft Office 2013
- How To Install Actual Facebook App On Kindle Fire
- How To Create, View And Edit Microsoft Office Files On Kindle Fire
- Download Attractive Business PowerPoint Templates For Free At SlideHunter
- How To Use And Enable Hibernate & Sleep Mode In Windows 8