cvs commit: spice/sandbox/repository/componenthaus/src/tests/org/componenthaus/usecases/showcomponent ShowComponentControllerTestCase.java

Mike Hogan <[email protected]> Mon, 10 Nov 2003 12:21:44 -0800
Newsgroups gmane.comp.java.spice.cvs
Message-ID <[email protected]>
hogie       03/11/10 12:21:44

  Added:       sandbox/repository/componenthaus/src/tests/org/componenthaus/usecases/showcomponent
                        ShowComponentControllerTestCase.java
  Log:
  Preview release with plexus-utils components
  
  Revision  Changes    Path
  1.1                  spice/sandbox/repository/componenthaus/src/tests/org/componenthaus/usecases/showcomponent/ShowComponentControllerTestCase.java
  
  Index: ShowComponentControllerTestCase.java
  ===================================================================
  package org.componenthaus.usecases.showcomponent;
  
  import junit.framework.TestCase;
  import org.componenthaus.tests.MockComponentRepository;
  import org.componenthaus.tests.MockComponent;
  import org.springframework.web.servlet.ModelAndView;
  import com.mockobjects.servlet.MockHttpServletRequest;
  
  import javax.servlet.ServletException;
  import java.io.IOException;
  
  public class ShowComponentControllerTestCase extends TestCase {
  
      public void testCallsRepositoryAndMakesModelAvailable() throws IOException, ServletException {
          MockComponentRepository repository = new MockComponentRepository();
          ShowComponentController controller = new ShowComponentController(repository);
          String componentId = "jjhjh";
          MockComponent component = new MockComponent(componentId);
          repository.setupComponent(component);
          final MockHttpServletRequest request = new MockHttpServletRequest();
          request.setupAddParameter("id",componentId);
          ModelAndView modelAndView = controller.handleRequestInternal(request,null);
          assertNotNull(modelAndView.getViewName());
          assertEquals(1,modelAndView.getModel().size());
          assertSame(component,modelAndView.getModel().get(ShowComponentController.MODEL_NAME));
          repository.verify();
      }
  }
  
  
  


-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/