Example usage for org.apache.commons.validator Arg setPosition

List of usage examples for org.apache.commons.validator Arg setPosition

Introduction

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

Prototype

public void setPosition(int position) 

Source Link

Document

Set this argument's replacement position.

Usage

From source file:com.sapienter.jbilling.client.payment.PaymentCrudAction.java

private void validateCreditCard() {
    // set up for cc validation, 
    // (meant for use within Validator framework)

    // from validator.xml
    Arg arg = new Arg();
    arg.setKey("all.prompt.creditCard");
    arg.setPosition(0);
    Field field = new Field();
    field.addArg(arg);/*from   www .j  av a2 s. co m*/
    field.setProperty(FIELD_CC_NUMBER);
    field.setDepends("creditCard");

    // from validator-rules.xml
    ValidatorAction va = new ValidatorAction();
    va.setName("creditCard");
    va.setClassname("org.apache.struts.validator.FieldChecks");
    va.setMethod("validateCreditCard");
    va.setMethodParams("java.lang.Object, " + "org.apache.commons.validator.ValidatorAction, "
            + "org.apache.commons.validator.Field, " + "org.apache.struts.action.ActionErrors, "
            + "javax.servlet.http.HttpServletRequest");
    va.setDepends("");
    va.setMsg("errors.creditcard");

    // do cc number validation
    LOG.debug("doing credit card number validation");
    FieldChecks.validateCreditCard(myForm, va, field, errors, request);
}

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

