Search in sources :

Example 16 with MuleArtifactLoaderDescriptor

use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor in project mule by mulesoft.

the class AbstractDeploymentTestCase method createByeXmlPluginFileBuilder.

private ArtifactPluginFileBuilder createByeXmlPluginFileBuilder() {
    final String prefixModuleName = "module-bye";
    String extensionName = "bye-extension";
    final String resources = "org/mule/module/";
    String moduleDestination = resources + prefixModuleName + ".xml";
    MulePluginModel.MulePluginModelBuilder builder = new MulePluginModel.MulePluginModelBuilder().setName(extensionName).setMinMuleVersion(MIN_MULE_VERSION);
    builder.withExtensionModelDescriber().setId(XmlExtensionModelLoader.DESCRIBER_ID).addProperty(RESOURCE_XML, moduleDestination);
    builder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
    builder.withBundleDescriptorLoader(createBundleDescriptorLoader(extensionName, MULE_EXTENSION_CLASSIFIER, MULE_LOADER_ID));
    builder.setRequiredProduct(MULE).setMinMuleVersion(MIN_MULE_VERSION);
    return new ArtifactPluginFileBuilder(extensionName).containingResource("module-byeSource.xml", moduleDestination).containingResource("module-using-bye-catalogSource.xml", resources + prefixModuleName + "-catalog.xml").containingResource("module-bye-type-schemaSource.json", resources + "type1-schema.json").containingResource("module-bye-type-schemaSource.json", resources + "inner/folder/type2-schema.json").containingResource("module-bye-type-schemaSource.json", "org/mule/type3-schema.json").describedBy(builder.build());
}
Also used : MuleArtifactLoaderDescriptor(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor) ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) MulePluginModelBuilder(org.mule.runtime.api.deployment.meta.MulePluginModel.MulePluginModelBuilder) MulePluginModel(org.mule.runtime.api.deployment.meta.MulePluginModel) MulePluginModelBuilder(org.mule.runtime.api.deployment.meta.MulePluginModel.MulePluginModelBuilder)

Example 17 with MuleArtifactLoaderDescriptor

use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor in project mule by mulesoft.

the class ApplicationPolicyDeploymentTestCase method failsToApplyBrokenApplicationPolicy.

