View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.validator.routines.checkdigit;
18  
19  
20  /**
21   * ModulusTenCheckDigit Luhn Test.
22   *
23   * @version $Revision$
24   */
25  public class ModulusTenLuhnCheckDigitTest extends AbstractCheckDigitTest {
26  
27      private static final String VALID_VISA       = "4417123456789113";
28      private static final String VALID_SHORT_VISA = "4222222222222";
29      private static final String VALID_AMEX       = "378282246310005";
30      private static final String VALID_MASTERCARD = "5105105105105100";
31      private static final String VALID_DISCOVER   = "6011000990139424";
32      private static final String VALID_DINERS     = "30569309025904";
33  
34      /**
35       * Constructor
36       * @param name test name
37       */
38      public ModulusTenLuhnCheckDigitTest(String name) {
39          super(name);
40      }
41  
42      /**
43       * Set up routine & valid codes.
44       */
45      @Override
46      protected void setUp() throws Exception {
47          super.setUp();
48  
49          routine = new ModulusTenCheckDigit(new int[] {1, 2}, true, true);
50  
51          valid = new String[] {
52                  VALID_VISA,
53                  VALID_SHORT_VISA,
54                  VALID_AMEX,
55                  VALID_MASTERCARD,
56                  VALID_DISCOVER,
57                  VALID_DINERS};
58      }
59  }