Migrate handler-proxy tests to JUnit 5 (#11313)
Motivation: JUnit 5 is more expressive, extensible, and composable in many ways, and it's better able to run tests in parallel. Modifications: Use JUnit5 in handler-proxy tests Result: Related to https://github.com/netty/netty/issues/10757
This commit is contained in:
parent
6ffb001caf
commit
a63a4d99e0
@ -42,12 +42,15 @@ import io.netty.handler.proxy.HttpProxyHandler.HttpProxyConnectException;
|
||||
import io.netty.util.NetUtil;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class HttpProxyHandlerTest {
|
||||
|
@ -47,13 +47,11 @@ import io.netty.util.internal.EmptyArrays;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import io.netty.util.internal.logging.InternalLogger;
|
||||
import io.netty.util.internal.logging.InternalLoggerFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
@ -69,9 +67,8 @@ import java.util.Random;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class ProxyHandlerTest {
|
||||
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(ProxyHandlerTest.class);
|
||||
@ -136,7 +133,6 @@ public class ProxyHandlerTest {
|
||||
// look for "Seed used: *" debug message in test logs
|
||||
private static final long reproducibleSeed = 0L;
|
||||
|
||||
@Parameters(name = "{index}: {0}")
|
||||
public static List<Object[]> testItems() {
|
||||
|
||||
List<TestItem> items = Arrays.asList(
|
||||
@ -423,32 +419,27 @@ public class ProxyHandlerTest {
|
||||
return params;
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void stopServers() {
|
||||
for (ProxyServer p: allProxies) {
|
||||
p.stop();
|
||||
}
|
||||
}
|
||||
|
||||
private final TestItem testItem;
|
||||
|
||||
public ProxyHandlerTest(TestItem testItem) {
|
||||
this.testItem = testItem;
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void clearServerExceptions() throws Exception {
|
||||
for (ProxyServer p: allProxies) {
|
||||
p.clearExceptions();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
@ParameterizedTest(name = "{index}: {0}")
|
||||
@MethodSource("testItems")
|
||||
public void test(TestItem testItem) throws Exception {
|
||||
testItem.test();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void checkServerExceptions() throws Exception {
|
||||
for (ProxyServer p: allProxies) {
|
||||
p.checkExceptions();
|
||||
|
Loading…
Reference in New Issue
Block a user