public void testExtract() {
Properties config = new Properties();
config.setProperty("filenamePattern", "(\\w*)_(\\d*)\\.txt");
config.setProperty("metadataKeys", "Name,ID");
FilenameRegexMetExtractor extractor = new FilenameRegexMetExtractor();
extractor.configure(config);
Reference ref = new Reference();
ref.setOrigReference("file:/foo/bar/foobar_001.txt");
ref.setDataStoreReference("file:/foo/bar/final/foobar_001.txt");
Product product = new Product();
product.getProductReferences().add(ref);
product.setProductStructure(Product.STRUCTURE_FLAT);
Metadata met = new Metadata();
try {
met = extractor.doExtract(product, met);
} catch (MetExtractionException e) {
fail(e.getMessage());
}
assertTrue(met.containsKey("Name"));