Search in sources :

Example 1 with NoRetryPolicyTemplate

use of org.mule.runtime.core.api.retry.policy.NoRetryPolicyTemplate in project mule by mulesoft.

the class DefaultsConfigurationBuilder method doConfigure.

@Override
protected void doConfigure(MuleContext muleContext) throws Exception {
    MuleRegistry registry = ((MuleContextWithRegistries) muleContext).getRegistry();
    new SimpleRegistryBootstrap(APP, muleContext).initialise();
    configureQueueManager(muleContext);
    registry.registerObject(OBJECT_MULE_CONTEXT, muleContext);
    registerObject(OBJECT_SECURITY_MANAGER, new DefaultMuleSecurityManager(), muleContext);
    registerObject(BASE_IN_MEMORY_OBJECT_STORE_KEY, createDefaultInMemoryObjectStore(), muleContext);
    registerObject(BASE_PERSISTENT_OBJECT_STORE_KEY, createDefaultPersistentObjectStore(), muleContext);
    registerLocalObjectStoreManager(muleContext, registry);
    registerObject(OBJECT_SCHEDULER_POOLS_CONFIG, SchedulerContainerPoolsConfig.getInstance(), muleContext);
    registerObject(OBJECT_SCHEDULER_BASE_CONFIG, config().withPrefix(muleContext.getConfiguration().getId()).withShutdownTimeout(() -> muleContext.getConfiguration().getShutdownTimeout(), MILLISECONDS), muleContext);
    registerObject(OBJECT_STORE_MANAGER, new MuleObjectStoreManager(), muleContext);
    registerObject(OBJECT_DEFAULT_MESSAGE_PROCESSING_MANAGER, new MuleMessageProcessingManager(), muleContext);
    registerObject(OBJECT_MULE_STREAM_CLOSER_SERVICE, new DefaultStreamCloserService(), muleContext);
    registerObject(OBJECT_LOCK_PROVIDER, new SingleServerLockProvider(), muleContext);
    registerObject(OBJECT_LOCK_FACTORY, new MuleLockFactory(), muleContext);
    registerObject(OBJECT_PROCESSING_TIME_WATCHER, new DefaultProcessingTimeWatcher(), muleContext);
    registerObject(OBJECT_DEFAULT_RETRY_POLICY_TEMPLATE, new NoRetryPolicyTemplate(), muleContext);
    registerObject(OBJECT_CONVERTER_RESOLVER, new DynamicDataTypeConversionResolver(muleContext), muleContext);
    registerObject(DEFAULT_OBJECT_SERIALIZER_NAME, new JavaObjectSerializer(), muleContext);
    registerObject(OBJECT_EXPRESSION_LANGUAGE, new MVELExpressionLanguage(muleContext), muleContext);
    StreamingManager streamingManager = new DefaultStreamingManager();
    registerObject(OBJECT_STREAMING_MANAGER, streamingManager, muleContext);
    registerObject(OBJECT_EXPRESSION_MANAGER, new DefaultExpressionManager(), muleContext);
    registerObject(OBJECT_TIME_SUPPLIER, new LocalTimeSupplier(), muleContext);
    registerObject(OBJECT_CONNECTION_MANAGER, new DefaultConnectionManager(muleContext), muleContext);
    registerObject(METADATA_SERVICE_KEY, new MuleMetadataService(), muleContext);
    registerObject(VALUE_PROVIDER_SERVICE_KEY, new MuleValueProviderService(), muleContext);
    registerObject(PROCESSOR_INTERCEPTOR_MANAGER_REGISTRY_KEY, new DefaultProcessorInterceptorManager(), muleContext);
    registerObject(OBJECT_NOTIFICATION_DISPATCHER, new DefaultNotificationDispatcher(), muleContext);
    registerObject(NotificationListenerRegistry.REGISTRY_KEY, new DefaultNotificationListenerRegistry(), muleContext);
    registerObject(EventContextService.REGISTRY_KEY, new DefaultEventContextService(), muleContext);
    registerObject(OBJECT_TRANSACTION_FACTORY_LOCATOR, new TransactionFactoryLocator(), muleContext);
    registerObject(ComponentInitialStateManager.SERVICE_ID, new ComponentInitialStateManager() {

        @Override
        public boolean mustStartMessageSource(Component component) {
            return true;
        }
    }, muleContext);
}
Also used : TransactionFactoryLocator(org.mule.runtime.core.internal.transaction.TransactionFactoryLocator) DefaultEventContextService(org.mule.runtime.core.internal.event.DefaultEventContextService) DefaultConnectionManager(org.mule.runtime.core.internal.connection.DefaultConnectionManager) MuleMessageProcessingManager(org.mule.runtime.core.internal.execution.MuleMessageProcessingManager) DefaultNotificationDispatcher(org.mule.runtime.core.internal.context.notification.DefaultNotificationDispatcher) DefaultNotificationListenerRegistry(org.mule.runtime.core.internal.context.notification.DefaultNotificationListenerRegistry) NoRetryPolicyTemplate(org.mule.runtime.core.api.retry.policy.NoRetryPolicyTemplate) LocalTimeSupplier(org.mule.runtime.core.internal.time.LocalTimeSupplier) MuleMetadataService(org.mule.runtime.core.internal.metadata.MuleMetadataService) Component(org.mule.runtime.api.component.Component) DynamicDataTypeConversionResolver(org.mule.runtime.core.internal.transformer.DynamicDataTypeConversionResolver) MuleValueProviderService(org.mule.runtime.core.internal.value.MuleValueProviderService) MuleContextWithRegistries(org.mule.runtime.core.internal.context.MuleContextWithRegistries) MuleObjectStoreManager(org.mule.runtime.core.internal.util.store.MuleObjectStoreManager) SingleServerLockProvider(org.mule.runtime.core.internal.lock.SingleServerLockProvider) DefaultProcessingTimeWatcher(org.mule.runtime.core.internal.management.stats.DefaultProcessingTimeWatcher) MVELExpressionLanguage(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguage) JavaObjectSerializer(org.mule.runtime.core.internal.serialization.JavaObjectSerializer) MuleLockFactory(org.mule.runtime.core.internal.lock.MuleLockFactory) ComponentInitialStateManager(org.mule.runtime.api.deployment.management.ComponentInitialStateManager) DefaultMuleSecurityManager(org.mule.runtime.core.internal.security.DefaultMuleSecurityManager) DefaultExpressionManager(org.mule.runtime.core.internal.el.DefaultExpressionManager) DefaultProcessorInterceptorManager(org.mule.runtime.core.internal.processor.interceptor.DefaultProcessorInterceptorManager) DefaultStreamCloserService(org.mule.runtime.core.internal.util.DefaultStreamCloserService) StreamingManager(org.mule.runtime.core.api.streaming.StreamingManager) DefaultStreamingManager(org.mule.runtime.core.api.streaming.DefaultStreamingManager) MuleRegistry(org.mule.runtime.core.internal.registry.MuleRegistry) DefaultStreamingManager(org.mule.runtime.core.api.streaming.DefaultStreamingManager) SimpleRegistryBootstrap(org.mule.runtime.core.internal.config.bootstrap.SimpleRegistryBootstrap)

