Search in sources :

Example 1 with DefaultJavaExtensionModelLoader

use of org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader in project mule by mulesoft.

the class ExtensionActivatorTestCase method enumsReleasedWhenStopped.

@Test
public void enumsReleasedWhenStopped() throws Exception {
    Map<String, Object> attributes = new HashMap<>();
    attributes.put(TYPE_PROPERTY_NAME, HeisenbergExtension.class.getName());
    attributes.put(VERSION, "1.0.0");
    ExtensionModel extensionModel = new DefaultJavaExtensionModelLoader().loadExtensionModel(HeisenbergExtension.class.getClassLoader(), new DefaultDslResolvingContext(Collections.emptySet()), attributes);
    ExtensionActivator extensionActivator = new ExtensionActivator(mock(ExtensionErrorsRegistrant.class, RETURNS_DEEP_STUBS), mockMuleContext());
    extensionActivator.activateExtension(extensionModel);
    assertThat(extensionActivator.getEnumTypes().size(), is(greaterThan(0)));
    extensionActivator.stop();
    assertThat(extensionActivator.getEnumTypes(), hasSize(0));
}
Also used : HashMap(java.util.HashMap) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) DefaultJavaExtensionModelLoader(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) DefaultDslResolvingContext(org.mule.runtime.internal.dsl.DefaultDslResolvingContext) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 2 with DefaultJavaExtensionModelLoader

use of org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader in project mule by mulesoft.

the class XmlExtensionLoaderTestCase method loadExtension.

private ExtensionModel loadExtension(Class extension, Set<ExtensionModel> deps) {
    DefaultJavaExtensionModelLoader loader = new DefaultJavaExtensionModelLoader();
    Map<String, Object> ctx = new HashMap<>();
    ctx.put(TYPE_PROPERTY_NAME, extension.getName());
    ctx.put(VERSION, "1.0.0-SNAPSHOT");
    return loader.loadExtensionModel(currentThread().getContextClassLoader(), DslResolvingContext.getDefault(deps), ctx);
}
Also used : HashMap(java.util.HashMap) DefaultJavaExtensionModelLoader(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader) Matchers.containsString(org.hamcrest.Matchers.containsString)

Example 3 with DefaultJavaExtensionModelLoader

use of org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader in project mule by mulesoft.

the class ExtensionResourcesGeneratorAnnotationProcessor method getExtensionModelLoader.

@Override
protected ExtensionModelLoader getExtensionModelLoader() {
    return new DefaultJavaExtensionModelLoader() {

        @Override
        protected void configureContextBeforeDeclaration(ExtensionLoadingContext context) {
            super.configureContextBeforeDeclaration(context);
            context.addCustomDeclarationEnricher(new DescriptionDeclarationEnricher());
            context.addCustomValidator(new ExportedPackagesValidator());
        }
    };
}
Also used : ExportedPackagesValidator(org.mule.runtime.module.extension.internal.resources.validator.ExportedPackagesValidator) ExtensionLoadingContext(org.mule.runtime.extension.api.loader.ExtensionLoadingContext) DescriptionDeclarationEnricher(org.mule.runtime.module.extension.internal.capability.xml.description.DescriptionDeclarationEnricher) DefaultJavaExtensionModelLoader(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader)

Example 4 with DefaultJavaExtensionModelLoader

use of org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader in project mule by mulesoft.

the class ExtensionResourcesGeneratorAnnotationProcessorTestCase method generateDocumentedSchema.

