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 NUM_THREADS = 4;
39 private static final EventLoopGroup NIO_GROUP = new NioEventLoopGroup(
40 NUM_THREADS, new DefaultThreadFactory("testsuite-sctp-nio", true));
41 private static final EventLoopGroup OIO_GROUP =
42 new OioEventLoopGroup(Integer.MAX_VALUE, new DefaultThreadFactory("testsuite-sctp-oio", true));
43
44 static List<BootstrapFactory<ServerBootstrap>> sctpServerChannel() {
45 if (!TestUtils.isSctpSupported()) {
46 return Collections.emptyList();
47 }
48
49 List<BootstrapFactory<ServerBootstrap>> list = new ArrayList<BootstrapFactory<ServerBootstrap>>();
50
51 list.add(new BootstrapFactory<ServerBootstrap>() {
52 @Override
53 public ServerBootstrap newInstance() {
54 return new ServerBootstrap().
55 group(NIO_GROUP).
56 channel(NioSctpServerChannel.class);
57 }
58 });
59 list.add(new BootstrapFactory<ServerBootstrap>() {
60 @Override
61 public ServerBootstrap newInstance() {
62 return new ServerBootstrap().
63 group(OIO_GROUP).
64 channel(OioSctpServerChannel.class);
65 }
66 });
67
68 return list;
69 }
70
71 static List<BootstrapFactory<Bootstrap>> sctpClientChannel() {
72 if (!TestUtils.isSctpSupported()) {
73 return Collections.emptyList();
74 }
75
76 List<BootstrapFactory<Bootstrap>> list = new ArrayList<BootstrapFactory<Bootstrap>>();
77 list.add(new BootstrapFactory<Bootstrap>() {
78 @Override
79 public Bootstrap newInstance() {
80 return new Bootstrap().group(NIO_GROUP).channel(NioSctpChannel.class);
81 }
82 });
83 list.add(new BootstrapFactory<Bootstrap>() {
84 @Override
85 public Bootstrap newInstance() {
86 return new Bootstrap().group(OIO_GROUP).channel(OioSctpChannel.class);
87 }
88 });
89 return list;
90 }
91
92 static List<BootstrapComboFactory<ServerBootstrap, Bootstrap>> sctpChannel() {
93 List<BootstrapComboFactory<ServerBootstrap, Bootstrap>> list =
94 new ArrayList<BootstrapComboFactory<ServerBootstrap, Bootstrap>>();
95
96
97 List<BootstrapFactory<ServerBootstrap>> sbfs = sctpServerChannel();
98
99
100 List<BootstrapFactory<Bootstrap>> cbfs = sctpClientChannel();
101
102
103 for (BootstrapFactory<ServerBootstrap> sbf: sbfs) {
104 for (BootstrapFactory<Bootstrap> cbf: cbfs) {
105 final BootstrapFactory<ServerBootstrap> sbf0 = sbf;
106 final BootstrapFactory<Bootstrap> cbf0 = cbf;
107 list.add(new BootstrapComboFactory<ServerBootstrap, Bootstrap>() {
108 @Override
109 public ServerBootstrap newServerInstance() {
110 return sbf0.newInstance();
111 }
112
113 @Override
114 public Bootstrap newClientInstance() {
115 return cbf0.newInstance();
116 }
117 });
118 }
119 }
120
121 return list;
122 }
123
124 private SctpTestPermutation() { }
125 }