use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class ReadMetadataFromFilesystemTest method testService_NoFile.
@Test
public void testService_NoFile() throws Exception {
String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", "");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
ReadMetadataFromFilesystem service = createService(subDir);
execute(service, msg);
assertFalse(msg.headersContainsKey("key5"));
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class ReadMetadataFromFilesystemTest method testService_DoNotOverwriteExistingMetadata.
@Test
public void testService_DoNotOverwriteExistingMetadata() throws Exception {
String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", "");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
msg.addMetadata("key5", "MyValue");
ReadMetadataFromFilesystem service = createService(subDir);
service.setOverwriteExistingMetadata(false);
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true));
String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId();
Properties p = createProperties();
writeProperties(p, new File(propsFilename), false);
execute(service, msg);
assertTrue(msg.headersContainsKey("key5"));
assertEquals("MyValue", msg.getMetadataValue("key5"));
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class ReadMetadataFromFilesystemTest method testService_OverwriteExistingMetadata.
@Test
public void testService_OverwriteExistingMetadata() throws Exception {
String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", "");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
msg.addMetadata("key5", "MyValue");
ReadMetadataFromFilesystem service = createService(subDir);
service.setOverwriteExistingMetadata(true);
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true));
String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId();
Properties p = createProperties();
writeProperties(p, new File(propsFilename), false);
execute(service, msg);
assertTrue(msg.headersContainsKey("key5"));
assertEquals("v5", msg.getMetadataValue("key5"));
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class ReadMetadataFromFilesystemTest method testService_InputXml.
@Test
public void testService_InputXml() throws Exception {
String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", "");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
ReadMetadataFromFilesystem service = createService(subDir);
service.setInputStyle(InputStyle.XML);
service.setFilenameCreator(new FormattedFilenameCreator());
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true));
String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId();
Properties p = createProperties();
writeProperties(p, new File(propsFilename), true);
execute(service, msg);
assertTrue(msg.headersContainsKey("key5"));
assertEquals("v5", msg.getMetadataValue("key5"));
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class ReadMetadataFromFilesystemTest method testService_Default.
@Test
public void testService_Default() throws Exception {
String subDir = new GuidGenerator().safeUUID();
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
ReadMetadataFromFilesystem service = createService(subDir);
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true));
String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId();
Properties p = createProperties();
writeProperties(p, new File(propsFilename), false);
execute(service, msg);
assertTrue(msg.headersContainsKey("key5"));
assertEquals("v5", msg.getMetadataValue("key5"));
}
Aggregations