enable checkstyle for test source directory and fix checkstyle errors

This commit is contained in:
Prajwal Tuladhar 2013-03-27 03:31:43 -04:00 committed by Norman Maurer
parent 8e23ab6886
commit 05850da863
114 changed files with 947 additions and 368 deletions

View File

@ -1519,7 +1519,6 @@ public abstract class AbstractByteBufTest {
buffer.setIndex(0, value.length); buffer.setIndex(0, value.length);
buffer.setBytes(0, value); buffer.setBytes(0, value);
assertEquals(0, buffer.compareTo(wrappedBuffer(value))); assertEquals(0, buffer.compareTo(wrappedBuffer(value)));
assertEquals(0, buffer.compareTo(wrappedBuffer(value).order(LITTLE_ENDIAN))); assertEquals(0, buffer.compareTo(wrappedBuffer(value).order(LITTLE_ENDIAN)));

View File

@ -99,7 +99,8 @@ public abstract class AbstractCompositeByteBufTest extends
*/ */
@Test @Test
public void testComponentAtOffset() { 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 //Ensure that a random place will be fine
assertEquals(5, buf.componentAtOffset(2).capacity()); assertEquals(5, buf.componentAtOffset(2).capacity());
@ -412,7 +413,7 @@ public abstract class AbstractCompositeByteBufTest extends
assertFalse(BufUtil.equals(a, b)); assertFalse(BufUtil.equals(a, b));
} }
@Test @Test
public void testEmptyBuffer() { public void testEmptyBuffer() {
ByteBuf b = freeLater(wrappedBuffer(new byte[]{1, 2}, new byte[]{3, 4})); ByteBuf b = freeLater(wrappedBuffer(new byte[]{1, 2}, new byte[]{3, 4}));
b.readBytes(new byte[4]); b.readBytes(new byte[4]);

View File

@ -105,8 +105,6 @@ public class ByteBufDerivationTest {
ro.setIndex(2, 6); ro.setIndex(2, 6);
assertThat(buf.readerIndex(), is(1)); assertThat(buf.readerIndex(), is(1));
assertThat(buf.writerIndex(), is(7));
} }
@Test @Test

View File

@ -22,7 +22,6 @@ import java.nio.charset.Charset;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
* Tests channel buffer streams * Tests channel buffer streams
*/ */
@ -173,33 +172,33 @@ public class ByteBufStreamTest {
@Test @Test
public void testReadLine() throws Exception { public void testReadLine() throws Exception {
Charset utf8=Charset.forName("UTF-8"); Charset utf8 = Charset.forName("UTF-8");
ByteBuf buf = Unpooled.buffer(); ByteBuf buf = Unpooled.buffer();
ByteBufInputStream in = new ByteBufInputStream(buf); ByteBufInputStream in = new ByteBufInputStream(buf);
String s = in.readLine(); String s = in.readLine();
assertNull(s); 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); byte[] abc = "a\nb\r\nc\nd\ne".getBytes(utf8);
buf.writeBytes(abc); buf.writeBytes(abc);
in.mark(charCount); in.mark(charCount);
assertEquals("a",in.readLine()); assertEquals("a", in.readLine());
assertEquals("b",in.readLine()); assertEquals("b", in.readLine());
assertEquals("c",in.readLine()); assertEquals("c", in.readLine());
assertEquals("d",in.readLine()); assertEquals("d", in.readLine());
assertEquals("e",in.readLine()); assertEquals("e", in.readLine());
assertNull(in.readLine()); assertNull(in.readLine());
in.reset(); in.reset();
int count=0; int count = 0;
while(in.readLine() != null){ while (in.readLine() != null) {
++count; ++count;
if(count > charCount){ if (count > charCount) {
fail("readLine() should have returned null"); fail("readLine() should have returned null");
} }
} }
assertEquals(charCount,count); assertEquals(charCount, count);
in.close(); in.close();
} }
} }

View File

@ -41,7 +41,7 @@ public class ConsolidationTest {
public void shouldConsolidationInSequence() { public void shouldConsolidationInSequence() {
ByteBuf currentBuffer = wrappedBuffer(wrappedBuffer("a".getBytes()), wrappedBuffer("=".getBytes())); ByteBuf currentBuffer = wrappedBuffer(wrappedBuffer("a".getBytes()), wrappedBuffer("=".getBytes()));
currentBuffer = wrappedBuffer(currentBuffer, wrappedBuffer("1".getBytes()), wrappedBuffer("&".getBytes())); currentBuffer = wrappedBuffer(currentBuffer, wrappedBuffer("1".getBytes()), wrappedBuffer("&".getBytes()));
currentBuffer = wrappedBuffer(currentBuffer, wrappedBuffer("b".getBytes()), wrappedBuffer("=".getBytes())); currentBuffer = wrappedBuffer(currentBuffer, wrappedBuffer("b".getBytes()), wrappedBuffer("=".getBytes()));
currentBuffer = wrappedBuffer(currentBuffer, wrappedBuffer("2".getBytes()), wrappedBuffer("&".getBytes())); currentBuffer = wrappedBuffer(currentBuffer, wrappedBuffer("2".getBytes()), wrappedBuffer("&".getBytes()));
@ -60,5 +60,5 @@ public class ConsolidationTest {
currentBuffer.release(); currentBuffer.release();
copy.release(); copy.release();
} }
} }

View File

