use of com.hazelcast.internal.config.YamlConfigSchemaValidator in project hazelcast by hazelcast.
the class YamlClientConfigBuilder method parseAndBuildConfig.
private void parseAndBuildConfig(ClientConfig config) throws Exception {
YamlMapping yamlRootNode;
try {
yamlRootNode = ((YamlMapping) YamlLoader.load(in));
} catch (Exception ex) {
throw new InvalidConfigurationException("Invalid YAML configuration", ex);
}
YamlNode clientRoot = yamlRootNode.childAsMapping(ClientConfigSections.HAZELCAST_CLIENT.getName());
if (clientRoot == null) {
clientRoot = yamlRootNode;
}
YamlDomChecker.check(clientRoot);
Node w3cRootNode = asW3cNode(clientRoot);
replaceVariables(w3cRootNode);
importDocuments(clientRoot);
if (shouldValidateTheSchema()) {
new YamlConfigSchemaValidator().validate((YamlMapping) clientRoot.parent());
}
new YamlClientDomConfigProcessor(true, config).buildConfig(w3cRootNode);
}
use of com.hazelcast.internal.config.YamlConfigSchemaValidator in project hazelcast by hazelcast.
the class YamlConfigBuilder method parseAndBuildConfig.
private void parseAndBuildConfig(Config config) throws Exception {
YamlMapping yamlRootNode;
try {
yamlRootNode = ((YamlMapping) YamlLoader.load(in));
} catch (Exception ex) {
throw new InvalidConfigurationException("Invalid YAML configuration", ex);
}
YamlNode imdgRoot = yamlRootNode.childAsMapping(ConfigSections.HAZELCAST.getName());
if (imdgRoot == null) {
imdgRoot = yamlRootNode;
}
YamlDomChecker.check(imdgRoot);
Node w3cRootNode = asW3cNode(imdgRoot);
replaceVariables(w3cRootNode);
importDocuments(imdgRoot);
if (shouldValidateTheSchema()) {
new YamlConfigSchemaValidator().validate((YamlMapping) imdgRoot.parent());
}
new YamlMemberDomConfigProcessor(true, config).buildConfig(w3cRootNode);
}
use of com.hazelcast.internal.config.YamlConfigSchemaValidator in project hazelcast by hazelcast.
the class YamlClientFailoverConfigBuilder method parseAndBuildConfig.
private void parseAndBuildConfig(ClientFailoverConfig config) throws Exception {
YamlMapping yamlRootNode;
try {
yamlRootNode = ((YamlMapping) YamlLoader.load(in));
} catch (Exception ex) {
throw new InvalidConfigurationException("Invalid YAML configuration", ex);
}
String configRoot = getConfigRoot();
YamlNode clientFailoverRoot = yamlRootNode.childAsMapping(configRoot);
if (clientFailoverRoot == null) {
clientFailoverRoot = yamlRootNode;
}
YamlDomChecker.check(clientFailoverRoot);
Node w3cRootNode = asW3cNode(clientFailoverRoot);
replaceVariables(w3cRootNode);
importDocuments(clientFailoverRoot);
if (shouldValidateTheSchema()) {
new YamlConfigSchemaValidator().validate(yamlRootNode);
}
new YamlClientFailoverDomConfigProcessor(true, config).buildConfig(w3cRootNode);
}
use of com.hazelcast.internal.config.YamlConfigSchemaValidator in project hazelcast by hazelcast.
the class YamlConfigSchemaValidatorTest method validationExceptionIsWrapped.
@Test
public void validationExceptionIsWrapped() {
YamlMapping config = (YamlMapping) YamlDomBuilder.build(new HashMap<>());
YamlConfigSchemaValidator validator = new YamlConfigSchemaValidator();
try {
validator.validate(config);
fail("did not throw exception for invalid config");
} catch (SchemaViolationConfigurationException e) {
assertEquals("#", e.getKeywordLocation());
assertEquals("#", e.getInstanceLocation());
assertEquals("exactly one of [hazelcast], [hazelcast-client] and [hazelcast-client-failover] should be present in the" + " root schema document, 0 are present", e.getMessage());
}
}
Aggregations