2
* $Header: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/FieldTest.java,v 1.3 2004/02/21 17:10:30 rleland Exp $
4
* $Date: 2004/02/21 17:10:30 $
6
* ====================================================================
7
* Copyright 2001-2004 The Apache Software Foundation
9
* Licensed under the Apache License, Version 2.0 (the "License");
10
* you may not use this file except in compliance with the License.
11
* You may obtain a copy of the License at
13
* http://www.apache.org/licenses/LICENSE-2.0
15
* Unless required by applicable law or agreed to in writing, software
16
* distributed under the License is distributed on an "AS IS" BASIS,
17
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
* See the License for the specific language governing permissions and
19
* limitations under the License.
22
package org.apache.commons.validator;
24
import junit.framework.TestCase;
27
* Test <code>Field</code> objects.
29
public class FieldTest extends TestCase {
32
* FieldTest constructor.
39
* FieldTest constructor.
42
public FieldTest(String name) {
46
public void testGetArgs() {
47
// Arg with a validator name
49
a.setKey("my.resource.key");
50
a.setName("required");
52
// Arg without name so it will be stored under default name
54
a2.setKey("another.resource.key");
57
Field f = new Field();
58
// test empty args first
59
Arg[] emptyArgs = f.getArgs("required");
60
assertEquals(0, emptyArgs.length);
62
// add args for other tests
66
// test arg lookup for "required" validator
67
Arg[] args = f.getArgs("required");
68
assertEquals(2, args.length);
69
assertTrue(args[0] == a);
71
// test arg lookup for non-existent "required2" validator
72
// should find default arg for position 1
73
Arg[] args2 = f.getArgs("required2");
74
assertEquals(2, args2.length);
75
assertNull(args2[0]); // we didn't define a 0 position arg
76
assertTrue(args2[1] == a2);