Search in sources :

Example 21 with Adapter

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

the class FilteredSharedComponentStartTest method testNonBlockingStart_WithException.

@Test
public void testNonBlockingStart_WithException() throws Exception {
    Adapter adapter = new Adapter();
    adapter.setUniqueId(getName());
    TriggeredFailingMockConnection sharedConnection = new TriggeredFailingMockConnection(getName());
    try {
        adapter.getSharedComponents().addConnection(sharedConnection);
        adapter.getSharedComponents().setLifecycleStrategy(new FilteredSharedComponentStart(true));
        adapter.requestInit();
        // Will return straight away.
        assertEquals(InitialisedState.getInstance(), adapter.retrieveComponentState());
        assertNotSame(InitialisedState.getInstance(), sharedConnection.retrieveComponentState());
        sharedConnection.wakeup = true;
        Thread.sleep(1000);
        // The connection should never start.
        assertEquals(ClosedState.getInstance(), sharedConnection.retrieveComponentState());
    } finally {
        stop(adapter);
    }
}
Also used : Adapter(com.adaptris.core.Adapter) Test(org.junit.Test)

Example 22 with Adapter

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

the class ConfigurationCheckRunnerTest method createAdapterConfig.

private String createAdapterConfig(AdaptrisConnection sharedComponent, AdaptrisConnection consumeConnection, AdaptrisConnection produceConnection) throws Exception {
    Adapter adapter = new Adapter();
    if (sharedComponent != null) {
        adapter.getSharedComponents().addConnection(sharedComponent);
    }
    Channel channel = new Channel();
    if (consumeConnection != null) {
        channel.setConsumeConnection(consumeConnection);
    }
    if (produceConnection != null) {
        channel.setProduceConnection(produceConnection);
    }
    adapter.getChannelList().add(channel);
    return DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
}
Also used : Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter)

Example 23 with Adapter

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

the class DeserializationConfigurationCheckerTest method createAdapterConfig.

private String createAdapterConfig() throws Exception {
    Adapter adapter = new Adapter();
    adapter.setUniqueId("MyAdapter");
    return DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
}
Also used : Adapter(com.adaptris.core.Adapter)

Example 24 with Adapter

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

the class JavaxValidationCheckerTest method createAdapterConfig.

private Adapter createAdapterConfig(boolean validates, boolean channels) throws Exception {
    Adapter adapter = new Adapter();
    if (validates) {
        // have a unique-id
        adapter.setUniqueId("MyAdapter");
        AddTimestampMetadataService ts = new AddTimestampMetadataService();
        ts.setUniqueId("valid-add-timestamp-service");
        PayloadHashingService ph = new PayloadHashingService();
        ph.setUniqueId("valid-payload-hasher");
        ph.setMetadataKey("payloadHash");
        ph.setHashAlgorithm("SHA-256");
        adapter.getSharedComponents().addService(ts);
        adapter.getSharedComponents().addService(ph);
    } else {
        // no adapter unique-id
        // explicitly set add timestamp to have an empty key, thankfully
        // no checks on the setter...
        AddTimestampMetadataService ts = new AddTimestampMetadataService();
        ts.setUniqueId("invalid-add-timestamp-service");
        ts.setMetadataKey("");
        // don't specify the hash algo or the metadata-key
        PayloadHashingService ph = new PayloadHashingService();
        ph.setUniqueId("invalid-payload-hasher");
        adapter.getSharedComponents().addService(ts);
        adapter.getSharedComponents().addService(ph);
    }
    if (channels) {
        Channel c = new Channel();
        c.setUniqueId("channel");
        StandardWorkflow w = new StandardWorkflow();
        w.setUniqueId("workflow");
        if (!validates) {
            PayloadHashingService ph = new PayloadHashingService();
            ph.setUniqueId("invalid-payload-hasher-2");
            w.getServiceCollection().add(ph);
        }
        c.getWorkflowList().add(w);
        adapter.getChannelList().add(c);
    }
    return adapter;
}
Also used : PayloadHashingService(com.adaptris.core.services.metadata.PayloadHashingService) StandardWorkflow(com.adaptris.core.StandardWorkflow) AddTimestampMetadataService(com.adaptris.core.services.metadata.AddTimestampMetadataService) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter)

Example 25 with Adapter

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

the class ShutdownHandlerTest method testRun.

@Test
public void testRun() throws Exception {
    String adapterName = nameGenerator.safeUUID();
    Adapter adapter = new Adapter();
    adapter.setUniqueId(adapterName);
    BootstrapProperties boot = bootstrapWithAdapter(adapter);
    AdapterManagerMBean mgmtBean = boot.getConfigManager().createAdapter();
    try {
        mgmtBean.requestStart();
        ShutdownHandler shutdown = new ShutdownHandler(boot);
        shutdown.run();
    } finally {
        unregisterQuietly(mgmtBean);
    }
}
Also used : AdapterManagerMBean(com.adaptris.core.runtime.AdapterManagerMBean) Adapter(com.adaptris.core.Adapter) Test(org.junit.Test)

Aggregations

Adapter (com.adaptris.core.Adapter)342 Test (org.junit.Test)318 ObjectName (javax.management.ObjectName)234 Channel (com.adaptris.core.Channel)136 StandardWorkflow (com.adaptris.core.StandardWorkflow)93 ArrayList (java.util.ArrayList)80 URLString (com.adaptris.util.URLString)48 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)47 Properties (java.util.Properties)46 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)43 BootstrapProperties (com.adaptris.core.management.BootstrapProperties)41 Workflow (com.adaptris.core.Workflow)40 JunitBootstrapProperties (com.adaptris.core.stubs.JunitBootstrapProperties)40 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)38 File (java.io.File)37 CoreException (com.adaptris.core.CoreException)32 Notification (javax.management.Notification)28 TimeInterval (com.adaptris.util.TimeInterval)26 BaseComponentMBean (com.adaptris.core.runtime.BaseComponentMBean)25 NullConnection (com.adaptris.core.NullConnection)21