@Test
public void generateDocumentedSchema() throws Exception {
    ArgumentCaptor<ByteSource> byteSourceCaptor = ArgumentCaptor.forClass(ByteSource.class);
    ByteSource byteSource = mock(ByteSource.class);
    when(byteSource.contentEquals(byteSourceCaptor.capture())).thenReturn(true);
    DefaultJavaExtensionModelLoader loader = new DefaultJavaExtensionModelLoader();
    ExtensionModel model = loader.loadExtensionModel(TestExtensionWithDocumentationAndMultipleConfig.class.getClassLoader(), DslResolvingContext.getDefault(emptySet()), ImmutableMap.<String, Object>builder().put(TYPE_PROPERTY_NAME, TestExtensionWithDocumentationAndMultipleConfig.class.getName()).put(VERSION, "4.0.0").build());
    String generatedSchema = new DefaultExtensionSchemaGenerator().generate(model, DslResolvingContext.getDefault(emptySet()));
    assertThat(generatedSchema, is(notNullValue()));
    assertXpath(generatedSchema, "//xs:attribute[@name='configParameter']/xs:annotation/xs:documentation", "Config parameter");
    assertXpath(generatedSchema, "//xs:attribute[@name='configParameterWithComplexJavadoc']/xs:annotation/xs:documentation", "Config Parameter with an Optional value");
    assertXpath(generatedSchema, "//xs:attribute[@name='value1']/xs:annotation/xs:documentation", GROUP_PARAMETER_1);
    assertXpath(generatedSchema, "//xs:attribute[@name='value2']/xs:annotation/xs:documentation", GROUP_PARAMETER_2);
    assertXpath(generatedSchema, "//xs:element[@name='operation']/xs:annotation/xs:documentation", "Test Operation");
    assertXpath(generatedSchema, "//xs:complexType[@name='OperationType']/xs:complexContent/xs:extension/xs:attribute[@name='value']/xs:annotation/xs:documentation", "test value");
    assertXpath(generatedSchema, "//xs:complexType[@name='OperationType']/xs:complexContent/xs:extension/xs:attribute[@name='value1']/xs:annotation/xs:documentation", GROUP_PARAMETER_1);
    assertXpath(generatedSchema, "//xs:complexType[@name='OperationType']/xs:complexContent/xs:extension/xs:attribute[@name='value2']/xs:annotation/xs:documentation", GROUP_PARAMETER_2);
    assertXpath(generatedSchema, "//xs:element[@name='ignore-operation-should-be-ignored']/xs:annotation/xs:documentation", "");
    assertXpath(generatedSchema, "//xs:element[@name='private-operation-should-be-ignored']/xs:annotation/xs:documentation", "");
    assertXpath(generatedSchema, "//xs:element[@name='operation-with-blank-parameter-description']/xs:annotation/xs:documentation", "Test Operation with blank parameter description");
    assertXpath(generatedSchema, "//xs:complexType[@name='OperationWithBlankParameterDescriptionType']/xs:complexContent/xs:extension/xs:attribute[@name='value']/xs:annotation/xs:documentation", "");
    assertXpath(generatedSchema, "//xs:element[@name='operation-with-javadoc-link-references']/xs:annotation/xs:documentation", "Operation that returns a String value");
    assertXpath(generatedSchema, "//xs:complexType[@name='OperationWithJavadocLinkReferencesType']/xs:complexContent/xs:extension/xs:attribute[@name='value']/xs:annotation/xs:documentation", "this is the String to be returned");
}
Also used : DefaultExtensionSchemaGenerator(org.mule.runtime.module.extension.internal.capability.xml.schema.DefaultExtensionSchemaGenerator) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ByteSource(com.google.common.io.ByteSource) DefaultJavaExtensionModelLoader(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader) TestExtensionWithDocumentationAndMultipleConfig(org.mule.runtime.module.extension.internal.capability.xml.extension.multiple.config.TestExtensionWithDocumentationAndMultipleConfig) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 5 with DefaultJavaExtensionModelLoader

use of org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader in project mule by mulesoft.

the class DefaultModelValidatorTestCase method loadExtension.

private ExtensionModel loadExtension(Class extension, Set<ExtensionModel> deps) {
    DefaultJavaExtensionModelLoader loader = new DefaultJavaExtensionModelLoader();
    Map<String, Object> ctx = new HashMap<>();
    ctx.put(TYPE_PROPERTY_NAME, extension.getName());
    ctx.put(VERSION, "1.0.0-SNAPSHOT");
    return loader.loadExtensionModel(currentThread().getContextClassLoader(), DslResolvingContext.getDefault(deps), ctx);
}
Also used : HashMap(java.util.HashMap) DefaultJavaExtensionModelLoader(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Aggregations

DefaultJavaExtensionModelLoader (org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader)7 HashMap (java.util.HashMap)3 Test (org.junit.Test)2 DslResolvingContext (org.mule.runtime.api.dsl.DslResolvingContext)2 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)2 SmallTest (org.mule.tck.size.SmallTest)2 ByteSource (com.google.common.io.ByteSource)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 ExtensionLoadingContext (org.mule.runtime.extension.api.loader.ExtensionLoadingContext)1 DefaultDslResolvingContext (org.mule.runtime.internal.dsl.DefaultDslResolvingContext)1 DescriptionDeclarationEnricher (org.mule.runtime.module.extension.internal.capability.xml.description.DescriptionDeclarationEnricher)1 TestExtensionWithDocumentationAndMultipleConfig (org.mule.runtime.module.extension.internal.capability.xml.extension.multiple.config.TestExtensionWithDocumentationAndMultipleConfig)1 DefaultExtensionSchemaGenerator (org.mule.runtime.module.extension.internal.capability.xml.schema.DefaultExtensionSchemaGenerator)1 ExportedPackagesValidator (org.mule.runtime.module.extension.internal.resources.validator.ExportedPackagesValidator)1 HeisenbergExtension (org.mule.test.heisenberg.extension.HeisenbergExtension)1