Search in sources :

Example 1 with AdapterManager

use of com.adaptris.core.runtime.AdapterManager in project interlok by adaptris.

the class StatisticsMBeanCase method testRegistration.

@Test
public void testRegistration() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager am = new AdapterManager(adapter);
    try {
        start(adapter);
        am.registerMBean();
    } finally {
        am.unregisterMBean();
        stop(adapter);
    }
}
Also used : AdapterManager(com.adaptris.core.runtime.AdapterManager) Adapter(com.adaptris.core.Adapter) Test(org.junit.Test)

Example 2 with AdapterManager

use of com.adaptris.core.runtime.AdapterManager in project interlok by adaptris.

the class StatisticsMBeanCase method createJmxManagers.

protected List<BaseComponentMBean> createJmxManagers(Adapter adapter) throws Exception {
    List<BaseComponentMBean> result = new ArrayList<BaseComponentMBean>();
    AdapterManager am = new AdapterManager(adapter);
    result.add(am);
    result.addAll(am.getAllDescendants());
    return result;
}
Also used : BaseComponentMBean(com.adaptris.core.runtime.BaseComponentMBean) AdapterManager(com.adaptris.core.runtime.AdapterManager) ArrayList(java.util.ArrayList)

Example 3 with AdapterManager

use of com.adaptris.core.runtime.AdapterManager in project interlok by adaptris.

the class FsConsumerCase method testFsMonitor.

@Test
public void testFsMonitor() throws Exception {
    String subdir = new GuidGenerator().safeUUID();
    FsConsumerImpl fs = createConsumer(subdir);
    fs.setUniqueId(getName());
    Adapter adapter = new Adapter();
    adapter.setUniqueId(getName());
    Channel channel = new Channel();
    channel.setUniqueId(getName());
    StandardWorkflow wf = new StandardWorkflow();
    wf.setUniqueId(getName());
    wf.setConsumer(fs);
    channel.getWorkflowList().add(wf);
    adapter.getChannelList().add(channel);
    AdapterManager am = new AdapterManager(adapter);
    try {
        am.registerMBean();
        am.requestInit();
        String objectNameString = String.format("com.adaptris:type=ConsumerMonitor,adapter=%s,channel=%s,workflow=%s,id=%s", getName(), getName(), getName(), getName());
        MBeanServer mBeanServer = JmxHelper.findMBeanServer();
        FsConsumerMonitorMBean mbean = JMX.newMBeanProxy(mBeanServer, ObjectName.getInstance(objectNameString), FsConsumerMonitorMBean.class);
        assertEquals(0, mbean.messagesRemaining());
    } finally {
        am.requestClose();
        am.unregisterMBean();
    }
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) AdapterManager(com.adaptris.core.runtime.AdapterManager) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) GuidGenerator(com.adaptris.util.GuidGenerator) MBeanServer(javax.management.MBeanServer) Test(org.junit.Test)

Example 4 with AdapterManager

use of com.adaptris.core.runtime.AdapterManager in project interlok by adaptris.

the class AdapterTest method testBug469AndBug1268.

@Test
public void testBug469AndBug1268() throws Exception {
    final Adapter adapter = AdapterTest.createRetryingAdapter("testBug469AndBug1268");
    // NonBlockingChannelStartStrategy tests Bug1268...
    adapter.getChannelList().setLifecycleStrategy(new com.adaptris.core.lifecycle.NonBlockingChannelStartStrategy());
    AdapterManager am = new AdapterManager(adapter);
    try {
        adapter.requestStart();
        waitFor(adapter, StartedState.getInstance());
        assertEquals(StartedState.getInstance(), adapter.retrieveComponentState());
        // So the Adapter is started but channel1 should currently be "retrying",
        // so let's try and stop the adapter.
        // Channel should have a componentState of closed.
        Channel c = adapter.getChannelList().getChannel("testBug469AndBug1268_c1");
        assertEquals(ClosedState.getInstance(), c.retrieveComponentState());
        new Thread() {

            @Override
            public void run() {
                Thread.currentThread().setName("testBug469AndBug1268 stop");
                adapter.requestClose();
            }
        }.start();
        waitFor(adapter, ClosedState.getInstance());
        // Bug469 is tested by the fact that the Adapter is now closed.
        assertEquals(ClosedState.getInstance(), adapter.retrieveComponentState());
    } finally {
        am.forceClose();
    }
}
Also used : AdapterManager(com.adaptris.core.runtime.AdapterManager) Test(org.junit.Test)

Example 5 with AdapterManager

use of com.adaptris.core.runtime.AdapterManager in project interlok by adaptris.

the class StatisticsMBeanCase method testStandardGetters.

@Test
public void testStandardGetters() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager am = new AdapterManager(adapter);
    try {
        start(adapter);
        am.registerMBean();
        Collection<BaseComponentMBean> children = am.getAllDescendants();
        for (BaseComponentMBean bean : children) {
            assertNotNull(bean.createObjectName());
            if (bean instanceof ChildRuntimeInfoComponent) {
                assertNotNull(((ChildRuntimeInfoComponent) bean).getParentId());
                assertNotNull(((ChildRuntimeInfoComponent) bean).getParentObjectName());
                assertNotNull(((ChildRuntimeInfoComponent) bean).getParentRuntimeInfoComponent());
            }
        }
    } finally {
        stop(adapter);
        am.unregisterMBean();
    }
}
Also used : BaseComponentMBean(com.adaptris.core.runtime.BaseComponentMBean) ChildRuntimeInfoComponent(com.adaptris.core.runtime.ChildRuntimeInfoComponent) AdapterManager(com.adaptris.core.runtime.AdapterManager) Adapter(com.adaptris.core.Adapter) Test(org.junit.Test)

Aggregations

AdapterManager (com.adaptris.core.runtime.AdapterManager)6 Test (org.junit.Test)4 Adapter (com.adaptris.core.Adapter)3 BaseComponentMBean (com.adaptris.core.runtime.BaseComponentMBean)3 ArrayList (java.util.ArrayList)2 Channel (com.adaptris.core.Channel)1 StandardWorkflow (com.adaptris.core.StandardWorkflow)1 ChildRuntimeInfoComponent (com.adaptris.core.runtime.ChildRuntimeInfoComponent)1 GuidGenerator (com.adaptris.util.GuidGenerator)1 MBeanServer (javax.management.MBeanServer)1