Category Archives: Spring

Adding Plug-Ins To Your Application With Spring

Spring’s classpath scanning support can be leveraged to easily implement an application that supports plugins to be added. One method would be to simply scan a specific package (for example org.example.myapp.plugin for beans annotated with @Component, and add them to … Continue reading

Posted in Java, Spring | Leave a comment

Annotation-based Spring Configuration

Spring has been supporting annotation-based context configuration for some years now. Time to explore it if you haven’t already done so! A quick overview is available here. Getting rid of your XML configuration is as easy as: If you need … Continue reading

Posted in Java, Spring | 1 Comment

Mocking a multipart/form-data HTTP request in a unit test

If you have a servlet that processes HTML Form post data, you might want to simulate such a request in your unit tests. This is easily done with Apache Commons HttpClient using MultipartRequestEntity. This example uses MockHttpServletRequest from Spring, but can … Continue reading

Posted in Java, Spring, Testing | Tagged , , , | 3 Comments

Writing Unit Tests for Servlets

When writing unit tests for simple servlets you’ll need to write a lot boilerplate code for mocking out all these HttpServletRequest/Response/Context/… objects every time, plus it feels like too much of a white box test really. Surely there’s a better … Continue reading

Posted in Google Web Toolkit, Java, Spring | Tagged , , , | Leave a comment