001    /**
002     * Copyright 2005-2011 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.krad.datadictionary.validation.charlevel;
017    
018    import org.junit.Test;
019    import org.kuali.rice.kns.datadictionary.validation.charlevel.NumericValidationPattern;
020    import org.kuali.rice.krad.datadictionary.validation.ValidationTestUtils;
021    import org.kuali.rice.test.BaseRiceTestCase;
022    
023    public class NumericValidationPatternTest extends BaseRiceTestCase {
024        private NumericValidationPattern pattern;
025    
026        
027        public void setUp() throws Exception {
028            pattern = new NumericValidationPattern();
029        }
030    
031    
032        @Test public final void testMatch_allowDefault() {
033            boolean[] expected = { true, // ""
034                    false, // "!!!"
035                    false, // "[a-9]"
036                    false, // "^A-Z"
037                    false, // "abc"
038                    false, // "a bc"
039                    false, // "a_bc"
040                    true, // "123"
041                    false, // "12 3"
042                    false, // "12_3"
043                    false, // "a1b2c3"
044                    false, // "a1b2_c3"
045                    false, // "a 1b2c3"
046                    false, // "a 1b2_c3"
047                    false, //"foo.bar"
048                    false, //"foo.bar_baz"
049                    false, //".bar_foo baz"
050            };
051    
052            ValidationTestUtils.assertPatternMatches(pattern, expected);
053        }
054    }