Search in sources :

Example 6 with MulePolicyModelBuilder

use of org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder 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 7 with MulePolicyModelBuilder

use of org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder 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)7 MulePolicyModelBuilder (org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder)7 PolicyFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder)7 File (java.io.File)5 File.createTempFile (java.io.File.createTempFile)5 FileUtils.toFile (org.apache.commons.io.FileUtils.toFile)5 Test (org.junit.Test)5 SmallTest (org.mule.tck.size.SmallTest)5 PolicyTemplateDescriptor (org.mule.runtime.deployment.model.api.policy.PolicyTemplateDescriptor)3 ArtifactPluginFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder)2 URISyntaxException (java.net.URISyntaxException)1 ArtifactPluginDescriptor (org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor)1 ArtifactPluginDescriptorFactory (org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorFactory)1 ArtifactPluginDescriptorLoader (org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorLoader)1 SingleClassCompiler (org.mule.tck.util.CompilerUtils.SingleClassCompiler)1