BizTalk Maven

A few notes on BizTalk

Archive for the ‘Tools’ Category

First Steps with BizUnit

Posted by Jeremy on 12/10/2009

I’ve always been afraid to use BizUnit.
It seemed like a lot of work had to be done before I could actually test anything so I never really bothered to look into it.
I was recently on a project where testing any functionality was a very very long process.
Put some files somewhere, check some emails, go to a website, check SQL tables … you know the drill.
At some point I had enough and decided to see what all the fuss about BizUnit was about.
Let me tell you that from now on, this is how I’ll do testing.
The documentation is clearly not the best in the world, so I’ve cooked up a very simple example for anyone interested to start using BizUnit.

The little solution

The solution in this example is very simple:

BizTalk picks up a file from a folder location, applies a little transformation, and send the result to another location.
I could have done it without an orchestration, but I still used one for you guys to add some functionality to it if you wanted to extend the example a bit.

0. Installation of BizUnit

You can download it here and install it following the installation steps – nothing fancy here.

1. Identify the steps required for testing

After you’ve implemented and deployed your BizTalk solution and that you’re ready to test it, you need first of all to identify the steps required for testing:

  • Do you need to put some files in a folder for BizTalk to pick up?
  • Do you need to validate some data in those files first?
  • Do you need to see if some rows got successfully inserted in some SQL tables?

Basically, write down all you need to check for your test to be declared successful.

For my little solution, I have 5 steps:

1. Delete all the files present in the receive location
2. Put a file in the receiving location
3. Wait 10 seconds – give time to Biztalk to do its business
4. Check there is a file in the send port location
5. Delete the file in the send port location

2. Create the Test Cases

A TestCase is an XML file that declares all the steps described in the section above.
It consists of 3 distinct parts:

  • TestSetup – this stage is used to setup your environment (here we’ll do step 1)
  • TestExecution – this stage will do the actual test (here we’ll do step 2, 3 and 4)
  • TestCleanup – this stage will cleanup the environment to leave it as it was. (here we’ll do step 5).   This stage will execute even if the previous stages fail.

Each of these stages has 0, 1 or multiple TestSteps which represents the actual steps we described above.

The basic structure of a TestCase is like this:

<TestCase testName="Test_01">
<TestSetup>
<TestStep assemblyPath="" typeName="">
</TestStep>
.
.
.
</TestSetup>

<TestExecution>
<TestStep assemblyPath="" typeName="">
</TestStep>
.
.
.
</TestExecution>

<TestCleanup>
<TestStep assemblyPath="" typeName="">
</TestStep>
.
.
.
</TestCleanup>
</TestCase>

Each of the TestSteps has a typeName attribute and some parameters as element.
The typeName tells us what function to execute and the parameters are parameters of this function.
You create all the steps you need in the stages where they must be executed.
For example, to copy a file from a folder to another, the testStep will look like this:

<TestStep assemblyPath="" typeName="BizUnit.FileCreateStep">
<SourcePath>source.xml</SourcePath>
<CreationPath>destination.xml</CreationPath>
</TestStep>

For deleting files from a folder the function is BizUnit.FileDeleteMultipleStep, to add a delay it is BizUnit.DelayStep etc…
There are functions for almost everything.
It’s a bit of a hassle because there isn’t any structured XML so you don’t have intellisense here.
The place to go and look at if you’re looking for a method is the BizUnit.chm (located in C:\Program Files\BizUnit\BizUnit 3.1\bins).
If you’re interested in how any method operates, you should look into the BizUnit solution (located in C:\Program Files\BizUnit\BizUnit 3.1) where most of them are.

3. Create a test project (if you do tests with Visual Studio) or a class library (if you use NUnit)

Add a test project and then add a reference to the BizUnit assembly (C:\Program Files\BizUnit\BizUnit 3.1\bins\BizUnit.dll)
Then add 1 TestMethod per XML TestCase file.
We have one TestCase XML for our tests so we have only one test method.
In the TestMethod, the code to invoke BizUnit looks like this:

[TestMethod]
public void TestMethod1()
{
BizUnit.BizUnit bizunit = new BizUnit.BizUnit(@"path\TestCase_01.xml");
bizunit.RunTest();
}

4. Run your tests

Once you’ve done all the above, you’re ready to test.
Run your test and check that it passed.
If you click on the Test Result row, you can see the output of the tests in the Standard Console Output.

I hope this helps in starting with BizUnit.
The source code for my example is provided below.
It includes everything you need for our example : the BizTalk project, the test project, the TestCase, the binding file (for the ports) and the test file and folders.


Posted in BizTalk, BizUnit, Testing, Tools | Tagged: , , , | 4 Comments »

The Windows 7 Resource Monitor

Posted by Jeremy on 30/07/2009

We all know that the way your resources are allocated in your system plays an important role in how the performance of the said system will be.
When the computer is slow, we typically open the Task Manager and look for the culprit by looking at the CPU and Memory columns.
Well, same thing here, but better.
In the performance tab of the the Windows 7 Task Manager, there is a button that opens the Resource Monitor.
This is new to Windows 7 and you can also open it directly by doing ‘Run’ and then ‘resmon’.
Let’s explore what’s in it.

Here is a screenshot of the overview:

As you can see, in the overview tab, there are expandable areas for CPU, Disk, Network and Memory.
There are also tabs for each one of these, in which you have a bit more detail.
In the CPU area you can right-click on one of the process

and you’ll get the options to end or suspend the process, but also to ‘search online’ which basically opens your default browser and searches for myprocess.exe on Google, and to ‘Analyze wait chain’.

The last one tells you either that the process runs normally, or that it is waiting for another process to finish in order for your process to continue.
This is good to see why a window is unresponsive for example.
You can also select the process and click End Process. No need to explain what it does.

It looks like this:

Let’s now look at the different tabs in more detail.

The CPU tab:

In the CPU tab, you have lists of Processes, Services, but also Associated Handles and Associated Modules.
The last two are empty until you select a process, not by highlighting it but by selecting the box.

The filtered areas get highlighted.
Also, note that you can select and view multiple processes, but all the selected ones go to the top of the list of processes.
This way you don’t have to run after the selected process up and down the list when it has a sudden change in the number of threads for example.
When you select a process, it stays selected across the tabs and you see only the info relevant to this process.
You can also stop and start Services from here, as well as search Handles (look at the search box in the Associated Handles area).
The Associated Handles shows you the registry keys, the files and the directories used by the process.

The Memory tab:

The only interesting thing here is the grey area on the left.
This is actually the amount of RAM I’m losing because I’m using the 32-bit version of Windows.
In the 64-bit version this grey chunk is almost inexistent.

The Disk tab:

The good thing here is that only the processes that have disk activity are shown.
If you select one of them, it will filter the files in the Disk Activity area so that you can see exactly which files are used by the selected process.

The Network tab:

This is nice as well, you get to see all the Network Activity very clearly.
Here you can see the ports used by your applications, you can see the firewall status (look at the bottom right corner), and you can see the bandwidth used by an app.
That’s the place to go if you feel that one of your application is taking up all the bandwidth.
Here, as well as in the Disk tab, when you select a process, you see its graph on the right highlighted in orange.

This is all very useful, and all very tidy.
The user is not overwhelmed by unnecessary data and the filtering and the highlighting make it all very easy to use.

Posted in General, Tools | Tagged: , | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 85 other followers