private static void recursivelyAddDescriptors(
      Descriptor message, Set<Descriptor> descriptors, ExtensionRegistry registry) {
    if (descriptors.contains(message)) {
      return;
    }
    descriptors.add(message);

    for (FieldDescriptor f : message.getFields()) {
      recursivelyAddDescriptors(f, descriptors, registry);
    }
    for (FieldDescriptor f : message.getExtensions()) {
      recursivelyAddDescriptors(f, descriptors, registry);
    }
    for (ExtensionInfo info :
        registry.getAllImmutableExtensionsByExtendedType(message.getFullName())) {
      recursivelyAddDescriptors(info.descriptor, descriptors, registry);
    }
    for (ExtensionInfo info :
        registry.getAllMutableExtensionsByExtendedType(message.getFullName())) {
      recursivelyAddDescriptors(info.descriptor, descriptors, registry);
    }
  }
Beispiel #2
0
  /**
   * Set up the test environment.
   *
   * @throws Exception set up failed
   */
  @Before
  public void setUp() throws Exception {
    receivingNode = new Node();
    publishingNode = new Node();
    final MmiReceiver receiver = new MmiReceiver("target1");
    receiver.addMMIEventListener(this);
    TypedSubscriber subscriber = new TypedSubscriber("test", receiver);
    receivingNode.addSubscriber(subscriber);
    subscriber.registerType(LifeCycleEvents.LifeCycleEvent.class);

    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    LifeCycleEvents.registerAllExtensions(registry);
    subscriber.setExtensionRegistry(registry);
    lock = new Object();
    receivedEvent = null;
  }
  @Test
  public void testNestedExtension() throws Exception {
    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    UnittestProto.registerAllExtensions(registry);

    UnittestProto.TestAllExtensions tae =
        UnittestProto.TestAllExtensions.newBuilder()
            .setExtension(TestNestedExtension.test, "aTest")
            .build();
    String output = formatter.printToString(tae);

    UnittestProto.TestAllExtensions.Builder builder = UnittestProto.TestAllExtensions.newBuilder();
    formatter.merge(TextUtils.toInputStream(output), registry, builder);
    String value = builder.build().getExtension(TestNestedExtension.test);
    assertEquals("aTest", value);
  }
Beispiel #4
0
 public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) {
   registry.add(
       org.opendaylight.controller.cluster.example.protobuff.messages.KeyValueMessages.key);
   registry.add(
       org.opendaylight.controller.cluster.example.protobuff.messages.KeyValueMessages.value);
 }
Beispiel #5
0
 public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) {
   registry.add(org.apache.bookkeeper.proto.TestDataFormats.messageType);
 }
Beispiel #6
0
 /**
  * Creates instance of decoder specific for given message type.
  *
  * @param prototype The prototype message used to decode messages.
  */
 protected ProtobufDecoder(Message prototype) {
   this(prototype, ExtensionRegistry.getEmptyRegistry());
 }
Beispiel #7
0
 public static <T extends Message> List<T> mergeCollection(Readable reader, Builder builder)
     throws IOException {
   return mergeCollection(reader, ExtensionRegistry.getEmptyRegistry(), builder);
 }