Search in sources :

Example 21 with DefaultMessageFactory

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);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 22 with DefaultMessageFactory

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);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) InputStream(java.io.InputStream) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 23 with DefaultMessageFactory

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);
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 24 with DefaultMessageFactory

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);
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) TimeInterval(com.adaptris.util.TimeInterval) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ExpiringMapCache(com.adaptris.core.cache.ExpiringMapCache) CacheConnection(com.adaptris.core.services.cache.CacheConnection) Test(org.junit.Test)

Example 25 with DefaultMessageFactory

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"));
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)170 Test (org.junit.Test)163 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)158 Channel (com.adaptris.core.Channel)37 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)36 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)30 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)30 StandaloneProducer (com.adaptris.core.StandaloneProducer)27 ServiceException (com.adaptris.core.ServiceException)26 File (java.io.File)26 ServiceList (com.adaptris.core.ServiceList)18 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)18 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)18 StandardResponseProducer (com.adaptris.core.http.jetty.StandardResponseProducer)18 GuidGenerator (com.adaptris.util.GuidGenerator)18 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)15 ValidationStage (com.adaptris.transform.validate.ValidationStage)15 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)12 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)11 StandardWorkflow (com.adaptris.core.StandardWorkflow)10