Package org.springframework.mock.web.portlet

Examples of org.springframework.mock.web.portlet.MockPortletRequest.addParameter()


    TestBean bean = new TestBean();
    PortletRequestDataBinder binder = new PortletRequestDataBinder(bean);
    binder.setRequiredFields(new String[] {"age", "name"});

    MockPortletRequest request = new MockPortletRequest();
    request.addParameter("age", "35");
    binder.bind(request);

    BindingResult error = binder.getBindingResult();
    assertNotNull(error.getFieldError("name"));
    assertEquals("required", error.getFieldError("name").getCode());
View Full Code Here


    TestBean bean = new TestBean();
    PortletRequestDataBinder binder = new PortletRequestDataBinder(bean);
    binder.setAllowedFields(new String[] {"age"});

    MockPortletRequest request = new MockPortletRequest();
    request.addParameter("age", "35");
    request.addParameter("name", "test");
    binder.bind(request);

    assertEquals(35, bean.getAge());
    assertNull(bean.getName());
View Full Code Here

    PortletRequestDataBinder binder = new PortletRequestDataBinder(bean);
    binder.setAllowedFields(new String[] {"age"});

    MockPortletRequest request = new MockPortletRequest();
    request.addParameter("age", "35");
    request.addParameter("name", "test");
    binder.bind(request);

    assertEquals(35, bean.getAge());
    assertNull(bean.getName());
  }
View Full Code Here

    assertTrue("Should not have any property values", pvs.getPropertyValues().length == 0);
  }
 
  public void testWithNoPrefix() {
    MockPortletRequest request = new MockPortletRequest();
    request.addParameter("param", "value");
    PortletRequestParameterPropertyValues pvs = new PortletRequestParameterPropertyValues(request);
    assertEquals("value", pvs.getPropertyValue("param").getValue());
  }
 
  public void testWithPrefix() {
View Full Code Here

    assertEquals("value", pvs.getPropertyValue("param").getValue());
  }
 
  public void testWithPrefix() {
    MockPortletRequest request = new MockPortletRequest();
    request.addParameter("test_param", "value");
    PortletRequestParameterPropertyValues pvs = new PortletRequestParameterPropertyValues(request, "test");
    assertTrue(pvs.contains("param"));
    assertFalse(pvs.contains("test_param"));
    assertEquals("value", pvs.getPropertyValue("param").getValue());
  }
View Full Code Here

    assertEquals("value", pvs.getPropertyValue("param").getValue());
  }

  public void testWithPrefixAndOverridingSeparator() {
    MockPortletRequest request = new MockPortletRequest();
    request.addParameter("test.param", "value");
    request.addParameter("test_another", "anotherValue");
    request.addParameter("some.other", "someValue");
    PortletRequestParameterPropertyValues pvs = new PortletRequestParameterPropertyValues(request, "test", ".");
    assertFalse(pvs.contains("test.param"));
    assertFalse(pvs.contains("test_another"));
View Full Code Here

  }

  public void testWithPrefixAndOverridingSeparator() {
    MockPortletRequest request = new MockPortletRequest();
    request.addParameter("test.param", "value");
    request.addParameter("test_another", "anotherValue");
    request.addParameter("some.other", "someValue");
    PortletRequestParameterPropertyValues pvs = new PortletRequestParameterPropertyValues(request, "test", ".");
    assertFalse(pvs.contains("test.param"));
    assertFalse(pvs.contains("test_another"));
    assertFalse(pvs.contains("some.other"));
View Full Code Here

  public void testWithPrefixAndOverridingSeparator() {
    MockPortletRequest request = new MockPortletRequest();
    request.addParameter("test.param", "value");
    request.addParameter("test_another", "anotherValue");
    request.addParameter("some.other", "someValue");
    PortletRequestParameterPropertyValues pvs = new PortletRequestParameterPropertyValues(request, "test", ".");
    assertFalse(pvs.contains("test.param"));
    assertFalse(pvs.contains("test_another"));
    assertFalse(pvs.contains("some.other"));
    assertFalse(pvs.contains("another"));
View Full Code Here

public class PortletRequestUtilsTests {

  @Test
  public void testIntParameter() throws PortletRequestBindingException {
    MockPortletRequest request = new MockPortletRequest();
    request.addParameter("param1", "5");
    request.addParameter("param2", "e");
    request.addParameter("paramEmpty", "");

    assertEquals(PortletRequestUtils.getIntParameter(request, "param1"), new Integer(5));
    assertEquals(PortletRequestUtils.getIntParameter(request, "param1", 6), 5);
View Full Code Here

  @Test
  public void testIntParameter() throws PortletRequestBindingException {
    MockPortletRequest request = new MockPortletRequest();
    request.addParameter("param1", "5");
    request.addParameter("param2", "e");
    request.addParameter("paramEmpty", "");

    assertEquals(PortletRequestUtils.getIntParameter(request, "param1"), new Integer(5));
    assertEquals(PortletRequestUtils.getIntParameter(request, "param1", 6), 5);
    assertEquals(PortletRequestUtils.getRequiredIntParameter(request, "param1"), 5);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.