Spring MVC – @RequestBody and @ResponseBody

In this post i want to dig into spring mvc a little, revealing what happens behind the scenes when a request is converted to your parameter object and vice versa. Before we start, i want to explain the purpose of these annotations. What are @RequestBody and @ResponseBody for? They are annotations of the spring mvc…

use log4j in junit test assertions

I need to confirm that some error/warnings are logged in the code being tested. The logger is usually private static final that we cannot get from the junit. The following pattern would be able to achieve it.  

modify method arguments using spring aspect

@Before For logging kinds of stuff, we usually use the “@Before”   A before advice gets a copy of the argument array, but it can’t modify the original arguments.      @Around So in order to modify , we need to use “@Around” with which you can pass the args to the execution!  

Proper way to access file resources in junit tests

As I was refactoring some JUnit tests recently I was reminded of an important fact on the proper way to read in a file. In maven any file under /src/test/resources is automatically copied over to /target/test-classes. So for example lets say I need to read in a wsdl in my test. So I place the wsdl in the resources folder: /src/test/resources/test.wsdl. Now at…

Log4j MDC

I hope that Log4j does not need any introduction and I assume that you already have basic understanding of Log4j. If not, I’ll recommend you to first read this Log4j Tutorial, to get started. That said, now I’ll start with MDC or Mapped Diagnostic Context. Don’t get scared with this name! MDC is not that tough. It’s…

replace indexed but not stored data in lucene

Was trying to replace indexed but not stored data in lucene . found this thread has the same issue: > > >> I have a strange problem with Field.Store.NO and Field.Index.ANALYZED > > >> fields with Lucene 3.0.1. > > >> > > >> I’m testing my app with twenty test documents. Each has about ten…