@Test public void multipleMatchesNotSupported() throws Exception { this.view = new HttpMessageWriterView(CharSequenceEncoder.allMimeTypes()); this.view.setModelKeys(new HashSet<>(Arrays.asList("foo1", "foo2"))); this.model.addAttribute("foo1", "bar1"); this.model.addAttribute("foo2", "bar2"); try { doRender(); fail(); } catch (IllegalStateException ex) { String message = ex.getMessage(); assertTrue(message, message.contains("Map rendering is not supported")); } }
@Override protected void configureViewResolvers(ViewResolverRegistry registry) { registry.freeMarker(); registry.defaultViews(new HttpMessageWriterView(new Jackson2JsonEncoder())); }
@Test public void noMatchBecauseNotSupported() throws Exception { this.view = new HttpMessageWriterView(new Jaxb2XmlEncoder()); this.view.setModelKeys(new HashSet<>(Collections.singletonList("foo1"))); this.model.addAttribute("foo1", "bar1"); assertEquals("", doRender()); }
@Test public void defaultViews() throws Exception { View view = new HttpMessageWriterView(new Jackson2JsonEncoder()); this.registry.defaultViews(view); assertEquals(1, this.registry.getDefaultViews().size()); assertSame(view, this.registry.getDefaultViews().get(0)); }