@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); }
@Test public void testNull() throws Exception { AioChannelFinder finder = create(); AbstractAioChannel channel = finder.findChannel( new Runnable() { @Override public void run() { // Noop } }); assertNull(channel); }