### Question:
MessageFormatter { public static FormattingTuple format(String messagePattern, Object arg) { return arrayFormat(messagePattern, new Object[]{arg}); }  static FormattingTuple format(String messagePattern, Object arg); static FormattingTuple format(final String messagePattern, Object arg1, Object arg2); static FormattingTuple arrayFormat(final String messagePattern, final @Nullable Object[] argArray);  }### Answer:
@Test public void testOneParameter() { String result = MessageFormatter.format("Value is {}.", 3).getFormattedMessage(); assertEquals("Value is 3.", result); result = MessageFormatter.format("Value is {", 3).getFormattedMessage(); assertEquals("Value is {", result); result = MessageFormatter.format("{} is larger than 2.", 3).getFormattedMessage(); assertEquals("3 is larger than 2.", result); result = MessageFormatter.format("No subst", 3).getFormattedMessage(); assertEquals("No subst", result); result = MessageFormatter.format("Incorrect {subst", 3).getFormattedMessage(); assertEquals("Incorrect {subst", result); result = MessageFormatter.format("Value is {bla} {}", 3).getFormattedMessage(); assertEquals("Value is {bla} 3", result); result = MessageFormatter.format("Escaped \\{} subst", 3).getFormattedMessage(); assertEquals("Escaped {} subst", result); result = MessageFormatter.format("{Escaped", 3).getFormattedMessage(); assertEquals("{Escaped", result); result = MessageFormatter.format("\\{}Escaped", 3).getFormattedMessage(); assertEquals("{}Escaped", result); result = MessageFormatter.format("File name is {{}}.", "App folder.zip").getFormattedMessage(); assertEquals("File name is {App folder.zip}.", result); result = MessageFormatter.format("File name is C:\\\\{}.", "App folder.zip").getFormattedMessage(); assertEquals("File name is C:\\App folder.zip.", result); }
@Test public void testTwoParameters() { String result = MessageFormatter.format("Value {} is smaller than {}.", 1, 2).getFormattedMessage(); assertEquals("Value 1 is smaller than 2.", result); result = MessageFormatter.format("Value {} is smaller than {}", 1, 2).getFormattedMessage(); assertEquals("Value 1 is smaller than 2", result); result = MessageFormatter.format("{}{}", 1, 2).getFormattedMessage(); assertEquals("12", result); result = MessageFormatter.format("Val1={}, Val2={", 1, 2).getFormattedMessage(); assertEquals("Val1=1, Val2={", result); result = MessageFormatter.format("Value {} is smaller than \\{}", 1, 2).getFormattedMessage(); assertEquals("Value 1 is smaller than {}", result); result = MessageFormatter.format("Value {} is smaller than \\{} tail", 1, 2).getFormattedMessage(); assertEquals("Value 1 is smaller than {} tail", result); result = MessageFormatter.format("Value {} is smaller than \\{", 1, 2).getFormattedMessage(); assertEquals("Value 1 is smaller than \\{", result); result = MessageFormatter.format("Value {} is smaller than {tail", 1, 2).getFormattedMessage(); assertEquals("Value 1 is smaller than {tail", result); result = MessageFormatter.format("Value \\{} is smaller than {}", 1, 2).getFormattedMessage(); assertEquals("Value {} is smaller than 1", result); }
@Test public void testExceptionIn_toString() { Object o = new TestExceptionIn_toString(); String result = MessageFormatter.format("Troublesome object {}", o).getFormattedMessage(); assertEquals("Troublesome object [FAILED toString(); toString threw exception: jsimple.util.BasicException: a]", result); }