@Test public void testNoLatestVersion() throws IOException { File oldFile = File.createTempFile("test", ".txt", tmpDir); oldFile.delete(); URI uri = oldFile.toURI(); Assert.assertNull( finder.getLatestVersion(uri, Pattern.compile(".*\\.txt")) ); }
@Test public void testSimpleOneFileLatestVersion() throws IOException { File oldFile = File.createTempFile("old", ".txt", tmpDir); Assert.assertTrue(oldFile.exists()); Assert.assertEquals( oldFile.getAbsolutePath(), finder.getLatestVersion(oldFile.toURI(), Pattern.compile(".*\\.txt")).getPath() ); }
@Test public void testSimpleOneFileLatestVersionNullMatcher() throws IOException { File oldFile = File.createTempFile("old", ".txt", tmpDir); Assert.assertTrue(oldFile.exists()); Assert.assertEquals( oldFile.getAbsolutePath(), finder.getLatestVersion(oldFile.toURI(), null).getPath() ); }
@Test public void testExampleRegex() throws IOException { File tmpFile = new File(tmpDir, "renames-123.gz"); tmpFile.createNewFile(); Assert.assertTrue(tmpFile.exists()); Assert.assertFalse(tmpFile.isDirectory()); Assert.assertEquals( tmpFile.getAbsolutePath(), finder.getLatestVersion(tmpDir.toURI(), Pattern.compile("renames-[0-9]*\\.gz")).getPath() ); } }