@@ -0,0 +1,2686 @@
+package edu.columbia.gemma.controller;%0A%0Aimport org.springframework.mock.web.MockHttpServletRequest;%0Aimport org.springframework.mock.web.MockHttpServletResponse;%0Aimport org.springframework.validation.BindException;%0Aimport org.springframework.web.servlet.ModelAndView;%0Aimport org.springframework.web.servlet.View;%0Aimport org.springframework.web.servlet.view.RedirectView;%0A%0Aimport edu.columbia.gemma.BaseControllerTestCase;%0A%0A/**%0A * This test makes use of Spring's MockHttpServletRequest and MockHttpServletResponse.%0A * I have used TaxonLoaderService as the loader of choice as it is fast (small file to read from).%0A * %3Chr%3E%0A * %3Cp%3E%0A * Copyright (c) 2004 - 2005 Columbia University%0A * %0A * @author keshav%0A * @version $Id$%0A */%0Apublic class LoaderControllerTest extends BaseControllerTestCase %7B%0A%0A    private LoaderController c;%0A    private MockHttpServletRequest request;%0A    private MockHttpServletResponse response;%0A    private View returnedView;%0A%0A    public void setUp() throws Exception %7B%0A        c = ( LoaderController ) ctx.getBean( %22loaderController%22 );%0A        request = new MockHttpServletRequest();%0A        response = new MockHttpServletResponse();%0A        returnedView = new RedirectView( %22home.jsp%22 );%0A    %7D%0A%0A    public void tearDown() %7B%0A        c = null;%0A    %7D%0A%0A    /**%0A     * hasHeader = true The View returned by the onSubmit method ( a RedirectView(String view) ) will obviously not%0A     * point to the same place on the heap as returnedView defined in setUp(). Calling toString on both will, however%0A     * yield the same String value: org.springframework.web.servlet.view.RedirectView: unnamed; URL %5Bhome.jsp%5D%0A     * %0A     * @throws Exception%0A     */%0A    public void testOnSubmitHeaderIsTrue() throws Exception %7B%0A        request.addParameter( %22hasHeader%22, %22true%22 );%0A        request.addParameter( %22typeOfLoader%22, %22taxonLoaderService%22 );%0A        ModelAndView mav = c.onSubmit( request, response, ( Object ) null, ( BindException ) null );%0A        assertEquals( returnedView.toString(), mav.getView().toString() );%0A%0A    %7D%0A%0A    /**%0A     * hasHeader = false Calling onSubmit with hasHeader = false will cause a NumberFormatException, as expected. This%0A     * results in a call to the view numberFormatError.jsp (to display the error), with the view name being%0A     * numberFormatError.%0A     * %0A     * @throws Exception%0A     */%0A    public void testOnSubmitIsFalse() throws Exception %7B%0A        request.addParameter( %22hasHeader%22, %22false%22 );%0A        request.addParameter( %22typeOfLoader%22, %22taxonLoaderService%22 );%0A        ModelAndView mav = c.onSubmit( request, response, ( Object ) null, ( BindException ) null );%0A        assertEquals( %22numberFormatError%22, mav.getViewName() );%0A%0A    %7D%0A%0A%7D

Test to test the LoaderController