Search in sources :

Example 86 with Channel

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

the class ChannelManagerTest method testEqualityHashCode.

@Test
public void testEqualityHashCode() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    AdapterManager am1 = new AdapterManager(createAdapter(adapterName));
    AdapterManager am2 = new AdapterManager(createAdapter(adapterName));
    AdapterManager fam = new AdapterManager(createAdapter(adapterName));
    Channel channel = createChannel("c1");
    Channel channel2 = createChannel("c1");
    ChannelManager cm1 = new ChannelManager(channel, am1);
    ChannelManager cm2 = new ChannelManager(channel2, am2);
    ChannelManager fcm = new FailingChannelManager(channel, fam);
    ChannelManager cm3 = new ChannelManager(createChannel("c3"), am1);
    assertEquals(cm1, cm1);
    assertEquals(cm1, cm2);
    assertNotSame(cm1, cm3);
    assertFalse(cm1.equals(fcm));
    assertFalse(cm1.equals(new Object()));
    assertFalse(cm1.equals(null));
    assertEquals(cm1.hashCode(), cm2.hashCode());
    assertNotSame(cm1.hashCode(), cm3.hashCode());
}
Also used : Channel(com.adaptris.core.Channel) Test(org.junit.Test)

Example 87 with Channel

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

the class ChannelManagerTest method testGetChildren.

@Test
public void testGetChildren() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager adapterManager = new AdapterManager(adapter);
    Channel c1 = createChannel(getName() + "_1", 2);
    // Add a WF with no ID... which should mean we have a workflow that is unmanaged.
    c1.getWorkflowList().add(new StandardWorkflow());
    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 {
        assertEquals(2, child1.getChildren().size());
    } finally {
        adapter.requestClose();
    }
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 88 with Channel

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

the class ChannelManagerTest method testInitialise.

@Test
public void testInitialise() 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();
        adapterManager.requestStart();
        ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
        channelManagerProxy.requestClose();
        assertEquals(ClosedState.getInstance(), channelManagerProxy.getComponentState());
        channelManagerProxy.requestInit();
        assertEquals(InitialisedState.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)

Example 89 with Channel

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

the class ChannelManagerTest method testGetParent.

@Test
public void testGetParent() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    Adapter adapter2 = createAdapter(adapterName);
    Channel channel = createChannel(getName(), 0);
    try {
        AdapterManager adapterManager = new AdapterManager(adapter);
        AdapterManager adapterManager_2 = new AdapterManager(adapter2);
        ChannelManager channelManager = new ChannelManager(channel, adapterManager);
        assertEquals(adapterManager, channelManager.getParent());
        assertTrue(adapterManager == channelManager.getParent());
        assertEquals(adapterManager_2, channelManager.getParent());
        assertFalse(adapterManager_2 == channelManager.getParent());
    } finally {
        adapter.requestClose();
    }
}
Also used : Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) Test(org.junit.Test)

Example 90 with Channel

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

the class ChannelManagerTest method testChannelManager_HasRetryMonitor.

@Test
public void testChannelManager_HasRetryMonitor() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager adapterManager = new AdapterManager(adapter);
    Channel c1 = createChannel(getName() + "_1");
    c1.setMessageErrorHandler(new RetryMessageErrorHandler(getName()));
    ChannelManager cm1 = new ChannelManager(c1, adapterManager);
    ObjectName channelObj = cm1.createObjectName();
    List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>(Arrays.asList(new BaseComponentMBean[] { adapterManager, cm1 }));
    try {
        register(mBeans);
        ObjectName handlerObjectName = ObjectName.getInstance(JMX_RETRY_MONITOR_TYPE + cm1.createObjectHierarchyString() + ID_PREFIX + getName());
        ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
        assertTrue(channelManagerProxy.getChildRuntimeInfoComponents().contains(handlerObjectName));
        RetryMessageErrorHandlerMonitorMBean monitor = JMX.newMBeanProxy(mBeanServer, handlerObjectName, RetryMessageErrorHandlerMonitorMBean.class);
    } finally {
        adapter.requestClose();
    }
}
Also used : Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) RetryMessageErrorHandlerMonitorMBean(com.adaptris.core.RetryMessageErrorHandlerMonitorMBean) Adapter(com.adaptris.core.Adapter) RetryMessageErrorHandler(com.adaptris.core.RetryMessageErrorHandler) 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