Search in sources :

Example 1 with AbstractConfigurationBuilder

use of org.mule.runtime.core.api.config.builders.AbstractConfigurationBuilder 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 AbstractConfigurationBuilder

use of org.mule.runtime.core.api.config.builders.AbstractConfigurationBuilder in project mule by mulesoft.

the class AbstractXmlExtensionMuleArtifactFunctionalTestCase method addBuilders.

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

        @Override
        protected void doConfigure(MuleContext muleContext) throws Exception {
            ExtensionManager extensionManager;
            if (muleContext.getExtensionManager() == null) {
                extensionManager = createDefaultExtensionManager();
                muleContext.setExtensionManager(extensionManager);
                initialiseIfNeeded(extensionManager, muleContext);
            }
            extensionManager = muleContext.getExtensionManager();
            registerXmlExtensions(extensionManager);
        }

        private void registerXmlExtensions(ExtensionManager extensionManager) {
            // take all the plugins loaded by org.mule.test.runner.api.IsolatedClassLoaderExtensionsManagerConfigurationBuilder in the extension manager
            final Set<ExtensionModel> extensions = new HashSet<>(extensionManager.getExtensions());
            for (String modulePath : getModulePaths()) {
                Map<String, Object> params = new HashMap<>();
                params.put(XmlExtensionModelLoader.RESOURCE_XML, modulePath);
                params.put(XmlExtensionModelLoader.VALIDATE_XML, shouldValidateXml());
                operationsOutputPath().ifPresent(path -> params.put(XmlExtensionModelLoader.RESOURCE_DECLARATION, path));
                final DslResolvingContext dslResolvingContext = getDefault(extensions);
                final ExtensionModel extensionModel = new XmlExtensionModelLoader().loadExtensionModel(getClass().getClassLoader(), dslResolvingContext, params);
                extensions.add(extensionModel);
            }
            for (ExtensionModel extension : extensions) {
                extensionManager.registerExtension(extension);
            }
        }
    });
}
Also used : XmlExtensionModelLoader(org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader) AbstractConfigurationBuilder(org.mule.runtime.core.api.config.builders.AbstractConfigurationBuilder) Set(java.util.Set) HashMap(java.util.HashMap) LifecycleUtils.initialiseIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded) MuleExtensionUtils.createDefaultExtensionManager(org.mule.runtime.module.extension.api.util.MuleExtensionUtils.createDefaultExtensionManager) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) XmlExtensionLoaderDelegate(org.mule.runtime.extension.internal.loader.XmlExtensionLoaderDelegate) HashSet(java.util.HashSet) List(java.util.List) MuleContext(org.mule.runtime.core.api.MuleContext) ExtensionManager(org.mule.runtime.core.api.extension.ExtensionManager) Map(java.util.Map) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) ConfigurationBuilder(org.mule.runtime.core.api.config.ConfigurationBuilder) Optional(java.util.Optional) MuleArtifactFunctionalTestCase(org.mule.functional.junit4.MuleArtifactFunctionalTestCase) ArtifactClassLoaderRunnerConfig(org.mule.test.runner.ArtifactClassLoaderRunnerConfig) DslResolvingContext.getDefault(org.mule.runtime.api.dsl.DslResolvingContext.getDefault) AbstractConfigurationBuilder(org.mule.runtime.core.api.config.builders.AbstractConfigurationBuilder) Set(java.util.Set) HashSet(java.util.HashSet) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) MuleContext(org.mule.runtime.core.api.MuleContext) MuleExtensionUtils.createDefaultExtensionManager(org.mule.runtime.module.extension.api.util.MuleExtensionUtils.createDefaultExtensionManager) ExtensionManager(org.mule.runtime.core.api.extension.ExtensionManager) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) HashMap(java.util.HashMap) Map(java.util.Map) XmlExtensionModelLoader(org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader)

Example 3 with AbstractConfigurationBuilder

use of org.mule.runtime.core.api.config.builders.AbstractConfigurationBuilder in project mule by mulesoft.

the class ExtensionFunctionalTestCase method addBuilders.

/**
 * Adds a {@link ConfigurationBuilder} that sets the {@link #extensionManager} into the {@link #muleContext}. This
 * {@link ConfigurationBuilder} is set as the first element of the {@code builders} {@link List}
 *
 * @param builders the list of {@link ConfigurationBuilder}s that will be used to initialise the {@link #muleContext}
 */
@Override
protected // TODO - MULE-11119: Make final again once we can add the HTTP service injection as the scehduler's is
void addBuilders(List<ConfigurationBuilder> builders) {
    super.addBuilders(builders);
    builders.add(0, new AbstractConfigurationBuilder() {

        @Override
        protected void doConfigure(MuleContext muleContext) throws Exception {
            createExtensionsManager(muleContext);
        }
    });
}
Also used : AbstractConfigurationBuilder(org.mule.runtime.core.api.config.builders.AbstractConfigurationBuilder) MuleContext(org.mule.runtime.core.api.MuleContext)

Example 4 with AbstractConfigurationBuilder

use of org.mule.runtime.core.api.config.builders.AbstractConfigurationBuilder in project mule by mulesoft.

the class ConfigurationInjectionLifecycleTestCase method addBuilders.

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

        @Override
        protected void doConfigure(MuleContext muleContext) throws Exception {
            muleContext.getCustomizationService().registerCustomServiceClass("lifecycleTracker", LifecycleTracker.class);
        }
    });
    super.addBuilders(builders);
}
Also used : AbstractConfigurationBuilder(org.mule.runtime.core.api.config.builders.AbstractConfigurationBuilder) MuleContext(org.mule.runtime.core.api.MuleContext) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleException(org.mule.runtime.api.exception.MuleException) OnException(org.mule.runtime.extension.api.annotation.OnException) HeisenbergException(org.mule.test.heisenberg.extension.exception.HeisenbergException)

Aggregations

MuleContext (org.mule.runtime.core.api.MuleContext)4 AbstractConfigurationBuilder (org.mule.runtime.core.api.config.builders.AbstractConfigurationBuilder)4 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 MuleArtifactFunctionalTestCase (org.mule.functional.junit4.MuleArtifactFunctionalTestCase)1 DslResolvingContext (org.mule.runtime.api.dsl.DslResolvingContext)1 DslResolvingContext.getDefault (org.mule.runtime.api.dsl.DslResolvingContext.getDefault)1 MuleException (org.mule.runtime.api.exception.MuleException)1 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)1 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)1 ConfigurationBuilder (org.mule.runtime.core.api.config.ConfigurationBuilder)1 ExtensionManager (org.mule.runtime.core.api.extension.ExtensionManager)1 LifecycleUtils.initialiseIfNeeded (org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded)1 DefaultMuleContext (org.mule.runtime.core.internal.context.DefaultMuleContext)1 OnException (org.mule.runtime.extension.api.annotation.OnException)1 XmlExtensionModelLoader (org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader)1