You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/05/29 11:33:39 UTC

[commons-text] branch master updated (9bd9f6a0 -> a2bcc4a2)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git


    from 9bd9f6a0 Bump mockito-inline from 4.5.1 to 4.6.0 #330
     new b479a8df Move test fixture to absolute Apache Commons location on classpath
     new 03c906f7 Get Checkstyle to pass on Windows
     new 1d22d51c Remove noisy inline comment.
     new a2bcc4a2 Fix Checkstyle issue in FormattableUtils

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 checkstyle-suppressions.xml                            |  1 -
 checkstyle.xml                                         |  4 +---
 pom.xml                                                |  8 ++++----
 .../java/org/apache/commons/text/FormattableUtils.java | 18 +++++++++---------
 src/main/java/org/apache/commons/text/StrBuilder.java  |  1 -
 .../org/apache/commons/text/StringSubstitutor.java     |  2 +-
 src/site/xdoc/userguide.xml                            |  2 +-
 .../java/org/apache/commons/text/StrLookupTest.java    |  2 +-
 ...ingSubstitutorWithInterpolatorStringLookupTest.java |  6 +++---
 .../text/lookup/ResourceBundleStringLookupTest.java    |  2 +-
 .../text}/example/testResourceBundleLookup.properties  |  0
 11 files changed, 21 insertions(+), 25 deletions(-)
 rename src/test/resources/org/{ => apache/commons/text}/example/testResourceBundleLookup.properties (100%)


[commons-text] 03/04: Remove noisy inline comment.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 1d22d51ca15b1f02d5357743f41ad7d7c50571d3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 29 07:32:30 2022 -0400

    Remove noisy inline comment.
---
 src/main/java/org/apache/commons/text/StrBuilder.java | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/text/StrBuilder.java b/src/main/java/org/apache/commons/text/StrBuilder.java
index 21bc815a..599017a3 100644
--- a/src/main/java/org/apache/commons/text/StrBuilder.java
+++ b/src/main/java/org/apache/commons/text/StrBuilder.java
@@ -2230,7 +2230,6 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
         return insert(index, String.valueOf(value));
     }
 
