blob: 2921f63a78e4be4a1c0ce2769bad055690506726 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.model.builder.xml;
import org.junit.jupiter.api.Test;
import org.xml.sax.InputSource;
import java.io.FileReader;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author hmusum
*/
public class XmlErrorHandlingTest {
@Test
void requireExceptionWithSourceAndFilenameAndLineNumber() {
try {
XmlHelper.getDocument(new FileReader("src/test/cfg/application/invalid-services-syntax/services.xml"), "services.xml");
} catch (Exception e) {
assertEquals("Invalid XML in services.xml: The element type \"config\" must be terminated by the matching end-tag \"</config>\". [7:5]",
e.getMessage());
}
}
@Test
void requireExceptionWithLineNumber() {
try {
XmlHelper.getDocumentBuilder().parse(
new InputSource(new FileReader("src/test/cfg/application/invalid-services-syntax/services.xml")));
} catch (Exception e) {
assertEquals("Invalid XML (unknown source): The element type \"config\" must be terminated by the matching end-tag \"</config>\". [7:5]",
e.getMessage());
}
}
}
|