Search in sources :

Example 6 with DeserializationException

use of com.yahoo.document.serialization.DeserializationException in project vespa by vespa-engine.

the class XMLNumericFieldErrorMsgTestCase method requireDescriptiveErrorMsgForLongs.

@Test
public void requireDescriptiveErrorMsgForLongs() throws Exception {
    DocumentTypeManager dtm = setupTypes();
    try {
        VespaXMLDocumentReader documentReader = new VespaXMLDocumentReader(new ByteArrayInputStream(("<document id=\"doc:foo:bar\" type=\"doctype\">" + "  <longfield></longfield>" + "</document>").getBytes(StandardCharsets.UTF_8)), dtm);
        new Document(documentReader);
        fail("Sorry mac");
    } catch (DeserializationException e) {
        assertThat(e.getMessage(), e.getMessage().contains("Field 'longfield': Invalid long \"\""), is(true));
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) Document(com.yahoo.document.Document) DeserializationException(com.yahoo.document.serialization.DeserializationException) Test(org.junit.Test)

Aggregations

DeserializationException (com.yahoo.document.serialization.DeserializationException)6 ByteArrayInputStream (java.io.ByteArrayInputStream)6 Document (com.yahoo.document.Document)5 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)5 Test (org.junit.Test)5 InputStream (java.io.InputStream)1