Skip to content

Commit

Permalink
Moved sctp transport classes from io.netty.channel.socket.sctp to it'…
Browse files Browse the repository at this point in the history
…s own subpackage io.netty.channel.sctp
  • Loading branch information
jestan authored and Norman Maurer committed Jan 14, 2013
1 parent c20d875 commit 983a708
Show file tree
Hide file tree
Showing 30 changed files with 187 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.socket.sctp.SctpChannel;
import io.netty.channel.sctp.SctpChannel;
import io.netty.channel.socket.nio.NioEventLoopGroup;
import io.netty.channel.socket.sctp.nio.NioSctpChannel;
import io.netty.channel.sctp.nio.NioSctpChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.socket.sctp.SctpChannel;
import io.netty.channel.sctp.SctpChannel;
import io.netty.channel.socket.nio.NioEventLoopGroup;
import io.netty.channel.socket.sctp.nio.NioSctpServerChannel;
import io.netty.channel.sctp.nio.NioSctpServerChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.socket.sctp.SctpChannel;
import io.netty.channel.sctp.SctpChannel;
import io.netty.channel.socket.oio.OioEventLoopGroup;
import io.netty.channel.socket.sctp.oio.OioSctpChannel;
import io.netty.channel.sctp.oio.OioSctpChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.socket.sctp.SctpChannel;
import io.netty.channel.sctp.SctpChannel;
import io.netty.channel.socket.oio.OioEventLoopGroup;
import io.netty.channel.socket.sctp.oio.OioSctpServerChannel;
import io.netty.channel.sctp.oio.OioSctpServerChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.channel.socket.sctp.SctpMessage;
import io.netty.channel.sctp.SctpMessage;

import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.channel.socket.sctp.SctpMessage;
import io.netty.channel.sctp.SctpMessage;

import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.testsuite.transport.socket;
package io.netty.testsuite.transport.sctp;

import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
import io.netty.testsuite.transport.sctp.SctpTestPermutation;
import io.netty.testsuite.transport.sctp.SctpTestPermutation.Factory;
import io.netty.testsuite.util.TestUtils;
import io.netty.util.NetUtil;
import org.junit.Rule;
Expand All @@ -34,7 +35,7 @@
public abstract class AbstractSctpTest {

private static final List<Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>> COMBO =
SocketTestPermutation.sctpChannel();
SctpTestPermutation.sctpChannel();

@Rule
public final TestName testName = new TestName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.testsuite.transport.socket;
package io.netty.testsuite.transport.sctp;

import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
Expand All @@ -23,7 +23,7 @@
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundByteHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.sctp.SctpChannel;
import io.netty.channel.sctp.SctpChannel;
import io.netty.handler.codec.sctp.SctpInboundByteStreamHandler;
import io.netty.handler.codec.sctp.SctpMessageCompletionHandler;
import io.netty.handler.codec.sctp.SctpOutboundByteStreamHandler;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* Copyright 2012 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.testsuite.transport.sctp;

import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.sctp.nio.NioSctpChannel;
import io.netty.channel.sctp.nio.NioSctpServerChannel;
import io.netty.channel.sctp.oio.OioSctpChannel;
import io.netty.channel.sctp.oio.OioSctpServerChannel;
import io.netty.channel.socket.nio.NioEventLoopGroup;
import io.netty.channel.socket.oio.OioEventLoopGroup;
import io.netty.testsuite.util.TestUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public class SctpTestPermutation {


static List<Factory<ServerBootstrap>> sctpServerChannel() {
if (!TestUtils.isSctpSupported()) {
return Collections.emptyList();
}

List<Factory<ServerBootstrap>> list = new ArrayList<Factory<ServerBootstrap>>();
// Make the list of ServerBootstrap factories.
list.add(new Factory<ServerBootstrap>() {
@Override
public ServerBootstrap newInstance() {
return new ServerBootstrap().
group(new NioEventLoopGroup(), new NioEventLoopGroup()).
channel(NioSctpServerChannel.class);
}
});
list.add(new Factory<ServerBootstrap>() {
@Override
public ServerBootstrap newInstance() {
return new ServerBootstrap().
group(new OioEventLoopGroup(), new OioEventLoopGroup()).
channel(OioSctpServerChannel.class);
}
});

return list;
}

static List<Factory<Bootstrap>> sctpClientChannel() {
if (!TestUtils.isSctpSupported()) {
return Collections.emptyList();
}

List<Factory<Bootstrap>> list = new ArrayList<Factory<Bootstrap>>();
list.add(new Factory<Bootstrap>() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(new NioEventLoopGroup()).channel(NioSctpChannel.class);
}
});
list.add(new Factory<Bootstrap>() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(new OioEventLoopGroup()).channel(OioSctpChannel.class);
}
});
return list;
}

static List<Map.Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>> sctpChannel() {
List<Map.Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>> list =
new ArrayList<Map.Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>>();

// Make the list of SCTP ServerBootstrap factories.
List<Factory<ServerBootstrap>> sbfs = sctpServerChannel();

// Make the list of SCTP Bootstrap factories.
List<Factory<Bootstrap>> cbfs = sctpClientChannel();

// Populate the combinations
for (Factory<ServerBootstrap> sbf: sbfs) {
for (Factory<Bootstrap> cbf: cbfs) {
final Factory<ServerBootstrap> sbf0 = sbf;
final Factory<Bootstrap> cbf0 = cbf;
list.add(new Map.Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>() {
@Override
public Factory<ServerBootstrap> getKey() {
return sbf0;
}

@Override
public Factory<Bootstrap> getValue() {
return cbf0;
}

@Override
public Factory<Bootstrap> setValue(Factory<Bootstrap> value) {
throw new UnsupportedOperationException();
}
});
}
}

return list;
}


