Search in sources :

Example 21 with Service

use of com.adaptris.core.Service in project interlok by adaptris.

the class JdbcRawDataCaptureServiceTest method testService_AdvancedPooledConnection.

@Test
public void testService_AdvancedPooledConnection() throws Exception {
    int maxServices = 5;
    final int iterations = 5;
    int poolsize = maxServices - 1;
    createDatabase();
    List<Service> serviceList = new ArrayList<>();
    String name = Thread.currentThread().getName();
    Thread.currentThread().setName(getName());
    AdvancedJdbcPooledConnection conn = PooledConnectionHelper.createAdvancedPooledConnection(PROPERTIES.getProperty(JDBC_CAPTURE_SERVICE_DRIVER), PROPERTIES.getProperty(JDBC_CAPTURE_SERVICE_URL), poolsize);
    try {
        for (int i = 0; i < maxServices; i++) {
            JdbcRawDataCaptureService service = createService(false);
            service.setConnection(conn);
            serviceList.add(service);
            start(service);
        }
        PooledConnectionHelper.executeTest(serviceList, iterations, new PooledConnectionHelper.MessageCreator() {

            @Override
            public AdaptrisMessage createMsgForPooledConnectionTest() throws Exception {
                return createMessage();
            }
        });
        assertEquals(0, conn.currentBusyConnectionCount());
        assertEquals(poolsize, conn.currentIdleConnectionCount());
        assertEquals(poolsize, conn.currentConnectionCount());
        doBasicCaptureAsserts(iterations * maxServices);
    } finally {
        stop(serviceList.toArray(new ComponentLifecycle[0]));
        Thread.currentThread().setName(name);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ArrayList(java.util.ArrayList) AdvancedJdbcPooledConnection(com.adaptris.core.jdbc.AdvancedJdbcPooledConnection) Service(com.adaptris.core.Service) AddTimestampMetadataService(com.adaptris.core.services.metadata.AddTimestampMetadataService) PooledConnectionHelper(com.adaptris.core.jdbc.PooledConnectionHelper) ComponentLifecycle(com.adaptris.core.ComponentLifecycle) Test(org.junit.Test)

Example 22 with Service

use of com.adaptris.core.Service in project interlok by adaptris.

the class AdvancedMessageSplitterServiceTest method createServiceImpl.

@Override
protected AdvancedMessageSplitterService createServiceImpl(MessageSplitter splitter, MockMessageProducer producer) {
    AdvancedMessageSplitterService service = new AdvancedMessageSplitterService();
    service.setSplitter(splitter);
    service.setService(new ServiceList(new Service[] { new StandaloneProducer(producer) }));
    return service;
}
Also used : ServiceList(com.adaptris.core.ServiceList) Service(com.adaptris.core.Service) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) StandaloneProducer(com.adaptris.core.StandaloneProducer)

Example 23 with Service

use of com.adaptris.core.Service in project interlok by adaptris.

the class LoggingHelperTest method testFriendlyNameService.

@Test
public void testFriendlyNameService() throws Exception {
    assertEquals("", friendlyName((Service) null));
    NullService service = new NullService();
    assertEquals("NullService", friendlyName(service));
    service.setUniqueId("");
    assertEquals("NullService", friendlyName(service));
    service.setUniqueId("testFriendlyNameService");
    assertEquals("NullService(testFriendlyNameService)", friendlyName(service));
}
Also used : NullService(com.adaptris.core.NullService) NullService(com.adaptris.core.NullService) Service(com.adaptris.core.Service) Test(org.junit.Test)

Example 24 with Service

use of com.adaptris.core.Service 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 25 with Service

use of com.adaptris.core.Service in project interlok by adaptris.

the class ExampleServiceCase method createExampleXml.

@Override
protected String createExampleXml(Object object) throws Exception {
    String result = getExampleCommentHeader(object);
    Service service = (Service) object;
    if (service.getUniqueId() == null || "".equals(service.getUniqueId())) {
        service.setUniqueId("unique-id");
    }
    ExampleServiceConfig config = new ExampleServiceConfig();
    config.addService(service);
    result = result + configMarshaller.marshal(config);
    return result;
}
Also used : ExampleServiceConfig(com.adaptris.interlok.junit.scaffolding.ExampleServiceConfig) Service(com.adaptris.core.Service)

Aggregations

Service (com.adaptris.core.Service)49 Test (org.junit.Test)38 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)28 ServiceList (com.adaptris.core.ServiceList)16 ArrayList (java.util.ArrayList)16 ComponentLifecycle (com.adaptris.core.ComponentLifecycle)14 AdvancedJdbcPooledConnection (com.adaptris.core.jdbc.AdvancedJdbcPooledConnection)12 PooledConnectionHelper (com.adaptris.core.jdbc.PooledConnectionHelper)12 ServiceException (com.adaptris.core.ServiceException)11 MetadataElement (com.adaptris.core.MetadataElement)10 NullService (com.adaptris.core.NullService)10 StandaloneProducer (com.adaptris.core.StandaloneProducer)10 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)10 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)9 LogMessageService (com.adaptris.core.services.LogMessageService)8 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)7 MockChannel (com.adaptris.core.stubs.MockChannel)7 StandardProcessingExceptionHandler (com.adaptris.core.StandardProcessingExceptionHandler)6 JdbcPooledConnection (com.adaptris.core.jdbc.JdbcPooledConnection)6 GuidGenerator (com.adaptris.util.GuidGenerator)6