@ -44,7 +44,6 @@ public class ReadOnlyDirectByteBufferBufTest {
buf.setByte(0, 1); buf.setByte(0, 1);
} }
@Test(expected = ReadOnlyBufferException.class) @Test(expected = ReadOnlyBufferException.class)
public void testSetInt() { public void testSetInt() {
ByteBuf buf = buffer(allocate(8).asReadOnlyBuffer()); ByteBuf buf = buffer(allocate(8).asReadOnlyBuffer());
@ -109,10 +108,10 @@ public class ReadOnlyDirectByteBufferBufTest {
Assert.assertFalse(buf.isReadable()); Assert.assertFalse(buf.isReadable());
} }
@Test @Test
public void testGetReadShort() { 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(1, buf.getShort(0));
Assert.assertEquals(2, buf.getShort(2)); Assert.assertEquals(2, buf.getShort(2));

View File

@ -28,7 +28,7 @@ public class ReadOnlyUnsafeDirectByteBufferBufTest extends ReadOnlyDirectByteBuf
* Needs unsafe to run * Needs unsafe to run
*/ */
@BeforeClass @BeforeClass
public static void assumeConditions(){ public static void assumeConditions() {
assumeTrue(PlatformDependent.hasUnsafe()); assumeTrue(PlatformDependent.hasUnsafe());
} }

View File

@ -568,7 +568,6 @@ public class UnpooledTest {
assertEquals(0, Unpooled.copyBoolean(null).capacity()); assertEquals(0, Unpooled.copyBoolean(null).capacity());
assertEquals(0, Unpooled.copyBoolean(new boolean[0]).capacity()); assertEquals(0, Unpooled.copyBoolean(new boolean[0]).capacity());
} }
@Test @Test

View File

@ -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;

View File

@ -29,7 +29,8 @@ public class CookieDecoderTest {
@Test @Test
public void testDecodingSingleCookieV0() { public void testDecodingSingleCookieV0() {
String cookieString = "myCookie=myValue;expires=XXX;path=/apathsomewhere;domain=.adomainsomewhere;secure;"; 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<Cookie> cookies = CookieDecoder.decode(cookieString); Set<Cookie> cookies = CookieDecoder.decode(cookieString);
assertEquals(1, cookies.size()); assertEquals(1, cookies.size());
@ -60,7 +61,9 @@ public class CookieDecoderTest {
@Test @Test
public void testDecodingSingleCookieV0ExtraParamsIgnored() { 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<Cookie> cookies = CookieDecoder.decode(cookieString); Set<Cookie> cookies = CookieDecoder.decode(cookieString);
assertEquals(1, cookies.size()); assertEquals(1, cookies.size());
Cookie cookie = cookies.iterator().next(); Cookie cookie = cookies.iterator().next();
@ -78,7 +81,8 @@ public class CookieDecoderTest {
} }
@Test @Test
public void testDecodingSingleCookieV1() { 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<Cookie> cookies = CookieDecoder.decode(cookieString); Set<Cookie> cookies = CookieDecoder.decode(cookieString);
assertEquals(1, cookies.size()); assertEquals(1, cookies.size());
Cookie cookie = cookies.iterator().next(); Cookie cookie = cookies.iterator().next();
@ -97,7 +101,9 @@ public class CookieDecoderTest {
@Test @Test
public void testDecodingSingleCookieV1ExtraParamsIgnored() { 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<Cookie> cookies = CookieDecoder.decode(cookieString); Set<Cookie> cookies = CookieDecoder.decode(cookieString);
assertEquals(1, cookies.size()); assertEquals(1, cookies.size());
Cookie cookie = cookies.iterator().next(); Cookie cookie = cookies.iterator().next();
@ -115,7 +121,9 @@ public class CookieDecoderTest {
} }
@Test @Test
public void testDecodingSingleCookieV2() { 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<Cookie> cookies = CookieDecoder.decode(cookieString); Set<Cookie> cookies = CookieDecoder.decode(cookieString);
assertEquals(1, cookies.size()); assertEquals(1, cookies.size());
Cookie cookie = cookies.iterator().next(); Cookie cookie = cookies.iterator().next();
@ -134,11 +142,14 @@ public class CookieDecoderTest {
assertEquals(2, cookie.getVersion()); assertEquals(2, cookie.getVersion());
} }
@Test @Test
public void testDecodingMultipleCookies() { 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 c1 = "myCookie=myValue;max-age=50;path=/apathsomewhere;" +
String c2 = "myCookie2=myValue2;max-age=0;path=/anotherpathsomewhere;domain=.anotherdomainsomewhere;comment=this is another comment;version=2;commentURL=http://anotherurl.com;"; "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;"; String c3 = "myCookie3=myValue3;max-age=0;version=2;";
Set<Cookie> cookies = CookieDecoder.decode(c1 + c2 + c3); Set<Cookie> cookies = CookieDecoder.decode(c1 + c2 + c3);
@ -173,7 +184,7 @@ public class CookieDecoderTest {
cookie = it.next(); cookie = it.next();
assertNotNull(cookie); assertNotNull(cookie);
assertEquals("myValue3", cookie.getValue()); assertEquals("myValue3", cookie.getValue());
assertNull( cookie.getComment()); assertNull(cookie.getComment());
assertNull(cookie.getCommentUrl()); assertNull(cookie.getCommentUrl());
assertNull(cookie.getDomain()); assertNull(cookie.getDomain());
assertFalse(cookie.isDiscard()); assertFalse(cookie.isDiscard());
@ -268,7 +279,6 @@ public class CookieDecoderTest {
"g=\"\\\\\"," + "g=\"\\\\\"," +
"h=\"';,\\x\""; "h=\"';,\\x\"";
Set<Cookie> cookies = CookieDecoder.decode(source); Set<Cookie> cookies = CookieDecoder.decode(source);
Iterator<Cookie> it = cookies.iterator(); Iterator<Cookie> it = cookies.iterator();
Cookie c; Cookie c;
@ -315,7 +325,8 @@ public class CookieDecoderTest {
"kw-2E343B92-B097-442c-BFA5-BE371E0325A2=unfinished furniture; " + "kw-2E343B92-B097-442c-BFA5-BE371E0325A2=unfinished furniture; " +
"__utma=48461872.1094088325.1258140131.1258140131.1258140131.1; " + "__utma=48461872.1094088325.1258140131.1258140131.1258140131.1; " +
"__utmb=48461872.13.10.1258140131; __utmc=48461872; " + "__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<Cookie> cookies = CookieDecoder.decode(source); Set<Cookie> cookies = CookieDecoder.decode(source);
Iterator<Cookie> it = cookies.iterator(); Iterator<Cookie> it = cookies.iterator();
Cookie c; Cookie c;
@ -334,7 +345,9 @@ public class CookieDecoderTest {
c = it.next(); c = it.next();
assertEquals("__utmz", c.getName()); 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(); c = it.next();
assertEquals("ARPT", c.getName()); assertEquals("ARPT", c.getName());

View File

@ -58,7 +58,8 @@ public class CookieEncoderTest {
@Test @Test
public void testEncodingSingleCookieV1() { 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 cookie = new DefaultCookie("myCookie", "myValue");
cookie.setVersion(1); cookie.setVersion(1);
cookie.setComment("this is a Comment"); cookie.setComment("this is a Comment");
@ -72,7 +73,9 @@ public class CookieEncoderTest {
@Test @Test
public void testEncodingSingleCookieV2() { 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 cookie = new DefaultCookie("myCookie", "myValue");
cookie.setVersion(1); cookie.setVersion(1);
cookie.setComment("this is a Comment"); cookie.setComment("this is a Comment");
@ -89,8 +92,10 @@ public class CookieEncoderTest {
@Test @Test
public void testEncodingMultipleClientCookies() { public void testEncodingMultipleClientCookies() {
String c1 = "$Version=1; myCookie=myValue; $Path=\"/apathsomewhere\"; $Domain=.adomainsomewhere; $Port=\"80,8080\"; "; String c1 = "$Version=1; myCookie=myValue; $Path=\"/apathsomewhere\"; " +
String c2 = "$Version=1; myCookie2=myValue2; $Path=\"/anotherpathsomewhere\"; $Domain=.anotherdomainsomewhere; "; "$Domain=.adomainsomewhere; $Port=\"80,8080\"; ";
String c2 = "$Version=1; myCookie2=myValue2; $Path=\"/anotherpathsomewhere\"; " +
"$Domain=.anotherdomainsomewhere; ";
String c3 = "$Version=1; myCookie3=myValue3"; String c3 = "$Version=1; myCookie3=myValue3";
Cookie cookie = new DefaultCookie("myCookie", "myValue"); Cookie cookie = new DefaultCookie("myCookie", "myValue");
cookie.setVersion(1); cookie.setVersion(1);

View File

@ -26,13 +26,14 @@ import static org.junit.Assert.*;
public class HttpClientCodecTest { 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"
+ "<html><body></body></html>\r\n"; + "<html><body></body></html>\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" private static final String INCOMPLETE_CHUNKED_RESPONSE = "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" +
+"5\r\n" + "first\r\n" + "6\r\n" + "second\r\n" + "0\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"; private static final String CHUNKED_RESPONSE = INCOMPLETE_CHUNKED_RESPONSE + "\r\n";
@Test @Test
public void testFailsNotOnRequestResponse() { public void testFailsNotOnRequestResponse() {
HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true); HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
@ -58,7 +59,8 @@ public class HttpClientCodecTest {
HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true); HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
EmbeddedByteChannel ch = new EmbeddedByteChannel(codec); 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()); assertNotNull(ch.readOutbound());
try { try {
@ -67,7 +69,6 @@ public class HttpClientCodecTest {
} catch (CodecException e) { } catch (CodecException e) {
assertTrue(e instanceof PrematureChannelClosureException); assertTrue(e instanceof PrematureChannelClosureException);
} }
} }
@Test @Test
@ -84,6 +85,5 @@ public class HttpClientCodecTest {
} catch (CodecException e) { } catch (CodecException e) {
assertTrue(e instanceof PrematureChannelClosureException); assertTrue(e instanceof PrematureChannelClosureException);
} }
} }
} }

View File

@ -34,31 +34,29 @@ public class HttpHeaderDateFormatTest {
public void testParse() throws ParseException { public void testParse() throws ParseException {
HttpHeaderDateFormat format = new HttpHeaderDateFormat(); HttpHeaderDateFormat format = new HttpHeaderDateFormat();
{ final Date parsedDateWithSingleDigitDay = format.parse("Sun, 6 Nov 1994 08:49:37 GMT");
final Date parsed = format.parse("Sun, 6 Nov 1994 08:49:37 GMT"); Assert.assertNotNull(parsedDateWithSingleDigitDay);
Assert.assertNotNull(parsed); Assert.assertEquals(DATE, parsedDateWithSingleDigitDay);
Assert.assertEquals(DATE, parsed);
} final Date parsedDateWithDoubleDigitDay = format.parse("Sun, 06 Nov 1994 08:49:37 GMT");
{ Assert.assertNotNull(parsedDateWithDoubleDigitDay);
final Date parsed = format.parse("Sun, 06 Nov 1994 08:49:37 GMT"); Assert.assertEquals(DATE, parsedDateWithDoubleDigitDay);
Assert.assertNotNull(parsed);
Assert.assertEquals(DATE, parsed); final Date parsedDateWithDashSeparatorSingleDigitDay = format.parse("Sunday, 06-Nov-94 08:49:37 GMT");
} Assert.assertNotNull(parsedDateWithDashSeparatorSingleDigitDay);
{ Assert.assertEquals(DATE, parsedDateWithDashSeparatorSingleDigitDay);
final Date parsed = format.parse("Sunday, 06-Nov-94 08:49:37 GMT");
Assert.assertNotNull(parsed); final Date parsedDateWithSingleDoubleDigitDay = format.parse("Sunday, 6-Nov-94 08:49:37 GMT");
Assert.assertEquals(DATE, parsed); Assert.assertNotNull(parsedDateWithSingleDoubleDigitDay);
} Assert.assertEquals(DATE, parsedDateWithSingleDoubleDigitDay);
{
final Date parsed = format.parse("Sunday, 6-Nov-94 08:49:37 GMT"); final Date parsedDateWithoutGMT = format.parse("Sun Nov 6 08:49:37 1994");
Assert.assertNotNull(parsed); Assert.assertNotNull(parsedDateWithoutGMT);
Assert.assertEquals(DATE, parsed); Assert.assertEquals(DATE, parsedDateWithoutGMT);
} }
{
final Date parsed = format.parse("Sun Nov 6 08:49:37 1994"); private Date parseDate(HttpHeaderDateFormat dateFormat, String dateStr) throws ParseException {
Assert.assertNotNull(parsed); return dateFormat.parse(dateStr);
Assert.assertEquals(DATE, parsed);
}
} }
@Test @Test

View File

@ -52,11 +52,11 @@ public class HttpObjecctAggregatorTest {
DefaultFullHttpRequest aggratedMessage = (DefaultFullHttpRequest) embedder.readInbound(); DefaultFullHttpRequest aggratedMessage = (DefaultFullHttpRequest) embedder.readInbound();
assertNotNull(aggratedMessage); 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-Test"), Boolean.TRUE.toString());
checkContentBuffer(aggratedMessage); checkContentBuffer(aggratedMessage);
assertNull(embedder.readInbound()); assertNull(embedder.readInbound());
} }
private static void checkContentBuffer(DefaultFullHttpRequest aggregatedMessage) { private static void checkContentBuffer(DefaultFullHttpRequest aggregatedMessage) {
@ -93,16 +93,15 @@ public class HttpObjecctAggregatorTest {
DefaultFullHttpRequest aggratedMessage = (DefaultFullHttpRequest) embedder.readInbound(); DefaultFullHttpRequest aggratedMessage = (DefaultFullHttpRequest) embedder.readInbound();
assertNotNull(aggratedMessage); 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-Test"), Boolean.TRUE.toString());
assertEquals(aggratedMessage.headers().get("X-Trailer"), Boolean.TRUE.toString()); assertEquals(aggratedMessage.headers().get("X-Trailer"), Boolean.TRUE.toString());
checkContentBuffer(aggratedMessage); checkContentBuffer(aggratedMessage);
assertNull(embedder.readInbound()); assertNull(embedder.readInbound());
} }
@Test(expected = TooLongFrameException.class) @Test(expected = TooLongFrameException.class)
public void testTooLongFrameException() { public void testTooLongFrameException() {
HttpObjectAggregator aggr = new HttpObjectAggregator(4); HttpObjectAggregator aggr = new HttpObjectAggregator(4);
@ -115,7 +114,6 @@ public class HttpObjecctAggregatorTest {
assertFalse(embedder.writeInbound(chunk1)); assertFalse(embedder.writeInbound(chunk1));
embedder.writeInbound(chunk2); embedder.writeInbound(chunk2);
fail(); fail();
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@ -125,7 +123,7 @@ public class HttpObjecctAggregatorTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidMaxCumulationBufferComponents() { public void testInvalidMaxCumulationBufferComponents() {
HttpObjectAggregator aggr= new HttpObjectAggregator(Integer.MAX_VALUE); HttpObjectAggregator aggr = new HttpObjectAggregator(Integer.MAX_VALUE);
aggr.setMaxCumulationBufferComponents(1); aggr.setMaxCumulationBufferComponents(1);
} }

View File

@ -37,7 +37,6 @@ public class HttpRequestEncoderTest {
assertEquals("GET http://localhost/ HTTP/1.1\r\n", req); assertEquals("GET http://localhost/ HTTP/1.1\r\n", req);
} }
@Test @Test
public void testUriWithPath() throws Exception { public void testUriWithPath() throws Exception {
HttpRequestEncoder encoder = new HttpRequestEncoder(); HttpRequestEncoder encoder = new HttpRequestEncoder();
@ -47,4 +46,4 @@ public class HttpRequestEncoderTest {
String req = buffer.toString(Charset.forName("US-ASCII")); String req = buffer.toString(Charset.forName("US-ASCII"));
assertEquals("GET http://localhost/ HTTP/1.1\r\n", req); assertEquals("GET http://localhost/ HTTP/1.1\r\n", req);
} }
} }

View File

@ -184,7 +184,6 @@ public class QueryStringDecoderTest {
Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals(1, entry.getValue().size());
Assert.assertEquals("value1", entry.getValue().get(0)); Assert.assertEquals("value1", entry.getValue().get(0));
entry = entries.next(); entry = entries.next();
Assert.assertEquals("param2", entry.getKey()); Assert.assertEquals("param2", entry.getKey());
Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals(1, entry.getValue().size());
@ -213,7 +212,6 @@ public class QueryStringDecoderTest {
Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals(1, entry.getValue().size());
Assert.assertEquals("value1", entry.getValue().get(0)); Assert.assertEquals("value1", entry.getValue().get(0));
entry = entries.next(); entry = entries.next();
Assert.assertEquals("param2", entry.getKey()); Assert.assertEquals("param2", entry.getKey());
Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals(1, entry.getValue().size());
@ -242,7 +240,6 @@ public class QueryStringDecoderTest {
Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals(1, entry.getValue().size());
Assert.assertEquals("value1", entry.getValue().get(0)); Assert.assertEquals("value1", entry.getValue().get(0));
entry = entries.next(); entry = entries.next();
Assert.assertEquals("param2", entry.getKey()); Assert.assertEquals("param2", entry.getKey());
Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals(1, entry.getValue().size());

View File

@ -36,7 +36,8 @@ public class HttpPostRequestDecoderTest {
public void testBinaryStreamUpload() throws Exception { public void testBinaryStreamUpload() throws Exception {
final String boundary = "dLV9Wyq26L_-JQxk6ferf-RT153LhOO"; 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.setDecoderResult(DecoderResult.SUCCESS);
req.headers().add(HttpHeaders.Names.CONTENT_TYPE, "multipart/form-data; boundary=" + boundary); req.headers().add(HttpHeaders.Names.CONTENT_TYPE, "multipart/form-data; boundary=" + boundary);
@ -77,7 +78,8 @@ public class HttpPostRequestDecoderTest {
public void testFullHttpRequestUpload() throws Exception { public void testFullHttpRequestUpload() throws Exception {
final String boundary = "dLV9Wyq26L_-JQxk6ferf-RT153LhOO"; 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.setDecoderResult(DecoderResult.SUCCESS);
req.headers().add(HttpHeaders.Names.CONTENT_TYPE, "multipart/form-data; boundary=" + boundary); req.headers().add(HttpHeaders.Names.CONTENT_TYPE, "multipart/form-data; boundary=" + boundary);
@ -100,6 +102,5 @@ public class HttpPostRequestDecoderTest {
// Create decoder instance to test. // Create decoder instance to test.
final HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(inMemoryFactory, req); final HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(inMemoryFactory, req);
assertFalse(decoder.getBodyHttpDatas().isEmpty()); assertFalse(decoder.getBodyHttpDatas().isEmpty());
} }
} }

View File

@ -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;

View File

@ -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;

View File

@ -1,12 +1,12 @@
/* /*
* Copyright 2012 The Netty Project * Copyright 2012 The Netty Project
* *
* The Netty Project licenses this file to you under the Apache License, version * 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 * 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: * License. You may obtain a copy of the License at:
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * 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.*; import static io.netty.handler.codec.http.HttpVersion.*;
public class WebSocketRequestBuilder { public class WebSocketRequestBuilder {
private HttpVersion httpVersion; private HttpVersion httpVersion;
private HttpMethod method; private HttpMethod method;
private String uri; private String uri;
@ -37,17 +37,17 @@ public class WebSocketRequestBuilder {
private String key; private String key;
private String origin; private String origin;
private WebSocketVersion version; private WebSocketVersion version;
public WebSocketRequestBuilder httpVersion(HttpVersion httpVersion) { public WebSocketRequestBuilder httpVersion(HttpVersion httpVersion) {
this.httpVersion = httpVersion; this.httpVersion = httpVersion;
return this; return this;
} }
public WebSocketRequestBuilder method(HttpMethod method) { public WebSocketRequestBuilder method(HttpMethod method) {
this.method = method; this.method = method;
return this; return this;
} }
public WebSocketRequestBuilder uri(String uri) { public WebSocketRequestBuilder uri(String uri) {
this.uri = uri; this.uri = uri;
return this; return this;
@ -57,46 +57,46 @@ public class WebSocketRequestBuilder {
this.host = host; this.host = host;
return this; return this;
} }
public WebSocketRequestBuilder upgrade(String upgrade) { public WebSocketRequestBuilder upgrade(String upgrade) {
this.upgrade = upgrade; this.upgrade = upgrade;
return this; return this;
} }
public WebSocketRequestBuilder connection(String connection) { public WebSocketRequestBuilder connection(String connection) {
this.connection = connection; this.connection = connection;
return this; return this;
} }
public WebSocketRequestBuilder key(String key) { public WebSocketRequestBuilder key(String key) {
this.key = key; this.key = key;
return this; return this;
} }
public WebSocketRequestBuilder origin(String origin) { public WebSocketRequestBuilder origin(String origin) {
this.origin = origin; this.origin = origin;
return this; return this;
} }
public WebSocketRequestBuilder version13() { public WebSocketRequestBuilder version13() {
version = WebSocketVersion.V13; version = WebSocketVersion.V13;
return this; return this;
} }
public WebSocketRequestBuilder version8() { public WebSocketRequestBuilder version8() {
version = WebSocketVersion.V08; version = WebSocketVersion.V08;
return this; return this;
} }
public WebSocketRequestBuilder version00() { public WebSocketRequestBuilder version00() {
version = null; version = null;
return this; return this;
} }
public WebSocketRequestBuilder noVersion() { public WebSocketRequestBuilder noVersion() {
return this; return this;
} }
public FullHttpRequest build() { public FullHttpRequest build() {
FullHttpRequest req = new DefaultFullHttpRequest(httpVersion, method, uri); FullHttpRequest req = new DefaultFullHttpRequest(httpVersion, method, uri);
HttpHeaders headers = req.headers(); HttpHeaders headers = req.headers();
@ -121,7 +121,7 @@ public class WebSocketRequestBuilder {
} }
return req; return req;
} }
public static HttpRequest sucessful() { public static HttpRequest sucessful() {
return new WebSocketRequestBuilder().httpVersion(HTTP_1_1) return new WebSocketRequestBuilder().httpVersion(HTTP_1_1)
.method(HttpMethod.GET) .method(HttpMethod.GET)

View File

@ -1,12 +1,12 @@
/* /*
* Copyright 2012 The Netty Project * Copyright 2012 The Netty Project
* *
* The Netty Project licenses this file to you under the Apache License, version * 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 * 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: * License. You may obtain a copy of the License at:
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@ -45,24 +45,22 @@ public class WebSocketServerProtocolHandlerTest {
public void testHttpUpgradeRequest() throws Exception { public void testHttpUpgradeRequest() throws Exception {
EmbeddedMessageChannel ch = createChannel(new MockOutboundHandler()); EmbeddedMessageChannel ch = createChannel(new MockOutboundHandler());
ChannelHandlerContext handshakerCtx = ch.pipeline().context(WebSocketServerProtocolHandshakeHandler.class); ChannelHandlerContext handshakerCtx = ch.pipeline().context(WebSocketServerProtocolHandshakeHandler.class);
writeUpgradeRequest(ch); writeUpgradeRequest(ch);
assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus()); assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
assertNotNull(WebSocketServerProtocolHandler.getHandshaker(handshakerCtx)); assertNotNull(WebSocketServerProtocolHandler.getHandshaker(handshakerCtx));
} }
@Test @Test
public void testSubsequentHttpRequestsAfterUpgradeShouldReturn403() throws Exception { public void testSubsequentHttpRequestsAfterUpgradeShouldReturn403() throws Exception {
EmbeddedMessageChannel ch = createChannel(new MockOutboundHandler()); EmbeddedMessageChannel ch = createChannel(new MockOutboundHandler());
writeUpgradeRequest(ch); writeUpgradeRequest(ch);
assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus()); assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
ch.writeInbound(new DefaultFullHttpRequest(HTTP_1_1, HttpMethod.GET, "/test")); ch.writeInbound(new DefaultFullHttpRequest(HTTP_1_1, HttpMethod.GET, "/test"));
assertEquals(FORBIDDEN, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus()); assertEquals(FORBIDDEN, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
} }
@Test @Test
public void testHttpUpgradeRequestInvalidUpgradeHeader() { public void testHttpUpgradeRequestInvalidUpgradeHeader() {
EmbeddedMessageChannel ch = createChannel(); EmbeddedMessageChannel ch = createChannel();
@ -73,15 +71,14 @@ public class WebSocketServerProtocolHandlerTest {
.version00() .version00()
.upgrade("BogusSocket") .upgrade("BogusSocket")
.build(); .build();
ch.writeInbound(httpRequestWithEntity); ch.writeInbound(httpRequestWithEntity);
FullHttpResponse response = getHttpResponse(ch); FullHttpResponse response = getHttpResponse(ch);
assertEquals(BAD_REQUEST, response.getStatus()); assertEquals(BAD_REQUEST, response.getStatus());
assertEquals("not a WebSocket handshake request: missing upgrade", getResponseMessage(response)); assertEquals("not a WebSocket handshake request: missing upgrade", getResponseMessage(response));
} }
@Test @Test
public void testHttpUpgradeRequestMissingWSKeyHeader() { public void testHttpUpgradeRequestMissingWSKeyHeader() {
EmbeddedMessageChannel ch = createChannel(); EmbeddedMessageChannel ch = createChannel();
@ -93,14 +90,14 @@ public class WebSocketServerProtocolHandlerTest {
.upgrade(WEBSOCKET.toLowerCase()) .upgrade(WEBSOCKET.toLowerCase())
.version13() .version13()
.build(); .build();
ch.writeInbound(httpRequest); ch.writeInbound(httpRequest);
FullHttpResponse response = getHttpResponse(ch); FullHttpResponse response = getHttpResponse(ch);
assertEquals(BAD_REQUEST, response.getStatus()); assertEquals(BAD_REQUEST, response.getStatus());
assertEquals("not a WebSocket request: missing key", getResponseMessage(response)); assertEquals("not a WebSocket request: missing key", getResponseMessage(response));
} }
@Test @Test
public void testHandleTextFrame() { public void testHandleTextFrame() {
CustomTextFrameHandler customTextFrameHandler = new CustomTextFrameHandler(); CustomTextFrameHandler customTextFrameHandler = new CustomTextFrameHandler();
@ -108,16 +105,16 @@ public class WebSocketServerProtocolHandlerTest {
writeUpgradeRequest(ch); writeUpgradeRequest(ch);
// Removing the HttpRequestDecoder as we are writing a TextWebSocketFrame so decoding is not neccessary. // Removing the HttpRequestDecoder as we are writing a TextWebSocketFrame so decoding is not neccessary.
ch.pipeline().remove(HttpRequestDecoder.class); ch.pipeline().remove(HttpRequestDecoder.class);
ch.writeInbound(new TextWebSocketFrame("payload")); ch.writeInbound(new TextWebSocketFrame("payload"));
assertEquals("processed: payload", customTextFrameHandler.getContent()); assertEquals("processed: payload", customTextFrameHandler.getContent());
} }
private static EmbeddedMessageChannel createChannel() { private static EmbeddedMessageChannel createChannel() {
return createChannel(null); return createChannel(null);
} }
private static EmbeddedMessageChannel createChannel(ChannelHandler handler) { private static EmbeddedMessageChannel createChannel(ChannelHandler handler) {
return new EmbeddedMessageChannel( return new EmbeddedMessageChannel(
new WebSocketServerProtocolHandler("/test", null, false), new WebSocketServerProtocolHandler("/test", null, false),
@ -126,7 +123,7 @@ public class WebSocketServerProtocolHandlerTest {
new MockOutboundHandler(), new MockOutboundHandler(),
handler); handler);
} }
private static void writeUpgradeRequest(EmbeddedMessageChannel ch) { private static void writeUpgradeRequest(EmbeddedMessageChannel ch) {
ch.writeInbound(WebSocketRequestBuilder.sucessful()); ch.writeInbound(WebSocketRequestBuilder.sucessful());
} }
@ -158,7 +155,7 @@ public class WebSocketServerProtocolHandlerTest {
//NoOp //NoOp
} }
} }
private static class CustomTextFrameHandler extends ChannelInboundMessageHandlerAdapter<TextWebSocketFrame> { private static class CustomTextFrameHandler extends ChannelInboundMessageHandlerAdapter<TextWebSocketFrame> {
private String content; private String content;
@ -166,7 +163,7 @@ public class WebSocketServerProtocolHandlerTest {
public void messageReceived(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception {
content = "processed: " + msg.text(); content = "processed: " + msg.text();
} }
String getContent() { String getContent() {
return content; return content;
} }

View File

@ -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
* <a href="http://en.wikipedia.org/wiki/Web_Sockets">Web Socket</a> data frames.
*/
package io.netty.handler.codec.http.websocketx;

View File

@ -147,8 +147,8 @@ public class SpdySessionHandlerTest {
assertNull(sessionHandler.readOutbound()); assertNull(sessionHandler.readOutbound());
SpdyHeadersFrame spdyHeadersFrame = new DefaultSpdyHeadersFrame(localStreamID); SpdyHeadersFrame spdyHeadersFrame = new DefaultSpdyHeadersFrame(localStreamID);
spdyHeadersFrame.headers().add("HEADER","test1"); spdyHeadersFrame.headers().add("HEADER", "test1");
spdyHeadersFrame.headers().add("HEADER","test2"); spdyHeadersFrame.headers().add("HEADER", "test2");
sessionHandler.writeInbound(spdyHeadersFrame); sessionHandler.writeInbound(spdyHeadersFrame);
assertHeaders(sessionHandler.readOutbound(), localStreamID, spdyHeadersFrame); assertHeaders(sessionHandler.readOutbound(), localStreamID, spdyHeadersFrame);
@ -178,7 +178,6 @@ public class SpdySessionHandlerTest {
assertNull(sessionHandler.readOutbound()); assertNull(sessionHandler.readOutbound());
spdySynStreamFrame.setUnidirectional(false); spdySynStreamFrame.setUnidirectional(false);
// Check if session handler returns PROTOCOL_ERROR if it receives // Check if session handler returns PROTOCOL_ERROR if it receives
// multiple SYN_STREAM frames for the same active Stream-ID // multiple SYN_STREAM frames for the same active Stream-ID
sessionHandler.writeInbound(spdySynStreamFrame); sessionHandler.writeInbound(spdySynStreamFrame);
@ -194,7 +193,6 @@ public class SpdySessionHandlerTest {
assertNull(sessionHandler.readOutbound()); assertNull(sessionHandler.readOutbound());
spdySynStreamFrame.setStreamId(localStreamID); spdySynStreamFrame.setStreamId(localStreamID);
// Check if session handler correctly limits the number of // Check if session handler correctly limits the number of
// concurrent streams in the SETTINGS frame // concurrent streams in the SETTINGS frame
SpdySettingsFrame spdySettingsFrame = new DefaultSpdySettingsFrame(); SpdySettingsFrame spdySettingsFrame = new DefaultSpdySettingsFrame();

View File

@ -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;

View File

@ -25,8 +25,8 @@ import static org.junit.Assert.*;
public class SocksAuthResponseDecoderTest { public class SocksAuthResponseDecoderTest {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksAuthResponseDecoderTest.class); private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksAuthResponseDecoderTest.class);
private static void testSocksAuthResponseDecoderWithDifferentParams(SocksAuthStatus authStatus){ private static void testSocksAuthResponseDecoderWithDifferentParams(SocksAuthStatus authStatus) {
logger.debug("Testing SocksAuthResponseDecoder with authStatus: "+ authStatus); logger.debug("Testing SocksAuthResponseDecoder with authStatus: " + authStatus);
SocksAuthResponse msg = new SocksAuthResponse(authStatus); SocksAuthResponse msg = new SocksAuthResponse(authStatus);
SocksAuthResponseDecoder decoder = new SocksAuthResponseDecoder(); SocksAuthResponseDecoder decoder = new SocksAuthResponseDecoder();
EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder); EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder);
@ -37,9 +37,9 @@ public class SocksAuthResponseDecoderTest {
} }
@Test @Test
public void testSocksCmdResponseDecoder(){ public void testSocksCmdResponseDecoder() {
for (SocksAuthStatus authStatus: SocksAuthStatus.values()){ for (SocksAuthStatus authStatus: SocksAuthStatus.values()) {
testSocksAuthResponseDecoderWithDifferentParams(authStatus); testSocksAuthResponseDecoderWithDifferentParams(authStatus);
} }
} }
} }

View File

@ -26,8 +26,12 @@ import static org.junit.Assert.*;
public class SocksCmdRequestDecoderTest { public class SocksCmdRequestDecoderTest {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksCmdRequestDecoderTest.class); private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksCmdRequestDecoderTest.class);
private static void testSocksCmdRequestDecoderWithDifferentParams(SocksCmdType cmdType, SocksAddressType addressType, String host, int port) { private static void testSocksCmdRequestDecoderWithDifferentParams(SocksCmdType cmdType,
logger.debug("Testing cmdType: " + cmdType + " addressType: " + addressType + " host: " + host + " port: " + port); 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); SocksCmdRequest msg = new SocksCmdRequest(cmdType, addressType, host, port);
SocksCmdRequestDecoder decoder = new SocksCmdRequestDecoder(); SocksCmdRequestDecoder decoder = new SocksCmdRequestDecoder();
EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder); EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder);
@ -46,7 +50,7 @@ public class SocksCmdRequestDecoderTest {
@Test @Test
public void testCmdRequestDecoderIPv4() { public void testCmdRequestDecoderIPv4() {
String[] hosts = {"127.0.0.1",}; String[] hosts = {"127.0.0.1", };
int[] ports = {0, 32769, 65535 }; int[] ports = {0, 32769, 65535 };
for (SocksCmdType cmdType : SocksCmdType.values()) { for (SocksCmdType cmdType : SocksCmdType.values()) {
for (String host : hosts) { for (String host : hosts) {

View File

@ -21,70 +21,70 @@ import static org.junit.Assert.*;
public class SocksCmdRequestTest { public class SocksCmdRequestTest {
@Test @Test
public void testConstructorParamsAreNotNull(){ public void testConstructorParamsAreNotNull() {
try { try {
new SocksCmdRequest(null, SocksAddressType.UNKNOWN, "", 0); new SocksCmdRequest(null, SocksAddressType.UNKNOWN, "", 0);
} catch (Exception e){ } catch (Exception e) {
assertTrue(e instanceof NullPointerException); assertTrue(e instanceof NullPointerException);
} }
try { try {
new SocksCmdRequest(SocksCmdType.UNKNOWN, null, "", 0); new SocksCmdRequest(SocksCmdType.UNKNOWN, null, "", 0);
} catch (Exception e){ } catch (Exception e) {
assertTrue(e instanceof NullPointerException); assertTrue(e instanceof NullPointerException);
} }
try { try {
new SocksCmdRequest(SocksCmdType.UNKNOWN, SocksAddressType.UNKNOWN, null, 0); new SocksCmdRequest(SocksCmdType.UNKNOWN, SocksAddressType.UNKNOWN, null, 0);
} catch (Exception e){ } catch (Exception e) {
assertTrue(e instanceof NullPointerException); assertTrue(e instanceof NullPointerException);
} }
} }
@Test @Test
public void testIPv4CorrectAddress(){ public void testIPv4CorrectAddress() {
try { try {
new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.IPv4, "54.54.1111.253", 0); new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.IPv4, "54.54.1111.253", 0);
} catch (Exception e){ } catch (Exception e) {
assertTrue(e instanceof IllegalArgumentException); assertTrue(e instanceof IllegalArgumentException);
} }
} }
@Test @Test
public void testIPv6CorrectAddress(){ public void testIPv6CorrectAddress() {
try { try {
new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.IPv6, "xxx:xxx:xxx", 0); new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.IPv6, "xxx:xxx:xxx", 0);
} catch (Exception e){ } catch (Exception e) {
assertTrue(e instanceof IllegalArgumentException); assertTrue(e instanceof IllegalArgumentException);
} }
} }
@Test @Test
public void testIDNNotExceeds255CharsLimit(){ public void testIDNNotExceeds255CharsLimit() {
try { try {
new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.DOMAIN, new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.DOMAIN,
"παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή" + "παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή" +
"παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή" + "παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή" +
"παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή" + "παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή" +
"παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή", 0); "παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή", 0);
} catch (Exception e){ } catch (Exception e) {
assertTrue(e instanceof IllegalArgumentException); assertTrue(e instanceof IllegalArgumentException);
} }
} }
@Test @Test
public void testValidPortRange(){ public void testValidPortRange() {
try { try {
new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.DOMAIN, new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.DOMAIN,
"παράδειγμα.δοκιμήπαράδει", -1); "παράδειγμα.δοκιμήπαράδει", -1);
} catch (Exception e){ } catch (Exception e) {
assertTrue(e instanceof IllegalArgumentException); assertTrue(e instanceof IllegalArgumentException);
} }
try { try {
new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.DOMAIN, new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.DOMAIN,
"παράδειγμα.δοκιμήπαράδει", 65536); "παράδειγμα.δοκιμήπαράδει", 65536);
} catch (Exception e){ } catch (Exception e) {
assertTrue(e instanceof IllegalArgumentException); assertTrue(e instanceof IllegalArgumentException);
} }
} }

View File

@ -25,13 +25,14 @@ import static org.junit.Assert.*;
public class SocksCmdResponseDecoderTest { public class SocksCmdResponseDecoderTest {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksCmdResponseDecoderTest.class); 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); logger.debug("Testing cmdStatus: " + cmdStatus + " addressType: " + addressType);
SocksResponse msg = new SocksCmdResponse(cmdStatus, addressType); SocksResponse msg = new SocksCmdResponse(cmdStatus, addressType);
SocksCmdResponseDecoder decoder = new SocksCmdResponseDecoder(); SocksCmdResponseDecoder decoder = new SocksCmdResponseDecoder();
EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder); EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder);
SocksCommonTestUtils.writeMessageIntoEmbedder(embedder, msg); SocksCommonTestUtils.writeMessageIntoEmbedder(embedder, msg);
if (addressType == SocksAddressType.UNKNOWN){ if (addressType == SocksAddressType.UNKNOWN) {
assertTrue(embedder.readInbound() instanceof UnknownSocksResponse); assertTrue(embedder.readInbound() instanceof UnknownSocksResponse);
} else { } else {
msg = (SocksResponse) embedder.readInbound(); msg = (SocksResponse) embedder.readInbound();
@ -41,9 +42,9 @@ public class SocksCmdResponseDecoderTest {
} }
@Test @Test
public void testSocksCmdResponseDecoder(){ public void testSocksCmdResponseDecoder() {
for (SocksCmdStatus cmdStatus: SocksCmdStatus.values()){ for (SocksCmdStatus cmdStatus: SocksCmdStatus.values()) {
for (SocksAddressType addressType: SocksAddressType.values()){ for (SocksAddressType addressType: SocksAddressType.values()) {
testSocksCmdResponseDecoderWithDifferentParams(cmdStatus, addressType); testSocksCmdResponseDecoderWithDifferentParams(cmdStatus, addressType);
} }
} }

View File

@ -20,10 +20,10 @@ import static org.junit.Assert.assertTrue;
public class SocksInitRequestTest { public class SocksInitRequestTest {
@Test @Test
public void testConstructorParamsAreNotNull(){ public void testConstructorParamsAreNotNull() {
try { try {
new SocksInitRequest(null); new SocksInitRequest(null);
} catch (Exception e){ } catch (Exception e) {
assertTrue(e instanceof NullPointerException); assertTrue(e instanceof NullPointerException);
} }
} }

View File

@ -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;

View File

@ -30,41 +30,45 @@ public class DelimiterBasedFrameDecoderTest {
@Test @Test
public void testMultipleLinesStrippedDelimiters() { 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())); ch.writeInbound(Unpooled.copiedBuffer("TestLine\r\ng\r\n", Charset.defaultCharset()));
assertEquals("TestLine", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset())); assertEquals("TestLine", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset()));
assertEquals("g", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset())); assertEquals("g", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset()));
assertNull(ch.readInbound()); assertNull(ch.readInbound());
} }
@Test @Test
public void testIncompleteLinesStrippedDelimiters() { 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())); ch.writeInbound(Unpooled.copiedBuffer("Test", Charset.defaultCharset()));
assertNull(ch.readInbound()); assertNull(ch.readInbound());
ch.writeInbound(Unpooled.copiedBuffer("Line\r\ng\r\n", Charset.defaultCharset())); ch.writeInbound(Unpooled.copiedBuffer("Line\r\ng\r\n", Charset.defaultCharset()));
assertEquals("TestLine", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset())); assertEquals("TestLine", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset()));
assertEquals("g", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset())); assertEquals("g", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset()));
assertNull(ch.readInbound()); assertNull(ch.readInbound());
} }
@Test @Test
public void testMultipleLines() { 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())); ch.writeInbound(Unpooled.copiedBuffer("TestLine\r\ng\r\n", Charset.defaultCharset()));
assertEquals("TestLine\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())); assertEquals("g\r\n", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset()));
assertNull(ch.readInbound()); assertNull(ch.readInbound());
} }
@Test @Test
public void testIncompleteLines() { 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())); ch.writeInbound(Unpooled.copiedBuffer("Test", Charset.defaultCharset()));
assertNull(ch.readInbound()); assertNull(ch.readInbound());
ch.writeInbound(Unpooled.copiedBuffer("Line\r\ng\r\n", Charset.defaultCharset())); ch.writeInbound(Unpooled.copiedBuffer("Line\r\ng\r\n", Charset.defaultCharset()));
assertEquals("TestLine\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())); assertEquals("g\r\n", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset()));
assertNull(ch.readInbound()); assertNull(ch.readInbound());
} }
@ -74,9 +78,8 @@ public class DelimiterBasedFrameDecoderTest {
new DelimiterBasedFrameDecoder(8192, true, Delimiters.lineDelimiter())); new DelimiterBasedFrameDecoder(8192, true, Delimiters.lineDelimiter()));
ch.writeInbound(Unpooled.copiedBuffer("first\r\nsecond\nthird", CharsetUtil.US_ASCII)); ch.writeInbound(Unpooled.copiedBuffer("first\r\nsecond\nthird", CharsetUtil.US_ASCII));
assertEquals("first", ((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)); assertEquals("second", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII));
assertNull(ch.readInbound()); assertNull(ch.readInbound());
} }
} }

View File

@ -28,18 +28,17 @@ public class LineBasedFrameDecoderTest {
EmbeddedByteChannel ch = new EmbeddedByteChannel(new LineBasedFrameDecoder(8192, true, false)); EmbeddedByteChannel ch = new EmbeddedByteChannel(new LineBasedFrameDecoder(8192, true, false));
ch.writeInbound(Unpooled.copiedBuffer("first\r\nsecond\nthird", CharsetUtil.US_ASCII)); ch.writeInbound(Unpooled.copiedBuffer("first\r\nsecond\nthird", CharsetUtil.US_ASCII));
Assert.assertEquals("first", ((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.assertEquals("second", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII));
Assert.assertNull(ch.readInbound()); Assert.assertNull(ch.readInbound());
} }
@Test @Test
public void testDecodeWithoutStrip() throws Exception { public void testDecodeWithoutStrip() throws Exception {
EmbeddedByteChannel ch = new EmbeddedByteChannel(new LineBasedFrameDecoder(8192, false, false)); EmbeddedByteChannel ch = new EmbeddedByteChannel(new LineBasedFrameDecoder(8192, false, false));
ch.writeInbound(Unpooled.copiedBuffer("first\r\nsecond\nthird", CharsetUtil.US_ASCII)); 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("first\r\n", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII));
Assert.assertEquals("second\n", ((ByteBuf)ch.readInbound()).toString(CharsetUtil.US_ASCII)); Assert.assertEquals("second\n", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII));
Assert.assertNull(ch.readInbound()); Assert.assertNull(ch.readInbound());
} }
} }

