Skip to content

Commit

Permalink
Write test for catalog extension (see #204)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelozerr committed Dec 5, 2018
1 parent f4d6d4a commit 57cfba0
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.eclipse.lsp4xml.extensions.catalog;

import static org.eclipse.lsp4xml.XMLAssert.c;
import static org.eclipse.lsp4xml.XMLAssert.d;

import org.eclipse.lsp4xml.XMLAssert;
import org.eclipse.lsp4xml.commons.BadLocationException;
import org.eclipse.lsp4xml.extensions.contentmodel.participants.XMLSchemaErrorCode;
import org.junit.Test;

/**
* Test of catalog completion/validation which doesn't declare DTD or XML
* Schema.
*
*/
public class XMLCatalogExtensionTest {

@Test
public void completion() throws BadLocationException {
String xml = "<?xml version=\"1.0\"?>\r\n" + //
"<catalog xmlns=\"urn:oasis:names:tc:entity:xmlns:xml:catalog\">\r\n" + //
" |";

XMLAssert.testCompletionFor(xml, 16, c("public", "<public publicId=\"\" uri=\"\" />"));
}

@Test
public void diagnostics() throws BadLocationException {
String xml = "<?xml version=\"1.0\"?>\r\n" + //
"<catalog xmlns=\"urn:oasis:names:tc:entity:xmlns:xml:catalog\">\r\n" + //
" <bad /> // error validation, because \"bad\" doesn't belong to the XML Schema catalog\r\n" + //
"</catalog> ";

XMLAssert.testDiagnosticsFor(xml, d(2, 5, 8, XMLSchemaErrorCode.cvc_complex_type_2_4_a), //
d(2, 12, 14, XMLSchemaErrorCode.cvc_complex_type_2_3));
}
}

0 comments on commit 57cfba0

Please sign in to comment.