2016-11-25 15:42:29 +01:00
|
|
|
package test.container;
|
|
|
|
|
2022-03-17 17:17:15 +01:00
|
|
|
import java.io.StringWriter;
|
2016-11-25 15:42:29 +01:00
|
|
|
|
|
|
|
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
2022-03-17 17:17:15 +01:00
|
|
|
import org.ini4j.Ini;
|
|
|
|
import org.ini4j.Profile.Section;
|
2016-11-25 15:42:29 +01:00
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
public class ConfigurationTest {
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void containerConfigurationBinds() throws Exception {
|
|
|
|
|
2022-03-17 17:17:15 +01:00
|
|
|
ContainerConfiguration bound = ContainerConfiguration
|
|
|
|
.load(ConfigurationTest.class.getResourceAsStream("/test-configuration.ini"));
|
|
|
|
|
2016-11-25 15:42:29 +01:00
|
|
|
bound.validate();
|
2022-03-17 17:17:15 +01:00
|
|
|
|
2016-11-25 15:42:29 +01:00
|
|
|
}
|
|
|
|
|
2022-03-17 17:17:15 +01:00
|
|
|
@Test
|
|
|
|
public void iniStore() throws Exception {
|
|
|
|
Ini ini = new Ini();
|
|
|
|
|
|
|
|
// lets add a section, it will create needed intermediate sections as well
|
|
|
|
ini.add("root/child/sub");
|
|
|
|
|
|
|
|
Section rsec = ini.get("root");
|
|
|
|
rsec.add("test", "team");
|
|
|
|
Section csec = rsec.getChild("child");
|
|
|
|
csec.add("testchild", "pappo");
|
|
|
|
Section ssec = csec.getChild("sub");
|
|
|
|
ssec.add("testSec", "pippo");
|
|
|
|
|
|
|
|
StringWriter sw = new StringWriter();
|
|
|
|
ini.store(sw);
|
2022-03-21 11:17:07 +01:00
|
|
|
|
2016-11-25 15:42:29 +01:00
|
|
|
}
|
|
|
|
}
|