From 9d9a50eef1e5079133a05a6f7074307a9879df14 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Sat, 11 Feb 2012 18:57:19 +0000 Subject: [PATCH] test same prefix/suffix git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1243121 13f79535-47bb-0310-9956-ffa450edef68 --- .../lang3/text/StrSubstitutorTest.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java b/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java index 6adbb29ce..81d14fee0 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java @@ -159,14 +159,14 @@ public class StrSubstitutorTest extends TestCase { /** * Tests when no prefix or suffix. */ - public void testReplaceNoPefixNoSuffix() { + public void testReplaceNoPrefixNoSuffix() { doTestReplace("The animal jumps over the lazy dog.", "The animal jumps over the ${target}.", true); } /** * Tests when no incomplete prefix. */ - public void testReplaceIncompletePefix() { + public void testReplaceIncompletePrefix() { doTestReplace("The {animal} jumps over the lazy dog.", "The {animal} jumps over the ${target}.", true); } @@ -466,14 +466,23 @@ public class StrSubstitutorTest extends TestCase { /** * Test the replace of a properties object */ - public void testSubstitutetDefaultProperties(){ + public void testSubstituteDefaultProperties(){ String org = "${doesnotwork}"; - System.setProperty("doesnotwork", "It work's!"); + System.setProperty("doesnotwork", "It works!"); // create a new Properties object with the System.getProperties as default Properties props = new Properties(System.getProperties()); - assertEquals("It work's!",StrSubstitutor.replace(org, props)); + assertEquals("It works!", StrSubstitutor.replace(org, props)); + } + + public void testSamePrefixAndSuffix() { + Map map = new HashMap(); + map.put("greeting", "Hello"); + map.put(" there ", "XXX"); + map.put("name", "commons"); + assertEquals("Hi commons!", StrSubstitutor.replace("Hi @name@!", map, "@", "@")); + assertEquals("Hello there commons!", StrSubstitutor.replace("@greeting@ there @name@!", map, "@", "@")); } //-----------------------------------------------------------------------