use of com.yahoo.document.DocumentTypeManager in project vespa by vespa-engine.
the class VespaXmlUpdateReaderTestCase method readUpdateHelper.
private static DocumentUpdate readUpdateHelper(Field field, String documentXml) throws Exception {
DocumentTypeManager docManager = new DocumentTypeManager();
DocumentType docType = new DocumentType("my_type");
if (field != null) {
docType.addField(field);
}
docManager.register(docType);
InputStream in = new ByteArrayInputStream(documentXml.getBytes(StandardCharsets.UTF_8));
DocumentUpdate doc = new DocumentUpdate(docType, "doc:scheme:");
VespaXMLUpdateReader reader = new VespaXMLUpdateReader(in, docManager);
// initialize reader
reader.reader.next();
reader.read(doc);
return doc;
}
use of com.yahoo.document.DocumentTypeManager in project vespa by vespa-engine.
the class JsonWriterTestCase method setUp.
@Before
public void setUp() throws Exception {
types = new DocumentTypeManager();
registerAllTestDocumentTypes();
}
use of com.yahoo.document.DocumentTypeManager in project vespa by vespa-engine.
the class SystemTestCase method setUp.
public void setUp() {
manager = new DocumentTypeManager();
DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.systemtest.cfg");
}
use of com.yahoo.document.DocumentTypeManager in project vespa by vespa-engine.
the class MapTestCase method assertCorrectSerialization.
private void assertCorrectSerialization(MapDataType mapType, MapFieldValue<? extends FieldValue, ? extends FieldValue> map) {
Field f = new Field("", mapType);
DocumentTypeManager man = new DocumentTypeManager();
man.register(mapType);
GrowableByteBuffer buffer = new GrowableByteBuffer(1024);
DocumentSerializer serializer = DocumentSerializerFactory.create42(buffer);
serializer.write(f, map);
buffer.flip();
DocumentDeserializer deserializer = DocumentDeserializerFactory.create42(man, buffer);
MapFieldValue<FieldValue, FieldValue> map2 = new MapFieldValue<FieldValue, FieldValue>(mapType);
deserializer.read(f, map2);
assertNotSame(map, map2);
for (Map.Entry<?, ?> e : map.entrySet()) {
assertEquals(e.getValue(), map2.get(e.getKey()));
}
}
use of com.yahoo.document.DocumentTypeManager in project vespa by vespa-engine.
the class Bug4475379TestCase method testClone.
@Test
public void testClone() {
DocumentTypeManager manager = new DocumentTypeManager();
DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4475379.cfg");
DocumentType type = manager.getDocumentType("blog");
Document doc = new Document(type, "doc:this:is:a:test");
doc.setFieldValue("body", new StringFieldValue(""));
annotate(manager, doc);
Document anotherDoc = doc.clone();
assertThat(doc, equalTo(anotherDoc));
}
Aggregations