enable checkstyle for test source directory and fix checkstyle errors
This commit is contained in:
parent
8e23ab6886
commit
05850da863
@ -1519,7 +1519,6 @@ public abstract class AbstractByteBufTest {
|
||||
buffer.setIndex(0, value.length);
|
||||
buffer.setBytes(0, value);
|
||||
|
||||
|
||||
assertEquals(0, buffer.compareTo(wrappedBuffer(value)));
|
||||
assertEquals(0, buffer.compareTo(wrappedBuffer(value).order(LITTLE_ENDIAN)));
|
||||
|
||||
|
@ -99,7 +99,8 @@ public abstract class AbstractCompositeByteBufTest extends
|
||||
*/
|
||||
@Test
|
||||
public void testComponentAtOffset() {
|
||||
CompositeByteBuf buf = (CompositeByteBuf) wrappedBuffer(new byte[]{1, 2, 3, 4, 5}, new byte[]{4, 5, 6, 7, 8, 9, 26});
|
||||
CompositeByteBuf buf = (CompositeByteBuf) wrappedBuffer(new byte[]{1, 2, 3, 4, 5},
|
||||
new byte[]{4, 5, 6, 7, 8, 9, 26});
|
||||
|
||||
//Ensure that a random place will be fine
|
||||
assertEquals(5, buf.componentAtOffset(2).capacity());
|
||||
@ -412,7 +413,7 @@ public abstract class AbstractCompositeByteBufTest extends
|
||||
assertFalse(BufUtil.equals(a, b));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void testEmptyBuffer() {
|
||||
ByteBuf b = freeLater(wrappedBuffer(new byte[]{1, 2}, new byte[]{3, 4}));
|
||||
b.readBytes(new byte[4]);
|
||||
|
@ -105,8 +105,6 @@ public class ByteBufDerivationTest {
|
||||
|
||||
ro.setIndex(2, 6);
|
||||
assertThat(buf.readerIndex(), is(1));
|
||||
assertThat(buf.writerIndex(), is(7));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -22,7 +22,6 @@ import java.nio.charset.Charset;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
/**
|
||||
* Tests channel buffer streams
|
||||
*/
|
||||
@ -173,33 +172,33 @@ public class ByteBufStreamTest {
|
||||
|
||||
@Test
|
||||
public void testReadLine() throws Exception {
|
||||
Charset utf8=Charset.forName("UTF-8");
|
||||
Charset utf8 = Charset.forName("UTF-8");
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
ByteBufInputStream in = new ByteBufInputStream(buf);
|
||||
|
||||
String s = in.readLine();
|
||||
assertNull(s);
|
||||
|
||||
int charCount=5;//total chars in the string below without new line characters
|
||||
int charCount = 5; //total chars in the string below without new line characters
|
||||
byte[] abc = "a\nb\r\nc\nd\ne".getBytes(utf8);
|
||||
buf.writeBytes(abc);
|
||||
in.mark(charCount);
|
||||
assertEquals("a",in.readLine());
|
||||
assertEquals("b",in.readLine());
|
||||
assertEquals("c",in.readLine());
|
||||
assertEquals("d",in.readLine());
|
||||
assertEquals("e",in.readLine());
|
||||
assertEquals("a", in.readLine());
|
||||
assertEquals("b", in.readLine());
|
||||
assertEquals("c", in.readLine());
|
||||
assertEquals("d", in.readLine());
|
||||
assertEquals("e", in.readLine());
|
||||
assertNull(in.readLine());
|
||||
|
||||
in.reset();
|
||||
int count=0;
|
||||
while(in.readLine() != null){
|
||||
int count = 0;
|
||||
while (in.readLine() != null) {
|
||||
++count;
|
||||
if(count > charCount){
|
||||
if (count > charCount) {
|
||||
fail("readLine() should have returned null");
|
||||
}
|
||||
}
|
||||
assertEquals(charCount,count);
|
||||
assertEquals(charCount, count);
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class ConsolidationTest {
|
||||
public void shouldConsolidationInSequence() {
|
||||
ByteBuf currentBuffer = wrappedBuffer(wrappedBuffer("a".getBytes()), wrappedBuffer("=".getBytes()));
|
||||
currentBuffer = wrappedBuffer(currentBuffer, wrappedBuffer("1".getBytes()), wrappedBuffer("&".getBytes()));
|
||||
|
||||
|
||||
currentBuffer = wrappedBuffer(currentBuffer, wrappedBuffer("b".getBytes()), wrappedBuffer("=".getBytes()));
|
||||
currentBuffer = wrappedBuffer(currentBuffer, wrappedBuffer("2".getBytes()), wrappedBuffer("&".getBytes()));
|
||||
|
||||
@ -60,5 +60,5 @@ public class ConsolidationTest {
|
||||
|
||||
currentBuffer.release();
|
||||
copy.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ public class ReadOnlyDirectByteBufferBufTest {
|
||||
buf.setByte(0, 1);
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = ReadOnlyBufferException.class)
|
||||
public void testSetInt() {
|
||||
ByteBuf buf = buffer(allocate(8).asReadOnlyBuffer());
|
||||
@ -109,10 +108,10 @@ public class ReadOnlyDirectByteBufferBufTest {
|
||||
Assert.assertFalse(buf.isReadable());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetReadShort() {
|
||||
ByteBuf buf = buffer(((ByteBuffer) allocate(8).putShort((short) 1).putShort((short) 2).flip()).asReadOnlyBuffer());
|
||||
ByteBuf buf = buffer(((ByteBuffer) allocate(8).putShort((short) 1)
|
||||
.putShort((short) 2).flip()).asReadOnlyBuffer());
|
||||
Assert.assertEquals(1, buf.getShort(0));
|
||||
Assert.assertEquals(2, buf.getShort(2));
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class ReadOnlyUnsafeDirectByteBufferBufTest extends ReadOnlyDirectByteBuf
|
||||
* Needs unsafe to run
|
||||
*/
|
||||
@BeforeClass
|
||||
public static void assumeConditions(){
|
||||
public static void assumeConditions() {
|
||||
assumeTrue(PlatformDependent.hasUnsafe());
|
||||
}
|
||||
|
||||
|
@ -568,7 +568,6 @@ public class UnpooledTest {
|
||||
|
||||
assertEquals(0, Unpooled.copyBoolean(null).capacity());
|
||||
assertEquals(0, Unpooled.copyBoolean(new boolean[0]).capacity());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
21
buffer/src/test/java/io/netty/buffer/package-info.java
Normal file
21
buffer/src/test/java/io/netty/buffer/package-info.java
Normal 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;
|
@ -29,7 +29,8 @@ public class CookieDecoderTest {
|
||||
@Test
|
||||
public void testDecodingSingleCookieV0() {
|
||||
String cookieString = "myCookie=myValue;expires=XXX;path=/apathsomewhere;domain=.adomainsomewhere;secure;";
|
||||
cookieString = cookieString.replace("XXX", new HttpHeaderDateFormat().format(new Date(System.currentTimeMillis() + 50000)));
|
||||
cookieString = cookieString.replace("XXX",
|
||||
new HttpHeaderDateFormat().format(new Date(System.currentTimeMillis() + 50000)));
|
||||
|
||||
Set<Cookie> cookies = CookieDecoder.decode(cookieString);
|
||||
assertEquals(1, cookies.size());
|
||||
@ -60,7 +61,9 @@ public class CookieDecoderTest {
|
||||
|
||||
@Test
|
||||
public void testDecodingSingleCookieV0ExtraParamsIgnored() {
|
||||
String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;domain=.adomainsomewhere;secure;comment=this is a comment;version=0;commentURL=http://aurl.com;port=\"80,8080\";discard;";
|
||||
String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;" +
|
||||
"domain=.adomainsomewhere;secure;comment=this is a comment;version=0;" +
|
||||
"commentURL=http://aurl.com;port=\"80,8080\";discard;";
|
||||
Set<Cookie> cookies = CookieDecoder.decode(cookieString);
|
||||
assertEquals(1, cookies.size());
|
||||
Cookie cookie = cookies.iterator().next();
|
||||
@ -78,7 +81,8 @@ public class CookieDecoderTest {
|
||||
}
|
||||
@Test
|
||||
public void testDecodingSingleCookieV1() {
|
||||
String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;domain=.adomainsomewhere;secure;comment=this is a comment;version=1;";
|
||||
String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;" +
|
||||
"domain=.adomainsomewhere;secure;comment=this is a comment;version=1;";
|
||||
Set<Cookie> cookies = CookieDecoder.decode(cookieString);
|
||||
assertEquals(1, cookies.size());
|
||||
Cookie cookie = cookies.iterator().next();
|
||||
@ -97,7 +101,9 @@ public class CookieDecoderTest {
|
||||
|
||||
@Test
|
||||
public void testDecodingSingleCookieV1ExtraParamsIgnored() {
|
||||
String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;domain=.adomainsomewhere;secure;comment=this is a comment;version=1;commentURL=http://aurl.com;port='80,8080';discard;";
|
||||
String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;" +
|
||||
"domain=.adomainsomewhere;secure;comment=this is a comment;version=1;" +
|
||||
"commentURL=http://aurl.com;port='80,8080';discard;";
|
||||
Set<Cookie> cookies = CookieDecoder.decode(cookieString);
|
||||
assertEquals(1, cookies.size());
|
||||
Cookie cookie = cookies.iterator().next();
|
||||
@ -115,7 +121,9 @@ public class CookieDecoderTest {
|
||||
}
|
||||
@Test
|
||||
public void testDecodingSingleCookieV2() {
|
||||
String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;domain=.adomainsomewhere;secure;comment=this is a comment;version=2;commentURL=http://aurl.com;port=\"80,8080\";discard;";
|
||||
String cookieString = "myCookie=myValue;max-age=50;path=/apathsomewhere;" +
|
||||
"domain=.adomainsomewhere;secure;comment=this is a comment;version=2;" +
|
||||
"commentURL=http://aurl.com;port=\"80,8080\";discard;";
|
||||
Set<Cookie> cookies = CookieDecoder.decode(cookieString);
|
||||
assertEquals(1, cookies.size());
|
||||
Cookie cookie = cookies.iterator().next();
|
||||
@ -134,11 +142,14 @@ public class CookieDecoderTest {
|
||||
assertEquals(2, cookie.getVersion());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDecodingMultipleCookies() {
|
||||
String c1 = "myCookie=myValue;max-age=50;path=/apathsomewhere;domain=.adomainsomewhere;secure;comment=this is a comment;version=2;commentURL=\"http://aurl.com\";port='80,8080';discard;";
|
||||
String c2 = "myCookie2=myValue2;max-age=0;path=/anotherpathsomewhere;domain=.anotherdomainsomewhere;comment=this is another comment;version=2;commentURL=http://anotherurl.com;";
|
||||
String c1 = "myCookie=myValue;max-age=50;path=/apathsomewhere;" +
|
||||
"domain=.adomainsomewhere;secure;comment=this is a comment;version=2;" +
|
||||
"commentURL=\"http://aurl.com\";port='80,8080';discard;";
|
||||
String c2 = "myCookie2=myValue2;max-age=0;path=/anotherpathsomewhere;" +
|
||||
"domain=.anotherdomainsomewhere;comment=this is another comment;version=2;" +
|
||||
"commentURL=http://anotherurl.com;";
|
||||
String c3 = "myCookie3=myValue3;max-age=0;version=2;";
|
||||
|
||||
Set<Cookie> cookies = CookieDecoder.decode(c1 + c2 + c3);
|
||||
@ -173,7 +184,7 @@ public class CookieDecoderTest {
|
||||
cookie = it.next();
|
||||
assertNotNull(cookie);
|
||||
assertEquals("myValue3", cookie.getValue());
|
||||
assertNull( cookie.getComment());
|
||||
assertNull(cookie.getComment());
|
||||
assertNull(cookie.getCommentUrl());
|
||||
assertNull(cookie.getDomain());
|
||||
assertFalse(cookie.isDiscard());
|
||||
@ -268,7 +279,6 @@ public class CookieDecoderTest {
|
||||
"g=\"\\\\\"," +
|
||||
"h=\"';,\\x\"";
|
||||
|
||||
|
||||
Set<Cookie> cookies = CookieDecoder.decode(source);
|
||||
Iterator<Cookie> it = cookies.iterator();
|
||||
Cookie c;
|
||||
@ -315,7 +325,8 @@ public class CookieDecoderTest {
|
||||
"kw-2E343B92-B097-442c-BFA5-BE371E0325A2=unfinished furniture; " +
|
||||
"__utma=48461872.1094088325.1258140131.1258140131.1258140131.1; " +
|
||||
"__utmb=48461872.13.10.1258140131; __utmc=48461872; " +
|
||||
"__utmz=48461872.1258140131.1.1.utmcsr=overstock.com|utmccn=(referral)|utmcmd=referral|utmcct=/Home-Garden/Furniture/Clearance,/clearance,/32/dept.html";
|
||||
"__utmz=48461872.1258140131.1.1.utmcsr=overstock.com|utmccn=(referral)|" +
|
||||
"utmcmd=referral|utmcct=/Home-Garden/Furniture/Clearance,/clearance,/32/dept.html";
|
||||
Set<Cookie> cookies = CookieDecoder.decode(source);
|
||||
Iterator<Cookie> it = cookies.iterator();
|
||||
Cookie c;
|
||||
@ -334,7 +345,9 @@ public class CookieDecoderTest {
|
||||
|
||||
c = it.next();
|
||||
assertEquals("__utmz", c.getName());
|
||||
assertEquals("48461872.1258140131.1.1.utmcsr=overstock.com|utmccn=(referral)|utmcmd=referral|utmcct=/Home-Garden/Furniture/Clearance,/clearance,/32/dept.html", c.getValue());
|
||||
assertEquals("48461872.1258140131.1.1.utmcsr=overstock.com|" +
|
||||
"utmccn=(referral)|utmcmd=referral|utmcct=/Home-Garden/Furniture/Clearance,/clearance,/32/dept.html",
|
||||
c.getValue());
|
||||
|
||||
c = it.next();
|
||||
assertEquals("ARPT", c.getName());
|
||||
|
@ -58,7 +58,8 @@ public class CookieEncoderTest {
|
||||
|
||||
@Test
|
||||
public void testEncodingSingleCookieV1() {
|
||||
String result = "myCookie=myValue; Max-Age=50; Path=\"/apathsomewhere\"; Domain=.adomainsomewhere; Secure; Comment=\"this is a Comment\"; Version=1";
|
||||
String result = "myCookie=myValue; Max-Age=50; Path=\"/apathsomewhere\"; " +
|
||||
"Domain=.adomainsomewhere; Secure; Comment=\"this is a Comment\"; Version=1";
|
||||
Cookie cookie = new DefaultCookie("myCookie", "myValue");
|
||||
cookie.setVersion(1);
|
||||
cookie.setComment("this is a Comment");
|
||||
@ -72,7 +73,9 @@ public class CookieEncoderTest {
|
||||
|
||||
@Test
|
||||
public void testEncodingSingleCookieV2() {
|
||||
String result = "myCookie=myValue; Max-Age=50; Path=\"/apathsomewhere\"; Domain=.adomainsomewhere; Secure; Comment=\"this is a Comment\"; Version=1; CommentURL=\"http://aurl.com\"; Port=\"80,8080\"; Discard";
|
||||
String result = "myCookie=myValue; Max-Age=50; Path=\"/apathsomewhere\"; Domain=.adomainsomewhere; " +
|
||||
"Secure; Comment=\"this is a Comment\"; Version=1; CommentURL=\"http://aurl.com\"; " +
|
||||
"Port=\"80,8080\"; Discard";
|
||||
Cookie cookie = new DefaultCookie("myCookie", "myValue");
|
||||
cookie.setVersion(1);
|
||||
cookie.setComment("this is a Comment");
|
||||
@ -89,8 +92,10 @@ public class CookieEncoderTest {
|
||||
|
||||
@Test
|
||||
public void testEncodingMultipleClientCookies() {
|
||||
String c1 = "$Version=1; myCookie=myValue; $Path=\"/apathsomewhere\"; $Domain=.adomainsomewhere; $Port=\"80,8080\"; ";
|
||||
String c2 = "$Version=1; myCookie2=myValue2; $Path=\"/anotherpathsomewhere\"; $Domain=.anotherdomainsomewhere; ";
|
||||
String c1 = "$Version=1; myCookie=myValue; $Path=\"/apathsomewhere\"; " +
|
||||
"$Domain=.adomainsomewhere; $Port=\"80,8080\"; ";
|
||||
String c2 = "$Version=1; myCookie2=myValue2; $Path=\"/anotherpathsomewhere\"; " +
|
||||
"$Domain=.anotherdomainsomewhere; ";
|
||||
String c3 = "$Version=1; myCookie3=myValue3";
|
||||
Cookie cookie = new DefaultCookie("myCookie", "myValue");
|
||||
cookie.setVersion(1);
|
||||
|
@ -26,13 +26,14 @@ import static org.junit.Assert.*;
|
||||
|
||||
public class HttpClientCodecTest {
|
||||
|
||||
private static final String RESPONSE = "HTTP/1.0 200 OK\r\n" + "Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n" + "Content-Type: text/html\r\n" + "Content-Length: 28\r\n" + "\r\n"
|
||||
private static final String RESPONSE = "HTTP/1.0 200 OK\r\n" + "Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n" +
|
||||
"Content-Type: text/html\r\n" + "Content-Length: 28\r\n" + "\r\n"
|
||||
+ "<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"
|
||||
+"5\r\n" + "first\r\n" + "6\r\n" + "second\r\n" + "0\r\n";
|
||||
private static final String INCOMPLETE_CHUNKED_RESPONSE = "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" +
|
||||
"Transfer-Encoding: chunked\r\n" + "\r\n" +
|
||||
"5\r\n" + "first\r\n" + "6\r\n" + "second\r\n" + "0\r\n";
|
||||
private static final String CHUNKED_RESPONSE = INCOMPLETE_CHUNKED_RESPONSE + "\r\n";
|
||||
|
||||
|
||||
@Test
|
||||
public void testFailsNotOnRequestResponse() {
|
||||
HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
|
||||
@ -58,7 +59,8 @@ public class HttpClientCodecTest {
|
||||
HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
|
||||
EmbeddedByteChannel ch = new EmbeddedByteChannel(codec);
|
||||
|
||||
assertTrue(ch.writeOutbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/")));
|
||||
assertTrue(ch.writeOutbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,
|
||||
"http://localhost/")));
|
||||
assertNotNull(ch.readOutbound());
|
||||
|
||||
try {
|
||||
@ -67,7 +69,6 @@ public class HttpClientCodecTest {
|
||||
} catch (CodecException e) {
|
||||
assertTrue(e instanceof PrematureChannelClosureException);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -84,6 +85,5 @@ public class HttpClientCodecTest {
|
||||
} catch (CodecException e) {
|
||||
assertTrue(e instanceof PrematureChannelClosureException);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,31 +34,29 @@ public class HttpHeaderDateFormatTest {
|
||||
public void testParse() throws ParseException {
|
||||
HttpHeaderDateFormat format = new HttpHeaderDateFormat();
|
||||
|
||||
{
|
||||
final Date parsed = format.parse("Sun, 6 Nov 1994 08:49:37 GMT");
|
||||
Assert.assertNotNull(parsed);
|
||||
Assert.assertEquals(DATE, parsed);
|
||||
}
|
||||
{
|
||||
final Date parsed = format.parse("Sun, 06 Nov 1994 08:49:37 GMT");
|
||||
Assert.assertNotNull(parsed);
|
||||
Assert.assertEquals(DATE, parsed);
|
||||
}
|
||||
{
|
||||
final Date parsed = format.parse("Sunday, 06-Nov-94 08:49:37 GMT");
|
||||
Assert.assertNotNull(parsed);
|
||||
Assert.assertEquals(DATE, parsed);
|
||||
}
|
||||
{
|
||||
final Date parsed = format.parse("Sunday, 6-Nov-94 08:49:37 GMT");
|
||||
Assert.assertNotNull(parsed);
|
||||
Assert.assertEquals(DATE, parsed);
|
||||
}
|
||||
{
|
||||
final Date parsed = format.parse("Sun Nov 6 08:49:37 1994");
|
||||
Assert.assertNotNull(parsed);
|
||||
Assert.assertEquals(DATE, parsed);
|
||||
}
|
||||
final Date parsedDateWithSingleDigitDay = format.parse("Sun, 6 Nov 1994 08:49:37 GMT");
|
||||
Assert.assertNotNull(parsedDateWithSingleDigitDay);
|
||||
Assert.assertEquals(DATE, parsedDateWithSingleDigitDay);
|
||||
|
||||
final Date parsedDateWithDoubleDigitDay = format.parse("Sun, 06 Nov 1994 08:49:37 GMT");
|
||||
Assert.assertNotNull(parsedDateWithDoubleDigitDay);
|
||||
Assert.assertEquals(DATE, parsedDateWithDoubleDigitDay);
|
||||
|
||||
final Date parsedDateWithDashSeparatorSingleDigitDay = format.parse("Sunday, 06-Nov-94 08:49:37 GMT");
|
||||
Assert.assertNotNull(parsedDateWithDashSeparatorSingleDigitDay);
|
||||
Assert.assertEquals(DATE, parsedDateWithDashSeparatorSingleDigitDay);
|
||||
|
||||
final Date parsedDateWithSingleDoubleDigitDay = format.parse("Sunday, 6-Nov-94 08:49:37 GMT");
|
||||
Assert.assertNotNull(parsedDateWithSingleDoubleDigitDay);
|
||||
Assert.assertEquals(DATE, parsedDateWithSingleDoubleDigitDay);
|
||||
|
||||
final Date parsedDateWithoutGMT = format.parse("Sun Nov 6 08:49:37 1994");
|
||||
Assert.assertNotNull(parsedDateWithoutGMT);
|
||||
Assert.assertEquals(DATE, parsedDateWithoutGMT);
|
||||
}
|
||||
|
||||
private Date parseDate(HttpHeaderDateFormat dateFormat, String dateStr) throws ParseException {
|
||||
return dateFormat.parse(dateStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -52,11 +52,11 @@ public class HttpObjecctAggregatorTest {
|
||||
DefaultFullHttpRequest aggratedMessage = (DefaultFullHttpRequest) embedder.readInbound();
|
||||
assertNotNull(aggratedMessage);
|
||||
|
||||
assertEquals(chunk1.data().readableBytes() + chunk2.data().readableBytes(), HttpHeaders.getContentLength(aggratedMessage));
|
||||
assertEquals(chunk1.data().readableBytes() + chunk2.data().readableBytes(),
|
||||
HttpHeaders.getContentLength(aggratedMessage));
|
||||
assertEquals(aggratedMessage.headers().get("X-Test"), Boolean.TRUE.toString());
|
||||
checkContentBuffer(aggratedMessage);
|
||||
assertNull(embedder.readInbound());
|
||||
|
||||
}
|
||||
|
||||
private static void checkContentBuffer(DefaultFullHttpRequest aggregatedMessage) {
|
||||
@ -93,16 +93,15 @@ public class HttpObjecctAggregatorTest {
|
||||
DefaultFullHttpRequest aggratedMessage = (DefaultFullHttpRequest) embedder.readInbound();
|
||||
assertNotNull(aggratedMessage);
|
||||
|
||||
assertEquals(chunk1.data().readableBytes() + chunk2.data().readableBytes(), HttpHeaders.getContentLength(aggratedMessage));
|
||||
assertEquals(chunk1.data().readableBytes() + chunk2.data().readableBytes(),
|
||||
HttpHeaders.getContentLength(aggratedMessage));
|
||||
assertEquals(aggratedMessage.headers().get("X-Test"), Boolean.TRUE.toString());
|
||||
assertEquals(aggratedMessage.headers().get("X-Trailer"), Boolean.TRUE.toString());
|
||||
checkContentBuffer(aggratedMessage);
|
||||
|
||||
assertNull(embedder.readInbound());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = TooLongFrameException.class)
|
||||
public void testTooLongFrameException() {
|
||||
HttpObjectAggregator aggr = new HttpObjectAggregator(4);
|
||||
@ -115,7 +114,6 @@ public class HttpObjecctAggregatorTest {
|
||||
assertFalse(embedder.writeInbound(chunk1));
|
||||
embedder.writeInbound(chunk2);
|
||||
fail();
|
||||
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@ -125,7 +123,7 @@ public class HttpObjecctAggregatorTest {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidMaxCumulationBufferComponents() {
|
||||
HttpObjectAggregator aggr= new HttpObjectAggregator(Integer.MAX_VALUE);
|
||||
HttpObjectAggregator aggr = new HttpObjectAggregator(Integer.MAX_VALUE);
|
||||
aggr.setMaxCumulationBufferComponents(1);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,6 @@ public class HttpRequestEncoderTest {
|
||||
assertEquals("GET http://localhost/ HTTP/1.1\r\n", req);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUriWithPath() throws Exception {
|
||||
HttpRequestEncoder encoder = new HttpRequestEncoder();
|
||||
@ -47,4 +46,4 @@ public class HttpRequestEncoderTest {
|
||||
String req = buffer.toString(Charset.forName("US-ASCII"));
|
||||
assertEquals("GET http://localhost/ HTTP/1.1\r\n", req);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +184,6 @@ public class QueryStringDecoderTest {
|
||||
Assert.assertEquals(1, entry.getValue().size());
|
||||
Assert.assertEquals("value1", entry.getValue().get(0));
|
||||
|
||||
|
||||
entry = entries.next();
|
||||
Assert.assertEquals("param2", entry.getKey());
|
||||
Assert.assertEquals(1, entry.getValue().size());
|
||||
@ -213,7 +212,6 @@ public class QueryStringDecoderTest {
|
||||
Assert.assertEquals(1, entry.getValue().size());
|
||||
Assert.assertEquals("value1", entry.getValue().get(0));
|
||||
|
||||
|
||||
entry = entries.next();
|
||||
Assert.assertEquals("param2", entry.getKey());
|
||||
Assert.assertEquals(1, entry.getValue().size());
|
||||
@ -242,7 +240,6 @@ public class QueryStringDecoderTest {
|
||||
Assert.assertEquals(1, entry.getValue().size());
|
||||
Assert.assertEquals("value1", entry.getValue().get(0));
|
||||
|
||||
|
||||
entry = entries.next();
|
||||
Assert.assertEquals("param2", entry.getKey());
|
||||
Assert.assertEquals(1, entry.getValue().size());
|
||||
|
@ -36,7 +36,8 @@ public class HttpPostRequestDecoderTest {
|
||||
public void testBinaryStreamUpload() throws Exception {
|
||||
final String boundary = "dLV9Wyq26L_-JQxk6ferf-RT153LhOO";
|
||||
|
||||
final DefaultHttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "http://localhost");
|
||||
final DefaultHttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST,
|
||||
"http://localhost");
|
||||
|
||||
req.setDecoderResult(DecoderResult.SUCCESS);
|
||||
req.headers().add(HttpHeaders.Names.CONTENT_TYPE, "multipart/form-data; boundary=" + boundary);
|
||||
@ -77,7 +78,8 @@ public class HttpPostRequestDecoderTest {
|
||||
public void testFullHttpRequestUpload() throws Exception {
|
||||
final String boundary = "dLV9Wyq26L_-JQxk6ferf-RT153LhOO";
|
||||
|
||||
final DefaultFullHttpRequest req = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "http://localhost");
|
||||
final DefaultFullHttpRequest req = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST,
|
||||
"http://localhost");
|
||||
|
||||
req.setDecoderResult(DecoderResult.SUCCESS);
|
||||
req.headers().add(HttpHeaders.Names.CONTENT_TYPE, "multipart/form-data; boundary=" + boundary);
|
||||
@ -100,6 +102,5 @@ public class HttpPostRequestDecoderTest {
|
||||
// Create decoder instance to test.
|
||||
final HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(inMemoryFactory, req);
|
||||
assertFalse(decoder.getBodyHttpDatas().isEmpty());
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
@ -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;
|
@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License, version
|
||||
* 2.0 (the "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
@ -27,7 +27,7 @@ import static io.netty.handler.codec.http.HttpHeaders.Values.*;
|
||||
import static io.netty.handler.codec.http.HttpVersion.*;
|
||||
|
||||
public class WebSocketRequestBuilder {
|
||||
|
||||
|
||||
private HttpVersion httpVersion;
|
||||
private HttpMethod method;
|
||||
private String uri;
|
||||
@ -37,17 +37,17 @@ public class WebSocketRequestBuilder {
|
||||
private String key;
|
||||
private String origin;
|
||||
private WebSocketVersion version;
|
||||
|
||||
|
||||
public WebSocketRequestBuilder httpVersion(HttpVersion httpVersion) {
|
||||
this.httpVersion = httpVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public WebSocketRequestBuilder method(HttpMethod method) {
|
||||
this.method = method;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public WebSocketRequestBuilder uri(String uri) {
|
||||
this.uri = uri;
|
||||
return this;
|
||||
@ -57,46 +57,46 @@ public class WebSocketRequestBuilder {
|
||||
this.host = host;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public WebSocketRequestBuilder upgrade(String upgrade) {
|
||||
this.upgrade = upgrade;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public WebSocketRequestBuilder connection(String connection) {
|
||||
this.connection = connection;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public WebSocketRequestBuilder key(String key) {
|
||||
this.key = key;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public WebSocketRequestBuilder origin(String origin) {
|
||||
this.origin = origin;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public WebSocketRequestBuilder version13() {
|
||||
version = WebSocketVersion.V13;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public WebSocketRequestBuilder version8() {
|
||||
version = WebSocketVersion.V08;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public WebSocketRequestBuilder version00() {
|
||||
version = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public WebSocketRequestBuilder noVersion() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public FullHttpRequest build() {
|
||||
FullHttpRequest req = new DefaultFullHttpRequest(httpVersion, method, uri);
|
||||
HttpHeaders headers = req.headers();
|
||||
@ -121,7 +121,7 @@ public class WebSocketRequestBuilder {
|
||||
}
|
||||
return req;
|
||||
}
|
||||
|
||||
|
||||
public static HttpRequest sucessful() {
|
||||
return new WebSocketRequestBuilder().httpVersion(HTTP_1_1)
|
||||
.method(HttpMethod.GET)
|
||||
|
@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License, version
|
||||
* 2.0 (the "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
@ -45,24 +45,22 @@ public class WebSocketServerProtocolHandlerTest {
|
||||
public void testHttpUpgradeRequest() throws Exception {
|
||||
EmbeddedMessageChannel ch = createChannel(new MockOutboundHandler());
|
||||
ChannelHandlerContext handshakerCtx = ch.pipeline().context(WebSocketServerProtocolHandshakeHandler.class);
|
||||
|
||||
writeUpgradeRequest(ch);
|
||||
|
||||
assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
|
||||
assertNotNull(WebSocketServerProtocolHandler.getHandshaker(handshakerCtx));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@Test
|
||||
public void testSubsequentHttpRequestsAfterUpgradeShouldReturn403() throws Exception {
|
||||
EmbeddedMessageChannel ch = createChannel(new MockOutboundHandler());
|
||||
|
||||
|
||||
writeUpgradeRequest(ch);
|
||||
assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
|
||||
|
||||
|
||||
ch.writeInbound(new DefaultFullHttpRequest(HTTP_1_1, HttpMethod.GET, "/test"));
|
||||
assertEquals(FORBIDDEN, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHttpUpgradeRequestInvalidUpgradeHeader() {
|
||||
EmbeddedMessageChannel ch = createChannel();
|
||||
@ -73,15 +71,14 @@ public class WebSocketServerProtocolHandlerTest {
|
||||
.version00()
|
||||
.upgrade("BogusSocket")
|
||||
.build();
|
||||
|
||||
|
||||
ch.writeInbound(httpRequestWithEntity);
|
||||
|
||||
|
||||
FullHttpResponse response = getHttpResponse(ch);
|
||||
assertEquals(BAD_REQUEST, response.getStatus());
|
||||
assertEquals("not a WebSocket handshake request: missing upgrade", getResponseMessage(response));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHttpUpgradeRequestMissingWSKeyHeader() {
|
||||
EmbeddedMessageChannel ch = createChannel();
|
||||
@ -93,14 +90,14 @@ public class WebSocketServerProtocolHandlerTest {
|
||||
.upgrade(WEBSOCKET.toLowerCase())
|
||||
.version13()
|
||||
.build();
|
||||
|
||||
|
||||
ch.writeInbound(httpRequest);
|
||||
|
||||
|
||||
FullHttpResponse response = getHttpResponse(ch);
|
||||
assertEquals(BAD_REQUEST, response.getStatus());
|
||||
assertEquals("not a WebSocket request: missing key", getResponseMessage(response));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHandleTextFrame() {
|
||||
CustomTextFrameHandler customTextFrameHandler = new CustomTextFrameHandler();
|
||||
@ -108,16 +105,16 @@ public class WebSocketServerProtocolHandlerTest {
|
||||
writeUpgradeRequest(ch);
|
||||
// Removing the HttpRequestDecoder as we are writing a TextWebSocketFrame so decoding is not neccessary.
|
||||
ch.pipeline().remove(HttpRequestDecoder.class);
|
||||
|
||||
|
||||
ch.writeInbound(new TextWebSocketFrame("payload"));
|
||||
|
||||
|
||||
assertEquals("processed: payload", customTextFrameHandler.getContent());
|
||||
}
|
||||
|
||||
|
||||
private static EmbeddedMessageChannel createChannel() {
|
||||
return createChannel(null);
|
||||
}
|
||||
|
||||
|
||||
private static EmbeddedMessageChannel createChannel(ChannelHandler handler) {
|
||||
return new EmbeddedMessageChannel(
|
||||
new WebSocketServerProtocolHandler("/test", null, false),
|
||||
@ -126,7 +123,7 @@ public class WebSocketServerProtocolHandlerTest {
|
||||
new MockOutboundHandler(),
|
||||
handler);
|
||||
}
|
||||
|
||||
|
||||
private static void writeUpgradeRequest(EmbeddedMessageChannel ch) {
|
||||
ch.writeInbound(WebSocketRequestBuilder.sucessful());
|
||||
}
|
||||
@ -158,7 +155,7 @@ public class WebSocketServerProtocolHandlerTest {
|
||||
//NoOp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class CustomTextFrameHandler extends ChannelInboundMessageHandlerAdapter<TextWebSocketFrame> {
|
||||
private String content;
|
||||
|
||||
@ -166,7 +163,7 @@ public class WebSocketServerProtocolHandlerTest {
|
||||
public void messageReceived(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception {
|
||||
content = "processed: " + msg.text();
|
||||
}
|
||||
|
||||
|
||||
String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
@ -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;
|
@ -147,8 +147,8 @@ public class SpdySessionHandlerTest {
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
SpdyHeadersFrame spdyHeadersFrame = new DefaultSpdyHeadersFrame(localStreamID);
|
||||
|
||||
spdyHeadersFrame.headers().add("HEADER","test1");
|
||||
spdyHeadersFrame.headers().add("HEADER","test2");
|
||||
spdyHeadersFrame.headers().add("HEADER", "test1");
|
||||
spdyHeadersFrame.headers().add("HEADER", "test2");
|
||||
|
||||
sessionHandler.writeInbound(spdyHeadersFrame);
|
||||
assertHeaders(sessionHandler.readOutbound(), localStreamID, spdyHeadersFrame);
|
||||
@ -178,7 +178,6 @@ public class SpdySessionHandlerTest {
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
spdySynStreamFrame.setUnidirectional(false);
|
||||
|
||||
|
||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||
// multiple SYN_STREAM frames for the same active Stream-ID
|
||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||
@ -194,7 +193,6 @@ public class SpdySessionHandlerTest {
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
spdySynStreamFrame.setStreamId(localStreamID);
|
||||
|
||||
|
||||
// Check if session handler correctly limits the number of
|
||||
// concurrent streams in the SETTINGS frame
|
||||
SpdySettingsFrame spdySettingsFrame = new DefaultSpdySettingsFrame();
|
||||
|
@ -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;
|
@ -25,8 +25,8 @@ import static org.junit.Assert.*;
|
||||
public class SocksAuthResponseDecoderTest {
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksAuthResponseDecoderTest.class);
|
||||
|
||||
private static void testSocksAuthResponseDecoderWithDifferentParams(SocksAuthStatus authStatus){
|
||||
logger.debug("Testing SocksAuthResponseDecoder with authStatus: "+ authStatus);
|
||||
private static void testSocksAuthResponseDecoderWithDifferentParams(SocksAuthStatus authStatus) {
|
||||
logger.debug("Testing SocksAuthResponseDecoder with authStatus: " + authStatus);
|
||||
SocksAuthResponse msg = new SocksAuthResponse(authStatus);
|
||||
SocksAuthResponseDecoder decoder = new SocksAuthResponseDecoder();
|
||||
EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder);
|
||||
@ -37,9 +37,9 @@ public class SocksAuthResponseDecoderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSocksCmdResponseDecoder(){
|
||||
for (SocksAuthStatus authStatus: SocksAuthStatus.values()){
|
||||
testSocksAuthResponseDecoderWithDifferentParams(authStatus);
|
||||
public void testSocksCmdResponseDecoder() {
|
||||
for (SocksAuthStatus authStatus: SocksAuthStatus.values()) {
|
||||
testSocksAuthResponseDecoderWithDifferentParams(authStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,12 @@ import static org.junit.Assert.*;
|
||||
public class SocksCmdRequestDecoderTest {
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksCmdRequestDecoderTest.class);
|
||||
|
||||
private static void testSocksCmdRequestDecoderWithDifferentParams(SocksCmdType cmdType, SocksAddressType addressType, String host, int port) {
|
||||
logger.debug("Testing cmdType: " + cmdType + " addressType: " + addressType + " host: " + host + " port: " + port);
|
||||
private static void testSocksCmdRequestDecoderWithDifferentParams(SocksCmdType cmdType,
|
||||
SocksAddressType addressType,
|
||||
String host,
|
||||
int port) {
|
||||
logger.debug("Testing cmdType: " + cmdType + " addressType: " + addressType + " host: " + host +
|
||||
" port: " + port);
|
||||
SocksCmdRequest msg = new SocksCmdRequest(cmdType, addressType, host, port);
|
||||
SocksCmdRequestDecoder decoder = new SocksCmdRequestDecoder();
|
||||
EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder);
|
||||
@ -46,7 +50,7 @@ public class SocksCmdRequestDecoderTest {
|
||||
|
||||
@Test
|
||||
public void testCmdRequestDecoderIPv4() {
|
||||
String[] hosts = {"127.0.0.1",};
|
||||
String[] hosts = {"127.0.0.1", };
|
||||
int[] ports = {0, 32769, 65535 };
|
||||
for (SocksCmdType cmdType : SocksCmdType.values()) {
|
||||
for (String host : hosts) {
|
||||
|
@ -21,70 +21,70 @@ import static org.junit.Assert.*;
|
||||
|
||||
public class SocksCmdRequestTest {
|
||||
@Test
|
||||
public void testConstructorParamsAreNotNull(){
|
||||
public void testConstructorParamsAreNotNull() {
|
||||
try {
|
||||
new SocksCmdRequest(null, SocksAddressType.UNKNOWN, "", 0);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof NullPointerException);
|
||||
}
|
||||
|
||||
try {
|
||||
new SocksCmdRequest(SocksCmdType.UNKNOWN, null, "", 0);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof NullPointerException);
|
||||
}
|
||||
|
||||
try {
|
||||
new SocksCmdRequest(SocksCmdType.UNKNOWN, SocksAddressType.UNKNOWN, null, 0);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof NullPointerException);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIPv4CorrectAddress(){
|
||||
public void testIPv4CorrectAddress() {
|
||||
try {
|
||||
new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.IPv4, "54.54.1111.253", 0);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof IllegalArgumentException);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIPv6CorrectAddress(){
|
||||
public void testIPv6CorrectAddress() {
|
||||
try {
|
||||
new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.IPv6, "xxx:xxx:xxx", 0);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof IllegalArgumentException);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIDNNotExceeds255CharsLimit(){
|
||||
public void testIDNNotExceeds255CharsLimit() {
|
||||
try {
|
||||
new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.DOMAIN,
|
||||
"παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή" +
|
||||
"παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή" +
|
||||
"παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή" +
|
||||
"παράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμήπαράδειγμα.δοκιμή", 0);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof IllegalArgumentException);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidPortRange(){
|
||||
public void testValidPortRange() {
|
||||
try {
|
||||
new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.DOMAIN,
|
||||
"παράδειγμα.δοκιμήπαράδει", -1);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof IllegalArgumentException);
|
||||
}
|
||||
|
||||
try {
|
||||
new SocksCmdRequest(SocksCmdType.BIND, SocksAddressType.DOMAIN,
|
||||
"παράδειγμα.δοκιμήπαράδει", 65536);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof IllegalArgumentException);
|
||||
}
|
||||
}
|
||||
|
@ -25,13 +25,14 @@ import static org.junit.Assert.*;
|
||||
public class SocksCmdResponseDecoderTest {
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksCmdResponseDecoderTest.class);
|
||||
|
||||
private static void testSocksCmdResponseDecoderWithDifferentParams(SocksCmdStatus cmdStatus, SocksAddressType addressType){
|
||||
private static void testSocksCmdResponseDecoderWithDifferentParams(SocksCmdStatus cmdStatus,
|
||||
SocksAddressType addressType) {
|
||||
logger.debug("Testing cmdStatus: " + cmdStatus + " addressType: " + addressType);
|
||||
SocksResponse msg = new SocksCmdResponse(cmdStatus, addressType);
|
||||
SocksCmdResponseDecoder decoder = new SocksCmdResponseDecoder();
|
||||
EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder);
|
||||
SocksCommonTestUtils.writeMessageIntoEmbedder(embedder, msg);
|
||||
if (addressType == SocksAddressType.UNKNOWN){
|
||||
if (addressType == SocksAddressType.UNKNOWN) {
|
||||
assertTrue(embedder.readInbound() instanceof UnknownSocksResponse);
|
||||
} else {
|
||||
msg = (SocksResponse) embedder.readInbound();
|
||||
@ -41,9 +42,9 @@ public class SocksCmdResponseDecoderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSocksCmdResponseDecoder(){
|
||||
for (SocksCmdStatus cmdStatus: SocksCmdStatus.values()){
|
||||
for (SocksAddressType addressType: SocksAddressType.values()){
|
||||
public void testSocksCmdResponseDecoder() {
|
||||
for (SocksCmdStatus cmdStatus: SocksCmdStatus.values()) {
|
||||
for (SocksAddressType addressType: SocksAddressType.values()) {
|
||||
testSocksCmdResponseDecoderWithDifferentParams(cmdStatus, addressType);
|
||||
}
|
||||
}
|
||||
|
@ -20,10 +20,10 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SocksInitRequestTest {
|
||||
@Test
|
||||
public void testConstructorParamsAreNotNull(){
|
||||
public void testConstructorParamsAreNotNull() {
|
||||
try {
|
||||
new SocksInitRequest(null);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
assertTrue(e instanceof NullPointerException);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
@ -30,41 +30,45 @@ public class DelimiterBasedFrameDecoderTest {
|
||||
|
||||
@Test
|
||||
public void testMultipleLinesStrippedDelimiters() {
|
||||
EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, true, Delimiters.lineDelimiter()));
|
||||
EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, true,
|
||||
Delimiters.lineDelimiter()));
|
||||
ch.writeInbound(Unpooled.copiedBuffer("TestLine\r\ng\r\n", Charset.defaultCharset()));
|
||||
assertEquals("TestLine", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertEquals("g", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertEquals("TestLine", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertEquals("g", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertNull(ch.readInbound());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncompleteLinesStrippedDelimiters() {
|
||||
EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, true, Delimiters.lineDelimiter()));
|
||||
EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, true,
|
||||
Delimiters.lineDelimiter()));
|
||||
ch.writeInbound(Unpooled.copiedBuffer("Test", Charset.defaultCharset()));
|
||||
assertNull(ch.readInbound());
|
||||
ch.writeInbound(Unpooled.copiedBuffer("Line\r\ng\r\n", Charset.defaultCharset()));
|
||||
assertEquals("TestLine", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertEquals("g", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertEquals("TestLine", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertEquals("g", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertNull(ch.readInbound());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleLines() {
|
||||
EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, false, Delimiters.lineDelimiter()));
|
||||
EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, false,
|
||||
Delimiters.lineDelimiter()));
|
||||
ch.writeInbound(Unpooled.copiedBuffer("TestLine\r\ng\r\n", Charset.defaultCharset()));
|
||||
assertEquals("TestLine\r\n", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertEquals("g\r\n", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertEquals("TestLine\r\n", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertEquals("g\r\n", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertNull(ch.readInbound());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncompleteLines() {
|
||||
EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, false, Delimiters.lineDelimiter()));
|
||||
EmbeddedByteChannel ch = new EmbeddedByteChannel(new DelimiterBasedFrameDecoder(8192, false,
|
||||
Delimiters.lineDelimiter()));
|
||||
ch.writeInbound(Unpooled.copiedBuffer("Test", Charset.defaultCharset()));
|
||||
assertNull(ch.readInbound());
|
||||
ch.writeInbound(Unpooled.copiedBuffer("Line\r\ng\r\n", Charset.defaultCharset()));
|
||||
assertEquals("TestLine\r\n", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertEquals("g\r\n", ((ByteBuf)ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertEquals("TestLine\r\n", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertEquals("g\r\n", ((ByteBuf) ch.readInbound()).toString(Charset.defaultCharset()));
|
||||
assertNull(ch.readInbound());
|
||||
}
|
||||
|
||||
@ -74,9 +78,8 @@ public class DelimiterBasedFrameDecoderTest {
|
||||
new DelimiterBasedFrameDecoder(8192, true, Delimiters.lineDelimiter()));
|
||||
|
||||
ch.writeInbound(Unpooled.copiedBuffer("first\r\nsecond\nthird", CharsetUtil.US_ASCII));
|
||||
assertEquals("first", ((ByteBuf)ch.readInbound()).toString(CharsetUtil.US_ASCII));
|
||||
assertEquals("second", ((ByteBuf)ch.readInbound()).toString(CharsetUtil.US_ASCII));
|
||||
assertEquals("first", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII));
|
||||
assertEquals("second", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII));
|
||||
assertNull(ch.readInbound());
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -28,18 +28,17 @@ public class LineBasedFrameDecoderTest {
|
||||
EmbeddedByteChannel ch = new EmbeddedByteChannel(new LineBasedFrameDecoder(8192, true, false));
|
||||
|
||||
ch.writeInbound(Unpooled.copiedBuffer("first\r\nsecond\nthird", CharsetUtil.US_ASCII));
|
||||
Assert.assertEquals("first", ((ByteBuf)ch.readInbound()).toString(CharsetUtil.US_ASCII));
|
||||
Assert.assertEquals("second", ((ByteBuf)ch.readInbound()).toString(CharsetUtil.US_ASCII));
|
||||
Assert.assertEquals("first", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII));
|
||||
Assert.assertEquals("second", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII));
|
||||
Assert.assertNull(ch.readInbound());
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testDecodeWithoutStrip() throws Exception {
|
||||
EmbeddedByteChannel ch = new EmbeddedByteChannel(new LineBasedFrameDecoder(8192, false, false));
|
||||
|
||||
ch.writeInbound(Unpooled.copiedBuffer("first\r\nsecond\nthird", CharsetUtil.US_ASCII));
|
||||
Assert.assertEquals("first\r\n", ((ByteBuf)ch.readInbound()).toString(CharsetUtil.US_ASCII));
|
||||
Assert.assertEquals("second\n", ((ByteBuf)ch.readInbound()).toString(CharsetUtil.US_ASCII));
|
||||
Assert.assertEquals("first\r\n", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII));
|
||||
Assert.assertEquals("second\n", ((ByteBuf) ch.readInbound()).toString(CharsetUtil.US_ASCII));
|
||||
Assert.assertNull(ch.readInbound());
|
||||
}
|
||||
}
|
||||
|
@ -24,13 +24,14 @@ import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ReplayingDecoderBufferTest {
|
||||
|
||||
|
||||
/**
|
||||
* See https://github.com/netty/netty/issues/445
|
||||
*/
|
||||
@Test
|
||||
public void testGetUnsignedByte() {
|
||||
ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(Unpooled.copiedBuffer("TestBuffer", CharsetUtil.ISO_8859_1));
|
||||
ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(Unpooled.copiedBuffer("TestBuffer",
|
||||
CharsetUtil.ISO_8859_1));
|
||||
|
||||
boolean error;
|
||||
int i = 0;
|
||||
@ -52,7 +53,8 @@ public class ReplayingDecoderBufferTest {
|
||||
*/
|
||||
@Test
|
||||
public void testGetByte() {
|
||||
ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(Unpooled.copiedBuffer("TestBuffer", CharsetUtil.ISO_8859_1));
|
||||
ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(Unpooled.copiedBuffer("TestBuffer",
|
||||
CharsetUtil.ISO_8859_1));
|
||||
|
||||
boolean error;
|
||||
int i = 0;
|
||||
@ -68,14 +70,14 @@ public class ReplayingDecoderBufferTest {
|
||||
assertTrue(error);
|
||||
assertEquals(10, i);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* See https://github.com/netty/netty/issues/445
|
||||
*/
|
||||
@Test
|
||||
public void testGetBoolean() {
|
||||
ByteBuf buf = Unpooled.buffer(10);
|
||||
while(buf.isWritable()) {
|
||||
while (buf.isWritable()) {
|
||||
buf.writeBoolean(true);
|
||||
}
|
||||
ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(buf);
|
||||
|
@ -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;
|
@ -37,25 +37,21 @@ public class JZlibTest {
|
||||
|
||||
byte[] deflatedData = chEncoder.readOutbound().array();
|
||||
|
||||
{
|
||||
EmbeddedByteChannel chDecoder =
|
||||
EmbeddedByteChannel chDecoderZlib =
|
||||
new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB));
|
||||
|
||||
chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData));
|
||||
assertTrue(chDecoder.finish());
|
||||
chDecoderZlib.writeInbound(Unpooled.wrappedBuffer(deflatedData));
|
||||
assertTrue(chDecoderZlib.finish());
|
||||
|
||||
assertEquals(data, chDecoder.readInbound());
|
||||
}
|
||||
assertEquals(data, chDecoderZlib.readInbound());
|
||||
|
||||
{
|
||||
EmbeddedByteChannel chDecoder =
|
||||
EmbeddedByteChannel chDecoderZlibOrNone =
|
||||
new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB_OR_NONE));
|
||||
|
||||
chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData));
|
||||
assertTrue(chDecoder.finish());
|
||||
chDecoderZlibOrNone.writeInbound(Unpooled.wrappedBuffer(deflatedData));
|
||||
assertTrue(chDecoderZlibOrNone.finish());
|
||||
|
||||
assertEquals(data, chDecoder.readInbound());
|
||||
}
|
||||
assertEquals(data, chDecoderZlibOrNone.readInbound());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -67,31 +63,26 @@ public class JZlibTest {
|
||||
|
||||
chEncoder.writeOutbound(data);
|
||||
assertTrue(chEncoder.finish());
|
||||
|
||||
|
||||
byte[] deflatedData = chEncoder.readOutbound().array();
|
||||
|
||||
{
|
||||
EmbeddedByteChannel chDecoder =
|
||||
EmbeddedByteChannel chDecoderZlibNone =
|
||||
new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.NONE));
|
||||
|
||||
chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData));
|
||||
assertTrue(chDecoder.finish());
|
||||
chDecoderZlibNone.writeInbound(Unpooled.wrappedBuffer(deflatedData));
|
||||
assertTrue(chDecoderZlibNone.finish());
|
||||
|
||||
assertEquals(data, chDecoder.readInbound());
|
||||
}
|
||||
assertEquals(data, chDecoderZlibNone.readInbound());
|
||||
|
||||
{
|
||||
EmbeddedByteChannel chDecoder =
|
||||
EmbeddedByteChannel chDecoderZlibOrNone =
|
||||
new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB_OR_NONE));
|
||||
|
||||
chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData));
|
||||
assertTrue(chDecoder.finish());
|
||||
chDecoderZlibOrNone.writeInbound(Unpooled.wrappedBuffer(deflatedData));
|
||||
assertTrue(chDecoderZlibOrNone.finish());
|
||||
|
||||
assertEquals(data, chDecoder.readInbound());
|
||||
}
|
||||
assertEquals(data, chDecoderZlibOrNone.readInbound());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGZIP() throws Exception {
|
||||
ByteBuf data = Unpooled.wrappedBuffer("test".getBytes());
|
||||
@ -104,24 +95,20 @@ public class JZlibTest {
|
||||
|
||||
byte[] deflatedData = chEncoder.readOutbound().array();
|
||||
|
||||
{
|
||||
EmbeddedByteChannel chDecoder =
|
||||
EmbeddedByteChannel chDecoderGZip =
|
||||
new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.GZIP));
|
||||
|
||||
chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData));
|
||||
assertTrue(chDecoder.finish());
|
||||
chDecoderGZip.writeInbound(Unpooled.wrappedBuffer(deflatedData));
|
||||
assertTrue(chDecoderGZip.finish());
|
||||
|
||||
assertEquals(data, chDecoder.readInbound());
|
||||
}
|
||||
assertEquals(data, chDecoderGZip.readInbound());
|
||||
|
||||
{
|
||||
EmbeddedByteChannel chDecoder =
|
||||
EmbeddedByteChannel chDecoderZlibOrNone =
|
||||
new EmbeddedByteChannel(new JZlibDecoder(ZlibWrapper.ZLIB_OR_NONE));
|
||||
|
||||
chDecoder.writeInbound(Unpooled.wrappedBuffer(deflatedData));
|
||||
assertTrue(chDecoder.finish());
|
||||
chDecoderZlibOrNone.writeInbound(Unpooled.wrappedBuffer(deflatedData));
|
||||
assertTrue(chDecoderZlibOrNone.finish());
|
||||
|
||||
assertEquals(data, chDecoder.readInbound());
|
||||
}
|
||||
assertEquals(data, chDecoderZlibOrNone.readInbound());
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import static org.junit.Assert.*;
|
||||
|
||||
public class SnappyFramedEncoderTest {
|
||||
private EmbeddedByteChannel channel;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
channel = new EmbeddedByteChannel(new SnappyFramedEncoder());
|
||||
@ -85,7 +85,7 @@ public class SnappyFramedEncoderTest {
|
||||
});
|
||||
assertEquals(expected, channel.readOutbound());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This test asserts that if we have a remainder after emitting a copy that
|
||||
* is less than 4 bytes (ie. the minimum required for a copy), we should
|
||||
@ -127,7 +127,7 @@ public class SnappyFramedEncoderTest {
|
||||
-1, -1, -1, // copy
|
||||
-1, 1 // remainder
|
||||
});
|
||||
|
||||
|
||||
channel.writeOutbound(in);
|
||||
assertTrue(channel.finish());
|
||||
}
|
||||
|
@ -70,12 +70,11 @@ public class SnappyIntegrationTest {
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
// These tests were found using testRandom() with large RANDOM_RUNS.
|
||||
|
||||
// Tests that copies do not attempt to overrun into a previous frame chunk
|
||||
@Test
|
||||
public void test5323211032315942961(){
|
||||
public void test5323211032315942961() {
|
||||
testWithSeed(5323211032315942961L);
|
||||
}
|
||||
|
||||
|
@ -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;
|
@ -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;
|
@ -121,12 +121,12 @@ public abstract class AbstractCompatibleMarshallingDecoderTest {
|
||||
}
|
||||
|
||||
protected ChannelHandler createDecoder(int maxObjectSize) {
|
||||
return new CompatibleMarshallingDecoder(createProvider(createMarshallerFactory(), createMarshallingConfig()), maxObjectSize);
|
||||
return new CompatibleMarshallingDecoder(createProvider(createMarshallerFactory(),
|
||||
createMarshallingConfig()), maxObjectSize);
|
||||
}
|
||||
|
||||
protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) {
|
||||
return new DefaultUnmarshallerProvider(factory, config);
|
||||
|
||||
}
|
||||
|
||||
protected abstract MarshallerFactory createMarshallerFactory();
|
||||
|
@ -21,7 +21,6 @@ import org.jboss.marshalling.MarshallingConfiguration;
|
||||
|
||||
public class RiverCompatibleMarshallingEncoderTest extends AbstractCompatibleMarshallingEncoderTest {
|
||||
|
||||
|
||||
@Override
|
||||
protected MarshallerFactory createMarshallerFactory() {
|
||||
return Marshalling.getProvidedMarshallerFactory("river");
|
||||
|
@ -25,5 +25,4 @@ public class RiverContextBoundCompatibleMarshallingDecoderTest extends RiverComp
|
||||
return new ContextBoundUnmarshallerProvider(factory, config);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -25,5 +25,4 @@ public class RiverContextBoundMarshallingDecoderTest extends RiverMarshallingDec
|
||||
return new ContextBoundUnmarshallerProvider(factory, config);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ public class RiverMarshallingDecoderTest extends RiverCompatibleMarshallingDecod
|
||||
|
||||
@Override
|
||||
protected ChannelHandler createDecoder(int maxObjectSize) {
|
||||
return new MarshallingDecoder(createProvider(createMarshallerFactory(), createMarshallingConfig()), maxObjectSize);
|
||||
return new MarshallingDecoder(createProvider(createMarshallerFactory(),
|
||||
createMarshallingConfig()), maxObjectSize);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -25,5 +25,4 @@ public class RiverThreadLocalCompatibleMarshallingDecoderTest extends RiverCompa
|
||||
return new ThreadLocalUnmarshallerProvider(factory, config);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -25,5 +25,4 @@ public class RiverThreadLocalMarshallingDecoderTest extends RiverMarshallingDeco
|
||||
return new ThreadLocalUnmarshallerProvider(factory, config);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import org.jboss.marshalling.MarshallingConfiguration;
|
||||
|
||||
public class SerialCompatibleMarshallingEncoderTest extends AbstractCompatibleMarshallingEncoderTest {
|
||||
|
||||
|
||||
@Override
|
||||
protected MarshallerFactory createMarshallerFactory() {
|
||||
return Marshalling.getProvidedMarshallerFactory("serial");
|
||||
|
@ -20,7 +20,6 @@ import org.jboss.marshalling.MarshallingConfiguration;
|
||||
|
||||
public class SerialContextBoundCompatibleMarshallingDecoderTest extends SerialCompatibleMarshallingDecoderTest {
|
||||
|
||||
|
||||
@Override
|
||||
protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) {
|
||||
return new ContextBoundUnmarshallerProvider(factory, config);
|
||||
|
@ -20,7 +20,6 @@ import org.jboss.marshalling.MarshallingConfiguration;
|
||||
|
||||
public class SerialContextBoundMarshallingDecoderTest extends SerialMarshallingDecoderTest {
|
||||
|
||||
|
||||
@Override
|
||||
protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) {
|
||||
return new ContextBoundUnmarshallerProvider(factory, config);
|
||||
|
@ -30,7 +30,8 @@ public class SerialMarshallingDecoderTest extends SerialCompatibleMarshallingDec
|
||||
|
||||
@Override
|
||||
protected ChannelHandler createDecoder(int maxObjectSize) {
|
||||
return new MarshallingDecoder(createProvider(createMarshallerFactory(), createMarshallingConfig()), maxObjectSize);
|
||||
return new MarshallingDecoder(createProvider(createMarshallerFactory(),
|
||||
createMarshallingConfig()), maxObjectSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ package io.netty.handler.codec.marshalling;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
|
||||
public class SerialMarshallingEncoderTest extends SerialCompatibleMarshallingEncoderTest{
|
||||
public class SerialMarshallingEncoderTest extends SerialCompatibleMarshallingEncoderTest {
|
||||
|
||||
@Override
|
||||
protected ByteBuf truncate(ByteBuf buf) {
|
||||
|
@ -20,7 +20,6 @@ import org.jboss.marshalling.MarshallingConfiguration;
|
||||
|
||||
public class SerialThreadLocalCompatibleMarshallingDecoderTest extends SerialCompatibleMarshallingDecoderTest {
|
||||
|
||||
|
||||
@Override
|
||||
protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) {
|
||||
return new ThreadLocalUnmarshallerProvider(factory, config);
|
||||
|
@ -20,7 +20,6 @@ import org.jboss.marshalling.MarshallingConfiguration;
|
||||
|
||||
public class SerialThreadLocalMarshallingDecoderTest extends SerialMarshallingDecoderTest {
|
||||
|
||||
|
||||
@Override
|
||||
protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) {
|
||||
return new ThreadLocalUnmarshallerProvider(factory, config);
|
||||
|
@ -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;
|
20
codec/src/test/java/io/netty/handler/codec/package-info.java
Normal file
20
codec/src/test/java/io/netty/handler/codec/package-info.java
Normal 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;
|
@ -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;
|
@ -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;
|
@ -24,7 +24,7 @@ import java.util.Map.Entry;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
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;
|
||||
{
|
||||
put("192.168.1.0", new byte[]{
|
||||
@ -42,10 +42,9 @@ public class NetUtilTest {
|
||||
put("127.0.0.1", new byte[]{
|
||||
0x7f, 0x00, 0x00, 0x01
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
private final static Map<String, byte[]> invalidIpV4Hosts = new HashMap<String, byte[]>() {
|
||||
private static final Map<String, byte[]> invalidIpV4Hosts = new HashMap<String, byte[]>() {
|
||||
private static final long serialVersionUID = 1299215199895717282L;
|
||||
{
|
||||
put("1.256.3.4", null);
|
||||
@ -53,7 +52,7 @@ public class NetUtilTest {
|
||||
put("1.1.1.1.1", null);
|
||||
}
|
||||
};
|
||||
private final static Map<String, byte[]> validIpV6Hosts = new HashMap<String, byte[]>() {
|
||||
private static final Map<String, byte[]> validIpV6Hosts = new HashMap<String, byte[]>() {
|
||||
private static final long serialVersionUID = 3999763170377573184L;
|
||||
{
|
||||
put("::ffff:5.6.7.8", new byte[]{
|
||||
@ -165,7 +164,7 @@ public class NetUtilTest {
|
||||
);
|
||||
}
|
||||
};
|
||||
private final static Map<String, byte[]> invalidIpV6Hosts = new HashMap<String, byte[]>() {
|
||||
private static final Map<String, byte[]> invalidIpV6Hosts = new HashMap<String, byte[]>() {
|
||||
private static final long serialVersionUID = -5870810805409009696L;
|
||||
{
|
||||
// Test method with garbage.
|
||||
|
@ -47,12 +47,12 @@ public class UniqueNameTest {
|
||||
names = PlatformDependent.newConcurrentHashMap();
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testCannnotProvideNullMap() {
|
||||
new UniqueName(null, "Nothing");
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testCannotProvideNullName() {
|
||||
new UniqueName(names, null);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class StringUtilTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void ensureNewlineExists() {
|
||||
assertNotNull(StringUtil.NEWLINE);
|
||||
|
@ -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 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> { }
|
||||
|
||||
|
@ -43,7 +43,6 @@ public class InternalLoggerFactoryTest {
|
||||
InternalLoggerFactory.setDefaultFactory(oldLoggerFactory);
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void shouldNotAllowNullDefaultFactory() {
|
||||
InternalLoggerFactory.setDefaultFactory(null);
|
||||
@ -52,12 +51,12 @@ public class InternalLoggerFactoryTest {
|
||||
@Test
|
||||
public void shouldGetInstance() {
|
||||
InternalLoggerFactory.setDefaultFactory(oldLoggerFactory);
|
||||
|
||||
|
||||
String helloWorld = "Hello, world!";
|
||||
|
||||
|
||||
InternalLogger one = InternalLoggerFactory.getInstance("helloWorld");
|
||||
InternalLogger two = InternalLoggerFactory.getInstance(helloWorld.getClass());
|
||||
|
||||
|
||||
assertNotNull(one);
|
||||
assertNotNull(two);
|
||||
assertNotSame(one, two);
|
||||
|
@ -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;
|
@ -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;
|
20
common/src/test/java/io/netty/util/package-info.java
Normal file
20
common/src/test/java/io/netty/util/package-info.java
Normal 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;
|
@ -24,7 +24,6 @@ import io.netty.channel.embedded.EmbeddedByteChannel;
|
||||
import io.netty.channel.embedded.EmbeddedMessageChannel;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@ -68,19 +67,20 @@ public class ChunkedWriteHandlerTest {
|
||||
public void testChunkedStream() {
|
||||
check(new ChunkedStream(new ByteArrayInputStream(BYTES)));
|
||||
|
||||
check(new ChunkedStream(new ByteArrayInputStream(BYTES)), new ChunkedStream(new ByteArrayInputStream(BYTES)), new ChunkedStream(new ByteArrayInputStream(BYTES)));
|
||||
|
||||
check(new ChunkedStream(new ByteArrayInputStream(BYTES)),
|
||||
new ChunkedStream(new ByteArrayInputStream(BYTES)),
|
||||
new ChunkedStream(new ByteArrayInputStream(BYTES)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChunkedNioStream() {
|
||||
check(new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES))));
|
||||
|
||||
check(new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES))), new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES))), new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES))));
|
||||
|
||||
check(new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES))),
|
||||
new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES))),
|
||||
new ChunkedNioStream(Channels.newChannel(new ByteArrayInputStream(BYTES))));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testChunkedFile() throws IOException {
|
||||
check(new ChunkedFile(TMP));
|
||||
@ -96,7 +96,7 @@ public class ChunkedWriteHandlerTest {
|
||||
}
|
||||
|
||||
// Test case which shows that there is not a bug like stated here:
|
||||
// http://stackoverflow.com/questions/10409241/why-is-close-channelfuturelistener-not-notified/10426305#comment14126161_10426305
|
||||
// http://stackoverflow.com/a/10426305
|
||||
@Test
|
||||
public void testListenerNotifiedWhenIsEnd() {
|
||||
ByteBuf buffer = Unpooled.copiedBuffer("Test", CharsetUtil.ISO_8859_1);
|
||||
@ -146,7 +146,6 @@ public class ChunkedWriteHandlerTest {
|
||||
|
||||
assertEquals(buffer, ch.readOutbound());
|
||||
assertNull(ch.readOutbound());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -184,7 +183,6 @@ public class ChunkedWriteHandlerTest {
|
||||
|
||||
assertEquals(0, ch.readOutbound());
|
||||
assertNull(ch.readOutbound());
|
||||
|
||||
}
|
||||
|
||||
private static void check(ChunkedInput<?>... inputs) {
|
||||
|
@ -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;
|
@ -14,21 +14,6 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright (C) 2010 Google Inc.
|
||||
*
|
||||
|
@ -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;
|
@ -33,7 +33,7 @@ public class ByteBufAllocatorBenchmark extends DefaultBenchmark {
|
||||
private static final ByteBufAllocator POOLED_ALLOCATOR_HEAP = new PooledByteBufAllocator(false);
|
||||
private static final ByteBufAllocator POOLED_ALLOCATOR_DIRECT = new PooledByteBufAllocator(true);
|
||||
|
||||
@Param({"0", "256", "1024", "4096", "16384", "65536"})
|
||||
@Param({ "0", "256", "1024", "4096", "16384", "65536" })
|
||||
private int size;
|
||||
|
||||
@Param
|
||||
|
@ -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;
|
@ -118,7 +118,8 @@ public abstract class DefaultBenchmark extends SimpleBenchmark {
|
||||
deleted = true;
|
||||
System.out.println();
|
||||
}
|
||||
System.out.println(" Deleted old report: " + name.substring(prefix.length(), name.length() - suffix.length()));
|
||||
System.out.println(" Deleted old report: " +
|
||||
name.substring(prefix.length(), name.length() - suffix.length()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
1
pom.xml
1
pom.xml
@ -361,6 +361,7 @@
|
||||
<failsOnError>true</failsOnError>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
<configLocation>io/netty/checkstyle.xml</configLocation>
|
||||
<includeTestSourceDirectory>true</includeTestSourceDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
@ -49,7 +49,5 @@ public class DependencyIT {
|
||||
} else {
|
||||
System.out.println("all transitive dependencies are osgi bundles");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
@ -29,7 +29,7 @@ import org.osgi.framework.wiring.BundleWiring;
|
||||
/**
|
||||
* Unit Test Utilities.
|
||||
*/
|
||||
public class UnitHelp {
|
||||
public final class UnitHelp {
|
||||
|
||||
private UnitHelp() {
|
||||
}
|
||||
@ -106,7 +106,6 @@ public class UnitHelp {
|
||||
|
||||
/** install java unit bundles */
|
||||
junitBundles());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
@ -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;
|
@ -45,7 +45,7 @@ public abstract class AbstractSctpTest {
|
||||
protected volatile Bootstrap cb;
|
||||
protected volatile InetSocketAddress addr;
|
||||
protected volatile Factory<Bootstrap> currentBootstrap;
|
||||
|
||||
|
||||
protected void run() throws Throwable {
|
||||
int i = 0;
|
||||
for (Entry<Factory<ServerBootstrap>, Factory<Bootstrap>> e: COMBO) {
|
||||
|
@ -41,7 +41,7 @@ import static org.junit.Assert.*;
|
||||
public class SctpEchoTest extends AbstractSctpTest {
|
||||
|
||||
private static final Random random = new Random();
|
||||
static final byte[] data = new byte[4096];//could not test ultra jumbo frames
|
||||
static final byte[] data = new byte[4096]; //could not test ultra jumbo frames
|
||||
|
||||
static {
|
||||
random.nextBytes(data);
|
||||
@ -95,7 +95,7 @@ public class SctpEchoTest extends AbstractSctpTest {
|
||||
Channel sc = sb.bind().sync().channel();
|
||||
Channel cc = cb.connect().sync().channel();
|
||||
|
||||
for (int i = 0; i < data.length; ) {
|
||||
for (int i = 0; i < data.length;) {
|
||||
int length = Math.min(random.nextInt(1024 * 64), data.length - i);
|
||||
cc.write(Unpooled.wrappedBuffer(data, i, length));
|
||||
i += length;
|
||||
|
@ -117,8 +117,7 @@ public final class SctpTestPermutation {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
private SctpTestPermutation() {}
|
||||
private SctpTestPermutation() { }
|
||||
|
||||
interface Factory<T> {
|
||||
T newInstance();
|
||||
|
@ -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;
|
@ -45,8 +45,7 @@ public abstract class AbstractClientSocketTest {
|
||||
int i = 0;
|
||||
for (Factory<Bootstrap> e: COMBO) {
|
||||
cb = e.newInstance();
|
||||
addr = new InetSocketAddress(
|
||||
NetUtil.LOCALHOST, TestUtils.getFreePort());
|
||||
addr = new InetSocketAddress(NetUtil.LOCALHOST, TestUtils.getFreePort());
|
||||
cb.remoteAddress(addr);
|
||||
|
||||
logger.info(String.format(
|
||||
|
@ -45,7 +45,7 @@ public abstract class AbstractSocketTest {
|
||||
protected volatile Bootstrap cb;
|
||||
protected volatile InetSocketAddress addr;
|
||||
protected volatile Factory<Bootstrap> currentBootstrap;
|
||||
|
||||
|
||||
protected void run() throws Throwable {
|
||||
int i = 0;
|
||||
for (Entry<Factory<ServerBootstrap>, Factory<Bootstrap>> e: COMBO) {
|
||||
|
@ -92,7 +92,6 @@ public class DatagramMulticastTest extends AbstractDatagramTest {
|
||||
|
||||
sc.close().awaitUninterruptibly();
|
||||
cc.close().awaitUninterruptibly();
|
||||
|
||||
}
|
||||
|
||||
private static final class MulticastTestHandler extends ChannelInboundMessageHandlerAdapter<DatagramPacket> {
|
||||
|
@ -68,7 +68,6 @@ public class SocketShutdownOutputBySelfTest extends AbstractClientSocketTest {
|
||||
// If half-closed, the peer should be able to write something.
|
||||
s.getOutputStream().write(1);
|
||||
assertEquals(1, (int) h.queue.take());
|
||||
|
||||
} finally {
|
||||
if (s != null) {
|
||||
s.close();
|
||||
|
@ -63,7 +63,6 @@ public class SocketSslEchoTest extends AbstractSocketTest {
|
||||
testSslEcho0(sb, cb, false);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSslEchoWithChunkHandler() throws Throwable {
|
||||
run();
|
||||
|
@ -200,7 +200,7 @@ final class SocketTestPermutation {
|
||||
return list;
|
||||
}
|
||||
|
||||
private SocketTestPermutation() {}
|
||||
private SocketTestPermutation() { }
|
||||
|
||||
interface Factory<T> {
|
||||
T newInstance();
|
||||
|
@ -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;
|
@ -16,12 +16,15 @@
|
||||
package io.netty.testsuite.util;
|
||||
|
||||
import io.netty.util.NetUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.nio.channels.Channel;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public final class TestUtils {
|
||||
|
||||
|
@ -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;
|
@ -30,7 +30,7 @@ public abstract class AbstractUdtTest {
|
||||
* UDT test assumptions.
|
||||
*/
|
||||
@BeforeClass
|
||||
public static void assumeConditions(){
|
||||
public static void assumeConditions() {
|
||||
assumeTrue(UnitHelp.canLoadAndInitClass("com.barchart.udt.SocketUDT"));
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,6 @@ public class NioUdtByteRendezvousChannelTest extends AbstractUdtTest {
|
||||
.meter().count());
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
}
|
||||
|
||||
connectFuture1.channel().close().sync();
|
||||
@ -98,7 +97,6 @@ public class NioUdtByteRendezvousChannelTest extends AbstractUdtTest {
|
||||
|
||||
boot1.shutdown();
|
||||
boot2.shutdown();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ public class NioUdtMessageRendezvousChannelTest extends AbstractUdtTest {
|
||||
@Test
|
||||
public void metadata() throws Exception {
|
||||
assertEquals(BufType.MESSAGE, new NioUdtMessageRendezvousChannel().metadata().bufferType());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,7 +86,6 @@ public class NioUdtMessageRendezvousChannelTest extends AbstractUdtTest {
|
||||
.meter().count());
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
}
|
||||
|
||||
connectFuture1.channel().close().sync();
|
||||
@ -103,7 +101,6 @@ public class NioUdtMessageRendezvousChannelTest extends AbstractUdtTest {
|
||||
|
||||
boot1.shutdown();
|
||||
boot2.shutdown();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class NioUdtProviderTest extends AbstractUdtTest {
|
||||
assertNotNull(NioUdtProvider.MESSAGE_ACCEPTOR.newChannel());
|
||||
assertNotNull(NioUdtProvider.MESSAGE_CONNECTOR.newChannel());
|
||||
assertNotNull(NioUdtProvider.MESSAGE_RENDEZVOUS.newChannel());
|
||||
|
||||
|
||||
// acceptor types
|
||||
assertTrue(NioUdtProvider.BYTE_ACCEPTOR.newChannel() instanceof UdtServerChannel);
|
||||
assertTrue(NioUdtProvider.MESSAGE_ACCEPTOR.newChannel() instanceof UdtServerChannel);
|
||||
|
@ -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;
|
||||
|
@ -46,7 +46,6 @@ public final class BootHelp {
|
||||
.localAddress(self).remoteAddress(peer).handler(handler);
|
||||
|
||||
return boot;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,7 +66,6 @@ public final class BootHelp {
|
||||
.localAddress(self).remoteAddress(peer).handler(handler);
|
||||
|
||||
return boot;
|
||||
|
||||
}
|
||||
|
||||
private BootHelp() { }
|
||||
|
@ -94,7 +94,6 @@ public abstract class CaliperBench extends SimpleBenchmark {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -147,21 +147,18 @@ public class CaliperMeasure {
|
||||
/** ignore complete blank entries */
|
||||
return;
|
||||
}
|
||||
{
|
||||
final Measurement mark = new Measurement(RATE_UNIT, rateValue,
|
||||
rateValue);
|
||||
rateMap.put(System.nanoTime(), mark);
|
||||
}
|
||||
{
|
||||
final Measurement mark = new Measurement(TIME_UNIT, timeValue,
|
||||
timeValue);
|
||||
timeMap.put(System.nanoTime(), mark);
|
||||
}
|
||||
{
|
||||
final Measurement mark = new Measurement(SIZE_UNIT, sizeValue,
|
||||
sizeValue);
|
||||
sizeMap.put(System.nanoTime(), mark);
|
||||
}
|
||||
|
||||
final Measurement markRate = new Measurement(RATE_UNIT, rateValue,
|
||||
rateValue);
|
||||
rateMap.put(System.nanoTime(), markRate);
|
||||
|
||||
final Measurement markTime = new Measurement(TIME_UNIT, timeValue,
|
||||
timeValue);
|
||||
timeMap.put(System.nanoTime(), markTime);
|
||||
|
||||
final Measurement markSize = new Measurement(SIZE_UNIT, sizeValue,
|
||||
sizeValue);
|
||||
sizeMap.put(System.nanoTime(), markSize);
|
||||
}
|
||||
|
||||
private final Map<String, String> variables = new HashMap<String, String>();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user