Example usage for org.apache.commons.validator Msg Msg

List of usage examples for org.apache.commons.validator Msg Msg

Introduction

In this page you can find the example usage for org.apache.commons.validator Msg Msg.

Prototype

Msg

Source Link

Usage

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest09.java

/**
 * testValidateDateRange09()/*from   w w w. ja  va 2s .com*/
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:"abc"<br>
 *         (?) va:not null<br>
 *         (?) field:not null<br>
 *                var:datePattern="yyyy/MM/dd"<br>
 *                var:datePatternStrict=null<br>
 *                Msg("message","message")<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *                Locale=JAPANESE<br>
 *
 * <br>
 * l?F(l) boolean:false<br>
 *         (?) errors:ActionMessage("message")<br>
 *
 * <br>
 * datePattern??ttH?[}bgw?A
 * ?beanDate???AG?[?bZ?[Wfalse
 * pmF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateDateRange09() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = "abc";
    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setName("message");
    // ++++ ?tB?[h?
    Field field = new Field();
    Var var = new Var();
    var.setName("datePattern");
    var.setValue("yyyy/MM/dd");
    field.addVar(var);
    var = new Var();
    var.setName("datePatternStrict");
    var.setValue(null);
    field.addVar(var);
    // ?bZ?[W?
    Msg msg = new Msg();
    msg.setKey("message");
    msg.setName("message");
    msg.setResource(false);
    field.addMsg(msg);
    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setLocale(Locale.JAPANESE);
    // ValidatorResourcesCX^X
    ValidatorResources validatorResources = new ValidatorResources();
    // ValidatorCX^X
    Validator validator = new Validator(validatorResources);

    // eXg?s
    boolean result = FieldChecksEx.validateDateRange(bean, va, field, errors, validator, request);
    // eXgmF
    // falsep?B
    assertFalse(result);
    // G?[?1??B
    assertEquals(1, errors.size());

    // ?bZ?[WIuWFNgmF
    Iterator it = errors.get();
    ActionMessage message = (ActionMessage) it.next();
    assertEquals("message", message.getKey());
}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest07.java

/**
 * testValidateNumber10()//  w  w w .j a  va 2 s. c om
 * <br><br>
 *
 * (?n)
 * <br>
 * _?FC,F
 * <br><br>
 * l?F(?) bean:String:"123.12"<br>
 *         (?) va:not null<br>
 *         (?) field:not null<br>
 *                var:integerLength=null<br>
 *                var:scale="3"<br>
 *                var:isAccordedScale=null<br>
 *                Msg("message","message")<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *
 * <br>
 * l?F(l) boolean:true<br>
 *         (?) errors:not null<br>
 *                    (vf)<br>
 *
 * <br>
 * scale?l?AisAccordedScalenullw?Ascale?l?A
 * bean??_??Atruep?A
 * G?[?bZ?[WmF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateNumber10() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = "123.12";
    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setName("message");
    // ++++ ?tB?[h?
    Field field = new Field();
    // ?bZ?[W?
    Msg msg = new Msg();
    msg.setKey("message");
    msg.setName("message");
    msg.setResource(false);
    field.addMsg(msg);
    // ???
    Var varInteger = new Var();
    varInteger.setName("integerLength");
    varInteger.setValue(null);
    field.addVar(varInteger);
    // ???
    Var varScale = new Var();
    varScale.setName("scale");
    varScale.setValue("3");
    field.addVar(varScale);
    // ???vw
    Var varAccorded = new Var();
    varAccorded.setName("isAccordedScale");
    varAccorded.setValue(null);
    field.addVar(varAccorded);

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    MockHttpServletRequest request = new MockHttpServletRequest();

    // ValidatorResourcesCX^X
    ValidatorResources validatorResources = new ValidatorResources();
    // ValidatorCX^X
    Validator validator = new Validator(validatorResources);

    // eXg?s
    boolean result = FieldChecksEx.validateNumber(bean, va, field, errors, validator, request);

    // eXgmF
    // truep?B
    assertTrue(result);
    // G?[?G?[IuWFNgo^?B
    assertTrue(errors.isEmpty());
}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest03.java

/**
 * testValidateZenkakuString04()/*from w  ww.jav  a2  s.  c  o m*/
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:String:"1a"<br>
 *         (?) va:not null<br>
 *         (?) field:not null<br>
 *                Msg("message","message")<br>
 *         (?) errors:not null<br>
 *                ActionMessage("testMessage")<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *
 * <br>
 * l?F(l) boolean:false<br>
 *         (?) errors:ActionMessage("testMessage")<br>
 *                    ActionMessage("message")<br>
 *
 * <br>
 * ?beanSpO???A
 * G?[?bZ?[W?AfalsepmF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateZenkakuString04() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = "1a";
    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setName("message");
    // ++++ ?tB?[h?
    Field field = new Field();
    // ?bZ?[W?
    Msg msg = new Msg();
    msg.setKey("message");
    msg.setName("message");
    msg.setResource(false);
    field.addMsg(msg);

    // G?[??iActionMessage1???j
    ActionMessages errors = new ActionMessages();
    ActionMessage error = new ActionMessage("testMessage");
    errors.add(Globals.ERROR_KEY, error);

    // [HTTPNGXg
    MockHttpServletRequest request = new MockHttpServletRequest();
    // ValidatorResourcesCX^X
    ValidatorResources validatorResources = new ValidatorResources();
    // ValidatorCX^X
    Validator validator = new Validator(validatorResources);

    // eXg?s
    boolean result = FieldChecksEx.validateZenkakuString(bean, va, field, errors, validator, request);

    // eXgmF
    // falsep?B
    assertFalse(result);
    // G?[?G?[IuWFNg2o^?B
    assertEquals(2, errors.size());
    // G?[???bZ?[Wo^?B
    // ActionMessage???B
    Iterator it = errors.get();
    List<String> list = new ArrayList<String>();
    while (it.hasNext()) {
        ActionMessage retError = (ActionMessage) it.next();
        list.add(retError.getKey());
    }
    assertTrue(list.contains("testMessage"));
    assertTrue(list.contains("message"));
}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest05.java

/**
 * testValidateByteLength01()/*  ww w  . ja v  a 2s  .  c  o  m*/
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FC,F
 * <br><br>
 * l?F(?) bean:null<br>
 *         (?) va:not null<br>
 *         (?) field:not null<br>
 *                var:byteLength=null<br>
 *                Msg("message","message")<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *
 * <br>
 * l?F(l) boolean:true<br>
 *         (?) ?O:?Ox?F<br>
 *                    G?[<br>
 *                    ?bZ?[W?F<br>
 *                    bean is null.<br>
 *         (?) errors:not null<br>
 *                    (vf)<br>
 *
 * <br>
 * ?beannull?AG?[?O?otruep
 * mF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateByteLength01() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = null;
    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setName("message");
    // ++++ ?tB?[h?
    Field field = new Field();
    Var var = new Var();
    var.setName("byteLength");
    var.setValue(null);
    field.addVar(var);
    // ?bZ?[W?
    Msg msg = new Msg();
    msg.setKey("message");
    msg.setName("message");
    msg.setResource(false);
    field.addMsg(msg);
    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    MockHttpServletRequest request = new MockHttpServletRequest();
    // ValidatorResourcesCX^X
    ValidatorResources validatorResources = new ValidatorResources();
    // ValidatorCX^X
    Validator validator = new Validator(validatorResources);

    // eXg?s
    boolean result = FieldChecksEx.validateByteLength(bean, va, field, errors, validator, request);
    // eXgmF
    // truep?B
    assertTrue(result);
    // G?[??B
    assertTrue(errors.isEmpty());

    // G?[?OmF
    assertTrue(LogUTUtil.checkError("bean is null."));
}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest02.java

/**
 * testValidateHankakuKanaString08()/*from  w w  w.ja  v  a  2  s .  c o m*/
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:Map:["field1"="123"]<br>
 *         (?) va:not null<br>
 *         (?) field:not null<br>
 *                property="field2"<br>
 *                Msg("message","message")<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *
 * <br>
 * l?F(l) boolean:true<br>
 *         (?) errors:not null<br>
 *                    (vf)<br>
 *
 * <br>
 * ?beanString^?AfieldOv?peB????AtruemF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateHankakuKanaString08() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    Map<String, String> bean = new HashMap<String, String>();
    bean.put("field1", "123");

    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setName("message");
    // ++++ ?tB?[h?
    Field field = new Field();
    field.setProperty("field2");
    // ?bZ?[W?
    Msg msg = new Msg();
    msg.setKey("message");
    msg.setName("message");
    msg.setResource(false);
    field.addMsg(msg);

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    MockHttpServletRequest request = new MockHttpServletRequest();
    Validator validator = new Validator(new ValidatorResources());

    // eXg?s
    boolean result = FieldChecksEx.validateHankakuKanaString(bean, va, field, errors, validator, request);
    // eXgmF
    // truep?B
    assertTrue(result);
    // G?[?G?[IuWFNgo^?B
    assertTrue(errors.isEmpty());
}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest04.java

/**
 * testValidateProhibited04()//from   ww w.j a v  a2  s  . co  m
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:String:"abc0#"<br>
 *         (?) va:not null<br>
 *         (?) field:not null<br>
 *                var:chars=""<br>
 *                Msg("message","message")<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *
 * <br>
 * l?F(l) boolean:true<br>
 *         (?) errors:not null<br>
 *                    (vf)<br>
 *
 * <br>
 * varvfchar???AtruepmF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateProhibited04() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = "abc0#";
    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setName("message");
    // ++++ ?tB?[h?
    Field field = new Field();
    // ?bZ?[W?
    Msg msg = new Msg();
    msg.setKey("message");
    msg.setName("message");
    msg.setResource(false);
    field.addMsg(msg);
    Var var = new Var();
    var.setName("chars");
    var.setValue("");
    field.addVar(var);

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    MockHttpServletRequest request = new MockHttpServletRequest();
    // ValidatorResourcesCX^X
    ValidatorResources validatorResources = new ValidatorResources();
    // ValidatorCX^X
    Validator validator = new Validator(validatorResources);

    // eXg?s
    boolean result = FieldChecksEx.validateProhibited(bean, va, field, errors, validator, request);
    // eXgmF
    // truep?B
    assertTrue(result);
    // G?[??B
    assertTrue(errors.isEmpty());
}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest08.java

/**
 * testValidateByteRange10()/*from  w  w w.  j ava  2 s . c  om*/
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:String:""<br>
 *         (?) va:not null<br>
 *         (?) field:not null<br>
 *                var:minByte="4"<br>
 *                var:maxByte="4"<br>
 *                encoding="Windows-31J"<br>
 *                Msg("message","message")<br>
 *         (?) errors:not null<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *
 * <br>
 * l?F(l) boolean:true<br>
 *         (?) errors:not null<br>
 *                    (vf)<br>
 *
 * <br>
 * fieldminBytemaxBytelv?A?bean?lv
 * ???AtruepmF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateByteRange10() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = "";
    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setName("message");
    // ++++ ?tB?[h?
    Field field = new Field();
    Var var = new Var();
    var.setName("maxByte");
    var.setValue("4");
    field.addVar(var);
    var = new Var();
    var.setName("minByte");
    var.setValue("4");
    field.addVar(var);
    var = new Var();
    var.setName("encoding");
    var.setValue("Windows-31J");
    field.addVar(var);
    // ?bZ?[W?
    Msg msg = new Msg();
    msg.setKey("message");
    msg.setName("message");
    msg.setResource(false);
    field.addMsg(msg);
    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    MockHttpServletRequest request = new MockHttpServletRequest();
    // ValidatorResourcesCX^X
    ValidatorResources validatorResources = new ValidatorResources();
    // ValidatorCX^X
    Validator validator = new Validator(validatorResources);

    // eXg?s
    boolean result = FieldChecksEx.validateByteRange(bean, va, field, errors, validator, request);
    // eXgmF
    // truep?B
    assertTrue(result);
    // G?[??B
    assertTrue(errors.isEmpty());
}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest09.java

/**
 * testValidateDateRange10()/*  w ww .jav a 2 s.c o m*/
 * <br><br>
 *
 * (?n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:"2005/10/24"<br>
 *         (?) va:not null<br>
 *         (?) field:not null<br>
 *                var:datePattern="abc"<br>
 *                var:datePatternStrict=null<br>
 *                Msg("message","message")<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *                Locale=JAPANESE<br>
 *
 * <br>
 * l?F(l) boolean:false<br>
 *         (?) ?O:?Ox?F<br>
 *                    G?[<br>
 *                    ?bZ?[W?F<br>
 *                    Illegal pattern character 'b'<br>
 *                    O?F<br>
 *                    IllegalArgumentException<br>
 *         (?) errors:ActionMessage("message")<br>
 *
 * <br>
 * ?bean??t\?AdatePatterns?
 * ttH?[}bgw???AG?[?bZ?[Wfalse
 * pmF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateDateRange10() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = "2005/10/24";
    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setName("message");
    // ++++ ?tB?[h?
    Field field = new Field();
    Var var = new Var();
    var.setName("datePattern");
    var.setValue("abc");
    field.addVar(var);
    var = new Var();
    var.setName("datePatternStrict");
    var.setValue(null);
    field.addVar(var);
    // ?bZ?[W?
    Msg msg = new Msg();
    msg.setKey("message");
    msg.setName("message");
    msg.setResource(false);
    field.addMsg(msg);
    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setLocale(Locale.JAPANESE);
    // ValidatorResourcesCX^X
    ValidatorResources validatorResources = new ValidatorResources();
    // ValidatorCX^X
    Validator validator = new Validator(validatorResources);

    // eXg?s
    boolean result = FieldChecksEx.validateDateRange(bean, va, field, errors, validator, request);
    // eXgmF
    // falsep?B
    assertFalse(result);
    // G?[?1??B
    assertEquals(1, errors.size());

    // ?bZ?[WIuWFNgmF
    Iterator it = errors.get();
    ActionMessage message = (ActionMessage) it.next();
    assertEquals("message", message.getKey());

    // G?[?O`FbN
    assertTrue(LogUTUtil.checkError("Illegal pattern character 'b'", new IllegalArgumentException()));
}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest07.java

/**
 * testValidateNumber11()/*from ww w .  ja  v a 2  s .c  om*/
 * <br><br>
 *
 * (?n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:String:"123.12"<br>
 *         (?) va:not null<br>
 *         (?) field:not null<br>
 *                var:integerLength=null<br>
 *                var:scale="3"<br>
 *                var:isAccordedScale="abc"<br>
 *                Msg("message","message")<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *
 * <br>
 * l?F(l) boolean:true<br>
 *         (?) errors:not null<br>
 *                    (vf)<br>
 *
 * <br>
 * scale?l?AisAccordedScaletruew?A
 * scale?l?Abean??_??Atruep?A
 * G?[?bZ?[WmF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateNumber11() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = "123.12";
    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setName("message");
    // ++++ ?tB?[h?
    Field field = new Field();
    // ?bZ?[W?
    Msg msg = new Msg();
    msg.setKey("message");
    msg.setName("message");
    msg.setResource(false);
    field.addMsg(msg);
    // ???
    Var varInteger = new Var();
    varInteger.setName("integerLength");
    varInteger.setValue(null);
    field.addVar(varInteger);
    // ???
    Var varScale = new Var();
    varScale.setName("scale");
    varScale.setValue("3");
    field.addVar(varScale);
    // ???vw
    Var varAccorded = new Var();
    varAccorded.setName("isAccordedScale");
    varAccorded.setValue("abc");
    field.addVar(varAccorded);

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    MockHttpServletRequest request = new MockHttpServletRequest();

    // ValidatorResourcesCX^X
    ValidatorResources validatorResources = new ValidatorResources();
    // ValidatorCX^X
    Validator validator = new Validator(validatorResources);

    // eXg?s
    boolean result = FieldChecksEx.validateNumber(bean, va, field, errors, validator, request);

    // eXgmF
    // truep?B
    assertTrue(result);
    // G?[?G?[IuWFNgo^?B
    assertTrue(errors.isEmpty());
}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest03.java

/**
 * testValidateZenkakuString05()/*from  w w w.ja  v  a2s  . co  m*/
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:String:"A"<br>
 *         (?) va:not null<br>
 *         (?) field:not null<br>
 *                Msg("message","message")<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *
 * <br>
 * l?F(l) boolean:false<br>
 *         (?) errors:ActionMessage("message")<br>
 *
 * <br>
 * ?beanSpO???A
 * G?[?bZ?[W?AfalsepmF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateZenkakuString05() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = "A";
    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setName("message");
    // ++++ ?tB?[h?
    Field field = new Field();
    // ?bZ?[W?
    Msg msg = new Msg();
    msg.setKey("message");
    msg.setName("message");
    msg.setResource(false);
    field.addMsg(msg);

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    MockHttpServletRequest request = new MockHttpServletRequest();
    // ValidatorResourcesCX^X
    ValidatorResources validatorResources = new ValidatorResources();
    // ValidatorCX^X
    Validator validator = new Validator(validatorResources);

    // eXg?s
    boolean result = FieldChecksEx.validateZenkakuString(bean, va, field, errors, validator, request);
    // eXgmF
    // falsep?B
    assertFalse(result);
    // G?[?G?[IuWFNgo^?B
    assertEquals(1, errors.size());
    // G?[???bZ?[Wo^?B
    Iterator it = errors.get();
    ActionMessage error = (ActionMessage) it.next();
    assertEquals("message", error.getKey());
}