Search in sources :

Example 66 with Adapter

use of com.adaptris.core.Adapter 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 67 with Adapter

use of com.adaptris.core.Adapter 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)

Example 68 with Adapter

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

the class ChannelManagerTest method testAdapterStopped_StartChannel.

@Test
public void testAdapterStopped_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>(Arrays.asList(new BaseComponentMBean[] { adapterManager, child1, child2 }));
    try {
        register(mBeans);
        ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
        adapterManager.requestStart();
        adapterManager.requestStop();
        try {
            channelManagerProxy.requestStart();
            fail();
        } catch (CoreException e) {
            assertEquals(createErrorMessageString(adapterManager.getComponentState(), StartedState.getInstance()), e.getMessage());
        }
    } finally {
        adapter.requestClose();
    }
}
Also used : CoreException(com.adaptris.core.CoreException) Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 69 with Adapter

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

the class ChannelManagerTest method testClose.

@Test
public void testClose() 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());
        assertEquals(ClosedState.getInstance(), child1.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 70 with Adapter

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

the class ChannelManagerTest method testLastStopTime.

@Test
public void testLastStopTime() 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);
        long t1 = channelManagerProxy.requestStopTime();
        assertTrue(t1 > 0);
        adapterManager.requestStart();
        adapterManager.requestStop();
        assertTrue(t1 <= channelManagerProxy.requestStopTime());
    } 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

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