Move sctp tests to correct directory and migrate to junit5 (#11331)

Motivation:

The sctp tests were in the incorrect directory and so were never executed. Beside this we also should use junit5

Modifications:

- Move to correct directory
- Use JUnit5 in tests

Result:

Related to https://github.com/netty/netty/issues/10757 and fixes https://github.com/netty/netty/issues/11325
This commit is contained in:
Norman Maurer 2021-05-28 15:03:18 +02:00 committed by GitHub
parent 4d681bfc6f
commit 18e92304a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 78 additions and 7 deletions

View File

@ -22,14 +22,28 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import org.junit.Test;
import java.net.InetSocketAddress;
import io.netty.util.SuppressForbidden;
import static org.junit.Assert.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import java.net.InetSocketAddress;
import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
public abstract class SctpLimitStreamsTest {
@Test(timeout = 5000)
@BeforeAll
public static void checkSupported() {
assumeTrue(SctpTestUtil.isSctpSupported());
}
@SuppressForbidden(reason = "test-only")
@Test
@Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSctpInitMaxstreams() throws Exception {
EventLoopGroup loop = newEventLoopGroup();
try {

View File

@ -0,0 +1,55 @@
/*
* Copyright 2021 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:
*
* https://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.channel.sctp;
import com.sun.nio.sctp.SctpChannel;
import io.netty.util.SuppressForbidden;
import java.io.IOException;
import java.nio.channels.Channel;
@SuppressForbidden(reason = "test-only")
final class SctpTestUtil {
private static final boolean SCTP_SUPPORTED;
static {
boolean supported = true;
Channel channel = null;
try {
channel = SctpChannel.open();
} catch (UnsupportedOperationException e) {
supported = false;
} catch (IOException e) {
// ignore
} finally {
if (channel != null) {
try {
channel.close();
} catch (IOException ignore) {
// ignore
}
}
}
SCTP_SUPPORTED = supported;
}
public static boolean isSctpSupported() {
return SCTP_SUPPORTED;
}
private SctpTestUtil() { }
}

View File

@ -21,12 +21,13 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.channel.sctp.SctpMessage;
import org.junit.Test;
import io.netty.util.SuppressForbidden;
import org.junit.jupiter.api.Test;
import java.net.SocketAddress;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class SctpMessageCompletionHandlerTest {
@ -46,6 +47,7 @@ public class SctpMessageCompletionHandlerTest {
assertEquals(0, buffer2.refCnt());
}
@SuppressForbidden(reason = "test-only")
private final class TestMessageInfo extends MessageInfo {
private final boolean complete;