@Test
public void failsToApplyBrokenApplicationPolicy() throws Exception {
    PolicyFileBuilder brokenPolicyFileBuilder = new PolicyFileBuilder(BAR_POLICY_NAME).describedBy(new MulePolicyModel.MulePolicyModelBuilder().setMinMuleVersion(MIN_MULE_VERSION).setName(BAR_POLICY_NAME).setRequiredProduct(MULE).withBundleDescriptorLoader(createBundleDescriptorLoader(BAR_POLICY_NAME, MULE_POLICY_CLASSIFIER, PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap())).build());
    policyManager.registerPolicyTemplate(brokenPolicyFileBuilder.getArtifactFile());
    ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_EXTENSION_PLUGIN_CONFIG, helloExtensionV1Plugin);
    addPackedAppFromBuilder(applicationFileBuilder);
    startDeployment();
    assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
    try {
        policyManager.addPolicy(applicationFileBuilder.getId(), brokenPolicyFileBuilder.getArtifactId(), new PolicyParametrization(FOO_POLICY_ID, parameters -> true, 1, emptyMap(), getResourceFile("/brokenPolicy.xml"), emptyList()));
        fail("Policy application should have failed");
    } catch (PolicyRegistrationException expected) {
    }
}
Also used : MuleArtifactLoaderDescriptor(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor) URISyntaxException(java.net.URISyntaxException) ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) Matchers.hasItems(org.hamcrest.Matchers.hasItems) PollingProber(org.mule.tck.probe.PollingProber) Collections.singletonList(java.util.Collections.singletonList) BEFORE_NEXT(org.mule.runtime.api.notification.PolicyNotification.BEFORE_NEXT) PROCESS_END(org.mule.runtime.api.notification.PolicyNotification.PROCESS_END) TestPolicyProcessor.policyParametrization(org.mule.runtime.module.deployment.internal.TestPolicyProcessor.policyParametrization) Arrays.asList(java.util.Arrays.asList) Is.is(org.hamcrest.core.Is.is) AbstractSecurityProvider(org.mule.runtime.core.api.security.AbstractSecurityProvider) Assert.fail(org.junit.Assert.fail) PolicyFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder) JUnitProbe(org.mule.tck.probe.JUnitProbe) AFTER_NEXT(org.mule.runtime.api.notification.PolicyNotification.AFTER_NEXT) PolicyPointcut(org.mule.runtime.core.api.policy.PolicyPointcut) MulePluginModel(org.mule.runtime.api.deployment.meta.MulePluginModel) EXPORTED_RESOURCE_PROPERTY(org.mule.runtime.container.internal.ClasspathModuleDiscoverer.EXPORTED_RESOURCE_PROPERTY) MULE_LOADER_ID(org.mule.runtime.deployment.model.api.artifact.ArtifactDescriptorConstants.MULE_LOADER_ID) Collections.emptyList(java.util.Collections.emptyList) PolicyNotification(org.mule.runtime.api.notification.PolicyNotification) PolicyNotificationListener(org.mule.runtime.api.notification.PolicyNotificationListener) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) CompilerUtils(org.mule.tck.util.CompilerUtils) PolicyRegistrationException(org.mule.runtime.deployment.model.api.policy.PolicyRegistrationException) JAVA_LOADER_ID(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader.JAVA_LOADER_ID) List(java.util.List) Matchers.equalTo(org.hamcrest.Matchers.equalTo) MULE(org.mule.runtime.api.deployment.meta.Product.MULE) PROCESS_START(org.mule.runtime.api.notification.PolicyNotification.PROCESS_START) MuleArtifactLoaderDescriptor(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor) EXPORTED_RESOURCES(org.mule.runtime.deployment.model.api.artifact.ArtifactDescriptorConstants.EXPORTED_RESOURCES) BeforeClass(org.junit.BeforeClass) MulePolicyModel(org.mule.runtime.api.deployment.meta.MulePolicyModel) ArrayList(java.util.ArrayList) PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID(org.mule.runtime.module.deployment.impl.internal.policy.PropertiesBundleDescriptorLoader.PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Collections.singletonMap(java.util.Collections.singletonMap) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestPolicyProcessor.invocationCount(org.mule.runtime.module.deployment.internal.TestPolicyProcessor.invocationCount) Collections.emptyMap(java.util.Collections.emptyMap) SecurityException(org.mule.runtime.api.security.SecurityException) XmlExtensionModelLoader(org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader) PolicyParametrization(org.mule.runtime.core.api.policy.PolicyParametrization) JarFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder) Test(org.junit.Test) File(java.io.File) BOOTSTRAP_PROPERTIES(org.mule.runtime.core.internal.config.bootstrap.ClassLoaderRegistryBootstrapDiscoverer.BOOTSTRAP_PROPERTIES) Authentication(org.mule.runtime.api.security.Authentication) EXPORTED_PACKAGES(org.mule.runtime.deployment.model.api.artifact.ArtifactDescriptorConstants.EXPORTED_PACKAGES) RESOURCE_XML(org.mule.runtime.extension.api.loader.xml.XmlExtensionModelLoader.RESOURCE_XML) MuleArtifactLoaderDescriptorBuilder(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder) Product(org.mule.runtime.api.deployment.meta.Product) MulePolicyModel(org.mule.runtime.api.deployment.meta.MulePolicyModel) ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) PolicyFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder) PolicyRegistrationException(org.mule.runtime.deployment.model.api.policy.PolicyRegistrationException) PolicyParametrization(org.mule.runtime.core.api.policy.PolicyParametrization) Test(org.junit.Test)

Example 18 with MuleArtifactLoaderDescriptor

use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor in project mule by mulesoft.

the class PolicyTemplateDescriptorFactoryTestCase method detectsInvalidBundleDescriptorLoaderId.

