Thursday, January 08, 2009

Skipping Maven Tests ... For real!

For the longest time, I have been trying to figure out how to skip running
the tests that are in a project that I have been working on because they
usually fail!

Usually, I edit the POM file and disable testing, but with a project
containing numerous subprojects, this became very tedious.

All of the documentation points to a variable maven.test.skip and states to
set it to true in order to skip tests; something like:

maven.test.skip=true

This has never worked for me. In case you are wondering, I am using maven
2.0.9 (latest as of January 8, 2009)

Having tried everything, I finally have found a way to get it to work
properly:

maven.test.skip.exec=true

Now when I run the install task for the project, I do it like:

mvn -Dmaven.test.skip.exec=true install

Tests are finally skipped!

Sunday, December 28, 2008

Windows and problem playing DVDs

The other day on a short road trip we tried playing a DVD on our laptop and got the following message:

"Windows Media Player cannot play this DVD because there is a problem with digital copy protection between your DVD drive, decoder, and video card. Try installing an updated driver for your video card."


As soon as I got an internet connection, I tried downloading a driver for my video card. After installing it, I assumed that the DVD would play (after all, the message told me it would!).

No luck. I then downloaded new firmware and drivers for my DVD drive. The message did say something about my DVD drive too ...

Again, no luck. Well, what else is there? Then I noticed the word 'decoder' in the message and decided to pursue that option.

I tried a few things, but the one that actually did the trick was to download the XP Codec Pack. After downloading and installing these codecs, I was finally able to play the DVD that we brought to occupy our time on our short road trip!

Thursday, November 27, 2008

Comparing XML Documents Semantically

I have been interested in comparing the contents of XML documents for some time now.

What I wanted to do is to perform a 'Diff' on 2 XML documents and determine whether or not they are the same document (regardless of whitespace or child element ordering).

In JAVA, I came across XmlUnit. This piece of software is excellent for determining whether or not 2 separate XML documents are equal.

In Perl, I came across XML-SemanticDiff. I thought it was great until I re-ordered the elements in one of my documents. Then this module wasn't so great anymore.

Since I really needed a piece of software equivalent to XmlUnit in Perl, I decided to create my own module and to call it XML-SemanticCompare. This new module really does perform a semantic diff on XML documents:
  • Child element re-ordering doesn't result in false negatives.
  • Whitespace is trimmed from text by default when comparing text and attribute values [can be turned off].
  • Attributes can be ignored [turned off by default].

Using the module is extremely straightforward:
  use XML::SemanticCompare;
my $x = XML::SemanticCompare->new;

# compare 2 different files
my $isSame = $x->compare($control_xml, $test_xml);
# are they the same
print "XML matches!\n"
if $isSame;
print "XML files are semantically different!\n"
unless $isSame;

# get the diffs
my $diffs_arrayref = $x->diff($control_xml, $test_xml);

# test xpath statement against XML
my $success = $x->test_xpath($xpath, $test_xml);
print "xpath success!\n" if $success;

The only downside to this piece of software is that it isn't very efficient (although, it isn't terribly inefficient either).

If you find yourself trying to compare XML documents DOM trees for equality and you are using Perl, please check out XML-SemanticCompare. If you can make the code more robust and efficient, please do!