diff options
author | Harald Musum <musum@verizonmedia.com> | 2021-04-23 08:38:39 +0200 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2021-04-23 08:38:39 +0200 |
commit | aee7ff2c99074b5ba90000b91ed73d9465c7b2eb (patch) | |
tree | e064df628607a2791682b8d42eb65f30141abc85 /config-model/src/test/java/com/yahoo/config/model/application/provider/SchemaValidatorTest.java | |
parent | f40237d5bdfe32a7b33df13e426b67b88fd0288a (diff) |
Make sure we are able to output context for validation errors
Diffstat (limited to 'config-model/src/test/java/com/yahoo/config/model/application/provider/SchemaValidatorTest.java')
-rw-r--r-- | config-model/src/test/java/com/yahoo/config/model/application/provider/SchemaValidatorTest.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/config-model/src/test/java/com/yahoo/config/model/application/provider/SchemaValidatorTest.java b/config-model/src/test/java/com/yahoo/config/model/application/provider/SchemaValidatorTest.java index c2938746443..3849e9e03fd 100644 --- a/config-model/src/test/java/com/yahoo/config/model/application/provider/SchemaValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/config/model/application/provider/SchemaValidatorTest.java @@ -2,12 +2,14 @@ package com.yahoo.config.model.application.provider; import com.yahoo.component.Version; +import com.yahoo.io.IOUtils; import com.yahoo.vespa.config.VespaVersion; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.xml.sax.InputSource; +import java.io.File; import java.io.IOException; import java.io.StringReader; @@ -47,15 +49,15 @@ public class SchemaValidatorTest { @Test public void testXMLParse() throws IOException { SchemaValidator validator = createValidator(); - validator.validate(new InputSource(new StringReader(okServices)), "services.xml"); + validator.validate(new StringReader(okServices)); } @Test public void testXMLParseError() throws IOException { SchemaValidator validator = createValidator(); expectedException.expect(RuntimeException.class); - expectedException.expectMessage(expectedErrorMessage("services.xml")); - validator.validate(new InputSource(new StringReader(invalidServices)), "services.xml"); + expectedException.expectMessage(expectedErrorMessage("input")); + validator.validate(new StringReader(invalidServices)); } @Test @@ -72,6 +74,14 @@ public class SchemaValidatorTest { validator.validate(new StringReader(invalidServices)); } + @Test + public void testXMLParseErrorFromFile() throws IOException { + SchemaValidator validator = createValidator(); + expectedException.expect(IllegalArgumentException.class); + expectedException.expectMessage(expectedErrorMessage("services.xml")); + validator.validate(new File("src/test/cfg/application/invalid-services-syntax/services.xml")); + } + private SchemaValidator createValidator() { return new SchemaValidators(new Version(VespaVersion.major)).servicesXmlValidator(); } |