The Architect: new monthly column on Modelus Blog

I am happy to announce a new monthly column called "The Architect" where we will touch on many issues facing designers and developers creating object-oriented business applications.

I will share with you rules, principles, and techniques that I found useful over the years. I hope you will be able to identify with the problems described and will take pleasure in learning from the situations that apply to you.

We have a wide scope to cover: object-oriented analysis and design, domain modeling, design patterns, domain-driven design, responsibility-driven design, service-oriented architecture, etc. If you are a member of a development team, or if you work with software developers, this column is for you.

NUnit 2.5 GUI cannot locate iBatis.NET sqlMap.config

NUnit 2.5 was released last month introducing a large set of new functionality into the NUnit framework. If you are using an earlier version of NUnit today, take a look at the following new features released in 2.5:

  • Parameterized, data-driven tests
  • New constraints
  • New asserts
  • Theories
  • Distributed parallel tests
As in previous versions, NUnit 2.5 allows running tests from multiple assemblies by using NUnit test project files. We find a lot of value in using these files on local development workstations. However, our automated build and continuous integration server, TeamCity 4.5.1, does not support NUnit project files and requires all test libraries to be listed manually. As a result, TeamCity executes tests with the value of AppDomain.BaseDirectory set to the location of the executing assembly. While we used to be able to configure the same behavior in previous versions of NUnit, NUnit GUI 2.5 no longer updates AppDomain.BaseDirectory at the assembly level and is likely to fail your unit or integration tests when they rely on the AppDomain.BaseDirectory value.

We came across this issue while upgrading our persistence tests. When iBatis.NET Data Mapper was used, tests succeeded on the build server but failed locally (could not find sqlMap.config or properties.config). I looked into the iBatis.NET 1.6.1 source code and noticed that the framework uses AppDomain.BaseDirectory to load its configuration files. To fix the problem, update AppDomain.BaseDirectory to the location of the executing assembly before creating the iBatis.NET Sql Mapper:

var  assembly =  Assembly.GetExecutingAssembly();
var  applicationBase = assembly.CodeBase.Substring(0, assembly.CodeBase.Length - assembly.ManifestModule.Name.Length);
AppDomain.CurrentDomain.SetData("APPBASE", applicationBase);

Contact us if you are interested in upgrading your applications to NUnit 2.5 or configuring them for TeamCity. Happy coding!

Looking back at Microsoft TechEd 2009

I just came back from Microsoft TechEd 2009 conference in Los Angeles. This year's conference was smaller than usual registering only about 7,000 attendees. If you did not get a chance to attend, take a look at the highlights below.

Azure

Windows Azure is a run-time environment in the cloud that provides an ability to host, seamlessly scale, and manage web applications and services. I was amazed by how many sessions this year were dedicated to Windows Azure as well as Azure Services Platform which includes .NET Services, SQL Data Services, and Live Services. Although the detailed pricing and service-level agreements have not been announced, it is clear that Microsoft is seriously investing into their cloud infrastructure with the intention to offer .NET developers a choice to host web applications on-premise, externally, or in the cloud.

Silverlight

Microsoft Silverlight is a web browser plug-in for delivering Rich Internet Applications (RIA). I attended a day-long seminar on Silverlight led by Jeff Prosise. Jeff took a deep dive into capabilities of Silverlight 2 and 3 and explained the logic and philosophy behind many Silverlight design decisions. This was one of my favourite TechEd sessions this year.

Over the last couple of years, Silverlight has matured into a very powerful product. We have observed significant decreases in project cycle times when building RIA applications using Silverlight 2 as opposed to AJAX and JavaScript toolkits. Silverlight 3 introduces many new long-awaited features, such as back-button navigation, deep linking, dynamic styling, style inheritance, element-to-element binding, writable bitmaps, offline support, etc.

Note that according to http://riastats.com/ as of May 19, 2009, Silverlight 2/3 is installed only on 27% of client computers. While not a concern for an Intranet application, it presents a challenge when you have no control over your client environments.

