use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class HttpRequestServiceTest method testRequest_GetMethod_ZeroBytes.
@Test
public void testRequest_GetMethod_ZeroBytes() throws Exception {
MockMessageProducer mock = new MockMessageProducer();
HttpConnection jc = HttpHelper.createConnection();
JettyMessageConsumer mc = createConsumer(HttpHelper.URL_TO_POST_TO);
Channel c = createChannel(jc, createWorkflow(mc, mock, new ServiceList(new Service[] { new PayloadFromTemplateService().withTemplate(TEXT), new StandaloneProducer(new StandardResponseProducer(HttpStatus.OK_200)) })));
HttpRequestService service = new HttpRequestService(HttpHelper.createProduceDestination(c)).withMethod("GET");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
try {
start(c);
execute(service, msg);
waitForMessages(mock, 1);
} finally {
HttpHelper.stopChannelAndRelease(c);
}
assertEquals(1, mock.messageCount());
AdaptrisMessage m2 = mock.getMessages().get(0);
assertEquals("GET", m2.getMetadataValue(CoreConstants.HTTP_METHOD));
assertEquals(TEXT, msg.getContent());
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class FilesystemRetryStoreTest method testWrite_Exception.
@Test(expected = InterlokException.class)
public void testWrite_Exception() throws Exception {
FilesystemRetryStore store = new FilesystemRetryStore().withBaseUrl(INVALID_URL);
try {
LifecycleHelper.initAndStart(store);
AdaptrisMessage msg = new DefaultMessageFactory().newMessage("hello");
store.write(msg);
} finally {
LifecycleHelper.stopAndClose(store);
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class FilesystemRetryStoreTest method testWrite_PayloadMetadataException.
@Test
public void testWrite_PayloadMetadataException() throws Exception {
FilesystemRetryStore store = new FilesystemRetryStore().withBaseUrl(BaseCase.getConfiguration(TEST_BASE_URL));
try {
LifecycleHelper.initAndStart(store);
AdaptrisMessage msg = new DefaultMessageFactory().newMessage("hello");
msg.addObjectHeader(CoreConstants.OBJ_METADATA_EXCEPTION, new Exception());
store.write(msg);
File retryDir = FsHelper.toFile(BaseCase.getConfiguration(TEST_BASE_URL));
File msgDir = new File(retryDir, msg.getUniqueId());
assertTrue(retryDir.listFiles((FileFilter) DirectoryFileFilter.DIRECTORY).length >= 1);
assertTrue(msgDir.exists());
assertEquals(3, msgDir.listFiles().length);
} finally {
LifecycleHelper.stopAndClose(store);
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class FilesystemRetryStoreTest method testReport.
@Test
public void testReport() throws Exception {
FilesystemRetryStore store = new FilesystemRetryStore().withBaseUrl(BaseCase.getConfiguration(TEST_BASE_URL));
try {
LifecycleHelper.initAndStart(store);
AdaptrisMessage msg = new DefaultMessageFactory().newMessage("hello");
store.write(msg);
assertTrue(store.report().iterator().hasNext());
} finally {
LifecycleHelper.stopAndClose(store);
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class FilesystemRetryStoreTest method testGetMetadata.
@Test
public void testGetMetadata() throws Exception {
FilesystemRetryStore store = new FilesystemRetryStore().withBaseUrl(BaseCase.getConfiguration(TEST_BASE_URL));
try {
LifecycleHelper.initAndStart(store);
AdaptrisMessage msg = new DefaultMessageFactory().newMessage("hello");
store.write(msg);
Map<String, String> metadata = store.getMetadata(msg.getUniqueId());
assertEquals(msg.getMessageHeaders(), metadata);
} finally {
LifecycleHelper.stopAndClose(store);
}
}
Aggregations