use of com.yahoo.document.serialization.DeserializationException in project vespa by vespa-engine.
the class XMLNumericFieldErrorMsgTestCase method requireDescriptiveErrorMsgForIntegers.
@Test
public void requireDescriptiveErrorMsgForIntegers() throws Exception {
DocumentTypeManager dtm = setupTypes();
try {
VespaXMLDocumentReader documentReader = new VespaXMLDocumentReader(new ByteArrayInputStream(("<document id=\"doc:foo:bar\" type=\"doctype\">" + " <intfield></intfield>" + "</document>").getBytes(StandardCharsets.UTF_8)), dtm);
new Document(documentReader);
fail("Sorry mac");
} catch (DeserializationException e) {
assertThat(e.getMessage(), e.getMessage().contains("Field 'intfield': Invalid integer \"\""), is(true));
}
}
use of com.yahoo.document.serialization.DeserializationException in project vespa by vespa-engine.
the class XMLNumericFieldErrorMsgTestCase method requireDescriptiveErrorMsgForFloats.
@Test
public void requireDescriptiveErrorMsgForFloats() throws Exception {
DocumentTypeManager dtm = setupTypes();
try {
VespaXMLDocumentReader documentReader = new VespaXMLDocumentReader(new ByteArrayInputStream(("<document id=\"doc:foo:bar\" type=\"doctype\">" + " <floatfield></floatfield>" + "</document>").getBytes(StandardCharsets.UTF_8)), dtm);
new Document(documentReader);
fail("Sorry mac");
} catch (DeserializationException e) {
assertThat(e.getMessage(), e.getMessage().contains("Field 'floatfield': Invalid float \"\""), is(true));
}
}
use of com.yahoo.document.serialization.DeserializationException in project vespa by vespa-engine.
the class VespaXmlFieldReaderTestCase method assertThrows.
private static void assertThrows(Field field, String fieldXml, String expected) throws Exception {
DocumentTypeManager docManager = new DocumentTypeManager();
DocumentType docType = new DocumentType("my_type");
docType.addField(field);
docManager.register(docType);
String documentXml = "<document id='doc:scheme:' type='my_type'><" + field.getName() + ">" + fieldXml + "</" + field.getName() + "></document>";
InputStream in = new ByteArrayInputStream(documentXml.getBytes(StandardCharsets.UTF_8));
Document doc = new Document(docType, "doc:scheme:");
try {
new VespaXMLFieldReader(in, docManager).read(null, doc);
fail();
} catch (DeserializationException e) {
assertEquals(expected, e.getMessage());
}
}
use of com.yahoo.document.serialization.DeserializationException in project vespa by vespa-engine.
the class XMLNumericFieldErrorMsgTestCase method requireDescriptiveErrorMsgForBytes.
@Test
public void requireDescriptiveErrorMsgForBytes() throws Exception {
DocumentTypeManager dtm = setupTypes();
try {
VespaXMLDocumentReader documentReader = new VespaXMLDocumentReader(new ByteArrayInputStream(("<document id=\"doc:foo:bar\" type=\"doctype\">" + " <bytefield></bytefield>" + "</document>").getBytes(StandardCharsets.UTF_8)), dtm);
new Document(documentReader);
fail("Sorry mac");
} catch (DeserializationException e) {
assertThat(e.getMessage(), e.getMessage().contains("Field 'bytefield': Invalid byte \"\""), is(true));
}
}
use of com.yahoo.document.serialization.DeserializationException in project vespa by vespa-engine.
the class XMLNumericFieldErrorMsgTestCase method requireDescriptiveErrorMsgForDoubles.
@Test
public void requireDescriptiveErrorMsgForDoubles() throws Exception {
DocumentTypeManager dtm = setupTypes();
try {
VespaXMLDocumentReader documentReader = new VespaXMLDocumentReader(new ByteArrayInputStream(("<document id=\"doc:foo:bar\" type=\"doctype\">" + " <doublefield></doublefield>" + "</document>").getBytes(StandardCharsets.UTF_8)), dtm);
new Document(documentReader);
fail("Sorry mac");
} catch (DeserializationException e) {
assertThat(e.getMessage(), e.getMessage().contains("Field 'doublefield': Invalid double \"\""), is(true));
}
}
Aggregations