Search in sources :

Example 71 with Adapter

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

the class ChannelManagerTest method testMBean_RemoveWorkflow_NotFound.

@Test
public void testMBean_RemoveWorkflow_NotFound() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager adapterManager = new AdapterManager(adapter);
    Channel newChannel = createChannel(getName() + "_1");
    ObjectName adapterObj = adapterManager.createObjectName();
    ChannelManager channelManager = new ChannelManager(newChannel, adapterManager);
    ObjectName channelObj = channelManager.createObjectName();
    StandardWorkflow newWorkflow1 = createWorkflow(getName() + "_1");
    StandardWorkflow newWorkflow2 = createWorkflow(getName() + "_2");
    List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
    mBeans.add(adapterManager);
    mBeans.addAll(adapterManager.getAllDescendants());
    try {
        adapterManager.registerMBean();
        AdapterManagerMBean adapterManagerProxy = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
        ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
        ObjectName workflowObj1 = channelManagerProxy.addWorkflow(DefaultMarshaller.getDefaultMarshaller().marshal(newWorkflow1));
        ObjectName workflowObj2 = channelManagerProxy.addWorkflow(DefaultMarshaller.getDefaultMarshaller().marshal(newWorkflow2));
        WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj1, WorkflowManagerMBean.class);
        Adapter marshalledAdapter = (Adapter) DefaultMarshaller.getDefaultMarshaller().unmarshal(adapterManagerProxy.getConfiguration());
        Channel marshalledChannel = (Channel) DefaultMarshaller.getDefaultMarshaller().unmarshal(channelManagerProxy.getConfiguration());
        assertEquals(1, marshalledAdapter.getChannelList().size());
        assertEquals(2, marshalledAdapter.getChannelList().get(0).getWorkflowList().size());
        assertEquals(2, marshalledChannel.getWorkflowList().size());
        assertFalse(channelManagerProxy.removeWorkflow(null));
        assertFalse(channelManagerProxy.removeWorkflow(getName()));
        marshalledAdapter = (Adapter) DefaultMarshaller.getDefaultMarshaller().unmarshal(adapterManagerProxy.getConfiguration());
        marshalledChannel = (Channel) DefaultMarshaller.getDefaultMarshaller().unmarshal(channelManagerProxy.getConfiguration());
        assertEquals(1, marshalledAdapter.getChannelList().size());
        assertEquals(2, marshalledAdapter.getChannelList().get(0).getWorkflowList().size());
        assertEquals(2, marshalledChannel.getWorkflowList().size());
    } finally {
    }
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 72 with Adapter

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

the class ChannelManagerTest method testAdapterStarted_CloseChannel.

@Test
public void testAdapterStarted_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();
        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 73 with Adapter

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

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

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

the class ChannelManagerTest method testMBean_NotificationOnAddWorkflow.

@Test
public void testMBean_NotificationOnAddWorkflow() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager adapterManager = new AdapterManager(adapter);
    String workflowXml = DefaultMarshaller.getDefaultMarshaller().marshal(new PoolingWorkflow(getName() + "_wf1"));
    ChannelManager child1 = new ChannelManager(createChannel(getName() + "_1"), adapterManager);
    SimpleNotificationListener listener = new SimpleNotificationListener();
    NotificationFilterSupport filter = new NotificationFilterSupport();
    filter.enableType(NOTIF_TYPE_CHANNEL_CONFIG);
    ObjectName adapterObj = adapterManager.createObjectName();
    ObjectName channelObj = child1.createObjectName();
    try {
        adapterManager.registerMBean();
        mBeanServer.addNotificationListener(channelObj, listener, null, null);
        ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
        channelManagerProxy.addWorkflow(workflowXml);
        listener.waitForMessages(1);
        assertEquals(1, listener.getNotifications().size());
        Notification n = listener.getNotifications().get(0);
        assertEquals(NOTIF_TYPE_CHANNEL_CONFIG, n.getType());
        assertEquals(NOTIF_MSG_CONFIG_UPDATED, n.getMessage());
        assertEquals(channelManagerProxy.getConfiguration(), n.getUserData());
    } finally {
        mBeanServer.removeNotificationListener(channelObj, listener);
        adapterManager.requestClose();
        adapterManager.unregisterMBean();
    }
}
Also used : NotificationFilterSupport(javax.management.NotificationFilterSupport) Adapter(com.adaptris.core.Adapter) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) Notification(javax.management.Notification) 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