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
The following commit(s) were added to refs/heads/master by this push:
new d36a5fa Move new method to tests since it is only used there is not
generally handy.
d36a5fa is described below
commit d36a5faf0560fce4f0d23ded7db8c915c68def91
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Jul 20 12:49:30 2020 -0400
Move new method to tests since it is only used there is not generally
handy.
---
.../java/org/apache/commons/text/StringSubstitutor.java | 13 -------------
.../org/apache/commons/text/StringSubstitutorTest.java | 15 ---------------
.../text/io/StringSubstitutorFilterReaderTest.java | 8 ++++++--
3 files changed, 6 insertions(+), 30 deletions(-)
diff --git a/src/main/java/org/apache/commons/text/StringSubstitutor.java
b/src/main/java/org/apache/commons/text/StringSubstitutor.java
index 6b6ebae..0400c43 100644
--- a/src/main/java/org/apache/commons/text/StringSubstitutor.java
+++ b/src/main/java/org/apache/commons/text/StringSubstitutor.java
@@ -603,19 +603,6 @@ public class StringSubstitutor {
}
/**
- * Gets the minimum expression length based on the size of the prefix
matcher and suffix matcher.
- * <p>
- * By default, {@code 4}, as the shortest variable name length is 1, for
example, {@code "${k}"}.
- * </p>
- *
- * @return the minimum expression length.
- * @since 1.9
- */
- public int getMinExpressionLength() {
- return getVariablePrefixMatcher().size() + 1 +
getVariableSuffixMatcher().size();
- }
-
- /**
* Gets the StringLookup that is used to lookup variables.
*
* @return The StringLookup
diff --git a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
index e5cc903..b4a7446 100644
--- a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
+++ b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
@@ -227,21 +227,6 @@ public class StringSubstitutorTest {
target.getValueDelimiterMatcher().toString());
}
- @Test
- public void testGetMinExpressionLength() throws IOException {
- final StringSubstitutor sub = new StringSubstitutor();
- assertEquals(4, sub.getMinExpressionLength());
- sub.setVariablePrefix('a');
- assertEquals(3, sub.getMinExpressionLength());
- sub.setVariablePrefix("abc");
- assertEquals(5, sub.getMinExpressionLength());
- sub.setVariableSuffix("xyz");
- assertEquals(7, sub.getMinExpressionLength());
- sub.setVariablePrefix(StringUtils.EMPTY);
- sub.setVariableSuffix(StringUtils.EMPTY);
- assertEquals(1, sub.getMinExpressionLength());
- }
-
/**
* Tests get set.
*/
diff --git
a/src/test/java/org/apache/commons/text/io/StringSubstitutorFilterReaderTest.java
b/src/test/java/org/apache/commons/text/io/StringSubstitutorFilterReaderTest.java
index fd246b8..bdae41d 100644
---
a/src/test/java/org/apache/commons/text/io/StringSubstitutorFilterReaderTest.java
+++
b/src/test/java/org/apache/commons/text/io/StringSubstitutorFilterReaderTest.java
@@ -183,6 +183,10 @@ public class StringSubstitutorFilterReaderTest extends
StringSubstitutorTest {
assertEquals(Objects.toString(expectedResult, StringUtils.EMPTY),
actualResultWriter.toString());
}
+ private int getMinExpressionLength(final StringSubstitutor substitutor) {
+ return substitutor.getVariablePrefixMatcher().size() + 1 +
substitutor.getVariableSuffixMatcher().size();
+ }
+
@Override
protected String replace(final StringSubstitutor substitutor, final String
source) throws IOException {
if (source == null) {
@@ -197,7 +201,7 @@ public class StringSubstitutorFilterReaderTest extends
StringSubstitutorTest {
public void testReadMixedBufferLengths1ToVarLenPlusNoReplace() throws
IOException {
final StringSubstitutor substitutor = new StringSubstitutor(values);
final String template = "123456";
- assertTrue(template.length() > substitutor.getMinExpressionLength() +
1);
+ assertTrue(template.length() > getMinExpressionLength(substitutor) +
1);
try (Reader reader = createReader(substitutor, template)) {
assertEquals('1', reader.read());
final char[] cbuf = new char[template.length() - 1];
@@ -225,7 +229,7 @@ public class StringSubstitutorFilterReaderTest extends
StringSubstitutorTest {
public void testReadMixedBufferLengthsVarLenPlusToNoReplace() throws
IOException {
final StringSubstitutor substitutor = new StringSubstitutor(values);
final String template = "123456";
- assertTrue(template.length() > substitutor.getMinExpressionLength() +
1);
+ assertTrue(template.length() > getMinExpressionLength(substitutor) +
1);
try (Reader reader = createReader(substitutor, template)) {
final int endIndex = template.length() - 1;
final char[] cbuf = new char[endIndex];