View File

@ -24,13 +24,14 @@ import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
public class ReplayingDecoderBufferTest { public class ReplayingDecoderBufferTest {
/** /**
* See https://github.com/netty/netty/issues/445 * See https://github.com/netty/netty/issues/445
*/ */
@Test @Test
public void testGetUnsignedByte() { 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; boolean error;
int i = 0; int i = 0;
@ -52,7 +53,8 @@ public class ReplayingDecoderBufferTest {
*/ */
@Test @Test
public void testGetByte() { 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; boolean error;
int i = 0; int i = 0;
@ -68,14 +70,14 @@ public class ReplayingDecoderBufferTest {
assertTrue(error); assertTrue(error);
assertEquals(10, i); assertEquals(10, i);
} }
/** /**
* See https://github.com/netty/netty/issues/445 * See https://github.com/netty/netty/issues/445
*/ */
@Test @Test
public void testGetBoolean() { public void testGetBoolean() {
ByteBuf buf = Unpooled.buffer(10); ByteBuf buf = Unpooled.buffer(10);
while(buf.isWritable()) { while (buf.isWritable()) {
buf.writeBoolean(true); buf.writeBoolean(true);
} }
ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(buf); ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(buf);

View File

@ -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;

View File

@ -37,25 +37,21 @@ public class JZlibTest {
byte[] deflatedData = chEncoder.readOutbound().array(); byte[] deflatedData = chEncoder.readOutbound().array();
{ EmbeddedByteChannel chDecoderZlib =
EmbeddedByteChannel chDecoder =
new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB)); new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB));
chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData)); chDecoderZlib.writeInbound(Unpooled.wrappedBuffer(deflatedData));
assertTrue(chDecoder.finish()); assertTrue(chDecoderZlib.finish());
assertEquals(data, chDecoder.readInbound()); assertEquals(data, chDecoderZlib.readInbound());
}
{ EmbeddedByteChannel chDecoderZlibOrNone =
EmbeddedByteChannel chDecoder =
new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB_OR_NONE)); new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB_OR_NONE));
chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData)); chDecoderZlibOrNone.writeInbound(Unpooled.wrappedBuffer(deflatedData));
assertTrue(chDecoder.finish()); assertTrue(chDecoderZlibOrNone.finish());
assertEquals(data, chDecoder.readInbound()); assertEquals(data, chDecoderZlibOrNone.readInbound());
}
} }
@Test @Test
@ -67,31 +63,26 @@ public class JZlibTest {
chEncoder.writeOutbound(data); chEncoder.writeOutbound(data);
assertTrue(chEncoder.finish()); assertTrue(chEncoder.finish());
byte[] deflatedData = chEncoder.readOutbound().array(); byte[] deflatedData = chEncoder.readOutbound().array();
{ EmbeddedByteChannel chDecoderZlibNone =
EmbeddedByteChannel chDecoder =
new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.NONE)); new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.NONE));
chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData)); chDecoderZlibNone.writeInbound(Unpooled.wrappedBuffer(deflatedData));
assertTrue(chDecoder.finish()); assertTrue(chDecoderZlibNone.finish());
assertEquals(data, chDecoder.readInbound()); assertEquals(data, chDecoderZlibNone.readInbound());
}
{ EmbeddedByteChannel chDecoderZlibOrNone =
EmbeddedByteChannel chDecoder =
new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB_OR_NONE)); new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB_OR_NONE));
chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData)); chDecoderZlibOrNone.writeInbound(Unpooled.wrappedBuffer(deflatedData));
assertTrue(chDecoder.finish()); assertTrue(chDecoderZlibOrNone.finish());
assertEquals(data, chDecoder.readInbound()); assertEquals(data, chDecoderZlibOrNone.readInbound());
}
} }
@Test @Test
public void testGZIP() throws Exception { public void testGZIP() throws Exception {
ByteBuf data = Unpooled.wrappedBuffer("test".getBytes()); ByteBuf data = Unpooled.wrappedBuffer("test".getBytes());
@ -104,24 +95,20 @@ public class JZlibTest {
byte[] deflatedData = chEncoder.readOutbound().array(); byte[] deflatedData = chEncoder.readOutbound().array();
{ EmbeddedByteChannel chDecoderGZip =
EmbeddedByteChannel chDecoder =
new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.GZIP)); new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.GZIP));
chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData)); chDecoderGZip.writeInbound(Unpooled.wrappedBuffer(deflatedData));
assertTrue(chDecoder.finish()); assertTrue(chDecoderGZip.finish());
assertEquals(data, chDecoder.readInbound()); assertEquals(data, chDecoderGZip.readInbound());
}
{ EmbeddedByteChannel chDecoderZlibOrNone =
EmbeddedByteChannel chDecoder =
new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB_OR_NONE)); new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB_OR_NONE));
chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData)); chDecoderZlibOrNone.writeInbound(Unpooled.wrappedBuffer(deflatedData));
assertTrue(chDecoder.finish()); assertTrue(chDecoderZlibOrNone.finish());
assertEquals(data, chDecoder.readInbound()); assertEquals(data, chDecoderZlibOrNone.readInbound());
}
} }
} }

