use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class ReadMetadataFromFilesystemTest method testService_DestinationIsFile.
@Test
public void testService_DestinationIsFile() throws Exception {
String subDir = new GuidGenerator().safeUUID();
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
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);
ReadMetadataFromFilesystem service = createService(subDir + "/" + msg.getUniqueId());
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 SimpleSequenceNumberTest method testDoService_NumberFormatting.
@Test
public void testDoService_NumberFormatting() throws Exception {
SimpleSequenceNumberService service = new SimpleSequenceNumberService();
service.setMetadataKey(DEFAULT_METADATA_KEY);
String filename = new File(PROPERTIES.getProperty(KEY_BASEDIR), new GuidGenerator().getUUID()).getCanonicalPath();
service.setSequenceNumberFile(filename);
service.setNumberFormat(DEFAULT_NUMBER_FORMAT);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
execute(service, msg);
assertEquals(2, getSequenceNumber(filename));
assertTrue(msg.containsKey(DEFAULT_METADATA_KEY));
assertEquals("000000001", msg.getMetadataValue(DEFAULT_METADATA_KEY));
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class SimpleSequenceNumberTest method testDoService_FileIsDirectory.
@Test
public void testDoService_FileIsDirectory() throws Exception {
SimpleSequenceNumberService service = new SimpleSequenceNumberService();
service.setMetadataKey(DEFAULT_METADATA_KEY);
File dir = new File(PROPERTIES.getProperty(KEY_BASEDIR), new GuidGenerator().getUUID());
dir.mkdirs();
service.setSequenceNumberFile(dir.getCanonicalPath());
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
try {
execute(service, msg);
fail();
} catch (ServiceException expected) {
}
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class SimpleSequenceNumberTest method testDoService_MetadataExistsOverwrite.
@Test
public void testDoService_MetadataExistsOverwrite() throws Exception {
SimpleSequenceNumberService service = new SimpleSequenceNumberService();
service.setMetadataKey(DEFAULT_METADATA_KEY);
String filename = new File(PROPERTIES.getProperty(KEY_BASEDIR), new GuidGenerator().getUUID()).getCanonicalPath();
service.setSequenceNumberFile(filename);
service.setAlwaysReplaceMetadata(Boolean.TRUE);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(DEFAULT_METADATA_KEY, "testDoService_MetadataExistsNoOverwrite");
execute(service, msg);
assertEquals(2, getSequenceNumber(filename));
assertTrue(msg.containsKey(DEFAULT_METADATA_KEY));
assertEquals("1", msg.getMetadataValue(DEFAULT_METADATA_KEY));
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class SimpleSequenceNumberTest method testDoService_FileExists.
@Test
public void testDoService_FileExists() throws Exception {
SimpleSequenceNumberService service = new SimpleSequenceNumberService();
service.setMetadataKey(DEFAULT_METADATA_KEY);
String filename = new File(PROPERTIES.getProperty(KEY_BASEDIR), new GuidGenerator().getUUID()).getCanonicalPath();
createPropertyFile(filename, 5);
service.setSequenceNumberFile(filename);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
execute(service, msg);
assertEquals(6, getSequenceNumber(filename));
assertTrue(msg.containsKey(DEFAULT_METADATA_KEY));
assertEquals("5", msg.getMetadataValue(DEFAULT_METADATA_KEY));
}
Aggregations