Example 2 with NoRetryPolicyTemplate

use of org.mule.runtime.core.api.retry.policy.NoRetryPolicyTemplate in project mule by mulesoft.

the class AbstractOperationMessageProcessorTestCase method before.

@Before
public void before() throws Exception {
    ((MuleContextWithRegistries) muleContext).getRegistry().registerObject(OBJECT_STREAMING_MANAGER, streamingManager);
    cursorStreamProviderFactory = spy(getDefaultCursorStreamProviderFactory(streamingManager));
    event = configureEvent();
    when(context.getInjector().inject(any())).thenAnswer(invocationOnMock -> {
        final Object subject = invocationOnMock.getArguments()[0];
        muleContext.getInjector().inject(subject);
        return subject;
    });
    when(extensionModel.getName()).thenReturn(EXTENSION_NAMESPACE);
    when(extensionModel.getConfigurationModels()).thenReturn(asList(configurationModel));
    when(operationModel.getName()).thenReturn(getClass().getName());
    when(operationModel.isBlocking()).thenReturn(true);
    when(extensionModel.getXmlDslModel()).thenReturn(XmlDslModel.builder().setPrefix("test-extension").build());
    when(operationModel.getOutput()).thenReturn(new ImmutableOutputModel("Message.Payload", toMetadataType(String.class), false, emptySet()));
    mockExecutorFactory(operationModel, operationExecutorFactory);
    visitableMock(operationModel);
    when(operationModel.getModelProperty(MetadataKeyIdModelProperty.class)).thenReturn(of(new MetadataKeyIdModelProperty(ExtensionsTypeLoaderFactory.getDefault().createTypeLoader().load(String.class), "someParam")));
    setRequires(operationModel, true, true);
    when(operationExecutorFactory.createExecutor(same(operationModel), anyMap())).thenReturn(operationExecutor);
    when(operationModel.getName()).thenReturn(OPERATION_NAME);
    when(operationModel.getDisplayModel()).thenReturn(empty());
    when(operationModel.getModelProperty(MediaTypeModelProperty.class)).thenReturn(empty());
    mockExceptionEnricher(operationModel, exceptionHandlerFactory);
    when(exceptionHandlerFactory.createHandler()).thenReturn(new NullExceptionHandler());
    mockMetadataResolverFactory(operationModel, metadataResolverFactory);
    when(metadataResolverFactory.getKeyResolver()).thenReturn(new TestNoConfigMetadataResolver());
    when(metadataResolverFactory.getInputResolver("content")).thenReturn(new TestNoConfigMetadataResolver());
    when(metadataResolverFactory.getInputResolver("type")).thenReturn(new NullMetadataResolver());
    when(metadataResolverFactory.getOutputResolver()).thenReturn(new TestNoConfigMetadataResolver());
    when(metadataResolverFactory.getOutputAttributesResolver()).thenReturn(new TestNoConfigMetadataResolver());
    when(metadataResolverFactory.getQueryEntityResolver()).thenReturn(new TestNoConfigMetadataResolver());
    when(keyParamMock.getName()).thenReturn("type");
    when(keyParamMock.getType()).thenReturn(stringType);
    when(keyParamMock.getModelProperty(MetadataKeyPartModelProperty.class)).thenReturn(of(new MetadataKeyPartModelProperty(1)));
    when(keyParamMock.getRole()).thenReturn(BEHAVIOUR);
    when(keyParamMock.getDisplayModel()).thenReturn(empty());
    when(keyParamMock.getLayoutModel()).thenReturn(empty());
    when(keyParamMock.getModelProperty(QueryParameterModelProperty.class)).thenReturn(empty());
    when(keyParamMock.getModelProperty(FieldOperationParameterModelProperty.class)).thenReturn(empty());
    when(contentMock.getName()).thenReturn("content");
    when(contentMock.hasDynamicType()).thenReturn(true);
    when(contentMock.getType()).thenReturn(stringType);
    when(contentMock.getRole()).thenReturn(CONTENT);
    when(contentMock.getDisplayModel()).thenReturn(empty());
    when(contentMock.getLayoutModel()).thenReturn(empty());
    when(contentMock.getModelProperty(MetadataKeyPartModelProperty.class)).thenReturn(empty());
    when(contentMock.getModelProperty(QueryParameterModelProperty.class)).thenReturn(empty());
    when(contentMock.getModelProperty(FieldOperationParameterModelProperty.class)).thenReturn(empty());
    parameterGroupModel = mockParameters(operationModel, keyParamMock, contentMock);
    when(parameterGroupModel.getDisplayModel()).thenReturn(empty());
    when(parameterGroupModel.getLayoutModel()).thenReturn(empty());
    when(parameterGroupModel.getModelProperty(MetadataKeyIdModelProperty.class)).thenReturn(empty());
    when(outputMock.getType()).thenReturn(stringType);
    when(outputMock.hasDynamicType()).thenReturn(true);
    when(operationModel.getOutput()).thenReturn(outputMock);
    when(operationModel.getOutputAttributes()).thenReturn(outputMock);
    when(operationModel.getModelProperty(InterceptorsModelProperty.class)).thenReturn(empty());
    when(operationExecutorFactory.createExecutor(same(operationModel), anyMap())).thenReturn(operationExecutor);
    when(operationExecutor.execute(any())).thenReturn(just(""));
    when(resolverSet.resolve(from(event))).thenReturn(parameters);
    when(configurationInstance.getName()).thenReturn(CONFIG_NAME);
    when(configurationInstance.getModel()).thenReturn(configurationModel);
    when(configurationInstance.getValue()).thenReturn(configuration);
    when(configurationInstance.getConnectionProvider()).thenReturn(of(connectionProviderWrapper));
    when(configurationProvider.get(event)).thenReturn(configurationInstance);
    when(configurationProvider.getConfigurationModel()).thenReturn(configurationModel);
    when(configurationProvider.getName()).thenReturn(configurationName);
    when(configurationModel.getOperationModels()).thenReturn(asList(operationModel));
    when(configurationModel.getOperationModel(OPERATION_NAME)).thenReturn(of(operationModel));
    when(connectionProviderWrapper.getReconnectionConfig()).thenReturn(of(ReconnectionConfig.getDefault()));
    when(connectionProviderWrapper.getRetryPolicyTemplate()).thenReturn(new NoRetryPolicyTemplate());
    mockSubTypes(extensionModel);
    mockClassLoaderModelProperty(extensionModel, getClass().getClassLoader());
    when(extensionManager.getConfiguration(anyString(), anyObject())).thenReturn(configurationInstance);
    when(extensionManager.getConfiguration(extensionModel, operationModel, event)).thenReturn(of(configurationInstance));
    when(configurationProvider.get(anyObject())).thenReturn(configurationInstance);
    when(extensionManager.getConfigurationProvider(extensionModel, operationModel)).thenReturn(of(configurationProvider));
    when(extensionManager.getConfigurationProvider(CONFIG_NAME)).thenReturn(of(configurationProvider));
    when(stringType.getAnnotation(anyObject())).thenReturn(empty());
    when(mockPolicyManager.createOperationPolicy(any(), any(), any(), any())).thenAnswer(invocationOnMock -> {
        if (mockOperationPolicy == null) {
            mockOperationPolicy = mock(OperationPolicy.class);
            when(mockOperationPolicy.process(any())).thenAnswer(operationPolicyInvocationMock -> ((OperationExecutionFunction) invocationOnMock.getArguments()[3]).execute((Map<String, Object>) invocationOnMock.getArguments()[2], (CoreEvent) invocationOnMock.getArguments()[1]));
        }
        return mockOperationPolicy;
    });
    when(executionContext.getRetryPolicyTemplate()).thenReturn(empty());
    when(connectionManagerAdapter.getConnection(anyString())).thenReturn(null);
    messageProcessor = setUpOperationMessageProcessor();
}
Also used : NullMetadataResolver(org.mule.runtime.extension.api.metadata.NullMetadataResolver) ImmutableOutputModel(org.mule.runtime.extension.api.model.ImmutableOutputModel) MetadataKeyIdModelProperty(org.mule.runtime.extension.api.property.MetadataKeyIdModelProperty) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) OperationPolicy(org.mule.runtime.core.internal.policy.OperationPolicy) Matchers.anyObject(org.mockito.Matchers.anyObject) MetadataKeyPartModelProperty(org.mule.runtime.extension.api.property.MetadataKeyPartModelProperty) Matchers.anyString(org.mockito.Matchers.anyString) NullExceptionHandler(org.mule.runtime.module.extension.internal.runtime.exception.NullExceptionHandler) TestNoConfigMetadataResolver(org.mule.test.metadata.extension.resolver.TestNoConfigMetadataResolver) Map(java.util.Map) Matchers.anyMap(org.mockito.Matchers.anyMap) NoRetryPolicyTemplate(org.mule.runtime.core.api.retry.policy.NoRetryPolicyTemplate) Before(org.junit.Before)

