Search in sources :

Example 1 with Adapter

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

the class MessageMetricsStatisticsByMetadataTest method testGetMessageStatistics.

@Override
public void testGetMessageStatistics() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    String payload = "SomePayload";
    MessageMetricsInterceptorByMetadata 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());
        MessageMetricsStatisticsMBean stats = JMX.newMBeanProxy(mBeanServer, metricsObj, MessageMetricsStatisticsMBean.class);
        MessageProcessor workflow = JMX.newMBeanProxy(mBeanServer, workflowObj, MessageProcessor.class);
        workflow.processAsync(createMessageForInjection(payload));
        assertEquals(1, stats.getStatistics().size());
        assertEquals(interceptor.getStats().size(), stats.getStatistics().size());
        MessageStatistic interceptorStat = (MessageStatistic) interceptor.getStats().get(0);
        MessageStatistic 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.getTotalMessageCount(), mbeanStat.getTotalMessageCount());
        assertEquals(interceptorStat.getTotalMessageErrorCount(), mbeanStat.getTotalMessageErrorCount());
        assertEquals(interceptorStat.getTotalMessageSize(), mbeanStat.getTotalMessageSize());
    } finally {
        stop(adapter);
    }
}
Also used : BaseComponentMBean(com.adaptris.core.runtime.BaseComponentMBean) MessageProcessor(com.adaptris.interlok.management.MessageProcessor) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName)

Example 2 with Adapter

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

the class MessageMetricsStatisticsTest method testGetMessageStatistics.

@Test
public void testGetMessageStatistics() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    String payload = "SomePayload";
    MessageMetricsInterceptor interceptor = (MessageMetricsInterceptor) 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());
        MessageMetricsStatisticsMBean stats = JMX.newMBeanProxy(mBeanServer, metricsObj, MessageMetricsStatisticsMBean.class);
        MessageProcessor workflow = JMX.newMBeanProxy(mBeanServer, workflowObj, MessageProcessor.class);
        workflow.processAsync(createMessageForInjection(payload));
        assertEquals(1, stats.getStatistics().size());
        assertEquals(interceptor.getStats().size(), stats.getStatistics().size());
        MessageStatistic interceptorStat = (MessageStatistic) interceptor.getStats().get(0);
        MessageStatistic 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.getTotalMessageCount(), mbeanStat.getTotalMessageCount());
        assertEquals(interceptorStat.getTotalMessageErrorCount(), mbeanStat.getTotalMessageErrorCount());
        assertEquals(interceptorStat.getTotalMessageSize(), mbeanStat.getTotalMessageSize());
    } finally {
        stop(adapter);
    }
}
Also used : BaseComponentMBean(com.adaptris.core.runtime.BaseComponentMBean) MessageProcessor(com.adaptris.interlok.management.MessageProcessor) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 3 with Adapter

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

the class MessageMetricsStatisticsTest method testNoCachesExists.

@Test
public void testNoCachesExists() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
    try {
        start(adapter);
        register(mBeans);
        ObjectName adapterObj = createAdapterObjectName(adapterName);
        ObjectName metricsObj = createMetricsObjectName(adapterName);
        MessageMetricsStatisticsMBean metrics = JMX.newMBeanProxy(mBeanServer, metricsObj, MessageMetricsStatisticsMBean.class);
        assertEquals(0, metrics.getNumberOfTimeSlices());
    } finally {
        stop(adapter);
    }
}
Also used : BaseComponentMBean(com.adaptris.core.runtime.BaseComponentMBean) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 4 with Adapter

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

the class MessageNotificationCase method createAdapter.

protected Adapter createAdapter(String uid, Workflow... workflows) throws Exception {
    Adapter adapter = new Adapter();
    adapter.setUniqueId(uid);
    adapter.getChannelList().add(createChannel(uid + "_Channel", workflows));
    return adapter;
}
Also used : Adapter(com.adaptris.core.Adapter)

Example 5 with Adapter

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

the class SlowMessageNotificationTest method testNotification_SentAsPartOfCleanup.

@Test
public void testNotification_SentAsPartOfCleanup() throws Exception {
    SlowMessageNotification notif = new SlowMessageNotification(getName(), new TimeInterval(100L, TimeUnit.MILLISECONDS), new TimeInterval(200L, TimeUnit.MILLISECONDS));
    StandardWorkflow workflow = createWorkflow(getName() + "_Workflow", notif);
    workflow.getServiceCollection().add(new WaitService(new TimeInterval(500L, TimeUnit.MILLISECONDS)));
    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("-1", userData.getProperty(SlowMessageNotification.KEY_MESSAGE_DURATION));
        assertEquals("-1", userData.getProperty(SlowMessageNotification.KEY_MESSAGE_END));
        assertEquals("false", 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)

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