public VelocityView build () { VelocityView view = new VelocityView (); super.initialize (view); view.setCacheTemplate (cacheTemplate); if (dateToolAttribute != null) view.setDateToolAttribute (dateToolAttribute); if (encoding != null) view.setEncoding (encoding); if (numberToolAttribute != null) view.setNumberToolAttribute (numberToolAttribute); if (toolAttributes != null) view.setToolAttributes (toolAttributes); if (velocityEngine != null) view.setVelocityEngine (velocityEngine); return view; }
@Override protected void initApplicationContext() { if (this.toolboxConfigLocation != null) { if (VelocityView.class.equals(getViewClass())) { this.logger.info("Using EmbeddedVelocityToolboxView instead of " + "default VelocityView due to specified toolboxConfigLocation"); setViewClass(EmbeddedVelocityToolboxView.class); } } super.initApplicationContext(); }
@Test public void standardViewWithoutToolboxConfig() throws Exception { ApplicationContext context = loadContext(WithoutToolboxConfig.class); EmbeddedVelocityViewResolver resolver = context .getBean(EmbeddedVelocityViewResolver.class); Object viewClass = ReflectionTestUtils.getField(resolver, "viewClass"); assertThat(viewClass).isEqualTo(VelocityView.class); }
@Test public void standardViewWithoutToolboxConfig() throws Exception { ApplicationContext context = loadContext(WithoutToolboxConfig.class); EmbeddedVelocityViewResolver resolver = context .getBean(EmbeddedVelocityViewResolver.class); Object viewClass = ReflectionTestUtils.getField(resolver, "viewClass"); assertEquals(VelocityView.class, viewClass); }
public void testSetIncorrectViewClass() { try { new JasperReportsViewResolver().setViewClass(VelocityView.class); fail("Should not be able to set view class to a class that does not extend AbstractJasperReportsView"); } catch (IllegalArgumentException ex) { // success } }
@Test(expected = IllegalArgumentException.class) public void setIncorrectViewClass() { // Should not be able to set view class to a class that does not extend // AbstractJasperReportsView. new JasperReportsViewResolver().setViewClass(VelocityView.class); }