use of org.apache.tools.ant.util.FlatFileNameMapper in project ant by apache.
the class MapperTest method testNested.
@Test
public void testNested() {
Mapper mapper1 = new Mapper(project);
Mapper.MapperType mt = new Mapper.MapperType();
mt.setValue("glob");
mapper1.setType(mt);
mapper1.setFrom("from*");
mapper1.setTo("to*");
// mix element types
FileNameMapper mapper2 = new FlatFileNameMapper();
FileNameMapper mapper3 = new MergingMapper();
mapper3.setTo("mergefile");
Mapper container = new Mapper(project);
container.addConfiguredMapper(mapper1);
container.add(mapper2);
container.add(mapper3);
FileNameMapper fileNameMapper = container.getImplementation();
String[] targets = fileNameMapper.mapFileName("fromfilename");
assertNotNull("no filenames mapped", targets);
assertEquals("wrong number of filenames mapped", 3, targets.length);
List list = Arrays.asList(targets);
assertTrue("cannot find expected target \"tofilename\"", list.contains("tofilename"));
assertTrue("cannot find expected target \"fromfilename\"", list.contains("fromfilename"));
assertTrue("cannot find expected target \"mergefile\"", list.contains("mergefile"));
}
Aggregations