Remove unnecessarily qualified static access
This commit is contained in:
parent
bbcb035246
commit
58ba0de659
@ -47,25 +47,25 @@ public abstract class AbstractCompositeChannelBufferTest extends
|
|||||||
protected ByteBuf newBuffer(int length) {
|
protected ByteBuf newBuffer(int length) {
|
||||||
buffers = new ArrayList<ByteBuf>();
|
buffers = new ArrayList<ByteBuf>();
|
||||||
for (int i = 0; i < length + 45; i += 45) {
|
for (int i = 0; i < length + 45; i += 45) {
|
||||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
buffers.add(EMPTY_BUFFER);
|
||||||
buffers.add(Unpooled.wrappedBuffer(new byte[1]));
|
buffers.add(wrappedBuffer(new byte[1]));
|
||||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
buffers.add(EMPTY_BUFFER);
|
||||||
buffers.add(Unpooled.wrappedBuffer(new byte[2]));
|
buffers.add(wrappedBuffer(new byte[2]));
|
||||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
buffers.add(EMPTY_BUFFER);
|
||||||
buffers.add(Unpooled.wrappedBuffer(new byte[3]));
|
buffers.add(wrappedBuffer(new byte[3]));
|
||||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
buffers.add(EMPTY_BUFFER);
|
||||||
buffers.add(Unpooled.wrappedBuffer(new byte[4]));
|
buffers.add(wrappedBuffer(new byte[4]));
|
||||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
buffers.add(EMPTY_BUFFER);
|
||||||
buffers.add(Unpooled.wrappedBuffer(new byte[5]));
|
buffers.add(wrappedBuffer(new byte[5]));
|
||||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
buffers.add(EMPTY_BUFFER);
|
||||||
buffers.add(Unpooled.wrappedBuffer(new byte[6]));
|
buffers.add(wrappedBuffer(new byte[6]));
|
||||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
buffers.add(EMPTY_BUFFER);
|
||||||
buffers.add(Unpooled.wrappedBuffer(new byte[7]));
|
buffers.add(wrappedBuffer(new byte[7]));
|
||||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
buffers.add(EMPTY_BUFFER);
|
||||||
buffers.add(Unpooled.wrappedBuffer(new byte[8]));
|
buffers.add(wrappedBuffer(new byte[8]));
|
||||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
buffers.add(EMPTY_BUFFER);
|
||||||
buffers.add(Unpooled.wrappedBuffer(new byte[9]));
|
buffers.add(wrappedBuffer(new byte[9]));
|
||||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
buffers.add(EMPTY_BUFFER);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = Unpooled.wrappedBuffer(
|
buffer = Unpooled.wrappedBuffer(
|
||||||
@ -98,7 +98,7 @@ public abstract class AbstractCompositeChannelBufferTest extends
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testComponentAtOffset() {
|
public void testComponentAtOffset() {
|
||||||
CompositeByteBuf buf = (CompositeByteBuf) Unpooled.wrappedBuffer(new byte[] { 1, 2, 3, 4, 5 }, new byte[] {4, 5, 6, 7, 8, 9, 26});
|
CompositeByteBuf buf = (CompositeByteBuf) wrappedBuffer(new byte[]{1, 2, 3, 4, 5}, new byte[]{4, 5, 6, 7, 8, 9, 26});
|
||||||
|
|
||||||
//Ensure that a random place will be fine
|
//Ensure that a random place will be fine
|
||||||
assertEquals(buf.componentAtOffset(2).capacity(), 5);
|
assertEquals(buf.componentAtOffset(2).capacity(), 5);
|
||||||
|
@ -194,13 +194,13 @@ public class ChannelBuffersTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testCompare2() {
|
public void testCompare2() {
|
||||||
assertTrue(ByteBufUtil.compare(
|
assertTrue(ByteBufUtil.compare(
|
||||||
Unpooled.wrappedBuffer(new byte[]{(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}),
|
wrappedBuffer(new byte[]{(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}),
|
||||||
Unpooled.wrappedBuffer(new byte[]{(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00}))
|
wrappedBuffer(new byte[]{(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00}))
|
||||||
> 0);
|
> 0);
|
||||||
|
|
||||||
assertTrue(ByteBufUtil.compare(
|
assertTrue(ByteBufUtil.compare(
|
||||||
Unpooled.wrappedBuffer(new byte[]{(byte) 0xFF}),
|
wrappedBuffer(new byte[]{(byte) 0xFF}),
|
||||||
Unpooled.wrappedBuffer(new byte[]{(byte) 0x00}))
|
wrappedBuffer(new byte[]{(byte) 0x00}))
|
||||||
> 0);
|
> 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ public class ChannelBuffersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapSingleInt() {
|
public void testWrapSingleInt() {
|
||||||
ByteBuf buffer = Unpooled.copyInt(42);
|
ByteBuf buffer = copyInt(42);
|
||||||
assertEquals(4, buffer.capacity());
|
assertEquals(4, buffer.capacity());
|
||||||
assertEquals(42, buffer.readInt());
|
assertEquals(42, buffer.readInt());
|
||||||
assertFalse(buffer.readable());
|
assertFalse(buffer.readable());
|
||||||
@ -411,7 +411,7 @@ public class ChannelBuffersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapInt() {
|
public void testWrapInt() {
|
||||||
ByteBuf buffer = Unpooled.copyInt(1, 4);
|
ByteBuf buffer = copyInt(1, 4);
|
||||||
assertEquals(8, buffer.capacity());
|
assertEquals(8, buffer.capacity());
|
||||||
assertEquals(1, buffer.readInt());
|
assertEquals(1, buffer.readInt());
|
||||||
assertEquals(4, buffer.readInt());
|
assertEquals(4, buffer.readInt());
|
||||||
@ -423,7 +423,7 @@ public class ChannelBuffersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapSingleShort() {
|
public void testWrapSingleShort() {
|
||||||
ByteBuf buffer = Unpooled.copyShort(42);
|
ByteBuf buffer = copyShort(42);
|
||||||
assertEquals(2, buffer.capacity());
|
assertEquals(2, buffer.capacity());
|
||||||
assertEquals(42, buffer.readShort());
|
assertEquals(42, buffer.readShort());
|
||||||
assertFalse(buffer.readable());
|
assertFalse(buffer.readable());
|
||||||
@ -431,7 +431,7 @@ public class ChannelBuffersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapShortFromShortArray() {
|
public void testWrapShortFromShortArray() {
|
||||||
ByteBuf buffer = Unpooled.copyShort(new short[] { 1, 4 });
|
ByteBuf buffer = copyShort(new short[]{1, 4});
|
||||||
assertEquals(4, buffer.capacity());
|
assertEquals(4, buffer.capacity());
|
||||||
assertEquals(1, buffer.readShort());
|
assertEquals(1, buffer.readShort());
|
||||||
assertEquals(4, buffer.readShort());
|
assertEquals(4, buffer.readShort());
|
||||||
@ -443,7 +443,7 @@ public class ChannelBuffersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapShortFromIntArray() {
|
public void testWrapShortFromIntArray() {
|
||||||
ByteBuf buffer = Unpooled.copyShort(1, 4);
|
ByteBuf buffer = copyShort(1, 4);
|
||||||
assertEquals(4, buffer.capacity());
|
assertEquals(4, buffer.capacity());
|
||||||
assertEquals(1, buffer.readShort());
|
assertEquals(1, buffer.readShort());
|
||||||
assertEquals(4, buffer.readShort());
|
assertEquals(4, buffer.readShort());
|
||||||
@ -455,7 +455,7 @@ public class ChannelBuffersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapSingleMedium() {
|
public void testWrapSingleMedium() {
|
||||||
ByteBuf buffer = Unpooled.copyMedium(42);
|
ByteBuf buffer = copyMedium(42);
|
||||||
assertEquals(3, buffer.capacity());
|
assertEquals(3, buffer.capacity());
|
||||||
assertEquals(42, buffer.readMedium());
|
assertEquals(42, buffer.readMedium());
|
||||||
assertFalse(buffer.readable());
|
assertFalse(buffer.readable());
|
||||||
@ -463,7 +463,7 @@ public class ChannelBuffersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapMedium() {
|
public void testWrapMedium() {
|
||||||
ByteBuf buffer = Unpooled.copyMedium(1, 4);
|
ByteBuf buffer = copyMedium(1, 4);
|
||||||
assertEquals(6, buffer.capacity());
|
assertEquals(6, buffer.capacity());
|
||||||
assertEquals(1, buffer.readMedium());
|
assertEquals(1, buffer.readMedium());
|
||||||
assertEquals(4, buffer.readMedium());
|
assertEquals(4, buffer.readMedium());
|
||||||
@ -475,7 +475,7 @@ public class ChannelBuffersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapSingleLong() {
|
public void testWrapSingleLong() {
|
||||||
ByteBuf buffer = Unpooled.copyLong(42);
|
ByteBuf buffer = copyLong(42);
|
||||||
assertEquals(8, buffer.capacity());
|
assertEquals(8, buffer.capacity());
|
||||||
assertEquals(42, buffer.readLong());
|
assertEquals(42, buffer.readLong());
|
||||||
assertFalse(buffer.readable());
|
assertFalse(buffer.readable());
|
||||||
@ -483,7 +483,7 @@ public class ChannelBuffersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapLong() {
|
public void testWrapLong() {
|
||||||
ByteBuf buffer = Unpooled.copyLong(1, 4);
|
ByteBuf buffer = copyLong(1, 4);
|
||||||
assertEquals(16, buffer.capacity());
|
assertEquals(16, buffer.capacity());
|
||||||
assertEquals(1, buffer.readLong());
|
assertEquals(1, buffer.readLong());
|
||||||
assertEquals(4, buffer.readLong());
|
assertEquals(4, buffer.readLong());
|
||||||
@ -495,7 +495,7 @@ public class ChannelBuffersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapSingleFloat() {
|
public void testWrapSingleFloat() {
|
||||||
ByteBuf buffer = Unpooled.copyFloat(42);
|
ByteBuf buffer = copyFloat(42);
|
||||||
assertEquals(4, buffer.capacity());
|
assertEquals(4, buffer.capacity());
|
||||||
assertEquals(42, buffer.readFloat(), 0.01);
|
assertEquals(42, buffer.readFloat(), 0.01);
|
||||||
assertFalse(buffer.readable());
|
assertFalse(buffer.readable());
|
||||||
@ -503,7 +503,7 @@ public class ChannelBuffersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapFloat() {
|
public void testWrapFloat() {
|
||||||
ByteBuf buffer = Unpooled.copyFloat(1, 4);
|
ByteBuf buffer = copyFloat(1, 4);
|
||||||
assertEquals(8, buffer.capacity());
|
assertEquals(8, buffer.capacity());
|
||||||
assertEquals(1, buffer.readFloat(), 0.01);
|
assertEquals(1, buffer.readFloat(), 0.01);
|
||||||
assertEquals(4, buffer.readFloat(), 0.01);
|
assertEquals(4, buffer.readFloat(), 0.01);
|
||||||
@ -515,7 +515,7 @@ public class ChannelBuffersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapSingleDouble() {
|
public void testWrapSingleDouble() {
|
||||||
ByteBuf buffer = Unpooled.copyDouble(42);
|
ByteBuf buffer = copyDouble(42);
|
||||||
assertEquals(8, buffer.capacity());
|
assertEquals(8, buffer.capacity());
|
||||||
assertEquals(42, buffer.readDouble(), 0.01);
|
assertEquals(42, buffer.readDouble(), 0.01);
|
||||||
assertFalse(buffer.readable());
|
assertFalse(buffer.readable());
|
||||||
@ -523,7 +523,7 @@ public class ChannelBuffersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapDouble() {
|
public void testWrapDouble() {
|
||||||
ByteBuf buffer = Unpooled.copyDouble(1, 4);
|
ByteBuf buffer = copyDouble(1, 4);
|
||||||
assertEquals(16, buffer.capacity());
|
assertEquals(16, buffer.capacity());
|
||||||
assertEquals(1, buffer.readDouble(), 0.01);
|
assertEquals(1, buffer.readDouble(), 0.01);
|
||||||
assertEquals(4, buffer.readDouble(), 0.01);
|
assertEquals(4, buffer.readDouble(), 0.01);
|
||||||
@ -535,7 +535,7 @@ public class ChannelBuffersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapBoolean() {
|
public void testWrapBoolean() {
|
||||||
ByteBuf buffer = Unpooled.copyBoolean(true, false);
|
ByteBuf buffer = copyBoolean(true, false);
|
||||||
assertEquals(2, buffer.capacity());
|
assertEquals(2, buffer.capacity());
|
||||||
assertEquals(true, buffer.readBoolean());
|
assertEquals(true, buffer.readBoolean());
|
||||||
assertEquals(false, buffer.readBoolean());
|
assertEquals(false, buffer.readBoolean());
|
||||||
|
@ -40,26 +40,26 @@ public class ReadOnlyChannelBufferTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnmodifiableBuffer() {
|
public void testUnmodifiableBuffer() {
|
||||||
assertTrue(Unpooled.unmodifiableBuffer(Unpooled.buffer(1)) instanceof ReadOnlyByteBuf);
|
assertTrue(unmodifiableBuffer(buffer(1)) instanceof ReadOnlyByteBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnwrap() {
|
public void testUnwrap() {
|
||||||
ByteBuf buf = Unpooled.buffer(1);
|
ByteBuf buf = buffer(1);
|
||||||
assertSame(buf, ((WrappedByteBuf) Unpooled.unmodifiableBuffer(buf)).unwrap());
|
assertSame(buf, ((WrappedByteBuf) Unpooled.unmodifiableBuffer(buf)).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldHaveSameByteOrder() {
|
public void shouldHaveSameByteOrder() {
|
||||||
ByteBuf buf = Unpooled.buffer(1);
|
ByteBuf buf = buffer(1);
|
||||||
assertSame(Unpooled.BIG_ENDIAN, Unpooled.unmodifiableBuffer(buf).order());
|
assertSame(BIG_ENDIAN, Unpooled.unmodifiableBuffer(buf).order());
|
||||||
buf = buf.order(LITTLE_ENDIAN);
|
buf = buf.order(LITTLE_ENDIAN);
|
||||||
assertSame(Unpooled.LITTLE_ENDIAN, Unpooled.unmodifiableBuffer(buf).order());
|
assertSame(LITTLE_ENDIAN, Unpooled.unmodifiableBuffer(buf).order());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldReturnReadOnlyDerivedBuffer() {
|
public void shouldReturnReadOnlyDerivedBuffer() {
|
||||||
ByteBuf buf = Unpooled.unmodifiableBuffer(Unpooled.buffer(1));
|
ByteBuf buf = unmodifiableBuffer(buffer(1));
|
||||||
assertTrue(buf.duplicate() instanceof ReadOnlyByteBuf);
|
assertTrue(buf.duplicate() instanceof ReadOnlyByteBuf);
|
||||||
assertTrue(buf.slice() instanceof ReadOnlyByteBuf);
|
assertTrue(buf.slice() instanceof ReadOnlyByteBuf);
|
||||||
assertTrue(buf.slice(0, 1) instanceof ReadOnlyByteBuf);
|
assertTrue(buf.slice(0, 1) instanceof ReadOnlyByteBuf);
|
||||||
@ -68,7 +68,7 @@ public class ReadOnlyChannelBufferTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldReturnWritableCopy() {
|
public void shouldReturnWritableCopy() {
|
||||||
ByteBuf buf = Unpooled.unmodifiableBuffer(Unpooled.buffer(1));
|
ByteBuf buf = unmodifiableBuffer(buffer(1));
|
||||||
assertFalse(buf.copy() instanceof ReadOnlyByteBuf);
|
assertFalse(buf.copy() instanceof ReadOnlyByteBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,13 +138,13 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
|
|||||||
// New handshake method with a challenge:
|
// New handshake method with a challenge:
|
||||||
res.addHeader(SEC_WEBSOCKET_ORIGIN, req.getHeader(ORIGIN));
|
res.addHeader(SEC_WEBSOCKET_ORIGIN, req.getHeader(ORIGIN));
|
||||||
res.addHeader(SEC_WEBSOCKET_LOCATION, getWebSocketUrl());
|
res.addHeader(SEC_WEBSOCKET_LOCATION, getWebSocketUrl());
|
||||||
String subprotocols = req.getHeader(Names.SEC_WEBSOCKET_PROTOCOL);
|
String subprotocols = req.getHeader(SEC_WEBSOCKET_PROTOCOL);
|
||||||
if (subprotocols != null) {
|
if (subprotocols != null) {
|
||||||
String selectedSubprotocol = selectSubprotocol(subprotocols);
|
String selectedSubprotocol = selectSubprotocol(subprotocols);
|
||||||
if (selectedSubprotocol == null) {
|
if (selectedSubprotocol == null) {
|
||||||
throw new WebSocketHandshakeException("Requested subprotocol(s) not supported: " + subprotocols);
|
throw new WebSocketHandshakeException("Requested subprotocol(s) not supported: " + subprotocols);
|
||||||
} else {
|
} else {
|
||||||
res.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, selectedSubprotocol);
|
res.addHeader(SEC_WEBSOCKET_PROTOCOL, selectedSubprotocol);
|
||||||
setSelectedSubprotocol(selectedSubprotocol);
|
setSelectedSubprotocol(selectedSubprotocol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class WebSocketServerProtocolHandler extends ChannelInboundMessageHandler
|
|||||||
@Override
|
@Override
|
||||||
public void messageReceived(ChannelHandlerContext ctx, WebSocketFrame frame) throws Exception {
|
public void messageReceived(ChannelHandlerContext ctx, WebSocketFrame frame) throws Exception {
|
||||||
if (frame instanceof CloseWebSocketFrame) {
|
if (frame instanceof CloseWebSocketFrame) {
|
||||||
WebSocketServerHandshaker handshaker = WebSocketServerProtocolHandler.getHandshaker(ctx);
|
WebSocketServerHandshaker handshaker = getHandshaker(ctx);
|
||||||
handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame);
|
handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame);
|
||||||
return;
|
return;
|
||||||
} else if (frame instanceof PingWebSocketFrame) {
|
} else if (frame instanceof PingWebSocketFrame) {
|
||||||
|
@ -59,7 +59,7 @@ public class WebSocketServerProtocolHandlerTest {
|
|||||||
writeUpgradeRequest(ch);
|
writeUpgradeRequest(ch);
|
||||||
assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
|
assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
|
||||||
|
|
||||||
ch.writeInbound(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/test"));
|
ch.writeInbound(new DefaultHttpRequest(HTTP_1_1, HttpMethod.GET, "/test"));
|
||||||
assertEquals(FORBIDDEN, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
|
assertEquals(FORBIDDEN, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,14 +39,14 @@ public class DelimiterBasedFrameDecoderTest {
|
|||||||
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 1, 2 }));
|
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 1, 2 }));
|
||||||
try {
|
try {
|
||||||
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0 })));
|
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0 })));
|
||||||
Assert.fail(DecoderException.class.getSimpleName() + " must be raised.");
|
fail(DecoderException.class.getSimpleName() + " must be raised.");
|
||||||
} catch (TooLongFrameException e) {
|
} catch (TooLongFrameException e) {
|
||||||
// Expected
|
// Expected
|
||||||
}
|
}
|
||||||
|
|
||||||
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 'A', 0 }));
|
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 'A', 0 }));
|
||||||
ByteBuf buf = (ByteBuf) ch.readInbound();
|
ByteBuf buf = (ByteBuf) ch.readInbound();
|
||||||
Assert.assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,14 +58,14 @@ public class DelimiterBasedFrameDecoderTest {
|
|||||||
for (int i = 0; i < 2; i ++) {
|
for (int i = 0; i < 2; i ++) {
|
||||||
try {
|
try {
|
||||||
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 1, 2 })));
|
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 1, 2 })));
|
||||||
Assert.fail(DecoderException.class.getSimpleName() + " must be raised.");
|
fail(DecoderException.class.getSimpleName() + " must be raised.");
|
||||||
} catch (TooLongFrameException e) {
|
} catch (TooLongFrameException e) {
|
||||||
// Expected
|
// Expected
|
||||||
}
|
}
|
||||||
|
|
||||||
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 'A', 0 }));
|
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 'A', 0 }));
|
||||||
ByteBuf buf = (ByteBuf) ch.readInbound();
|
ByteBuf buf = (ByteBuf) ch.readInbound();
|
||||||
Assert.assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,14 +37,14 @@ public class LengthFieldBasedFrameDecoderTest {
|
|||||||
assertFalse(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 2 })));
|
assertFalse(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 2 })));
|
||||||
try {
|
try {
|
||||||
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0 })));
|
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0 })));
|
||||||
Assert.fail(DecoderException.class.getSimpleName() + " must be raised.");
|
fail(DecoderException.class.getSimpleName() + " must be raised.");
|
||||||
} catch (TooLongFrameException e) {
|
} catch (TooLongFrameException e) {
|
||||||
// Expected
|
// Expected
|
||||||
}
|
}
|
||||||
|
|
||||||
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 1, 'A' }));
|
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 1, 'A' }));
|
||||||
ByteBuf buf = (ByteBuf) ch.readInbound();
|
ByteBuf buf = (ByteBuf) ch.readInbound();
|
||||||
Assert.assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,14 +56,14 @@ public class LengthFieldBasedFrameDecoderTest {
|
|||||||
for (int i = 0; i < 2; i ++) {
|
for (int i = 0; i < 2; i ++) {
|
||||||
try {
|
try {
|
||||||
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 2 })));
|
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 2 })));
|
||||||
Assert.fail(DecoderException.class.getSimpleName() + " must be raised.");
|
fail(DecoderException.class.getSimpleName() + " must be raised.");
|
||||||
} catch (TooLongFrameException e) {
|
} catch (TooLongFrameException e) {
|
||||||
// Expected
|
// Expected
|
||||||
}
|
}
|
||||||
|
|
||||||
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 0, 0, 1, 'A' }));
|
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 0, 0, 1, 'A' }));
|
||||||
ByteBuf buf = (ByteBuf) ch.readInbound();
|
ByteBuf buf = (ByteBuf) ch.readInbound();
|
||||||
Assert.assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,10 +256,10 @@ final class Deflate {
|
|||||||
window_size = 2 * w_size;
|
window_size = 2 * w_size;
|
||||||
|
|
||||||
// Set the default configuration parameters:
|
// Set the default configuration parameters:
|
||||||
max_lazy_match = Deflate.config_table[level].max_lazy;
|
max_lazy_match = config_table[level].max_lazy;
|
||||||
good_match = Deflate.config_table[level].good_length;
|
good_match = config_table[level].good_length;
|
||||||
nice_match = Deflate.config_table[level].nice_length;
|
nice_match = config_table[level].nice_length;
|
||||||
max_chain_length = Deflate.config_table[level].max_chain;
|
max_chain_length = config_table[level].max_chain;
|
||||||
|
|
||||||
strstart = 0;
|
strstart = 0;
|
||||||
block_start = 0;
|
block_start = 0;
|
||||||
|
@ -142,7 +142,7 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cache Validation
|
// Cache Validation
|
||||||
String ifModifiedSince = request.getHeader(HttpHeaders.Names.IF_MODIFIED_SINCE);
|
String ifModifiedSince = request.getHeader(IF_MODIFIED_SINCE);
|
||||||
if (ifModifiedSince != null && !ifModifiedSince.equals("")) {
|
if (ifModifiedSince != null && !ifModifiedSince.equals("")) {
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
|
SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
|
||||||
Date ifModifiedSinceDate = dateFormatter.parse(ifModifiedSince);
|
Date ifModifiedSinceDate = dateFormatter.parse(ifModifiedSince);
|
||||||
@ -232,7 +232,7 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
|
|||||||
private static final Pattern ALLOWED_FILE_NAME = Pattern.compile("[A-Za-z0-9][-_A-Za-z0-9\\.]*");
|
private static final Pattern ALLOWED_FILE_NAME = Pattern.compile("[A-Za-z0-9][-_A-Za-z0-9\\.]*");
|
||||||
|
|
||||||
private static void sendListing(ChannelHandlerContext ctx, File dir) {
|
private static void sendListing(ChannelHandlerContext ctx, File dir) {
|
||||||
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.OK);
|
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);
|
||||||
response.setHeader(CONTENT_TYPE, "text/html; charset=UTF-8");
|
response.setHeader(CONTENT_TYPE, "text/html; charset=UTF-8");
|
||||||
|
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
@ -302,7 +302,7 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
|
|||||||
* Context
|
* Context
|
||||||
*/
|
*/
|
||||||
private static void sendNotModified(ChannelHandlerContext ctx) {
|
private static void sendNotModified(ChannelHandlerContext ctx) {
|
||||||
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.NOT_MODIFIED);
|
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, NOT_MODIFIED);
|
||||||
setDateHeader(response);
|
setDateHeader(response);
|
||||||
|
|
||||||
// Close the connection as soon as the error message is sent.
|
// Close the connection as soon as the error message is sent.
|
||||||
@ -320,7 +320,7 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
|
|||||||
dateFormatter.setTimeZone(TimeZone.getTimeZone(HTTP_DATE_GMT_TIMEZONE));
|
dateFormatter.setTimeZone(TimeZone.getTimeZone(HTTP_DATE_GMT_TIMEZONE));
|
||||||
|
|
||||||
Calendar time = new GregorianCalendar();
|
Calendar time = new GregorianCalendar();
|
||||||
response.setHeader(HttpHeaders.Names.DATE, dateFormatter.format(time.getTime()));
|
response.setHeader(DATE, dateFormatter.format(time.getTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -337,14 +337,14 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
|
|||||||
|
|
||||||
// Date header
|
// Date header
|
||||||
Calendar time = new GregorianCalendar();
|
Calendar time = new GregorianCalendar();
|
||||||
response.setHeader(HttpHeaders.Names.DATE, dateFormatter.format(time.getTime()));
|
response.setHeader(DATE, dateFormatter.format(time.getTime()));
|
||||||
|
|
||||||
// Add cache headers
|
// Add cache headers
|
||||||
time.add(Calendar.SECOND, HTTP_CACHE_SECONDS);
|
time.add(Calendar.SECOND, HTTP_CACHE_SECONDS);
|
||||||
response.setHeader(HttpHeaders.Names.EXPIRES, dateFormatter.format(time.getTime()));
|
response.setHeader(EXPIRES, dateFormatter.format(time.getTime()));
|
||||||
response.setHeader(HttpHeaders.Names.CACHE_CONTROL, "private, max-age=" + HTTP_CACHE_SECONDS);
|
response.setHeader(CACHE_CONTROL, "private, max-age=" + HTTP_CACHE_SECONDS);
|
||||||
response.setHeader(
|
response.setHeader(
|
||||||
HttpHeaders.Names.LAST_MODIFIED, dateFormatter.format(new Date(fileToCache.lastModified())));
|
LAST_MODIFIED, dateFormatter.format(new Date(fileToCache.lastModified())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -357,7 +357,7 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
|
|||||||
*/
|
*/
|
||||||
private static void setContentTypeHeader(HttpResponse response, File file) {
|
private static void setContentTypeHeader(HttpResponse response, File file) {
|
||||||
MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
|
MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
|
||||||
response.setHeader(HttpHeaders.Names.CONTENT_TYPE, mimeTypesMap.getContentType(file.getPath()));
|
response.setHeader(CONTENT_TYPE, mimeTypesMap.getContentType(file.getPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
|
|||||||
|
|
||||||
// new method
|
// new method
|
||||||
Set<Cookie> cookies;
|
Set<Cookie> cookies;
|
||||||
String value = request.getHeader(HttpHeaders.Names.COOKIE);
|
String value = request.getHeader(COOKIE);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
cookies = Collections.emptySet();
|
cookies = Collections.emptySet();
|
||||||
} else {
|
} else {
|
||||||
@ -302,23 +302,23 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
|
|||||||
responseContent.setLength(0);
|
responseContent.setLength(0);
|
||||||
|
|
||||||
// Decide whether to close the connection or not.
|
// Decide whether to close the connection or not.
|
||||||
boolean close = HttpHeaders.Values.CLOSE.equalsIgnoreCase(request.getHeader(HttpHeaders.Names.CONNECTION))
|
boolean close = HttpHeaders.Values.CLOSE.equalsIgnoreCase(request.getHeader(CONNECTION))
|
||||||
|| request.getProtocolVersion().equals(HttpVersion.HTTP_1_0)
|
|| request.getProtocolVersion().equals(HttpVersion.HTTP_1_0)
|
||||||
&& !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request.getHeader(HttpHeaders.Names.CONNECTION));
|
&& !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request.getHeader(CONNECTION));
|
||||||
|
|
||||||
// Build the response object.
|
// Build the response object.
|
||||||
HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
|
HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
|
||||||
response.setContent(buf);
|
response.setContent(buf);
|
||||||
response.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/plain; charset=UTF-8");
|
response.setHeader(CONTENT_TYPE, "text/plain; charset=UTF-8");
|
||||||
|
|
||||||
if (!close) {
|
if (!close) {
|
||||||
// There's no need to add 'Content-Length' header
|
// There's no need to add 'Content-Length' header
|
||||||
// if this is the last response.
|
// if this is the last response.
|
||||||
response.setHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(buf.readableBytes()));
|
response.setHeader(CONTENT_LENGTH, String.valueOf(buf.readableBytes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Cookie> cookies;
|
Set<Cookie> cookies;
|
||||||
String value = request.getHeader(HttpHeaders.Names.COOKIE);
|
String value = request.getHeader(COOKIE);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
cookies = Collections.emptySet();
|
cookies = Collections.emptySet();
|
||||||
} else {
|
} else {
|
||||||
@ -414,8 +414,8 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
|
|||||||
// Build the response object.
|
// Build the response object.
|
||||||
HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
|
HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
|
||||||
response.setContent(buf);
|
response.setContent(buf);
|
||||||
response.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/html; charset=UTF-8");
|
response.setHeader(CONTENT_TYPE, "text/html; charset=UTF-8");
|
||||||
response.setHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(buf.readableBytes()));
|
response.setHeader(CONTENT_LENGTH, String.valueOf(buf.readableBytes()));
|
||||||
// Write the response.
|
// Write the response.
|
||||||
ctx.channel().write(response);
|
ctx.channel().write(response);
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,6 @@ public class WebSocketServerHandler extends ChannelInboundMessageHandlerAdapter<
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String getWebSocketLocation(HttpRequest req) {
|
private static String getWebSocketLocation(HttpRequest req) {
|
||||||
return "ws://" + req.getHeader(HttpHeaders.Names.HOST) + WEBSOCKET_PATH;
|
return "ws://" + req.getHeader(HOST) + WEBSOCKET_PATH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,6 @@ public class WebSocketSslServerHandler extends ChannelInboundMessageHandlerAdapt
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String getWebSocketLocation(HttpRequest req) {
|
private static String getWebSocketLocation(HttpRequest req) {
|
||||||
return "wss://" + req.getHeader(HttpHeaders.Names.HOST) + WEBSOCKET_PATH;
|
return "wss://" + req.getHeader(HOST) + WEBSOCKET_PATH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public class LocalTimeServerHandler extends ChannelInboundMessageHandlerAdapter<
|
|||||||
for (Location l: locations.getLocationList()) {
|
for (Location l: locations.getLocationList()) {
|
||||||
TimeZone tz = TimeZone.getTimeZone(
|
TimeZone tz = TimeZone.getTimeZone(
|
||||||
toString(l.getContinent()) + '/' + l.getCity());
|
toString(l.getContinent()) + '/' + l.getCity());
|
||||||
Calendar calendar = Calendar.getInstance(tz);
|
Calendar calendar = getInstance(tz);
|
||||||
calendar.setTimeInMillis(currentTime);
|
calendar.setTimeInMillis(currentTime);
|
||||||
|
|
||||||
builder.addLocalTime(LocalTime.newBuilder().
|
builder.addLocalTime(LocalTime.newBuilder().
|
||||||
|
@ -110,7 +110,7 @@ public class DatagramMulticastTest extends AbstractDatagramTest {
|
|||||||
fail = true;
|
fail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertEquals(1, msg.data().readInt());
|
assertEquals(1, msg.data().readInt());
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
|
|
||||||
// mark the handler as done as we only are supposed to receive one message
|
// mark the handler as done as we only are supposed to receive one message
|
||||||
@ -121,7 +121,7 @@ public class DatagramMulticastTest extends AbstractDatagramTest {
|
|||||||
boolean success = latch.await(10, TimeUnit.SECONDS);
|
boolean success = latch.await(10, TimeUnit.SECONDS);
|
||||||
if (fail) {
|
if (fail) {
|
||||||
// fail if we receive an message after we are done
|
// fail if we receive an message after we are done
|
||||||
Assert.fail();
|
fail();
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class DatagramUnicastTest extends AbstractDatagramTest {
|
|||||||
public void messageReceived(
|
public void messageReceived(
|
||||||
ChannelHandlerContext ctx,
|
ChannelHandlerContext ctx,
|
||||||
DatagramPacket msg) throws Exception {
|
DatagramPacket msg) throws Exception {
|
||||||
Assert.assertEquals(1, msg.data().readInt());
|
assertEquals(1, msg.data().readInt());
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -38,7 +38,7 @@ import static com.sun.nio.sctp.SctpStandardSocketOptions.InitMaxStreams;
|
|||||||
* <td>{@code "sendBufferSize"}</td><td>{@link #setSendBufferSize(int)}</td>
|
* <td>{@code "sendBufferSize"}</td><td>{@link #setSendBufferSize(int)}</td>
|
||||||
* </tr><tr>
|
* </tr><tr>
|
||||||
* <td>{@code "sctpInitMaxStreams"}</td>
|
* <td>{@code "sctpInitMaxStreams"}</td>
|
||||||
* <td>{@link #setInitMaxStreams(com.sun.nio.sctp.SctpStandardSocketOptions.InitMaxStreams)}</td>
|
* <td>{@link #setInitMaxStreams(InitMaxStreams)}</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
@ -39,7 +39,7 @@ import static com.sun.nio.sctp.SctpStandardSocketOptions.InitMaxStreams;
|
|||||||
* <td>{@code "sendBufferSize"}</td><td>{@link #setSendBufferSize(int)}</td>
|
* <td>{@code "sendBufferSize"}</td><td>{@link #setSendBufferSize(int)}</td>
|
||||||
* </tr><tr>
|
* </tr><tr>
|
||||||
* <td>{@code "sctpInitMaxStreams"}</td>
|
* <td>{@code "sctpInitMaxStreams"}</td>
|
||||||
* <td>{@link #setInitMaxStreams(com.sun.nio.sctp.SctpStandardSocketOptions.InitMaxStreams)} (int)}}</td>
|
* <td>{@link #setInitMaxStreams(InitMaxStreams)} (int)}}</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user