コード例 #1
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;
  }
コード例 #2
0
  @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);
  }