Search in sources :

Example 1 with OnErrorPropagateHandler

use of org.mule.runtime.core.internal.exception.OnErrorPropagateHandler in project mule by mulesoft.

the class MessageProcessorsTestCase method setup.

@Before
public void setup() throws MuleException {
    flow = mock(Flow.class, RETURNS_DEEP_STUBS);
    OnErrorPropagateHandler exceptionHandler = new OnErrorPropagateHandler();
    exceptionHandler.setMuleContext(muleContext);
    exceptionHandler.setNotificationFirer(((MuleContextWithRegistries) muleContext).getRegistry().lookupObject(NotificationDispatcher.class));
    exceptionHandler.initialise();
    when(flow.getExceptionListener()).thenReturn(exceptionHandler);
    eventContext = (BaseEventContext) create(flow, TEST_CONNECTOR_LOCATION);
    input = builder(eventContext).message(of(TEST_MESSAGE)).build();
    output = builder(eventContext).message(of(TEST_MESSAGE)).build();
    response = builder(eventContext).message(of(TEST_MESSAGE)).build();
    responsePublisher = eventContext.getResponsePublisher();
}
Also used : MuleContextWithRegistries(org.mule.runtime.core.internal.context.MuleContextWithRegistries) NotificationDispatcher(org.mule.runtime.api.notification.NotificationDispatcher) OnErrorPropagateHandler(org.mule.runtime.core.internal.exception.OnErrorPropagateHandler) Flow(org.mule.runtime.core.api.construct.Flow) Before(org.junit.Before)

Example 2 with OnErrorPropagateHandler

use of org.mule.runtime.core.internal.exception.OnErrorPropagateHandler in project mule by mulesoft.

the class MuleContextUtils method mockMuleContext.

public static MuleContextWithRegistries mockMuleContext() {
    final MuleContextWithRegistries muleContext = mock(DefaultMuleContext.class, withSettings().defaultAnswer(RETURNS_DEEP_STUBS).extraInterfaces(PrivilegedMuleContext.class));
    when(muleContext.getUniqueIdString()).thenReturn(UUID.getUUID());
    when(muleContext.getDefaultErrorHandler(empty())).thenReturn(new OnErrorPropagateHandler());
    StreamingManager streamingManager = mock(StreamingManager.class, RETURNS_DEEP_STUBS);
    try {
        MuleRegistry registry = mock(MuleRegistry.class);
        when(muleContext.getRegistry()).thenReturn(registry);
        ComponentInitialStateManager componentInitialStateManager = mock(ComponentInitialStateManager.class);
        when(componentInitialStateManager.mustStartMessageSource(any())).thenReturn(true);
        when(registry.lookupObject(ComponentInitialStateManager.SERVICE_ID)).thenReturn(componentInitialStateManager);
        doReturn(streamingManager).when(registry).lookupObject(StreamingManager.class);
        doReturn(mock(NotificationDispatcher.class)).when(registry).lookupObject(NotificationDispatcher.class);
        doReturn(mock(ObjectStoreManager.class, RETURNS_DEEP_STUBS)).when(registry).lookupObject(OBJECT_STORE_MANAGER);
    } catch (RegistrationException e) {
        throw new RuntimeException(e);
    }
    return muleContext;
}
Also used : ComponentInitialStateManager(org.mule.runtime.api.deployment.management.ComponentInitialStateManager) RegistrationException(org.mule.runtime.core.privileged.registry.RegistrationException) ObjectStoreManager(org.mule.runtime.api.store.ObjectStoreManager) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) StreamingManager(org.mule.runtime.core.api.streaming.StreamingManager) MuleContextWithRegistries(org.mule.runtime.core.internal.context.MuleContextWithRegistries) NotificationDispatcher(org.mule.runtime.api.notification.NotificationDispatcher) MuleRegistry(org.mule.runtime.core.internal.registry.MuleRegistry) OnErrorPropagateHandler(org.mule.runtime.core.internal.exception.OnErrorPropagateHandler) PrivilegedMuleContext(org.mule.runtime.core.privileged.PrivilegedMuleContext)

Aggregations

NotificationDispatcher (org.mule.runtime.api.notification.NotificationDispatcher)2 MuleContextWithRegistries (org.mule.runtime.core.internal.context.MuleContextWithRegistries)2 OnErrorPropagateHandler (org.mule.runtime.core.internal.exception.OnErrorPropagateHandler)2 Before (org.junit.Before)1 ComponentInitialStateManager (org.mule.runtime.api.deployment.management.ComponentInitialStateManager)1 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1 ObjectStoreManager (org.mule.runtime.api.store.ObjectStoreManager)1 Flow (org.mule.runtime.core.api.construct.Flow)1 StreamingManager (org.mule.runtime.core.api.streaming.StreamingManager)1 MuleRegistry (org.mule.runtime.core.internal.registry.MuleRegistry)1 PrivilegedMuleContext (org.mule.runtime.core.privileged.PrivilegedMuleContext)1 RegistrationException (org.mule.runtime.core.privileged.registry.RegistrationException)1