Search in sources :

Example 1 with ServiceRegistryDescriptorLoaderRepository

use of org.mule.runtime.module.deployment.impl.internal.artifact.ServiceRegistryDescriptorLoaderRepository in project mule by mulesoft.

the class PropertyOverridesTestCase method testOverrides.

@Test
public void testOverrides() throws Exception {
    File tempProps = File.createTempFile("property", "overrides");
    InputStream input = getClass().getClassLoader().getResourceAsStream("overridden.properties");
    FileOutputStream output = new FileOutputStream(tempProps);
    copy(input, output);
    input.close();
    output.close();
    ApplicationDescriptor descriptor = new ApplicationDescriptor("app");
    ApplicationDescriptorFactory applicationDescriptorFactory = new ApplicationDescriptorFactory(new ArtifactPluginDescriptorLoader(new ArtifactPluginDescriptorFactory()), new ServiceRegistryDescriptorLoaderRepository(new SpiServiceRegistry()), ArtifactDescriptorValidatorBuilder.builder());
    applicationDescriptorFactory.setApplicationProperties(descriptor, tempProps);
    Map<String, String> appProps = descriptor.getAppProperties();
    assertEquals("state", appProps.get("texas"));
    assertEquals("country", appProps.get("peru"));
    assertEquals("austin", appProps.get("texas.capital"));
    assertEquals("4", appProps.get("peru.capital.numberOfletters"));
    assertEquals("runtime", appProps.get("mule"));
    assertEquals("ipaas", appProps.get("mule.ion"));
    try {
        setSystemProperties();
        descriptor = new ApplicationDescriptor("app");
        applicationDescriptorFactory.setApplicationProperties(descriptor, tempProps);
        appProps = descriptor.getAppProperties();
        assertEquals("state", appProps.get("texas"));
        assertEquals("nation", appProps.get("peru"));
        assertEquals("austin", appProps.get("texas.capital"));
        assertEquals("4", appProps.get("peru.capital.numberOfletters"));
        assertEquals("wayCool", appProps.get("mule"));
        assertEquals("ipaas", appProps.get("mule.ion"));
        assertEquals("evenCooler", appProps.get("mule.mmc"));
        descriptor = new ApplicationDescriptor("app");
        applicationDescriptorFactory.setApplicationProperties(descriptor, new File("nonexistent.nonexistent"));
        appProps = descriptor.getAppProperties();
        assertNull(appProps.get("texas"));
        assertEquals("nation", appProps.get("peru"));
        assertNull(appProps.get("texas.capital"));
        assertNull(appProps.get("peru.capital.numberOfletters"));
        assertEquals("wayCool", appProps.get("mule"));
        assertNull(appProps.get("mule.ion"));
        assertEquals("evenCooler", appProps.get("mule.mmc"));
    } finally {
        resetSystemProperties();
    }
}
Also used : InputStream(java.io.InputStream) FileOutputStream(java.io.FileOutputStream) ArtifactPluginDescriptorLoader(org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorLoader) ArtifactPluginDescriptorFactory(org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorFactory) SpiServiceRegistry(org.mule.runtime.core.api.registry.SpiServiceRegistry) File(java.io.File) ApplicationDescriptor(org.mule.runtime.deployment.model.api.application.ApplicationDescriptor) ServiceRegistryDescriptorLoaderRepository(org.mule.runtime.module.deployment.impl.internal.artifact.ServiceRegistryDescriptorLoaderRepository) Test(org.junit.Test)

Aggregations

File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 Test (org.junit.Test)1 SpiServiceRegistry (org.mule.runtime.core.api.registry.SpiServiceRegistry)1 ApplicationDescriptor (org.mule.runtime.deployment.model.api.application.ApplicationDescriptor)1 ServiceRegistryDescriptorLoaderRepository (org.mule.runtime.module.deployment.impl.internal.artifact.ServiceRegistryDescriptorLoaderRepository)1 ArtifactPluginDescriptorFactory (org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorFactory)1 ArtifactPluginDescriptorLoader (org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorLoader)1