Search in sources :

Example 96 with Channel

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

the class ChannelManagerTest method testAdapterStopped_CloseChannel.

@Test
public void testAdapterStopped_CloseChannel() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager adapterManager = new AdapterManager(adapter);
    Channel c1 = createChannel(getName() + "_1");
    Channel c2 = createChannel(getName() + "_2");
    ChannelManager child1 = new ChannelManager(c1, adapterManager);
    ChannelManager child2 = new ChannelManager(c2, adapterManager);
    ObjectName adapterObj = adapterManager.createObjectName();
    ObjectName channelObj = child1.createObjectName();
    List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
    mBeans.add(adapterManager);
    mBeans.addAll(adapterManager.getAllDescendants());
    try {
        register(mBeans);
        ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
        adapterManager.requestStart();
        adapterManager.requestStop();
        channelManagerProxy.requestClose();
    } finally {
        adapter.requestClose();
    }
}
Also used : Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 97 with Channel

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

the class ChannelManagerTest method testAdapterInitialised_CloseChannel.

@Test
public void testAdapterInitialised_CloseChannel() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager adapterManager = new AdapterManager(adapter);
    Channel c1 = createChannel(getName() + "_1");
    Channel c2 = createChannel(getName() + "_2");
    ChannelManager child1 = new ChannelManager(c1, adapterManager);
    ChannelManager child2 = new ChannelManager(c2, adapterManager);
    ObjectName adapterObj = adapterManager.createObjectName();
    ObjectName channelObj = child1.createObjectName();
    List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
    mBeans.add(adapterManager);
    mBeans.addAll(adapterManager.getAllDescendants());
    try {
        register(mBeans);
        ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
        adapterManager.requestInit();
        channelManagerProxy.requestClose();
    } finally {
        adapter.requestClose();
    }
}
Also used : Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 98 with Channel

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

the class ChannelManagerTest method testAdapterStarted_StartChannel.

@Test
public void testAdapterStarted_StartChannel() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager adapterManager = new AdapterManager(adapter);
    Channel c1 = createChannel(getName() + "_1");
    Channel c2 = createChannel(getName() + "_2");
    ChannelManager child1 = new ChannelManager(c1, adapterManager);
    ChannelManager child2 = new ChannelManager(c2, adapterManager);
    ObjectName adapterObj = adapterManager.createObjectName();
    ObjectName channelObj = child1.createObjectName();
    List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
    mBeans.add(adapterManager);
    mBeans.addAll(adapterManager.getAllDescendants());
    try {
        register(mBeans);
        ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
        adapterManager.requestStart();
        channelManagerProxy.requestStart();
    } finally {
        adapter.requestClose();
    }
}
Also used : Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 99 with Channel

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

the class ChannelManagerTest method testAddChildRuntimeComponent.

@Test
public void testAddChildRuntimeComponent() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager adapterManager = new AdapterManager(adapter);
    Channel c1 = createChannel(getName() + "_1");
    ChannelManager channelManager = new ChannelManager(c1, adapterManager);
    assertTrue(channelManager.addChildJmxComponent(new ChannelChild(channelManager)));
    assertEquals(1, channelManager.getChildRuntimeInfoComponents().size());
    assertEquals(1, channelManager.getAllDescendants().size());
}
Also used : Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) Test(org.junit.Test)

Example 100 with Channel

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

the class ChannelManagerTest method testGetState.

@Test
public void testGetState() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager adapterManager = new AdapterManager(adapter);
    Channel c1 = createChannel(getName() + "_1");
    Channel c2 = createChannel(getName() + "_2");
    ChannelManager child1 = new ChannelManager(c1, adapterManager);
    ChannelManager child2 = new ChannelManager(c2, adapterManager);
    ObjectName adapterObj = adapterManager.createObjectName();
    ObjectName channelObj = child1.createObjectName();
    try {
        adapterManager.registerMBean();
        ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
        assertEquals(ClosedState.getInstance(), channelManagerProxy.getComponentState());
    } finally {
        adapterManager.requestClose();
        adapterManager.unregisterMBean();
    }
}
Also used : Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

Channel (com.adaptris.core.Channel)322 Test (org.junit.Test)276 Adapter (com.adaptris.core.Adapter)136 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)125 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)122 StandardWorkflow (com.adaptris.core.StandardWorkflow)111 ObjectName (javax.management.ObjectName)97 ArrayList (java.util.ArrayList)74 StandaloneProducer (com.adaptris.core.StandaloneProducer)64 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)57 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)52 Workflow (com.adaptris.core.Workflow)44 MockChannel (com.adaptris.core.stubs.MockChannel)43 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)37 TimeInterval (com.adaptris.util.TimeInterval)36 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)35 StaticMockMessageProducer (com.adaptris.core.stubs.StaticMockMessageProducer)35 ServiceList (com.adaptris.core.ServiceList)31 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)30 CoreException (com.adaptris.core.CoreException)29