protected void setUp() throws Exception { factory = new NodeFactory(); RegularExpressionSelectionCriteria filterCriteria = new RegularExpressionSelectionCriteria("//"); filterCriteria.setGlobalExcludes("/java.lang/"); ClassfileLoader loader = new AggregatingClassfileLoader(); loader.addLoadListener( new LoadListenerVisitorAdapter(new CodeDependencyCollector(factory, filterCriteria))); loader.load(Collections.singleton(TEST_FILENAME)); }
private void doTestLine( final String artist, final String album, final String title, final String year, final String path, final String genre, final long lastModified, final long length) { MusicFile file = new MusicFile() { public synchronized MetaData getMetaData() { MetaData metaData = new MetaData(); metaData.setArtist(artist); metaData.setAlbum(album); metaData.setTitle(title); metaData.setYear(year); metaData.setGenre(genre); return metaData; } public File getFile() { return new File(path); } public boolean isFile() { return true; } public boolean isDirectory() { return false; } public long lastModified() { return lastModified; } public long length() { return length; } }; SearchService.Line line = SearchService.Line.forFile( file, Collections.<File, SearchService.Line>emptyMap(), Collections.<File>emptySet()); String yearString = year == null ? "" : year; String expected = 'F' + SearchService.Line.SEPARATOR + lastModified + SearchService.Line.SEPARATOR + lastModified + SearchService.Line.SEPARATOR + path + SearchService.Line.SEPARATOR + length + SearchService.Line.SEPARATOR + artist + SearchService.Line.SEPARATOR + album + SearchService.Line.SEPARATOR + title + SearchService.Line.SEPARATOR + yearString + SearchService.Line.SEPARATOR + StringUtils.capitalize(genre); assertEquals("Error in toString().", expected, line.toString()); assertEquals( "Error in forFile().", expected, SearchService.Line.forFile( file, Collections.<File, SearchService.Line>emptyMap(), Collections.<File>emptySet()) .toString()); assertEquals("Error in parse().", expected, SearchService.Line.parse(expected).toString()); }