1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.testsuite.transport.sctp;
17
18 import io.netty.bootstrap.Bootstrap;
19 import io.netty.bootstrap.ServerBootstrap;
20 import io.netty.channel.EventLoopGroup;
21 import io.netty.channel.nio.NioEventLoopGroup;
22 import io.netty.channel.oio.OioEventLoopGroup;
23 import io.netty.channel.sctp.nio.NioSctpChannel;
24 import io.netty.channel.sctp.nio.NioSctpServerChannel;
25 import io.netty.channel.sctp.oio.OioSctpChannel;
26 import io.netty.channel.sctp.oio.OioSctpServerChannel;
27 import io.netty.testsuite.util.TestUtils;
28 import io.netty.testsuite.transport.TestsuitePermutation.BootstrapComboFactory;
29 import io.netty.testsuite.transport.TestsuitePermutation.BootstrapFactory;
30 import io.netty.util.concurrent.DefaultThreadFactory;
31
32 import java.util.ArrayList;
33 import java.util.Collections;
34 import java.util.List;
35
36 public final class SctpTestPermutation {
37
38 private static final int BOSSES = 2;
39 private static final int WORKERS = 3;
40 private static final EventLoopGroup nioBossGroup =
41 new NioEventLoopGroup(BOSSES, new DefaultThreadFactory("testsuite-sctp-nio-boss", true));
42 private static final EventLoopGroup nioWorkerGroup =
43 new NioEventLoopGroup(WORKERS, new DefaultThreadFactory("testsuite-sctp-nio-worker", true));
44 private static final EventLoopGroup oioBossGroup =
45 new OioEventLoopGroup(Integer.MAX_VALUE, new DefaultThreadFactory("testsuite-sctp-oio-boss", true));
46 private static final EventLoopGroup oioWorkerGroup =
47 new OioEventLoopGroup(Integer.MAX_VALUE, new DefaultThreadFactory("testsuite-sctp-oio-worker", true));
48
49 static List<BootstrapFactory<ServerBootstrap>> sctpServerChannel() {
50 if (!TestUtils.isSctpSupported()) {
51 return Collections.emptyList();
52 }
53
54 List<BootstrapFactory<ServerBootstrap>> list = new ArrayList<BootstrapFactory<ServerBootstrap>>();
55
56 list.add(new BootstrapFactory<ServerBootstrap>() {
57 @Override
58 public ServerBootstrap newInstance() {
59 return new ServerBootstrap().
60 group(nioBossGroup, nioWorkerGroup).
61 channel(NioSctpServerChannel.class);
62 }
63 });
64 list.add(new BootstrapFactory<ServerBootstrap>() {
65 @Override
66 public ServerBootstrap newInstance() {
67 return new ServerBootstrap().
68 group(oioBossGroup, oioWorkerGroup).
69 channel(OioSctpServerChannel.class);
70 }
71 });
72
73 return list;
74 }
75
76 static List<BootstrapFactory<Bootstrap>> sctpClientChannel() {
77 if (!TestUtils.isSctpSupported()) {
78 return Collections.emptyList();
79 }
80
81 List<BootstrapFactory<Bootstrap>> list = new ArrayList<BootstrapFactory<Bootstrap>>();
82 list.add(new BootstrapFactory<Bootstrap>() {
83 @Override
84 public Bootstrap newInstance() {
85 return new Bootstrap().group(nioWorkerGroup).channel(NioSctpChannel.class);
86 }
87 });
88 list.add(new BootstrapFactory<Bootstrap>() {
89 @Override
90 public Bootstrap newInstance() {
91 return new Bootstrap().group(oioWorkerGroup).channel(OioSctpChannel.class);
92 }
93 });
94 return list;
95 }
96
97 static List<BootstrapComboFactory<ServerBootstrap, Bootstrap>> sctpChannel() {
98 List<BootstrapComboFactory<ServerBootstrap, Bootstrap>> list =
99 new ArrayList<BootstrapComboFactory<ServerBootstrap, Bootstrap>>();
100
101
102 List<BootstrapFactory<ServerBootstrap>> sbfs = sctpServerChannel();
103
104
105 List<BootstrapFactory<Bootstrap>> cbfs = sctpClientChannel();
106
107
108 for (BootstrapFactory<ServerBootstrap> sbf: sbfs) {
109 for (BootstrapFactory<Bootstrap> cbf: cbfs) {
110 final BootstrapFactory<ServerBootstrap> sbf0 = sbf;
111 final BootstrapFactory<Bootstrap> cbf0 = cbf;
112 list.add(new BootstrapComboFactory<ServerBootstrap, Bootstrap>() {
113 @Override
114 public ServerBootstrap newServerInstance() {
115 return sbf0.newInstance();
116 }
117
118 @Override
119 public Bootstrap newClientInstance() {
120 return cbf0.newInstance();
121 }
122 });
123 }
124 }
125
126 return list;
127 }
128
129 private SctpTestPermutation() { }
130 }