Search in sources :

Example 21 with BaseComponentMBean

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

the class MessageThresholdNotificationTest method testNotification_SizeThresholdNotExceeded.

@Test
public void testNotification_SizeThresholdNotExceeded() throws Exception {
    MessageThresholdNotification notif = new MessageThresholdNotification(getName());
    notif.setSizeThreshold(100L);
    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 22 with BaseComponentMBean

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

the class MessageThresholdNotificationTest method testNotification_CountThresholdNotExceeded.

@Test
public void testNotification_CountThresholdNotExceeded() throws Exception {
    MessageThresholdNotification notif = new MessageThresholdNotification(getName());
    notif.setCountThreshold(100L);
    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);
        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 23 with BaseComponentMBean

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

the class MetadataTotalsMBeanTest method testGetMetadataStatistics.

@Test
public void testGetMetadataStatistics() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    MetadataCountInterceptor 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 24 with BaseComponentMBean

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

the class SlowMessageNotificationTest method testNotification_SlowMessage_Success.

@Test
public void testNotification_SlowMessage_Success() throws Exception {
    SlowMessageNotification notif = new SlowMessageNotification(getName(), new TimeInterval(100L, TimeUnit.MILLISECONDS), new TimeInterval(1L, TimeUnit.MINUTES));
    StandardWorkflow workflow = createWorkflow(getName() + "_Workflow", notif);
    workflow.getServiceCollection().add(new WaitService(new TimeInterval(1L, TimeUnit.SECONDS)));
    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();
        workflow.onAdaptrisMessage(msg);
        listener.waitForMessages(1);
        assertEquals(1, listener.getNotifications().size());
        Notification notification = listener.getNotifications().get(0);
        Properties userData = (Properties) notification.getUserData();
        assertEquals(msg.getUniqueId(), userData.getProperty(SlowMessageNotification.KEY_MESSAGE_ID));
    // assertEquals("true", userData.getProperty(SlowMessageNotification.KEY_MESSAGE_SUCCESS));
    } finally {
        stop(adapter);
    }
}
Also used : BaseComponentMBean(com.adaptris.core.runtime.BaseComponentMBean) WaitService(com.adaptris.core.services.WaitService) StandardWorkflow(com.adaptris.core.StandardWorkflow) TimeInterval(com.adaptris.util.TimeInterval) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SimpleNotificationListener(com.adaptris.core.runtime.SimpleNotificationListener) Adapter(com.adaptris.core.Adapter) Properties(java.util.Properties) Notification(javax.management.Notification) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 25 with BaseComponentMBean

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

the class MessageMetricsStatisticsTest method testGetTotalStringStats.

@Test
public void testGetTotalStringStats() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
    try {
        start(adapter);
        register(mBeans);
        ObjectName workflowObj = createWorkflowObjectName(adapterName);
        ObjectName metricsObj = createMetricsObjectName(adapterName);
        MessageMetricsStatisticsMBean stats = JMX.newMBeanProxy(mBeanServer, metricsObj, MessageMetricsStatisticsMBean.class);
        WorkflowManagerMBean workflow = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
        assertNotNull(stats.getTotalStringStats());
        SerializableAdaptrisMessage msg = createMessageForInjection(null);
        workflow.processAsync(msg);
        assertNotNull(stats.getTotalStringStats());
    } 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)

Aggregations

BaseComponentMBean (com.adaptris.core.runtime.BaseComponentMBean)29 ObjectName (javax.management.ObjectName)26 Adapter (com.adaptris.core.Adapter)25 Test (org.junit.Test)24 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)16 StandardWorkflow (com.adaptris.core.StandardWorkflow)16 SimpleNotificationListener (com.adaptris.core.runtime.SimpleNotificationListener)16 Notification (javax.management.Notification)10 TimeInterval (com.adaptris.util.TimeInterval)9 Properties (java.util.Properties)6 WorkflowManagerMBean (com.adaptris.core.runtime.WorkflowManagerMBean)5 SerializableAdaptrisMessage (com.adaptris.core.SerializableAdaptrisMessage)3 AdapterManager (com.adaptris.core.runtime.AdapterManager)3 AlwaysFailService (com.adaptris.core.services.AlwaysFailService)3 WaitService (com.adaptris.core.services.WaitService)3 MessageProcessor (com.adaptris.interlok.management.MessageProcessor)2 ArrayList (java.util.ArrayList)2 ChildRuntimeInfoComponent (com.adaptris.core.runtime.ChildRuntimeInfoComponent)1