View File

@ -25,7 +25,7 @@ import static org.junit.Assert.*;
public class SnappyFramedEncoderTest { public class SnappyFramedEncoderTest {
private EmbeddedByteChannel channel; private EmbeddedByteChannel channel;
@Before @Before
public void setUp() { public void setUp() {
channel = new EmbeddedByteChannel(new SnappyFramedEncoder()); channel = new EmbeddedByteChannel(new SnappyFramedEncoder());
@ -85,7 +85,7 @@ public class SnappyFramedEncoderTest {
}); });
assertEquals(expected, channel.readOutbound()); assertEquals(expected, channel.readOutbound());
} }
/** /**
* This test asserts that if we have a remainder after emitting a copy that * 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 * 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, -1, // copy
-1, 1 // remainder -1, 1 // remainder
}); });
channel.writeOutbound(in); channel.writeOutbound(in);
assertTrue(channel.finish()); assertTrue(channel.finish());
} }

View File

@ -70,12 +70,11 @@ public class SnappyIntegrationTest {
})); }));
} }
// These tests were found using testRandom() with large RANDOM_RUNS. // These tests were found using testRandom() with large RANDOM_RUNS.
// Tests that copies do not attempt to overrun into a previous frame chunk // Tests that copies do not attempt to overrun into a previous frame chunk
@Test @Test
public void test5323211032315942961(){ public void test5323211032315942961() {
testWithSeed(5323211032315942961L); testWithSeed(5323211032315942961L);
} }

View File

@ -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;

View File

@ -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;

View File

@ -121,12 +121,12 @@ public abstract class AbstractCompatibleMarshallingDecoderTest {
} }
protected ChannelHandler createDecoder(int maxObjectSize) { 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) { protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) {
return new DefaultUnmarshallerProvider(factory, config); return new DefaultUnmarshallerProvider(factory, config);
} }
protected abstract MarshallerFactory createMarshallerFactory(); protected abstract MarshallerFactory createMarshallerFactory();

View File

@ -21,7 +21,6 @@ import org.jboss.marshalling.MarshallingConfiguration;
public class RiverCompatibleMarshallingEncoderTest extends AbstractCompatibleMarshallingEncoderTest { public class RiverCompatibleMarshallingEncoderTest extends AbstractCompatibleMarshallingEncoderTest {
@Override @Override
protected MarshallerFactory createMarshallerFactory() { protected MarshallerFactory createMarshallerFactory() {
return Marshalling.getProvidedMarshallerFactory("river"); return Marshalling.getProvidedMarshallerFactory("river");

View File

@ -25,5 +25,4 @@ public class RiverContextBoundCompatibleMarshallingDecoderTest extends RiverComp
return new ContextBoundUnmarshallerProvider(factory, config); return new ContextBoundUnmarshallerProvider(factory, config);
} }
} }

View File

@ -25,5 +25,4 @@ public class RiverContextBoundMarshallingDecoderTest extends RiverMarshallingDec
return new ContextBoundUnmarshallerProvider(factory, config); return new ContextBoundUnmarshallerProvider(factory, config);
} }
} }

View File

@ -30,8 +30,8 @@ public class RiverMarshallingDecoderTest extends RiverCompatibleMarshallingDecod
@Override @Override
protected ChannelHandler createDecoder(int maxObjectSize) { protected ChannelHandler createDecoder(int maxObjectSize) {
return new MarshallingDecoder(createProvider(createMarshallerFactory(), createMarshallingConfig()), maxObjectSize); return new MarshallingDecoder(createProvider(createMarshallerFactory(),
createMarshallingConfig()), maxObjectSize);
} }
} }

View File

@ -25,5 +25,4 @@ public class RiverThreadLocalCompatibleMarshallingDecoderTest extends RiverCompa
return new ThreadLocalUnmarshallerProvider(factory, config); return new ThreadLocalUnmarshallerProvider(factory, config);
} }
} }

View File

@ -25,5 +25,4 @@ public class RiverThreadLocalMarshallingDecoderTest extends RiverMarshallingDeco
return new ThreadLocalUnmarshallerProvider(factory, config); return new ThreadLocalUnmarshallerProvider(factory, config);
} }
} }

View File

@ -21,7 +21,6 @@ import org.jboss.marshalling.MarshallingConfiguration;
public class SerialCompatibleMarshallingEncoderTest extends AbstractCompatibleMarshallingEncoderTest { public class SerialCompatibleMarshallingEncoderTest extends AbstractCompatibleMarshallingEncoderTest {
@Override @Override
protected MarshallerFactory createMarshallerFactory() { protected MarshallerFactory createMarshallerFactory() {
return Marshalling.getProvidedMarshallerFactory("serial"); return Marshalling.getProvidedMarshallerFactory("serial");

View File

@ -20,7 +20,6 @@ import org.jboss.marshalling.MarshallingConfiguration;
public class SerialContextBoundCompatibleMarshallingDecoderTest extends SerialCompatibleMarshallingDecoderTest { public class SerialContextBoundCompatibleMarshallingDecoderTest extends SerialCompatibleMarshallingDecoderTest {
@Override @Override
protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) { protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) {
return new ContextBoundUnmarshallerProvider(factory, config); return new ContextBoundUnmarshallerProvider(factory, config);

View File

@ -20,7 +20,6 @@ import org.jboss.marshalling.MarshallingConfiguration;
public class SerialContextBoundMarshallingDecoderTest extends SerialMarshallingDecoderTest { public class SerialContextBoundMarshallingDecoderTest extends SerialMarshallingDecoderTest {
@Override @Override
protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) { protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) {
return new ContextBoundUnmarshallerProvider(factory, config); return new ContextBoundUnmarshallerProvider(factory, config);

View File

@ -30,7 +30,8 @@ public class SerialMarshallingDecoderTest extends SerialCompatibleMarshallingDec
@Override @Override
protected ChannelHandler createDecoder(int maxObjectSize) { protected ChannelHandler createDecoder(int maxObjectSize) {
return new MarshallingDecoder(createProvider(createMarshallerFactory(), createMarshallingConfig()), maxObjectSize); return new MarshallingDecoder(createProvider(createMarshallerFactory(),
createMarshallingConfig()), maxObjectSize);
} }
} }

View File

@ -18,7 +18,7 @@ package io.netty.handler.codec.marshalling;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
public class SerialMarshallingEncoderTest extends SerialCompatibleMarshallingEncoderTest{ public class SerialMarshallingEncoderTest extends SerialCompatibleMarshallingEncoderTest {
@Override @Override
protected ByteBuf truncate(ByteBuf buf) { protected ByteBuf truncate(ByteBuf buf) {

View File

@ -20,7 +20,6 @@ import org.jboss.marshalling.MarshallingConfiguration;
public class SerialThreadLocalCompatibleMarshallingDecoderTest extends SerialCompatibleMarshallingDecoderTest { public class SerialThreadLocalCompatibleMarshallingDecoderTest extends SerialCompatibleMarshallingDecoderTest {
@Override @Override
protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) { protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) {
return new ThreadLocalUnmarshallerProvider(factory, config); return new ThreadLocalUnmarshallerProvider(factory, config);

View File

@ -20,7 +20,6 @@ import org.jboss.marshalling.MarshallingConfiguration;
public class SerialThreadLocalMarshallingDecoderTest extends SerialMarshallingDecoderTest { public class SerialThreadLocalMarshallingDecoderTest extends SerialMarshallingDecoderTest {
@Override @Override
protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) { protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) {
return new ThreadLocalUnmarshallerProvider(factory, config); return new ThreadLocalUnmarshallerProvider(factory, config);

View File

@ -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
* <a href="http://www.jboss.org/jbossmarshalling">JBoss Marshalling</a>.
*/
package io.netty.handler.codec.marshalling;

