SuperX-Kernmodul
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

40 lines
1.9 KiB

package de.superx.conf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.File;
import org.junit.Test;
import de.superx.conf.ApplicationConfig.Key;
@SuppressWarnings("static-method")
public class ApplicationConfigTest {
@Test
public void applicationConfigHealthCheckAvailable() {
ApplicationConfig.readApplicationProperties();
String val = ApplicationConfig.get(Key.init_health_check);
assertNotNull("Key for healthcheck available", val);
}
@Test
public void customPropertiesOverwrite() {
File applicationPropertiesFile = new File(String.join(File.separator, ".", "test", "resources", "application_config", "application.properties"));
File customApplicationPropertiesFile = new File(String.join(File.separator, ".", "test", "resources", "application_config", "application_custom.properties"));
ApplicationConfig.readApplicationProperties(applicationPropertiesFile, customApplicationPropertiesFile);
Boolean val = (Boolean) ApplicationConfig.getWithType(Key.init_health_check);
assertEquals("Config property is overwritten", Boolean.FALSE, val);
}
@Test
public void wrongKeyIsDiscarded() {
File applicationPropertiesFile = new File(String.join(File.separator, "test", "resources", "application_config", "application.properties"));
File customApplicationPropertiesFile = new File(String.join(File.separator, "test", "resources", "application_config", "application_custom_wrong_type.properties"));
ApplicationConfig.readApplicationProperties(applicationPropertiesFile, customApplicationPropertiesFile);
Boolean val = (Boolean) ApplicationConfig.getWithType(Key.init_health_check);
assertEquals("Wrong type is discarded", Boolean.TRUE, val);
assertEquals("Wrong key is discarded", 2, ApplicationConfig.getKeyCount());
}
}