@Override public long lastModified() throws IOException { return this.encoded.lastModified(); }
@Override public long lastModified() throws IOException { return this.encoded.lastModified(); }
@Override public long lastModified() throws IOException { return this.original.lastModified(); }
@Override public long lastModified() throws IOException { return this.gzipped.lastModified(); }
@Override public long lastModified() throws IOException { return this.gzipped.lastModified(); }
@Override public long lastModified() throws IOException { return this.original.lastModified(); }
@Override public long lastModified() throws IOException { return this.delegate.lastModified(); }
public TransformedResource(Resource original, byte[] transformedContent) { super(transformedContent); this.filename = original.getFilename(); try { this.lastModified = original.lastModified(); } catch (IOException ex) { // should never happen throw new IllegalArgumentException(ex); } }
public TransformedResource(Resource original, byte[] transformedContent) { super(transformedContent); this.filename = original.getFilename(); try { this.lastModified = original.lastModified(); } catch (IOException ex) { // should never happen throw new IllegalArgumentException(ex); } }
@Override public long getLastModified(Object templateSource) { Resource resource = (Resource) templateSource; try { return resource.lastModified(); } catch (IOException ex) { if (logger.isDebugEnabled()) { logger.debug("Could not obtain last-modified timestamp for FreeMarker template in " + resource + ": " + ex); } return -1; } }
@Override public long lastModified() throws IOException { return this.original.lastModified(); }
@Override public long lastModified() throws IOException { return this.gzipped.lastModified(); }
@Override public long lastModified() throws IOException { return this.encoded.lastModified(); }
public TransformedResource(Resource original, byte[] transformedContent) { super(transformedContent); this.filename = original.getFilename(); try { this.lastModified = original.lastModified(); } catch (IOException ex) { // should never happen throw new IllegalArgumentException(ex); } }
/** * Retrieve the current last-modified timestamp of the underlying resource. * @return the current timestamp, or 0 if not determinable */ protected long retrieveLastModifiedTime() { try { return getResource().lastModified(); } catch (IOException ex) { if (logger.isDebugEnabled()) { logger.debug(getResource() + " could not be resolved in the file system - " + "current timestamp not available for script modification check", ex); } return 0; } }
/** * Retrieve the current last-modified timestamp of the underlying resource. * @return the current timestamp, or 0 if not determinable */ protected long retrieveLastModifiedTime() { try { return getResource().lastModified(); } catch (IOException ex) { if (logger.isDebugEnabled()) { logger.debug(getResource() + " could not be resolved in the file system - " + "current timestamp not available for script modification check", ex); } return 0; } }
fileTimestamp = resource.lastModified(); if (propHolder != null && propHolder.getFileTimestamp() == fileTimestamp) { if (logger.isDebugEnabled()) {
@Test public void doesNotPropagateFatalExceptionOnResourceThatCannotBeResolvedToAFile() throws Exception { Resource resource = mock(Resource.class); given(resource.lastModified()).willThrow(new IOException()); ResourceScriptSource scriptSource = new ResourceScriptSource(resource); long lastModified = scriptSource.retrieveLastModifiedTime(); assertEquals(0, lastModified); }
assertTrue(resource.isReadable()); assertTrue(resource.contentLength() > 0); assertTrue(resource.lastModified() > 0); assertTrue(relative1.isReadable()); assertTrue(relative1.contentLength() > 0); assertTrue(relative1.lastModified() > 0); assertTrue(relative2.isReadable()); assertTrue(relative2.contentLength() > 0); assertTrue(relative2.lastModified() > 0); assertTrue(relative3.isReadable()); assertTrue(relative3.contentLength() > 0); assertTrue(relative3.lastModified() > 0); relative4.lastModified(); fail("Should have thrown FileNotFoundException");
@Test public void lastModifiedWorksWithResourceThatDoesNotSupportFileBasedReading() throws Exception { Resource resource = mock(Resource.class); // underlying File is asked for so that the last modified time can be checked... // And then mock the file changing; i.e. the File says it has been modified given(resource.lastModified()).willReturn(100L, 100L, 200L); // does not support File-based reading; delegates to InputStream-style reading... //resource.getFile(); //mock.setThrowable(new FileNotFoundException()); given(resource.getInputStream()).willReturn(StreamUtils.emptyInput()); ResourceScriptSource scriptSource = new ResourceScriptSource(resource); assertTrue("ResourceScriptSource must start off in the 'isModified' state (it obviously isn't).", scriptSource.isModified()); scriptSource.getScriptAsString(); assertFalse("ResourceScriptSource must not report back as being modified if the underlying File resource is not reporting a changed lastModified time.", scriptSource.isModified()); // Must now report back as having been modified assertTrue("ResourceScriptSource must report back as being modified if the underlying File resource is reporting a changed lastModified time.", scriptSource.isModified()); }