Taking a tour inside the Spring Framework

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!


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.
// notify EasyMock of expected calls. You can also define return values!
// indicates that the mocked object is configured and can start tracking calls.
// the actual test involving a call to the mocked interface.
// check that the call was actually done.

Without further ado, I give to you EasyMock!

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