forked from phoedos/pmd
[core] Make sure, a language with empty version selects the default version
This commit is contained in:
@ -14,6 +14,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Created by christoferdutz on 20.09.14.
|
||||
*/
|
||||
@ -90,7 +92,7 @@ public final class LanguageRegistry {
|
||||
String version;
|
||||
String terseName;
|
||||
if (terseNameAndVersion.contains(" ")) {
|
||||
version = terseNameAndVersion.substring(terseNameAndVersion.lastIndexOf(' ') + 1);
|
||||
version = StringUtils.trimToNull(terseNameAndVersion.substring(terseNameAndVersion.lastIndexOf(' ') + 1));
|
||||
terseName = terseNameAndVersion.substring(0, terseNameAndVersion.lastIndexOf(' '));
|
||||
} else {
|
||||
version = null;
|
||||
|
@ -17,4 +17,17 @@ public class LanguageRegistryTest {
|
||||
// available language now -> DummyLanguage
|
||||
Assert.assertSame(DummyLanguageModule.class, defaultLanguage.getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDefaultVersionLanguageTest() {
|
||||
LanguageVersion dummy12 = LanguageRegistry.findLanguageVersionByTerseName("dummy 1.2");
|
||||
Assert.assertNotNull(dummy12);
|
||||
|
||||
Language dummy = LanguageRegistry.findLanguageByTerseName("dummy");
|
||||
LanguageVersion dummyDefault = dummy.getDefaultVersion();
|
||||
|
||||
LanguageVersion dummyDefault2 = LanguageRegistry.findLanguageVersionByTerseName("dummy ");
|
||||
Assert.assertNotNull(dummyDefault2);
|
||||
Assert.assertSame(dummyDefault, dummyDefault2);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user