FilterFile { public static String toString(Filter filter) throws IOException { StringWriter stringWriter = new StringWriter(); FilterXpp3Writer xmlWriter = new FilterXpp3Writer(); xmlWriter.write(stringWriter, filter); return stringWriter.toString(); }  static Filter getFilter(File filterFile); static Filter getFilter(InputStream filterFile); static String toString(Filter filter);  }
@Test public void createEnhancedFilterTest() throws IOException { String expectedXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<filter>\n" + " <repositories>\n" + " <repository>\n" + " <id>ThisIsId</id>\n" + " <filenames>\n" + " <includes>\n" + " <include>*</include>\n" + " </includes>\n" + " <excludes>\n" + " <exclude>*.doc</exclude>\n" + " </excludes>\n" + " </filenames>\n" + " <paths>\n" + " <includes>\n" + " <include>*</include>\n" + " </includes>\n" + " <excludes>\n" + " <exclude>/tags/*</exclude>\n" + " </excludes>\n" + " </paths>\n" + " <properties>\n" + " <includes>\n" + " <include>*</include>\n" + " </includes>\n" + " <excludes>\n" + " <exclude>svm:*</exclude>\n" + " </excludes>\n" + " </properties>\n" + " </repository>\n" + " </repositories>\n" + "</filter>\n"; Repository repos = new Repository(); IncludeExcludeList includeList = new IncludeExcludeList(); includeList.addInclude("*"); includeList.addExclude("*.doc"); repos.setId("ThisIsId"); repos.setFilenames(includeList); IncludeExcludeList il = new IncludeExcludeList(); il.addInclude("*"); il.addExclude("/tags/*"); repos.setPaths(il); il = new IncludeExcludeList(); il.addInclude("*"); il.addExclude("svm:*"); repos.setProperties(il); Repositories repositories = new Repositories(); repositories.addRepository(repos); Filter filter = new Filter(); filter.setRepositories(repositories); assertEquals(FilterFile.toString(filter), expectedXML); }
@Test public void createDefaultFilterTest() throws IOException { String expectedXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<filter>\n" + " <repositories>\n" + " <repository>\n" + " <id>default</id>\n" + " <filenames>\n" + " <includes>\n" + " <include>.*</include>\n" + " </includes>\n" + " </filenames>\n" + " <paths>\n" + " <includes>\n" + " <include>*</include>\n" + " </includes>\n" + " </paths>\n" + " <properties>\n" + " <includes>\n" + " <include>*</include>\n" + " </includes>\n" + " </properties>\n" + " </repository>\n" + " </repositories>\n" + "</filter>\n"; Repository repos = new Repository(); IncludeExcludeList includeList = new IncludeExcludeList(); includeList.addInclude(".*"); repos.setId("default"); repos.setFilenames(includeList); IncludeExcludeList il = new IncludeExcludeList(); il.addInclude("*"); repos.setPaths(il); il = new IncludeExcludeList(); il.addInclude("*"); repos.setProperties(il); Repositories repositories = new Repositories(); repositories.addRepository(repos); Filter filter = new Filter(); filter.setRepositories(repositories); assertEquals(FilterFile.toString(filter), expectedXML); }