ASP.NET 4.0

Surprisingly, ASP.NET core classes have not changed much, which is an excellent news for your existing web infrastructure. Our security, logging, exception management, content management, branding, internationalization, and other infrastructural libraries are likely to integrate seamlessly with the new version of ASP.NET.

The features that make me excited about the upcoming release of ASP.NET 4.0 are integration of ASP.NET with jQuery and availability of client-side templates and data binding. Take a look at ASP.NET AJAX 4.0 Preview 4 on codeplex.com to get a better idea on what is coming out.

Hyper-V

Microsoft Hyper-V is a virtualization platform that ships with Windows Server 2008 for x64. It allows you to optimize your server hardware by consolidating multiple servers into a single physical machine running multiple virtual machines. Virtualization was a very hot topic at the conference.

Windows Server 2008 R2 and Windows 7

Quite a few sessions as well as the key note were dedicated to the upcoming releases of Windows Server 2008 R2 and Windows 7. Both products are on schedule to be released at the end of this year.

Miscellaneous

A few additional sessions are well worth mentioning:

  1. "The Scaling Habits of ASP.NET Applications", an excellent talk on scalability of ASP.NET by Kent Alstad, CTO of StrangeLoop Networks.
  2. "Cracking Open Kerberos: How Active Directory Knows Who You Are" by Mark Minasi, Chief Scientist at MR&D. Mark's presentation helped me better understand how Kerberos tickets work as well as when and why Kerberos switches to NTLM.
  3. "Busy Microsoft .NET Developer's Guide to F#" by Ted Neward. I am contemplating using F# for one of our financial calculators.

iBatis.NET DataMapper 1.6.1 does not support default parameters in stored procedures

iBatis.Net DataMapper is our de facto standard for implementing persistence in .NET applications. The framework works well with an object-oriented domain model and relational data store.

Today, we stumbled upon a bug in the latest production release of iBatis.Net DataMapper. A new parameter was added to the existing stored procedure and although this parameter came with a default value, the application threw the following exception: 
"Specified argument was out of the range of valid values. Parameter name: index" from IBatisNet.DataMapper.Configuration.ParameterMapping.ParameterPropertyCollection.get_Item.

One way to work around this issue is to replace the original procedure configuration:

<statements>
  <procedure id="OurStoredProcedure" parameterMap="OurStoredProcedure_Parameters" >
    up_YourStoredProcedure
  </procedure>
</statements>

</parameterMaps> 
   <parameterMap id="OurStoredProcedure_Parameters" class="OurParametersClass">
     <parameter property="Value1"/>
     <parameter property="Value2"/>
   </parameterMap>
<parameterMaps>

with a dynamic statement:

<statements>
  <statement id="OurStoredProcedure" parameterClass="OurParametersClass" >
    EXEC up_OurStoredProcedure #Value1#, #Value2#
  </statement>
</statements>

Happy coding!

How to automatically fail TeamCity 4.0 build when MSTest 2008 webtests fail

Out of the box, there are two options to configure MSTest 2008 webtests with TeamCity 4.0 build server. The first option is to add webtest names to the MSTest assemblies list. The second option is to specify MSTest configuration and .vsmdi metadata files. In both cases, TeamCity 4.0 does not fail a project build when webtests fail. Nor does TeamCity display webtests results as it does for unit tests.

To solve this issue, we created a custom command-line file to execute MSTest webtests:

set ConfigPath=<Path to your webtest configuration and .vsmdi files>
set ResultPath=<Path to .trx and .txt result files>
set MSTestPath=<Path to your MSTest.exe>

"%MSTestPath%\MSTest.exe" /runconfig:%ConfigPath%/Your.testrunconfig
/testmetadata:%ConfigPath%/Your.vsmdi
/resultsfile:%ResultPath%\Your%1.trx >> %ResultPath%\Your%1.txt

if not %errorlevel% == 0 exit 1

