Search in sources :

Example 1 with SchemaViolationConfigurationException

use of com.hazelcast.internal.config.SchemaViolationConfigurationException in project hazelcast by hazelcast.

the class YamlRootAdditionalPropertiesTest method multipleMisIndented_configProps.

@Test
public void multipleMisIndented_configProps() {
    SchemaViolationConfigurationException actual = assertThrows(SchemaViolationConfigurationException.class, () -> YamlClientConfigBuilderTest.buildConfig("hazelcast-client: {}\n" + "instance-name: 'my-instance'\n" + "client-labels: 'my-lbl'\n"));
    assertEquals(new SchemaViolationConfigurationException(format("2 schema violations found%n" + "Note: you can disable this validation by passing the " + "-Dhazelcast.yaml.config.indentation.check.enabled=false system property"), "#", "#", asList(new SchemaViolationConfigurationException("Mis-indented hazelcast configuration property found: [instance-name]", "#", "#", emptyList()), new SchemaViolationConfigurationException("Mis-indented hazelcast configuration property found: [client-labels]", "#", "#", emptyList()))), actual);
}
Also used : SchemaViolationConfigurationException(com.hazelcast.internal.config.SchemaViolationConfigurationException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) YamlClientConfigBuilderTest(com.hazelcast.client.config.YamlClientConfigBuilderTest)

Example 2 with SchemaViolationConfigurationException

use of com.hazelcast.internal.config.SchemaViolationConfigurationException 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());
    }
}
Also used : YamlConfigSchemaValidator(com.hazelcast.internal.config.YamlConfigSchemaValidator) HashMap(java.util.HashMap) SchemaViolationConfigurationException(com.hazelcast.internal.config.SchemaViolationConfigurationException) YamlMapping(com.hazelcast.internal.yaml.YamlMapping) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with SchemaViolationConfigurationException

use of com.hazelcast.internal.config.SchemaViolationConfigurationException in project hazelcast by hazelcast.

the class YamlRootAdditionalPropertiesTest method testMisIndentedMemberConfigProperty_failsValidation.

@Test
public void testMisIndentedMemberConfigProperty_failsValidation() {
    SchemaViolationConfigurationException actual = assertThrows(SchemaViolationConfigurationException.class, () -> buildConfig("hazelcast:\n" + "  instance-name: 'my-instance'\n" + "cluster-name: 'my-cluster'\n"));
    assertEquals(format("Mis-indented hazelcast configuration property found: [cluster-name]%n" + "Note: you can disable this validation by passing the " + "-Dhazelcast.yaml.config.indentation.check.enabled=false system property"), actual.getMessage());
}
Also used : SchemaViolationConfigurationException(com.hazelcast.internal.config.SchemaViolationConfigurationException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) YamlClientConfigBuilderTest(com.hazelcast.client.config.YamlClientConfigBuilderTest)

Example 4 with SchemaViolationConfigurationException

use of com.hazelcast.internal.config.SchemaViolationConfigurationException in project hazelcast by hazelcast.

the class YamlRootAdditionalPropertiesTest method testMisIndented_ClientConfigProperty_failsValidation.

@Test
public void testMisIndented_ClientConfigProperty_failsValidation() {
    SchemaViolationConfigurationException actual = assertThrows(SchemaViolationConfigurationException.class, () -> YamlClientConfigBuilderTest.buildConfig("hazelcast-client:\n" + "  instance-name: 'my-instance'\n" + "client-labels: 'my-lbl'\n"));
    assertEquals(format("Mis-indented hazelcast configuration property found: [client-labels]%n" + "Note: you can disable this validation by passing the " + "-Dhazelcast.yaml.config.indentation.check.enabled=false system property"), actual.getMessage());
}
Also used : SchemaViolationConfigurationException(com.hazelcast.internal.config.SchemaViolationConfigurationException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) YamlClientConfigBuilderTest(com.hazelcast.client.config.YamlClientConfigBuilderTest)

Aggregations

SchemaViolationConfigurationException (com.hazelcast.internal.config.SchemaViolationConfigurationException)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 YamlClientConfigBuilderTest (com.hazelcast.client.config.YamlClientConfigBuilderTest)3 YamlConfigSchemaValidator (com.hazelcast.internal.config.YamlConfigSchemaValidator)1 YamlMapping (com.hazelcast.internal.yaml.YamlMapping)1 HashMap (java.util.HashMap)1