Search in sources :

Example 1 with DefaultMuleContext

use of org.mule.runtime.core.internal.context.DefaultMuleContext in project mule by mulesoft.

the class ConvertersNotRegisteredTwiceTestCase method addBuilders.

@Override
protected void addBuilders(List<ConfigurationBuilder> builders) {
    super.addBuilders(builders);
    builders.add(0, new AbstractConfigurationBuilder() {

        @Override
        protected void doConfigure(MuleContext muleContext) throws Exception {
            registryHelper = (MuleRegistryHelper) ((MuleContextWithRegistries) muleContext).getRegistry();
            registryHelper = spy(registryHelper);
            ((DefaultMuleContext) muleContext).setMuleRegistry(registryHelper);
        }
    });
}
Also used : AbstractConfigurationBuilder(org.mule.runtime.core.api.config.builders.AbstractConfigurationBuilder) DefaultMuleContext(org.mule.runtime.core.internal.context.DefaultMuleContext) MuleContext(org.mule.runtime.core.api.MuleContext)

Example 2 with DefaultMuleContext

use of org.mule.runtime.core.internal.context.DefaultMuleContext in project mule by mulesoft.

the class FilePersistenceTestCase method createQueueManager.

@Override
protected TransactionalQueueManager createQueueManager() throws Exception {
    TransactionalQueueManager mgr = new TransactionalQueueManager();
    MuleConfiguration mockConfiguration = mock(MuleConfiguration.class);
    when(mockConfiguration.getWorkingDirectory()).thenReturn(temporaryFolder.getRoot().getAbsolutePath());
    when(mockConfiguration.getMaxQueueTransactionFilesSizeInMegabytes()).thenReturn(100);
    ((DefaultMuleContext) muleContext).setMuleConfiguration(mockConfiguration);
    mgr.setMuleContext(muleContext);
    mgr.initialise();
    mgr.setDefaultQueueConfiguration(new DefaultQueueConfiguration(0, true));
    return mgr;
}
Also used : MuleConfiguration(org.mule.runtime.core.api.config.MuleConfiguration) DefaultQueueConfiguration(org.mule.runtime.core.api.util.queue.DefaultQueueConfiguration) DefaultMuleContext(org.mule.runtime.core.internal.context.DefaultMuleContext)

Example 3 with DefaultMuleContext

use of org.mule.runtime.core.internal.context.DefaultMuleContext in project mule by mulesoft.

the class ClusterExtensionMessageSourceTestCase method before.

@Override
public void before() throws Exception {
    super.before();
    SchedulerController schedulerController = mock(SchedulerController.class);
    when(schedulerController.isPrimarySchedulingInstance()).thenReturn(false);
    ((DefaultMuleContext) muleContext).setSchedulerController(schedulerController);
}
Also used : DefaultMuleContext(org.mule.runtime.core.internal.context.DefaultMuleContext) SchedulerController(org.mule.runtime.core.internal.connector.SchedulerController)

Example 4 with DefaultMuleContext

use of org.mule.runtime.core.internal.context.DefaultMuleContext in project mule by mulesoft.

the class SimpleRegistryBootstrapTestCase method createTestRegistryBootstrap.

private SimpleRegistryBootstrap createTestRegistryBootstrap(ArtifactType artifactType) throws InitialisationException {
    final Properties properties = new Properties();
    properties.put("1", format("java.lang.String,%s=%s", APPLY_TO_ARTIFACT_TYPE_PARAMETER_KEY, APP.getAsString()));
    properties.put("2", format("java.util.Properties,%s=%s", APPLY_TO_ARTIFACT_TYPE_PARAMETER_KEY, DOMAIN.getAsString()));
    properties.put("3", format("java.util.HashMap,%s=%s", APPLY_TO_ARTIFACT_TYPE_PARAMETER_KEY, POLICY.getAsString()));
    properties.put("4", format("java.util.ArrayList,%s=%s/%s/%s", APPLY_TO_ARTIFACT_TYPE_PARAMETER_KEY, APP.getAsString(), DOMAIN.getAsString(), POLICY.getAsString()));
    properties.put("jms.singletx.transaction.resource1", format("%s,optional)", TEST_TRANSACTION_FACTORY_CLASS));
    properties.put("test.singletx.transaction.factory1", FakeTransactionFactory.class.getName());
    properties.put("test.singletx.transaction.resource1", FakeTransactionResource.class.getName());
    final BootstrapServiceDiscoverer bootstrapServiceDiscoverer = new TestBootstrapServiceDiscoverer(properties);
    ((DefaultMuleContext) muleContext).setBootstrapServiceDiscoverer(bootstrapServiceDiscoverer);
    SimpleRegistryBootstrap simpleRegistryBootstrap = new SimpleRegistryBootstrap(artifactType, muleContext);
    simpleRegistryBootstrap.initialise();
    return simpleRegistryBootstrap;
}
Also used : DefaultMuleContext(org.mule.runtime.core.internal.context.DefaultMuleContext) BootstrapServiceDiscoverer(org.mule.runtime.core.api.config.bootstrap.BootstrapServiceDiscoverer) Properties(java.util.Properties)

Example 5 with DefaultMuleContext

use of org.mule.runtime.core.internal.context.DefaultMuleContext in project mule by mulesoft.

the class ExtensionPluginMetadataGenerator method createExtensionManager.

/**
 * Creates a {@link ExtensionManager} needed for generating the metadata for an extension. It would be later discarded due to
 * the manager would have references to classes loaded with the launcher class loader instead of the hierarchical class loaders
 * created as result of the classification process.
 *
 * @return an {@link ExtensionManager} that would be used to register the extensions.
 */
private ExtensionManager createExtensionManager() {
    DefaultExtensionManager extensionManager = new DefaultExtensionManager();
    extensionManager.setMuleContext(new DefaultMuleContext() {

        private ErrorTypeRepository errorTypeRepository = createDefaultErrorTypeRepository();

        private ErrorTypeLocator errorTypeLocator = createDefaultErrorTypeLocator(errorTypeRepository);

        @Override
        public MuleRegistry getRegistry() {
            return new MuleRegistryHelper(new DefaultRegistryBroker(this, new MuleLifecycleInterceptor()), this);
        }

        @Override
        public ErrorTypeLocator getErrorTypeLocator() {
            return errorTypeLocator;
        }

        @Override
        public ErrorTypeRepository getErrorTypeRepository() {
            return errorTypeRepository;
        }
    });
    try {
        extensionManager.initialise();
    } catch (InitialisationException e) {
        throw new RuntimeException("Error while initialising the extension manager", e);
    }
    return extensionManager;
}
Also used : ErrorTypeRepository(org.mule.runtime.api.exception.ErrorTypeRepository) ErrorTypeRepositoryFactory.createDefaultErrorTypeRepository(org.mule.runtime.core.internal.exception.ErrorTypeRepositoryFactory.createDefaultErrorTypeRepository) MuleRegistryHelper(org.mule.runtime.core.internal.registry.MuleRegistryHelper) DefaultMuleContext(org.mule.runtime.core.internal.context.DefaultMuleContext) DefaultRegistryBroker(org.mule.runtime.core.internal.registry.DefaultRegistryBroker) ErrorTypeLocatorFactory.createDefaultErrorTypeLocator(org.mule.runtime.core.internal.exception.ErrorTypeLocatorFactory.createDefaultErrorTypeLocator) ErrorTypeLocator(org.mule.runtime.core.privileged.exception.ErrorTypeLocator) MuleRegistry(org.mule.runtime.core.internal.registry.MuleRegistry) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleLifecycleInterceptor(org.mule.runtime.core.internal.lifecycle.MuleLifecycleInterceptor) DefaultExtensionManager(org.mule.runtime.module.extension.internal.manager.DefaultExtensionManager)

Aggregations

DefaultMuleContext (org.mule.runtime.core.internal.context.DefaultMuleContext)7 Properties (java.util.Properties)1 TransactionManager (javax.transaction.TransactionManager)1 Test (org.junit.Test)1 ErrorTypeRepository (org.mule.runtime.api.exception.ErrorTypeRepository)1 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)1 TransactionManagerFactoryBean (org.mule.runtime.config.internal.factories.TransactionManagerFactoryBean)1 Injector (org.mule.runtime.core.api.Injector)1 MuleContext (org.mule.runtime.core.api.MuleContext)1 MuleConfiguration (org.mule.runtime.core.api.config.MuleConfiguration)1 BootstrapServiceDiscoverer (org.mule.runtime.core.api.config.bootstrap.BootstrapServiceDiscoverer)1 AbstractConfigurationBuilder (org.mule.runtime.core.api.config.builders.AbstractConfigurationBuilder)1 DefaultMuleContextFactory (org.mule.runtime.core.api.context.DefaultMuleContextFactory)1 DefaultQueueConfiguration (org.mule.runtime.core.api.util.queue.DefaultQueueConfiguration)1 DefaultsConfigurationBuilder (org.mule.runtime.core.internal.config.builders.DefaultsConfigurationBuilder)1 SchedulerController (org.mule.runtime.core.internal.connector.SchedulerController)1 ErrorTypeLocatorFactory.createDefaultErrorTypeLocator (org.mule.runtime.core.internal.exception.ErrorTypeLocatorFactory.createDefaultErrorTypeLocator)1 ErrorTypeRepositoryFactory.createDefaultErrorTypeRepository (org.mule.runtime.core.internal.exception.ErrorTypeRepositoryFactory.createDefaultErrorTypeRepository)1 MuleLifecycleInterceptor (org.mule.runtime.core.internal.lifecycle.MuleLifecycleInterceptor)1 DefaultRegistryBroker (org.mule.runtime.core.internal.registry.DefaultRegistryBroker)1