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:
parent
cba9cf1b6c
commit
f805c50f9f
@ -21,14 +21,28 @@ import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
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 {
|
@ -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() { }
|
||||
}
|
@ -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;
|
Loading…
Reference in New Issue
Block a user