How to use @ContextConfiguration to test Web Spring app locally and in memory?
===

Let's imagine a Spring 3.1 web mvc application using MySql via Hibernate JPA via DAO's.

One has to write tests for the controllers without deploying the application and using an in-memory database (like `hsqldb:mem` for example). In other words, one should be able to run tests on a local PC.

Example of controller to test:

    @Controller
    @RequestMapping(value="/account")
    public class AccountController {
    
    	private Map<Long, Account> accounts = new ConcurrentHashMap<Long, Account>();
    	
    	@RequestMapping(method=RequestMethod.GET)
    	public String getCreateForm(Model model) {
    		model.addAttribute(new Account());
    		return "account/createForm";
    	}
    	
    	@RequestMapping(method=RequestMethod.POST)
    	public String create(@Valid Account account, BindingResult result) {
    		if (result.hasErrors()) {
    			return "account/createForm";
    		}
    		this.accounts.put(account.assignId(), account);
    		return "redirect:/account/" + account.getId();
    	}
    	
    	@RequestMapping(value="{id}", method=RequestMethod.GET)
    	public String getView(@PathVariable Long id, Model model) {
    		Account account = this.accounts.get(id);
    		if (account == null) {
    			throw new ResourceNotFoundException(id);
    		}
    		model.addAttribute(account);
    		return "account/view";
    	}
    
    }


How can this be achieved? Can someone provide a detailed example of how to write tests for such a controller? How should `@ContextConfiguration` be configured? How to retrieve a `WebApplicationContext` for testing purposes locally? Should one maintain a `hibernate-test.cfg.xml`?

**Update**

I am not talking only about unit testing, I am talking about integration testing.
