Instead, I found an easier answer - Spring's StaticMessageSource implementation. You can create an instance of this class, and add messages to it (code, locale and message):
StaticMessageSource messageSource = new StaticMessageSource(); messageSource.addMessage("my.message.path", Locale.US, "My Message");
With this solution, I was able to unit test my validator code with needing to wire up the actual MessageSource implementation. Obviously this solution will not work if you're testing/validating the actual message content.
No comments:
Post a Comment