You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by ad...@apache.org on 2019/05/02 13:40:15 UTC

[wicket] 09/15: WICKET-6657 change replaceAll() to replace() when a regex is not used

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

adelbene pushed a commit to branch WICKET-6662
in repository https://gitbox.apache.org/repos/asf/wicket.git

commit aab8d38348f35e7a164219f5f063bf90cbce9172
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Wed Apr 24 19:16:09 2019 +0200

    WICKET-6657 change replaceAll() to replace() when a regex is not used
    
    closes #354
---
 .../src/main/java/org/apache/wicket/util/lang/Args.java   |  2 +-
 .../test/java/org/apache/wicket/util/lang/ArgsTest.java   | 15 +++++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/wicket-util/src/main/java/org/apache/wicket/util/lang/Args.java b/wicket-util/src/main/java/org/apache/wicket/util/lang/Args.java
index 5d62b17..cd947d1 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/lang/Args.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/lang/Args.java
@@ -170,7 +170,7 @@ public class Args
 	 */
 	static String format(String msg, final Object... params)
 	{
-		msg = msg.replaceAll("\\{\\}", "%s");
+		msg = msg.replace("{}", "%s");
 		return String.format(msg, params);
 	}
 }
diff --git a/wicket-util/src/test/java/org/apache/wicket/util/lang/ArgsTest.java b/wicket-util/src/test/java/org/apache/wicket/util/lang/ArgsTest.java
index c70bc88..58b68a8 100644
--- a/wicket-util/src/test/java/org/apache/wicket/util/lang/ArgsTest.java
+++ b/wicket-util/src/test/java/org/apache/wicket/util/lang/ArgsTest.java
@@ -21,36 +21,39 @@ import org.junit.jupiter.api.Test;
 import java.util.Collection;
 import java.util.Collections;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
 /**
  * Tests for {@link Args}
  */
-public class ArgsTest
+class ArgsTest
 {
-
-
 	/**
 	 * Test for {@link Args#notEmpty(java.util.Collection, String, Object...)}
 	 */
 	@Test
-	public void notNullCollection()
+	void notNullCollection()
 	{
 		assertThrows(IllegalArgumentException.class, () -> {
 			Args.notEmpty((Collection<?>)null, "col");
 		});
-
 	}
 
 	/**
 	 * Test for {@link Args#notEmpty(java.util.Collection, String, Object...)}
 	 */
 	@Test
-	public void notEmptyCollection()
+	void notEmptyCollection()
 	{
 		assertThrows(IllegalArgumentException.class, () -> {
 			Args.notEmpty(Collections.emptySet(), "col");
 		});
 	}
 
+	@Test
+	void format()
+	{
+		assertEquals("Hello world", Args.format("Hello {}", "world"));
+	}
 }