ComponentProxyObjectFactory { protected long getLastModified(String filePath) { long lastModified = 0L; try { String tmpFilePath = filePath.replace('\\', '/').replaceAll(" ", "%20"); URI fileURI = new URI(tmpFilePath); File configFile = new File(fileURI); if (configFile.exists()) { lastModified = configFile.lastModified(); } else { LOG.error(filePath + " does not exist."); } } catch (URISyntaxException use) { LOG.error("Error getting last modified: " + use.getMessage(), use); } return lastModified; }    }
@Test public void testGetLastModified() { try { ComponentProxyObjectFactory sut = new ComponentProxyObjectFactory() { @Override protected long getLastModified(String filePath) { return 6L; } @Override protected String getConfigFileName() { return ""; } }; long lastModified = sut.getLastModified(""); assertEquals("Last modified not equal", 6L, lastModified); } catch (Throwable t) { System.out.println("Error running testGetLastModified test: " + t.getMessage()); t.printStackTrace(); fail("Error running testGetLastModified test: " + t.getMessage()); } }