### Question:
SpringResourceTemplateLocator extends AbstractTemplateLocator implements ResourceLoaderAware { public Reader locate(final String name) { final String resourceLocation = prefix + name + suffix; try { if (Strings.isEmpty(charset)) { return new InputStreamReader(resourceLoader.getResource(resourceLocation).getInputStream()); } return new InputStreamReader(resourceLoader.getResource(resourceLocation).getInputStream(), charset); } catch (UnsupportedEncodingException e) { LOGGER.warn("Charset not supported: {}", charset); } catch (IOException e) { LOGGER.warn("Template not found: {}", resourceLocation); } return null; } SpringResourceTemplateLocator();  SpringResourceTemplateLocator(final int priority, final String prefix, final String suffix); void setResourceLoader(final ResourceLoader resourceLoader); Reader locate(final String name); String getPrefix(); void setPrefix(final String prefix); String getSuffix(); void setSuffix(final String suffix); String getCharset(); void setCharset(final String charset); static final String DEFAULT_PREFIX; static final String DEFAULT_SUFFIX; }### Answer:
@Test public void availabilityOfTemplateInDefaultLocation() throws Exception { final SpringResourceTemplateLocator loader = new SpringResourceTemplateLocator(); final Reader r1 = loader.locate("home"); assertThat(readContent(r1), is("home")); final Reader r2 = loader.locate("prefix/prefixed"); assertThat(readContent(r2), is("prefixed")); }
@Test public void availabilityOfTemplateThatDoesNotExist() throws Exception { final SpringResourceTemplateLocator loader = new SpringResourceTemplateLocator(); assertThat(loader.locate("unknown"), is(nullValue())); }
@Test public void availabilityOfTemplateWithCustomPrefix() throws Exception { final SpringResourceTemplateLocator loader = new SpringResourceTemplateLocator(1, "classpath:/custom-templates/", SpringResourceTemplateLocator.DEFAULT_SUFFIX); final Reader reader = loader.locate("custom"); assertThat(readContent(reader), is("custom")); }
@Test public void availabilityOfTemplateWithCustomSuffix() throws Exception { final SpringResourceTemplateLocator loader = new SpringResourceTemplateLocator(1, SpringResourceTemplateLocator.DEFAULT_PREFIX, ".html"); final Reader reader = loader.locate("suffixed"); assertThat(readContent(reader), is("suffixed")); }