Package org.springframework.mock.web.portlet

Examples of org.springframework.mock.web.portlet.MockRenderRequest


  }

  public void testRequiresSessionWithSession() throws Exception {
    TestController tc = new TestController();
    tc.setRequireSession(true);
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
   
    // create the session
    request.getPortletSession(true);
    try {
      tc.handleRenderRequest(request, response);
    }
    catch (PortletSessionRequiredException ex) {
      fail("Should not have thrown PortletSessionRequiredException");
View Full Code Here


    }
  }
 
  public void testRenderRequestWithoutCacheSetting() throws Exception {
    TestController tc = new TestController();
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    tc.handleRenderRequest(request, response);
    String cacheProperty = response.getProperty(RenderResponse.EXPIRATION_CACHE);
    assertNull("Expiration-cache should be null", cacheProperty);
  }
View Full Code Here

  }

  public void testRenderRequestWithNegativeCacheSetting() throws Exception {
    TestController tc = new TestController();
    tc.setCacheSeconds(-99);
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    tc.handleRenderRequest(request, response);   
    String cacheProperty = response.getProperty(RenderResponse.EXPIRATION_CACHE);
    assertNull("Expiration-cache should be null", cacheProperty);
  }
View Full Code Here

  }
 
  public void testRenderRequestWithZeroCacheSetting() throws Exception {
    TestController tc = new TestController();
    tc.setCacheSeconds(0);
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    tc.handleRenderRequest(request, response);   
    String cacheProperty = response.getProperty(RenderResponse.EXPIRATION_CACHE);
    assertEquals("Expiration-cache should be set to 0 seconds", "0", cacheProperty);
  }
View Full Code Here

  }

  public void testRenderRequestWithPositiveCacheSetting() throws Exception {
    TestController tc = new TestController();
    tc.setCacheSeconds(30);
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    tc.handleRenderRequest(request, response);   
    String cacheProperty = response.getProperty(RenderResponse.EXPIRATION_CACHE);
    assertEquals("Expiration-cache should be set to 30 seconds", "30", cacheProperty);
  }
View Full Code Here

    TestController tc = new TestController() {
      protected boolean suppressBinding(PortletRequest request) {
        return true;
      }
    };
    MockRenderRequest request = new MockRenderRequest();   
    MockRenderResponse response = new MockRenderResponse();
    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());
View Full Code Here

    TestController tc = new TestController() {
      protected void initBinder(PortletRequest request, PortletRequestDataBinder binder) {
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
      }
    };
    MockRenderRequest request = new MockRenderRequest();   
    MockRenderResponse response = new MockRenderResponse();
    String name = "test";
    int age = 30;
    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());
View Full Code Here

    TestController tc = new TestController() {
      protected void initBinder(PortletRequest request, PortletRequestDataBinder binder) {
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
      }
    };
    MockRenderRequest request = new MockRenderRequest();   
    MockRenderResponse response = new MockRenderResponse();
    String name = "test";
    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);
View Full Code Here

    TestController tc = new TestController() {
      protected void initBinder(PortletRequest request, PortletRequestDataBinder binder) {
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
      }
    };
    MockRenderRequest request = new MockRenderRequest();   
    MockRenderResponse response = new MockRenderResponse();
    String name = "test";
    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);
View Full Code Here

            setValue(new TestBean(text));
          }
        });
      }
    };
    MockRenderRequest request = new MockRenderRequest();   
    MockRenderResponse response = new MockRenderResponse();
    String name = "test";
    String spouseName = "testSpouse";
    int age = 30;
    int spouseAge = 31;
    request.addParameter("name", name);
    request.addParameter("age", "" + age);
    request.addParameter("spouse", spouseName);
    request.addParameter("spouse.age", "" + spouseAge);
    ModelAndView mav = tc.handleRenderRequest(request, response);
    TestBean command = (TestBean)mav.getModel().get(tc.getCommandName());
    assertEquals(name, command.getName());
    assertEquals(age, command.getAge());
    assertNotNull(command.getSpouse());
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.portlet.MockRenderRequest

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.