@Override
	public PropertySource<?> locate(Environment environment) {
		if (polarisConfigProperties.isEnabled()) {
			CompositePropertySource compositePropertySource = new CompositePropertySource(POLARIS_CONFIG_PROPERTY_SOURCE_NAME);
			try {
				// load custom config extension files
				initCustomPolarisConfigExtensionFiles(compositePropertySource);
				// load spring boot default config files
				initInternalConfigFiles(compositePropertySource);
				// load custom config files
				List<ConfigFileGroup> configFileGroups = polarisConfigProperties.getGroups();
				if (CollectionUtils.isEmpty(configFileGroups)) {
					return compositePropertySource;
				}
				initCustomPolarisConfigFiles(compositePropertySource, configFileGroups);
				return compositePropertySource;
			}
			finally {
				afterLocatePolarisConfigExtension(compositePropertySource);
			}
		}
		return null;
	}
@Test
	public void testLoadApplicationPropertiesFile() {
		PolarisConfigFileLocator locator = new PolarisConfigFileLocator(polarisConfigProperties, polarisContextProperties,
				configFileService, environment);

		when(polarisContextProperties.getNamespace()).thenReturn(testNamespace);
		when(polarisContextProperties.getService()).thenReturn(testServiceName);

		// application.properties
		Map<String, Object> applicationProperties = new HashMap<>();
		applicationProperties.put("k1", "v1");
		applicationProperties.put("k2", "v2");
		applicationProperties.put("k3", "v3");
		ConfigKVFile propertiesFile = new MockedConfigKVFile(applicationProperties);
		when(configFileService.getConfigPropertiesFile(testNamespace, testServiceName, "application.properties"))
				.thenReturn(propertiesFile);

		Map<String, Object> emptyMap = new HashMap<>();
		ConfigKVFile emptyConfigFile = new MockedConfigKVFile(emptyMap);
		when(configFileService.getConfigYamlFile(testNamespace, testServiceName, "application.yml")).thenReturn(emptyConfigFile);
		when(configFileService.getConfigYamlFile(testNamespace, testServiceName, "application.yaml")).thenReturn(emptyConfigFile);
		when(configFileService.getConfigPropertiesFile(testNamespace, testServiceName, "bootstrap.properties")).thenReturn(emptyConfigFile);
		when(configFileService.getConfigYamlFile(testNamespace, testServiceName, "bootstrap.yml")).thenReturn(emptyConfigFile);
		when(configFileService.getConfigYamlFile(testNamespace, testServiceName, "bootstrap.yaml")).thenReturn(emptyConfigFile);

		when(polarisConfigProperties.isEnabled()).thenReturn(true);
		when(polarisConfigProperties.getGroups()).thenReturn(null);
		when(polarisConfigProperties.isInternalEnabled()).thenReturn(true);
		when(environment.getActiveProfiles()).thenReturn(new String[] {});

		PropertySource<?> propertySource = locator.locate(environment);

		assertThat(propertySource.getProperty("k1")).isEqualTo("v1");
		assertThat(propertySource.getProperty("k2")).isEqualTo("v2");
		assertThat(propertySource.getProperty("k3")).isEqualTo("v3");
	}