Search in sources :

Example 1 with PolicyTemplateDescriptorFactory

use of org.mule.runtime.module.deployment.impl.internal.policy.PolicyTemplateDescriptorFactory in project mule by mulesoft.

the class AbstractDeploymentTestCase method setUp.

@Before
public void setUp() throws Exception {
    if (parallelDeployment) {
        setProperty(PARALLEL_DEPLOYMENT_PROPERTY, "");
    }
    final String tmpDir = getProperty("java.io.tmpdir");
    muleHome = new File(new File(tmpDir, "mule_home"), getClass().getSimpleName() + currentTimeMillis());
    appsDir = new File(muleHome, "apps");
    appsDir.mkdirs();
    domainsDir = new File(muleHome, "domains");
    domainsDir.mkdirs();
    setProperty(MULE_HOME_DIRECTORY_PROPERTY, muleHome.getCanonicalPath());
    GlobalConfigLoader.reset();
    final File domainFolder = getDomainFolder(DEFAULT_DOMAIN_NAME);
    assertThat(domainFolder.mkdirs(), is(true));
    services = getServicesFolder();
    services.mkdirs();
    copyFileToDirectory(buildSchedulerServiceFile(compilerWorkFolder.newFolder("schedulerService")), services);
    copyFileToDirectory(buildExpressionLanguageServiceFile(compilerWorkFolder.newFolder("expressionLanguageService")), services);
    applicationDeploymentListener = mock(DeploymentListener.class);
    testDeploymentListener = new TestDeploymentListener();
    domainDeploymentListener = mock(DeploymentListener.class);
    domainBundleDeploymentListener = mock(DeploymentListener.class);
    moduleDiscoverer = new TestModuleDiscoverer(getPrivilegedArtifactIds());
    moduleRepository = new DefaultModuleRepository(moduleDiscoverer);
    MuleArtifactResourcesRegistry muleArtifactResourcesRegistry = new MuleArtifactResourcesRegistry.Builder().moduleRepository(moduleRepository).build();
    serviceManager = muleArtifactResourcesRegistry.getServiceManager();
    containerClassLoader = muleArtifactResourcesRegistry.getContainerClassLoader();
    extensionModelLoaderManager = muleArtifactResourcesRegistry.getExtensionModelLoaderManager();
    artifactClassLoaderManager = muleArtifactResourcesRegistry.getArtifactClassLoaderManager();
    deploymentService = new TestMuleDeploymentService(muleArtifactResourcesRegistry.getDomainFactory(), muleArtifactResourcesRegistry.getApplicationFactory(), () -> findSchedulerService(serviceManager));
    deploymentService.addDeploymentListener(applicationDeploymentListener);
    deploymentService.addDomainDeploymentListener(domainDeploymentListener);
    deploymentService.addDeploymentListener(testDeploymentListener);
    deploymentService.addDomainDeploymentListener(testDeploymentListener);
    deploymentService.addDomainBundleDeploymentListener(domainBundleDeploymentListener);
    policyManager = new TestPolicyManager(deploymentService, new PolicyTemplateDescriptorFactory(muleArtifactResourcesRegistry.getArtifactPluginDescriptorLoader(), createDescriptorLoaderRepository(), ArtifactDescriptorValidatorBuilder.builder()));
    // Reset test component state
    invocationCount = 0;
    policyParametrization = "";
}
Also used : DefaultModuleRepository(org.mule.runtime.container.internal.DefaultModuleRepository) MuleArtifactResourcesRegistry(org.mule.runtime.module.deployment.impl.internal.MuleArtifactResourcesRegistry) TestModuleDiscoverer(org.mule.test.runner.classloader.TestModuleDiscoverer) ServiceFileBuilder(org.mule.runtime.module.service.builder.ServiceFileBuilder) MulePolicyModelBuilder(org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder) MuleArtifactLoaderDescriptorBuilder(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder) ArtifactDescriptorValidatorBuilder(org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptorValidatorBuilder) ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) MulePluginModelBuilder(org.mule.runtime.api.deployment.meta.MulePluginModel.MulePluginModelBuilder) PolicyFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder) ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) DomainFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder) JarFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder) PolicyTemplateDescriptorFactory(org.mule.runtime.module.deployment.impl.internal.policy.PolicyTemplateDescriptorFactory) TestDeploymentListener(org.mule.runtime.module.deployment.api.TestDeploymentListener) DeploymentListener(org.mule.runtime.module.deployment.api.DeploymentListener) FileUtils.toFile(org.apache.commons.io.FileUtils.toFile) TestServicesUtils.buildExpressionLanguageServiceFile(org.mule.functional.services.TestServicesUtils.buildExpressionLanguageServiceFile) File(java.io.File) TestServicesUtils.buildSchedulerServiceFile(org.mule.functional.services.TestServicesUtils.buildSchedulerServiceFile) FileUtils.copyFile(org.apache.commons.io.FileUtils.copyFile) TestDeploymentListener(org.mule.runtime.module.deployment.api.TestDeploymentListener) Before(org.junit.Before)

Aggregations

File (java.io.File)1 FileUtils.copyFile (org.apache.commons.io.FileUtils.copyFile)1 FileUtils.toFile (org.apache.commons.io.FileUtils.toFile)1 Before (org.junit.Before)1 TestServicesUtils.buildExpressionLanguageServiceFile (org.mule.functional.services.TestServicesUtils.buildExpressionLanguageServiceFile)1 TestServicesUtils.buildSchedulerServiceFile (org.mule.functional.services.TestServicesUtils.buildSchedulerServiceFile)1 MuleArtifactLoaderDescriptorBuilder (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder)1 MulePluginModelBuilder (org.mule.runtime.api.deployment.meta.MulePluginModel.MulePluginModelBuilder)1 MulePolicyModelBuilder (org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder)1 DefaultModuleRepository (org.mule.runtime.container.internal.DefaultModuleRepository)1 ArtifactDescriptorValidatorBuilder (org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptorValidatorBuilder)1 DeploymentListener (org.mule.runtime.module.deployment.api.DeploymentListener)1 TestDeploymentListener (org.mule.runtime.module.deployment.api.TestDeploymentListener)1 MuleArtifactResourcesRegistry (org.mule.runtime.module.deployment.impl.internal.MuleArtifactResourcesRegistry)1 ApplicationFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder)1 ArtifactPluginFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder)1 DomainFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder)1 JarFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder)1 PolicyFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder)1 PolicyTemplateDescriptorFactory (org.mule.runtime.module.deployment.impl.internal.policy.PolicyTemplateDescriptorFactory)1