From 05850da8638a5af14c7ee5f1ebf4e17cf10dd71a Mon Sep 17 00:00:00 2001 From: Prajwal Tuladhar Date: Wed, 27 Mar 2013 03:31:43 -0400 Subject: [PATCH] enable checkstyle for test source directory and fix checkstyle errors --- .../io/netty/buffer/AbstractByteBufTest.java | 1 - .../buffer/AbstractCompositeByteBufTest.java | 5 +- .../netty/buffer/ByteBufDerivationTest.java | 2 - .../io/netty/buffer/ByteBufStreamTest.java | 23 ++++--- .../io/netty/buffer/ConsolidationTest.java | 4 +- .../ReadOnlyDirectByteBufferBufTest.java | 5 +- ...ReadOnlyUnsafeDirectByteBufferBufTest.java | 2 +- .../java/io/netty/buffer/UnpooledTest.java | 1 - .../java/io/netty/buffer/package-info.java | 21 +++++++ .../handler/codec/http/CookieDecoderTest.java | 37 +++++++---- .../handler/codec/http/CookieEncoderTest.java | 13 ++-- .../codec/http/HttpClientCodecTest.java | 16 ++--- .../codec/http/HttpHeaderDateFormatTest.java | 48 +++++++------- .../codec/http/HttpObjecctAggregatorTest.java | 12 ++-- .../codec/http/HttpRequestEncoderTest.java | 3 +- .../codec/http/QueryStringDecoderTest.java | 3 - .../multipart/HttpPostRequestDecoderTest.java | 7 ++- .../codec/http/multipart/package-info.java | 20 ++++++ .../handler/codec/http/package-info.java | 20 ++++++ .../websocketx/WebSocketRequestBuilder.java | 34 +++++----- .../WebSocketServerProtocolHandlerTest.java | 45 +++++++------ .../codec/http/websocketx/package-info.java | 21 +++++++ .../codec/spdy/SpdySessionHandlerTest.java | 6 +- .../handler/codec/spdy/package-info.java | 20 ++++++ .../socks/SocksAuthResponseDecoderTest.java | 10 +-- .../socks/SocksCmdRequestDecoderTest.java | 10 ++- .../codec/socks/SocksCmdRequestTest.java | 26 ++++---- .../socks/SocksCmdResponseDecoderTest.java | 11 ++-- .../codec/socks/SocksInitRequestTest.java | 4 +- .../handler/codec/socks/package-info.java | 20 ++++++ .../codec/DelimiterBasedFrameDecoderTest.java | 33 +++++----- .../codec/LineBasedFrameDecoderTest.java | 9 ++- .../codec/ReplayingDecoderBufferTest.java | 12 ++-- .../handler/codec/bytes/package-info.java | 21 +++++++ .../handler/codec/compression/JZlibTest.java | 63 ++++++++----------- .../compression/SnappyFramedEncoderTest.java | 6 +- .../compression/SnappyIntegrationTest.java | 3 +- .../codec/compression/package-info.java | 21 +++++++ .../handler/codec/frame/package-info.java | 20 ++++++ ...tractCompatibleMarshallingDecoderTest.java | 4 +- ...RiverCompatibleMarshallingEncoderTest.java | 1 - ...BoundCompatibleMarshallingDecoderTest.java | 1 - ...verContextBoundMarshallingDecoderTest.java | 1 - .../RiverMarshallingDecoderTest.java | 4 +- ...LocalCompatibleMarshallingDecoderTest.java | 1 - ...iverThreadLocalMarshallingDecoderTest.java | 1 - ...erialCompatibleMarshallingEncoderTest.java | 1 - ...BoundCompatibleMarshallingDecoderTest.java | 1 - ...ialContextBoundMarshallingDecoderTest.java | 1 - .../SerialMarshallingDecoderTest.java | 3 +- .../SerialMarshallingEncoderTest.java | 2 +- ...LocalCompatibleMarshallingDecoderTest.java | 1 - ...rialThreadLocalMarshallingDecoderTest.java | 1 - .../codec/marshalling/package-info.java | 21 +++++++ .../io/netty/handler/codec/package-info.java | 20 ++++++ .../handler/codec/protobuf/package-info.java | 23 +++++++ .../codec/serialization/package-info.java | 22 +++++++ .../test/java/io/netty/util/NetUtilTest.java | 9 ++- .../java/io/netty/util/UniqueNameTest.java | 4 +- .../netty/util/internal/StringUtilTest.java | 2 +- .../internal/TypeParameterMatcherTest.java | 2 +- .../logging/InternalLoggerFactoryTest.java | 7 +-- .../util/internal/logging/package-info.java | 20 ++++++ .../io/netty/util/internal/package-info.java | 20 ++++++ .../test/java/io/netty/util/package-info.java | 20 ++++++ .../stream/ChunkedWriteHandlerTest.java | 16 +++-- .../io/netty/handler/stream/package-info.java | 20 ++++++ .../java/com/google/caliper/StandardVm.java | 15 ----- .../java/com/google/caliper/package-info.java | 20 ++++++ .../buffer/ByteBufAllocatorBenchmark.java | 2 +- .../netty/microbench/buffer/package-info.java | 20 ++++++ .../microbench/util/DefaultBenchmark.java | 3 +- .../netty/microbench/util/package-info.java | 20 ++++++ pom.xml | 1 + .../io/netty/verify/osgi/DependencyIT.java | 2 - .../io/netty/verify/osgi/package-info.java | 20 ++++++ .../java/io/netty/verify/osgi/UnitHelp.java | 3 +- .../io/netty/verify/osgi/package-info.java | 20 ++++++ .../io/netty/verify/osgi/package-info.java | 20 ++++++ .../transport/sctp/AbstractSctpTest.java | 2 +- .../transport/sctp/SctpEchoTest.java | 4 +- .../transport/sctp/SctpTestPermutation.java | 3 +- .../transport/sctp/package-info.java | 20 ++++++ .../socket/AbstractClientSocketTest.java | 3 +- .../transport/socket/AbstractSocketTest.java | 2 +- .../socket/DatagramMulticastTest.java | 1 - .../SocketShutdownOutputBySelfTest.java | 1 - .../transport/socket/SocketSslEchoTest.java | 1 - .../socket/SocketTestPermutation.java | 2 +- .../transport/socket/package-info.java | 20 ++++++ .../io/netty/testsuite/util/TestUtils.java | 7 ++- .../io/netty/testsuite/util/package-info.java | 20 ++++++ .../netty/test/udt/nio/AbstractUdtTest.java | 2 +- .../nio/NioUdtByteRendezvousChannelTest.java | 2 - .../NioUdtMessageRendezvousChannelTest.java | 3 - .../test/udt/nio/NioUdtProviderTest.java | 2 +- .../io/netty/test/udt/nio/package-info.java | 21 +++++++ .../java/io/netty/test/udt/util/BootHelp.java | 2 - .../io/netty/test/udt/util/CaliperBench.java | 1 - .../netty/test/udt/util/CaliperMeasure.java | 27 ++++---- .../io/netty/test/udt/util/CaliperRunner.java | 2 +- .../netty/test/udt/util/EchoByteHandler.java | 4 -- .../java/io/netty/test/udt/util/UnitHelp.java | 6 +- .../java/io/netty/bootstrap/package-info.java | 20 ++++++ .../netty/channel/AbstractEventLoopTest.java | 1 - .../channel/DefaultChannelPipelineTest.java | 38 ++++------- .../group/DefaultChannnelGroupTest.java | 1 - .../io/netty/channel/group/package-info.java | 20 ++++++ .../local/LocalChannelRegistryTest.java | 1 - .../local/LocalTransportThreadModelTest.java | 1 - .../local/LocalTransportThreadModelTest2.java | 2 - .../io/netty/channel/local/package-info.java | 20 ++++++ .../io/netty/channel/nio/package-info.java | 20 ++++++ .../java/io/netty/channel/package-info.java | 20 ++++++ 114 files changed, 947 insertions(+), 368 deletions(-) create mode 100644 buffer/src/test/java/io/netty/buffer/package-info.java create mode 100644 codec-http/src/test/java/io/netty/handler/codec/http/multipart/package-info.java create mode 100644 codec-http/src/test/java/io/netty/handler/codec/http/package-info.java create mode 100644 codec-http/src/test/java/io/netty/handler/codec/http/websocketx/package-info.java create mode 100644 codec-http/src/test/java/io/netty/handler/codec/spdy/package-info.java create mode 100644 codec-socks/src/test/java/io/netty/handler/codec/socks/package-info.java create mode 100644 codec/src/test/java/io/netty/handler/codec/bytes/package-info.java create mode 100644 codec/src/test/java/io/netty/handler/codec/compression/package-info.java create mode 100644 codec/src/test/java/io/netty/handler/codec/frame/package-info.java create mode 100644 codec/src/test/java/io/netty/handler/codec/marshalling/package-info.java create mode 100644 codec/src/test/java/io/netty/handler/codec/package-info.java create mode 100644 codec/src/test/java/io/netty/handler/codec/protobuf/package-info.java create mode 100644 codec/src/test/java/io/netty/handler/codec/serialization/package-info.java create mode 100644 common/src/test/java/io/netty/util/internal/logging/package-info.java create mode 100644 common/src/test/java/io/netty/util/internal/package-info.java create mode 100644 common/src/test/java/io/netty/util/package-info.java create mode 100644 handler/src/test/java/io/netty/handler/stream/package-info.java create mode 100644 microbench/src/test/java/com/google/caliper/package-info.java create mode 100644 microbench/src/test/java/io/netty/microbench/buffer/package-info.java create mode 100644 microbench/src/test/java/io/netty/microbench/util/package-info.java create mode 100644 testsuite-osgi/testsuite-osgi-deps/src/test/java/io/netty/verify/osgi/package-info.java create mode 100644 testsuite-osgi/testsuite-osgi-exam/src/test/java/io/netty/verify/osgi/package-info.java create mode 100644 testsuite-osgi/testsuite-osgi-split/src/test/java/io/netty/verify/osgi/package-info.java create mode 100644 testsuite/src/test/java/io/netty/testsuite/transport/sctp/package-info.java create mode 100644 testsuite/src/test/java/io/netty/testsuite/transport/socket/package-info.java create mode 100644 testsuite/src/test/java/io/netty/testsuite/util/package-info.java create mode 100644 transport-udt/src/test/java/io/netty/test/udt/nio/package-info.java create mode 100644 transport/src/test/java/io/netty/bootstrap/package-info.java create mode 100644 transport/src/test/java/io/netty/channel/group/package-info.java create mode 100644 transport/src/test/java/io/netty/channel/local/package-info.java create mode 100644 transport/src/test/java/io/netty/channel/nio/package-info.java create mode 100644 transport/src/test/java/io/netty/channel/package-info.java diff --git a/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java b/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java index 680ec3f6e3..b6ab641bef 100644 --- a/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java @@ -1519,7 +1519,6 @@ public abstract class AbstractByteBufTest { buffer.setIndex(0, value.length); buffer.setBytes(0, value); - assertEquals(0, buffer.compareTo(wrappedBuffer(value))); assertEquals(0, buffer.compareTo(wrappedBuffer(value).order(LITTLE_ENDIAN))); diff --git a/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java b/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java index b3c013774c..d6c275fc88 100644 --- a/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java @@ -99,7 +99,8 @@ public abstract class AbstractCompositeByteBufTest extends */ @Test public void testComponentAtOffset() { - CompositeByteBuf buf = (CompositeByteBuf) wrappedBuffer(new byte[]{1, 2, 3, 4, 5}, new byte[]{4, 5, 6, 7, 8, 9, 26}); + CompositeByteBuf buf = (CompositeByteBuf) wrappedBuffer(new byte[]{1, 2, 3, 4, 5}, + new byte[]{4, 5, 6, 7, 8, 9, 26}); //Ensure that a random place will be fine assertEquals(5, buf.componentAtOffset(2).capacity()); @@ -412,7 +413,7 @@ public abstract class AbstractCompositeByteBufTest extends assertFalse(BufUtil.equals(a, b)); } - @Test + @Test public void testEmptyBuffer() { ByteBuf b = freeLater(wrappedBuffer(new byte[]{1, 2}, new byte[]{3, 4})); b.readBytes(new byte[4]); diff --git a/buffer/src/test/java/io/netty/buffer/ByteBufDerivationTest.java b/buffer/src/test/java/io/netty/buffer/ByteBufDerivationTest.java index 4a23f8c64e..ad60acb6b2 100644 --- a/buffer/src/test/java/io/netty/buffer/ByteBufDerivationTest.java +++ b/buffer/src/test/java/io/netty/buffer/ByteBufDerivationTest.java @@ -105,8 +105,6 @@ public class ByteBufDerivationTest { ro.setIndex(2, 6); assertThat(buf.readerIndex(), is(1)); - assertThat(buf.writerIndex(), is(7)); - } @Test diff --git a/buffer/src/test/java/io/netty/buffer/ByteBufStreamTest.java b/buffer/src/test/java/io/netty/buffer/ByteBufStreamTest.java index c725f87751..e23169219e 100644 --- a/buffer/src/test/java/io/netty/buffer/ByteBufStreamTest.java +++ b/buffer/src/test/java/io/netty/buffer/ByteBufStreamTest.java @@ -22,7 +22,6 @@ import java.nio.charset.Charset; import static org.junit.Assert.*; - /** * Tests channel buffer streams */ @@ -173,33 +172,33 @@ public class ByteBufStreamTest { @Test public void testReadLine() throws Exception { - Charset utf8=Charset.forName("UTF-8"); + Charset utf8 = Charset.forName("UTF-8"); ByteBuf buf = Unpooled.buffer(); ByteBufInputStream in = new ByteBufInputStream(buf); String s = in.readLine(); assertNull(s); - int charCount=5;//total chars in the string below without new line characters + int charCount = 5; //total chars in the string below without new line characters byte[] abc = "a\nb\r\nc\nd\ne".getBytes(utf8); buf.writeBytes(abc); in.mark(charCount); - assertEquals("a",in.readLine()); - assertEquals("b",in.readLine()); - assertEquals("c",in.readLine()); - assertEquals("d",in.readLine()); - assertEquals("e",in.readLine()); + assertEquals("a", in.readLine()); + assertEquals("b", in.readLine()); + assertEquals("c", in.readLine()); + assertEquals("d", in.readLine()); + assertEquals("e", in.readLine()); assertNull(in.readLine()); in.reset(); - int count=0; - while(in.readLine() != null){ + int count = 0; + while (in.readLine() != null) { ++count; - if(count > charCount){ + if (count > charCount) { fail("readLine() should have returned null"); } } - assertEquals(charCount,count); + assertEquals(charCount, count); in.close(); } } diff --git a/buffer/src/test/java/io/netty/buffer/ConsolidationTest.java b/buffer/src/test/java/io/netty/buffer/ConsolidationTest.java index addb356490..dcbccacb66 100644 --- a/buffer/src/test/java/io/netty/buffer/ConsolidationTest.java +++ b/buffer/src/test/java/io/netty/buffer/ConsolidationTest.java @@ -41,7 +41,7 @@ public class ConsolidationTest { public void shouldConsolidationInSequence() { ByteBuf currentBuffer = wrappedBuffer(wrappedBuffer("a".getBytes()), wrappedBuffer("=".getBytes())); currentBuffer = wrappedBuffer(currentBuffer, wrappedBuffer("1".getBytes()), wrappedBuffer("&".getBytes())); - + currentBuffer = wrappedBuffer(currentBuffer, wrappedBuffer("b".getBytes()), wrappedBuffer("=".getBytes())); currentBuffer = wrappedBuffer(currentBuffer, wrappedBuffer("2".getBytes()), wrappedBuffer("&".getBytes())); @@ -60,5 +60,5 @@ public class ConsolidationTest { currentBuffer.release(); copy.release(); - } + } } diff --git a/buffer/src/test/java/io/netty/buffer/ReadOnlyDirectByteBufferBufTest.java b/buffer/src/test/java/io/netty/buffer/ReadOnlyDirectByteBufferBufTest.java index f0a2082611..9c7ff84fcf 100644 --- a/buffer/src/test/java/io/netty/buffer/ReadOnlyDirectByteBufferBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/ReadOnlyDirectByteBufferBufTest.java @@ -44,7 +44,6 @@ public class ReadOnlyDirectByteBufferBufTest { buf.setByte(0, 1); } - @Test(expected = ReadOnlyBufferException.class) public void testSetInt() { ByteBuf buf = buffer(allocate(8).asReadOnlyBuffer()); @@ -109,10 +108,10 @@ public class ReadOnlyDirectByteBufferBufTest { Assert.assertFalse(buf.isReadable()); } - @Test public void testGetReadShort() { - ByteBuf buf = buffer(((ByteBuffer) allocate(8).putShort((short) 1).putShort((short) 2).flip()).asReadOnlyBuffer()); + ByteBuf buf = buffer(((ByteBuffer) allocate(8).putShort((short) 1) + .putShort((short) 2).flip()).asReadOnlyBuffer()); Assert.assertEquals(1, buf.getShort(0)); Assert.assertEquals(2, buf.getShort(2)); diff --git a/buffer/src/test/java/io/netty/buffer/ReadOnlyUnsafeDirectByteBufferBufTest.java b/buffer/src/test/java/io/netty/buffer/ReadOnlyUnsafeDirectByteBufferBufTest.java index ffef7f8ac4..1a69725a27 100644 --- a/buffer/src/test/java/io/netty/buffer/ReadOnlyUnsafeDirectByteBufferBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/ReadOnlyUnsafeDirectByteBufferBufTest.java @@ -28,7 +28,7 @@ public class ReadOnlyUnsafeDirectByteBufferBufTest extends ReadOnlyDirectByteBuf * Needs unsafe to run */ @BeforeClass - public static void assumeConditions(){ + public static void assumeConditions() { assumeTrue(PlatformDependent.hasUnsafe()); } diff --git a/buffer/src/test/java/io/netty/buffer/UnpooledTest.java b/buffer/src/test/java/io/netty/buffer/UnpooledTest.java index 9f61c6533e..5258b4f592 100644 --- a/buffer/src/test/java/io/netty/buffer/UnpooledTest.java +++ b/buffer/src/test/java/io/netty/buffer/UnpooledTest.java @@ -568,7 +568,6 @@ public class UnpooledTest { assertEquals(0, Unpooled.copyBoolean(null).capacity()); assertEquals(0, Unpooled.copyBoolean(new boolean[0]).capacity()); - } @Test diff --git a/buffer/src/test/java/io/netty/buffer/package-info.java b/buffer/src/test/java/io/netty/buffer/package-info.java new file mode 100644 index 0000000000..4271c3f5c9 --- /dev/null +++ b/buffer/src/test/java/io/netty/buffer/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Byte Buffer test classes + **/ + +package io.netty.buffer; diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/CookieDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/CookieDecoderTest.java index e565d3e362..8192f5f580 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/CookieDecoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/CookieDecoderTest.java @@ -29,7 +29,8 @@ public class CookieDecoderTest { @Test public void testDecodingSingleCookieV0() { String cookieString = "myCookie=myValue;expires=XXX;path=/apathsomewhere;domain=.adomainsomewhere;secure;"; - cookieString = cookieString.replace("XXX", new HttpHeaderDateFormat().format(new Date(System.currentTimeMillis() + 50000))); + cookieString = cookieString.replace("XXX", + new HttpHeaderDateFormat().format(new Date(System.currentTimeMillis() + 50000))); Set cookies = CookieDecoder.decode(cookieString); assertEquals(1, cookies.size()); @@ -60,7 +61,9 @@ public class CookieDecoderTest { @Test public void testDecodingSingleCookieV0ExtraParamsIgnored() { - String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;domain=.adomainsomewhere;secure;comment=this is a comment;version=0;commentURL=http://aurl.com;port=\"80,8080\";discard;"; + String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;" + + "domain=.adomainsomewhere;secure;comment=this is a comment;version=0;" + + "commentURL=http://aurl.com;port=\"80,8080\";discard;"; Set cookies = CookieDecoder.decode(cookieString); assertEquals(1, cookies.size()); Cookie cookie = cookies.iterator().next(); @@ -78,7 +81,8 @@ public class CookieDecoderTest { } @Test public void testDecodingSingleCookieV1() { - String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;domain=.adomainsomewhere;secure;comment=this is a comment;version=1;"; + String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;" + + "domain=.adomainsomewhere;secure;comment=this is a comment;version=1;"; Set cookies = CookieDecoder.decode(cookieString); assertEquals(1, cookies.size()); Cookie cookie = cookies.iterator().next(); @@ -97,7 +101,9 @@ public class CookieDecoderTest { @Test public void testDecodingSingleCookieV1ExtraParamsIgnored() { - String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;domain=.adomainsomewhere;secure;comment=this is a comment;version=1;commentURL=http://aurl.com;port='80,8080';discard;"; + String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;" + + "domain=.adomainsomewhere;secure;comment=this is a comment;version=1;" + + "commentURL=http://aurl.com;port='80,8080';discard;"; Set cookies = CookieDecoder.decode(cookieString); assertEquals(1, cookies.size()); Cookie cookie = cookies.iterator().next(); @@ -115,7 +121,9 @@ public class CookieDecoderTest { } @Test public void testDecodingSingleCookieV2() { - String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;domain=.adomainsomewhere;secure;comment=this is a comment;version=2;commentURL=http://aurl.com;port=\"80,8080\";discard;"; + String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;" + + "domain=.adomainsomewhere;secure;comment=this is a comment;version=2;" + + "commentURL=http://aurl.com;port=\"80,8080\";discard;"; Set cookies = CookieDecoder.decode(cookieString); assertEquals(1, cookies.size()); Cookie cookie = cookies.iterator().next(); @@ -134,11 +142,14 @@ public class CookieDecoderTest { assertEquals(2, cookie.getVersion()); } - @Test public void testDecodingMultipleCookies() { - String c1 = "myCookie=myValue;max-age=50;path=/apathsomewhere;domain=.adomainsomewhere;secure;comment=this is a comment;version=2;commentURL=\"http://aurl.com\";port='80,8080';discard;"; - String c2 = "myCookie2=myValue2;max-age=0;path=/anotherpathsomewhere;domain=.anotherdomainsomewhere;comment=this is another comment;version=2;commentURL=http://anotherurl.com;"; + String c1 = "myCookie=myValue;max-age=50;path=/apathsomewhere;" + + "domain=.adomainsomewhere;secure;comment=this is a comment;version=2;" + + "commentURL=\"http://aurl.com\";port='80,8080';discard;"; + String c2 = "myCookie2=myValue2;max-age=0;path=/anotherpathsomewhere;" + + "domain=.anotherdomainsomewhere;comment=this is another comment;version=2;" + + "commentURL=http://anotherurl.com;"; String c3 = "myCookie3=myValue3;max-age=0;version=2;"; Set cookies = CookieDecoder.decode(c1 + c2 + c3); @@ -173,7 +184,7 @@ public class CookieDecoderTest { cookie = it.next(); assertNotNull(cookie); assertEquals("myValue3", cookie.getValue()); - assertNull( cookie.getComment()); + assertNull(cookie.getComment()); assertNull(cookie.getCommentUrl()); assertNull(cookie.getDomain()); assertFalse(cookie.isDiscard()); @@ -268,7 +279,6 @@ public class CookieDecoderTest { "g=\"\\\\\"," + "h=\"';,\\x\""; - Set cookies = CookieDecoder.decode(source); Iterator it = cookies.iterator(); Cookie c; @@ -315,7 +325,8 @@ public class CookieDecoderTest { "kw-2E343B92-B097-442c-BFA5-BE371E0325A2=unfinished furniture; " + "__utma=48461872.1094088325.1258140131.1258140131.1258140131.1; " + "__utmb=48461872.13.10.1258140131; __utmc=48461872; " + - "__utmz=48461872.1258140131.1.1.utmcsr=overstock.com|utmccn=(referral)|utmcmd=referral|utmcct=/Home-Garden/Furniture/Clearance,/clearance,/32/dept.html"; + "__utmz=48461872.1258140131.1.1.utmcsr=overstock.com|utmccn=(referral)|" + + "utmcmd=referral|utmcct=/Home-Garden/Furniture/Clearance,/clearance,/32/dept.html"; Set cookies = CookieDecoder.decode(source); Iterator it = cookies.iterator(); Cookie c; @@ -334,7 +345,9 @@ public class CookieDecoderTest { c = it.next(); assertEquals("__utmz", c.getName()); - assertEquals("48461872.1258140131.1.1.utmcsr=overstock.com|utmccn=(referral)|utmcmd=referral|utmcct=/Home-Garden/Furniture/Clearance,/clearance,/32/dept.html", c.getValue()); + assertEquals("48461872.1258140131.1.1.utmcsr=overstock.com|" + + "utmccn=(referral)|utmcmd=referral|utmcct=/Home-Garden/Furniture/Clearance,/clearance,/32/dept.html", + c.getValue()); c = it.next(); assertEquals("ARPT", c.getName()); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/CookieEncoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/CookieEncoderTest.java index 7c04c541d1..00aa3289c8 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/CookieEncoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/CookieEncoderTest.java @@ -58,7 +58,8 @@ public class CookieEncoderTest { @Test public void testEncodingSingleCookieV1() { - String result = "myCookie=myValue; Max-Age=50; Path=\"/apathsomewhere\"; Domain=.adomainsomewhere; Secure; Comment=\"this is a Comment\"; Version=1"; + String result = "myCookie=myValue; Max-Age=50; Path=\"/apathsomewhere\"; " + + "Domain=.adomainsomewhere; Secure; Comment=\"this is a Comment\"; Version=1"; Cookie cookie = new DefaultCookie("myCookie", "myValue"); cookie.setVersion(1); cookie.setComment("this is a Comment"); @@ -72,7 +73,9 @@ public class CookieEncoderTest { @Test public void testEncodingSingleCookieV2() { - String result = "myCookie=myValue; Max-Age=50; Path=\"/apathsomewhere\"; Domain=.adomainsomewhere; Secure; Comment=\"this is a Comment\"; Version=1; CommentURL=\"http://aurl.com\"; Port=\"80,8080\"; Discard"; + String result = "myCookie=myValue; Max-Age=50; Path=\"/apathsomewhere\"; Domain=.adomainsomewhere; " + + "Secure; Comment=\"this is a Comment\"; Version=1; CommentURL=\"http://aurl.com\"; " + + "Port=\"80,8080\"; Discard"; Cookie cookie = new DefaultCookie("myCookie", "myValue"); cookie.setVersion(1); cookie.setComment("this is a Comment"); @@ -89,8 +92,10 @@ public class CookieEncoderTest { @Test public void testEncodingMultipleClientCookies() { - String c1 = "$Version=1; myCookie=myValue; $Path=\"/apathsomewhere\"; $Domain=.adomainsomewhere; $Port=\"80,8080\"; "; - String c2 = "$Version=1; myCookie2=myValue2; $Path=\"/anotherpathsomewhere\"; $Domain=.anotherdomainsomewhere; "; + String c1 = "$Version=1; myCookie=myValue; $Path=\"/apathsomewhere\"; " + + "$Domain=.adomainsomewhere; $Port=\"80,8080\"; "; + String c2 = "$Version=1; myCookie2=myValue2; $Path=\"/anotherpathsomewhere\"; " + + "$Domain=.anotherdomainsomewhere; "; String c3 = "$Version=1; myCookie3=myValue3"; Cookie cookie = new DefaultCookie("myCookie", "myValue"); cookie.setVersion(1); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java index 7d92efffb2..5ba19f180b 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java @@ -26,13 +26,14 @@ import static org.junit.Assert.*; public class HttpClientCodecTest { - private static final String RESPONSE = "HTTP/1.0 200 OK\r\n" + "Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n" + "Content-Type: text/html\r\n" + "Content-Length: 28\r\n" + "\r\n" + private static final String RESPONSE = "HTTP/1.0 200 OK\r\n" + "Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n" + + "Content-Type: text/html\r\n" + "Content-Length: 28\r\n" + "\r\n" + "\r\n"; - private static final String INCOMPLETE_CHUNKED_RESPONSE = "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" - +"5\r\n" + "first\r\n" + "6\r\n" + "second\r\n" + "0\r\n"; + private static final String INCOMPLETE_CHUNKED_RESPONSE = "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" + + "Transfer-Encoding: chunked\r\n" + "\r\n" + + "5\r\n" + "first\r\n" + "6\r\n" + "second\r\n" + "0\r\n"; private static final String CHUNKED_RESPONSE = INCOMPLETE_CHUNKED_RESPONSE + "\r\n"; - @Test public void testFailsNotOnRequestResponse() { HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true); @@ -58,7 +59,8 @@ public class HttpClientCodecTest { HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true); EmbeddedByteChannel ch = new EmbeddedByteChannel(codec); - assertTrue(ch.writeOutbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/"))); + assertTrue(ch.writeOutbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, + "http://localhost/"))); assertNotNull(ch.readOutbound()); try { @@ -67,7 +69,6 @@ public class HttpClientCodecTest { } catch (CodecException e) { assertTrue(e instanceof PrematureChannelClosureException); } - } @Test @@ -84,6 +85,5 @@ public class HttpClientCodecTest { } catch (CodecException e) { assertTrue(e instanceof PrematureChannelClosureException); } - } -} \ No newline at end of file +} diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpHeaderDateFormatTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpHeaderDateFormatTest.java index b5585c07f7..a72c42024a 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpHeaderDateFormatTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpHeaderDateFormatTest.java @@ -34,31 +34,29 @@ public class HttpHeaderDateFormatTest { public void testParse() throws ParseException { HttpHeaderDateFormat format = new HttpHeaderDateFormat(); - { - final Date parsed = format.parse("Sun, 6 Nov 1994 08:49:37 GMT"); - Assert.assertNotNull(parsed); - Assert.assertEquals(DATE, parsed); - } - { - final Date parsed = format.parse("Sun, 06 Nov 1994 08:49:37 GMT"); - Assert.assertNotNull(parsed); - Assert.assertEquals(DATE, parsed); - } - { - final Date parsed = format.parse("Sunday, 06-Nov-94 08:49:37 GMT"); - Assert.assertNotNull(parsed); - Assert.assertEquals(DATE, parsed); - } - { - final Date parsed = format.parse("Sunday, 6-Nov-94 08:49:37 GMT"); - Assert.assertNotNull(parsed); - Assert.assertEquals(DATE, parsed); - } - { - final Date parsed = format.parse("Sun Nov 6 08:49:37 1994"); - Assert.assertNotNull(parsed); - Assert.assertEquals(DATE, parsed); - } + final Date parsedDateWithSingleDigitDay = format.parse("Sun, 6 Nov 1994 08:49:37 GMT"); + Assert.assertNotNull(parsedDateWithSingleDigitDay); + Assert.assertEquals(DATE, parsedDateWithSingleDigitDay); + + final Date parsedDateWithDoubleDigitDay = format.parse("Sun, 06 Nov 1994 08:49:37 GMT"); + Assert.assertNotNull(parsedDateWithDoubleDigitDay); + Assert.assertEquals(DATE, parsedDateWithDoubleDigitDay); + + final Date parsedDateWithDashSeparatorSingleDigitDay = format.parse("Sunday, 06-Nov-94 08:49:37 GMT"); + Assert.assertNotNull(parsedDateWithDashSeparatorSingleDigitDay); + Assert.assertEquals(DATE, parsedDateWithDashSeparatorSingleDigitDay); + + final Date parsedDateWithSingleDoubleDigitDay = format.parse("Sunday, 6-Nov-94 08:49:37 GMT"); + Assert.assertNotNull(parsedDateWithSingleDoubleDigitDay); + Assert.assertEquals(DATE, parsedDateWithSingleDoubleDigitDay); + + final Date parsedDateWithoutGMT = format.parse("Sun Nov 6 08:49:37 1994"); + Assert.assertNotNull(parsedDateWithoutGMT); + Assert.assertEquals(DATE, parsedDateWithoutGMT); + } + + private Date parseDate(HttpHeaderDateFormat dateFormat, String dateStr) throws ParseException { + return dateFormat.parse(dateStr); } @Test diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpObjecctAggregatorTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpObjecctAggregatorTest.java index 01152c7436..30345107c7 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpObjecctAggregatorTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpObjecctAggregatorTest.java @@ -52,11 +52,11 @@ public class HttpObjecctAggregatorTest { DefaultFullHttpRequest aggratedMessage = (DefaultFullHttpRequest) embedder.readInbound(); assertNotNull(aggratedMessage); - assertEquals(chunk1.data().readableBytes() + chunk2.data().readableBytes(), HttpHeaders.getContentLength(aggratedMessage)); + assertEquals(chunk1.data().readableBytes() + chunk2.data().readableBytes(), + HttpHeaders.getContentLength(aggratedMessage)); assertEquals(aggratedMessage.headers().get("X-Test"), Boolean.TRUE.toString()); checkContentBuffer(aggratedMessage); assertNull(embedder.readInbound()); - } private static void checkContentBuffer(DefaultFullHttpRequest aggregatedMessage) { @@ -93,16 +93,15 @@ public class HttpObjecctAggregatorTest { DefaultFullHttpRequest aggratedMessage = (DefaultFullHttpRequest) embedder.readInbound(); assertNotNull(aggratedMessage); - assertEquals(chunk1.data().readableBytes() + chunk2.data().readableBytes(), HttpHeaders.getContentLength(aggratedMessage)); + assertEquals(chunk1.data().readableBytes() + chunk2.data().readableBytes(), + HttpHeaders.getContentLength(aggratedMessage)); assertEquals(aggratedMessage.headers().get("X-Test"), Boolean.TRUE.toString()); assertEquals(aggratedMessage.headers().get("X-Trailer"), Boolean.TRUE.toString()); checkContentBuffer(aggratedMessage); assertNull(embedder.readInbound()); - } - @Test(expected = TooLongFrameException.class) public void testTooLongFrameException() { HttpObjectAggregator aggr = new HttpObjectAggregator(4); @@ -115,7 +114,6 @@ public class HttpObjecctAggregatorTest { assertFalse(embedder.writeInbound(chunk1)); embedder.writeInbound(chunk2); fail(); - } @Test(expected = IllegalArgumentException.class) @@ -125,7 +123,7 @@ public class HttpObjecctAggregatorTest { @Test(expected = IllegalArgumentException.class) public void testInvalidMaxCumulationBufferComponents() { - HttpObjectAggregator aggr= new HttpObjectAggregator(Integer.MAX_VALUE); + HttpObjectAggregator aggr = new HttpObjectAggregator(Integer.MAX_VALUE); aggr.setMaxCumulationBufferComponents(1); } diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpRequestEncoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpRequestEncoderTest.java index 3a6aed1616..3d13cf9fae 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpRequestEncoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpRequestEncoderTest.java @@ -37,7 +37,6 @@ public class HttpRequestEncoderTest { assertEquals("GET http://localhost/ HTTP/1.1\r\n", req); } - @Test public void testUriWithPath() throws Exception { HttpRequestEncoder encoder = new HttpRequestEncoder(); @@ -47,4 +46,4 @@ public class HttpRequestEncoderTest { String req = buffer.toString(Charset.forName("US-ASCII")); assertEquals("GET http://localhost/ HTTP/1.1\r\n", req); } -} \ No newline at end of file +} diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/QueryStringDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/QueryStringDecoderTest.java index 179b55c526..7877feb521 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/QueryStringDecoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/QueryStringDecoderTest.java @@ -184,7 +184,6 @@ public class QueryStringDecoderTest { Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals("value1", entry.getValue().get(0)); - entry = entries.next(); Assert.assertEquals("param2", entry.getKey()); Assert.assertEquals(1, entry.getValue().size()); @@ -213,7 +212,6 @@ public class QueryStringDecoderTest { Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals("value1", entry.getValue().get(0)); - entry = entries.next(); Assert.assertEquals("param2", entry.getKey()); Assert.assertEquals(1, entry.getValue().size()); @@ -242,7 +240,6 @@ public class QueryStringDecoderTest { Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals("value1", entry.getValue().get(0)); - entry = entries.next(); Assert.assertEquals("param2", entry.getKey()); Assert.assertEquals(1, entry.getValue().size()); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoderTest.java index d746864d0c..a76f245377 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoderTest.java @@ -36,7 +36,8 @@ public class HttpPostRequestDecoderTest { public void testBinaryStreamUpload() throws Exception { final String boundary = "dLV9Wyq26L_-JQxk6ferf-RT153LhOO"; - final DefaultHttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "http://localhost"); + final DefaultHttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, + "http://localhost"); req.setDecoderResult(DecoderResult.SUCCESS); req.headers().add(HttpHeaders.Names.CONTENT_TYPE, "multipart/form-data; boundary=" + boundary); @@ -77,7 +78,8 @@ public class HttpPostRequestDecoderTest { public void testFullHttpRequestUpload() throws Exception { final String boundary = "dLV9Wyq26L_-JQxk6ferf-RT153LhOO"; - final DefaultFullHttpRequest req = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "http://localhost"); + final DefaultFullHttpRequest req = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, + "http://localhost"); req.setDecoderResult(DecoderResult.SUCCESS); req.headers().add(HttpHeaders.Names.CONTENT_TYPE, "multipart/form-data; boundary=" + boundary); @@ -100,6 +102,5 @@ public class HttpPostRequestDecoderTest { // Create decoder instance to test. final HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(inMemoryFactory, req); assertFalse(decoder.getBodyHttpDatas().isEmpty()); - } } diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/multipart/package-info.java b/codec-http/src/test/java/io/netty/handler/codec/http/multipart/package-info.java new file mode 100644 index 0000000000..ef01b48147 --- /dev/null +++ b/codec-http/src/test/java/io/netty/handler/codec/http/multipart/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test classes for HTTP multipart codec. + */ +package io.netty.handler.codec.http.multipart; diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/package-info.java b/codec-http/src/test/java/io/netty/handler/codec/http/package-info.java new file mode 100644 index 0000000000..f3545575a7 --- /dev/null +++ b/codec-http/src/test/java/io/netty/handler/codec/http/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test classes for encoder, decoder and their related message types for HTTP. + */ +package io.netty.handler.codec.http; diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketRequestBuilder.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketRequestBuilder.java index 2b71d25311..71e22adaf9 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketRequestBuilder.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketRequestBuilder.java @@ -1,12 +1,12 @@ /* * Copyright 2012 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: - * + * * http://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 @@ -27,7 +27,7 @@ import static io.netty.handler.codec.http.HttpHeaders.Values.*; import static io.netty.handler.codec.http.HttpVersion.*; public class WebSocketRequestBuilder { - + private HttpVersion httpVersion; private HttpMethod method; private String uri; @@ -37,17 +37,17 @@ public class WebSocketRequestBuilder { private String key; private String origin; private WebSocketVersion version; - + public WebSocketRequestBuilder httpVersion(HttpVersion httpVersion) { this.httpVersion = httpVersion; return this; } - + public WebSocketRequestBuilder method(HttpMethod method) { this.method = method; return this; } - + public WebSocketRequestBuilder uri(String uri) { this.uri = uri; return this; @@ -57,46 +57,46 @@ public class WebSocketRequestBuilder { this.host = host; return this; } - + public WebSocketRequestBuilder upgrade(String upgrade) { this.upgrade = upgrade; return this; } - + public WebSocketRequestBuilder connection(String connection) { this.connection = connection; return this; } - + public WebSocketRequestBuilder key(String key) { this.key = key; return this; } - + public WebSocketRequestBuilder origin(String origin) { this.origin = origin; return this; } - + public WebSocketRequestBuilder version13() { version = WebSocketVersion.V13; return this; } - + public WebSocketRequestBuilder version8() { version = WebSocketVersion.V08; return this; } - + public WebSocketRequestBuilder version00() { version = null; return this; } - + public WebSocketRequestBuilder noVersion() { return this; } - + public FullHttpRequest build() { FullHttpRequest req = new DefaultFullHttpRequest(httpVersion, method, uri); HttpHeaders headers = req.headers(); @@ -121,7 +121,7 @@ public class WebSocketRequestBuilder { } return req; } - + public static HttpRequest sucessful() { return new WebSocketRequestBuilder().httpVersion(HTTP_1_1) .method(HttpMethod.GET) diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java index 48db38f6b0..be8698b959 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java @@ -1,12 +1,12 @@ /* * Copyright 2012 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: - * + * * http://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 @@ -45,24 +45,22 @@ public class WebSocketServerProtocolHandlerTest { public void testHttpUpgradeRequest() throws Exception { EmbeddedMessageChannel ch = createChannel(new MockOutboundHandler()); ChannelHandlerContext handshakerCtx = ch.pipeline().context(WebSocketServerProtocolHandshakeHandler.class); - writeUpgradeRequest(ch); - assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus()); assertNotNull(WebSocketServerProtocolHandler.getHandshaker(handshakerCtx)); } - - @Test + + @Test public void testSubsequentHttpRequestsAfterUpgradeShouldReturn403() throws Exception { EmbeddedMessageChannel ch = createChannel(new MockOutboundHandler()); - + writeUpgradeRequest(ch); assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus()); - + ch.writeInbound(new DefaultFullHttpRequest(HTTP_1_1, HttpMethod.GET, "/test")); assertEquals(FORBIDDEN, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus()); } - + @Test public void testHttpUpgradeRequestInvalidUpgradeHeader() { EmbeddedMessageChannel ch = createChannel(); @@ -73,15 +71,14 @@ public class WebSocketServerProtocolHandlerTest { .version00() .upgrade("BogusSocket") .build(); - + ch.writeInbound(httpRequestWithEntity); - + FullHttpResponse response = getHttpResponse(ch); assertEquals(BAD_REQUEST, response.getStatus()); assertEquals("not a WebSocket handshake request: missing upgrade", getResponseMessage(response)); - } - + @Test public void testHttpUpgradeRequestMissingWSKeyHeader() { EmbeddedMessageChannel ch = createChannel(); @@ -93,14 +90,14 @@ public class WebSocketServerProtocolHandlerTest { .upgrade(WEBSOCKET.toLowerCase()) .version13() .build(); - + ch.writeInbound(httpRequest); - + FullHttpResponse response = getHttpResponse(ch); assertEquals(BAD_REQUEST, response.getStatus()); assertEquals("not a WebSocket request: missing key", getResponseMessage(response)); } - + @Test public void testHandleTextFrame() { CustomTextFrameHandler customTextFrameHandler = new CustomTextFrameHandler(); @@ -108,16 +105,16 @@ public class WebSocketServerProtocolHandlerTest { writeUpgradeRequest(ch); // Removing the HttpRequestDecoder as we are writing a TextWebSocketFrame so decoding is not neccessary. ch.pipeline().remove(HttpRequestDecoder.class); - + ch.writeInbound(new TextWebSocketFrame("payload")); - + assertEquals("processed: payload", customTextFrameHandler.getContent()); } - + private static EmbeddedMessageChannel createChannel() { return createChannel(null); } - + private static EmbeddedMessageChannel createChannel(ChannelHandler handler) { return new EmbeddedMessageChannel( new WebSocketServerProtocolHandler("/test", null, false), @@ -126,7 +123,7 @@ public class WebSocketServerProtocolHandlerTest { new MockOutboundHandler(), handler); } - + private static void writeUpgradeRequest(EmbeddedMessageChannel ch) { ch.writeInbound(WebSocketRequestBuilder.sucessful()); } @@ -158,7 +155,7 @@ public class WebSocketServerProtocolHandlerTest { //NoOp } } - + private static class CustomTextFrameHandler extends ChannelInboundMessageHandlerAdapter { private String content; @@ -166,7 +163,7 @@ public class WebSocketServerProtocolHandlerTest { public void messageReceived(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception { content = "processed: " + msg.text(); } - + String getContent() { return content; } diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/package-info.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/package-info.java new file mode 100644 index 0000000000..9fc5800a67 --- /dev/null +++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test classes for encoder, decoder, handshakers and their related message types for + * Web Socket data frames. + */ +package io.netty.handler.codec.http.websocketx; diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java index 562e268fbc..bd18a2b6a5 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java @@ -147,8 +147,8 @@ public class SpdySessionHandlerTest { assertNull(sessionHandler.readOutbound()); SpdyHeadersFrame spdyHeadersFrame = new DefaultSpdyHeadersFrame(localStreamID); - spdyHeadersFrame.headers().add("HEADER","test1"); - spdyHeadersFrame.headers().add("HEADER","test2"); + spdyHeadersFrame.headers().add("HEADER", "test1"); + spdyHeadersFrame.headers().add("HEADER", "test2"); sessionHandler.writeInbound(spdyHeadersFrame); assertHeaders(sessionHandler.readOutbound(), localStreamID, spdyHeadersFrame); @@ -178,7 +178,6 @@ public class SpdySessionHandlerTest { assertNull(sessionHandler.readOutbound()); spdySynStreamFrame.setUnidirectional(false); - // Check if session handler returns PROTOCOL_ERROR if it receives // multiple SYN_STREAM frames for the same active Stream-ID sessionHandler.writeInbound(spdySynStreamFrame); @@ -194,7 +193,6 @@ public class SpdySessionHandlerTest { assertNull(sessionHandler.readOutbound()); spdySynStreamFrame.setStreamId(localStreamID); - // Check if session handler correctly limits the number of // concurrent streams in the SETTINGS frame SpdySettingsFrame spdySettingsFrame = new DefaultSpdySettingsFrame(); diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/package-info.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/package-info.java new file mode 100644 index 0000000000..966486d3f2 --- /dev/null +++ b/codec-http/src/test/java/io/netty/handler/codec/spdy/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test classes for encoder, decoder, session handler and their related message types for the SPDY protocol. + */ +package io.netty.handler.codec.spdy; diff --git a/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksAuthResponseDecoderTest.java b/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksAuthResponseDecoderTest.java index 518e871b90..ad88597a4d 100644 --- a/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksAuthResponseDecoderTest.java +++ b/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksAuthResponseDecoderTest.java @@ -25,8 +25,8 @@ import static org.junit.Assert.*; public class SocksAuthResponseDecoderTest { private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksAuthResponseDecoderTest.class); - private static void testSocksAuthResponseDecoderWithDifferentParams(SocksAuthStatus authStatus){ - logger.debug("Testing SocksAuthResponseDecoder with authStatus: "+ authStatus); + private static void testSocksAuthResponseDecoderWithDifferentParams(SocksAuthStatus authStatus) { + logger.debug("Testing SocksAuthResponseDecoder with authStatus: " + authStatus); SocksAuthResponse msg = new SocksAuthResponse(authStatus); SocksAuthResponseDecoder decoder = new SocksAuthResponseDecoder(); EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder); @@ -37,9 +37,9 @@ public class SocksAuthResponseDecoderTest { } @Test - public void testSocksCmdResponseDecoder(){ - for (SocksAuthStatus authStatus: SocksAuthStatus.values()){ - testSocksAuthResponseDecoderWithDifferentParams(authStatus); + public void testSocksCmdResponseDecoder() { + for (SocksAuthStatus authStatus: SocksAuthStatus.values()) { + testSocksAuthResponseDecoderWithDifferentParams(authStatus); } } } diff --git a/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdRequestDecoderTest.java b/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdRequestDecoderTest.java index 1ab703e033..32de008844 100644 --- a/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdRequestDecoderTest.java +++ b/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdRequestDecoderTest.java @@ -26,8 +26,12 @@ import static org.junit.Assert.*; public class SocksCmdRequestDecoderTest { private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksCmdRequestDecoderTest.class); - private static void testSocksCmdRequestDecoderWithDifferentParams(SocksCmdType cmdType, SocksAddressType addressType, String host, int port) { - logger.debug("Testing cmdType: " + cmdType + " addressType: " + addressType + " host: " + host + " port: " + port); + private static void testSocksCmdRequestDecoderWithDifferentParams(SocksCmdType cmdType, + SocksAddressType addressType, + String host, + int port) { + logger.debug("Testing cmdType: " + cmdType + " addressType: " + addressType + " host: " + host + + " port: " + port); SocksCmdRequest msg = new SocksCmdRequest(cmdType, addressType, host, port); SocksCmdRequestDecoder decoder = new SocksCmdRequestDecoder(); EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder); @@ -46,7 +50,7 @@ public class SocksCmdRequestDecoderTest { @Test public void testCmdRequestDecoderIPv4() { - String[] hosts = {"127.0.0.1",}; + String[] hosts = {"127.0.0.1", }; int[] ports = {0, 32769, 65535 }; for (SocksCmdType cmdType : SocksCmdType.values()) { for (String host : hosts) { diff --git a/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdRequestTest.java b/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdRequestTest.java index d54b9f8192..5eb163c333 100644 --- a/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdRequestTest.java +++ b/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdRequestTest.java @@ -21,70 +21,70 @@ import static org.junit.Assert.*; public class SocksCmdRequestTest { @Test - public void testConstructorParamsAreNotNull(){ + public void testConstructorParamsAreNotNull() { try { new SocksCmdRequest(null, SocksAddressType.UNKNOWN, "", 0); - } catch (Exception e){ + } catch (Exception e) { assertTrue(e instanceof NullPointerException); } try { new SocksCmdRequest(SocksCmdType.UNKNOWN, null, "", 0); - } catch (Exception e){ + } catch (Exception e) { assertTrue(e instanceof NullPointerException); } try { new SocksCmdRequest(SocksCmdType.UNKNOWN, SocksAddressType.UNKNOWN, null, 0); - } catch (Exception e){ + } catch (Exception e) { assertTrue(e instanceof NullPointerException); } } @Test - public void testIPv4CorrectAddress(){ + public void testIPv4CorrectAddress() { try { new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.IPv4, "54.54.1111.253", 0); - } catch (Exception e){ + } catch (Exception e) { assertTrue(e instanceof IllegalArgumentException); } } @Test - public void testIPv6CorrectAddress(){ + public void testIPv6CorrectAddress() { try { new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.IPv6, "xxx:xxx:xxx", 0); - } catch (Exception e){ + } catch (Exception e) { assertTrue(e instanceof IllegalArgumentException); } } @Test - public void testIDNNotExceeds255CharsLimit(){ + public void testIDNNotExceeds255CharsLimit() { try { new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.DOMAIN, "παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή" + "παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή" + "παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή" + "παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή", 0); - } catch (Exception e){ + } catch (Exception e) { assertTrue(e instanceof IllegalArgumentException); } } @Test - public void testValidPortRange(){ + public void testValidPortRange() { try { new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.DOMAIN, "παράδειγμα.δοκιμήπαράδει", -1); - } catch (Exception e){ + } catch (Exception e) { assertTrue(e instanceof IllegalArgumentException); } try { new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.DOMAIN, "παράδειγμα.δοκιμήπαράδει", 65536); - } catch (Exception e){ + } catch (Exception e) { assertTrue(e instanceof IllegalArgumentException); } } diff --git a/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdResponseDecoderTest.java b/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdResponseDecoderTest.java index 50bafb49b5..f058780d36 100644 --- a/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdResponseDecoderTest.java +++ b/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdResponseDecoderTest.java @@ -25,13 +25,14 @@ import static org.junit.Assert.*; public class SocksCmdResponseDecoderTest { private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksCmdResponseDecoderTest.class); - private static void testSocksCmdResponseDecoderWithDifferentParams(SocksCmdStatus cmdStatus, SocksAddressType addressType){ + private static void testSocksCmdResponseDecoderWithDifferentParams(SocksCmdStatus cmdStatus, + SocksAddressType addressType) { logger.debug("Testing cmdStatus: " + cmdStatus + " addressType: " + addressType); SocksResponse msg = new SocksCmdResponse(cmdStatus, addressType); SocksCmdResponseDecoder decoder = new SocksCmdResponseDecoder(); EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder); SocksCommonTestUtils.writeMessageIntoEmbedder(embedder, msg); - if (addressType == SocksAddressType.UNKNOWN){ + if (addressType == SocksAddressType.UNKNOWN) { assertTrue(embedder.readInbound() instanceof UnknownSocksResponse); } else { msg = (SocksResponse) embedder.readInbound(); @@ -41,9 +42,9 @@ public class SocksCmdResponseDecoderTest { } @Test - public void testSocksCmdResponseDecoder(){ - for (SocksCmdStatus cmdStatus: SocksCmdStatus.values()){ - for (SocksAddressType addressType: SocksAddressType.values()){ + public void testSocksCmdResponseDecoder() { + for (SocksCmdStatus cmdStatus: SocksCmdStatus.values()) { + for (SocksAddressType addressType: SocksAddressType.values()) { testSocksCmdResponseDecoderWithDifferentParams(cmdStatus, addressType); } } diff --git a/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksInitRequestTest.java b/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksInitRequestTest.java index a1e92a87e3..e6f0f681b2 100644 --- a/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksInitRequestTest.java +++ b/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksInitRequestTest.java @@ -20,10 +20,10 @@ import static org.junit.Assert.assertTrue; public class SocksInitRequestTest { @Test - public void testConstructorParamsAreNotNull(){ + public void testConstructorParamsAreNotNull() { try { new SocksInitRequest(null); - } catch (Exception e){ + } catch (Exception e) { assertTrue(e instanceof NullPointerException); } } diff --git a/codec-socks/src/test/java/io/netty/handler/codec/socks/package-info.java b/codec-socks/src/test/java/io/netty/handler/codec/socks/package-info.java new file mode 100644 index 0000000000..df685f46f3 --- /dev/null +++ b/codec-socks/src/test/java/io/netty/handler/codec/socks/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test classes for encoder, decoder and their related message types for Socks. + */ +package io.netty.handler.codec.socks; diff --git a/codec/src/test/java/io/netty/handler/codec/DelimiterBasedFrameDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/DelimiterBasedFrameDecoderTest.java index 9d1c600872..3dd695eea2 100644 --- a/codec/src/test/java/io/netty/handler/codec/DelimiterBasedFrameDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/DelimiterBasedFrameDecoderTest.java @@ -30,41 +30,45 @@ public class DelimiterBasedFrameDecoderTest { @Test public void testMultipleLinesStrippedDelimiters() { - EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, true, Delimiters.lineDelimiter())); + EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, true, + Delimiters.lineDelimiter())); ch.writeInbound(Unpooled.copiedBuffer("TestLine\r\ng\r\n", Charset.defaultCharset())); - assertEquals("TestLine", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset())); - assertEquals("g", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset())); + assertEquals("TestLine", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset())); + assertEquals("g", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset())); assertNull(ch.readInbound()); } @Test public void testIncompleteLinesStrippedDelimiters() { - EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, true, Delimiters.lineDelimiter())); + EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, true, + Delimiters.lineDelimiter())); ch.writeInbound(Unpooled.copiedBuffer("Test", Charset.defaultCharset())); assertNull(ch.readInbound()); ch.writeInbound(Unpooled.copiedBuffer("Line\r\ng\r\n", Charset.defaultCharset())); - assertEquals("TestLine", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset())); - assertEquals("g", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset())); + assertEquals("TestLine", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset())); + assertEquals("g", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset())); assertNull(ch.readInbound()); } @Test public void testMultipleLines() { - EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, false, Delimiters.lineDelimiter())); + EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, false, + Delimiters.lineDelimiter())); ch.writeInbound(Unpooled.copiedBuffer("TestLine\r\ng\r\n", Charset.defaultCharset())); - assertEquals("TestLine\r\n", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset())); - assertEquals("g\r\n", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset())); + assertEquals("TestLine\r\n", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset())); + assertEquals("g\r\n", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset())); assertNull(ch.readInbound()); } @Test public void testIncompleteLines() { - EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, false, Delimiters.lineDelimiter())); + EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, false, + Delimiters.lineDelimiter())); ch.writeInbound(Unpooled.copiedBuffer("Test", Charset.defaultCharset())); assertNull(ch.readInbound()); ch.writeInbound(Unpooled.copiedBuffer("Line\r\ng\r\n", Charset.defaultCharset())); - assertEquals("TestLine\r\n", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset())); - assertEquals("g\r\n", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset())); + assertEquals("TestLine\r\n", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset())); + assertEquals("g\r\n", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset())); assertNull(ch.readInbound()); } @@ -74,9 +78,8 @@ public class DelimiterBasedFrameDecoderTest { new DelimiterBasedFrameDecoder(8192, true, Delimiters.lineDelimiter())); ch.writeInbound(Unpooled.copiedBuffer("first\r\nsecond\nthird", CharsetUtil.US_ASCII)); - assertEquals("first", ((ByteBuf)ch.readInbound()).toString(CharsetUtil.US_ASCII)); - assertEquals("second", ((ByteBuf)ch.readInbound()).toString(CharsetUtil.US_ASCII)); + assertEquals("first", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII)); + assertEquals("second", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII)); assertNull(ch.readInbound()); - } } diff --git a/codec/src/test/java/io/netty/handler/codec/LineBasedFrameDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/LineBasedFrameDecoderTest.java index 210ab592f7..def05bea6d 100644 --- a/codec/src/test/java/io/netty/handler/codec/LineBasedFrameDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/LineBasedFrameDecoderTest.java @@ -28,18 +28,17 @@ public class LineBasedFrameDecoderTest { EmbeddedByteChannel ch = new EmbeddedByteChannel(new LineBasedFrameDecoder(8192, true, false)); ch.writeInbound(Unpooled.copiedBuffer("first\r\nsecond\nthird", CharsetUtil.US_ASCII)); - Assert.assertEquals("first", ((ByteBuf)ch.readInbound()).toString(CharsetUtil.US_ASCII)); - Assert.assertEquals("second", ((ByteBuf)ch.readInbound()).toString(CharsetUtil.US_ASCII)); + Assert.assertEquals("first", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII)); + Assert.assertEquals("second", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII)); Assert.assertNull(ch.readInbound()); - } @Test public void testDecodeWithoutStrip() throws Exception { EmbeddedByteChannel ch = new EmbeddedByteChannel(new LineBasedFrameDecoder(8192, false, false)); ch.writeInbound(Unpooled.copiedBuffer("first\r\nsecond\nthird", CharsetUtil.US_ASCII)); - Assert.assertEquals("first\r\n", ((ByteBuf)ch.readInbound()).toString(CharsetUtil.US_ASCII)); - Assert.assertEquals("second\n", ((ByteBuf)ch.readInbound()).toString(CharsetUtil.US_ASCII)); + Assert.assertEquals("first\r\n", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII)); + Assert.assertEquals("second\n", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII)); Assert.assertNull(ch.readInbound()); } } diff --git a/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderBufferTest.java b/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderBufferTest.java index 058f71fc05..cc48d95c15 100644 --- a/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderBufferTest.java +++ b/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderBufferTest.java @@ -24,13 +24,14 @@ import org.junit.Test; import static org.junit.Assert.*; public class ReplayingDecoderBufferTest { - + /** * See https://github.com/netty/netty/issues/445 */ @Test public void testGetUnsignedByte() { - ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(Unpooled.copiedBuffer("TestBuffer", CharsetUtil.ISO_8859_1)); + ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(Unpooled.copiedBuffer("TestBuffer", + CharsetUtil.ISO_8859_1)); boolean error; int i = 0; @@ -52,7 +53,8 @@ public class ReplayingDecoderBufferTest { */ @Test public void testGetByte() { - ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(Unpooled.copiedBuffer("TestBuffer", CharsetUtil.ISO_8859_1)); + ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(Unpooled.copiedBuffer("TestBuffer", + CharsetUtil.ISO_8859_1)); boolean error; int i = 0; @@ -68,14 +70,14 @@ public class ReplayingDecoderBufferTest { assertTrue(error); assertEquals(10, i); } - + /** * See https://github.com/netty/netty/issues/445 */ @Test public void testGetBoolean() { ByteBuf buf = Unpooled.buffer(10); - while(buf.isWritable()) { + while (buf.isWritable()) { buf.writeBoolean(true); } ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(buf); diff --git a/codec/src/test/java/io/netty/handler/codec/bytes/package-info.java b/codec/src/test/java/io/netty/handler/codec/bytes/package-info.java new file mode 100644 index 0000000000..ca53036125 --- /dev/null +++ b/codec/src/test/java/io/netty/handler/codec/bytes/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test classes for encoder and decoder which transform an array of bytes into a + * {@link io.netty.buffer.ByteBuf} and vice versa. + */ +package io.netty.handler.codec.bytes; diff --git a/codec/src/test/java/io/netty/handler/codec/compression/JZlibTest.java b/codec/src/test/java/io/netty/handler/codec/compression/JZlibTest.java index 4820e82fb9..9eb05d8c8c 100644 --- a/codec/src/test/java/io/netty/handler/codec/compression/JZlibTest.java +++ b/codec/src/test/java/io/netty/handler/codec/compression/JZlibTest.java @@ -37,25 +37,21 @@ public class JZlibTest { byte[] deflatedData = chEncoder.readOutbound().array(); - { - EmbeddedByteChannel chDecoder = + EmbeddedByteChannel chDecoderZlib = new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB)); - chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData)); - assertTrue(chDecoder.finish()); + chDecoderZlib.writeInbound(Unpooled.wrappedBuffer(deflatedData)); + assertTrue(chDecoderZlib.finish()); - assertEquals(data, chDecoder.readInbound()); - } + assertEquals(data, chDecoderZlib.readInbound()); - { - EmbeddedByteChannel chDecoder = + EmbeddedByteChannel chDecoderZlibOrNone = new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB_OR_NONE)); - chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData)); - assertTrue(chDecoder.finish()); + chDecoderZlibOrNone.writeInbound(Unpooled.wrappedBuffer(deflatedData)); + assertTrue(chDecoderZlibOrNone.finish()); - assertEquals(data, chDecoder.readInbound()); - } + assertEquals(data, chDecoderZlibOrNone.readInbound()); } @Test @@ -67,31 +63,26 @@ public class JZlibTest { chEncoder.writeOutbound(data); assertTrue(chEncoder.finish()); - + byte[] deflatedData = chEncoder.readOutbound().array(); - { - EmbeddedByteChannel chDecoder = + EmbeddedByteChannel chDecoderZlibNone = new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.NONE)); - chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData)); - assertTrue(chDecoder.finish()); + chDecoderZlibNone.writeInbound(Unpooled.wrappedBuffer(deflatedData)); + assertTrue(chDecoderZlibNone.finish()); - assertEquals(data, chDecoder.readInbound()); - } + assertEquals(data, chDecoderZlibNone.readInbound()); - { - EmbeddedByteChannel chDecoder = + EmbeddedByteChannel chDecoderZlibOrNone = new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB_OR_NONE)); - chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData)); - assertTrue(chDecoder.finish()); + chDecoderZlibOrNone.writeInbound(Unpooled.wrappedBuffer(deflatedData)); + assertTrue(chDecoderZlibOrNone.finish()); - assertEquals(data, chDecoder.readInbound()); - } + assertEquals(data, chDecoderZlibOrNone.readInbound()); } - @Test public void testGZIP() throws Exception { ByteBuf data = Unpooled.wrappedBuffer("test".getBytes()); @@ -104,24 +95,20 @@ public class JZlibTest { byte[] deflatedData = chEncoder.readOutbound().array(); - { - EmbeddedByteChannel chDecoder = + EmbeddedByteChannel chDecoderGZip = new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.GZIP)); - chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData)); - assertTrue(chDecoder.finish()); + chDecoderGZip.writeInbound(Unpooled.wrappedBuffer(deflatedData)); + assertTrue(chDecoderGZip.finish()); - assertEquals(data, chDecoder.readInbound()); - } + assertEquals(data, chDecoderGZip.readInbound()); - { - EmbeddedByteChannel chDecoder = + EmbeddedByteChannel chDecoderZlibOrNone = new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB_OR_NONE)); - chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData)); - assertTrue(chDecoder.finish()); + chDecoderZlibOrNone.writeInbound(Unpooled.wrappedBuffer(deflatedData)); + assertTrue(chDecoderZlibOrNone.finish()); - assertEquals(data, chDecoder.readInbound()); - } + assertEquals(data, chDecoderZlibOrNone.readInbound()); } } diff --git a/codec/src/test/java/io/netty/handler/codec/compression/SnappyFramedEncoderTest.java b/codec/src/test/java/io/netty/handler/codec/compression/SnappyFramedEncoderTest.java index 307668bb7c..f40274ca0b 100644 --- a/codec/src/test/java/io/netty/handler/codec/compression/SnappyFramedEncoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/compression/SnappyFramedEncoderTest.java @@ -25,7 +25,7 @@ import static org.junit.Assert.*; public class SnappyFramedEncoderTest { private EmbeddedByteChannel channel; - + @Before public void setUp() { channel = new EmbeddedByteChannel(new SnappyFramedEncoder()); @@ -85,7 +85,7 @@ public class SnappyFramedEncoderTest { }); assertEquals(expected, channel.readOutbound()); } - + /** * This test asserts that if we have a remainder after emitting a copy that * is less than 4 bytes (ie. the minimum required for a copy), we should @@ -127,7 +127,7 @@ public class SnappyFramedEncoderTest { -1, -1, -1, // copy -1, 1 // remainder }); - + channel.writeOutbound(in); assertTrue(channel.finish()); } diff --git a/codec/src/test/java/io/netty/handler/codec/compression/SnappyIntegrationTest.java b/codec/src/test/java/io/netty/handler/codec/compression/SnappyIntegrationTest.java index ea3ffa0418..f92b83c6a5 100644 --- a/codec/src/test/java/io/netty/handler/codec/compression/SnappyIntegrationTest.java +++ b/codec/src/test/java/io/netty/handler/codec/compression/SnappyIntegrationTest.java @@ -70,12 +70,11 @@ public class SnappyIntegrationTest { })); } - // These tests were found using testRandom() with large RANDOM_RUNS. // Tests that copies do not attempt to overrun into a previous frame chunk @Test - public void test5323211032315942961(){ + public void test5323211032315942961() { testWithSeed(5323211032315942961L); } diff --git a/codec/src/test/java/io/netty/handler/codec/compression/package-info.java b/codec/src/test/java/io/netty/handler/codec/compression/package-info.java new file mode 100644 index 0000000000..af11948b60 --- /dev/null +++ b/codec/src/test/java/io/netty/handler/codec/compression/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test classes encoder and decoder which compresses and decompresses {@link io.netty.buffer.ByteBuf}s + * in a compression format + */ +package io.netty.handler.codec.compression; diff --git a/codec/src/test/java/io/netty/handler/codec/frame/package-info.java b/codec/src/test/java/io/netty/handler/codec/frame/package-info.java new file mode 100644 index 0000000000..90e823a53a --- /dev/null +++ b/codec/src/test/java/io/netty/handler/codec/frame/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test classes for frame based decoders + */ +package io.netty.handler.codec.frame; diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/AbstractCompatibleMarshallingDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/AbstractCompatibleMarshallingDecoderTest.java index 146d3f9ccf..67e736e671 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/AbstractCompatibleMarshallingDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/AbstractCompatibleMarshallingDecoderTest.java @@ -121,12 +121,12 @@ public abstract class AbstractCompatibleMarshallingDecoderTest { } protected ChannelHandler createDecoder(int maxObjectSize) { - return new CompatibleMarshallingDecoder(createProvider(createMarshallerFactory(), createMarshallingConfig()), maxObjectSize); + return new CompatibleMarshallingDecoder(createProvider(createMarshallerFactory(), + createMarshallingConfig()), maxObjectSize); } protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) { return new DefaultUnmarshallerProvider(factory, config); - } protected abstract MarshallerFactory createMarshallerFactory(); diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/RiverCompatibleMarshallingEncoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/RiverCompatibleMarshallingEncoderTest.java index e9764ba6d3..5927695304 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/RiverCompatibleMarshallingEncoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/RiverCompatibleMarshallingEncoderTest.java @@ -21,7 +21,6 @@ import org.jboss.marshalling.MarshallingConfiguration; public class RiverCompatibleMarshallingEncoderTest extends AbstractCompatibleMarshallingEncoderTest { - @Override protected MarshallerFactory createMarshallerFactory() { return Marshalling.getProvidedMarshallerFactory("river"); diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/RiverContextBoundCompatibleMarshallingDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/RiverContextBoundCompatibleMarshallingDecoderTest.java index 9426c0e3c8..eadaee7dad 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/RiverContextBoundCompatibleMarshallingDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/RiverContextBoundCompatibleMarshallingDecoderTest.java @@ -25,5 +25,4 @@ public class RiverContextBoundCompatibleMarshallingDecoderTest extends RiverComp return new ContextBoundUnmarshallerProvider(factory, config); } - } diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/RiverContextBoundMarshallingDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/RiverContextBoundMarshallingDecoderTest.java index ed20e13bd2..62b6a101bf 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/RiverContextBoundMarshallingDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/RiverContextBoundMarshallingDecoderTest.java @@ -25,5 +25,4 @@ public class RiverContextBoundMarshallingDecoderTest extends RiverMarshallingDec return new ContextBoundUnmarshallerProvider(factory, config); } - } diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/RiverMarshallingDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/RiverMarshallingDecoderTest.java index 11599b6e13..fec50f21c6 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/RiverMarshallingDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/RiverMarshallingDecoderTest.java @@ -30,8 +30,8 @@ public class RiverMarshallingDecoderTest extends RiverCompatibleMarshallingDecod @Override protected ChannelHandler createDecoder(int maxObjectSize) { - return new MarshallingDecoder(createProvider(createMarshallerFactory(), createMarshallingConfig()), maxObjectSize); + return new MarshallingDecoder(createProvider(createMarshallerFactory(), + createMarshallingConfig()), maxObjectSize); } - } diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/RiverThreadLocalCompatibleMarshallingDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/RiverThreadLocalCompatibleMarshallingDecoderTest.java index a5543f7b4e..9a7f3a8a07 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/RiverThreadLocalCompatibleMarshallingDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/RiverThreadLocalCompatibleMarshallingDecoderTest.java @@ -25,5 +25,4 @@ public class RiverThreadLocalCompatibleMarshallingDecoderTest extends RiverCompa return new ThreadLocalUnmarshallerProvider(factory, config); } - } diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/RiverThreadLocalMarshallingDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/RiverThreadLocalMarshallingDecoderTest.java index 1ac517cdb8..065203bc0b 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/RiverThreadLocalMarshallingDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/RiverThreadLocalMarshallingDecoderTest.java @@ -25,5 +25,4 @@ public class RiverThreadLocalMarshallingDecoderTest extends RiverMarshallingDeco return new ThreadLocalUnmarshallerProvider(factory, config); } - } diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/SerialCompatibleMarshallingEncoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/SerialCompatibleMarshallingEncoderTest.java index ab2a6ca24b..2b3d9f95ce 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/SerialCompatibleMarshallingEncoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/SerialCompatibleMarshallingEncoderTest.java @@ -21,7 +21,6 @@ import org.jboss.marshalling.MarshallingConfiguration; public class SerialCompatibleMarshallingEncoderTest extends AbstractCompatibleMarshallingEncoderTest { - @Override protected MarshallerFactory createMarshallerFactory() { return Marshalling.getProvidedMarshallerFactory("serial"); diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/SerialContextBoundCompatibleMarshallingDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/SerialContextBoundCompatibleMarshallingDecoderTest.java index 0dec87f51f..e60ef32041 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/SerialContextBoundCompatibleMarshallingDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/SerialContextBoundCompatibleMarshallingDecoderTest.java @@ -20,7 +20,6 @@ import org.jboss.marshalling.MarshallingConfiguration; public class SerialContextBoundCompatibleMarshallingDecoderTest extends SerialCompatibleMarshallingDecoderTest { - @Override protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) { return new ContextBoundUnmarshallerProvider(factory, config); diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/SerialContextBoundMarshallingDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/SerialContextBoundMarshallingDecoderTest.java index c4ce600dd3..fddeb672ae 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/SerialContextBoundMarshallingDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/SerialContextBoundMarshallingDecoderTest.java @@ -20,7 +20,6 @@ import org.jboss.marshalling.MarshallingConfiguration; public class SerialContextBoundMarshallingDecoderTest extends SerialMarshallingDecoderTest { - @Override protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) { return new ContextBoundUnmarshallerProvider(factory, config); diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/SerialMarshallingDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/SerialMarshallingDecoderTest.java index 06fd86460c..cf8f4f61f3 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/SerialMarshallingDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/SerialMarshallingDecoderTest.java @@ -30,7 +30,8 @@ public class SerialMarshallingDecoderTest extends SerialCompatibleMarshallingDec @Override protected ChannelHandler createDecoder(int maxObjectSize) { - return new MarshallingDecoder(createProvider(createMarshallerFactory(), createMarshallingConfig()), maxObjectSize); + return new MarshallingDecoder(createProvider(createMarshallerFactory(), + createMarshallingConfig()), maxObjectSize); } } diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/SerialMarshallingEncoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/SerialMarshallingEncoderTest.java index e6da44dcb4..5c2b7e0660 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/SerialMarshallingEncoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/SerialMarshallingEncoderTest.java @@ -18,7 +18,7 @@ package io.netty.handler.codec.marshalling; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandler; -public class SerialMarshallingEncoderTest extends SerialCompatibleMarshallingEncoderTest{ +public class SerialMarshallingEncoderTest extends SerialCompatibleMarshallingEncoderTest { @Override protected ByteBuf truncate(ByteBuf buf) { diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/SerialThreadLocalCompatibleMarshallingDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/SerialThreadLocalCompatibleMarshallingDecoderTest.java index 9c92839863..29e0a9189a 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/SerialThreadLocalCompatibleMarshallingDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/SerialThreadLocalCompatibleMarshallingDecoderTest.java @@ -20,7 +20,6 @@ import org.jboss.marshalling.MarshallingConfiguration; public class SerialThreadLocalCompatibleMarshallingDecoderTest extends SerialCompatibleMarshallingDecoderTest { - @Override protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) { return new ThreadLocalUnmarshallerProvider(factory, config); diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/SerialThreadLocalMarshallingDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/SerialThreadLocalMarshallingDecoderTest.java index 99ef876475..2a15ca227a 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/SerialThreadLocalMarshallingDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/SerialThreadLocalMarshallingDecoderTest.java @@ -20,7 +20,6 @@ import org.jboss.marshalling.MarshallingConfiguration; public class SerialThreadLocalMarshallingDecoderTest extends SerialMarshallingDecoderTest { - @Override protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) { return new ThreadLocalUnmarshallerProvider(factory, config); diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/package-info.java b/codec/src/test/java/io/netty/handler/codec/marshalling/package-info.java new file mode 100644 index 0000000000..e7e08938cc --- /dev/null +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test classes for decoder and encoder which uses + * JBoss Marshalling. + */ +package io.netty.handler.codec.marshalling; diff --git a/codec/src/test/java/io/netty/handler/codec/package-info.java b/codec/src/test/java/io/netty/handler/codec/package-info.java new file mode 100644 index 0000000000..f7cf92edaf --- /dev/null +++ b/codec/src/test/java/io/netty/handler/codec/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test classes for extensible decoder and its common implementations + */ +package io.netty.handler.codec; diff --git a/codec/src/test/java/io/netty/handler/codec/protobuf/package-info.java b/codec/src/test/java/io/netty/handler/codec/protobuf/package-info.java new file mode 100644 index 0000000000..b561895216 --- /dev/null +++ b/codec/src/test/java/io/netty/handler/codec/protobuf/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test classes for encoder and decoder which transform a + * Google Protocol Buffers + * {@link com.google.protobuf.Message} into a {@link io.netty.buffer.ByteBuf} + * and vice versa. + */ +package io.netty.handler.codec.protobuf; diff --git a/codec/src/test/java/io/netty/handler/codec/serialization/package-info.java b/codec/src/test/java/io/netty/handler/codec/serialization/package-info.java new file mode 100644 index 0000000000..389f6dbebb --- /dev/null +++ b/codec/src/test/java/io/netty/handler/codec/serialization/package-info.java @@ -0,0 +1,22 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test classes for encoder, decoder and their compatibility stream implementations which + * transform a {@link java.io.Serializable} object into a byte buffer and + * vice versa. + */ +package io.netty.handler.codec.serialization; diff --git a/common/src/test/java/io/netty/util/NetUtilTest.java b/common/src/test/java/io/netty/util/NetUtilTest.java index 2d65089bb9..fa36514a8c 100644 --- a/common/src/test/java/io/netty/util/NetUtilTest.java +++ b/common/src/test/java/io/netty/util/NetUtilTest.java @@ -24,7 +24,7 @@ import java.util.Map.Entry; import static org.junit.Assert.*; public class NetUtilTest { - private final static Map validIpV4Hosts = new HashMap() { + private static final Map validIpV4Hosts = new HashMap() { private static final long serialVersionUID = 2629792739366724032L; { put("192.168.1.0", new byte[]{ @@ -42,10 +42,9 @@ public class NetUtilTest { put("127.0.0.1", new byte[]{ 0x7f, 0x00, 0x00, 0x01 }); - } }; - private final static Map invalidIpV4Hosts = new HashMap() { + private static final Map invalidIpV4Hosts = new HashMap() { private static final long serialVersionUID = 1299215199895717282L; { put("1.256.3.4", null); @@ -53,7 +52,7 @@ public class NetUtilTest { put("1.1.1.1.1", null); } }; - private final static Map validIpV6Hosts = new HashMap() { + private static final Map validIpV6Hosts = new HashMap() { private static final long serialVersionUID = 3999763170377573184L; { put("::ffff:5.6.7.8", new byte[]{ @@ -165,7 +164,7 @@ public class NetUtilTest { ); } }; - private final static Map invalidIpV6Hosts = new HashMap() { + private static final Map invalidIpV6Hosts = new HashMap() { private static final long serialVersionUID = -5870810805409009696L; { // Test method with garbage. diff --git a/common/src/test/java/io/netty/util/UniqueNameTest.java b/common/src/test/java/io/netty/util/UniqueNameTest.java index f850358808..1f786f747e 100644 --- a/common/src/test/java/io/netty/util/UniqueNameTest.java +++ b/common/src/test/java/io/netty/util/UniqueNameTest.java @@ -47,12 +47,12 @@ public class UniqueNameTest { names = PlatformDependent.newConcurrentHashMap(); } - @Test(expected=NullPointerException.class) + @Test(expected = NullPointerException.class) public void testCannnotProvideNullMap() { new UniqueName(null, "Nothing"); } - @Test(expected=NullPointerException.class) + @Test(expected = NullPointerException.class) public void testCannotProvideNullName() { new UniqueName(names, null); } diff --git a/common/src/test/java/io/netty/util/internal/StringUtilTest.java b/common/src/test/java/io/netty/util/internal/StringUtilTest.java index 4ff03c28bd..24ba3814c0 100644 --- a/common/src/test/java/io/netty/util/internal/StringUtilTest.java +++ b/common/src/test/java/io/netty/util/internal/StringUtilTest.java @@ -20,7 +20,7 @@ import org.junit.Test; import static org.junit.Assert.*; public class StringUtilTest { - + @Test public void ensureNewlineExists() { assertNotNull(StringUtil.NEWLINE); diff --git a/common/src/test/java/io/netty/util/internal/TypeParameterMatcherTest.java b/common/src/test/java/io/netty/util/internal/TypeParameterMatcherTest.java index 2ae4427676..f9f1b62d71 100644 --- a/common/src/test/java/io/netty/util/internal/TypeParameterMatcherTest.java +++ b/common/src/test/java/io/netty/util/internal/TypeParameterMatcherTest.java @@ -77,7 +77,7 @@ public class TypeParameterMatcherTest { public static class TypeY extends TypeX { } - public static abstract class TypeZ extends TypeY { } + public abstract static class TypeZ extends TypeY { } public static class TypeQ extends TypeZ { } diff --git a/common/src/test/java/io/netty/util/internal/logging/InternalLoggerFactoryTest.java b/common/src/test/java/io/netty/util/internal/logging/InternalLoggerFactoryTest.java index 0ed738e6d4..0a9f85a3f7 100644 --- a/common/src/test/java/io/netty/util/internal/logging/InternalLoggerFactoryTest.java +++ b/common/src/test/java/io/netty/util/internal/logging/InternalLoggerFactoryTest.java @@ -43,7 +43,6 @@ public class InternalLoggerFactoryTest { InternalLoggerFactory.setDefaultFactory(oldLoggerFactory); } - @Test(expected = NullPointerException.class) public void shouldNotAllowNullDefaultFactory() { InternalLoggerFactory.setDefaultFactory(null); @@ -52,12 +51,12 @@ public class InternalLoggerFactoryTest { @Test public void shouldGetInstance() { InternalLoggerFactory.setDefaultFactory(oldLoggerFactory); - + String helloWorld = "Hello, world!"; - + InternalLogger one = InternalLoggerFactory.getInstance("helloWorld"); InternalLogger two = InternalLoggerFactory.getInstance(helloWorld.getClass()); - + assertNotNull(one); assertNotNull(two); assertNotSame(one, two); diff --git a/common/src/test/java/io/netty/util/internal/logging/package-info.java b/common/src/test/java/io/netty/util/internal/logging/package-info.java new file mode 100644 index 0000000000..3538aad14a --- /dev/null +++ b/common/src/test/java/io/netty/util/internal/logging/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 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: + * + * http://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. + */ + +/** + * Internal logging utility test classes + */ +package io.netty.util.internal.logging; diff --git a/common/src/test/java/io/netty/util/internal/package-info.java b/common/src/test/java/io/netty/util/internal/package-info.java new file mode 100644 index 0000000000..1a63153f41 --- /dev/null +++ b/common/src/test/java/io/netty/util/internal/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 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: + * + * http://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. + */ + +/** + * Utility internal test classes + */ +package io.netty.util.internal; diff --git a/common/src/test/java/io/netty/util/package-info.java b/common/src/test/java/io/netty/util/package-info.java new file mode 100644 index 0000000000..371ab4c4c0 --- /dev/null +++ b/common/src/test/java/io/netty/util/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 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: + * + * http://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. + */ + +/** + * Utility test classes + */ +package io.netty.util; diff --git a/handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java b/handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java index 7447d71ec5..99990f7231 100644 --- a/handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java @@ -24,7 +24,6 @@ import io.netty.channel.embedded.EmbeddedByteChannel; import io.netty.channel.embedded.EmbeddedMessageChannel; import io.netty.util.CharsetUtil; import org.junit.Test; - import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileOutputStream; @@ -68,19 +67,20 @@ public class ChunkedWriteHandlerTest { public void testChunkedStream() { check(new ChunkedStream(new ByteArrayInputStream(BYTES))); - check(new ChunkedStream(new ByteArrayInputStream(BYTES)), new ChunkedStream(new ByteArrayInputStream(BYTES)), new ChunkedStream(new ByteArrayInputStream(BYTES))); - + check(new ChunkedStream(new ByteArrayInputStream(BYTES)), + new ChunkedStream(new ByteArrayInputStream(BYTES)), + new ChunkedStream(new ByteArrayInputStream(BYTES))); } @Test public void testChunkedNioStream() { check(new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES)))); - check(new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES))), new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES))), new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES)))); - + check(new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES))), + new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES))), + new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES)))); } - @Test public void testChunkedFile() throws IOException { check(new ChunkedFile(TMP)); @@ -96,7 +96,7 @@ public class ChunkedWriteHandlerTest { } // Test case which shows that there is not a bug like stated here: - // http://stackoverflow.com/questions/10409241/why-is-close-channelfuturelistener-not-notified/10426305#comment14126161_10426305 + // http://stackoverflow.com/a/10426305 @Test public void testListenerNotifiedWhenIsEnd() { ByteBuf buffer = Unpooled.copiedBuffer("Test", CharsetUtil.ISO_8859_1); @@ -146,7 +146,6 @@ public class ChunkedWriteHandlerTest { assertEquals(buffer, ch.readOutbound()); assertNull(ch.readOutbound()); - } @Test @@ -184,7 +183,6 @@ public class ChunkedWriteHandlerTest { assertEquals(0, ch.readOutbound()); assertNull(ch.readOutbound()); - } private static void check(ChunkedInput... inputs) { diff --git a/handler/src/test/java/io/netty/handler/stream/package-info.java b/handler/src/test/java/io/netty/handler/stream/package-info.java new file mode 100644 index 0000000000..72c2f2a410 --- /dev/null +++ b/handler/src/test/java/io/netty/handler/stream/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test classes for stream package + */ +package io.netty.handler.stream; diff --git a/microbench/src/test/java/com/google/caliper/StandardVm.java b/microbench/src/test/java/com/google/caliper/StandardVm.java index 7a158aa108..c01ca21108 100644 --- a/microbench/src/test/java/com/google/caliper/StandardVm.java +++ b/microbench/src/test/java/com/google/caliper/StandardVm.java @@ -14,21 +14,6 @@ * under the License. */ -/* - * Copyright 2012 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: - * - * http://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. - */ /* * Copyright (C) 2010 Google Inc. * diff --git a/microbench/src/test/java/com/google/caliper/package-info.java b/microbench/src/test/java/com/google/caliper/package-info.java new file mode 100644 index 0000000000..5931441937 --- /dev/null +++ b/microbench/src/test/java/com/google/caliper/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 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: + * + * http://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. + */ + +/** + * Caliper VM arguments + */ +package com.google.caliper; diff --git a/microbench/src/test/java/io/netty/microbench/buffer/ByteBufAllocatorBenchmark.java b/microbench/src/test/java/io/netty/microbench/buffer/ByteBufAllocatorBenchmark.java index 1e34d7d58b..9482e9310a 100644 --- a/microbench/src/test/java/io/netty/microbench/buffer/ByteBufAllocatorBenchmark.java +++ b/microbench/src/test/java/io/netty/microbench/buffer/ByteBufAllocatorBenchmark.java @@ -33,7 +33,7 @@ public class ByteBufAllocatorBenchmark extends DefaultBenchmark { private static final ByteBufAllocator POOLED_ALLOCATOR_HEAP = new PooledByteBufAllocator(false); private static final ByteBufAllocator POOLED_ALLOCATOR_DIRECT = new PooledByteBufAllocator(true); - @Param({"0", "256", "1024", "4096", "16384", "65536"}) + @Param({ "0", "256", "1024", "4096", "16384", "65536" }) private int size; @Param diff --git a/microbench/src/test/java/io/netty/microbench/buffer/package-info.java b/microbench/src/test/java/io/netty/microbench/buffer/package-info.java new file mode 100644 index 0000000000..c4b7939333 --- /dev/null +++ b/microbench/src/test/java/io/netty/microbench/buffer/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 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: + * + * http://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. + */ + +/** + * Benchmark classes for Netty ByteBuf + */ +package io.netty.microbench.buffer; diff --git a/microbench/src/test/java/io/netty/microbench/util/DefaultBenchmark.java b/microbench/src/test/java/io/netty/microbench/util/DefaultBenchmark.java index 943ba123fa..1ee3f5e9c9 100644 --- a/microbench/src/test/java/io/netty/microbench/util/DefaultBenchmark.java +++ b/microbench/src/test/java/io/netty/microbench/util/DefaultBenchmark.java @@ -118,7 +118,8 @@ public abstract class DefaultBenchmark extends SimpleBenchmark { deleted = true; System.out.println(); } - System.out.println(" Deleted old report: " + name.substring(prefix.length(), name.length() - suffix.length())); + System.out.println(" Deleted old report: " + + name.substring(prefix.length(), name.length() - suffix.length())); } } } diff --git a/microbench/src/test/java/io/netty/microbench/util/package-info.java b/microbench/src/test/java/io/netty/microbench/util/package-info.java new file mode 100644 index 0000000000..c25b9c6fd8 --- /dev/null +++ b/microbench/src/test/java/io/netty/microbench/util/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 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: + * + * http://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. + */ + +/** + * Util benchmark classes + */ +package io.netty.microbench.util; diff --git a/pom.xml b/pom.xml index f3c635c406..b1aab0aba3 100644 --- a/pom.xml +++ b/pom.xml @@ -361,6 +361,7 @@ true true io/netty/checkstyle.xml + true diff --git a/testsuite-osgi/testsuite-osgi-deps/src/test/java/io/netty/verify/osgi/DependencyIT.java b/testsuite-osgi/testsuite-osgi-deps/src/test/java/io/netty/verify/osgi/DependencyIT.java index ab53348197..0aa59c4f9f 100644 --- a/testsuite-osgi/testsuite-osgi-deps/src/test/java/io/netty/verify/osgi/DependencyIT.java +++ b/testsuite-osgi/testsuite-osgi-deps/src/test/java/io/netty/verify/osgi/DependencyIT.java @@ -49,7 +49,5 @@ public class DependencyIT { } else { System.out.println("all transitive dependencies are osgi bundles"); } - } - } diff --git a/testsuite-osgi/testsuite-osgi-deps/src/test/java/io/netty/verify/osgi/package-info.java b/testsuite-osgi/testsuite-osgi-deps/src/test/java/io/netty/verify/osgi/package-info.java new file mode 100644 index 0000000000..d33b7a61d4 --- /dev/null +++ b/testsuite-osgi/testsuite-osgi-deps/src/test/java/io/netty/verify/osgi/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 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: + * + * http://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. + */ + +/** + * OSGI Dependency tests + */ +package io.netty.verify.osgi; diff --git a/testsuite-osgi/testsuite-osgi-exam/src/test/java/io/netty/verify/osgi/UnitHelp.java b/testsuite-osgi/testsuite-osgi-exam/src/test/java/io/netty/verify/osgi/UnitHelp.java index 770130a6cb..2e0de2353c 100644 --- a/testsuite-osgi/testsuite-osgi-exam/src/test/java/io/netty/verify/osgi/UnitHelp.java +++ b/testsuite-osgi/testsuite-osgi-exam/src/test/java/io/netty/verify/osgi/UnitHelp.java @@ -29,7 +29,7 @@ import org.osgi.framework.wiring.BundleWiring; /** * Unit Test Utilities. */ -public class UnitHelp { +public final class UnitHelp { private UnitHelp() { } @@ -106,7 +106,6 @@ public class UnitHelp { /** install java unit bundles */ junitBundles()); - } /** diff --git a/testsuite-osgi/testsuite-osgi-exam/src/test/java/io/netty/verify/osgi/package-info.java b/testsuite-osgi/testsuite-osgi-exam/src/test/java/io/netty/verify/osgi/package-info.java new file mode 100644 index 0000000000..6ef91550a4 --- /dev/null +++ b/testsuite-osgi/testsuite-osgi-exam/src/test/java/io/netty/verify/osgi/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 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: + * + * http://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. + */ + +/** + * OSGI verify compliance tests + */ +package io.netty.verify.osgi; diff --git a/testsuite-osgi/testsuite-osgi-split/src/test/java/io/netty/verify/osgi/package-info.java b/testsuite-osgi/testsuite-osgi-split/src/test/java/io/netty/verify/osgi/package-info.java new file mode 100644 index 0000000000..57b701f600 --- /dev/null +++ b/testsuite-osgi/testsuite-osgi-split/src/test/java/io/netty/verify/osgi/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 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: + * + * http://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. + */ + +/** + * OSGI placeholder + */ +package io.netty.verify.osgi; diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/sctp/AbstractSctpTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/sctp/AbstractSctpTest.java index a790ee04d5..42f81307c1 100644 --- a/testsuite/src/test/java/io/netty/testsuite/transport/sctp/AbstractSctpTest.java +++ b/testsuite/src/test/java/io/netty/testsuite/transport/sctp/AbstractSctpTest.java @@ -45,7 +45,7 @@ public abstract class AbstractSctpTest { protected volatile Bootstrap cb; protected volatile InetSocketAddress addr; protected volatile Factory currentBootstrap; - + protected void run() throws Throwable { int i = 0; for (Entry, Factory> e: COMBO) { diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/sctp/SctpEchoTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/sctp/SctpEchoTest.java index e016d58049..62fecd7efe 100644 --- a/testsuite/src/test/java/io/netty/testsuite/transport/sctp/SctpEchoTest.java +++ b/testsuite/src/test/java/io/netty/testsuite/transport/sctp/SctpEchoTest.java @@ -41,7 +41,7 @@ import static org.junit.Assert.*; public class SctpEchoTest extends AbstractSctpTest { private static final Random random = new Random(); - static final byte[] data = new byte[4096];//could not test ultra jumbo frames + static final byte[] data = new byte[4096]; //could not test ultra jumbo frames static { random.nextBytes(data); @@ -95,7 +95,7 @@ public class SctpEchoTest extends AbstractSctpTest { Channel sc = sb.bind().sync().channel(); Channel cc = cb.connect().sync().channel(); - for (int i = 0; i < data.length; ) { + for (int i = 0; i < data.length;) { int length = Math.min(random.nextInt(1024 * 64), data.length - i); cc.write(Unpooled.wrappedBuffer(data, i, length)); i += length; diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/sctp/SctpTestPermutation.java b/testsuite/src/test/java/io/netty/testsuite/transport/sctp/SctpTestPermutation.java index f152648be5..36ef3ddf2a 100644 --- a/testsuite/src/test/java/io/netty/testsuite/transport/sctp/SctpTestPermutation.java +++ b/testsuite/src/test/java/io/netty/testsuite/transport/sctp/SctpTestPermutation.java @@ -117,8 +117,7 @@ public final class SctpTestPermutation { return list; } - - private SctpTestPermutation() {} + private SctpTestPermutation() { } interface Factory { T newInstance(); diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/sctp/package-info.java b/testsuite/src/test/java/io/netty/testsuite/transport/sctp/package-info.java new file mode 100644 index 0000000000..7add199280 --- /dev/null +++ b/testsuite/src/test/java/io/netty/testsuite/transport/sctp/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test suite classes for sctp transport + */ +package io.netty.testsuite.transport.sctp; diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractClientSocketTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractClientSocketTest.java index 1c17a32539..7c46e2fe5e 100644 --- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractClientSocketTest.java +++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractClientSocketTest.java @@ -45,8 +45,7 @@ public abstract class AbstractClientSocketTest { int i = 0; for (Factory e: COMBO) { cb = e.newInstance(); - addr = new InetSocketAddress( - NetUtil.LOCALHOST, TestUtils.getFreePort()); + addr = new InetSocketAddress(NetUtil.LOCALHOST, TestUtils.getFreePort()); cb.remoteAddress(addr); logger.info(String.format( diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractSocketTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractSocketTest.java index e65dffd98c..dddf8a87e6 100644 --- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractSocketTest.java +++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractSocketTest.java @@ -45,7 +45,7 @@ public abstract class AbstractSocketTest { protected volatile Bootstrap cb; protected volatile InetSocketAddress addr; protected volatile Factory currentBootstrap; - + protected void run() throws Throwable { int i = 0; for (Entry, Factory> e: COMBO) { diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/DatagramMulticastTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/DatagramMulticastTest.java index aff6a25fe9..bb2e9b7038 100644 --- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/DatagramMulticastTest.java +++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/DatagramMulticastTest.java @@ -92,7 +92,6 @@ public class DatagramMulticastTest extends AbstractDatagramTest { sc.close().awaitUninterruptibly(); cc.close().awaitUninterruptibly(); - } private static final class MulticastTestHandler extends ChannelInboundMessageHandlerAdapter { diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketShutdownOutputBySelfTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketShutdownOutputBySelfTest.java index 1f3513a909..5c377c31db 100644 --- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketShutdownOutputBySelfTest.java +++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketShutdownOutputBySelfTest.java @@ -68,7 +68,6 @@ public class SocketShutdownOutputBySelfTest extends AbstractClientSocketTest { // If half-closed, the peer should be able to write something. s.getOutputStream().write(1); assertEquals(1, (int) h.queue.take()); - } finally { if (s != null) { s.close(); diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java index 61ae81ddac..6376196902 100644 --- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java +++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java @@ -63,7 +63,6 @@ public class SocketSslEchoTest extends AbstractSocketTest { testSslEcho0(sb, cb, false); } - @Test public void testSslEchoWithChunkHandler() throws Throwable { run(); diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketTestPermutation.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketTestPermutation.java index 1975c4f5a0..50b9b5810c 100644 --- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketTestPermutation.java +++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketTestPermutation.java @@ -200,7 +200,7 @@ final class SocketTestPermutation { return list; } - private SocketTestPermutation() {} + private SocketTestPermutation() { } interface Factory { T newInstance(); diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/package-info.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/package-info.java new file mode 100644 index 0000000000..8b19c321a9 --- /dev/null +++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Test suite classes for socket + */ +package io.netty.testsuite.transport.socket; diff --git a/testsuite/src/test/java/io/netty/testsuite/util/TestUtils.java b/testsuite/src/test/java/io/netty/testsuite/util/TestUtils.java index 46eda50916..7afb9889ce 100644 --- a/testsuite/src/test/java/io/netty/testsuite/util/TestUtils.java +++ b/testsuite/src/test/java/io/netty/testsuite/util/TestUtils.java @@ -16,12 +16,15 @@ package io.netty.testsuite.util; import io.netty.util.NetUtil; - import java.io.IOException; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.nio.channels.Channel; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; public final class TestUtils { diff --git a/testsuite/src/test/java/io/netty/testsuite/util/package-info.java b/testsuite/src/test/java/io/netty/testsuite/util/package-info.java new file mode 100644 index 0000000000..b3bf1e3843 --- /dev/null +++ b/testsuite/src/test/java/io/netty/testsuite/util/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * Util Test suite classes + */ +package io.netty.testsuite.util; diff --git a/transport-udt/src/test/java/io/netty/test/udt/nio/AbstractUdtTest.java b/transport-udt/src/test/java/io/netty/test/udt/nio/AbstractUdtTest.java index ba27358342..b4afead45c 100644 --- a/transport-udt/src/test/java/io/netty/test/udt/nio/AbstractUdtTest.java +++ b/transport-udt/src/test/java/io/netty/test/udt/nio/AbstractUdtTest.java @@ -30,7 +30,7 @@ public abstract class AbstractUdtTest { * UDT test assumptions. */ @BeforeClass - public static void assumeConditions(){ + public static void assumeConditions() { assumeTrue(UnitHelp.canLoadAndInitClass("com.barchart.udt.SocketUDT")); } diff --git a/transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtByteRendezvousChannelTest.java b/transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtByteRendezvousChannelTest.java index 4b9fcd241e..19595f9463 100644 --- a/transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtByteRendezvousChannelTest.java +++ b/transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtByteRendezvousChannelTest.java @@ -82,7 +82,6 @@ public class NioUdtByteRendezvousChannelTest extends AbstractUdtTest { .meter().count()); Thread.sleep(1000); - } connectFuture1.channel().close().sync(); @@ -98,7 +97,6 @@ public class NioUdtByteRendezvousChannelTest extends AbstractUdtTest { boot1.shutdown(); boot2.shutdown(); - } } diff --git a/transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtMessageRendezvousChannelTest.java b/transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtMessageRendezvousChannelTest.java index ab37d675ec..4f0bc435fa 100644 --- a/transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtMessageRendezvousChannelTest.java +++ b/transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtMessageRendezvousChannelTest.java @@ -44,7 +44,6 @@ public class NioUdtMessageRendezvousChannelTest extends AbstractUdtTest { @Test public void metadata() throws Exception { assertEquals(BufType.MESSAGE, new NioUdtMessageRendezvousChannel().metadata().bufferType()); - } /** @@ -87,7 +86,6 @@ public class NioUdtMessageRendezvousChannelTest extends AbstractUdtTest { .meter().count()); Thread.sleep(1000); - } connectFuture1.channel().close().sync(); @@ -103,7 +101,6 @@ public class NioUdtMessageRendezvousChannelTest extends AbstractUdtTest { boot1.shutdown(); boot2.shutdown(); - } } diff --git a/transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtProviderTest.java b/transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtProviderTest.java index e46b6eb6e3..aae2f9e0a0 100644 --- a/transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtProviderTest.java +++ b/transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtProviderTest.java @@ -38,7 +38,7 @@ public class NioUdtProviderTest extends AbstractUdtTest { assertNotNull(NioUdtProvider.MESSAGE_ACCEPTOR.newChannel()); assertNotNull(NioUdtProvider.MESSAGE_CONNECTOR.newChannel()); assertNotNull(NioUdtProvider.MESSAGE_RENDEZVOUS.newChannel()); - + // acceptor types assertTrue(NioUdtProvider.BYTE_ACCEPTOR.newChannel() instanceof UdtServerChannel); assertTrue(NioUdtProvider.MESSAGE_ACCEPTOR.newChannel() instanceof UdtServerChannel); diff --git a/transport-udt/src/test/java/io/netty/test/udt/nio/package-info.java b/transport-udt/src/test/java/io/netty/test/udt/nio/package-info.java new file mode 100644 index 0000000000..8155812c10 --- /dev/null +++ b/transport-udt/src/test/java/io/netty/test/udt/nio/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2012 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: + * + * http://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. + */ + +/** + * UDT NIO + */ +package io.netty.test.udt.nio; + diff --git a/transport-udt/src/test/java/io/netty/test/udt/util/BootHelp.java b/transport-udt/src/test/java/io/netty/test/udt/util/BootHelp.java index a9aa0fd379..3edcfa8e8a 100644 --- a/transport-udt/src/test/java/io/netty/test/udt/util/BootHelp.java +++ b/transport-udt/src/test/java/io/netty/test/udt/util/BootHelp.java @@ -46,7 +46,6 @@ public final class BootHelp { .localAddress(self).remoteAddress(peer).handler(handler); return boot; - } /** @@ -67,7 +66,6 @@ public final class BootHelp { .localAddress(self).remoteAddress(peer).handler(handler); return boot; - } private BootHelp() { } diff --git a/transport-udt/src/test/java/io/netty/test/udt/util/CaliperBench.java b/transport-udt/src/test/java/io/netty/test/udt/util/CaliperBench.java index 8f53fe5fb8..983daa8b5d 100644 --- a/transport-udt/src/test/java/io/netty/test/udt/util/CaliperBench.java +++ b/transport-udt/src/test/java/io/netty/test/udt/util/CaliperBench.java @@ -94,7 +94,6 @@ public abstract class CaliperBench extends SimpleBenchmark { continue; } } - } } diff --git a/transport-udt/src/test/java/io/netty/test/udt/util/CaliperMeasure.java b/transport-udt/src/test/java/io/netty/test/udt/util/CaliperMeasure.java index eae95290ef..dce20f1b59 100644 --- a/transport-udt/src/test/java/io/netty/test/udt/util/CaliperMeasure.java +++ b/transport-udt/src/test/java/io/netty/test/udt/util/CaliperMeasure.java @@ -147,21 +147,18 @@ public class CaliperMeasure { /** ignore complete blank entries */ return; } - { - final Measurement mark = new Measurement(RATE_UNIT, rateValue, - rateValue); - rateMap.put(System.nanoTime(), mark); - } - { - final Measurement mark = new Measurement(TIME_UNIT, timeValue, - timeValue); - timeMap.put(System.nanoTime(), mark); - } - { - final Measurement mark = new Measurement(SIZE_UNIT, sizeValue, - sizeValue); - sizeMap.put(System.nanoTime(), mark); - } + + final Measurement markRate = new Measurement(RATE_UNIT, rateValue, + rateValue); + rateMap.put(System.nanoTime(), markRate); + + final Measurement markTime = new Measurement(TIME_UNIT, timeValue, + timeValue); + timeMap.put(System.nanoTime(), markTime); + + final Measurement markSize = new Measurement(SIZE_UNIT, sizeValue, + sizeValue); + sizeMap.put(System.nanoTime(), markSize); } private final Map variables = new HashMap(); diff --git a/transport-udt/src/test/java/io/netty/test/udt/util/CaliperRunner.java b/transport-udt/src/test/java/io/netty/test/udt/util/CaliperRunner.java index cfaccd156b..970233f401 100644 --- a/transport-udt/src/test/java/io/netty/test/udt/util/CaliperRunner.java +++ b/transport-udt/src/test/java/io/netty/test/udt/util/CaliperRunner.java @@ -50,7 +50,7 @@ import java.util.TreeSet; */ public final class CaliperRunner { - private final static InternalLogger log = InternalLoggerFactory.getInstance(CaliperRunner.class); + private static final InternalLogger log = InternalLoggerFactory.getInstance(CaliperRunner.class); private CaliperRunner() { } diff --git a/transport-udt/src/test/java/io/netty/test/udt/util/EchoByteHandler.java b/transport-udt/src/test/java/io/netty/test/udt/util/EchoByteHandler.java index e8f90c4538..ebaed66ea4 100644 --- a/transport-udt/src/test/java/io/netty/test/udt/util/EchoByteHandler.java +++ b/transport-udt/src/test/java/io/netty/test/udt/util/EchoByteHandler.java @@ -53,7 +53,6 @@ public class EchoByteHandler extends ChannelInboundByteHandlerAdapter { for (int i = 0; i < message.capacity(); i++) { message.writeByte((byte) i); } - } @Override @@ -65,7 +64,6 @@ public class EchoByteHandler extends ChannelInboundByteHandlerAdapter { ctx.write(message); ctx.flush(); - } @Override @@ -83,7 +81,6 @@ public class EchoByteHandler extends ChannelInboundByteHandlerAdapter { out.writeBytes(in); ctx.flush(); - } @Override @@ -93,7 +90,6 @@ public class EchoByteHandler extends ChannelInboundByteHandlerAdapter { log.error("exception : {}", e.getMessage()); ctx.close(); - } @Override diff --git a/transport-udt/src/test/java/io/netty/test/udt/util/UnitHelp.java b/transport-udt/src/test/java/io/netty/test/udt/util/UnitHelp.java index c983950137..8447748ca2 100644 --- a/transport-udt/src/test/java/io/netty/test/udt/util/UnitHelp.java +++ b/transport-udt/src/test/java/io/netty/test/udt/util/UnitHelp.java @@ -44,16 +44,16 @@ public final class UnitHelp { * Verify class loading with class initialization. */ public static boolean canLoadAndInitClass(String name) { - try{ + try { Class.forName(name, true, UnitHelp.class.getClassLoader()); log.info("Class load and init success."); return true; - } catch(Throwable e){ + } catch (Throwable e) { log.warn("Class load or init failure.", e); return false; } } - + /** * Zero out buffer. */ diff --git a/transport/src/test/java/io/netty/bootstrap/package-info.java b/transport/src/test/java/io/netty/bootstrap/package-info.java new file mode 100644 index 0000000000..670d2ac62d --- /dev/null +++ b/transport/src/test/java/io/netty/bootstrap/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 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: + * + * http://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. + */ + +/** + * Test classes for transport bootstrap + */ +package io.netty.bootstrap; diff --git a/transport/src/test/java/io/netty/channel/AbstractEventLoopTest.java b/transport/src/test/java/io/netty/channel/AbstractEventLoopTest.java index e9cb829785..d318b9d689 100644 --- a/transport/src/test/java/io/netty/channel/AbstractEventLoopTest.java +++ b/transport/src/test/java/io/netty/channel/AbstractEventLoopTest.java @@ -48,7 +48,6 @@ public abstract class AbstractEventLoopTest { public void initChannel(ServerSocketChannel ch) throws Exception { ch.pipeline().addLast(new TestChannelHandler()); ch.pipeline().addLast(eventExecutorGroup, new TestChannelHandler2()); - } }) .bind(0).awaitUninterruptibly(); diff --git a/transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java b/transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java index b43cfbedc6..3b58494b59 100644 --- a/transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java +++ b/transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java @@ -124,7 +124,7 @@ public class DefaultChannelPipelineTest { } @Test - public void testFreeCalled() throws InterruptedException{ + public void testFreeCalled() throws InterruptedException { final CountDownLatch free = new CountDownLatch(1); final ReferenceCounted holder = new ReferenceCounted() { @@ -195,7 +195,6 @@ public class DefaultChannelPipelineTest { } } - @Test public void testRemoveChannelHandler() { DefaultChannelPipeline pipeline = new DefaultChannelPipeline(new LocalChannel()); @@ -319,7 +318,6 @@ public class DefaultChannelPipelineTest { group.register(channel).awaitUninterruptibly(); final DefaultChannelPipeline pipeline = new DefaultChannelPipeline(channel); - final ChannelInboundByteHandlerImpl handler1 = new ChannelInboundByteHandlerImpl(); final ChannelInboundByteHandlerImpl handler2 = new ChannelInboundByteHandlerImpl(); pipeline.addLast("handler1", handler1); @@ -348,7 +346,6 @@ public class DefaultChannelPipelineTest { group.register(channel).awaitUninterruptibly(); final DefaultChannelPipeline pipeline = new DefaultChannelPipeline(channel); - final ChannelInboundByteHandlerImpl handler1 = new ChannelInboundByteHandlerImpl(); final ChannelInboundByteHandlerImpl handler2 = new ChannelInboundByteHandlerImpl(); pipeline.addLast("handler1", handler1); @@ -366,7 +363,6 @@ public class DefaultChannelPipelineTest { assertTrue(latch.await(10, TimeUnit.SECONDS)); assertTrue(handler2.updated); - } @Test @@ -376,7 +372,6 @@ public class DefaultChannelPipelineTest { group.register(channel).awaitUninterruptibly(); final DefaultChannelPipeline pipeline = new DefaultChannelPipeline(channel); - final ChannelOutboundByteHandlerImpl handler1 = new ChannelOutboundByteHandlerImpl(); final ChannelOutboundByteHandlerImpl handler2 = new ChannelOutboundByteHandlerImpl(); pipeline.addLast("handler1", handler1); @@ -396,7 +391,6 @@ public class DefaultChannelPipelineTest { assertTrue(latch.await(10, TimeUnit.SECONDS)); assertTrue(handler1.flushed); - } @Test @@ -406,7 +400,6 @@ public class DefaultChannelPipelineTest { group.register(channel).awaitUninterruptibly(); final DefaultChannelPipeline pipeline = new DefaultChannelPipeline(channel); - final ChannelOutboundByteHandlerImpl handler1 = new ChannelOutboundByteHandlerImpl(); final ChannelOutboundByteHandlerImpl handler2 = new ChannelOutboundByteHandlerImpl(); pipeline.addLast("handler1", handler1); @@ -433,7 +426,6 @@ public class DefaultChannelPipelineTest { group.register(channel).awaitUninterruptibly(); final DefaultChannelPipeline pipeline = new DefaultChannelPipeline(channel); - final ByteHandlerImpl handler1 = new ByteHandlerImpl(); final ByteHandlerImpl handler2 = new ByteHandlerImpl(); pipeline.addLast("handler1", handler1); @@ -456,8 +448,8 @@ public class DefaultChannelPipelineTest { }); assertTrue(latch.await(10, TimeUnit.SECONDS)); - assertTrue(((ChannelInboundByteHandlerImpl)handler2.stateHandler()).updated); - assertTrue(((ChannelOutboundByteHandlerImpl)handler2.operationHandler()).flushed); + assertTrue(((ChannelInboundByteHandlerImpl) handler2.stateHandler()).updated); + assertTrue(((ChannelOutboundByteHandlerImpl) handler2.operationHandler()).flushed); } @Test @@ -467,7 +459,6 @@ public class DefaultChannelPipelineTest { group.register(channel).awaitUninterruptibly(); final DefaultChannelPipeline pipeline = new DefaultChannelPipeline(channel); - final ChannelOutboundByteHandlerImpl handler1 = new ChannelOutboundByteHandlerImpl(); final ByteHandlerImpl handler2 = new ByteHandlerImpl(); final ChannelInboundByteHandlerImpl handler3 = new ChannelInboundByteHandlerImpl(); @@ -498,7 +489,6 @@ public class DefaultChannelPipelineTest { assertTrue(latch.await(10, TimeUnit.SECONDS)); assertTrue(handler1.flushed); assertTrue(handler3.updated); - } @Test @@ -508,7 +498,6 @@ public class DefaultChannelPipelineTest { group.register(channel).awaitUninterruptibly(); final DefaultChannelPipeline pipeline = new DefaultChannelPipeline(channel); - final ChannelInboundMessageHandlerImpl handler1 = new ChannelInboundMessageHandlerImpl(); final ChannelInboundMessageHandlerImpl handler2 = new ChannelInboundMessageHandlerImpl(); pipeline.addLast("handler1", handler1); @@ -537,7 +526,6 @@ public class DefaultChannelPipelineTest { group.register(channel).awaitUninterruptibly(); final DefaultChannelPipeline pipeline = new DefaultChannelPipeline(channel); - final ChannelInboundMessageHandlerImpl handler1 = new ChannelInboundMessageHandlerImpl(); final ChannelInboundMessageHandlerImpl handler2 = new ChannelInboundMessageHandlerImpl(); pipeline.addLast("handler1", handler1); @@ -564,7 +552,6 @@ public class DefaultChannelPipelineTest { group.register(channel).awaitUninterruptibly(); final DefaultChannelPipeline pipeline = new DefaultChannelPipeline(channel); - final ChannelOutboundMessageHandlerImpl handler1 = new ChannelOutboundMessageHandlerImpl(); final ChannelOutboundMessageHandlerImpl handler2 = new ChannelOutboundMessageHandlerImpl(); pipeline.addLast("handler1", handler1); @@ -593,7 +580,6 @@ public class DefaultChannelPipelineTest { group.register(channel).awaitUninterruptibly(); final DefaultChannelPipeline pipeline = new DefaultChannelPipeline(channel); - final ChannelOutboundMessageHandlerImpl handler1 = new ChannelOutboundMessageHandlerImpl(); final ChannelOutboundMessageHandlerImpl handler2 = new ChannelOutboundMessageHandlerImpl(); pipeline.addLast("handler1", handler1); @@ -620,7 +606,6 @@ public class DefaultChannelPipelineTest { group.register(channel).awaitUninterruptibly(); final DefaultChannelPipeline pipeline = new DefaultChannelPipeline(channel); - final MessageHandlerImpl handler1 = new MessageHandlerImpl(); final MessageHandlerImpl handler2 = new MessageHandlerImpl(); pipeline.addLast("handler1", handler1); @@ -643,9 +628,8 @@ public class DefaultChannelPipelineTest { }); assertTrue(latch.await(10, TimeUnit.SECONDS)); - assertTrue(((ChannelInboundMessageHandlerImpl)handler2.stateHandler()).updated); - assertTrue(((ChannelOutboundMessageHandlerImpl)handler2.operationHandler()).flushed); - + assertTrue(((ChannelInboundMessageHandlerImpl) handler2.stateHandler()).updated); + assertTrue(((ChannelOutboundMessageHandlerImpl) handler2.operationHandler()).flushed); } @Test @@ -688,7 +672,6 @@ public class DefaultChannelPipelineTest { group.register(channel).awaitUninterruptibly(); final DefaultChannelPipeline pipeline = new DefaultChannelPipeline(channel); - final ChannelOutboundMessageHandlerImpl handler1 = new ChannelOutboundMessageHandlerImpl(); final MessageHandlerImpl handler2 = new MessageHandlerImpl(); final ChannelInboundMessageHandlerImpl handler3 = new ChannelInboundMessageHandlerImpl(); @@ -719,7 +702,6 @@ public class DefaultChannelPipelineTest { assertTrue(latch.await(10, TimeUnit.SECONDS)); assertTrue(handler1.flushed); assertTrue(handler3.updated); - } private static int next(DefaultChannelHandlerContext ctx) { DefaultChannelHandlerContext next = ctx.next; @@ -795,7 +777,8 @@ public class DefaultChannelPipelineTest { } } - private static final class ChannelInboundMessageHandlerImpl extends ChannelStateHandlerAdapter implements ChannelInboundMessageHandler { + private static final class ChannelInboundMessageHandlerImpl extends ChannelStateHandlerAdapter + implements ChannelInboundMessageHandler { boolean updated; @Override public MessageBuf newInboundBuffer(ChannelHandlerContext ctx) throws Exception { @@ -813,7 +796,8 @@ public class DefaultChannelPipelineTest { } } - private static final class ChannelOutboundMessageHandlerImpl extends ChannelOperationHandlerAdapter implements ChannelOutboundMessageHandler { + private static final class ChannelOutboundMessageHandlerImpl extends ChannelOperationHandlerAdapter + implements ChannelOutboundMessageHandler { boolean flushed; @Override public MessageBuf newOutboundBuffer(ChannelHandlerContext ctx) throws Exception { @@ -832,7 +816,8 @@ public class DefaultChannelPipelineTest { } } - private static final class ByteHandlerImpl extends CombinedChannelDuplexHandler implements ChannelInboundByteHandler, ChannelOutboundByteHandler{ + private static final class ByteHandlerImpl extends CombinedChannelDuplexHandler + implements ChannelInboundByteHandler, ChannelOutboundByteHandler { ByteHandlerImpl() { super(new ChannelInboundByteHandlerImpl(), new ChannelOutboundByteHandlerImpl()); } @@ -892,7 +877,6 @@ public class DefaultChannelPipelineTest { return ((ChannelOutboundMessageHandler) operationHandler()).newOutboundBuffer(ctx); } - @SuppressWarnings("unchecked") @Override public void freeOutboundBuffer(ChannelHandlerContext ctx) throws Exception { diff --git a/transport/src/test/java/io/netty/channel/group/DefaultChannnelGroupTest.java b/transport/src/test/java/io/netty/channel/group/DefaultChannnelGroupTest.java index 5d73171211..48174750d7 100644 --- a/transport/src/test/java/io/netty/channel/group/DefaultChannnelGroupTest.java +++ b/transport/src/test/java/io/netty/channel/group/DefaultChannnelGroupTest.java @@ -25,7 +25,6 @@ import org.junit.Test; public class DefaultChannnelGroupTest { - // Test for #1183 @Test public void testNotThrowBlockingOperationException() { diff --git a/transport/src/test/java/io/netty/channel/group/package-info.java b/transport/src/test/java/io/netty/channel/group/package-info.java new file mode 100644 index 0000000000..8481850471 --- /dev/null +++ b/transport/src/test/java/io/netty/channel/group/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 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: + * + * http://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. + */ + +/** + * Test classes for transport channel group + */ +package io.netty.channel.group; diff --git a/transport/src/test/java/io/netty/channel/local/LocalChannelRegistryTest.java b/transport/src/test/java/io/netty/channel/local/LocalChannelRegistryTest.java index 9c9830c2b4..43bd2b4b2e 100644 --- a/transport/src/test/java/io/netty/channel/local/LocalChannelRegistryTest.java +++ b/transport/src/test/java/io/netty/channel/local/LocalChannelRegistryTest.java @@ -57,7 +57,6 @@ public class LocalChannelRegistryTest { } }); - // Start server Channel sc = sb.bind(addr).sync().channel(); diff --git a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java index 8919918a5e..1ab599d9b2 100644 --- a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java +++ b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java @@ -319,7 +319,6 @@ public class LocalTransportThreadModelTest { } ch.close().sync(); - } finally { l.shutdown(); e1.shutdown(); diff --git a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java index 5832c1ed77..fba75ce135 100644 --- a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java +++ b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java @@ -110,7 +110,6 @@ public class LocalTransportThreadModelTest2 { // Wait until the connection is closed or the connection attempt fails. localChannel.closeFuture().awaitUninterruptibly(); - } @Sharable @@ -123,7 +122,6 @@ public class LocalTransportThreadModelTest2 { public LocalHander(String name) { this.name = name; - } @Override diff --git a/transport/src/test/java/io/netty/channel/local/package-info.java b/transport/src/test/java/io/netty/channel/local/package-info.java new file mode 100644 index 0000000000..9cd900034b --- /dev/null +++ b/transport/src/test/java/io/netty/channel/local/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 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: + * + * http://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. + */ + +/** + * Test classes for local transport channel + */ +package io.netty.channel.local; diff --git a/transport/src/test/java/io/netty/channel/nio/package-info.java b/transport/src/test/java/io/netty/channel/nio/package-info.java new file mode 100644 index 0000000000..cf80654c3e --- /dev/null +++ b/transport/src/test/java/io/netty/channel/nio/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 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: + * + * http://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. + */ + +/** + * Test classes for NIO transport channel + */ +package io.netty.channel.nio; diff --git a/transport/src/test/java/io/netty/channel/package-info.java b/transport/src/test/java/io/netty/channel/package-info.java new file mode 100644 index 0000000000..ea5aea35bb --- /dev/null +++ b/transport/src/test/java/io/netty/channel/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 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: + * + * http://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. + */ + +/** + * Test classes for transport channel + */ +package io.netty.channel;