org.xmlunit.matchers.ValidationMatcher Maven / Gradle / Ivy
/*
This file is licensed to You 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 org.xmlunit.matchers;
import static org.xmlunit.util.Linqy.any;
import static org.xmlunit.util.Linqy.asList;
import static org.xmlunit.util.Linqy.map;
import org.xmlunit.builder.Input;
import org.xmlunit.util.IsNullPredicate;
import org.xmlunit.util.Mapper;
import org.xmlunit.util.Predicate;
import org.xmlunit.validation.JAXPValidator;
import org.xmlunit.validation.Languages;
import org.xmlunit.validation.ValidationProblem;
import org.xmlunit.validation.ValidationResult;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import javax.xml.transform.Source;
import javax.xml.validation.Schema;
import java.util.Arrays;
/**
* Hamcrest Matcher for XML Validation against W3C XML Schema using
* {@link JAXPValidator}.
*/
public class ValidationMatcher extends BaseMatcher {
private final Source[] schemaSource;
private final Schema schema;
private Source instance;
private ValidationResult result;
public ValidationMatcher(Object... schemaSource) {
if (schemaSource == null) {
throw new IllegalArgumentException("schemaSource must not be null");
}
Iterable