IllegalStateException in text.VariableFormatter with "empty" keys.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@225179 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d1f1606960
commit
abbe3f0e26
|
@ -390,16 +390,16 @@ public class VariableFormatter {
|
|||
objResult = doReplace(objResult, priorVariables);
|
||||
result.append(objResult);
|
||||
objLen = objResult.toString().length();
|
||||
|
||||
// pop the interpolated variable off the stack
|
||||
// this maintains priorVariables correctness for
|
||||
// properties with multiple interpolations, e.g.
|
||||
// prop.name=${some.other.prop1}/blahblah/${some.other.prop2}
|
||||
priorVariables.remove(priorVariables.size() - 1);
|
||||
} else {
|
||||
// variable not defined - so put it back in the value
|
||||
result.append(getVariablePrefix()).append(variable).append(getVariableSuffix());
|
||||
}
|
||||
|
||||
// pop the interpolated variable off the stack
|
||||
// this maintains priorVariables correctness for
|
||||
// properties with multiple interpolations, e.g.
|
||||
// prop.name=${some.other.prop1}/blahblah/${some.other.prop2}
|
||||
priorVariables.remove(priorVariables.size() - 1);
|
||||
}
|
||||
|
||||
prec = end;
|
||||
|
|
|
@ -226,6 +226,13 @@ public class VariableFormatterTest extends TestCase {
|
|||
assertEquals("Variable ${var} is unknown!", this.getFormat().replace("Variable ${var} is unknown!"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a replace template with missing empty marker strings.
|
||||
*/
|
||||
public void testReplaceEmptyKeys() {
|
||||
testReplaceNoElement(REPLACE_TEMPLATE_EMPTY_KEYS);
|
||||
}
|
||||
|
||||
void testReplaceNoElement(String badReplaceTemplate) {
|
||||
assertEquals(badReplaceTemplate, this.getFormat().replaceObject(badReplaceTemplate));
|
||||
Map map = this.getValueMap();
|
||||
|
@ -242,13 +249,6 @@ public class VariableFormatterTest extends TestCase {
|
|||
testReplaceNoElement(REPLACE_TEMPLATE_NO_ESCAPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a replace template with missing prefix strings.
|
||||
*/
|
||||
public void testReplaceNoPrefix() {
|
||||
testReplaceNoElement(REPLACE_TEMPLATE_NO_PREFIX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a replace template with missing marker strings.
|
||||
*/
|
||||
|
@ -257,15 +257,10 @@ public class VariableFormatterTest extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests a replace template with missing empty marker strings.
|
||||
* Tests a replace template with missing prefix strings.
|
||||
*/
|
||||
public void testReplaceEmptyKeys() {
|
||||
try {
|
||||
testReplaceNoElement(REPLACE_TEMPLATE_EMPTY_KEYS);
|
||||
fail("Expected IllegalStateException.");
|
||||
} catch (IllegalStateException e) {
|
||||
// expected for now.
|
||||
}
|
||||
public void testReplaceNoPrefix() {
|
||||
testReplaceNoElement(REPLACE_TEMPLATE_NO_PREFIX);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue