Package org.araneaframework.uilib.form.control

Examples of org.araneaframework.uilib.form.control.FloatControl


   */
  public void testFloatControlSimpleValidation() throws Exception {
    MockHttpServletRequest correctValueRequest = new MockHttpServletRequest();
    correctValueRequest.addParameter("myFloatInput", "28.012");
   
    FloatControl nc = new FloatControl();
    nc._getComponent().init(new MockEnviroment());
    MockUiLibUtil.emulateHandleRequest(nc, "myFloatInput", correctValueRequest);
    nc.convertAndValidate();
   
    assertTrue("Float control must be valid.", nc.isValid());
    assertTrue("Float control value must be a 'BigDecimal'.", nc.getRawValue() instanceof BigDecimal);
    assertTrue("Float control value must be '28.012'.", ((BigDecimal) nc.getRawValue()).doubleValue() == 28.012);
   
    MockHttpServletRequest incorrectValueRequest = new MockHttpServletRequest();
    incorrectValueRequest.addParameter("myFloatInput", "abcd");
   
    MockUiLibUtil.emulateHandleRequest(nc, "myFloatInput", incorrectValueRequest);
    nc.convertAndValidate();   
   
    assertTrue("Float control mustn't be valid.", !nc.isValid());
   
    nc._getComponent().destroy();
  }
View Full Code Here


   */
  public void testFloatControlMinMaxValidation() throws Exception {
    MockHttpServletRequest correctValueRequest = new MockHttpServletRequest();
    correctValueRequest.addParameter("myFloatInput", "50.0018");
   
    FloatControl nc = new FloatControl();
    nc._getComponent().init(new MockEnviroment());
   
    nc.setMinValue(new BigDecimal("25.001"));
    nc.setMaxValue(new BigDecimal("75.002"));
   
    MockUiLibUtil.emulateHandleRequest(nc, "myFloatInput", correctValueRequest);
    nc.convertAndValidate();
   
    assertTrue("Float control must be valid.", nc.isValid());   
    assertTrue("Float control value must be '50.0018'.", ((BigDecimal) nc.getRawValue()).doubleValue() == 50.0018);
   
    MockHttpServletRequest tooLittleValueRequest = new MockHttpServletRequest();
    tooLittleValueRequest.addParameter("myFloatInput", "20.1");
   
    MockUiLibUtil.emulateHandleRequest(nc, "myFloatInput", tooLittleValueRequest);
    nc.convertAndValidate();   
   
    assertTrue("Float control mustn't be valid.", !nc.isValid());
   
    MockHttpServletRequest tooBigValueRequest = new MockHttpServletRequest();
    tooBigValueRequest.addParameter("myFloatInput", "80.2");
   
    MockUiLibUtil.emulateHandleRequest(nc, "myFloatInput", tooBigValueRequest);   
    nc.convertAndValidate();   
   
    assertTrue("Float control mustn't be valid.", !nc.isValid());   
  }
View Full Code Here

TOP

Related Classes of org.araneaframework.uilib.form.control.FloatControl

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.