use of org.springframework.web.reactive.result.view.DummyMacroRequestContext in project spring-framework by spring-projects.
the class FreeMarkerMacroTests method getMacroOutput.
private List<String> getMacroOutput(String name) throws Exception {
String macro = fetchMacro(name);
assertThat(macro).isNotNull();
storeTemplateInTempDir(macro);
Map<String, String> msgMap = new HashMap<>();
msgMap.put("hello", "Howdy");
msgMap.put("world", "Mundo");
TestBean darren = new TestBean("Darren", 99);
TestBean fred = new TestBean("Fred");
fred.setJedi(true);
darren.setSpouse(fred);
darren.setJedi(true);
darren.setStringArray(new String[] { "John", "Fred" });
Map<String, String> names = new HashMap<>();
names.put("Darren", "Darren Davison");
names.put("John", "John Doe");
names.put("Fred", "Fred Bloggs");
names.put("Rob&Harrop", "Rob Harrop");
ModelMap model = new ExtendedModelMap();
DummyMacroRequestContext rc = new DummyMacroRequestContext(this.exchange, model, this.applicationContext);
rc.setMessageMap(msgMap);
rc.setContextPath("/springtest");
model.put("command", darren);
model.put(FreeMarkerView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE, rc);
model.put("msgArgs", new Object[] { "World" });
model.put("nameOptionMap", names);
model.put("options", names.values());
FreeMarkerView view = new FreeMarkerView();
view.setApplicationContext(this.applicationContext);
view.setBeanName("myView");
view.setUrl("tmp.ftl");
view.setExposeSpringMacroHelpers(false);
view.setConfiguration(freeMarkerConfig);
view.render(model, null, this.exchange).subscribe();
return getOutput();
}
Aggregations