Search in sources :

Example 1 with XmlExtensionModelLoader

use of org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader in project mule by mulesoft.

the class XmlExtensionLoaderTestCase method getExtensionModelFrom.

/**
 * If {@link #validateXml} is true, the XML of the smart connector must be validated when reading it. False otherwise. Useful to
 * simulate the {@link ExtensionModel} generation of a connector that has malformed message processors in the <body/> element.
 *
 * @param modulePath relative path to the XML connector.
 * @return an {@link ExtensionModel}
 */
private ExtensionModel getExtensionModelFrom(String modulePath) {
    Map<String, Object> parameters = new HashMap<>();
    parameters.put(RESOURCE_XML, modulePath);
    parameters.put(XmlExtensionModelLoader.VALIDATE_XML, validateXml);
    final ExtensionModel extensionModel = new XmlExtensionModelLoader().loadExtensionModel(getClass().getClassLoader(), getDefault(getDependencyExtensions()), parameters);
    assertNoReconnectionIsAdded(extensionModel);
    return extensionModel;
}
Also used : HashMap(java.util.HashMap) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) Matchers.containsString(org.hamcrest.Matchers.containsString) XmlExtensionModelLoader(org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader)

Example 2 with XmlExtensionModelLoader

use of org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader in project mule by mulesoft.

the class XmlExtensionLoaderWithDeclarationTestCase method getExtensionModelFrom.

private ExtensionModel getExtensionModelFrom(Optional<String> declarationPath) {
    Map<String, Object> parameters = new HashMap<>();
    parameters.put(RESOURCE_XML, MODULE_DECLARATION_RESOURCE_FILE);
    parameters.put(XmlExtensionModelLoader.VALIDATE_XML, validateXml);
    declarationPath.ifPresent(path -> parameters.put(XmlExtensionModelLoader.RESOURCE_DECLARATION, path));
    return new XmlExtensionModelLoader().loadExtensionModel(getClass().getClassLoader(), getDefault(EMPTY_SET), parameters);
}
Also used : HashMap(java.util.HashMap) XmlExtensionModelLoader(org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader)

Example 3 with XmlExtensionModelLoader

use of org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader in project mule by mulesoft.

the class DefaultModelValidatorTestCase method getExtensionModelFrom.

private ExtensionModel getExtensionModelFrom(String modulePath, Set<ExtensionModel> extensions) {
    Map<String, Object> parameters = new HashMap<>();
    parameters.put(RESOURCE_XML, modulePath);
    return new XmlExtensionModelLoader().loadExtensionModel(getClass().getClassLoader(), getDefault(extensions), parameters);
}
Also used : HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) XmlExtensionModelLoader(org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader)

Example 4 with XmlExtensionModelLoader

use of org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader in project mule by mulesoft.

the class TestConnectionFailuresTestCase method getExtensionModelFrom.

private ExtensionModel getExtensionModelFrom(String modulePath, Set<ExtensionModel> extensions) {
    Map<String, Object> parameters = new HashMap<>();
    parameters.put(RESOURCE_XML, modulePath);
    return new XmlExtensionModelLoader().loadExtensionModel(getClass().getClassLoader(), getDefault(extensions), parameters);
}
Also used : HashMap(java.util.HashMap) XmlExtensionModelLoader(org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader)

Example 5 with XmlExtensionModelLoader

use of org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader 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)

Aggregations

HashMap (java.util.HashMap)6 XmlExtensionModelLoader (org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader)6 HashSet (java.util.HashSet)2 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)2 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Matchers.containsString (org.hamcrest.Matchers.containsString)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 MuleContext (org.mule.runtime.core.api.MuleContext)1 ConfigurationBuilder (org.mule.runtime.core.api.config.ConfigurationBuilder)1 AbstractConfigurationBuilder (org.mule.runtime.core.api.config.builders.AbstractConfigurationBuilder)1 ExtensionManager (org.mule.runtime.core.api.extension.ExtensionManager)1 LifecycleUtils.initialiseIfNeeded (org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded)1 XmlExtensionLoaderDelegate (org.mule.runtime.extension.internal.loader.XmlExtensionLoaderDelegate)1