DefaultConfigFactory implements ConfigFactory { ConfigFileFormat determineFileFormat(String namespaceName) { String lowerCase = namespaceName.toLowerCase(); for (ConfigFileFormat format : ConfigFileFormat.values()) { if (lowerCase.endsWith("." + format.getValue())) { return format; } } return ConfigFileFormat.Properties; } DefaultConfigFactory(); @Override Config create(String namespace); @Override ConfigFile createConfigFile(String namespace, ConfigFileFormat configFileFormat);  }
@Test public void testDetermineFileFormat() throws Exception { checkFileFormat("abc", ConfigFileFormat.Properties); checkFileFormat("abc.properties", ConfigFileFormat.Properties); checkFileFormat("abc.pRopErties", ConfigFileFormat.Properties); checkFileFormat("abc.xml", ConfigFileFormat.XML); checkFileFormat("abc.xmL", ConfigFileFormat.XML); checkFileFormat("abc.json", ConfigFileFormat.JSON); checkFileFormat("abc.jsOn", ConfigFileFormat.JSON); checkFileFormat("abc.yaml", ConfigFileFormat.YAML); checkFileFormat("abc.yAml", ConfigFileFormat.YAML); checkFileFormat("abc.yml", ConfigFileFormat.YML); checkFileFormat("abc.yMl", ConfigFileFormat.YML); checkFileFormat("abc.properties.yml", ConfigFileFormat.YML); }