View File

@ -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;

View File

@ -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
* <a href="http://code.google.com/p/protobuf/">Google Protocol Buffers</a>
* {@link com.google.protobuf.Message} into a {@link io.netty.buffer.ByteBuf}
* and vice versa.
*/
package io.netty.handler.codec.protobuf;

View File

@ -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;

View File

@ -24,7 +24,7 @@ import java.util.Map.Entry;
import static org.junit.Assert.*; import static org.junit.Assert.*;
public class NetUtilTest { public class NetUtilTest {
private final static Map<String, byte[]> validIpV4Hosts = new HashMap<String, byte[]>() { private static final Map<String, byte[]> validIpV4Hosts = new HashMap<String, byte[]>() {
private static final long serialVersionUID = 2629792739366724032L; private static final long serialVersionUID = 2629792739366724032L;
{ {
put("192.168.1.0", new byte[]{ put("192.168.1.0", new byte[]{
@ -42,10 +42,9 @@ public class NetUtilTest {
put("127.0.0.1", new byte[]{ put("127.0.0.1", new byte[]{
0x7f, 0x00, 0x00, 0x01 0x7f, 0x00, 0x00, 0x01
}); });
} }
}; };
private final static Map<String, byte[]> invalidIpV4Hosts = new HashMap<String, byte[]>() { private static final Map<String, byte[]> invalidIpV4Hosts = new HashMap<String, byte[]>() {
private static final long serialVersionUID = 1299215199895717282L; private static final long serialVersionUID = 1299215199895717282L;
{ {
put("1.256.3.4", null); put("1.256.3.4", null);
@ -53,7 +52,7 @@ public class NetUtilTest {
put("1.1.1.1.1", null); put("1.1.1.1.1", null);
} }
}; };
private final static Map<String, byte[]> validIpV6Hosts = new HashMap<String, byte[]>() { private static final Map<String, byte[]> validIpV6Hosts = new HashMap<String, byte[]>() {
private static final long serialVersionUID = 3999763170377573184L; private static final long serialVersionUID = 3999763170377573184L;
{ {
put("::ffff:5.6.7.8", new byte[]{ put("::ffff:5.6.7.8", new byte[]{
@ -165,7 +164,7 @@ public class NetUtilTest {
); );
} }
}; };
private final static Map<String, byte[]> invalidIpV6Hosts = new HashMap<String, byte[]>() { private static final Map<String, byte[]> invalidIpV6Hosts = new HashMap<String, byte[]>() {
private static final long serialVersionUID = -5870810805409009696L; private static final long serialVersionUID = -5870810805409009696L;
{ {
// Test method with garbage. // Test method with garbage.

View File

@ -47,12 +47,12 @@ public class UniqueNameTest {
names = PlatformDependent.newConcurrentHashMap(); names = PlatformDependent.newConcurrentHashMap();
} }
@Test(expected=NullPointerException.class) @Test(expected = NullPointerException.class)
public void testCannnotProvideNullMap() { public void testCannnotProvideNullMap() {
new UniqueName(null, "Nothing"); new UniqueName(null, "Nothing");
} }
@Test(expected=NullPointerException.class) @Test(expected = NullPointerException.class)
public void testCannotProvideNullName() { public void testCannotProvideNullName() {
new UniqueName(names, null); new UniqueName(names, null);
} }

View File

@ -20,7 +20,7 @@ import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
public class StringUtilTest { public class StringUtilTest {
@Test @Test
public void ensureNewlineExists() { public void ensureNewlineExists() {
assertNotNull(StringUtil.NEWLINE); assertNotNull(StringUtil.NEWLINE);

View File

@ -77,7 +77,7 @@ public class TypeParameterMatcherTest {
public static class TypeY<D extends C, E extends A, F extends B> extends TypeX<E, F, D> { } public static class TypeY<D extends C, E extends A, F extends B> extends TypeX<E, F, D> { }
public static abstract class TypeZ<G extends AA, H extends BB> extends TypeY<CC, G, H> { } public abstract static class TypeZ<G extends AA, H extends BB> extends TypeY<CC, G, H> { }
public static class TypeQ<I extends BBB> extends TypeZ<AAA, I> { } public static class TypeQ<I extends BBB> extends TypeZ<AAA, I> { }

View File

@ -43,7 +43,6 @@ public class InternalLoggerFactoryTest {
InternalLoggerFactory.setDefaultFactory(oldLoggerFactory); InternalLoggerFactory.setDefaultFactory(oldLoggerFactory);
} }
@Test(expected = NullPointerException.class) @Test(expected = NullPointerException.class)
public void shouldNotAllowNullDefaultFactory() { public void shouldNotAllowNullDefaultFactory() {
InternalLoggerFactory.setDefaultFactory(null); InternalLoggerFactory.setDefaultFactory(null);
@ -52,12 +51,12 @@ public class InternalLoggerFactoryTest {
@Test @Test
public void shouldGetInstance() { public void shouldGetInstance() {
InternalLoggerFactory.setDefaultFactory(oldLoggerFactory); InternalLoggerFactory.setDefaultFactory(oldLoggerFactory);
String helloWorld = "Hello, world!"; String helloWorld = "Hello, world!";
InternalLogger one = InternalLoggerFactory.getInstance("helloWorld"); InternalLogger one = InternalLoggerFactory.getInstance("helloWorld");
InternalLogger two = InternalLoggerFactory.getInstance(helloWorld.getClass()); InternalLogger two = InternalLoggerFactory.getInstance(helloWorld.getClass());
assertNotNull(one); assertNotNull(one);
assertNotNull(two); assertNotNull(two);
assertNotSame(one, two); assertNotSame(one, two);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -24,7 +24,6 @@ import io.netty.channel.embedded.EmbeddedByteChannel;
import io.netty.channel.embedded.EmbeddedMessageChannel; import io.netty.channel.embedded.EmbeddedMessageChannel;
import io.netty.util.CharsetUtil; import io.netty.util.CharsetUtil;
import org.junit.Test; import org.junit.Test;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -68,19 +67,20 @@ public class ChunkedWriteHandlerTest {
public void testChunkedStream() { public void testChunkedStream() {
check(new ChunkedStream(new ByteArrayInputStream(BYTES))); 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 @Test
public void testChunkedNioStream() { public void testChunkedNioStream() {
check(new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES)))); 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 @Test
public void testChunkedFile() throws IOException { public void testChunkedFile() throws IOException {
check(new ChunkedFile(TMP)); check(new ChunkedFile(TMP));
@ -96,7 +96,7 @@ public class ChunkedWriteHandlerTest {
} }
// Test case which shows that there is not a bug like stated here: // 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 @Test
public void testListenerNotifiedWhenIsEnd() { public void testListenerNotifiedWhenIsEnd() {
ByteBuf buffer = Unpooled.copiedBuffer("Test", CharsetUtil.ISO_8859_1); ByteBuf buffer = Unpooled.copiedBuffer("Test", CharsetUtil.ISO_8859_1);
@ -146,7 +146,6 @@ public class ChunkedWriteHandlerTest {
assertEquals(buffer, ch.readOutbound()); assertEquals(buffer, ch.readOutbound());
assertNull(ch.readOutbound()); assertNull(ch.readOutbound());
} }
@Test @Test
@ -184,7 +183,6 @@ public class ChunkedWriteHandlerTest {
assertEquals(0, ch.readOutbound()); assertEquals(0, ch.readOutbound());
assertNull(ch.readOutbound()); assertNull(ch.readOutbound());
} }
private static void check(ChunkedInput<?>... inputs) { private static void check(ChunkedInput<?>... inputs) {

View File

@ -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;

View File

@ -14,21 +14,6 @@
* under the License. * 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. * Copyright (C) 2010 Google Inc.
* *

View File

@ -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;

View File

@ -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_HEAP = new PooledByteBufAllocator(false);
private static final ByteBufAllocator POOLED_ALLOCATOR_DIRECT = new PooledByteBufAllocator(true); 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; private int size;
@Param @Param

View File

@ -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;

View File

@ -118,7 +118,8 @@ public abstract class DefaultBenchmark extends SimpleBenchmark {
deleted = true; deleted = true;
System.out.println(); 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()));
} }
} }
} }

View File

@ -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;

View File

@ -361,6 +361,7 @@
<failsOnError>true</failsOnError> <failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation> <failOnViolation>true</failOnViolation>
<configLocation>io/netty/checkstyle.xml</configLocation> <configLocation>io/netty/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>

View File

@ -49,7 +49,5 @@ public class DependencyIT {
} else { } else {
System.out.println("all transitive dependencies are osgi bundles"); System.out.println("all transitive dependencies are osgi bundles");
} }
} }
} }

View File

@ -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;

View File

@ -29,7 +29,7 @@ import org.osgi.framework.wiring.BundleWiring;
/** /**
* Unit Test Utilities. * Unit Test Utilities.
*/ */
public class UnitHelp { public final class UnitHelp {
private UnitHelp() { private UnitHelp() {
} }
@ -106,7 +106,6 @@ public class UnitHelp {
/** install java unit bundles */ /** install java unit bundles */
junitBundles()); junitBundles());
} }
/** /**

View File

@ -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;

View File

@ -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;

View File

@ -45,7 +45,7 @@ public abstract class AbstractSctpTest {
protected volatile Bootstrap cb; protected volatile Bootstrap cb;
protected volatile InetSocketAddress addr; protected volatile InetSocketAddress addr;
protected volatile Factory<Bootstrap> currentBootstrap; protected volatile Factory<Bootstrap> currentBootstrap;
protected void run() throws Throwable { protected void run() throws Throwable {
int i = 0; int i = 0;
for (Entry<Factory<ServerBootstrap>, Factory<Bootstrap>> e: COMBO) { for (Entry<Factory<ServerBootstrap>, Factory<Bootstrap>> e: COMBO) {

View File

@ -41,7 +41,7 @@ import static org.junit.Assert.*;
public class SctpEchoTest extends AbstractSctpTest { public class SctpEchoTest extends AbstractSctpTest {
private static final Random random = new Random(); 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 { static {
random.nextBytes(data); random.nextBytes(data);
@ -95,7 +95,7 @@ public class SctpEchoTest extends AbstractSctpTest {
Channel sc = sb.bind().sync().channel(); Channel sc = sb.bind().sync().channel();
Channel cc = cb.connect().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); int length = Math.min(random.nextInt(1024 * 64), data.length - i);
cc.write(Unpooled.wrappedBuffer(data, i, length)); cc.write(Unpooled.wrappedBuffer(data, i, length));
i += length; i += length;

View File

@ -117,8 +117,7 @@ public final class SctpTestPermutation {
return list; return list;
} }
private SctpTestPermutation() { }
private SctpTestPermutation() {}
interface Factory<T> { interface Factory<T> {
T newInstance(); T newInstance();

View File

@ -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;

View File

@ -45,8 +45,7 @@ public abstract class AbstractClientSocketTest {
int i = 0; int i = 0;
for (Factory<Bootstrap> e: COMBO) { for (Factory<Bootstrap> e: COMBO) {
cb = e.newInstance(); cb = e.newInstance();
addr = new InetSocketAddress( addr = new InetSocketAddress(NetUtil.LOCALHOST, TestUtils.getFreePort());
NetUtil.LOCALHOST, TestUtils.getFreePort());
cb.remoteAddress(addr); cb.remoteAddress(addr);
logger.info(String.format( logger.info(String.format(

View File

@ -45,7 +45,7 @@ public abstract class AbstractSocketTest {
protected volatile Bootstrap cb; protected volatile Bootstrap cb;
protected volatile InetSocketAddress addr; protected volatile InetSocketAddress addr;
protected volatile Factory<Bootstrap> currentBootstrap; protected volatile Factory<Bootstrap> currentBootstrap;
protected void run() throws Throwable { protected void run() throws Throwable {
int i = 0; int i = 0;
for (Entry<Factory<ServerBootstrap>, Factory<Bootstrap>> e: COMBO) { for (Entry<Factory<ServerBootstrap>, Factory<Bootstrap>> e: COMBO) {

View File

@ -92,7 +92,6 @@ public class DatagramMulticastTest extends AbstractDatagramTest {
sc.close().awaitUninterruptibly(); sc.close().awaitUninterruptibly();
cc.close().awaitUninterruptibly(); cc.close().awaitUninterruptibly();
} }
private static final class MulticastTestHandler extends ChannelInboundMessageHandlerAdapter<DatagramPacket> { private static final class MulticastTestHandler extends ChannelInboundMessageHandlerAdapter<DatagramPacket> {

View File

@ -68,7 +68,6 @@ public class SocketShutdownOutputBySelfTest extends AbstractClientSocketTest {
// If half-closed, the peer should be able to write something. // If half-closed, the peer should be able to write something.
s.getOutputStream().write(1); s.getOutputStream().write(1);
assertEquals(1, (int) h.queue.take()); assertEquals(1, (int) h.queue.take());
} finally { } finally {
if (s != null) { if (s != null) {
s.close(); s.close();

View File

@ -63,7 +63,6 @@ public class SocketSslEchoTest extends AbstractSocketTest {
testSslEcho0(sb, cb, false); testSslEcho0(sb, cb, false);
} }
@Test @Test
public void testSslEchoWithChunkHandler() throws Throwable { public void testSslEchoWithChunkHandler() throws Throwable {
run(); run();

View File

@ -200,7 +200,7 @@ final class SocketTestPermutation {
return list; return list;
} }
private SocketTestPermutation() {} private SocketTestPermutation() { }
interface Factory<T> { interface Factory<T> {
T newInstance(); T newInstance();

View File

@ -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;

View File

@ -16,12 +16,15 @@
package io.netty.testsuite.util; package io.netty.testsuite.util;
import io.netty.util.NetUtil; import io.netty.util.NetUtil;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.nio.channels.Channel; 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 { public final class TestUtils {

View File

@ -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;

View File

@ -30,7 +30,7 @@ public abstract class AbstractUdtTest {
* UDT test assumptions. * UDT test assumptions.
*/ */
@BeforeClass @BeforeClass
public static void assumeConditions(){ public static void assumeConditions() {
assumeTrue(UnitHelp.canLoadAndInitClass("com.barchart.udt.SocketUDT")); assumeTrue(UnitHelp.canLoadAndInitClass("com.barchart.udt.SocketUDT"));
} }

View File

@ -82,7 +82,6 @@ public class NioUdtByteRendezvousChannelTest extends AbstractUdtTest {
.meter().count()); .meter().count());
Thread.sleep(1000); Thread.sleep(1000);
} }
connectFuture1.channel().close().sync(); connectFuture1.channel().close().sync();
@ -98,7 +97,6 @@ public class NioUdtByteRendezvousChannelTest extends AbstractUdtTest {
boot1.shutdown(); boot1.shutdown();
boot2.shutdown(); boot2.shutdown();
} }
} }

View File

@ -44,7 +44,6 @@ public class NioUdtMessageRendezvousChannelTest extends AbstractUdtTest {
@Test @Test
public void metadata() throws Exception { public void metadata() throws Exception {
assertEquals(BufType.MESSAGE, new NioUdtMessageRendezvousChannel().metadata().bufferType()); assertEquals(BufType.MESSAGE, new NioUdtMessageRendezvousChannel().metadata().bufferType());
} }
/** /**
@ -87,7 +86,6 @@ public class NioUdtMessageRendezvousChannelTest extends AbstractUdtTest {
.meter().count()); .meter().count());
Thread.sleep(1000); Thread.sleep(1000);
} }
connectFuture1.channel().close().sync(); connectFuture1.channel().close().sync();
@ -103,7 +101,6 @@ public class NioUdtMessageRendezvousChannelTest extends AbstractUdtTest {
boot1.shutdown(); boot1.shutdown();
boot2.shutdown(); boot2.shutdown();
} }
} }

View File

@ -38,7 +38,7 @@ public class NioUdtProviderTest extends AbstractUdtTest {
assertNotNull(NioUdtProvider.MESSAGE_ACCEPTOR.newChannel()); assertNotNull(NioUdtProvider.MESSAGE_ACCEPTOR.newChannel());
assertNotNull(NioUdtProvider.MESSAGE_CONNECTOR.newChannel()); assertNotNull(NioUdtProvider.MESSAGE_CONNECTOR.newChannel());
assertNotNull(NioUdtProvider.MESSAGE_RENDEZVOUS.newChannel()); assertNotNull(NioUdtProvider.MESSAGE_RENDEZVOUS.newChannel());
// acceptor types // acceptor types
assertTrue(NioUdtProvider.BYTE_ACCEPTOR.newChannel() instanceof UdtServerChannel); assertTrue(NioUdtProvider.BYTE_ACCEPTOR.newChannel() instanceof UdtServerChannel);
assertTrue(NioUdtProvider.MESSAGE_ACCEPTOR.newChannel() instanceof UdtServerChannel); assertTrue(NioUdtProvider.MESSAGE_ACCEPTOR.newChannel() instanceof UdtServerChannel);

View File

@ -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;

View File

@ -46,7 +46,6 @@ public final class BootHelp {
.localAddress(self).remoteAddress(peer).handler(handler); .localAddress(self).remoteAddress(peer).handler(handler);
return boot; return boot;
} }
/** /**
@ -67,7 +66,6 @@ public final class BootHelp {
.localAddress(self).remoteAddress(peer).handler(handler); .localAddress(self).remoteAddress(peer).handler(handler);
return boot; return boot;
} }
private BootHelp() { } private BootHelp() { }

View File

@ -94,7 +94,6 @@ public abstract class CaliperBench extends SimpleBenchmark {
continue; continue;
} }
} }
} }
} }

View File

@ -147,21 +147,18 @@ public class CaliperMeasure {
/** ignore complete blank entries */ /** ignore complete blank entries */
return; return;
} }
{
final Measurement mark = new Measurement(RATE_UNIT, rateValue, final Measurement markRate = new Measurement(RATE_UNIT, rateValue,
rateValue); rateValue);
rateMap.put(System.nanoTime(), mark); rateMap.put(System.nanoTime(), markRate);
}
{ final Measurement markTime = new Measurement(TIME_UNIT, timeValue,
final Measurement mark = new Measurement(TIME_UNIT, timeValue, timeValue);
timeValue); timeMap.put(System.nanoTime(), markTime);
timeMap.put(System.nanoTime(), mark);
} final Measurement markSize = new Measurement(SIZE_UNIT, sizeValue,
{ sizeValue);
final Measurement mark = new Measurement(SIZE_UNIT, sizeValue, sizeMap.put(System.nanoTime(), markSize);
sizeValue);
sizeMap.put(System.nanoTime(), mark);
}
} }
private final Map<String, String> variables = new HashMap<String, String>(); private final Map<String, String> variables = new HashMap<String, String>();

Some files were not shown because too many files have changed in this diff Show More