Nov 23 2008

XBox (Hardware) = Pathetic

Category: MiscPhil @ 1:40 pm

I’m no gamer, but when you have have two boys (13 and 11), you can avoid it!  We purchased an XBox 360 last year for Christmas… can you say “excited” kids?  Anyway, that XBox lasted about two (2) weeks and we were introduced the the “Red Ring of Death”… Sounds like a really cool video game, right? Unfortunately, it means your XBox is toast! We returned it and decided to buy another one from Best Buy, only because they offered an extended warranty. Normally, we do not buy the warranty, but if you do a Google search on XBox reliablity, and you will see thousands of pages of people with issues…. I hoped it would be money well spent, at least it  would make it easier on the kids.

Needless to say,  less that eleven months later, we had our second failure, this time it was an E74. When I take it back to Best Buy tomorrow, I will find out the real value of the warranty. Rather than boxing it up and mailing it off to Microsoft, I believe I just take it back to Best Buy and they give me a new one… That’s the way it is supposed to work… I think… I hope!

The XBox hardware might be a piece of junk, but I do think they have a pretty nice on-line environment. It is really cool all of the stuff the kids can do on line. We installed the XBox Live 2.0 upgrade last week; it looked really cool from the few minutes I watched. I will be very interested to hear how the Netflix integration works out… unfortunately, we don’t have Netfix!!!!

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


Nov 23 2008

Unit Testing with Spring 2.5.x

Category: Java,TestingPhil @ 1:08 pm

Sometime back, using the Spring Framework and jUnit 4.x was not very elegant. Spring only supported dependency injection by sub-classing their AbstractDependencyInjectionSpringContextTests class. The coolest thing about jUnit 4.x was the implementation of annotations and the elimination of the requirement to extend the jUnit TestCase class. Obviously, this was considered an issue by many people, as several projects created their own solutions for jUnit 4.x integration. One such implemenation was Unitils, which I used on several projects. I did not take advantage of all of the Unitils features (Mock Objects, JPA, or DBUnit integration), only the dependency injection and a little of the Hibernate and Transaction management support.

Someone recently hipped me to the fact, that somewhere along the way, Spring finally added support for jUnit 4.x. I wanted to see if I could possibly eliminate the need to Unitils.  Only have only played with the integration for short time, but it appears to do what is required. The only real issue I encountered was having to downgrade from jUnit 4.5 to jUnit 4.4.  Unfortunately jUnit 4.5 broke the integration, and will not work. However, moving back to jUnit 4.4 solved all of the issues.

The basic class level annotations that you need to be aware of are @RunWith(SpringJUnit4ClassRunner.class) and @ContextConfiguration(locations = { “/com/sample/resources/applicationContext.xml” }).  I have seen the @RunWith annotation used by many new jUnit extensions, it seems pretty cool. The ContextConfiguration is pretty obvious, you can provide a list of XML files which contain your Spring context

Next you can simple provide the @Autowired or @Resource annotation to your test class properties. Spring will then inject those objects for you at execution time. They did provide the @Qualifier(“alternateBeanName”) annotation which allows you to remove possible ambiguity.

One thing that was not entirely obvious to me was the @TestExecutionListeners annotation. One of the Spring examples had it set to {}, which effectively turns off the dependency injection. It would have best to leave it out! Anyway, there are several other Listeners that you might want to be aware of, such as dealing with Transactions and a dirty spring context.

On of the more interesting annotations, (which was not in Unitils) was the idea of making tests specific to an environment. While this  is probably not that common, I have had situations where I can only run a test in the CI (Continuous Integration) environment, or maybe only I only want it to run on my development box. The @IfProfileValue annotaion provides this ability. The default implementation allows you to do simple “if logic” base on Java properties. It is also possible to define your own configuration (something that determines the value of the requested attributes) class, using the @ProfileValueSourceConfiguration(Include.class). Pretty cool, I can actually see using this feature in the future.

There are plenty of other annotations that will be useful, such as @BeforeTransaction, @AfterTransaction, @Rollback, and @NotTransactional.

I believe that the @RunWith and @ProfileValueSourceConfiguration annotations can be very useful in building a consistency unit test strategy, effectively hiding much of the noise associated with most jUnits (noise = configuration and setup tasks). Personally, I find jUnit 4.x much more elegant that the original (pre 4.x) strategy, providing a much cleaner implementation.

I believe that unit testing is essential to projects, and will continue on my personal mission to push for Test Driven Development. I truly believe that done right, “Testing is basically Free”… especially when you consider the integration environments provided by Spring and development tools such as Eclipse. How can anyone afford NOT to test?  Enough soapbox for the day, here was yet another little TDD article.

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png