This file takes a build number as the first positional parameter, executes webtests listed in Your.vsmdi, and saves .trx result file as well as the execution summary report so that TeamCity could store them as build artifacts. We then configured a dependent build configuration to run this command-line file as part of our build process.

Happy coding!

Introductory Windows Azure webcasts for developers

If you are new to Windows Azure and would like to get started, take a look at these introductory webcasts on MSDN: http://msdn.microsoft.com/en-us/azure/dd439432.aspx. Enjoy!

MSTest 2008 results file does not get refreshed when tests are executed in TeamCity 4.0

We run into a locking issue last week while setting up MSTest 2008 with TeamCity 4.0. We recommend using NUnit instead of MSTest, but MSTest 2008 is supported by TeamCity 4.0 and we did not anticipate any problems using it. The first build worked correctly as expected, but the second and all subsequent builds did not seem to execute any tests and did not overwrite MSTest results file created by the first build. All builds were displayed as successful and all included MSTest results from the first run!

I looked closer into the build logs and noticed the following entries:

  • "The results file 'C:\TeamCity\...\tests.trx' already exists. Please specify a different results file or verify the existing file is no longer needed and delete it."
  • "The command 'C:\...\mstest.exe' /testcontainer..." exited with code 1.

When I tried deleting the results file manually, I received the "Error Deleting File or Folder" exception. The file was locked by TeamCityAgentService-windows-x86-32.exe -> java.exe process.
 
To resolve this problem, we ended up naming our MSTest results file name as tests%env.BUILD_NUMBER%.trx. This way, each new build generates a brand-new results file. Note that this solution requires you to delete historical .trx files on a regular basis, which could be easily accomplished with a command line script.

Happy coding!

Videos from OreDev 2008 conference available for general public

Videos from last year's OreDev conference are available for general public:
http://www.oredev.org/topmenu/video.4.45b270a411a9ed8e1278000948.html.

Check out sessions from all three days and do not miss my favourite Domain Driven Design (DDD) track. Enjoy!

Dojo 1.1, Firefox 3.0.5, and this._getText is not a function

We run into an interesting problem with Dojo 1.1 running on Firefox 3.0.5. The page works well on Firefox 2, IE 6/7, Safari 2/3, but once in a while, it does not load correctly on Firefox 3. It may also throw one or more JavaScript exceptions. For example, "failed loading undefined./currency.js with error: TypeError: this._getText is not a function".

My hunch is that it happens because dojo.require statements are not handled correctly. It is also possible that this issue is related to another issue reported on the Dojo forum: http://dojotoolkit.org/forum/dojo-foundation/general-discussion/firefox-3-fires-domcontentloaded-event-prematurely.

The good news is that we tested the problem on the alpha version of Firefox 3.2 (Minefield - http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-mozilla-central/) and it seemed to be resolved. We also found a work-around to make Dojo 1.1 more stable on Firefox 3.0.5: loading base dojo libraries via script tags instead of the dojo.require function. The JavaScript exceptions still appear from time to time, but much more rarely.

If you have any insight into this issue, please, let us know. Your help would be very appreciated. Thank you. Happy coding!

Team City 4.0 supports relative URL in the svn:externals property of Subversion 1.5

In my September post, I wrote that we upgraded our development environment from Subversion 1.4 to Subversion 1.5. We were hoping to use relative URL's in svn:externals property - the feature introduced in Subversion 1.5. We use svn:externals to connect to shared non-compilable release units, such as common styles, images, script libraries, content, etc. We immediately found out that although Team City 3.2, our build and integration server at the time, supported Subversion 1.5, it did not recognize relative URL's in svn:externals. We have recently upgraded our build server to Team City 4.0 and it does support relative URL's in svn:externals!

Contact me if you have any questions on how to structure your Subversion repository. Happy coding!

Welcome to ModelBlog

Thank you for visiting ModelBlog. We hope the time you spend with us will be both entertaining and worth your while. Have fun!

Authors

Search

Archive

Tags