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