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));
}
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);
}
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());
}
};
}
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");
}
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);
}
Aggregations