MessageIdUtils { public static boolean isCorrectFormat(final String messageId) { if (Utils.isNullOrEmpty(messageId)) return false; else return messageId.matches(RFC2822_MESSAGE_ID); }  static String createMessageId(); static String createContentId(final String msgId); static boolean isAllowed(final String messageId); static boolean isCorrectFormat(final String messageId); static String stripBrackets(final String messageId);  }
@Test public void testCheckMessageId() { assertTrue(MessageIdUtils.isCorrectFormat("just.a.test@holodeck-b2b.org")); assertTrue(MessageIdUtils.isCorrectFormat("justatest@holodeck-b2b.org")); assertTrue(MessageIdUtils.isCorrectFormat("just_a.test@holodeck-b2b.org")); assertTrue(MessageIdUtils.isCorrectFormat("just.8.test@holodeck-b2b.org")); assertTrue(MessageIdUtils.isCorrectFormat("`a#very$spe.cial%id!@some-where+{%&'*/}?^~|")); assertFalse(MessageIdUtils.isCorrectFormat("")); assertFalse(MessageIdUtils.isCorrectFormat("just.a.test")); assertFalse(MessageIdUtils.isCorrectFormat("just[8]test@holodeck-b2b.org")); }