Package org.springframework.web.portlet

Examples of org.springframework.web.portlet.ModelAndView


 
  public void testViewPortletMode() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.VIEW);
    ModelAndView mav = controller.handleRenderRequest(request, response);
    assertEquals("view", mav.getViewName());
  }
View Full Code Here


  public void testRenderRequestWithNoParams() throws Exception {
    TestController tc = new TestController();
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setContextPath("test");
    ModelAndView mav = tc.handleRenderRequest(request, response);
    assertEquals("test-view", mav.getViewName());
    assertNotNull(mav.getModel().get(tc.getCommandName()));
    BindException errors = (BindException)mav.getModel().get(ERRORS_KEY);
    assertNotNull(errors);
    assertEquals("There should be no errors", 0, errors.getErrorCount());
  }
View Full Code Here

    String name = "test";
    int age = 30;
    request.addParameter("name", name);
    request.addParameter("age", "" + age);
    request.setContextPath("test");
    ModelAndView mav = tc.handleRenderRequest(request, response);
    assertEquals("test-view", mav.getViewName());
    TestBean command = (TestBean)mav.getModel().get(tc.getCommandName());
    assertEquals("Name should be bound", name, command.getName());
    assertEquals("Age should be bound", age, command.getAge());
    BindException errors = (BindException)mav.getModel().get(ERRORS_KEY);
    assertNotNull(errors);
    assertEquals("There should be no errors", 0, errors.getErrorCount());
  }
View Full Code Here

    MockRenderResponse response = new MockRenderResponse();
    String name = "test";
    request.addParameter("name", name);
    request.addParameter("age", "zzz");
    request.setContextPath("test");
    ModelAndView mav = tc.handleRenderRequest(request, response);
    assertEquals("test-view", mav.getViewName());
    TestBean command = (TestBean)mav.getModel().get(tc.getCommandName());
    assertNotNull(command);
    assertEquals("Name should be bound", name, command.getName());
    BindException errors = (BindException)mav.getModel().get(ERRORS_KEY);
    assertEquals("There should be 1 error", 1, errors.getErrorCount());   
    assertNotNull(errors.getFieldError("age"));
    assertEquals("typeMismatch", errors.getFieldError("age").getCode());
  }
View Full Code Here

    TestController tc = new TestController();
    assertFalse(tc.isRenderWhenMinimized());
    MockRenderRequest request = new MockRenderRequest();
    request.setWindowState(WindowState.MINIMIZED);
    MockRenderResponse response = new MockRenderResponse();
    ModelAndView mav = tc.handleRenderRequest(request, response);
    assertNull("ModelAndView should be null", mav);
  }
View Full Code Here

    tc.setRenderWhenMinimized(true);
    MockRenderRequest request = new MockRenderRequest();
    request.setWindowState(WindowState.MINIMIZED);
    request.setContextPath("test");
    MockRenderResponse response = new MockRenderResponse();
    ModelAndView mav = tc.handleRenderRequest(request, response);
    assertNotNull("ModelAndView should not be null", mav);   
    assertEquals("test-view", mav.getViewName());
    assertNotNull(mav.getModel().get(tc.getCommandName()));
    BindException errors = (BindException)mav.getModel().get(ERRORS_KEY);
    assertEquals("There should be no errors", 0, errors.getErrorCount());
  }
View Full Code Here

    String name = "test";
    int age = 30;
    request.addParameter("name", name);
    request.addParameter("age", "" + age);
    request.setContextPath("test");
    ModelAndView mav = tc.handleRenderRequest(request, response);
    assertEquals("test-view", mav.getViewName());
    TestBean command = (TestBean)mav.getModel().get(tc.getCommandName());
    assertNotNull(command);
    assertTrue("Name should not have been bound", name != command.getName());
    assertTrue("Age should not have been bound", age != command.getAge());
    BindException errors = (BindException)mav.getModel().get(ERRORS_KEY);
    assertEquals("There should be no errors", 0, errors.getErrorCount());
  }
View Full Code Here

    request.addParameter("name", name);
    request.addParameter("age", "" + age);
    String dateString = "07-03-2006";
    Date expectedDate = dateFormat.parse(dateString);
    request.addParameter("date", dateString);
    ModelAndView mav = tc.handleRenderRequest(request, response);
    TestBean command = (TestBean)mav.getModel().get(tc.getCommandName());
    assertEquals(name, command.getName());
    assertEquals(age, command.getAge());
    assertEquals(expectedDate, command.getDate());
    BindException errors = (BindException)mav.getModel().get(ERRORS_KEY);
    assertEquals("There should be no errors", 0, errors.getErrorCount());
  }
View Full Code Here

    int age = 30;
    request.addParameter("name", name);
    request.addParameter("age", "" + age);
    String emptyString = "";
    request.addParameter("date", emptyString);
    ModelAndView mav = tc.handleRenderRequest(request, response);
    TestBean command = (TestBean)mav.getModel().get(tc.getCommandName());
    assertEquals(name, command.getName());
    assertEquals(age, command.getAge());
    BindException errors = (BindException)mav.getModel().get(ERRORS_KEY);
    assertEquals("There should be 1 error", 1, errors.getErrorCount());   
    assertNotNull(errors.getFieldError("date"));
    assertEquals("typeMismatch", errors.getFieldError("date").getCode());
    assertEquals(emptyString, errors.getFieldError("date").getRejectedValue());
  }
View Full Code Here

    int age = 30;
    request.addParameter("name", name);
    request.addParameter("age", "" + age);
    String dateString = "";
    request.addParameter("date", dateString);
    ModelAndView mav = tc.handleRenderRequest(request, response);
    TestBean command = (TestBean)mav.getModel().get(tc.getCommandName());
    assertEquals(name, command.getName());
    assertEquals(age, command.getAge());
    BindException errors = (BindException)mav.getModel().get(ERRORS_KEY);
    assertEquals("There should be 0 errors", 0, errors.getErrorCount());   
    assertNull("date should be null", command.getDate());
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.portlet.ModelAndView

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.