@Test public void verifyOneParameterIsHandledCorrectly() { String result = MessageFormatter.format("Value is {}.", 3).getMessage(); assertEquals("Value is 3.", result); result = MessageFormatter.format("Value is {", 3).getMessage(); assertEquals("Value is {", result); result = MessageFormatter.format("{} is larger than 2.", 3).getMessage(); assertEquals("3 is larger than 2.", result); result = MessageFormatter.format("No subst", 3).getMessage(); assertEquals("No subst", result); result = MessageFormatter.format("Incorrect {subst", 3).getMessage(); assertEquals("Incorrect {subst", result); result = MessageFormatter.format("Value is {bla} {}", 3).getMessage(); assertEquals("Value is {bla} 3", result); result = MessageFormatter.format("Escaped \\{} subst", 3).getMessage(); assertEquals("Escaped {} subst", result); result = MessageFormatter.format("{Escaped", 3).getMessage(); assertEquals("{Escaped", result); result = MessageFormatter.format("\\{}Escaped", 3).getMessage(); assertEquals("{}Escaped", result); result = MessageFormatter.format("File name is {{}}.", "App folder.zip").getMessage(); assertEquals("File name is {App folder.zip}.", result); result = MessageFormatter.format("File name is C:\\\\{}.", "App folder.zip").getMessage(); assertEquals("File name is C:\\App folder.zip.", result); }
static FormattingTuple format(String messagePattern, Object arg) { return arrayFormat(messagePattern, new Object[]{arg}); }
MessageFormatter { static FormattingTuple format(String messagePattern, Object arg) { return arrayFormat(messagePattern, new Object[]{arg}); } }
MessageFormatter { static FormattingTuple format(String messagePattern, Object arg) { return arrayFormat(messagePattern, new Object[]{arg}); } private  MessageFormatter(); }
MessageFormatter { static FormattingTuple format(String messagePattern, Object arg) { return arrayFormat(messagePattern, new Object[]{arg}); } private  MessageFormatter();  }
MessageFormatter { static FormattingTuple format(String messagePattern, Object arg) { return arrayFormat(messagePattern, new Object[]{arg}); } private  MessageFormatter();   }