Example 3 with NoRetryPolicyTemplate

use of org.mule.runtime.core.api.retry.policy.NoRetryPolicyTemplate in project mule by mulesoft.

the class OperationMessageProcessorTestCase method createOperationMessageProcessor.

@Override
protected OperationMessageProcessor createOperationMessageProcessor() {
    OperationMessageProcessor operationMessageProcessor = new OperationMessageProcessor(extensionModel, operationModel, configurationProvider, target, targetValue, resolverSet, cursorStreamProviderFactory, new NoRetryPolicyTemplate(), extensionManager, mockPolicyManager, reflectionCache);
    operationMessageProcessor.setAnnotations(getFlowComponentLocationAnnotations(FLOW_NAME));
    return operationMessageProcessor;
}
Also used : NoRetryPolicyTemplate(org.mule.runtime.core.api.retry.policy.NoRetryPolicyTemplate)

Aggregations

NoRetryPolicyTemplate (org.mule.runtime.core.api.retry.policy.NoRetryPolicyTemplate)3 Map (java.util.Map)1 Before (org.junit.Before)1 Matchers.anyMap (org.mockito.Matchers.anyMap)1 Matchers.anyObject (org.mockito.Matchers.anyObject)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Component (org.mule.runtime.api.component.Component)1 ComponentInitialStateManager (org.mule.runtime.api.deployment.management.ComponentInitialStateManager)1 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)1 DefaultStreamingManager (org.mule.runtime.core.api.streaming.DefaultStreamingManager)1 StreamingManager (org.mule.runtime.core.api.streaming.StreamingManager)1 SimpleRegistryBootstrap (org.mule.runtime.core.internal.config.bootstrap.SimpleRegistryBootstrap)1 DefaultConnectionManager (org.mule.runtime.core.internal.connection.DefaultConnectionManager)1 MuleContextWithRegistries (org.mule.runtime.core.internal.context.MuleContextWithRegistries)1 DefaultNotificationDispatcher (org.mule.runtime.core.internal.context.notification.DefaultNotificationDispatcher)1 DefaultNotificationListenerRegistry (org.mule.runtime.core.internal.context.notification.DefaultNotificationListenerRegistry)1 DefaultExpressionManager (org.mule.runtime.core.internal.el.DefaultExpressionManager)1 MVELExpressionLanguage (org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguage)1 DefaultEventContextService (org.mule.runtime.core.internal.event.DefaultEventContextService)1 MuleMessageProcessingManager (org.mule.runtime.core.internal.execution.MuleMessageProcessingManager)1