diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyCodecUtil.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyCodecUtil.java index 7f323eed37..0fe4035bd4 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyCodecUtil.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyCodecUtil.java @@ -19,9 +19,6 @@ import io.netty.buffer.ChannelBuffer; final class SpdyCodecUtil { - static final int SPDY_MIN_VERSION = 2; - static final int SPDY_MAX_VERSION = 3; - static final int SPDY_HEADER_TYPE_OFFSET = 2; static final int SPDY_HEADER_FLAGS_OFFSET = 4; static final int SPDY_HEADER_LENGTH_OFFSET = 5; diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyConstants.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyConstants.java new file mode 100644 index 0000000000..b1f1ecc3b6 --- /dev/null +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyConstants.java @@ -0,0 +1,9 @@ +package io.netty.handler.codec.spdy; + +public final class SpdyConstants { + + public static final int SPDY_MIN_VERSION = 2; + public static final int SPDY_MAX_VERSION = 3; + + private SpdyConstants() {} +} diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameDecoder.java index a8a085bdae..1b0df4dc0c 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameDecoder.java @@ -82,7 +82,7 @@ public class SpdyFrameDecoder extends StreamToMessageDecoder { * Creates a new instance with the specified parameters. */ public SpdyFrameDecoder(int version, int maxChunkSize, int maxHeaderSize) { - if (version < SPDY_MIN_VERSION || version > SPDY_MAX_VERSION) { + if (version < SpdyConstants.SPDY_MIN_VERSION || version > SpdyConstants.SPDY_MAX_VERSION) { throw new IllegalArgumentException( "unsupported version: " + version); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameEncoder.java index 94a454766c..2e918de379 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameEncoder.java @@ -51,7 +51,7 @@ public class SpdyFrameEncoder extends MessageToStreamEncoder { */ public SpdyFrameEncoder(int version, int compressionLevel, int windowBits, int memLevel) { super(); - if (version < SPDY_MIN_VERSION || version > SPDY_MAX_VERSION) { + if (version < SpdyConstants.SPDY_MIN_VERSION || version > SpdyConstants.SPDY_MAX_VERSION) { throw new IllegalArgumentException( "unknown version: " + version); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockJZlibCompressor.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockJZlibCompressor.java index b50530425d..864f0cdf67 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockJZlibCompressor.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockJZlibCompressor.java @@ -27,7 +27,7 @@ class SpdyHeaderBlockJZlibCompressor extends SpdyHeaderBlockCompressor { public SpdyHeaderBlockJZlibCompressor( int version, int compressionLevel, int windowBits, int memLevel) { - if (version < SPDY_MIN_VERSION || version > SPDY_MAX_VERSION) { + if (version < SpdyConstants.SPDY_MIN_VERSION || version > SpdyConstants.SPDY_MAX_VERSION) { throw new IllegalArgumentException( "unsupported version: " + version); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibCompressor.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibCompressor.java index 24cc5a047f..c0a99067a5 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibCompressor.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibCompressor.java @@ -26,7 +26,7 @@ class SpdyHeaderBlockZlibCompressor extends SpdyHeaderBlockCompressor { private final Deflater compressor; public SpdyHeaderBlockZlibCompressor(int version, int compressionLevel) { - if (version < SPDY_MIN_VERSION || version > SPDY_MAX_VERSION) { + if (version < SpdyConstants.SPDY_MIN_VERSION || version > SpdyConstants.SPDY_MAX_VERSION) { throw new IllegalArgumentException( "unsupported version: " + version); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecompressor.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecompressor.java index 97b3379bae..fc6d6e141a 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecompressor.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecompressor.java @@ -28,7 +28,7 @@ class SpdyHeaderBlockZlibDecompressor extends SpdyHeaderBlockDecompressor { private final Inflater decompressor = new Inflater(); public SpdyHeaderBlockZlibDecompressor(int version) { - if (version < SPDY_MIN_VERSION || version > SPDY_MAX_VERSION) { + if (version < SpdyConstants.SPDY_MIN_VERSION || version > SpdyConstants.SPDY_MAX_VERSION) { throw new IllegalArgumentException( "unsupported version: " + version); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java index a3085bc49f..42906e2386 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java @@ -54,7 +54,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder SPDY_MAX_VERSION) { + if (version < SpdyConstants.SPDY_MIN_VERSION || version > SpdyConstants.SPDY_MAX_VERSION) { throw new IllegalArgumentException( "unsupported version: " + version); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpEncoder.java index 1b1b75807a..cca380821f 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpEncoder.java @@ -130,7 +130,7 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder { * @param version the protocol version */ public SpdyHttpEncoder(int version) { - if (version < SPDY_MIN_VERSION || version > SPDY_MAX_VERSION) { + if (version < SpdyConstants.SPDY_MIN_VERSION || version > SpdyConstants.SPDY_MAX_VERSION) { throw new IllegalArgumentException( "unsupported version: " + version); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java index 2774f6a7c7..f559b7b6c7 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java @@ -77,7 +77,7 @@ public class SpdySessionHandler extends ChannelHandlerAdapter { */ public SpdySessionHandler(int version, boolean server) { super(); - if (version < SPDY_MIN_VERSION || version > SPDY_MAX_VERSION) { + if (version < SpdyConstants.SPDY_MIN_VERSION || version > SpdyConstants.SPDY_MAX_VERSION) { throw new IllegalArgumentException( "unsupported version: " + version); } diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/NioNioSocketSpdyEchoTest.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/NioNioSocketSpdyEchoTest.java deleted file mode 100644 index e127f80129..0000000000 --- a/codec-http/src/test/java/io/netty/handler/codec/spdy/NioNioSocketSpdyEchoTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - */ -package io.netty.handler.codec.spdy; - - -import io.netty.bootstrap.Bootstrap; -import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.socket.nio.NioEventLoop; -import io.netty.channel.socket.nio.NioServerSocketChannel; -import io.netty.channel.socket.nio.NioSocketChannel; - -public class NioNioSocketSpdyEchoTest extends AbstractSocketSpdyEchoTest { - - @Override - protected Bootstrap newClientBootstrap() { - return new Bootstrap().eventLoop(new NioEventLoop()).channel(new NioSocketChannel()); - } - - @Override - protected ServerBootstrap newServerBootstrap() { - return new ServerBootstrap().eventLoop(new NioEventLoop(), new NioEventLoop()).channel(new NioServerSocketChannel()); - } - -} diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/NioOioSocketSpdyEchoTest.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/NioOioSocketSpdyEchoTest.java deleted file mode 100644 index 301bccbcdc..0000000000 --- a/codec-http/src/test/java/io/netty/handler/codec/spdy/NioOioSocketSpdyEchoTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - */ -package io.netty.handler.codec.spdy; - - -import io.netty.bootstrap.Bootstrap; -import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.socket.nio.NioEventLoop; -import io.netty.channel.socket.nio.NioSocketChannel; -import io.netty.channel.socket.oio.OioEventLoop; -import io.netty.channel.socket.oio.OioServerSocketChannel; - -public class NioOioSocketSpdyEchoTest extends AbstractSocketSpdyEchoTest { - - @Override - protected Bootstrap newClientBootstrap() { - return new Bootstrap().eventLoop(new NioEventLoop()).channel(new NioSocketChannel()); - } - - @Override - protected ServerBootstrap newServerBootstrap() { - return new ServerBootstrap().eventLoop(new OioEventLoop(), new OioEventLoop()).channel(new OioServerSocketChannel()); - } -} diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/OioNioSocketSpdyEchoTest.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/OioNioSocketSpdyEchoTest.java deleted file mode 100644 index fd0b5b56d6..0000000000 --- a/codec-http/src/test/java/io/netty/handler/codec/spdy/OioNioSocketSpdyEchoTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - */ -package io.netty.handler.codec.spdy; - - -import io.netty.bootstrap.Bootstrap; -import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.socket.nio.NioEventLoop; -import io.netty.channel.socket.nio.NioServerSocketChannel; -import io.netty.channel.socket.oio.OioEventLoop; -import io.netty.channel.socket.oio.OioSocketChannel; - -public class OioNioSocketSpdyEchoTest extends AbstractSocketSpdyEchoTest { - - @Override - protected Bootstrap newClientBootstrap() { - return new Bootstrap().eventLoop(new OioEventLoop()).channel(new OioSocketChannel()); - } - - @Override - protected ServerBootstrap newServerBootstrap() { - return new ServerBootstrap().eventLoop(new NioEventLoop(), new NioEventLoop()).channel(new NioServerSocketChannel()); - } -} diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/OioOioSocketSpdyEchoTest.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/OioOioSocketSpdyEchoTest.java deleted file mode 100644 index 26e3dedd1d..0000000000 --- a/codec-http/src/test/java/io/netty/handler/codec/spdy/OioOioSocketSpdyEchoTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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. - */ -package io.netty.handler.codec.spdy; - - -import io.netty.bootstrap.Bootstrap; -import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.socket.oio.OioEventLoop; -import io.netty.channel.socket.oio.OioServerSocketChannel; -import io.netty.channel.socket.oio.OioSocketChannel; - -public class OioOioSocketSpdyEchoTest extends AbstractSocketSpdyEchoTest { - - @Override - protected Bootstrap newClientBootstrap() { - return new Bootstrap().eventLoop(new OioEventLoop()).channel(new OioSocketChannel()); - } - - @Override - protected ServerBootstrap newServerBootstrap() { - return new ServerBootstrap().eventLoop(new OioEventLoop(), new OioEventLoop()).channel(new OioServerSocketChannel()); - } -} diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java index 4b0d4efa37..0b92bc0016 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java @@ -256,7 +256,7 @@ public class SpdySessionHandlerTest { @Test public void testSpdyClientSessionHandler() { - for (int version = SPDY_MIN_VERSION; version <= SPDY_MAX_VERSION; version ++) { + for (int version = SpdyConstants.SPDY_MIN_VERSION; version <= SpdyConstants.SPDY_MAX_VERSION; version ++) { logger.info("Running: testSpdyClientSessionHandler v" + version); testSpdySessionHandler(version, false); } @@ -264,7 +264,7 @@ public class SpdySessionHandlerTest { @Test public void testSpdyServerSessionHandler() { - for (int version = SPDY_MIN_VERSION; version <= SPDY_MAX_VERSION; version ++) { + for (int version = SpdyConstants.SPDY_MIN_VERSION; version <= SpdyConstants.SPDY_MAX_VERSION; version ++) { logger.info("Running: testSpdyServerSessionHandler v" + version); testSpdySessionHandler(version, true); } diff --git a/testsuite/pom.xml b/testsuite/pom.xml index 83a0a10452..67bd122328 100644 --- a/testsuite/pom.xml +++ b/testsuite/pom.xml @@ -34,6 +34,11 @@ netty-handler ${project.version} + + ${project.groupId} + netty-codec-http + ${project.version} + diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractSocketTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractSocketTest.java index f0b71d3629..0f2552b351 100644 --- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractSocketTest.java +++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractSocketTest.java @@ -46,7 +46,7 @@ public abstract class AbstractSocketTest { protected volatile Bootstrap cb; protected volatile InetSocketAddress addr; - protected void run() throws Exception { + protected void run() throws Throwable { int i = 0; for (Entry, Factory> e: COMBO) { sb = e.getKey().newInstance(); diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketEchoTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketEchoTest.java index d82cfee602..39eb40d7ec 100644 --- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketEchoTest.java +++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketEchoTest.java @@ -40,7 +40,7 @@ public class SocketEchoTest extends AbstractSocketTest { } @Test - public void testSimpleEcho() throws Exception { + public void testSimpleEcho() throws Throwable { run(); } diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/AbstractSocketSpdyEchoTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSpdyEchoTest.java similarity index 92% rename from codec-http/src/test/java/io/netty/handler/codec/spdy/AbstractSocketSpdyEchoTest.java rename to testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSpdyEchoTest.java index f0e8c228fa..2fca3fd5d5 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/spdy/AbstractSocketSpdyEchoTest.java +++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSpdyEchoTest.java @@ -13,9 +13,8 @@ * License for the specific language governing permissions and limitations * under the License. */ -package io.netty.handler.codec.spdy; +package io.netty.testsuite.transport.socket; -import static io.netty.handler.codec.spdy.SpdyCodecUtil.*; import static org.junit.Assert.*; import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; @@ -27,6 +26,9 @@ import io.netty.channel.ChannelInboundMessageHandlerAdapter; import io.netty.channel.ChannelInboundStreamHandlerAdapter; import io.netty.channel.ChannelInitializer; import io.netty.channel.socket.SocketChannel; +import io.netty.handler.codec.spdy.SpdyConstants; +import io.netty.handler.codec.spdy.SpdyFrameDecoder; +import io.netty.handler.codec.spdy.SpdyFrameEncoder; import io.netty.util.SocketAddresses; import java.io.IOException; @@ -36,7 +38,7 @@ import java.util.concurrent.atomic.AtomicReference; import org.junit.Test; -public abstract class AbstractSocketSpdyEchoTest { +public class SocketSpdyEchoTest extends AbstractSocketTest { private static final Random random = new Random(); static final int ignoredBytes = 20; @@ -163,27 +165,17 @@ public abstract class AbstractSocketSpdyEchoTest { return frames; } - private ServerBootstrap sb; - private Bootstrap cb; + private int version; - protected abstract ServerBootstrap newServerBootstrap(); - protected abstract Bootstrap newClientBootstrap(); - - @Test(timeout = 10000) + @Test(timeout = 15000) public void testSpdyEcho() throws Throwable { - for (int version = SPDY_MIN_VERSION; version <= SPDY_MAX_VERSION; version ++) { - sb = newServerBootstrap(); - cb = newClientBootstrap(); - try { - testSpdyEcho(version); - } finally { - sb.shutdown(); - cb.shutdown(); - } + for (version = SpdyConstants.SPDY_MIN_VERSION; version <= SpdyConstants.SPDY_MAX_VERSION; version ++) { + logger.info("Testing against SPDY v" + version); + run(); } } - private void testSpdyEcho(final int version) throws Throwable { + public void testSpdyEcho(ServerBootstrap sb, Bootstrap cb) throws Throwable { ChannelBuffer frames = createFrames(version);