forked from External/mage
[app-wiring-refactor]: Define external configuration
This commit is contained in:
parent
e3733dfae7
commit
cf3dd2d94c
14 changed files with 1083 additions and 2 deletions
|
|
@ -0,0 +1,34 @@
|
|||
package mage.server.util;
|
||||
|
||||
import mage.server.util.config.Config;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
public class ConfigFactoryTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("should unmarshal configuration from file")
|
||||
void loadConfig() {
|
||||
final Config config = ConfigFactory.loadFromFile("config/config.xml");
|
||||
|
||||
assertThat(config.getServer().getServerName()).isEqualTo("mage-server");
|
||||
assertThat(config.getServer().getPort()).isEqualTo(17171);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("should fail if config is malformed")
|
||||
void failOnMalformed() {
|
||||
assertThatExceptionOfType(ConfigurationException.class)
|
||||
.isThrownBy(() -> ConfigFactory.loadFromFile("config/config_error.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("should fail if file does not exist")
|
||||
void failOnNotFound() {
|
||||
assertThatExceptionOfType(ConfigurationException.class)
|
||||
.isThrownBy(() -> ConfigFactory.loadFromFile("does not exist"));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue