use of com.adaptris.core.DefaultMessageFactory 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.core.DefaultMessageFactory 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"));
}
use of com.adaptris.core.DefaultMessageFactory 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.core.DefaultMessageFactory in project interlok by adaptris.
the class DecodingServiceTest method testSetMessageFactory.
@Test
public void testSetMessageFactory() throws Exception {
DecodingService s = new DecodingService();
assertNull(s.getMessageFactory());
s = new DecodingService(new MockEncoder());
assertNull(s.getMessageFactory());
assertTrue(s.getEncoder().currentMessageFactory() instanceof DefaultMessageFactory);
s = new DecodingService(new MockEncoder());
AdaptrisMessageFactory amf = new StubMessageFactory();
s.setMessageFactory(amf);
try {
LifecycleHelper.init(s);
assertEquals(amf, s.getMessageFactory());
assertTrue(s.getEncoder().currentMessageFactory() instanceof StubMessageFactory);
assertEquals(amf, s.getEncoder().currentMessageFactory());
} finally {
LifecycleHelper.close(s);
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class EncodingServiceTest method testSetMessageFactory.
@Test
public void testSetMessageFactory() throws Exception {
EncodingService s = new EncodingService();
assertNull(s.getMessageFactory());
s = new EncodingService(new MockEncoder());
assertNull(s.getMessageFactory());
assertTrue(s.getEncoder().currentMessageFactory() instanceof DefaultMessageFactory);
s = new EncodingService(new MockEncoder());
AdaptrisMessageFactory amf = new StubMessageFactory();
s.setMessageFactory(amf);
try {
LifecycleHelper.init(s);
assertEquals(amf, s.getMessageFactory());
assertTrue(s.getEncoder().currentMessageFactory() instanceof StubMessageFactory);
assertEquals(amf, s.getEncoder().currentMessageFactory());
} finally {
LifecycleHelper.close(s);
}
}
Aggregations