1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty5.testsuite.transport.socket;
17
18 import io.netty5.bootstrap.Bootstrap;
19 import io.netty5.bootstrap.ServerBootstrap;
20 import io.netty5.buffer.api.BufferAllocator;
21 import io.netty5.channel.ChannelOption;
22 import io.netty5.testsuite.transport.AbstractComboTestsuiteTest;
23 import io.netty5.testsuite.transport.TestsuitePermutation;
24 import io.netty5.util.NetUtil;
25
26 import java.net.InetSocketAddress;
27 import java.net.SocketAddress;
28 import java.util.List;
29
30 public abstract class AbstractSocketTest extends AbstractComboTestsuiteTest<ServerBootstrap, Bootstrap> {
31 @Override
32 protected List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> newFactories() {
33 return SocketTestPermutation.INSTANCE.socket();
34 }
35
36 @Override
37 protected void configure(ServerBootstrap sb, Bootstrap cb,
38 BufferAllocator bufferAllocator) {
39 sb.localAddress(newSocketAddress());
40 sb.option(ChannelOption.BUFFER_ALLOCATOR, bufferAllocator);
41 sb.childOption(ChannelOption.BUFFER_ALLOCATOR, bufferAllocator);
42 cb.option(ChannelOption.BUFFER_ALLOCATOR, bufferAllocator);
43 }
44
45 protected SocketAddress newSocketAddress() {
46 return new InetSocketAddress(NetUtil.LOCALHOST, 0);
47 }
48 }