[ Content | Sidebar ]

Taking a tour inside the Spring Framework

February 10th, 2010

I’ll be attending SpringSource‘s Spring Core training this week. Two cool remarks from day one:

Infrastructure beans in its own bean definition file

After having heard this suggestion, I can’t believe I didn’t think of it before. Having plumbing beans on a separate file makes all the sense in the world. It is expected to change for different environments, so data sources for instance can be defined as pools or JNDI lookups for a web environment, and as stub beans for testing.
Building an application context then means having to specify more than one configuration file. No big deal, and much to gain!

EasyMock

Ok, this is not Spring related, I’ll give you that. But I discovered it during the training. I loved it. Basically it does all the stubbing I’ve ever done for testing in a way that is so simple… the disadvantage mentioned in the course was that it’s difficult to understand. I disagree so much! What can be easier than this?

 // first, create a mock for a dependant interface.
 Interface mocked = EasyMock.createMock(Interface.class);
 // "inject" it.
 testedClass.setDependency(mocked);
 // notify EasyMock of expected calls. You can also define return values!
 EasyMock.expect(mocked.someCallDoneInsideTestedMethod());
 // indicates that the mocked object is configured and can start tracking calls.
 EasyMock.replay(mocked);

 // the actual test involving a call to the mocked interface.
 testedClass.testedMethod();

 // check that the call was actually done.
 EasyMock.verify(mocked);

Without further ado, I give to you EasyMock!

Tomorrow, it’ll be all about AOP with Spring. Stay tuned!

Its that time of the year…

October 18th, 2009

Our statesmen still don’t realize how important time is for IT systems. For the third time in a row, the rules for DST were changed less than a week before they would’ve been implemented.

There’s no way vendors (or maintainers for FLOSS) can keep up with this kind of mambo-jambo. I’m trying hard not to turn this into a political rant, but it seems clear to me that this matter is being handled as almost every other subject by the government. “Just in Time” can be a good concept for compilers, but not for politics.

I pity on those who have to deal with this stuff in a large scale. I’ve received an email last Friday from Microsoft for instance. The subject was (translated from Spanish): “Know how to deal with possible change of time”. Maintainers of tz-data, on their side, haven’t yet released a version fixing this, so my computer’s clock is one hour ahead in time again.

Is it too much to ask, to start thinking about these issues a month before implementing it, instead of just a few hours?