Search in sources :

Example 11 with Adapter

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

the class MessageThresholdNotificationTest method testNotification_ErrorThresholdNotExceeded.

@Test
public void testNotification_ErrorThresholdNotExceeded() throws Exception {
    MessageThresholdNotification notif = new MessageThresholdNotification(getName());
    notif.setErrorThreshold(100L);
    StandardWorkflow workflow = createWorkflow(getName() + "_Workflow", notif);
    workflow.getServiceCollection().add(new AlwaysFailService());
    Adapter adapter = createAdapter(getName(), workflow);
    List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
    BaseComponentMBean notifier = getFirstImpl(mBeans, InterceptorNotificationMBean.class);
    assertNotNull(notifier);
    ObjectName notifObjName = notifier.createObjectName();
    SimpleNotificationListener listener = new SimpleNotificationListener();
    try {
        start(adapter);
        register(mBeans);
        mBeanServer.addNotificationListener(notifObjName, listener, null, null);
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("Hello World");
        workflow.onAdaptrisMessage(msg);
        workflow.onAdaptrisMessage(msg);
        workflow.onAdaptrisMessage(msg);
        workflow.onAdaptrisMessage(msg);
        workflow.onAdaptrisMessage(msg);
        workflow.onAdaptrisMessage(msg);
        workflow.onAdaptrisMessage(msg);
    } finally {
        stop(adapter);
    }
    assertEquals(0, listener.getNotifications().size());
}
Also used : BaseComponentMBean(com.adaptris.core.runtime.BaseComponentMBean) StandardWorkflow(com.adaptris.core.StandardWorkflow) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SimpleNotificationListener(com.adaptris.core.runtime.SimpleNotificationListener) Adapter(com.adaptris.core.Adapter) AlwaysFailService(com.adaptris.core.services.AlwaysFailService) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 12 with Adapter

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

the class MessageThresholdNotificationTest method testNotification_NoNotifications.

@Test
public void testNotification_NoNotifications() throws Exception {
    MessageThresholdNotification notif = new MessageThresholdNotification(getName());
    StandardWorkflow workflow = createWorkflow(getName() + "_Workflow", notif);
    Adapter adapter = createAdapter(getName(), workflow);
    List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
    BaseComponentMBean notifier = getFirstImpl(mBeans, InterceptorNotificationMBean.class);
    assertNotNull(notifier);
    ObjectName notifObjName = notifier.createObjectName();
    SimpleNotificationListener listener = new SimpleNotificationListener();
    try {
        start(adapter);
        register(mBeans);
        mBeanServer.addNotificationListener(notifObjName, listener, null, null);
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("Hello World");
        workflow.onAdaptrisMessage(msg);
        workflow.onAdaptrisMessage(msg);
        workflow.onAdaptrisMessage(msg);
        workflow.onAdaptrisMessage(msg);
        workflow.onAdaptrisMessage(msg);
        workflow.onAdaptrisMessage(msg);
    } finally {
        stop(adapter);
    }
    assertEquals(0, listener.getNotifications().size());
}
Also used : BaseComponentMBean(com.adaptris.core.runtime.BaseComponentMBean) StandardWorkflow(com.adaptris.core.StandardWorkflow) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SimpleNotificationListener(com.adaptris.core.runtime.SimpleNotificationListener) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 13 with Adapter

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

the class MetadataCountMBeanTest method testGetMetadataStatistics.

@Test
public void testGetMetadataStatistics() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    MetadataTotalsInterceptor interceptor = createInterceptor();
    interceptor.setUniqueId(getName());
    Adapter adapter = createSingleChannelAdapter(adapterName, interceptor);
    List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
    try {
        start(adapter);
        register(mBeans);
        ObjectName workflowObj = createWorkflowObjectName(adapterName);
        ObjectName metricsObj = createMetricsObjectName(adapterName, getName());
        MetadataStatisticsMBean stats = JMX.newMBeanProxy(mBeanServer, metricsObj, MetadataStatisticsMBean.class);
        WorkflowManagerMBean workflow = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
        SerializableAdaptrisMessage msg = createMessageForInjection(null);
        workflow.processAsync(msg);
        assertEquals(1, stats.getStatistics().size());
        assertEquals(interceptor.getStats().size(), stats.getStatistics().size());
        MetadataStatistic interceptorStat = (MetadataStatistic) interceptor.getStats().get(0);
        MetadataStatistic mbeanStat = stats.getStatistics().get(0);
        // They're not objectively equals (not clones), and no equals method.
        assertNotSame(interceptorStat, mbeanStat);
        assertEquals(interceptorStat.getEndMillis(), mbeanStat.getEndMillis());
        assertEquals(interceptorStat.getMetadataStatistics(), mbeanStat.getMetadataStatistics());
    } finally {
        stop(adapter);
    }
}
Also used : WorkflowManagerMBean(com.adaptris.core.runtime.WorkflowManagerMBean) BaseComponentMBean(com.adaptris.core.runtime.BaseComponentMBean) Adapter(com.adaptris.core.Adapter) SerializableAdaptrisMessage(com.adaptris.core.SerializableAdaptrisMessage) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 14 with Adapter

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

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

the class StatisticsMBeanCase method createAdapter.

protected Adapter createAdapter(String uid, int channels, int workflows) throws CoreException {
    Adapter adapter = new Adapter();
    adapter.setUniqueId(uid);
    for (int i = 0; i < channels; i++) {
        adapter.getChannelList().add(createChannel("channel" + (i + 1), workflows));
    }
    return adapter;
}
Also used : Adapter(com.adaptris.core.Adapter)

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