Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ protected Map<String, Properties> getMessagePropertyResourcesFromClasspath() {
for (Resource resource : coreResources) {
Properties properties = new Properties();
OpenmrsUtil.loadProperties(properties, resource.getInputStream());
ret.put(resource.getURI().toString(), properties);
log.trace("Added " + properties.size() + " from " + resource.getURI().toString());
ret.put(resource.getURL().toString(), properties);
log.trace("Added " + properties.size() + " from " + resource.getURL().toString());
}

// Load modules in their startup order, so these can overwrite each other where appropriate
Expand All @@ -244,11 +244,11 @@ protected Map<String, Properties> getMessagePropertyResourcesFromClasspath() {
for (Resource resource : moduleResources) {
// Module classpath entries contain other modules and core version libraries.
// We need to limit the resources processed to just those defined by this specific module
if (resource.getURI().toString().contains("/" + module.getModuleId() + "/")) {
if (resource.getURL().toString().replace('\\', '/').contains("/" + module.getModuleId() + "/")) {
Properties properties = new Properties();
OpenmrsUtil.loadProperties(properties, resource.getInputStream());
ret.put("classpath:" + resource.getURI().toString(), properties);
log.trace("Added " + properties.size() + " from " + resource.getURI().toString());
ret.put("classpath:" + resource.getURL().toString(), properties);
log.trace("Added " + properties.size() + " from " + resource.getURL().toString());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Locale;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

public class InitializerMessageSourceTest {

Expand Down Expand Up @@ -51,4 +57,19 @@ public void getLocaleFromFileBaseName_shouldAllowUnderscoresInDirectory() {
Locale.setDefault(Locale.US);
assertEquals(Locale.ENGLISH, src.getLocaleFromFileBaseName("/tmp/test_dir/basename"));
}

@Test
public void getURI_shouldFailOnWindowsJarUrlResource() throws IOException {
Resource jarResource = new UrlResource("jar:file:C:\\Users\\test\\.m2\\repository\\module.jar!/messages.properties");
IOException ex = assertThrows(IOException.class, jarResource::getURI);
assertTrue(ex.getCause() instanceof URISyntaxException);
}

@Test
public void getURL_shouldSucceedOnWindowsJarUrlResource() throws IOException {
Resource jarResource = new UrlResource(
"jar:file:C:\\Users\\test\\.m2\\repository\\module.jar!/messages_fr.properties");
String urlString = jarResource.getURL().toString();
assertEquals("jar:file:C:\\Users\\test\\.m2\\repository\\module.jar!/messages_fr.properties", urlString);
}
}