### Question:
PathUtils { public static String[] getMatchingPaths(final String[] includes, final String[] excludes, final String baseDir) { final DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir(baseDir); if (includes != null && includes.length > 0) scanner.setIncludes(includes); if (excludes != null && excludes.length > 0) scanner.setExcludes(excludes); scanner.scan(); return scanner.getIncludedFiles(); }  static String[] getMatchingPaths(final String[] includes,
			final String[] excludes, final String baseDir);  }### Answer:
@Test public void singleExlude() throws IOException { File dir = createDirectory(); File include = File.createTempFile("include", ".filetomatch", dir); File exclude = File.createTempFile("exlude", ".filetomatch", dir); String[] paths = PathUtils.getMatchingPaths(null, new String[] { exclude.getName() }, include.getParent()); assertNotNull(paths); assertEquals(1, paths.length); assertEquals(include.getName(), paths[0]); }
@Test public void singleInclude() throws IOException { File include = File .createTempFile("include", ".txt", createDirectory()); String[] paths = PathUtils.getMatchingPaths( new String[] { include.getName() }, null, include.getParent()); assertNotNull(paths); assertEquals(1, paths.length); assertEquals(include.getName(), paths[0]); }
@Test public void singleIncludeSingleExclude() throws IOException { File dir = createDirectory(); File include = File.createTempFile("include", ".filetomatch", dir); File.createTempFile("neutral", ".notmatch", dir); File exclude = File.createTempFile("exlude", ".filetomatch", dir); String[] paths = PathUtils.getMatchingPaths( new String[] { "*.filetomatch" }, new String[] { exclude.getName() }, include.getParent()); assertNotNull(paths); assertEquals(1, paths.length); assertEquals(include.getName(), paths[0]); }