private SctpTestPermutation() {}

interface Factory<T> {
T newInstance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,14 @@
import io.netty.channel.socket.aio.AioSocketChannel;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.channel.socket.nio.NioEventLoopGroup;
import io.netty.channel.socket.sctp.nio.NioSctpChannel;
import io.netty.channel.socket.sctp.nio.NioSctpServerChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.channel.socket.oio.OioDatagramChannel;
import io.netty.channel.socket.oio.OioEventLoopGroup;
import io.netty.channel.socket.sctp.oio.OioSctpChannel;
import io.netty.channel.socket.sctp.oio.OioSctpServerChannel;
import io.netty.channel.socket.oio.OioServerSocketChannel;
import io.netty.channel.socket.oio.OioSocketChannel;
import io.netty.testsuite.util.TestUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;

Expand Down Expand Up @@ -141,43 +135,6 @@ public Factory<Bootstrap> setValue(Factory<Bootstrap> value) {
return list;
}

static List<Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>> sctpChannel() {
List<Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>> list =
new ArrayList<Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>>();

// Make the list of SCTP ServerBootstrap factories.
List<Factory<ServerBootstrap>> sbfs = sctpServerChannel();

// Make the list of SCTP Bootstrap factories.
List<Factory<Bootstrap>> cbfs = sctpClientChannel();

// Populate the combinations
for (Factory<ServerBootstrap> sbf: sbfs) {
for (Factory<Bootstrap> cbf: cbfs) {
final Factory<ServerBootstrap> sbf0 = sbf;
final Factory<Bootstrap> cbf0 = cbf;
list.add(new Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>() {
@Override
public Factory<ServerBootstrap> getKey() {
return sbf0;
}

@Override
public Factory<Bootstrap> getValue() {
return cbf0;
}

@Override
public Factory<Bootstrap> setValue(Factory<Bootstrap> value) {
throw new UnsupportedOperationException();
}
});
}
}

return list;
}

static List<Factory<ServerBootstrap>> serverSocket() {
List<Factory<ServerBootstrap>> list = new ArrayList<Factory<ServerBootstrap>>();

Expand Down Expand Up @@ -234,54 +191,6 @@ public Bootstrap newInstance() {
return list;
}

static List<Factory<ServerBootstrap>> sctpServerChannel() {
if (!TestUtils.isSctpSupported()) {
return Collections.emptyList();
}

List<Factory<ServerBootstrap>> list = new ArrayList<Factory<ServerBootstrap>>();
// Make the list of ServerBootstrap factories.
list.add(new Factory<ServerBootstrap>() {
@Override
public ServerBootstrap newInstance() {
return new ServerBootstrap().
group(new NioEventLoopGroup(), new NioEventLoopGroup()).
channel(NioSctpServerChannel.class);
}
});
list.add(new Factory<ServerBootstrap>() {
@Override
public ServerBootstrap newInstance() {
return new ServerBootstrap().
group(new OioEventLoopGroup(), new OioEventLoopGroup()).
channel(OioSctpServerChannel.class);
}
});

return list;
}

static List<Factory<Bootstrap>> sctpClientChannel() {
if (!TestUtils.isSctpSupported()) {
return Collections.emptyList();
}

List<Factory<Bootstrap>> list = new ArrayList<Factory<Bootstrap>>();
list.add(new Factory<Bootstrap>() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(new NioEventLoopGroup()).channel(NioSctpChannel.class);
}
});
list.add(new Factory<Bootstrap>() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(new OioEventLoopGroup()).channel(OioSctpChannel.class);
}
});
return list;
}

private SocketTestPermutation() {}

interface Factory<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.channel.socket.sctp;
package io.netty.channel.sctp;

import com.sun.nio.sctp.SctpChannel;
import com.sun.nio.sctp.SctpStandardSocketOptions;
Expand All @@ -34,7 +34,7 @@ public class DefaultSctpChannelConfig extends DefaultChannelConfig implements Sc

private final SctpChannel javaChannel;

public DefaultSctpChannelConfig(io.netty.channel.socket.sctp.SctpChannel channel, SctpChannel javaChannel) {
public DefaultSctpChannelConfig(io.netty.channel.sctp.SctpChannel channel, SctpChannel javaChannel) {
super(channel);
if (javaChannel == null) {
throw new NullPointerException("javaChannel");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.channel.socket.sctp;
package io.netty.channel.sctp;

import com.sun.nio.sctp.SctpServerChannel;
import io.netty.buffer.ByteBufAllocator;
Expand All @@ -39,7 +39,7 @@ public class DefaultSctpServerChannelConfig extends DefaultChannelConfig impleme
* Creates a new instance.
*/
public DefaultSctpServerChannelConfig(
io.netty.channel.socket.sctp.SctpServerChannel channel, SctpServerChannel javaChannel) {
io.netty.channel.sctp.SctpServerChannel channel, SctpServerChannel javaChannel) {
super(channel);
if (javaChannel == null) {
throw new NullPointerException("javaChannel");
Expand Down
Loading

0 comments on commit 983a708

Please sign in to comment.