@Test
public void shouldSerializeErrorMessagesInJSON() throws Exception {

	Message normal = new ValidationMessage("The message", "category");
	I18nMessage i18ned = new I18nMessage("category", "message");
	i18ned.setBundle(new SingletonResourceBundle("message", "Something else"));
	MockSerializationResult result = new MockSerializationResult(XStreamBuilderImpl.cleanInstance(new MessageConverter())) {
		@Override
		public <T extends View> T use(Class<T> view) {
			return view.cast(new DefaultRepresentationResult(new FormatResolver() {
				public String getAcceptFormat() {
					return "json";
				}
				
			}, this, Arrays.<Serialization>asList(super.use(JSONSerialization.class)), null));
		}
	};
	DefaultStatus status = new DefaultStatus(response, result, config, new JavassistProxifier(new ObjenesisInstanceCreator()), router);
	
	status.badRequest(Lists.newArrayList(normal, i18ned));
	
	String serialized = result.serializedResult();
	assertThat(serialized, containsString("\"message\": \"The message\""));
	assertThat(serialized, containsString("\"category\": \"category\""));
	assertThat(serialized, containsString("\"message\": \"Something else\""));
	assertThat(serialized, not(containsString("\"validationMessage\"")));
	assertThat(serialized, not(containsString("\"i18nMessage\"")));
}