Search in sources :

Example 1 with FlatFileNameMapper

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"));
}
Also used : GlobPatternMapper(org.apache.tools.ant.util.GlobPatternMapper) FileNameMapper(org.apache.tools.ant.util.FileNameMapper) FlatFileNameMapper(org.apache.tools.ant.util.FlatFileNameMapper) MergingMapper(org.apache.tools.ant.util.MergingMapper) ChainedMapper(org.apache.tools.ant.util.ChainedMapper) FlatFileNameMapper(org.apache.tools.ant.util.FlatFileNameMapper) List(java.util.List) FileNameMapper(org.apache.tools.ant.util.FileNameMapper) FlatFileNameMapper(org.apache.tools.ant.util.FlatFileNameMapper) MergingMapper(org.apache.tools.ant.util.MergingMapper) Test(org.junit.Test)

Aggregations

List (java.util.List)1 ChainedMapper (org.apache.tools.ant.util.ChainedMapper)1 FileNameMapper (org.apache.tools.ant.util.FileNameMapper)1 FlatFileNameMapper (org.apache.tools.ant.util.FlatFileNameMapper)1 GlobPatternMapper (org.apache.tools.ant.util.GlobPatternMapper)1 MergingMapper (org.apache.tools.ant.util.MergingMapper)1 Test (org.junit.Test)1