Search in sources :

Example 11 with CoreException

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

the class AdapterRegistryTest method testAddAdapterMBean_ExistingObjectName.

@Test
public void testAddAdapterMBean_ExistingObjectName() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName, 2, 2);
    AdapterManager adapterManager = new AdapterManager(adapter);
    ObjectName adapterObjectName = adapterManager.createObjectName();
    adapterManager.registerMBean();
    AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
    int expectedCount = myAdapterRegistry.getAdapters().size() + 1;
    myAdapterRegistry.addAdapter(adapterManager);
    assertEquals(ClosedState.getInstance(), adapterManager.getComponentState());
    assertEquals(expectedCount, myAdapterRegistry.getAdapters().size());
    try {
        myAdapterRegistry.addAdapter(adapterManager);
        fail();
    } catch (CoreException expected) {
        assertTrue(expected.getMessage().contains("already exists in the registry, remove it first"));
    }
}
Also used : CoreException(com.adaptris.core.CoreException) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Adapter(com.adaptris.core.Adapter) URLString(com.adaptris.util.URLString) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Properties(java.util.Properties) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 12 with CoreException

use of com.adaptris.core.CoreException 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 13 with CoreException

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

the class ChannelManagerTest method testAdapterInitialised_StopChannel.

@Test
public void testAdapterInitialised_StopChannel() 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.requestStop();
            fail();
        } catch (CoreException e) {
            assertEquals(createErrorMessageString(adapterManager.getComponentState(), StoppedState.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 14 with CoreException

use of com.adaptris.core.CoreException 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 15 with CoreException

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

the class ChannelManagerTest method testMBean_AddWorkflow_NoUniqueId.

@Test
public void testMBean_AddWorkflow_NoUniqueId() 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 newWorkflow = new StandardWorkflow();
    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);
        try {
            ObjectName workflowObj = channelManagerProxy.addWorkflow(DefaultMarshaller.getDefaultMarshaller().marshal(newWorkflow));
            fail();
        } catch (CoreException e) {
        }
    } finally {
        adapterManager.requestClose();
    }
}
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) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Aggregations

CoreException (com.adaptris.core.CoreException)186 Test (org.junit.Test)110 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)44 Adapter (com.adaptris.core.Adapter)32 ObjectName (javax.management.ObjectName)29 Channel (com.adaptris.core.Channel)27 ArrayList (java.util.ArrayList)24 IOException (java.io.IOException)20 File (java.io.File)19 ServiceException (com.adaptris.core.ServiceException)14 TimeInterval (com.adaptris.util.TimeInterval)13 Document (org.w3c.dom.Document)12 MalformedObjectNameException (javax.management.MalformedObjectNameException)11 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)10 StandardWorkflow (com.adaptris.core.StandardWorkflow)9 URLString (com.adaptris.util.URLString)9 TimeoutException (java.util.concurrent.TimeoutException)9 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)8 Workflow (com.adaptris.core.Workflow)8 XPath (com.adaptris.util.text.xml.XPath)8