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.assertEquals;
21  
22  import org.apache.commons.lang3.AbstractLangTest;
23  import org.junit.jupiter.api.Test;
24  
25  /**
26   * Unit tests for {@link org.apache.commons.lang3.text.translate.NumericEntityEscaper}.
27   */
28  @Deprecated
29  public class NumericEntityEscaperTest extends AbstractLangTest {
30  
31      @Test
32      public void testAbove() {
33          final NumericEntityEscaper nee = NumericEntityEscaper.above('F');
34  
35          final String input = "ADFGZ";
36          final String result = nee.translate(input);
37          assertEquals("ADFGZ", result, "Failed to escape numeric entities via the above method");
38      }
39  
40      @Test
41      public void testBelow() {
42          final NumericEntityEscaper nee = NumericEntityEscaper.below('F');
43  
44          final String input = "ADFGZ";
45          final String result = nee.translate(input);
46          assertEquals("ADFGZ", result, "Failed to escape numeric entities via the below method");
47      }
48  
49      @Test
50      public void testBetween() {
51          final NumericEntityEscaper nee = NumericEntityEscaper.between('F', 'L');
52  
53          final String input = "ADFGZ";
54          final String result = nee.translate(input);
55          assertEquals("ADFGZ", result, "Failed to escape numeric entities via the between method");
56      }
57  
58      // See LANG-617
59      @Test
60      public void testSupplementary() {
61          final NumericEntityEscaper nee = new NumericEntityEscaper();
62          final String input = "\uD803\uDC22";
63          final String expected = "𐰢";
64  
65          final String result = nee.translate(input);
66          assertEquals(expected, result, "Failed to escape numeric entities supplementary characters");
67  
68      }
69  
70  }