use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class RetryFromJettyTest method testExecuteQuietly.
@Test
public void testExecuteQuietly() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
NullService s1 = new NullService();
ThrowExceptionService s2 = new ThrowExceptionService(new ConfiguredException("failure"));
try {
start(s1, s2);
RetryFromJetty.executeQuietly(s1, msg);
RetryFromJetty.executeQuietly(s2, msg);
} finally {
stop(s1, s2);
}
}
use of com.adaptris.core.AdaptrisMessage 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.AdaptrisMessage 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.AdaptrisMessage 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"));
}
use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class MetadataTokenWriterTest method testApply.
@Test
public void testApply() throws Exception {
AccessToken token = new AccessToken("Bearer", "token").withRefreshToken("refresh").withExpiry(DateFormatUtil.format(new Date(System.currentTimeMillis() + 2000)));
MetadataAccessTokenWriter writer = new MetadataAccessTokenWriter().withTokenKey("access_token").withTokenExpiryKey("expiry_token").withRefreshTokenKey("refresh_token");
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
try {
LifecycleHelper.initAndStart(writer);
writer.apply(token, msg);
assertTrue(msg.headersContainsKey("access_token"));
assertEquals("Bearer token", msg.getMetadataValue("access_token"));
assertTrue(msg.headersContainsKey("expiry_token"));
assertTrue(msg.headersContainsKey("refresh_token"));
} finally {
LifecycleHelper.stopAndClose(writer);
}
}
Aggregations