/** Test the afterPropertiesSet() method. */
@Test public void testAfterPropertiesSet() throws Exception {
GaeVelocityTemplateService service = new GaeVelocityTemplateService();
GaeVelocityUtils gaeVelocityUtils = mock(GaeVelocityUtils.class);
Resource templateDirResource = mock(Resource.class, RETURNS_DEEP_STUBS); // so call1().call2().call3() works
try {
service.setGaeVelocityUtils(null);
service.setTemplateDirResource(templateDirResource);
service.afterPropertiesSet();
fail("Expected NotConfiguredException");
} catch (NotConfiguredException e) { }
try {
service.setGaeVelocityUtils(gaeVelocityUtils);
service.setTemplateDirResource(null);
service.afterPropertiesSet();
fail("Expected NotConfiguredException");
} catch (NotConfiguredException e) { }
try {
when(templateDirResource.exists()).thenReturn(false);
service.setGaeVelocityUtils(gaeVelocityUtils);
service.setTemplateDirResource(templateDirResource);
service.afterPropertiesSet();
} catch (NotConfiguredException e) { }
when(templateDirResource.exists()).thenReturn(true);
when(templateDirResource.getFile().getPath()).thenReturn("path");
service.setGaeVelocityUtils(gaeVelocityUtils);
service.setTemplateDirResource(templateDirResource);
service.afterPropertiesSet();
assertEquals("path", service.getTemplateDir());
}