Search in sources :

Example 1 with ExtensionRegistryLite

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

the class CompatibilityTest method testMessageLiteInterface.

public void testMessageLiteInterface() throws Exception {
    ExtensionRegistryLite registry = ExtensionRegistryLite.newInstance();
    TypicalData data = TypicalData.newBuilder().build();
    MessageLite messageLite = data;
    MessageLite.Builder builderLite = messageLite.newBuilderForType();
    messageLite.writeTo(new ByteArrayOutputStream());
    messageLite.writeDelimitedTo(new ByteArrayOutputStream());
    builderLite.mergeFrom(new ByteArrayInputStream(new byte[0]));
    builderLite.mergeFrom(new ByteArrayInputStream(new byte[0]), registry);
    builderLite.mergeDelimitedFrom(new ByteArrayInputStream(new byte[0]));
    builderLite.mergeDelimitedFrom(new ByteArrayInputStream(new byte[0]), registry);
    assertEquals(0, messageLite.getSerializedSize());
}
Also used : TypicalData(protos.TypicalData) ByteArrayInputStream(java.io.ByteArrayInputStream) ExtensionRegistryLite(com.google.protobuf.ExtensionRegistryLite) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MessageLite(com.google.protobuf.MessageLite)

Example 2 with ExtensionRegistryLite

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

the class CompatibilityTest method testExtensionRegistryGetUnmodifiable.

public void testExtensionRegistryGetUnmodifiable() throws Exception {
    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    ExtensionRegistry registry2 = registry.getUnmodifiable();
    registry.add(Typical.myPrimitiveExtension);
    // Extension added to registry should be visible in registry2.
    Descriptor descriptor = TypicalData.getDescriptor();
    ExtensionRegistry.ExtensionInfo extensionInfo = registry2.findImmutableExtensionByNumber(descriptor, 1001);
    assertNotNull(extensionInfo);
    ExtensionRegistryLite registryLite = ExtensionRegistryLite.newInstance();
    ExtensionRegistryLite registryLite2 = registryLite.getUnmodifiable();
    assertNotNull(registryLite2);
}
Also used : ExtensionRegistryLite(com.google.protobuf.ExtensionRegistryLite) Descriptor(com.google.protobuf.Descriptors.Descriptor) FieldDescriptor(com.google.protobuf.Descriptors.FieldDescriptor) EnumDescriptor(com.google.protobuf.Descriptors.EnumDescriptor) EnumValueDescriptor(com.google.protobuf.Descriptors.EnumValueDescriptor) ExtensionRegistry(com.google.protobuf.ExtensionRegistry)

Aggregations

ExtensionRegistryLite (com.google.protobuf.ExtensionRegistryLite)2 Descriptor (com.google.protobuf.Descriptors.Descriptor)1 EnumDescriptor (com.google.protobuf.Descriptors.EnumDescriptor)1 EnumValueDescriptor (com.google.protobuf.Descriptors.EnumValueDescriptor)1 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)1 ExtensionRegistry (com.google.protobuf.ExtensionRegistry)1 MessageLite (com.google.protobuf.MessageLite)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 TypicalData (protos.TypicalData)1