use of com.yahoo.document.DocumentTypeManager in project vespa by vespa-engine.
the class StringTestCase method testAnnotatorConsumer.
/**
* Test for bug 4066566. No assertions, but works if it runs without exceptions.
*/
@Test
public void testAnnotatorConsumer() {
DocumentTypeManager manager = new DocumentTypeManager();
DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/datatypes/documentmanager.blog.sd");
DocumentType blogType = manager.getDocumentType("blog");
Document doc = new Document(blogType, "doc:blog:http://blogs.sun.com/praveenm");
doc.setFieldValue("url", new StringFieldValue("http://blogs.sun.com/praveenm"));
doc.setFieldValue("title", new StringFieldValue("Beginning JavaFX"));
doc.setFieldValue("author", new StringFieldValue("Praveen Mohan"));
doc.setFieldValue("body", new StringFieldValue("JavaFX can expand its wings across different domains such as manufacturing, logistics, retail, etc. Many companies have adopted it - IBM, Oracle, Yahoo, Honeywell. Even the non-IT industries such as GE, WIPRO, Ford etc. So it is a success for Christopher Oliver and Richard Bair. Scott Mcnealy is happy"));
doc = annotate(doc, manager);
doc = serializeAndDeserialize(doc, manager);
doc = consume(doc, manager);
System.err.println(doc);
}
use of com.yahoo.document.DocumentTypeManager 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.DocumentTypeManager 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));
}
}
use of com.yahoo.document.DocumentTypeManager 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));
}
}
use of com.yahoo.document.DocumentTypeManager in project vespa by vespa-engine.
the class Bug4261985TestCase method testAnnotate.
@Test
public void testAnnotate() {
DocumentTypeManager manager = new DocumentTypeManager();
DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4261985.cfg");
DocumentType type = manager.getDocumentType("blog");
Document doc = new Document(type, "doc:this:is:a:test");
doc.setFieldValue("body", new StringFieldValue("bla bla bla bla bla bla bla" + "bla bla bla bla bla bla bla"));
annotate(doc, manager);
GrowableByteBuffer buf = new GrowableByteBuffer();
doc.serialize(buf);
}
Aggregations