-    //-----------------------------------------------------------------------
     /**
      * Inserts the string representation of an object into this builder.
      * Inserting null will use the stored null text value.


[commons-text] 01/04: Move test fixture to absolute Apache Commons location on classpath

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit b479a8df62547b2e1b1501ebc97745a7c43778fc
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 29 07:29:23 2022 -0400

    Move test fixture to absolute Apache Commons location on classpath
---
 src/main/java/org/apache/commons/text/StringSubstitutor.java        | 2 +-
 src/site/xdoc/userguide.xml                                         | 2 +-
 src/test/java/org/apache/commons/text/StrLookupTest.java            | 2 +-
 .../text/StringSubstitutorWithInterpolatorStringLookupTest.java     | 6 +++---
 .../apache/commons/text/lookup/ResourceBundleStringLookupTest.java  | 2 +-
 .../commons/text}/example/testResourceBundleLookup.properties       | 0
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/StringSubstitutor.java b/src/main/java/org/apache/commons/text/StringSubstitutor.java
index a6691175..518eed25 100644
--- a/src/main/java/org/apache/commons/text/StringSubstitutor.java
+++ b/src/main/java/org/apache/commons/text/StringSubstitutor.java
@@ -150,7 +150,7 @@ import org.apache.commons.text.matcher.StringMatcherFactory;
  *     + "File Content:          ${file:UTF-8:src/test/resources/document.properties}\n"
  *     + "Java:                  ${java:version}\n" + "Localhost:             ${localhost:canonical-name}\n"
  *     + "Properties File:       ${properties:src/test/resources/document.properties::mykey}\n"
- *     + "Resource Bundle:       ${resourceBundle:org.example.testResourceBundleLookup:mykey}\n"
+ *     + "Resource Bundle:       ${resourceBundle:org.apache.commons.text.example.testResourceBundleLookup:mykey}\n"
  *     + "Script:                ${script:javascript:3 + 4}\n" + "System Property:       ${sys:user.dir}\n"
  *     + "URL Decoder:           ${urlDecoder:Hello%20World%21}\n"
  *     + "URL Encoder:           ${urlEncoder:Hello World!}\n"
diff --git a/src/site/xdoc/userguide.xml b/src/site/xdoc/userguide.xml
index 0b21c97e..a78902d5 100644
--- a/src/site/xdoc/userguide.xml
+++ b/src/site/xdoc/userguide.xml
@@ -200,7 +200,7 @@ final String text = interpolator.replace(
     "Java:                  ${java:version}\n" +
     "Localhost:             ${localhost:canonical-name}\n" +
     "Properties File:       ${properties:src/test/resources/document.properties::mykey}\n" +
-    "Resource Bundle:       ${resourceBundle:org.example.testResourceBundleLookup:mykey}\n" +
+    "Resource Bundle:       ${resourceBundle:org.apache.commons.text.example.testResourceBundleLookup:mykey}\n" +
     "Script:                ${script:javascript:3 + 4}\n" +
     "System Property:       ${sys:user.dir}\n" +
     "URL Decoder:           ${urlDecoder:Hello%20World%21}\n" +
diff --git a/src/test/java/org/apache/commons/text/StrLookupTest.java b/src/test/java/org/apache/commons/text/StrLookupTest.java
index f62a63ff..44ae9a32 100644
--- a/src/test/java/org/apache/commons/text/StrLookupTest.java
+++ b/src/test/java/org/apache/commons/text/StrLookupTest.java
@@ -65,7 +65,7 @@ public class StrLookupTest  {
 
     @Test
     public void testResourceBundleLookup() {
-        final ResourceBundle map = ResourceBundle.getBundle("org.example.testResourceBundleLookup");
+        final ResourceBundle map = ResourceBundle.getBundle("org.apache.commons.text.example.testResourceBundleLookup");
         assertEquals("value", StrLookup.resourceBundleLookup(map).lookup("key"));
         assertEquals("2", StrLookup.resourceBundleLookup(map).lookup("number"));
         assertNull(StrLookup.resourceBundleLookup(map).lookup(null));
diff --git a/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java b/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java
index 96634996..71df7906 100644
--- a/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java
@@ -103,7 +103,7 @@ public class StringSubstitutorWithInterpolatorStringLookupTest {
               + "Java:                  ${java:version}\n"
               + "Localhost:             ${localhost:canonical-name}\n"
               + "Properties File:       ${properties:src/test/resources/document.properties::mykey}\n"
-              + "Resource Bundle:       ${resourceBundle:org.example.testResourceBundleLookup:mykey}\n"
+              + "Resource Bundle:       ${resourceBundle:org.apache.commons.text.example.testResourceBundleLookup:mykey}\n"
               + "Script:                ${script:javascript:3 + 4}\n"
               + "System Property:       ${sys:user.dir}\n"
               + "URL Decoder:           ${urlDecoder:Hello%20World%21}\n"
@@ -120,13 +120,13 @@ public class StringSubstitutorWithInterpolatorStringLookupTest {
         Assertions.assertFalse(text.contains("${base64Encoder:HelloWorld!}"));
         Assertions.assertFalse(text.contains("${urlDecoder:Hello%20World%21}"));
         Assertions.assertFalse(text.contains("${urlEncoder:Hello World!}"));
-        Assertions.assertFalse(text.contains("${resourceBundle:org.example.testResourceBundleLookup:mykey}"));
+        Assertions.assertFalse(text.contains("${resourceBundle:org.apache.commons.text.example.testResourceBundleLookup:mykey}"));
         // System.out.println(text);
     }
     @Test
     public void testDefaultValueForMissingKeyInResourceBundle() {
         final StringLookup interpolatorStringLookup = StringLookupFactory.INSTANCE.interpolatorStringLookup(
-            StringLookupFactory.INSTANCE.resourceBundleStringLookup("org.example.testResourceBundleLookup"));
+            StringLookupFactory.INSTANCE.resourceBundleStringLookup("org.apache.commons.text.example.testResourceBundleLookup"));
         assertEquals("${missingKey:-defaultValue}", interpolatorStringLookup.lookup("keyWithMissingKey"));
         final StringSubstitutor stringSubstitutor = new StringSubstitutor(interpolatorStringLookup);
         // The following would throw a MissingResourceException before TEXT-165.
diff --git a/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java
index 44b4af00..7fb0f709 100644
--- a/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java
@@ -33,7 +33,7 @@ import org.junit.jupiter.api.Test;
 public class ResourceBundleStringLookupTest {
 
     private static final String KEY = "key";
-    private static final String TEST_RESOURCE_BUNDLE = "org.example.testResourceBundleLookup";
+    private static final String TEST_RESOURCE_BUNDLE = "org.apache.commons.text.example.testResourceBundleLookup";
 
     @Test
     public void testAny() {
diff --git a/src/test/resources/org/example/testResourceBundleLookup.properties b/src/test/resources/org/apache/commons/text/example/testResourceBundleLookup.properties
similarity index 100%
rename from src/test/resources/org/example/testResourceBundleLookup.properties
rename to src/test/resources/org/apache/commons/text/example/testResourceBundleLookup.properties


[commons-text] 04/04: Fix Checkstyle issue in FormattableUtils

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit a2bcc4a269176211bd2e516429ed37d06a32d490
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 29 07:33:33 2022 -0400

    Fix Checkstyle issue in FormattableUtils
---
 checkstyle-suppressions.xml                            |  1 -
 .../java/org/apache/commons/text/FormattableUtils.java | 18 +++++++++---------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml
index 7ed5c493..c34d65e0 100644
--- a/checkstyle-suppressions.xml
+++ b/checkstyle-suppressions.xml
@@ -19,7 +19,6 @@
    limitations under the License.
 -->
 <suppressions>
-  <suppress checks="LocalFinalVariableName" files="FormattableUtils.java" />
   <suppress checks="MagicNumber" files="JaccardDistance.java" />
   <suppress checks="MagicNumber" files="JaccardSimilarity.java" />
   <suppress checks="MagicNumber" files="JaroWinklerDistance.java" />
diff --git a/src/main/java/org/apache/commons/text/FormattableUtils.java b/src/main/java/org/apache/commons/text/FormattableUtils.java
index 642a1410..cd90e06d 100644
--- a/src/main/java/org/apache/commons/text/FormattableUtils.java
+++ b/src/main/java/org/apache/commons/text/FormattableUtils.java
@@ -83,29 +83,29 @@ public class FormattableUtils {
      * @param width  the width of the output, see {@code Formattable}
      * @param precision  the precision of the output, see {@code Formattable}
      * @param padChar  the pad character to use
-     * @param ellipsis  the ellipsis to use when precision dictates truncation, null or
+     * @param truncateEllipsis  the ellipsis to use when precision dictates truncation, null or
      *  empty causes a hard truncation
      * @return The {@code formatter} instance, not null
      * @throws IllegalArgumentException if {@code ellipsis.length() > precision},
      *  given that {@code ellipsis} is not null and {@code precision >= 0}
      */
     public static Formatter append(final CharSequence seq, final Formatter formatter, final int flags, final int width,
-            final int precision, final char padChar, final CharSequence ellipsis) {
-        if (!(ellipsis == null || precision < 0 || ellipsis.length() <= precision)) {
+            final int precision, final char padChar, final CharSequence truncateEllipsis) {
+        if (!(truncateEllipsis == null || precision < 0 || truncateEllipsis.length() <= precision)) {
             throw new IllegalArgumentException(
                     String.format("Specified ellipsis '%s' exceeds precision of %s",
-                            ellipsis,
+                            truncateEllipsis,
                             precision));
         }
         final StringBuilder buf = new StringBuilder(seq);
         if (precision >= 0 && precision < seq.length()) {
-            final CharSequence _ellipsis;
-            if (ellipsis == null) {
-                _ellipsis = StringUtils.EMPTY;
+            final CharSequence ellipsis;
+            if (truncateEllipsis == null) {
+                ellipsis = StringUtils.EMPTY;
             } else {
-                _ellipsis = ellipsis;
+                ellipsis = truncateEllipsis;
             }
-            buf.replace(precision - _ellipsis.length(), seq.length(), _ellipsis.toString());
+            buf.replace(precision - ellipsis.length(), seq.length(), ellipsis.toString());
         }
         final boolean leftJustify = (flags & LEFT_JUSTIFY) == LEFT_JUSTIFY;
         for (int i = buf.length(); i < width; i++) {


[commons-text] 02/04: Get Checkstyle to pass on Windows

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 03c906f73feef7b487e225cd33194cb849b9dcc2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 29 07:32:11 2022 -0400

    Get Checkstyle to pass on Windows
---
 checkstyle.xml | 4 +---
 pom.xml        | 8 ++++----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/checkstyle.xml b/checkstyle.xml
index 4ef4ccd8..86324b0a 100644
--- a/checkstyle.xml
+++ b/checkstyle.xml
@@ -63,9 +63,7 @@
 
     <!-- Checks whether files end with a new line.                        -->
     <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
-    <module name="NewlineAtEndOfFile">
-       <property name="lineSeparator" value="lf" />
-    </module>
+    <module name="NewlineAtEndOfFile" />
 
     <!-- Checks that property files contain the same keys.         -->
     <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
diff --git a/pom.xml b/pom.xml
index b4b2c091..4d0248d0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -210,10 +210,10 @@
         <version>${checkstyle.plugin.version}</version>
         <configuration>
           <enableRulesSummary>false</enableRulesSummary>
-          <configLocation>${basedir}/checkstyle.xml</configLocation>
-          <headerLocation>${basedir}/checkstyle-header.txt</headerLocation>
-          <suppressionsLocation>${basedir}/checkstyle-suppressions.xml</suppressionsLocation>
-          <suppressionsFileExpression>${basedir}/checkstyle-suppressions.xml</suppressionsFileExpression>
+          <configLocation>checkstyle.xml</configLocation>
+          <headerLocation>checkstyle-header.txt</headerLocation>
+          <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
+          <suppressionsFileExpression>checkstyle-suppressions.xml</suppressionsFileExpression>
           <includeTestSourceDirectory>true</includeTestSourceDirectory>
           <excludes>**/generated/**.java,**/jmh_generated/**.java</excludes>
         </configuration>