@Test
public void detectsInvalidBundleDescriptorLoaderId() throws Exception {
    MulePolicyModelBuilder mulePolicyModelBuilder = new MulePolicyModelBuilder().setName(POLICY_NAME).setMinMuleVersion("4.0.0").setRequiredProduct(MULE).withBundleDescriptorLoader(createPolicyBundleDescriptorLoader(INVALID_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(FILE_SYSTEM_POLICY_MODEL_LOADER_ID, emptyMap()));
    PolicyFileBuilder policyFileBuilder = new PolicyFileBuilder(POLICY_NAME).describedBy(mulePolicyModelBuilder.build());
    File tempFolder = createTempFolder();
    unzip(policyFileBuilder.getArtifactFile(), tempFolder);
    PolicyTemplateDescriptorFactory descriptorFactory = new PolicyTemplateDescriptorFactory(artifactPluginDescriptorLoader, descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
    expectedException.expect(ArtifactDescriptorCreateException.class);
    expectedException.expectMessage(invalidBundleDescriptorLoaderIdError(tempFolder, mulePolicyModelBuilder.getBundleDescriptorLoader()));
    descriptorFactory.create(tempFolder, empty());
}
Also used : MuleArtifactLoaderDescriptor(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor) PolicyFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder) MulePolicyModelBuilder(org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder) File.createTempFile(java.io.File.createTempFile) FileUtils.toFile(org.apache.commons.io.FileUtils.toFile) File(java.io.File) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 19 with MuleArtifactLoaderDescriptor

use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor in project mule by mulesoft.

the class PolicyTemplateDescriptorFactoryTestCase method detectsInvalidClassLoaderModelLoaderId.

@Test
public void detectsInvalidClassLoaderModelLoaderId() throws Exception {
    MulePolicyModelBuilder mulePolicyModelBuilder = new MulePolicyModelBuilder().setName(POLICY_NAME).setMinMuleVersion("4.0.0").setRequiredProduct(MULE).withBundleDescriptorLoader(createPolicyBundleDescriptorLoader(PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(INVALID_LOADER_ID, emptyMap()));
    PolicyFileBuilder policyFileBuilder = new PolicyFileBuilder(POLICY_NAME).describedBy(mulePolicyModelBuilder.build());
    File tempFolder = createTempFolder();
    unzip(policyFileBuilder.getArtifactFile(), tempFolder);
    PolicyTemplateDescriptorFactory descriptorFactory = new PolicyTemplateDescriptorFactory(artifactPluginDescriptorLoader, descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
    expectedException.expect(ArtifactDescriptorCreateException.class);
    expectedException.expectMessage(invalidClassLoaderModelIdError(tempFolder, mulePolicyModelBuilder.getClassLoaderModelDescriptorLoader()));
    descriptorFactory.create(tempFolder, empty());
}
Also used : MuleArtifactLoaderDescriptor(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor) PolicyFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder) MulePolicyModelBuilder(org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder) File.createTempFile(java.io.File.createTempFile) FileUtils.toFile(org.apache.commons.io.FileUtils.toFile) File(java.io.File) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 20 with MuleArtifactLoaderDescriptor

use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor in project mule by mulesoft.

the class PolicyTemplateDescriptorFactoryTestCase method assignsBundleDescriptor.

@Test
public void assignsBundleDescriptor() throws Exception {
    MulePolicyModelBuilder mulePolicyModelBuilder = new MulePolicyModelBuilder().setName(POLICY_NAME).setMinMuleVersion("4.0.0").setRequiredProduct(MULE).withBundleDescriptorLoader(createPolicyBundleDescriptorLoader(PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
    PolicyFileBuilder policyFileBuilder = new PolicyFileBuilder(POLICY_NAME).usingLibrary(echoTestJarFile.getAbsolutePath()).describedBy(mulePolicyModelBuilder.build());
    File tempFolder = createTempFolder();
    unzip(policyFileBuilder.getArtifactFile(), tempFolder);
    PolicyTemplateDescriptorFactory descriptorFactory = new PolicyTemplateDescriptorFactory(artifactPluginDescriptorLoader, descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
    PolicyTemplateDescriptor desc = descriptorFactory.create(tempFolder, empty());
    assertThat(desc.getBundleDescriptor().getArtifactId(), equalTo(POLICY_NAME));
    assertThat(desc.getBundleDescriptor().getGroupId(), equalTo(POLICY_GROUP_ID));
    assertThat(desc.getBundleDescriptor().getClassifier().get(), equalTo(POLICY_CLASSIFIER));
    assertThat(desc.getBundleDescriptor().getType(), equalTo(POLICY_ARTIFACT_TYPE));
    assertThat(desc.getBundleDescriptor().getVersion(), equalTo(POLICY_VERSION));
}
Also used : MuleArtifactLoaderDescriptor(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor) PolicyFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder) MulePolicyModelBuilder(org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder) PolicyTemplateDescriptor(org.mule.runtime.deployment.model.api.policy.PolicyTemplateDescriptor) File.createTempFile(java.io.File.createTempFile) FileUtils.toFile(org.apache.commons.io.FileUtils.toFile) File(java.io.File) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

MuleArtifactLoaderDescriptor (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor)22 File (java.io.File)13 Test (org.junit.Test)12 MulePluginModel (org.mule.runtime.api.deployment.meta.MulePluginModel)8 ArtifactPluginFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder)8 PolicyFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder)8 MulePolicyModelBuilder (org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder)7 SmallTest (org.mule.tck.size.SmallTest)7 MuleArtifactLoaderDescriptorBuilder (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder)6 File.createTempFile (java.io.File.createTempFile)5 FileUtils.toFile (org.apache.commons.io.FileUtils.toFile)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)3 MuleServiceModelJsonSerializer (org.mule.runtime.api.deployment.persistence.MuleServiceModelJsonSerializer)3 FileWriter (java.io.FileWriter)2 URISyntaxException (java.net.URISyntaxException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 Collections.emptyList (java.util.Collections.emptyList)2 List (java.util.List)2