@Test(expected = Exception.class) public void testNotFound() throws Exception { context.checking(new Expectations() { { allowing(resource).exists(); will(returnValue(false)); } }); sut.afterPropertiesSet(); context.assertIsSatisfied(); }
@Override public void afterPropertiesSet() throws Exception { Resource resource = resourceLoader.getResource(resourcePath); if (!resource.exists()) { throw new FileNotFoundException("Required resource '" + resourcePath + "' not found."); } final int bufferSize = 16 * 1024; char[] buffer = new char[bufferSize]; Reader reader = new BufferedReader(new InputStreamReader(resource.getInputStream())); StringBuilder builder = new StringBuilder(); try { int numRead; while ((numRead = reader.read(buffer)) > 0) { builder.append(buffer, 0, numRead); } } finally { reader.close(); } resourceContent = builder.toString(); }
ResourceContentLoaderFactoryBean implements FactoryBean, InitializingBean, ResourceLoaderAware { @Override public void afterPropertiesSet() throws Exception { Resource resource = resourceLoader.getResource(resourcePath); if (!resource.exists()) { throw new FileNotFoundException("Required resource '" + resourcePath + "' not found."); } final int bufferSize = 16 * 1024; char[] buffer = new char[bufferSize]; Reader reader = new BufferedReader(new InputStreamReader(resource.getInputStream())); StringBuilder builder = new StringBuilder(); try { int numRead; while ((numRead = reader.read(buffer)) > 0) { builder.append(buffer, 0, numRead); } } finally { reader.close(); } resourceContent = builder.toString(); } }
ResourceContentLoaderFactoryBean implements FactoryBean, InitializingBean, ResourceLoaderAware { @Override public void afterPropertiesSet() throws Exception { Resource resource = resourceLoader.getResource(resourcePath); if (!resource.exists()) { throw new FileNotFoundException("Required resource '" + resourcePath + "' not found."); } final int bufferSize = 16 * 1024; char[] buffer = new char[bufferSize]; Reader reader = new BufferedReader(new InputStreamReader(resource.getInputStream())); StringBuilder builder = new StringBuilder(); try { int numRead; while ((numRead = reader.read(buffer)) > 0) { builder.append(buffer, 0, numRead); } } finally { reader.close(); } resourceContent = builder.toString(); } ResourceContentLoaderFactoryBean(final String inResourcePath); }
ResourceContentLoaderFactoryBean implements FactoryBean, InitializingBean, ResourceLoaderAware { @Override public void afterPropertiesSet() throws Exception { Resource resource = resourceLoader.getResource(resourcePath); if (!resource.exists()) { throw new FileNotFoundException("Required resource '" + resourcePath + "' not found."); } final int bufferSize = 16 * 1024; char[] buffer = new char[bufferSize]; Reader reader = new BufferedReader(new InputStreamReader(resource.getInputStream())); StringBuilder builder = new StringBuilder(); try { int numRead; while ((numRead = reader.read(buffer)) > 0) { builder.append(buffer, 0, numRead); } } finally { reader.close(); } resourceContent = builder.toString(); } ResourceContentLoaderFactoryBean(final String inResourcePath); @Override Object getObject(); @Override Class getObjectType(); @Override boolean isSingleton(); @Override void afterPropertiesSet(); @Override void setResourceLoader(final ResourceLoader inResourceLoader); }
ResourceContentLoaderFactoryBean implements FactoryBean, InitializingBean, ResourceLoaderAware { @Override public void afterPropertiesSet() throws Exception { Resource resource = resourceLoader.getResource(resourcePath); if (!resource.exists()) { throw new FileNotFoundException("Required resource '" + resourcePath + "' not found."); } final int bufferSize = 16 * 1024; char[] buffer = new char[bufferSize]; Reader reader = new BufferedReader(new InputStreamReader(resource.getInputStream())); StringBuilder builder = new StringBuilder(); try { int numRead; while ((numRead = reader.read(buffer)) > 0) { builder.append(buffer, 0, numRead); } } finally { reader.close(); } resourceContent = builder.toString(); } ResourceContentLoaderFactoryBean(final String inResourcePath); @Override Object getObject(); @Override Class getObjectType(); @Override boolean isSingleton(); @Override void afterPropertiesSet(); @Override void setResourceLoader(final ResourceLoader inResourceLoader);  }