Search in sources :

Example 1 with CacheConnection

use of com.adaptris.core.services.cache.CacheConnection 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 2 with CacheConnection

use of com.adaptris.core.services.cache.CacheConnection in project interlok by adaptris.

the class ServiceFromCacheTest method createCache.

private CacheConnection createCache(String key) throws Exception {
    ExpiringMapCache cacheInstance = new ExpiringMapCache();
    CacheConnection conn = new CacheConnection();
    conn.setCacheInstance(cacheInstance);
    LifecycleHelper.initAndStart(conn);
    conn.retrieveCache().put(key, DynamicServiceExecutorTest.createMessage(new ServiceList(new LogMessageService())).getContent());
    return conn;
}
Also used : ExpiringMapCache(com.adaptris.core.cache.ExpiringMapCache) ServiceList(com.adaptris.core.ServiceList) LogMessageService(com.adaptris.core.services.LogMessageService) CacheConnection(com.adaptris.core.services.cache.CacheConnection)

Example 3 with CacheConnection

use of com.adaptris.core.services.cache.CacheConnection in project interlok by adaptris.

the class BasicSchemaValidationTest method testBasicSchemaValidator_Exception.

@Test(expected = ServiceException.class)
public void testBasicSchemaValidator_Exception() throws Exception {
    String schemaUrl = PROPERTIES.getProperty(KEY_WILL_VALIDATE_SCHEMA);
    BasicXmlSchemaValidator validator = new BasicXmlSchemaValidator().withSchema(schemaUrl).withSchemaCache(new CacheConnection().withCacheInstance(new ExpiringMapCache()));
    XmlValidationService service = new XmlValidationService(validator);
    try {
        LifecycleHelper.initAndStart(service);
        AdaptrisMessage m1 = new DefectiveMessageFactory(WhenToBreak.BOTH).newMessage();
        service.doService(m1);
    } finally {
        LifecycleHelper.stopAndClose(service);
    }
}
Also used : DefectiveMessageFactory(com.adaptris.core.stubs.DefectiveMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ExpiringMapCache(com.adaptris.core.cache.ExpiringMapCache) XmlValidationService(com.adaptris.core.transform.XmlValidationService) CacheConnection(com.adaptris.core.services.cache.CacheConnection) Test(org.junit.Test)

Example 4 with CacheConnection

use of com.adaptris.core.services.cache.CacheConnection in project interlok by adaptris.

the class CacheServiceExample method retrieveObjectsForSampleConfig.

@Override
protected List retrieveObjectsForSampleConfig() {
    List<Object> result = new ArrayList<Object>();
    for (CacheExampleImplementation c : getExampleCacheImplementations()) {
        for (CacheExampleServiceGenerator gen : getExampleGenerators()) {
            Service service = gen.createExampleService();
            navigateTo(service).setConnection(new CacheConnection(c.createCacheImplementation()));
            result.add(service);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Service(com.adaptris.core.Service) CacheConnection(com.adaptris.core.services.cache.CacheConnection)

Example 5 with CacheConnection

use of com.adaptris.core.services.cache.CacheConnection in project interlok by adaptris.

the class XmlSchemaValidatorImpl method prepare.

@Override
public void prepare() throws CoreException {
    schemaCacheConnection = ObjectUtils.defaultIfNull(getSchemaCache(), new CacheConnection(new ExpiringMapCache().withExpiration(DEFAULT_CACHE_TTL).withMaxEntries(DEFAULT_CACHE_SIZE)));
    LifecycleHelper.prepare(schemaCacheConnection);
}
Also used : ExpiringMapCache(com.adaptris.core.cache.ExpiringMapCache) CacheConnection(com.adaptris.core.services.cache.CacheConnection)

Aggregations

CacheConnection (com.adaptris.core.services.cache.CacheConnection)13 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)10 ExpiringMapCache (com.adaptris.core.cache.ExpiringMapCache)10 Test (org.junit.Test)10 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)3 TimeInterval (com.adaptris.util.TimeInterval)3 Cache (com.adaptris.core.cache.Cache)2 XmlValidationService (com.adaptris.core.transform.XmlValidationService)2 InputStream (java.io.InputStream)2 Service (com.adaptris.core.Service)1 ServiceList (com.adaptris.core.ServiceList)1 LogMessageService (com.adaptris.core.services.LogMessageService)1 DefectiveMessageFactory (com.adaptris.core.stubs.DefectiveMessageFactory)1 BasicXmlSchemaValidator (com.adaptris.core.transform.schema.BasicXmlSchemaValidator)1 ArrayList (java.util.ArrayList)1