Messages { public static String getString(String key, Object... details) { String msg = null; try { msg = RESOURCE_BUNDLE.getString(key); } catch (MissingResourceException e) { return '!' + key + '!'; } if(details != null) { return String.format(msg, details); } return msg; } private  Messages(); static String getString(String key, Object... details);  }
@Test public void testGetString() { String str1Msg = "no configuration items found in database."; String str2Msg = "sssd conf template file read err: Network connect failed."; String str1 = Messages.getString("MGMT_VM_CFG.CFG_NOT_FOUND"); String str2 = Messages.getString("SSSD_CONF_TEMPLATE_READ_ERR", "Network connect failed."); assertEquals(str1, str1Msg); assertEquals(str2, str2Msg); }