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