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  
18  package org.apache.commons.lang3.text.translate;
19  
20  import static org.junit.jupiter.api.Assertions.assertTrue;
21  
22  import java.util.HashSet;
23  import java.util.Set;
24  
25  import org.apache.commons.lang3.AbstractLangTest;
26  import org.junit.jupiter.api.Test;
27  
28  /**
29   * Unit tests for {@link org.apache.commons.lang3.text.translate.EntityArrays}.
30   */
31  @Deprecated
32  public class EntityArraysTest extends AbstractLangTest {
33  
34      @Test
35      public void testConstructorExists() {
36          new EntityArrays();
37      }
38  
39      // LANG-659 - check arrays for duplicate entries
40      @Test
41      public void testHTML40_EXTENDED_ESCAPE() {
42          final Set<String> col0 = new HashSet<>();
43          final Set<String> col1 = new HashSet<>();
44          final String [][] sa = EntityArrays.HTML40_EXTENDED_ESCAPE();
45          for (int i =0; i <sa.length; i++) {
46              assertTrue(col0.add(sa[i][0]), "Already added entry 0: "+i+" "+sa[i][0]);
47              assertTrue(col1.add(sa[i][1]), "Already added entry 1: "+i+" "+sa[i][1]);
48          }
49      }
50  
51     // LANG-658 - check arrays for duplicate entries
52      @Test
53      public void testISO8859_1_ESCAPE() {
54          final Set<String> col0 = new HashSet<>();
55          final Set<String> col1 = new HashSet<>();
56          final String [][] sa = EntityArrays.ISO8859_1_ESCAPE();
57          boolean success = true;
58          for (int i =0; i <sa.length; i++) {
59              final boolean add0 = col0.add(sa[i][0]);
60              final boolean add1 = col1.add(sa[i][1]);
61              if (!add0) {
62                  success = false;
63                  System.out.println("Already added entry 0: "+i+" "+sa[i][0]+" "+sa[i][1]);
64              }
65              if (!add1) {
66                  success = false;
67                  System.out.println("Already added entry 1: "+i+" "+sa[i][0]+" "+sa[i][1]);
68              }
69          }
70          assertTrue(success, "One or more errors detected");
71      }
72  
73  
74  }