use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.
the class WriteMetadataToFilesystemTest method testService_Filter.
@Test
public void testService_Filter() throws Exception {
String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", "");
AdaptrisMessage msg = createMessage();
WriteMetadataToFilesystem service = createService(subDir);
RegexMetadataFilter filter = new RegexMetadataFilter();
filter.addIncludePattern("alt_key.*");
filter.addExcludePattern("^key.*");
service.setMetadataFilter(filter);
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true));
String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId();
execute(service, msg);
Properties p = readProperties(new File(propsFilename), false);
assertFalse(p.containsKey("key5"));
assertTrue(p.containsKey("alt_key5"));
assertEquals("av5", p.getProperty("alt_key5"));
}
use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.
the class WriteMetadataToFilesystemTest method testSetMetadataFilter.
@Test
public void testSetMetadataFilter() throws Exception {
WriteMetadataToFilesystem service = new WriteMetadataToFilesystem();
assertNull(service.getMetadataFilter());
service.setMetadataFilter(new RegexMetadataFilter());
assertEquals(RegexMetadataFilter.class, service.getMetadataFilter().getClass());
service.setMetadataFilter(null);
assertEquals(NoOpMetadataFilter.class, service.metadataFilter().getClass());
}
use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.
the class MetadataFilterServiceTest method testServiceIncludesAndExcludes.
@Test
public void testServiceIncludesAndExcludes() throws Exception {
AdaptrisMessage msg = createMessage();
MetadataFilterService service = new MetadataFilterService();
RegexMetadataFilter filter = new RegexMetadataFilter();
filter.addExcludePattern(REG_EXP);
filter.addIncludePattern(MATCH_ANY);
service.setFilter(filter);
execute(service, msg);
assertEquals(DEF_VALUE, msg.getMetadataValue(JMS_MESSAGE_ID));
assertFalse(msg.containsKey(JMS_KEY_1));
assertFalse(msg.containsKey(JMS_KEY_2));
assertFalse(msg.containsKey(JMS_KEY_3));
}
use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.
the class MetadataFilterServiceTest method testSetFilter.
@Test
public void testSetFilter() {
MetadataFilterService service = new MetadataFilterService();
assertEquals(NoOpMetadataFilter.class, service.getFilter().getClass());
service.setFilter(new RegexMetadataFilter());
assertEquals(RegexMetadataFilter.class, service.getFilter().getClass());
try {
service.setFilter(null);
fail();
} catch (IllegalArgumentException expected) {
}
assertEquals(RegexMetadataFilter.class, service.getFilter().getClass());
}
use of com.adaptris.core.metadata.RegexMetadataFilter in project interlok by adaptris.
the class MetadataFilterServiceTest method testServiceExclude.
@Test
public void testServiceExclude() throws Exception {
AdaptrisMessage msg = createMessage();
MetadataFilterService service = new MetadataFilterService();
RegexMetadataFilter filter = new RegexMetadataFilter();
filter.addExcludePattern(REG_EXP);
service.setFilter(filter);
execute(service, msg);
assertEquals(DEF_VALUE, msg.getMetadataValue(JMS_MESSAGE_ID));
assertFalse(msg.containsKey(JMS_KEY_1));
assertFalse(msg.containsKey(JMS_KEY_2));
assertFalse(msg.containsKey(JMS_KEY_3));
}
Aggregations