PropertyHolder { public static String getErrorMessage(final int code, final Object... params) { String message = ERROR_MESSAGE.get(code + GlobalConstants.BLANK); if (StringUtils.isNotEmpty(message)) { if (CommonUtil.isNotEmpty(params)) { return CommonUtil.messageFormat(message, params); } return message; } return GlobalConstants.BLANK + code; }  static Map<String, String> getProperties(); static Boolean getBooleanProperty(final String name); static Boolean getBooleanProperty(final String name, final Boolean defaultValue); static Integer getIntProperty(final String name); static Integer getIntProperty(final String name, final Integer defaultValue); static Long getLongProperty(final String name); static Long getLongProperty(final String name, final Long defaultValue); static String getProperty(final String name); static String getProperty(final String name, final String defaultValue); static void setProperty(final String name, final String value); static String getErrorMessage(final int code, final Object... params); static String getProjectName(); static String getVersion();  }
@Test public void getErrorMessage() { String e1 = PropertyHolder.getErrorMessage(ErrorCodeDef.SYSTEM_ERROR_10001); Assert.equals(e1, "系统错误", ErrorCodeDef.SYSTEM_ERROR_10001); String e2 = PropertyHolder.getErrorMessage(-1); Assert.equals(e2, "-1", ErrorCodeDef.SYSTEM_ERROR_10001); String e3 = PropertyHolder.getErrorMessage(NUM_8888); Assert.equals(e3, "demo", ErrorCodeDef.SYSTEM_ERROR_10001); String e4 = PropertyHolder.getErrorMessage(NUM_9998, "a"); Assert.equals(e4, "测试a测试", ErrorCodeDef.SYSTEM_ERROR_10001); String e5 = PropertyHolder.getErrorMessage(NUM_9999); Assert.equals(e5, "测试", ErrorCodeDef.SYSTEM_ERROR_10001); }