Search in sources :

Example 6 with DocumentTypeManager

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;
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentType(com.yahoo.document.DocumentType)

Example 7 with DocumentTypeManager

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();
}
Also used : DocumentTypeManager(com.yahoo.document.DocumentTypeManager) Before(org.junit.Before)

Example 8 with DocumentTypeManager

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");
}
Also used : DocumentTypeManager(com.yahoo.document.DocumentTypeManager)

Example 9 with DocumentTypeManager

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()));
    }
}
Also used : Field(com.yahoo.document.Field) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) GrowableByteBuffer(com.yahoo.io.GrowableByteBuffer) Map(java.util.Map)

Example 10 with DocumentTypeManager

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));
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentType(com.yahoo.document.DocumentType) Document(com.yahoo.document.Document) Test(org.junit.Test)

Aggregations

DocumentTypeManager (com.yahoo.document.DocumentTypeManager)35 Test (org.junit.Test)18 DocumentType (com.yahoo.document.DocumentType)17 Document (com.yahoo.document.Document)12 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)7 Field (com.yahoo.document.Field)6 ByteArrayInputStream (java.io.ByteArrayInputStream)6 DeserializationException (com.yahoo.document.serialization.DeserializationException)5 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)5 DocumentPut (com.yahoo.document.DocumentPut)4 IlscriptsConfig (com.yahoo.vespa.configdefinition.IlscriptsConfig)4 StructDataType (com.yahoo.document.StructDataType)3 Before (org.junit.Before)3 DocumentUpdate (com.yahoo.document.DocumentUpdate)2 DocumentmanagerConfig (com.yahoo.document.config.DocumentmanagerConfig)2 Array (com.yahoo.document.datatypes.Array)2 DocumentProtocol (com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)2 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)2 RPCNetworkParams (com.yahoo.messagebus.network.rpc.RPCNetworkParams)2 TestServer (com.yahoo.messagebus.network.rpc.test.TestServer)2