use of com.torodb.standalone.CliConfig in project torodb by torodb.
the class ConfigTest method testParseWithYAML.
@Test
public void testParseWithYAML() throws Exception {
CliConfig cliConfig = new CliConfig() {
@Override
public boolean hasConfFile() {
return true;
}
@Override
public InputStream getConfInputStream() {
return ConfigTest.class.getResourceAsStream("/test-parse-with-yaml.yml");
}
};
Config config = CliConfigUtils.readConfig(cliConfig);
Assert.assertTrue("/generic not defined", config.getGeneric() != null);
Assert.assertTrue("/generic/logPackages not defined", config.getGeneric().getLogPackages() != null);
Assert.assertTrue("/generic/logPackages/com.torodb not defined", config.getGeneric().getLogPackages().get("com.torodb") != null);
Assert.assertEquals("/generic/logLevel has different value than that specified", LogLevel.NONE, config.getGeneric().getLogLevel());
Assert.assertEquals("/generic/logPackages has not 1 entry", 1, config.getGeneric().getLogPackages().size());
Assert.assertEquals("/generic/logPackages/com.torodb has different value than that specified", LogLevel.DEBUG, config.getGeneric().getLogPackages().get("com.torodb"));
Assert.assertTrue("/protocol not defined", config.getProtocol() != null);
Assert.assertTrue("/protocol/mongo not defined", config.getProtocol().getMongo() != null);
Assert.assertTrue("/protocol/mongo/net not defined", config.getProtocol().getMongo().getNet() != null);
Assert.assertTrue("/protocol/mongo/replication not defined", config.getProtocol().getMongo().getReplication() != null);
Assert.assertEquals("/protocol/mongo/net/port has different value than that specified", Integer.valueOf(27019), config.getProtocol().getMongo().getNet().getPort());
Assert.assertEquals("/protocol/mongo/replication has not 1 element", 1, config.getProtocol().getMongo().getReplication().size());
Assert.assertEquals("/protocol/mongo/replication/0/replSetName has different value than that specified", "rs1", config.getProtocol().getMongo().getReplication().get(0).getReplSetName());
Assert.assertEquals("/protocol/mongo/replication/0/role has different value than that specified", Role.HIDDEN_SLAVE, config.getProtocol().getMongo().getReplication().get(0).getRole());
Assert.assertEquals("/protocol/mongo/replication/0/syncSource has different value than that specified", "localhost:27017", config.getProtocol().getMongo().getReplication().get(0).getSyncSource());
Assert.assertTrue("/backend not defined", config.getBackend() != null);
Assert.assertEquals("/backend/postgres not defined", Postgres.class, config.getBackend().getBackendImplementation().getClass());
Assert.assertTrue("/backend/postgres not identified as AbstractPostgres", config.getBackend().is(Postgres.class));
Assert.assertTrue("/backend/postgres not identified as AbstractPostgres Like", config.getBackend().isLike(Postgres.class));
Assert.assertEquals("/backend/postgres/host has different value than that specified", "localhost", config.getBackend().as(Postgres.class).getHost());
Assert.assertEquals("/backend/postgres/port has different value than that specified", Integer.valueOf(5432), config.getBackend().as(Postgres.class).getPort());
Assert.assertEquals("/backend/postgres/user has different value than that specified", "root", config.getBackend().as(Postgres.class).getUser());
Assert.assertEquals("/backend/postgres/password specified but should have not been read from parameters", null, config.getBackend().as(Postgres.class).getPassword());
}
use of com.torodb.standalone.CliConfig in project torodb by torodb.
the class ConfigTest method testParseWithPasswordParam.
@Test(expected = IllegalArgumentException.class)
public void testParseWithPasswordParam() throws Exception {
CliConfig cliConfig = new CliConfig() {
@Override
public List<String> getParams() {
String[] params = new String[] { "/backend/postgres/password=toor" };
return Arrays.asList(params);
}
};
CliConfigUtils.readConfig(cliConfig);
}
use of com.torodb.standalone.CliConfig in project torodb by torodb.
the class ConfigTest method testParseWithYAMLUsingDoubleBackend.
@Test(expected = IllegalArgumentException.class)
public void testParseWithYAMLUsingDoubleBackend() throws Exception {
CliConfig cliConfig = new CliConfig() {
@Override
public boolean hasConfFile() {
return true;
}
@Override
public InputStream getConfInputStream() {
return ConfigTest.class.getResourceAsStream("/test-parse-with-yaml-using-double-backend.yml");
}
};
CliConfigUtils.readConfig(cliConfig);
}
use of com.torodb.standalone.CliConfig in project torodb by torodb.
the class ConfigTest method testParseWithNullParam.
@Test
public void testParseWithNullParam() throws Exception {
CliConfig cliConfig = new CliConfig() {
@Override
public List<String> getParams() {
String[] params = new String[] { "/generic/logFile=null" };
return Arrays.asList(params);
}
};
Config config = CliConfigUtils.readConfig(cliConfig);
Assert.assertEquals("Parameter has different value than that specified", null, config.getGeneric().getLogFile());
}
use of com.torodb.standalone.CliConfig in project torodb by torodb.
the class ConfigTest method testParseWithWrongYAML.
@Test(expected = IllegalArgumentException.class)
public void testParseWithWrongYAML() throws Exception {
CliConfig cliConfig = new CliConfig() {
@Override
public boolean hasConfFile() {
return true;
}
@Override
public InputStream getConfInputStream() {
return ConfigTest.class.getResourceAsStream("/test-parse-with-wrong-yaml.yml");
}
};
CliConfigUtils.readConfig(cliConfig);
}
Aggregations