Migrate codec-memcache tests to JUnit 5 (#11310)
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 codec-memcache tests Result: Related to https://github.com/netty/netty/issues/10757
This commit is contained in:
parent
7be16c549b
commit
c6aaaffec2
@ -22,15 +22,15 @@ import io.netty.handler.codec.memcache.LastMemcacheContent;
|
||||
import io.netty.handler.codec.memcache.MemcacheContent;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import io.netty.util.ReferenceCounted;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.core.IsNull.notNullValue;
|
||||
import static org.hamcrest.core.IsNull.nullValue;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Verifies the correct functionality of the {@link AbstractBinaryMemcacheDecoder}.
|
||||
@ -69,12 +69,12 @@ public class BinaryMemcacheDecoderTest {
|
||||
|
||||
private EmbeddedChannel channel;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
channel = new EmbeddedChannel(new BinaryMemcacheRequestDecoder());
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void teardown() throws Exception {
|
||||
channel.finishAndReleaseAll();
|
||||
}
|
||||
|
@ -22,13 +22,15 @@ import io.netty.handler.codec.EncoderException;
|
||||
import io.netty.handler.codec.memcache.DefaultLastMemcacheContent;
|
||||
import io.netty.handler.codec.memcache.DefaultMemcacheContent;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.function.Executable;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
/**
|
||||
* Verifies the correct functionality of the {@link AbstractBinaryMemcacheEncoder}.
|
||||
@ -39,13 +41,13 @@ public class BinaryMemcacheEncoderTest {
|
||||
|
||||
private EmbeddedChannel channel;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
channel = new EmbeddedChannel(new BinaryMemcacheRequestEncoder());
|
||||
}
|
||||
|
||||
@After
|
||||
public void teardown() throws Exception {
|
||||
@AfterEach
|
||||
public void teardown() {
|
||||
channel.finishAndReleaseAll();
|
||||
}
|
||||
|
||||
@ -153,9 +155,14 @@ public class BinaryMemcacheEncoderTest {
|
||||
written.release();
|
||||
}
|
||||
|
||||
@Test(expected = EncoderException.class)
|
||||
@Test
|
||||
public void shouldFailWithoutLastContent() {
|
||||
channel.writeOutbound(new DefaultMemcacheContent(Unpooled.EMPTY_BUFFER));
|
||||
assertThrows(EncoderException.class, new Executable() {
|
||||
@Override
|
||||
public void execute() {
|
||||
channel.writeOutbound(new DefaultBinaryMemcacheRequest());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,9 @@ package io.netty.handler.codec.memcache.binary;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class BinaryMemcacheMessageTest {
|
||||
|
||||
|
@ -21,14 +21,14 @@ import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.handler.codec.memcache.DefaultLastMemcacheContent;
|
||||
import io.netty.handler.codec.memcache.DefaultMemcacheContent;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.core.IsNull.notNullValue;
|
||||
import static org.hamcrest.core.IsNull.nullValue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Verifies the correct functionality of the {@link BinaryMemcacheObjectAggregator}.
|
||||
|
@ -18,17 +18,17 @@ package io.netty.handler.codec.memcache.binary;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
|
||||
public class DefaultFullBinaryMemcacheRequestTest {
|
||||
|
||||
private DefaultFullBinaryMemcacheRequest request;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
request = new DefaultFullBinaryMemcacheRequest(
|
||||
Unpooled.copiedBuffer("key", CharsetUtil.UTF_8),
|
||||
|
@ -18,17 +18,17 @@ package io.netty.handler.codec.memcache.binary;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
|
||||
public class DefaultFullBinaryMemcacheResponseTest {
|
||||
|
||||
private DefaultFullBinaryMemcacheResponse response;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
response = new DefaultFullBinaryMemcacheResponse(
|
||||
Unpooled.copiedBuffer("key", CharsetUtil.UTF_8),
|
||||
|
@ -19,17 +19,19 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class FullMemcacheMessageRequestTest {
|
||||
|
||||
private EmbeddedChannel channel;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
channel = new EmbeddedChannel(
|
||||
new BinaryMemcacheRequestEncoder(),
|
||||
@ -37,7 +39,7 @@ public class FullMemcacheMessageRequestTest {
|
||||
new BinaryMemcacheObjectAggregator(1024));
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void teardown() throws Exception {
|
||||
assertFalse(channel.finish());
|
||||
}
|
||||
|
@ -19,19 +19,19 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class FullMemcacheMessageResponseTest {
|
||||
|
||||
private EmbeddedChannel channel;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
channel = new EmbeddedChannel(
|
||||
new BinaryMemcacheResponseEncoder(),
|
||||
@ -39,7 +39,7 @@ public class FullMemcacheMessageResponseTest {
|
||||
new BinaryMemcacheObjectAggregator(1024));
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void teardown() throws Exception {
|
||||
assertFalse(channel.finish());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user