hazelcast-master/hazelcast/src/test/java/com/hazelcast/config/SchemaValidationSkippingTest.java
/*
 * Copyright (c) 2008-2023, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hazelcast.config;

import com.hazelcast.client.config.XmlClientConfigBuilderTest;
import com.hazelcast.client.config.XmlClientFailoverConfigBuilderTest;
import com.hazelcast.client.config.YamlClientConfigBuilderTest;
import com.hazelcast.client.config.YamlClientFailoverConfigBuilderTest;
import com.hazelcast.test.HazelcastSerialClassRunner;
import com.hazelcast.test.OverridePropertyRule;
import com.hazelcast.test.annotation.QuickTest;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

import static com.hazelcast.client.config.XmlClientFailoverConfigBuilderTest.HAZELCAST_CLIENT_FAILOVER_END_TAG;
import static com.hazelcast.client.config.XmlClientFailoverConfigBuilderTest.HAZELCAST_CLIENT_FAILOVER_START_TAG;
import static com.hazelcast.config.ConfigRecognizerTest.HAZELCAST_CLIENT_END_TAG;
import static com.hazelcast.config.ConfigRecognizerTest.HAZELCAST_CLIENT_START_TAG;
import static com.hazelcast.config.XMLConfigBuilderTest.HAZELCAST_END_TAG;
import static com.hazelcast.config.XMLConfigBuilderTest.HAZELCAST_START_TAG;

@RunWith(HazelcastSerialClassRunner.class)
@Category(QuickTest.class)
public class SchemaValidationSkippingTest {

    public static final String INVALID_YAML = "invalid: yes";
    @Rule
    public OverridePropertyRule setProp = OverridePropertyRule.set("hazelcast.config.schema.validation.enabled", "false");

    @Test
    public void testSkipping_Member_Yaml_SchemaValidation() {
        YamlConfigBuilderTest.buildConfig(INVALID_YAML);
    }

    @Test
    public void testSkipping_Member_Xml_SchemaValidation() {
        XMLConfigBuilderTest.buildConfig(HAZELCAST_START_TAG + "<invalid></invalid>" + HAZELCAST_END_TAG);
    }

    @Test
    public void testSkipping_ClientFailover_Xml_SchemaValidation() {
        XmlClientFailoverConfigBuilderTest.buildConfig(HAZELCAST_CLIENT_FAILOVER_START_TAG
                + "<invalid/>"
                + HAZELCAST_CLIENT_FAILOVER_END_TAG);
    }

    @Test
    public void testSkipping_ClientFailover_Yaml_SchemaValidation() {
        YamlClientFailoverConfigBuilderTest.buildConfig(INVALID_YAML);
    }

    @Test
    public void testSkipping_Client_Xml_SchemaValidation() {
        XmlClientConfigBuilderTest.buildConfig(HAZELCAST_CLIENT_START_TAG + "<invalid />" + HAZELCAST_CLIENT_END_TAG);
    }

    @Test
    public void testSkipping_Client_Yaml_SchemaValidation() {
        YamlClientConfigBuilderTest.buildConfig(INVALID_YAML);
    }
}
