Search in sources :

Example 41 with Adapter

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

the class AdapterManagerTest method testMBean_getArtifactIdentifiers.

@Test
public void testMBean_getArtifactIdentifiers() 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.getArtifactIdentifiers());
        // Should be 3 in the versions
        // The version for adp-core-apt.jar and adp-core.jar and interlok-common.
        assertEquals(3, adapterManagerProxy.getArtifactIdentifiers().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 42 with Adapter

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

the class AdapterManagerTest method testMBean_RemoveSharedComponent.

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

Example 43 with Adapter

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

the class AdapterManagerTest method testMBean_RemoveSharedConnection.

@Test
public void testMBean_RemoveSharedConnection() 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);
        amp.removeSharedConnection(getName());
        Adapter marshalledAdapter = (Adapter) m.unmarshal(amp.getConfiguration());
        assertEquals(0, marshalledAdapter.getSharedComponents().getConnections().size());
    } 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 44 with Adapter

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

the class AdapterManagerTest method testMBean_AddChannel_NoUniqueID.

@Test
public void testMBean_AddChannel_NoUniqueID() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager adapterManager = new AdapterManager(adapter);
    Channel newChannel = new Channel();
    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);
        try {
            adapterManagerProxy.addChannel(DefaultMarshaller.getDefaultMarshaller().marshal(newChannel));
            fail();
        } catch (CoreException expected) {
        }
    } finally {
    }
}
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 45 with Adapter

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

the class AdapterManagerTest method testMBean_Notification_AddAndBindSharedConnection.

@Test
public void testMBean_Notification_AddAndBindSharedConnection() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager adapterManager = new AdapterManager(adapter);
    ObjectName adapterObj = adapterManager.createObjectName();
    SimpleNotificationListener listener = new SimpleNotificationListener();
    NotificationFilterSupport filter = new NotificationFilterSupport();
    filter.enableType(NOTIF_TYPE_ADAPTER_CONFIG);
    AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
    List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
    mBeans.add(adapterManager);
    mBeans.addAll(adapterManager.getAllDescendants());
    try {
        register(mBeans);
        adapterManager.requestStart();
        AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
        mBeanServer.addNotificationListener(adapterObj, listener, filter, null);
        amp.addAndBindSharedConnection(m.marshal(new NullConnection(getName())));
        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(amp.getConfiguration(), n.getUserData());
    } finally {
        adapterManager.requestClose();
    }
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) Notification(javax.management.Notification) ObjectName(javax.management.ObjectName) NotificationFilterSupport(javax.management.NotificationFilterSupport) NullConnection(com.adaptris.core.NullConnection) 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