commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chtom...@apache.org
Subject [3/4] [text] Merge branch 'master' of https://github.com/apache/commons-text into escape_html_once
Date Wed, 28 Dec 2016 15:54:11 GMT
Merge branch 'master' of https://github.com/apache/commons-text into escape_html_once


Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/52ade284
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/52ade284
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/52ade284

Branch: refs/heads/master
Commit: 52ade284ebca7549dd0d9f87db2f0e3dc625e623
Parents: 336204e 51914f1
Author: sampyash <sampanna.kahu@flipkart.com>
Authored: Wed Dec 28 20:42:57 2016 +0530
Committer: sampyash <sampanna.kahu@flipkart.com>
Committed: Wed Dec 28 20:42:57 2016 +0530

----------------------------------------------------------------------
 pom.xml                                         |   3 +
 src/changes/changes.xml                         |   4 +
 .../apache/commons/text/CharacterPredicate.java |  37 ++
 .../commons/text/CharacterPredicates.java       |  52 +++
 .../commons/text/RandomStringBuilder.java       | 354 -------------------
 .../commons/text/RandomStringGenerator.java     | 316 +++++++++++++++++
 .../apache/commons/text/StringEscapeUtils.java  |   8 -
 .../text/similarity/JaroWinklerDistance.java    | 320 +++--------------
 .../text/translate/SingleLookupTranslator.java  |   2 +-
 .../commons/text/CharacterPredicatesTest.java   |  50 +++
 .../commons/text/RandomStringBuilderTest.java   | 235 ------------
 .../commons/text/RandomStringGeneratorTest.java | 212 +++++++++++
 .../commons/text/StringEscapeUtilsTest.java     |  24 ++
 .../similarity/JaroWinklerDistanceTest.java     |   8 +-
 14 files changed, 759 insertions(+), 866 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/52ade284/src/main/java/org/apache/commons/text/StringEscapeUtils.java
----------------------------------------------------------------------
diff --cc src/main/java/org/apache/commons/text/StringEscapeUtils.java
index 16949da,9d98583..69ec2a1
--- a/src/main/java/org/apache/commons/text/StringEscapeUtils.java
+++ b/src/main/java/org/apache/commons/text/StringEscapeUtils.java
@@@ -210,8 -210,7 +210,6 @@@ public class StringEscapeUtils 
       * AggregateTranslator. Because, a SingleLookupTranslator only checks the values of
the
       * lookup table passed to that instance while deciding whether a value is
       * already translated or not.
--     *
-      * @since 3.0
       */
      public static final CharSequenceTranslator ESCAPE_HTML3_ONCE =
              new SingleLookupTranslator(EntityArrays.BASIC_ESCAPE(), EntityArrays.ISO8859_1_ESCAPE());
@@@ -245,8 -244,7 +243,6 @@@
       * AggregateTranslator. Because, a SingleLookupTranslator only checks the values of
the
       * lookup table passed to that instance while deciding whether a value is
       * already translated or not.
--     *
-      * @since 3.0
       */
      public static final CharSequenceTranslator ESCAPE_HTML4_ONCE =
              new SingleLookupTranslator(EntityArrays.BASIC_ESCAPE(), EntityArrays.ISO8859_1_ESCAPE(),
EntityArrays.HTML40_EXTENDED_ESCAPE());
@@@ -754,8 -752,7 +750,6 @@@
       * @see <a href="http://www.w3.org/TR/REC-html40/sgml/entities.html">HTML 4.0
Character entity references</a>
       * @see <a href="http://www.w3.org/TR/html401/charset.html#h-5.3">HTML 4.01 Character
References</a>
       * @see <a href="http://www.w3.org/TR/html401/charset.html#code-position">HTML
4.01 Code positions</a>
--     *
-      * @since 3.0
       */
      public static final String escapeHtml4Once(final String input) {
          return ESCAPE_HTML4_ONCE.translate(input);
@@@ -780,8 -777,7 +774,6 @@@
       *
       * @param input  the {@code String} to escape, may be null
       * @return a new escaped {@code String}, {@code null} if null string input
--     *
-      * @since 3.0
       */
      public static final String escapeHtml3Once(final String input) {
          return ESCAPE_HTML3_ONCE.translate(input);

http://git-wip-us.apache.org/repos/asf/commons-text/blob/52ade284/src/test/java/org/apache/commons/text/StringEscapeUtilsTest.java
----------------------------------------------------------------------
diff --cc src/test/java/org/apache/commons/text/StringEscapeUtilsTest.java
index a2ed65d,aeabd84..f716763
--- a/src/test/java/org/apache/commons/text/StringEscapeUtilsTest.java
+++ b/src/test/java/org/apache/commons/text/StringEscapeUtilsTest.java
@@@ -265,7 -265,32 +265,31 @@@ public class StringEscapeUtilsTest 
          }
      }
  
+     @Test
+     public void testEscapeHtml3Once() {
+         for (final String[] element : HTML_ESCAPES) {
+             final String message = element[0];
+             final String expected = element[1];
+             final String original = element[2];
+             assertEquals(message, expected, StringEscapeUtils.escapeHtml3Once(original));
+             assertEquals(message, expected, StringEscapeUtils.escapeHtml3Once(expected));
+             final StringWriter sw = new StringWriter();
+             try {
+                 StringEscapeUtils.ESCAPE_HTML3_ONCE.translate(original, sw);
+             } catch (final IOException e) {
+             }
+             final String actual = original == null ? null : sw.toString();
+             assertEquals(message, expected, actual);
+             final StringWriter sw2 = new StringWriter();
+             try {
+                 StringEscapeUtils.ESCAPE_HTML3_ONCE.translate(expected, sw2);
+             } catch (final IOException e) {
+             }
+             final String actual2 = original == null ? null : sw2.toString();
+             assertEquals(message, expected, actual2);
+         }
+     }
  
 -
      @Test
      public void testUnescapeHtml4() {
          for (final String[] element : HTML_ESCAPES) {


Mime
View raw message