Replace deprecated Assert.assertThat(...) with MatcherAssert.assertThat(...) (#10699)

Motivation:

junit deprecated Assert.assertThat(...)

Modifications:

Use MatcherAssert.assertThat(...) as replacement for deprecated method

Result:

Less deprecation warnings
This commit is contained in:
Norman Maurer 2020-10-18 14:30:52 +02:00 committed by GitHub
parent ea2a0899de
commit ffbddcd842
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
87 changed files with 151 additions and 104 deletions

View File

@ -58,12 +58,12 @@ import static io.netty.buffer.Unpooled.unreleasableBuffer;
import static io.netty.buffer.Unpooled.wrappedBuffer;
import static io.netty.util.internal.EmptyArrays.EMPTY_BYTES;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeFalse;

View File

@ -38,13 +38,13 @@ import static io.netty.buffer.Unpooled.wrappedBuffer;
import static io.netty.util.internal.EmptyArrays.EMPTY_BYTES;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

View File

@ -21,8 +21,8 @@ import org.junit.Test;
import java.nio.ByteOrder;
import java.util.Random;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
/**
* Tests wrapping a wrapped buffer does not go way too deep chaining.

View File

@ -32,6 +32,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import static io.netty.buffer.Unpooled.unreleasableBuffer;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.*;

View File

@ -17,6 +17,7 @@
import io.netty.util.CharsetUtil;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

View File

@ -25,9 +25,9 @@ import org.junit.Test;
import java.util.ArrayDeque;
import java.util.Queue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class SimpleLeakAwareCompositeByteBufTest extends WrappedCompositeByteBufTest {

View File

@ -26,8 +26,8 @@ import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
public class DnsQueryTest {

View File

@ -27,8 +27,8 @@ import org.junit.rules.ExpectedException;
import java.net.InetSocketAddress;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
public class DnsResponseTest {

View File

@ -24,10 +24,10 @@ import java.util.Iterator;
import static io.netty.handler.codec.http.HttpHeaderNames.SET_COOKIE;
import static io.netty.util.AsciiString.contentEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class CombinedHttpHeadersTest {

View File

@ -29,6 +29,7 @@ import static io.netty.handler.codec.http.HttpHeadersTestUtils.of;
import static io.netty.util.AsciiString.contentEquals;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
public class DefaultHttpHeadersTest {

View File

@ -44,6 +44,7 @@ import java.util.concurrent.CountDownLatch;
import static io.netty.util.ReferenceCountUtil.release;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.*;

View File

@ -20,7 +20,6 @@ import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInitializer;
@ -48,6 +47,7 @@ import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
public class HttpContentCompressorTest {

View File

@ -39,6 +39,7 @@ import java.util.concurrent.atomic.AtomicReference;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
public class HttpContentDecoderTest {

View File

@ -35,6 +35,7 @@ import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
public class HttpContentEncoderTest {

View File

@ -22,9 +22,9 @@ import java.util.List;
import static io.netty.handler.codec.http.HttpHeadersTestUtils.of;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class HttpHeadersTest {

View File

@ -36,12 +36,12 @@ import java.util.List;
import static io.netty.handler.codec.http.HttpHeadersTestUtils.of;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertSame;

View File

@ -29,11 +29,11 @@ import static io.netty.handler.codec.http.HttpHeadersTestUtils.of;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class HttpRequestDecoderTest {

View File

@ -28,6 +28,7 @@ import java.nio.ByteOrder;
import java.nio.charset.Charset;
import java.util.concurrent.ExecutionException;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.*;

View File

@ -32,11 +32,11 @@ import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class HttpResponseDecoderTest {

View File

@ -25,6 +25,7 @@ import org.junit.Test;
import java.io.IOException;
import java.nio.channels.WritableByteChannel;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

View File

@ -22,6 +22,7 @@ import io.netty.util.CharsetUtil;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
public class HttpServerCodecTest {

View File

@ -20,6 +20,7 @@ import io.netty.util.ReferenceCountUtil;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
public class HttpServerExpectContinueHandlerTest {

View File

@ -28,6 +28,7 @@ import java.util.TimeZone;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
public class ClientCookieDecoderTest {

View File

@ -15,12 +15,13 @@
*/
package io.netty.handler.codec.http.cookie;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.matchers.JUnitMatchers.containsString;
import io.netty.handler.codec.DateFormatter;
import java.text.ParseException;

View File

@ -19,9 +19,13 @@ import java.util.SortedSet;
import java.util.TreeSet;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static io.netty.handler.codec.http.websocketx.WebSocketCloseStatus.*;
public class WebSocketCloseStatusTest {
@ -43,33 +47,33 @@ public class WebSocketCloseStatusTest {
@Test
public void testToString() {
Assert.assertEquals("1000 Bye", NORMAL_CLOSURE.toString());
assertEquals("1000 Bye", NORMAL_CLOSURE.toString());
}
@Test
public void testKnownStatuses() {
Assert.assertSame(NORMAL_CLOSURE, valueOf(1000));
Assert.assertSame(ENDPOINT_UNAVAILABLE, valueOf(1001));
Assert.assertSame(PROTOCOL_ERROR, valueOf(1002));
Assert.assertSame(INVALID_MESSAGE_TYPE, valueOf(1003));
Assert.assertSame(INVALID_PAYLOAD_DATA, valueOf(1007));
Assert.assertSame(POLICY_VIOLATION, valueOf(1008));
Assert.assertSame(MESSAGE_TOO_BIG, valueOf(1009));
Assert.assertSame(MANDATORY_EXTENSION, valueOf(1010));
Assert.assertSame(INTERNAL_SERVER_ERROR, valueOf(1011));
Assert.assertSame(SERVICE_RESTART, valueOf(1012));
Assert.assertSame(TRY_AGAIN_LATER, valueOf(1013));
Assert.assertSame(BAD_GATEWAY, valueOf(1014));
assertSame(NORMAL_CLOSURE, valueOf(1000));
assertSame(ENDPOINT_UNAVAILABLE, valueOf(1001));
assertSame(PROTOCOL_ERROR, valueOf(1002));
assertSame(INVALID_MESSAGE_TYPE, valueOf(1003));
assertSame(INVALID_PAYLOAD_DATA, valueOf(1007));
assertSame(POLICY_VIOLATION, valueOf(1008));
assertSame(MESSAGE_TOO_BIG, valueOf(1009));
assertSame(MANDATORY_EXTENSION, valueOf(1010));
assertSame(INTERNAL_SERVER_ERROR, valueOf(1011));
assertSame(SERVICE_RESTART, valueOf(1012));
assertSame(TRY_AGAIN_LATER, valueOf(1013));
assertSame(BAD_GATEWAY, valueOf(1014));
}
@Test
public void testNaturalOrder() {
Assert.assertThat(PROTOCOL_ERROR, Matchers.greaterThan(NORMAL_CLOSURE));
Assert.assertThat(PROTOCOL_ERROR, Matchers.greaterThan(valueOf(1001)));
Assert.assertThat(PROTOCOL_ERROR, Matchers.comparesEqualTo(PROTOCOL_ERROR));
Assert.assertThat(PROTOCOL_ERROR, Matchers.comparesEqualTo(valueOf(1002)));
Assert.assertThat(PROTOCOL_ERROR, Matchers.lessThan(INVALID_MESSAGE_TYPE));
Assert.assertThat(PROTOCOL_ERROR, Matchers.lessThan(valueOf(1007)));
assertThat(PROTOCOL_ERROR, Matchers.greaterThan(NORMAL_CLOSURE));
assertThat(PROTOCOL_ERROR, Matchers.greaterThan(valueOf(1001)));
assertThat(PROTOCOL_ERROR, Matchers.comparesEqualTo(PROTOCOL_ERROR));
assertThat(PROTOCOL_ERROR, Matchers.comparesEqualTo(valueOf(1002)));
assertThat(PROTOCOL_ERROR, Matchers.lessThan(INVALID_MESSAGE_TYPE));
assertThat(PROTOCOL_ERROR, Matchers.lessThan(valueOf(1007)));
}
@Test
@ -79,13 +83,13 @@ public class WebSocketCloseStatusTest {
WebSocketCloseStatus untradablePrice = new WebSocketCloseStatus(6034, "Untradable price");
// Then
Assert.assertNotSame(feedTimeot, valueOf(6033));
Assert.assertEquals(feedTimeot.code(), 6033);
Assert.assertEquals(feedTimeot.reasonText(), "Feed timed out");
assertNotSame(feedTimeot, valueOf(6033));
assertEquals(feedTimeot.code(), 6033);
assertEquals(feedTimeot.reasonText(), "Feed timed out");
Assert.assertNotSame(untradablePrice, valueOf(6034));
Assert.assertEquals(untradablePrice.code(), 6034);
Assert.assertEquals(untradablePrice.reasonText(), "Untradable price");
assertNotSame(untradablePrice, valueOf(6034));
assertEquals(untradablePrice.code(), 6034);
assertEquals(untradablePrice.reasonText(), "Untradable price");
}
@Test
@ -116,12 +120,11 @@ public class WebSocketCloseStatusTest {
}
// Then
Assert.assertEquals(0, invalidCodes.first().intValue());
Assert.assertEquals(2999, invalidCodes.last().intValue());
Assert.assertEquals(3000 - validCodes.size(), invalidCodes.size());
assertEquals(0, invalidCodes.first().intValue());
assertEquals(2999, invalidCodes.last().intValue());
assertEquals(3000 - validCodes.size(), invalidCodes.size());
invalidCodes.retainAll(knownCodes);
Assert.assertEquals(invalidCodes, Collections.emptySet());
assertEquals(invalidCodes, Collections.emptySet());
}
}

View File

@ -31,6 +31,7 @@ import org.junit.Test;
import java.util.concurrent.atomic.AtomicReference;
import static io.netty.util.CharsetUtil.UTF_8;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
/**

View File

@ -33,12 +33,16 @@ import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.util.ReferenceCountUtil;
import io.netty.util.ReferenceCounted;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Test;
import java.util.Iterator;
import static io.netty.handler.codec.http.HttpVersion.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
public class WebSocketServerHandshaker13Test extends WebSocketServerHandshakerTest {
@ -74,7 +78,7 @@ public class WebSocketServerHandshaker13Test extends WebSocketServerHandshakerTe
testUpgrade0(ch, new WebSocketServerHandshaker13(
"ws://example.com/chat", null, false, Integer.MAX_VALUE, false));
}
Assert.assertFalse(ch.finish());
assertFalse(ch.finish());
}
@Test
@ -98,14 +102,14 @@ public class WebSocketServerHandshaker13Test extends WebSocketServerHandshakerTe
ByteBuf buffer = ch.readOutbound();
try {
ch.writeInbound(buffer);
Assert.fail();
fail();
} catch (CorruptedWebSocketFrameException expected) {
// expected
}
ReferenceCounted closeMessage = ch.readOutbound();
Assert.assertThat(closeMessage, CoreMatchers.instanceOf(ByteBuf.class));
assertThat(closeMessage, CoreMatchers.instanceOf(ByteBuf.class));
closeMessage.release();
Assert.assertFalse(ch.finish());
assertFalse(ch.finish());
}
private static void testUpgrade0(EmbeddedChannel ch, WebSocketServerHandshaker13 handshaker) {
@ -126,14 +130,14 @@ public class WebSocketServerHandshaker13Test extends WebSocketServerHandshakerTe
ch2.writeInbound(resBuf);
HttpResponse res = ch2.readInbound();
Assert.assertEquals(
assertEquals(
"s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", res.headers().get(HttpHeaderNames.SEC_WEBSOCKET_ACCEPT));
Iterator<String> subProtocols = handshaker.subprotocols().iterator();
if (subProtocols.hasNext()) {
Assert.assertEquals(subProtocols.next(),
assertEquals(subProtocols.next(),
res.headers().get(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL));
} else {
Assert.assertNull(res.headers().get(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL));
assertNull(res.headers().get(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL));
}
ReferenceCountUtil.release(res);
req.release();

View File

@ -43,10 +43,11 @@ import static io.netty.handler.codec.http2.Http2Stream.State.OPEN;
import static io.netty.handler.codec.http2.Http2Stream.State.RESERVED_REMOTE;
import static io.netty.util.CharsetUtil.UTF_8;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.any;

View File

@ -51,12 +51,12 @@ import static io.netty.handler.codec.http2.Http2Stream.State.HALF_CLOSED_REMOTE;
import static io.netty.handler.codec.http2.Http2Stream.State.RESERVED_LOCAL;
import static io.netty.handler.codec.http2.Http2TestUtil.newVoidPromise;
import static io.netty.util.CharsetUtil.UTF_8;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.any;

View File

@ -45,9 +45,9 @@ import static io.netty.util.AsciiString.EMPTY_STRING;
import static io.netty.util.AsciiString.of;
import static java.lang.Integer.MAX_VALUE;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;

View File

@ -20,8 +20,8 @@ import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

View File

@ -60,19 +60,17 @@ import static io.netty.handler.codec.http2.Http2TestUtil.anyChannelPromise;
import static io.netty.handler.codec.http2.Http2TestUtil.anyHttp2Settings;
import static io.netty.handler.codec.http2.Http2TestUtil.assertEqualsAndRelease;
import static io.netty.handler.codec.http2.Http2TestUtil.bb;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyLong;
import static org.mockito.Mockito.anyShort;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.same;

View File

@ -43,9 +43,9 @@ import java.util.concurrent.ExecutionException;
import static io.netty.handler.codec.http2.Http2FrameCodecBuilder.forClient;
import static io.netty.handler.codec.http2.Http2FrameCodecBuilder.forServer;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

View File

@ -55,9 +55,9 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;

View File

@ -27,8 +27,8 @@ import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.*;
/**
* Verifies the correct functionality of the {@link AbstractBinaryMemcacheEncoder}.

View File

@ -30,6 +30,7 @@ import java.util.List;
import static io.netty.handler.codec.redis.RedisCodecTestUtil.*;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
/**

View File

@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
import static io.netty.handler.codec.redis.RedisCodecTestUtil.*;

View File

@ -22,6 +22,7 @@ import io.netty.util.ReferenceCountUtil;
import org.junit.Test;
import static io.netty.buffer.Unpooled.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

View File

@ -24,7 +24,7 @@ import java.util.Random;
import static io.netty.buffer.Unpooled.*;
import static org.hamcrest.core.Is.*;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
public class ByteArrayDecoderTest {

View File

@ -26,7 +26,7 @@ import java.util.Random;
import static io.netty.buffer.Unpooled.*;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
public class ByteArrayEncoderTest {

View File

@ -29,6 +29,7 @@ import org.junit.Test;
import java.util.Arrays;
import java.util.Random;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

View File

@ -20,6 +20,7 @@ import io.netty.buffer.CompositeByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.embedded.EmbeddedChannel;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

View File

@ -48,13 +48,13 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.zip.Checksum;
import static io.netty.handler.codec.compression.Lz4Constants.DEFAULT_SEED;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
public class Lz4FrameEncoderTest extends AbstractEncoderTest {

View File

@ -23,6 +23,7 @@ import org.junit.Test;
import static io.netty.buffer.Unpooled.*;
import static org.hamcrest.core.Is.*;
import static org.hamcrest.core.IsNull.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
public class ProtobufVarint32FrameDecoderTest {

View File

@ -22,6 +22,7 @@ import org.junit.Test;
import static io.netty.buffer.Unpooled.*;
import static org.hamcrest.core.Is.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
public class ProtobufVarint32LengthFieldPrependerTest {

View File

@ -37,7 +37,7 @@ import java.util.Collections;
import java.util.List;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
public class XmlFrameDecoderTest {

View File

@ -24,11 +24,11 @@ import java.util.Random;
import static io.netty.util.AsciiString.contains;
import static io.netty.util.AsciiString.containsIgnoreCase;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**

View File

@ -23,7 +23,7 @@ import java.util.Set;
import java.util.TreeSet;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
public class ConstantPoolTest {

View File

@ -23,12 +23,12 @@ import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicReference;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasToString;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
public class NettyRuntimeTests {

View File

@ -24,8 +24,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
public class ThreadDeathWatcherTest {

View File

@ -37,6 +37,7 @@ import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import static java.lang.Math.max;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.*;

View File

@ -25,10 +25,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class FastThreadLocalTest {

View File

@ -27,8 +27,8 @@ import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
public class GlobalEventExecutorTest {

View File

@ -17,7 +17,7 @@
package io.netty.util.concurrent;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.*;
import org.junit.Rule;

View File

@ -35,6 +35,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
public class SingleThreadEventExecutorTest {

View File

@ -32,12 +32,12 @@ import static io.netty.util.internal.StringUtil.toHexStringPadded;
import static io.netty.util.internal.StringUtil.unescapeCsv;
import static io.netty.util.internal.StringUtil.unescapeCsvFields;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class StringUtilTest {

View File

@ -39,8 +39,8 @@ import java.net.InetSocketAddress;
import java.net.SocketAddress;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
final class HttpProxyServer extends ProxyServer {

View File

@ -68,6 +68,7 @@ import java.util.concurrent.TimeUnit;
import java.util.Random;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
@RunWith(Parameterized.class)

View File

@ -34,8 +34,8 @@ import io.netty.util.internal.SocketUtils;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
final class Socks4ProxyServer extends ProxyServer {

View File

@ -43,8 +43,8 @@ import io.netty.util.internal.SocketUtils;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
final class Socks5ProxyServer extends ProxyServer {

View File

@ -43,8 +43,8 @@ import static io.netty.util.internal.StringUtil.NEWLINE;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
import static org.slf4j.Logger.ROOT_LOGGER_NAME;

View File

@ -20,6 +20,7 @@ import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.junit.Assert.*;

View File

@ -22,6 +22,7 @@ import org.junit.Test;
import javax.net.ssl.KeyManagerFactory;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
public class OpenSslCachingKeyMaterialProviderTest extends OpenSslKeyMaterialProviderTest {

View File

@ -66,10 +66,10 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import static io.netty.handler.ssl.OpenSslTestUtils.checkShouldUseKeyManagerFactory;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@RunWith(Parameterized.class)

View File

@ -18,11 +18,11 @@ package io.netty.handler.ssl;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;

View File

@ -94,12 +94,12 @@ import javax.net.ssl.X509ExtendedTrustManager;
import static io.netty.buffer.Unpooled.wrappedBuffer;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;

View File

@ -18,8 +18,8 @@ package io.netty.handler.timeout;
import org.junit.Test;
import static io.netty.handler.timeout.IdleStateEvent.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasToString;
import static org.junit.Assert.*;
public class IdleStateEventTest {
@Test

View File

@ -18,12 +18,15 @@ package io.netty.resolver.dns.macos;
import io.netty.resolver.dns.DnsServerAddressStream;
import io.netty.resolver.dns.DnsServerAddressStreamProvider;
import io.netty.resolver.dns.DnsServerAddressStreamProviders;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
public class MacOSDnsServerAddressStreamProviderTest {
@BeforeClass
@ -35,18 +38,18 @@ public class MacOSDnsServerAddressStreamProviderTest {
public void testStream() {
DnsServerAddressStreamProvider provider = new MacOSDnsServerAddressStreamProvider();
DnsServerAddressStream stream = provider.nameServerAddressStream("netty.io");
Assert.assertNotNull(stream);
Assert.assertNotEquals(0, stream.size());
assertNotNull(stream);
assertNotEquals(0, stream.size());
for (int i = 0; i < stream.size(); i++) {
Assert.assertNotEquals(0, stream.next().getPort());
assertNotEquals(0, stream.next().getPort());
}
}
@Test
public void testDefaultUseCorrectInstance() {
Assert.assertThat(DnsServerAddressStreamProviders.platformDefault(),
Matchers.instanceOf(MacOSDnsServerAddressStreamProvider.class));
assertThat(DnsServerAddressStreamProviders.platformDefault(),
instanceOf(MacOSDnsServerAddressStreamProvider.class));
}
}

View File

@ -23,13 +23,15 @@ import io.netty.resolver.AddressResolver;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
import io.netty.util.concurrent.Promise;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import java.net.SocketAddress;
import java.nio.channels.UnsupportedAddressTypeException;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertTrue;
public class DnsAddressResolverGroupTest {
@Test
public void testUseConfiguredEventLoop() throws InterruptedException {
@ -48,8 +50,9 @@ public class DnsAddressResolverGroupTest {
@Override
public void operationComplete(Future<Object> future) {
try {
Assert.assertThat(future.cause(), Matchers.instanceOf(UnsupportedAddressTypeException.class));
Assert.assertTrue(loop.inEventLoop());
assertThat(future.cause(),
instanceOf(UnsupportedAddressTypeException.class));
assertTrue(loop.inEventLoop());
promise.setSuccess(null);
} catch (Throwable cause) {
promise.setFailure(cause);

View File

@ -111,6 +111,7 @@ import static io.netty.handler.codec.dns.DnsRecordType.AAAA;
import static io.netty.handler.codec.dns.DnsRecordType.CNAME;
import static io.netty.resolver.dns.DnsServerAddresses.sequential;
import static java.util.Collections.singletonList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.instanceOf;

View File

@ -25,8 +25,8 @@ import java.util.IdentityHashMap;
import java.util.Set;
import static io.netty.resolver.dns.DefaultDnsServerAddressStreamProvider.defaultAddressList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
public class DnsServerAddressesTest {

View File

@ -33,12 +33,12 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class SearchDomainTest {

View File

@ -33,6 +33,7 @@ import java.net.ConnectException;
import java.net.Socket;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
import static org.junit.Assume.*;
import static io.netty.testsuite.transport.socket.SocketTestPermutation.BAD_HOST;

View File

@ -40,6 +40,7 @@ import java.util.Random;
import java.util.concurrent.atomic.AtomicReference;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
public class SocketFileRegionTest extends AbstractSocketTest {

View File

@ -58,13 +58,13 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import javax.net.ssl.SSLEngine;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.sameInstance;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
@RunWith(Parameterized.class)
public class SocketSslEchoTest extends AbstractSocketTest {

View File

@ -60,7 +60,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;

View File

@ -55,6 +55,7 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

View File

@ -31,6 +31,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.RejectedExecutionException;
import static io.netty.buffer.Unpooled.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

View File

@ -28,7 +28,7 @@ import java.io.ObjectOutputStream;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
@SuppressWarnings("DynamicRegexReplaceableByCompiledPattern")

View File

@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

View File

@ -26,6 +26,7 @@ import org.junit.Test;
import java.nio.channels.ClosedChannelException;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
public class ReentrantChannelTest extends BaseChannelTest {

View File

@ -40,6 +40,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

View File

@ -52,10 +52,10 @@ import java.util.concurrent.atomic.AtomicReference;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

View File

@ -32,7 +32,6 @@ import io.netty.util.concurrent.DefaultThreadFactory;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.RejectedExecutionHandlers;
import io.netty.util.concurrent.ThreadPerTaskExecutor;
import org.hamcrest.core.IsInstanceOf;
import org.junit.Test;
import java.io.IOException;
@ -50,6 +49,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.*;
public class NioEventLoopTest extends AbstractEventLoopTest {
@ -222,7 +223,7 @@ public class NioEventLoopTest extends AbstractEventLoopTest {
group.shutdownNow();
t.join();
group.terminationFuture().syncUninterruptibly();
assertThat(error.get(), IsInstanceOf.instanceOf(RejectedExecutionException.class));
assertThat(error.get(), instanceOf(RejectedExecutionException.class));
error.set(null);
}
}

View File

@ -33,7 +33,7 @@ import java.net.Socket;
import java.util.concurrent.CountDownLatch;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
public class OioEventLoopTest {
@Test

View File

@ -34,12 +34,12 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import static io.netty.channel.pool.ChannelPoolTestUtils.getLocalAddrId;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

View File

@ -54,6 +54,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;