Ejemplo n.º 1
0
  @Test
  public void testRunnableWrappsRunnable() throws Exception {
    final Object mockChannel = createMock("mockChannel", AbstractAioChannel.class);
    replay(mockChannel);

    final Runnable r =
        new Runnable() {

          @SuppressWarnings("unused")
          @Override
          public void run() {
            Object channel = mockChannel;
            // Noop
          }
        };
    Runnable r2 =
        new Runnable() {

          @SuppressWarnings("unused")
          @Override
          public void run() {
            Runnable runnable = r;
            // Noop
          }
        };
    AioChannelFinder finder = create();
    AbstractAioChannel channel = finder.findChannel(r2);
    assertNotNull(channel);

    AbstractAioChannel channel2 = finder.findChannel(r2);
    assertNotNull(channel2);
    assertSame(channel2, channel);
    verify(mockChannel);
    reset(mockChannel);
  }
Ejemplo n.º 2
0
  @Test
  public void testNull() throws Exception {
    AioChannelFinder finder = create();
    AbstractAioChannel channel =
        finder.findChannel(
            new Runnable() {

              @Override
              public void run() {
                // Noop
              }
            });
    assertNull(channel);
  }