Home / Class/ UniqueIpFilterTest Class — netty Architecture

UniqueIpFilterTest Class — netty Architecture

Architecture documentation for the UniqueIpFilterTest class in UniqueIpFilterTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  a74d4a73_e4e4_9c5c_930d_7d3ee65c7137["UniqueIpFilterTest"]
  269d2932_f3d3_97b8_ebdf_60c9862647d2["UniqueIpFilterTest.java"]
  a74d4a73_e4e4_9c5c_930d_7d3ee65c7137 -->|defined in| 269d2932_f3d3_97b8_ebdf_60c9862647d2
  036e83aa_d0d3_f2bf_0be2_4f2510191b24["testUniqueIpFilterHandler()"]
  a74d4a73_e4e4_9c5c_930d_7d3ee65c7137 -->|method| 036e83aa_d0d3_f2bf_0be2_4f2510191b24
  4f676050_4c24_f361_f493_0a591cde99bc["newChannelAsync()"]
  a74d4a73_e4e4_9c5c_930d_7d3ee65c7137 -->|method| 4f676050_4c24_f361_f493_0a591cde99bc

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/ipfilter/UniqueIpFilterTest.java lines 34–76

public class UniqueIpFilterTest {

    @Test
    public void testUniqueIpFilterHandler() throws ExecutionException, InterruptedException {
        final CyclicBarrier barrier = new CyclicBarrier(2);
        ExecutorService executorService = Executors.newFixedThreadPool(2);
        try {
            for (int round = 0; round < 10000; round++) {
                final UniqueIpFilter ipFilter = new UniqueIpFilter();
                Future<EmbeddedChannel> future1 = newChannelAsync(barrier, executorService, ipFilter);
                Future<EmbeddedChannel> future2 = newChannelAsync(barrier, executorService, ipFilter);
                EmbeddedChannel ch1 = future1.get();
                EmbeddedChannel ch2 = future2.get();
                assertTrue(ch1.isActive() || ch2.isActive());
                assertFalse(ch1.isActive() && ch2.isActive());

                barrier.reset();
                ch1.close().await();
                ch2.close().await();
            }
        } finally {
            executorService.shutdown();
        }
    }

    private static Future<EmbeddedChannel> newChannelAsync(final CyclicBarrier barrier,
            ExecutorService executorService,
            final ChannelHandler... handler) {
        return executorService.submit(new Callable<EmbeddedChannel>() {
            @Override
            public EmbeddedChannel call() throws Exception {
                barrier.await();
                return new EmbeddedChannel(handler) {
                    @Override
                    protected SocketAddress remoteAddress0() {
                        return isActive() ? SocketUtils.socketAddress("91.92.93.1", 5421) : null;
                    }
                };
            }
        });
    }

}

Frequently Asked Questions

What is the UniqueIpFilterTest class?
UniqueIpFilterTest is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/ipfilter/UniqueIpFilterTest.java.
Where is UniqueIpFilterTest defined?
UniqueIpFilterTest is defined in handler/src/test/java/io/netty/handler/ipfilter/UniqueIpFilterTest.java at line 34.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free