/**
 * testGetArrayIndexField02()//  w ww  .j ava2  s  .com
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) field:not null<br>
 *                {Arg:key="arg0", position=0;<br>
 *                 Arg:key="arg1", position=1;<br>
 *                 Arg:key="arg2", position=2;<br>
 *                 Arg:key="arg3", position=3}<br>
 *         (?) pos:0<br>
 *
 * <br>
 * l?F(l) Field:not null<br>
 *                  {Arg:key="arg0", position=0;<br>
 *                   Arg:key="arg1", position=1;<br>
 *                   Arg:key="arg2", position=2;<br>
 *                   Arg:key="arg3", position=3}<br>
 *                  (?)<br>
 *
 * <br>
 * ?field?ArgCX^Xkeyl"##INDEX"???A
 * fieldmF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testGetArrayIndexField02() throws Exception {

    // l?
    Field field = new Field();
    // arg?
    Arg param0 = new Arg();
    param0.setKey("arg0");
    param0.setPosition(0);
    field.addArg(param0);

    Arg param1 = new Arg();
    param1.setKey("arg1");
    param1.setPosition(1);
    field.addArg(param1);

    Arg param2 = new Arg();
    param2.setPosition(2);
    param2.setKey("arg2");
    field.addArg(param2);

    Arg param3 = new Arg();
    param3.setPosition(3);
    param3.setKey("arg3");
    field.addArg(param3);

    // eXg?s
    Field retField = FieldChecksEx.getArrayIndexField(field, 0);

    assertEquals("arg0", retField.getArg(0).getKey());
    assertEquals("arg1", retField.getArg(1).getKey());
    assertEquals("arg2", retField.getArg(2).getKey());
    assertEquals("arg3", retField.getArg(3).getKey());
}

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

/**
 * testGetArrayIndexField03()/*from  w  w w. jav  a 2s.  c o  m*/
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) field:not null<br>
 *                {Arg:key="##INDEX", position=0;<br>
 *                 Arg:key="##INDEX", position=1;<br>
 *                 Arg:key="##INDEX", position=2;<br>
 *                 Arg:key="##INDEX", position=3}<br>
 *         (?) pos:0<br>
 *
 * <br>
 * l?F(l) Field:not null<br>
 *                  {Arg:key="1", position=0;<br>
 *                   Arg:key="1", position=1;<br>
 *                   Arg:key="1", position=2;<br>
 *                   Arg:key="1", position=3}<br>
 *
 * <br>
 * ?field?ArgCX^Xkeyl"##INDEX"???A
 * keyl?posl?{PmF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testGetArrayIndexField03() throws Exception {

    // l?
    Field field = new Field();
    // arg?
    Arg param0 = new Arg();
    param0.setKey("##INDEX");
    param0.setPosition(0);
    field.addArg(param0);

    Arg param1 = new Arg();
    param1.setKey("##INDEX");
    param1.setPosition(1);
    field.addArg(param1);

    Arg param2 = new Arg();
    param2.setKey("##INDEX");
    param2.setPosition(2);
    field.addArg(param2);

    Arg param3 = new Arg();
    param3.setKey("##INDEX");
    param3.setPosition(3);
    field.addArg(param3);

    // eXg?s
    Field retField = FieldChecksEx.getArrayIndexField(field, 0);

    assertEquals("1", retField.getArg(0).getKey());
    assertEquals("1", retField.getArg(1).getKey());
    assertEquals("1", retField.getArg(2).getKey());
    assertEquals("1", retField.getArg(3).getKey());
}

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

/**
 * testGetArrayIndexField04()/*from   ww  w  .  ja v  a2 s.  c  om*/
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) field:not null<br>
 *                {Arg:key="##INDEX", position=0;<br>
 *                 Arg:key="arg1", position=1;<br>
 *                 Arg:key="arg2", position=2;<br>
 *                 Arg:key="##INDEX", position=3}<br>
 *         (?) pos:0<br>
 *
 * <br>
 * l?F(l) Field:not null<br>
 *                  {Arg:key="1", position=0;<br>
 *                   Arg:key="arg1", position=1;<br>
 *                   Arg:key="arg2", position=2;<br>
 *                   Arg:key="1", position=3}<br>
 *
 * <br>
 * ?field?ArgCX^Xkeyl"##INDEX"???A
 * keyl?posl?{PmF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testGetArrayIndexField04() throws Exception {

    // l?
    Field field = new Field();
    // arg?
    Arg param0 = new Arg();
    param0.setKey("##INDEX");
    param0.setPosition(0);
    field.addArg(param0);

    Arg param1 = new Arg();
    param1.setKey("arg1");
    param1.setPosition(1);
    field.addArg(param1);

    Arg param2 = new Arg();
    param2.setKey("arg2");
    param2.setPosition(2);
    field.addArg(param2);

    Arg param3 = new Arg();
    param3.setKey("##INDEX");
    param3.setPosition(3);
    field.addArg(param3);

    // eXg?s
    Field retField = FieldChecksEx.getArrayIndexField(field, 0);

    assertEquals("1", retField.getArg(0).getKey());
    assertEquals("arg1", retField.getArg(1).getKey());
    assertEquals("arg2", retField.getArg(2).getKey());
    assertEquals("1", retField.getArg(3).getKey());
}

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

/**
 * testValidateArraysIndex26()//w w  w .  java 2s  .  c o  m
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:*<br>
 *         (?) va:methodParams?F6S??<br>
 *                name?F"alphaNumericStringArray"<br>
 *         (?) field:property="rows.value"<br>
 *                arg:position="0",key="##INDEX",<br>
 *                  resource="false"<br>
 *                msg:key="alphaNumericStringArray",name="alphaNumericStringArray"<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:ANVtH?[?F"logon"<br>
 *         (?) session:L?[?F"logon"l<br>
 *                ActionFormIuWFNg<br>
 *         (?) ActionForm:<br>
 *                JavaBean[] rows<br>
 *                  +rows[0]<br>
 *                     + String value = ""<br>
 *                  +rows[1]<br>
 *                     + String value = "test"<br>
 *                  +rows[2]<br>
 *                     + String value = ""<br>
 *         (?) ?bZ?[W\?[X:message={0}<br>
 *
 * <br>
 * l?F(l) boolean:false<br>
 *         (?) errors:ActionMessage(<br>
 *                           "alphaNumericStringArray",<br>
 *                           arg{"2"})<br>
 *
 * <br>
 * ??lANVtH?[lXgv?peB???A????smF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
@SuppressWarnings("deprecation")
public void testValidateArraysIndex26() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = null;

    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setMethodParams(this.validClassStr);
    va.setName("alphaNumericStringArray");

    // ++++ ?tB?[h?
    Field field = new Field();
    field.setProperty("rows.value");
    Var var = new Var();
    field.addVar(var);
    Arg arg0 = new Arg();
    arg0.setPosition(0);
    arg0.setKey("##INDEX");
    arg0.setResource(false);
    field.addArg(arg0);
    Msg msg = new Msg();
    msg.setKey("alphaNumericStringArray");
    msg.setName("alphaNumericStringArray");
    field.addMsg(msg);
    UTUtil.invokePrivate(field, "process", Map.class, Map.class, new HashMap(), new HashMap());

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    FieldChecksEx_HttpServletRequestImpl01 request = new FieldChecksEx_HttpServletRequestImpl01();
    ActionMappingEx mapping = new ActionMappingEx();
    mapping.setName("logon");
    request.setAttribute(Globals.MAPPING_KEY, mapping);
    MockHttpSession session = new MockHttpSession();
    FieldChecksEx_JavaBeanStub01[] rows = { new FieldChecksEx_JavaBeanStub01(),
            new FieldChecksEx_JavaBeanStub01(), new FieldChecksEx_JavaBeanStub01() };
    rows[0].value = "";
    rows[1].value = "test";
    rows[2].value = "";
    form.rows = rows;

    session.setAttribute("logon", form);
    request.setSession(session);

    FieldChecksEx_MessageResourcesImpl01 messageResources = new FieldChecksEx_MessageResourcesImpl01(null,
            null);
    messageResources.message = "{0}";
    request.setAttribute(Globals.MESSAGES_KEY, messageResources);

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

    // eXg?s
    boolean result = FieldChecksEx.validateArraysIndex(bean, va, field, errors, validator, request);
    // eXgmF
    // falsep?B
    assertFalse(result);
    // G?[?2??B
    assertEquals(2, errors.size());
    Iterator it = errors.get();
    ActionMessage message = (ActionMessage) it.next();
    assertEquals("alphaNumericStringArray", message.getKey());
    assertEquals("1", message.getValues()[0]);
    message = (ActionMessage) it.next();
    assertEquals("alphaNumericStringArray", message.getKey());
    assertEquals("3", message.getValues()[0]);

}

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

/**
 * testValidateArraysIndex29()/*from w  w w  .j  av a  2  s.c  o  m*/
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:*<br>
 *         (?) va:methodParams?F6S??<br>
 *                name?F"alphaNumericStringArray"<br>
 *         (?) field:property="rows.value"<br>
 *                arg:position="0",key="##INDEX",<br>
 *                  resource="false"<br>
 *                msg:key="alphaNumericStringArray",name="alphaNumericStringArray"<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:ANVtH?[?F"logon"<br>
 *         (?) session:L?[?F"logon"l<br>
 *                ActionFormIuWFNg<br>
 *         (?) ActionForm:DynaValidatorActionFormExCX^X<br>
 *                JavaBean[] rows<br>
 *                  +rows[0]<br>
 *                     + String value = ""<br>
 *                  +rows[1]<br>
 *                     + String value = "test"<br>
 *                  +rows[2]<br>
 *                     + String value = ""<br>
 *         (?) ?bZ?[W\?[X:message={0}<br>
 *
 * <br>
 * l?F(l) boolean:false<br>
 *         (?) errors:ActionMessage(<br>
 *                           "alphaNumericStringArray",<br>
 *                           arg{"2"})<br>
 *
 * <br>
 * ??lANVtH?[lXgv?peB???A????smF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
@SuppressWarnings("deprecation")
public void testValidateArraysIndex29() throws Exception {

    //eXgf?[^?
    this.formEx = (DynaValidatorActionFormEx) creator.create(CONFIG_FILE_NAME);
    // ++++ beanIuWFNg ++++
    String bean = null;

    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setMethodParams(this.validClassStr);
    va.setName("alphaNumericStringArray");

    // ++++ ?tB?[h?
    Field field = new Field();
    field.setProperty("rows.value");
    Var var = new Var();
    field.addVar(var);
    Arg arg0 = new Arg();
    arg0.setPosition(0);
    arg0.setKey("##INDEX");
    arg0.setResource(false);
    field.addArg(arg0);
    Msg msg = new Msg();
    msg.setKey("alphaNumericStringArray");
    msg.setName("alphaNumericStringArray");
    field.addMsg(msg);
    UTUtil.invokePrivate(field, "process", Map.class, Map.class, new HashMap(), new HashMap());

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    FieldChecksEx_HttpServletRequestImpl01 request = new FieldChecksEx_HttpServletRequestImpl01();
    ActionMappingEx mapping = new ActionMappingEx();
    mapping.setName("logon");
    request.setAttribute(Globals.MAPPING_KEY, mapping);
    MockHttpSession session = new MockHttpSession();
    FieldChecksEx_JavaBeanStub01[] rows = { new FieldChecksEx_JavaBeanStub01(),
            new FieldChecksEx_JavaBeanStub01(), new FieldChecksEx_JavaBeanStub01() };
    rows[0].value = "";
    rows[1].value = "test";
    rows[2].value = "";
    formEx.set("rows", rows);

    session.setAttribute("logon", formEx);
    request.setSession(session);

    FieldChecksEx_MessageResourcesImpl01 messageResources = new FieldChecksEx_MessageResourcesImpl01(null,
            null);
    messageResources.message = "{0}";
    request.setAttribute(Globals.MESSAGES_KEY, messageResources);

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

    // eXg?s
    boolean result = FieldChecksEx.validateArraysIndex(bean, va, field, errors, validator, request);
    // eXgmF
    // falsep?B
    assertFalse(result);
    // G?[?2??B
    assertEquals(2, errors.size());
    Iterator it = errors.get();
    ActionMessage message = (ActionMessage) it.next();
    assertEquals("alphaNumericStringArray", message.getKey());
    assertEquals("1", message.getValues()[0]);
    message = (ActionMessage) it.next();
    assertEquals("alphaNumericStringArray", message.getKey());
    assertEquals("3", message.getValues()[0]);

}

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

/**
 * testValidateArraysIndex31()/* w w  w .j a v a  2 s .  c  o m*/
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:*<br>
 *         (?) va:methodParams?F6S??<br>
 *                name?F"requiredArray"<br>
 *         (?) field:property="/"<br>
 *                arg:position="0",key="##INDEX",<br>
 *                  resource="false"<br>
 *                msg:key="requiredArray",name="requiredArray"<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:ANVtH?[?F"logon"<br>
 *         (?) session:L?[?F"logon"l<br>
 *                ActionFormIuWFNg<br>
 *         (?) ActionForm:DynaValidatorActionFormExCX^X<br>
 *                ArrayList<JavaBean> rowList<br>
 *                 + rowList[0]<br>
 *                     + Map map = { key = null }<br>
 *                 + rowList[1]<br>
 *                     + Map map = { key = null }<br>
 *                 + rowList[2]<br>
 *                     + Map map = { key = null }<br>
 *         (?) ?bZ?[W\?[X:message={0}<br>
 *
 * <br>
 * l?F(l) boolean:true<br>
 *         (?) ?O:?Ox?FG?[
 *                         O?FIllegalArgumentException
 *                               "Invalid character has found within property name. '/' Cannot use [ / \" ' ]"
 *
 * <br>
 * s?v?peBw???AG?[?O?o?AtruemF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
@SuppressWarnings({ "deprecation", "unchecked" })
public void testValidateArraysIndex31() throws Exception {
    //eXgf?[^?
    this.formEx = (DynaValidatorActionFormEx) creator.create(CONFIG_FILE_NAME);
    // ++++ beanIuWFNg ++++
    String bean = null;

    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setMethodParams(this.validClassStr);
    va.setName("requiredArray");

    // ++++ ?tB?[h?
    Field field = new Field();
    field.setProperty("/");
    Var var = new Var();
    field.addVar(var);
    Arg arg0 = new Arg();
    arg0.setPosition(0);
    arg0.setKey("##INDEX");
    arg0.setResource(false);
    field.addArg(arg0);
    Msg msg = new Msg();
    msg.setKey("requiredArray");
    msg.setName("requiredArray");
    field.addMsg(msg);
    UTUtil.invokePrivate(field, "process", Map.class, Map.class, new HashMap(), new HashMap());

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    FieldChecksEx_HttpServletRequestImpl01 request = new FieldChecksEx_HttpServletRequestImpl01();
    ActionMappingEx mapping = new ActionMappingEx();
    mapping.setName("logon");
    request.setAttribute(Globals.MAPPING_KEY, mapping);
    MockHttpSession session = new MockHttpSession();
    List rowList = new ArrayList();
    FieldChecksEx_JavaBeanStub01 row = new FieldChecksEx_JavaBeanStub01();
    Map map = new HashMap();
    map.put("key", null);
    row.map = map;
    rowList.add(row);
    row = new FieldChecksEx_JavaBeanStub01();
    map = new HashMap();
    map.put("key", null);
    row.map = map;
    rowList.add(row);
    row = new FieldChecksEx_JavaBeanStub01();
    map = new HashMap();
    map.put("key", null);
    row.map = map;
    rowList.add(row);
    formEx.set("rowList", rowList);

    session.setAttribute("logon", formEx);
    request.setSession(session);

    FieldChecksEx_MessageResourcesImpl01 messageResources = new FieldChecksEx_MessageResourcesImpl01(null,
            null);
    messageResources.message = "{0}";
    request.setAttribute(Globals.MESSAGES_KEY, messageResources);

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

    // eXg?s
    boolean result = FieldChecksEx.validateArraysIndex(bean, va, field, errors, validator, request);
    // eXgmF
    // truep?B
    assertTrue(result);
    // G?[?O
    assertTrue(LogUTUtil.checkError("", new IllegalArgumentException(
            "Invalid character has found " + "within property name. '/' Cannot use [ / \" ' ]")));

}

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

/**
 * testValidateArraysIndex16()//w w w  . j  a v  a  2s. c  om
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:*<br>
 *         (?) va:methodParams?F6S??<br>
 *                name?F"hankakuString12345"<br>
 *         (?) field:property="codeArray"<br>
 *                arg:position="0",key="##INDEX",resource="false"<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:ANVtH?[?F"logon"<br>
 *         (?) session:L?[?F"logon"l<br>
 *                ActionFormIuWFNg<br>
 *         (?) ActionForm:ArrayList codeArray = {<br>
 *                    ""<br>
 *                }<br>
 *
 * <br>
 * l?F(l) boolean:true<br>
 *         (?) errors:not null<br>
 *                    (vf)<br>
 *
 * <br>
 * ??[??[?iCfbNX`FbNO?j
 * +5?[?A??smF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateArraysIndex16() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = null;

    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setMethodParams(this.validClassStr);
    va.setName("hankakuString12345");

    // ++++ ?tB?[h?
    Field field = new Field();
    field.setProperty("codeArray");

    Arg arg0 = new Arg();
    arg0.setKey("##INDEX");
    arg0.setPosition(0);
    arg0.setResource(false);
    field.addArg(arg0);

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    FieldChecksEx_HttpServletRequestImpl01 request = new FieldChecksEx_HttpServletRequestImpl01();
    ActionMappingEx mapping = new ActionMappingEx();
    mapping.setName("logon");
    request.setAttribute(Globals.MAPPING_KEY, mapping);
    MockHttpSession session = new MockHttpSession();
    ArrayList<String> testList = new ArrayList<String>();
    testList.add("");
    form.setCodeArray(testList);
    session.setAttribute("logon", form);
    request.setSession(session);

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

    // eXg?s
    boolean result = FieldChecksEx.validateArraysIndex(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.FieldChecksExTest06.java

/**
 * testValidateArraysIndex25()//from  w w w . j  ava 2s  . c  o m
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:*<br>
 *         (?) va:methodParams?F6S??<br>
 *                name?F"minLengthArray"<br>
 *         (?) field:property="row.values"<br>
 *                var:minlength="3"<br>
 *                arg:position="0",key="##INDEX",<br>
 *                  resource="false"<br>
 *                arg:position="1",key="${var:minlength}",<br>
 *                  resource="false"<br>
 *                msg:key="minLengthArray",name="minLengthArray"<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:ANVtH?[?F"logon"<br>
 *         (?) session:L?[?F"logon"l<br>
 *                ActionFormIuWFNg<br>
 *         (?) ActionForm:JavaBean row<br>
 *                 + String[] values = {<br>
 *                     "a", "bbbb","cc"<br>
 *                }<br>
 *         (?) ?bZ?[W\?[X:message={0},{1}<br>
 *
 * <br>
 * l?F(l) boolean:false<br>
 *         (?) errors:ActionMessage(<br>
 *                      "minLengthArray",<br>
 *                      arg{"2","3"})<br>
 *
 * <br>
 * ??lANVtH?[lXgv?peB???A????smF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
@SuppressWarnings("deprecation")
public void testValidateArraysIndex25() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = null;

    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setMethodParams(this.validClassStr);
    va.setName("minLengthArray");

    // ++++ ?tB?[h?
    Field field = new Field();
    field.setProperty("row.values");
    Var var = new Var();
    var.setName("minlength");
    var.setValue("3");
    field.addVar(var);
    Arg arg0 = new Arg();
    arg0.setPosition(0);
    arg0.setKey("##INDEX");
    arg0.setResource(false);
    //arg0.setName("minLengthArray");
    field.addArg(arg0);
    Arg arg1 = new Arg();
    arg1.setPosition(1);
    arg1.setKey("${var:minlength}");
    arg1.setResource(false);
    //arg1.setName("minLength");
    field.addArg(arg1);
    Msg msg = new Msg();
    msg.setKey("minLengthArray");
    msg.setName("minLengthArray");
    field.addMsg(msg);
    UTUtil.invokePrivate(field, "process", Map.class, Map.class, new HashMap(), new HashMap());

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    FieldChecksEx_HttpServletRequestImpl01 request = new FieldChecksEx_HttpServletRequestImpl01();
    ActionMappingEx mapping = new ActionMappingEx();
    mapping.setName("logon");
    request.setAttribute(Globals.MAPPING_KEY, mapping);
    MockHttpSession session = new MockHttpSession();
    FieldChecksEx_JavaBeanStub01 row = new FieldChecksEx_JavaBeanStub01();
    String[] values = { "a", "bbbb", "cc" };
    row.values = values;
    form.setRow(row);
    session.setAttribute("logon", form);
    request.setSession(session);

    FieldChecksEx_MessageResourcesImpl01 messageResources = new FieldChecksEx_MessageResourcesImpl01(null,
            null);
    messageResources.message = "{0},{1}";
    request.setAttribute(Globals.MESSAGES_KEY, messageResources);

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

    // eXg?s
    boolean result = FieldChecksEx.validateArraysIndex(bean, va, field, errors, validator, request);
    // eXgmF
    // falsep?B
    assertFalse(result);
    // G?[?1??B
    assertEquals(2, errors.size());
    Iterator it = errors.get();
    ActionMessage message = (ActionMessage) it.next();
    assertEquals("minLengthArray", message.getKey());
    assertEquals("1", message.getValues()[0]);
    assertEquals("3", message.getValues()[1]);
    message = (ActionMessage) it.next();
    assertEquals("minLengthArray", message.getKey());
    assertEquals("3", message.getValues()[0]);
    assertEquals("3", message.getValues()[1]);

}

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

/**
 * testValidateArraysIndex28()/*  www  .  j  a v a2  s.c  o  m*/
 * <br><br>
 *
 * (??n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:*<br>
 *         (?) va:methodParams?F6S??<br>
 *                name?F"minLengthArray"<br>
 *         (?) field:property="row.values"<br>
 *                var:minlength="3"<br>
 *                arg:position="0",key="##INDEX",<br>
 *                  resource="false"<br>
 *                arg:position="1",key="${var:minlength}",<br>
 *                  resource="false"<br>
 *                msg:key="minLengthArray",name="minLengthArray"<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:ANVtH?[?F"logon"<br>
 *         (?) session:L?[?F"logon"l<br>
 *                ActionFormIuWFNg<br>
 *         (?) ActionForm:DynaValidatorActionFormExCX^X<br>
 *                JavaBean row<br>
 *                 + String[] values = {<br>
 *                     "a", "bbbb","cc"<br>
 *                }<br>
 *         (?) ?bZ?[W\?[X:message={0},{1}<br>
 *
 * <br>
 * l?F(l) boolean:false<br>
 *         (?) errors:ActionMessage(<br>
 *                      "minLengthArray",<br>
 *                      arg{"2","3"})<br>
 *
 * <br>
 * ??lANVtH?[lXgv?peB???A????smF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
@SuppressWarnings("deprecation")
public void testValidateArraysIndex28() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    this.formEx = (DynaValidatorActionFormEx) creator.create(CONFIG_FILE_NAME);
    String bean = null;

    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setMethodParams(this.validClassStr);
    va.setName("minLengthArray");

    // ++++ ?tB?[h?
    Field field = new Field();
    field.setProperty("row.values");
    Var var = new Var();
    var.setName("minlength");
    var.setValue("3");
    field.addVar(var);
    Arg arg0 = new Arg();
    arg0.setPosition(0);
    arg0.setKey("##INDEX");
    arg0.setResource(false);
    //arg0.setName("minLengthArray");
    field.addArg(arg0);
    Arg arg1 = new Arg();
    arg1.setPosition(1);
    arg1.setKey("${var:minlength}");
    arg1.setResource(false);
    //arg1.setName("minLength");
    field.addArg(arg1);
    Msg msg = new Msg();
    msg.setKey("minLengthArray");
    msg.setName("minLengthArray");
    field.addMsg(msg);
    UTUtil.invokePrivate(field, "process", Map.class, Map.class, new HashMap(), new HashMap());

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    FieldChecksEx_HttpServletRequestImpl01 request = new FieldChecksEx_HttpServletRequestImpl01();
    ActionMappingEx mapping = new ActionMappingEx();
    mapping.setName("logon");
    request.setAttribute(Globals.MAPPING_KEY, mapping);
    MockHttpSession session = new MockHttpSession();
    FieldChecksEx_JavaBeanStub01 row = new FieldChecksEx_JavaBeanStub01();
    String[] values = { "a", "bbbb", "cc" };
    row.values = values;
    formEx.set("row", row);
    session.setAttribute("logon", formEx);
    request.setSession(session);

    FieldChecksEx_MessageResourcesImpl01 messageResources = new FieldChecksEx_MessageResourcesImpl01(null,
            null);
    messageResources.message = "{0},{1}";
    request.setAttribute(Globals.MESSAGES_KEY, messageResources);

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

    // eXg?s
    boolean result = FieldChecksEx.validateArraysIndex(bean, va, field, errors, validator, request);
    // eXgmF
    // falsep?B
    assertFalse(result);
    // G?[?2??B
    assertEquals(2, errors.size());
    Iterator it = errors.get();
    ActionMessage message = (ActionMessage) it.next();
    assertEquals("minLengthArray", message.getKey());
    assertEquals("1", message.getValues()[0]);
    assertEquals("3", message.getValues()[1]);
    message = (ActionMessage) it.next();
    assertEquals("minLengthArray", message.getKey());
    assertEquals("3", message.getValues()[0]);
    assertEquals("3", message.getValues()[1]);

}