Search in sources :

Example 86 with Adapter

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

the class ChannelManagerTest method testAdapterInitialised_StartChannel.

@Test
public void testAdapterInitialised_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.requestInit();
        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 87 with Adapter

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

the class AdapterManagerTest method testMBean_getAdapterModuleVersion.

@Test
public void testMBean_getAdapterModuleVersion() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    Channel newChannel1 = createChannel(getName() + "_1");
    adapter.getChannelList().add(newChannel1);
    AdapterManager adapterManager = new AdapterManager(adapter);
    ObjectName adapterObj = adapterManager.createObjectName();
    List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
    mBeans.add(adapterManager);
    mBeans.addAll(adapterManager.getAllDescendants());
    try {
        register(mBeans);
        AdapterManagerMBean adapterManagerProxy = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
        assertNotNull(adapterManagerProxy.getModuleVersions());
        // Should be 3 in the versions
        // The version for adp-core-apt.jar and adp-core.jar and interlok-common.
        assertEquals(3, adapterManagerProxy.getModuleVersions().size());
    } finally {
    }
}
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 88 with Adapter

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

the class AdapterManagerTest method testMBean_RemoveSharedConnection_NotFound.

@Test
public void testMBean_RemoveSharedConnection_NotFound() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    adapter.getSharedComponents().addConnection(new NullConnection(getName()));
    AdapterManager adapterManager = new AdapterManager(adapter);
    ObjectName adapterObj = adapterManager.createObjectName();
    AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
    try {
        adapterManager.registerMBean();
        AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
        assertFalse(amp.removeSharedConnection(getName() + "_1"));
        Adapter marshalledAdapter = (Adapter) m.unmarshal(amp.getConfiguration());
        assertEquals(1, marshalledAdapter.getSharedComponents().getConnections().size());
        assertEquals(getName(), marshalledAdapter.getSharedComponents().getConnections().get(0).getUniqueId());
    } finally {
    }
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Adapter(com.adaptris.core.Adapter) NullConnection(com.adaptris.core.NullConnection) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 89 with Adapter

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

the class AdapterManagerTest method testMBean_NotificationOnSetMessageErrorHandler.

@Test
public void testMBean_NotificationOnSetMessageErrorHandler() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName, 1, 1);
    String newCompXml = DefaultMarshaller.getDefaultMarshaller().marshal(new StandardProcessingExceptionHandler());
    AdapterManager adapterManager = new AdapterManager(adapter);
    ObjectName adapterObj = adapterManager.createObjectName();
    SimpleNotificationListener listener = new SimpleNotificationListener();
    NotificationFilterSupport filter = new NotificationFilterSupport();
    filter.enableType(NOTIF_TYPE_ADAPTER_CONFIG);
    try {
        adapterManager.registerMBean();
        mBeanServer.addNotificationListener(adapterObj, listener, filter, null);
        AdapterManagerMBean adapterManagerProxy = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
        adapterManagerProxy.setMessageErrorHandler(newCompXml);
        listener.waitForMessages(1);
        assertEquals(1, listener.getNotifications().size());
        Notification n = listener.getNotifications().get(0);
        assertEquals(NOTIF_TYPE_ADAPTER_CONFIG, n.getType());
        assertEquals(NOTIF_MSG_CONFIG_UPDATED, n.getMessage());
        assertEquals(adapterManagerProxy.getConfiguration(), n.getUserData());
    } finally {
    }
}
Also used : StandardProcessingExceptionHandler(com.adaptris.core.StandardProcessingExceptionHandler) NotificationFilterSupport(javax.management.NotificationFilterSupport) Adapter(com.adaptris.core.Adapter) Notification(javax.management.Notification) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 90 with Adapter

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

the class AdapterManagerTest method testMBean_NotificationOnAddWorkflow.

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