use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class FilesystemRetryStoreTest method testReport_Exception.
@Test(expected = InterlokException.class)
public void testReport_Exception() throws Exception {
FilesystemRetryStore store = new FilesystemRetryStore().withBaseUrl(INVALID_URL);
try {
LifecycleHelper.initAndStart(store);
AdaptrisMessage msg = new DefaultMessageFactory().newMessage("hello");
store.report();
} finally {
LifecycleHelper.stopAndClose(store);
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class ReportBuilderTest method testBuild.
@Test
public void testBuild() throws Exception {
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
ReportBuilder builder = new ReportBuilder();
try {
LifecycleHelper.initAndStart(builder);
builder.build(listFiles(10), msg);
try (InputStream in = msg.getInputStream()) {
List lines = IOUtils.readLines(in, StandardCharsets.UTF_8);
assertEquals(10, lines.size());
}
} finally {
LifecycleHelper.stopAndClose(builder);
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class RetryStoreListTest method testService_Exception.
@Test(expected = ServiceException.class)
public void testService_Exception() throws Exception {
AdaptrisMessage msg = new DefaultMessageFactory().newMessage("hello");
RetryStoreListService service = new RetryStoreListService().withRetryStore(new FilesystemRetryStore().withBaseUrl(INVALID_URL));
execute(service, msg);
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class GetAndCacheOauthTokenTest method testService_WithError.
@Test(expected = ServiceException.class)
public void testService_WithError() throws Exception {
ExpiringMapCache cache = new ExpiringMapCache().withExpiration(new TimeInterval(5L, TimeUnit.SECONDS));
AccessToken t = new AccessToken(getName());
GetAndCacheOauthToken service = new GetAndCacheOauthToken().withCacheKey("OauthToken").withConnection(new CacheConnection(cache)).withAccessTokenBuilder(new DummyAccessTokenBuilder(t, true));
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
execute(service, msg);
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class GetOauthTokenTest method testService.
@Test
@SuppressWarnings("deprecation")
public void testService() throws Exception {
long now = System.currentTimeMillis();
String expiryDate = DateFormatUtil.format(new Date(now));
AccessToken t = new AccessToken(getName(), now);
GetOauthToken service = new GetOauthToken().withAccessTokenWriter(new MetadataAccessTokenWriter().withTokenKey("Authorization"));
service.setAccessTokenBuilder(new DummyAccessTokenBuilder(t));
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
try {
execute(service, msg);
assertTrue(msg.headersContainsKey("Authorization"));
assertEquals("Bearer " + getName(), msg.getMetadataValue("Authorization"));
} finally {
}
assertTrue(msg.headersContainsKey("Authorization"));
assertEquals("Bearer " + getName(), msg.getMetadataValue("Authorization"));
assertFalse(msg.headersContainsKey("expiry"));
}
Aggregations