Search in sources :

Example 6 with ExtensionRegistry

use of com.google.protobuf.ExtensionRegistry in project j2objc by google.

the class EnumsTest method testMergeFromInputStream.

public void testMergeFromInputStream() throws Exception {
    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    EnumFields.registerAllExtensions(registry);
    ByteArrayInputStream in = new ByteArrayInputStream(ALL_ENUMS_BYTES);
    EnumMsg.Builder builder = EnumMsg.newBuilder().mergeFrom(in, registry);
    EnumMsg msg = builder.build();
    checkFields(builder);
    checkFields(msg);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) EnumMsg(protos.EnumMsg) ExtensionRegistry(com.google.protobuf.ExtensionRegistry)

Example 7 with ExtensionRegistry

use of com.google.protobuf.ExtensionRegistry in project j2objc by google.

the class EnumsTest method testParseFromByteArray.

public void testParseFromByteArray() throws Exception {
    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    EnumFields.registerAllExtensions(registry);
    EnumMsg msg = EnumMsg.parseFrom(ALL_ENUMS_BYTES, registry);
    checkFields(msg);
}
Also used : EnumMsg(protos.EnumMsg) ExtensionRegistry(com.google.protobuf.ExtensionRegistry)

Example 8 with ExtensionRegistry

use of com.google.protobuf.ExtensionRegistry in project j2objc by google.

the class MessagesTest method testMergeFromInputStream.

public void testMergeFromInputStream() throws Exception {
    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    MessageFields.registerAllExtensions(registry);
    ByteArrayInputStream in = new ByteArrayInputStream(ALL_MESSAGES_BYTES);
    MessageData.Builder builder = MessageData.newBuilder().mergeFrom(in, registry);
    MessageData msg = builder.build();
    checkFields(builder);
    checkFields(msg);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) MessageData(protos.MessageData) ExtensionRegistry(com.google.protobuf.ExtensionRegistry)

Example 9 with ExtensionRegistry

use of com.google.protobuf.ExtensionRegistry in project j2objc by google.

the class MessagesTest method testParseReversedMessageSets.

public void testParseReversedMessageSets() throws Exception {
    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    MessageFields.registerAllExtensions(registry);
    MessageData msg = MessageData.parseFrom(ALL_MESSAGES_WITH_MESSAGE_SETS_REVERSED_BYTES, registry);
    checkFields(msg);
}
Also used : MessageData(protos.MessageData) ExtensionRegistry(com.google.protobuf.ExtensionRegistry)

Example 10 with ExtensionRegistry

use of com.google.protobuf.ExtensionRegistry in project j2objc by google.

the class PerformanceBenchmarks method testMergeFrom.

private static void testMergeFrom() throws Exception {
    ByteArrayInputStream in = new ByteArrayInputStream(PROTO_DATA);
    ExtensionRegistry registry = ExtensionRegistry.getEmptyRegistry();
    for (int i = 0; i < 30000; i++) {
        TypicalData.newBuilder().mergeFrom(in, registry);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ExtensionRegistry(com.google.protobuf.ExtensionRegistry)

Aggregations

ExtensionRegistry (com.google.protobuf.ExtensionRegistry)25 ByteArrayInputStream (java.io.ByteArrayInputStream)9 Descriptor (com.google.protobuf.Descriptors.Descriptor)4 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)4 MessageData (protos.MessageData)4 EnumDescriptor (com.google.protobuf.Descriptors.EnumDescriptor)3 EnumValueDescriptor (com.google.protobuf.Descriptors.EnumValueDescriptor)3 EnumMsg (protos.EnumMsg)3 Test (org.junit.Test)2 PrimitiveFields (protos.PrimitiveFields)2 StringMsg (protos.StringMsg)2 TypicalData (protos.TypicalData)2 TypicalDataMessage (protos.TypicalDataMessage)2 ByteString (com.google.protobuf.ByteString)1 CodedInputStream (com.google.protobuf.CodedInputStream)1 GenericDescriptor (com.google.protobuf.Descriptors.GenericDescriptor)1 ExtensionRegistryLite (com.google.protobuf.ExtensionRegistryLite)1 GeneratedMessage (com.google.protobuf.GeneratedMessage)1 Message (com.google.protobuf.Message)1 Base (com.groupon.jesos.TestProtos.Base)1