[jboss-cvs] JBoss Messaging SVN: r6090 - in trunk: src/main/org/jboss/messaging/integration/transports/netty and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 16 07:07:01 EDT 2009
Author: ataylor
Date: 2009-03-16 07:07:00 -0400 (Mon, 16 Mar 2009)
New Revision: 6090
Modified:
trunk/build-thirdparty.xml
trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java
trunk/tests/src/org/jboss/messaging/tests/integration/http/NettyHttpTest.java
Log:
upgraded to netty beta1 and reenabled http tests
Modified: trunk/build-thirdparty.xml
===================================================================
--- trunk/build-thirdparty.xml 2009-03-16 10:04:45 UTC (rev 6089)
+++ trunk/build-thirdparty.xml 2009-03-16 11:07:00 UTC (rev 6090)
@@ -85,7 +85,7 @@
Dependencies required to build the transport jar
-->
- <componentref name="netty" version="3.1.0.ALPHA4"/>
+ <componentref name="netty" version="3.1.0.BETA1"/>
<!--
Dependencies needed to build the security.jar
Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java 2009-03-16 10:04:45 UTC (rev 6089)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java 2009-03-16 11:07:00 UTC (rev 6090)
@@ -21,24 +21,6 @@
*/
package org.jboss.messaging.integration.transports.netty;
-import static org.jboss.netty.channel.Channels.pipeline;
-import static org.jboss.netty.channel.Channels.write;
-
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLException;
-
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.impl.ssl.SSLSupport;
@@ -58,6 +40,8 @@
import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.ChannelStateEvent;
+import static org.jboss.netty.channel.Channels.pipeline;
+import static org.jboss.netty.channel.Channels.write;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.channel.UpstreamMessageEvent;
@@ -81,6 +65,21 @@
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.jboss.netty.handler.ssl.SslHandler;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
/**
* A NettyConnector
*
@@ -448,7 +447,7 @@
private String cookie;
- private CookieEncoder cookieEncoder = new CookieEncoder();
+ private CookieEncoder cookieEncoder = new CookieEncoder(false);
public void channelConnected(final ChannelHandlerContext ctx, final ChannelStateEvent e) throws Exception
{
@@ -481,12 +480,14 @@
HttpResponse response = (HttpResponse)e.getMessage();
if (httpRequiresSessionId && !active)
{
- Map<String, Cookie> cookieMap = cookieDecoder.decode(response.getHeader(HttpHeaders.Names.SET_COOKIE));
- Cookie cookie = cookieMap.get("JSESSIONID");
- if (cookie != null)
+ Set<Cookie> cookieMap = cookieDecoder.decode(response.getHeader(HttpHeaders.Names.SET_COOKIE));
+ for (Cookie cookie : cookieMap)
{
- cookieEncoder.addCookie(cookie);
- this.cookie = cookieEncoder.encode();
+ if (cookie.getName().equals("JSESSIONID"))
+ {
+ cookieEncoder.addCookie(cookie);
+ this.cookie = cookieEncoder.encode();
+ }
}
active = true;
handShakeFuture.run();
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/http/NettyHttpTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/http/NettyHttpTest.java 2009-03-16 10:04:45 UTC (rev 6089)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/http/NettyHttpTest.java 2009-03-16 11:07:00 UTC (rev 6090)
@@ -21,11 +21,6 @@
*/
package org.jboss.messaging.tests.integration.http;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.remoting.impl.AbstractBufferHandler;
import org.jboss.messaging.core.remoting.spi.BufferHandler;
@@ -37,6 +32,11 @@
import org.jboss.messaging.integration.transports.netty.TransportConstants;
import org.jboss.messaging.tests.util.UnitTestCase;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
/**
* @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
*/
@@ -50,306 +50,306 @@
{
}
-// public void testSendAndReceiveAtSameTime() throws Exception
-// {
-//
-// int numPackets = 1000;
-// CountDownLatch connCreatedLatch = new CountDownLatch(1);
-// CountDownLatch acceptorLatch = new CountDownLatch(numPackets);
-// CountDownLatch connectorLatch = new CountDownLatch(numPackets);
-// HashMap<String, Object> conf = new HashMap<String, Object>();
-// conf.put(TransportConstants.HTTP_ENABLED_PROP_NAME, true);
-// conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, -1l);
-// DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
-// SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
-// acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
-// acceptor.start();
-//
-// SimpleBufferHandler connectorHandler = new SimpleBufferHandler(connectorLatch);
-// connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
-// connector.start();
-// Connection conn = connector.createConnection();
-// connCreatedLatch.await(5, TimeUnit.SECONDS);
-// for (int i = 0; i < numPackets; i++)
-// {
-// MessagingBuffer buff = conn.createBuffer(8);
-// buff.writeInt(4);
-// buff.writeInt(i);
-// conn.write(buff);
-// buff = conn.createBuffer(8);
-// buff.writeInt(4);
-// buff.writeInt(i);
-// acceptorListener.connection.write(buff);
-// }
-// acceptorLatch.await(10, TimeUnit.SECONDS);
-// connectorLatch.await(10, TimeUnit.SECONDS);
-// conn.close();
-// assertEquals(acceptorHandler.messagesReceieved, numPackets);
-// assertEquals(connectorHandler.messagesReceieved, numPackets);
-// int i = 0;
-// for (Integer j : acceptorHandler.messages)
-// {
-// assertTrue(i == j);
-// i++;
-// }
-// i = 0;
-// for (Integer j : connectorHandler.messages)
-// {
-// assertTrue(i == j);
-// i++;
-// }
-// }
-//
-// public void testSendThenReceive() throws Exception
-// {
-//
-// int numPackets = 1000;
-// CountDownLatch connCreatedLatch = new CountDownLatch(1);
-// CountDownLatch acceptorLatch = new CountDownLatch(numPackets);
-// CountDownLatch connectorLatch = new CountDownLatch(numPackets);
-// HashMap<String, Object> conf = new HashMap<String, Object>();
-// conf.put(TransportConstants.HTTP_ENABLED_PROP_NAME, true);
-// conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, -1l);
-// DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
-// SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
-// acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
-// acceptor.start();
-//
-// SimpleBufferHandler connectorHandler = new SimpleBufferHandler(connectorLatch);
-// connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
-// connector.start();
-// Connection conn = connector.createConnection();
-// connCreatedLatch.await(5, TimeUnit.SECONDS);
-// for (int i = 0; i < numPackets; i++)
-// {
-// MessagingBuffer buff = conn.createBuffer(8);
-// buff.writeInt(4);
-// buff.writeInt(i);
-// conn.write(buff);
-// }
-// for (int i = 0; i < numPackets; i++)
-// {
-// MessagingBuffer buff = conn.createBuffer(8);
-// buff.writeInt(4);
-// buff.writeInt(i);
-// acceptorListener.connection.write(buff);
-// }
-// acceptorLatch.await(10, TimeUnit.SECONDS);
-// connectorLatch.await(10, TimeUnit.SECONDS);
-// conn.close();
-// assertEquals(acceptorHandler.messagesReceieved, numPackets);
-// assertEquals(connectorHandler.messagesReceieved, numPackets);
-// int i = 0;
-// for (Integer j : acceptorHandler.messages)
-// {
-// assertTrue(i == j);
-// i++;
-// }
-// i = 0;
-// for (Integer j : connectorHandler.messages)
-// {
-// assertTrue(i == j);
-// i++;
-// }
-// }
-//
-// public void testReceiveThenSend() throws Exception
-// {
-//
-// int numPackets = 1000;
-// CountDownLatch connCreatedLatch = new CountDownLatch(1);
-// CountDownLatch acceptorLatch = new CountDownLatch(numPackets);
-// CountDownLatch connectorLatch = new CountDownLatch(numPackets);
-// HashMap<String, Object> conf = new HashMap<String, Object>();
-// conf.put(TransportConstants.HTTP_ENABLED_PROP_NAME, true);
-// conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, -1l);
-// DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
-// SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
-// acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
-// acceptor.start();
-//
-// SimpleBufferHandler connectorHandler = new SimpleBufferHandler(connectorLatch);
-// connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
-// connector.start();
-// Connection conn = connector.createConnection();
-// connCreatedLatch.await(5, TimeUnit.SECONDS);
-// for (int i = 0; i < numPackets; i++)
-// {
-// MessagingBuffer buff = conn.createBuffer(8);
-// buff.writeInt(4);
-// buff.writeInt(i);
-// acceptorListener.connection.write(buff);
-// }
-//
-// for (int i = 0; i < numPackets; i++)
-// {
-// MessagingBuffer buff = conn.createBuffer(8);
-// buff.writeInt(4);
-// buff.writeInt(i);
-// conn.write(buff);
-// }
-// acceptorLatch.await(10, TimeUnit.SECONDS);
-// connectorLatch.await(10, TimeUnit.SECONDS);
-// conn.close();
-// assertEquals(acceptorHandler.messagesReceieved, numPackets);
-// assertEquals(connectorHandler.messagesReceieved, numPackets);
-// int i = 0;
-// for (Integer j : acceptorHandler.messages)
-// {
-// assertTrue(i == j);
-// i++;
-// }
-// i = 0;
-// for (Integer j : connectorHandler.messages)
-// {
-// assertTrue(i == j);
-// i++;
-// }
-// }
-//
-// public void testReceivePiggyBackOnOneResponse() throws Exception
-// {
-//
-// int numPackets = 1000;
-// CountDownLatch connCreatedLatch = new CountDownLatch(1);
-// CountDownLatch acceptorLatch = new CountDownLatch(1);
-// CountDownLatch connectorLatch = new CountDownLatch(numPackets);
-// HashMap<String, Object> conf = new HashMap<String, Object>();
-// conf.put(TransportConstants.HTTP_ENABLED_PROP_NAME, true);
-// conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, -1l);
-// DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
-// SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
-// acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
-// acceptor.start();
-//
-// SimpleBufferHandler connectorHandler = new SimpleBufferHandler(connectorLatch);
-// connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
-// connector.start();
-// Connection conn = connector.createConnection();
-// connCreatedLatch.await(5, TimeUnit.SECONDS);
-// for (int i = 0; i < numPackets; i++)
-// {
-// MessagingBuffer buff = conn.createBuffer(8);
-// buff.writeInt(4);
-// buff.writeInt(i);
-// acceptorListener.connection.write(buff);
-// }
-//
-//
-// MessagingBuffer buff = conn.createBuffer(8);
-// buff.writeInt(4);
-// buff.writeInt(0);
-// conn.write(buff);
-//
-// acceptorLatch.await(10, TimeUnit.SECONDS);
-// connectorLatch.await(10, TimeUnit.SECONDS);
-// conn.close();
-// assertEquals(acceptorHandler.messagesReceieved, 1);
-// assertEquals(connectorHandler.messagesReceieved, numPackets);
-// int i = 0;
-// for (Integer j : acceptorHandler.messages)
-// {
-// assertTrue(i == j);
-// i++;
-// }
-// i = 0;
-// for (Integer j : connectorHandler.messages)
-// {
-// assertTrue(i == j);
-// i++;
-// }
-// }
-//
-// public void testReceivePiggyBackOnIdleClient() throws Exception
-// {
-//
-// int numPackets = 1000;
-// CountDownLatch connCreatedLatch = new CountDownLatch(1);
-// CountDownLatch acceptorLatch = new CountDownLatch(0);
-// CountDownLatch connectorLatch = new CountDownLatch(numPackets);
-// HashMap<String, Object> conf = new HashMap<String, Object>();
-// conf.put(TransportConstants.HTTP_ENABLED_PROP_NAME, true);
-// conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, 500l);
-// conf.put(TransportConstants.HTTP_CLIENT_IDLE_PROP_NAME, 500l);
-// DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
-// SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
-// acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
-// acceptor.start();
-//
-// SimpleBufferHandler connectorHandler = new SimpleBufferHandler(connectorLatch);
-// connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
-// connector.start();
-// Connection conn = connector.createConnection();
-// connCreatedLatch.await(5, TimeUnit.SECONDS);
-// for (int i = 0; i < numPackets; i++)
-// {
-// MessagingBuffer buff = conn.createBuffer(8);
-// buff.writeInt(4);
-// buff.writeInt(i);
-// acceptorListener.connection.write(buff);
-// }
-//
-// acceptorLatch.await(10, TimeUnit.SECONDS);
-// connectorLatch.await(10, TimeUnit.SECONDS);
-// conn.close();
-// assertEquals(acceptorHandler.messagesReceieved, 0);
-// assertEquals(connectorHandler.messagesReceieved, numPackets);
-// int i = 0;
-// for (Integer j : acceptorHandler.messages)
-// {
-// assertTrue(i == j);
-// i++;
-// }
-// i = 0;
-// for (Integer j : connectorHandler.messages)
-// {
-// assertTrue(i == j);
-// i++;
-// }
-// }
-//
-// public void testSendWithNoReceive() throws Exception
-// {
-//
-// int numPackets = 1000;
-// CountDownLatch connCreatedLatch = new CountDownLatch(1);
-// CountDownLatch acceptorLatch = new CountDownLatch(numPackets);
-// CountDownLatch connectorLatch = new CountDownLatch(numPackets);
-// HashMap<String, Object> conf = new HashMap<String, Object>();
-// conf.put(TransportConstants.HTTP_ENABLED_PROP_NAME, true);
-// conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, -1l);
-// conf.put(TransportConstants.HTTP_RESPONSE_TIME_PROP_NAME, 500l);
-// conf.put(TransportConstants.HTTP_SERVER_SCAN_PERIOD_PROP_NAME, 5000l);
-// DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
-// SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
-// acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
-// acceptor.start();
-//
-// BogusResponseHandler connectorHandler = new BogusResponseHandler(connectorLatch);
-// connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
-// connector.start();
-// Connection conn = connector.createConnection();
-// connCreatedLatch.await(5, TimeUnit.SECONDS);
-// for (int i = 0; i < numPackets; i++)
-// {
-// MessagingBuffer buff = conn.createBuffer(8);
-// buff.writeInt(4);
-// buff.writeInt(i);
-// conn.write(buff);
-// }
-// acceptorLatch.await(100, TimeUnit.SECONDS);
-// connectorLatch.await(0, TimeUnit.SECONDS);
-// conn.close();
-// assertEquals(acceptorHandler.messagesReceieved, numPackets);
-// assertEquals(connectorHandler.messagesReceieved, 0);
-// int i = 0;
-// for (Integer j : acceptorHandler.messages)
-// {
-// assertTrue(i == j);
-// i++;
-// }
-// }
+ public void testSendAndReceiveAtSameTime() throws Exception
+ {
+ int numPackets = 1000;
+ CountDownLatch connCreatedLatch = new CountDownLatch(1);
+ CountDownLatch acceptorLatch = new CountDownLatch(numPackets);
+ CountDownLatch connectorLatch = new CountDownLatch(numPackets);
+ HashMap<String, Object> conf = new HashMap<String, Object>();
+ conf.put(TransportConstants.HTTP_ENABLED_PROP_NAME, true);
+ conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, -1l);
+ DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
+ SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
+ acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
+ acceptor.start();
+
+ SimpleBufferHandler connectorHandler = new SimpleBufferHandler(connectorLatch);
+ connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
+ connector.start();
+ Connection conn = connector.createConnection();
+ connCreatedLatch.await(5, TimeUnit.SECONDS);
+ for (int i = 0; i < numPackets; i++)
+ {
+ MessagingBuffer buff = conn.createBuffer(8);
+ buff.writeInt(4);
+ buff.writeInt(i);
+ conn.write(buff);
+ buff = conn.createBuffer(8);
+ buff.writeInt(4);
+ buff.writeInt(i);
+ acceptorListener.connection.write(buff);
+ }
+ acceptorLatch.await(10, TimeUnit.SECONDS);
+ connectorLatch.await(10, TimeUnit.SECONDS);
+ conn.close();
+ assertEquals(acceptorHandler.messagesReceieved, numPackets);
+ assertEquals(connectorHandler.messagesReceieved, numPackets);
+ int i = 0;
+ for (Integer j : acceptorHandler.messages)
+ {
+ assertTrue(i == j);
+ i++;
+ }
+ i = 0;
+ for (Integer j : connectorHandler.messages)
+ {
+ assertTrue(i == j);
+ i++;
+ }
+ }
+
+ public void testSendThenReceive() throws Exception
+ {
+
+ int numPackets = 1000;
+ CountDownLatch connCreatedLatch = new CountDownLatch(1);
+ CountDownLatch acceptorLatch = new CountDownLatch(numPackets);
+ CountDownLatch connectorLatch = new CountDownLatch(numPackets);
+ HashMap<String, Object> conf = new HashMap<String, Object>();
+ conf.put(TransportConstants.HTTP_ENABLED_PROP_NAME, true);
+ conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, -1l);
+ DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
+ SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
+ acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
+ acceptor.start();
+
+ SimpleBufferHandler connectorHandler = new SimpleBufferHandler(connectorLatch);
+ connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
+ connector.start();
+ Connection conn = connector.createConnection();
+ connCreatedLatch.await(5, TimeUnit.SECONDS);
+ for (int i = 0; i < numPackets; i++)
+ {
+ MessagingBuffer buff = conn.createBuffer(8);
+ buff.writeInt(4);
+ buff.writeInt(i);
+ conn.write(buff);
+ }
+ for (int i = 0; i < numPackets; i++)
+ {
+ MessagingBuffer buff = conn.createBuffer(8);
+ buff.writeInt(4);
+ buff.writeInt(i);
+ acceptorListener.connection.write(buff);
+ }
+ acceptorLatch.await(10, TimeUnit.SECONDS);
+ connectorLatch.await(10, TimeUnit.SECONDS);
+ conn.close();
+ assertEquals(acceptorHandler.messagesReceieved, numPackets);
+ assertEquals(connectorHandler.messagesReceieved, numPackets);
+ int i = 0;
+ for (Integer j : acceptorHandler.messages)
+ {
+ assertTrue(i == j);
+ i++;
+ }
+ i = 0;
+ for (Integer j : connectorHandler.messages)
+ {
+ assertTrue(i == j);
+ i++;
+ }
+ }
+
+ public void testReceiveThenSend() throws Exception
+ {
+
+ int numPackets = 1000;
+ CountDownLatch connCreatedLatch = new CountDownLatch(1);
+ CountDownLatch acceptorLatch = new CountDownLatch(numPackets);
+ CountDownLatch connectorLatch = new CountDownLatch(numPackets);
+ HashMap<String, Object> conf = new HashMap<String, Object>();
+ conf.put(TransportConstants.HTTP_ENABLED_PROP_NAME, true);
+ conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, -1l);
+ DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
+ SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
+ acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
+ acceptor.start();
+
+ SimpleBufferHandler connectorHandler = new SimpleBufferHandler(connectorLatch);
+ connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
+ connector.start();
+ Connection conn = connector.createConnection();
+ connCreatedLatch.await(5, TimeUnit.SECONDS);
+ for (int i = 0; i < numPackets; i++)
+ {
+ MessagingBuffer buff = conn.createBuffer(8);
+ buff.writeInt(4);
+ buff.writeInt(i);
+ acceptorListener.connection.write(buff);
+ }
+
+ for (int i = 0; i < numPackets; i++)
+ {
+ MessagingBuffer buff = conn.createBuffer(8);
+ buff.writeInt(4);
+ buff.writeInt(i);
+ conn.write(buff);
+ }
+ acceptorLatch.await(10, TimeUnit.SECONDS);
+ connectorLatch.await(10, TimeUnit.SECONDS);
+ conn.close();
+ assertEquals(acceptorHandler.messagesReceieved, numPackets);
+ assertEquals(connectorHandler.messagesReceieved, numPackets);
+ int i = 0;
+ for (Integer j : acceptorHandler.messages)
+ {
+ assertTrue(i == j);
+ i++;
+ }
+ i = 0;
+ for (Integer j : connectorHandler.messages)
+ {
+ assertTrue(i == j);
+ i++;
+ }
+ }
+
+ public void testReceivePiggyBackOnOneResponse() throws Exception
+ {
+
+ int numPackets = 1000;
+ CountDownLatch connCreatedLatch = new CountDownLatch(1);
+ CountDownLatch acceptorLatch = new CountDownLatch(1);
+ CountDownLatch connectorLatch = new CountDownLatch(numPackets);
+ HashMap<String, Object> conf = new HashMap<String, Object>();
+ conf.put(TransportConstants.HTTP_ENABLED_PROP_NAME, true);
+ conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, -1l);
+ DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
+ SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
+ acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
+ acceptor.start();
+
+ SimpleBufferHandler connectorHandler = new SimpleBufferHandler(connectorLatch);
+ connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
+ connector.start();
+ Connection conn = connector.createConnection();
+ connCreatedLatch.await(5, TimeUnit.SECONDS);
+ for (int i = 0; i < numPackets; i++)
+ {
+ MessagingBuffer buff = conn.createBuffer(8);
+ buff.writeInt(4);
+ buff.writeInt(i);
+ acceptorListener.connection.write(buff);
+ }
+
+
+ MessagingBuffer buff = conn.createBuffer(8);
+ buff.writeInt(4);
+ buff.writeInt(0);
+ conn.write(buff);
+
+ acceptorLatch.await(10, TimeUnit.SECONDS);
+ connectorLatch.await(10, TimeUnit.SECONDS);
+ conn.close();
+ assertEquals(acceptorHandler.messagesReceieved, 1);
+ assertEquals(connectorHandler.messagesReceieved, numPackets);
+ int i = 0;
+ for (Integer j : acceptorHandler.messages)
+ {
+ assertTrue(i == j);
+ i++;
+ }
+ i = 0;
+ for (Integer j : connectorHandler.messages)
+ {
+ assertTrue(i == j);
+ i++;
+ }
+ }
+
+ public void testReceivePiggyBackOnIdleClient() throws Exception
+ {
+
+ int numPackets = 1000;
+ CountDownLatch connCreatedLatch = new CountDownLatch(1);
+ CountDownLatch acceptorLatch = new CountDownLatch(0);
+ CountDownLatch connectorLatch = new CountDownLatch(numPackets);
+ HashMap<String, Object> conf = new HashMap<String, Object>();
+ conf.put(TransportConstants.HTTP_ENABLED_PROP_NAME, true);
+ conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, 500l);
+ conf.put(TransportConstants.HTTP_CLIENT_IDLE_PROP_NAME, 500l);
+ DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
+ SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
+ acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
+ acceptor.start();
+
+ SimpleBufferHandler connectorHandler = new SimpleBufferHandler(connectorLatch);
+ connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
+ connector.start();
+ Connection conn = connector.createConnection();
+ connCreatedLatch.await(5, TimeUnit.SECONDS);
+ for (int i = 0; i < numPackets; i++)
+ {
+ MessagingBuffer buff = conn.createBuffer(8);
+ buff.writeInt(4);
+ buff.writeInt(i);
+ acceptorListener.connection.write(buff);
+ }
+
+ acceptorLatch.await(10, TimeUnit.SECONDS);
+ connectorLatch.await(10, TimeUnit.SECONDS);
+ conn.close();
+ assertEquals(acceptorHandler.messagesReceieved, 0);
+ assertEquals(connectorHandler.messagesReceieved, numPackets);
+ int i = 0;
+ for (Integer j : acceptorHandler.messages)
+ {
+ assertTrue(i == j);
+ i++;
+ }
+ i = 0;
+ for (Integer j : connectorHandler.messages)
+ {
+ assertTrue(i == j);
+ i++;
+ }
+ }
+
+ public void testSendWithNoReceive() throws Exception
+ {
+
+ int numPackets = 1000;
+ CountDownLatch connCreatedLatch = new CountDownLatch(1);
+ CountDownLatch acceptorLatch = new CountDownLatch(numPackets);
+ CountDownLatch connectorLatch = new CountDownLatch(numPackets);
+ HashMap<String, Object> conf = new HashMap<String, Object>();
+ conf.put(TransportConstants.HTTP_ENABLED_PROP_NAME, true);
+ conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, -1l);
+ conf.put(TransportConstants.HTTP_RESPONSE_TIME_PROP_NAME, 500l);
+ conf.put(TransportConstants.HTTP_SERVER_SCAN_PERIOD_PROP_NAME, 5000l);
+ DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
+ SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
+ acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
+ acceptor.start();
+
+ BogusResponseHandler connectorHandler = new BogusResponseHandler(connectorLatch);
+ connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
+ connector.start();
+ Connection conn = connector.createConnection();
+ connCreatedLatch.await(5, TimeUnit.SECONDS);
+ for (int i = 0; i < numPackets; i++)
+ {
+ MessagingBuffer buff = conn.createBuffer(8);
+ buff.writeInt(4);
+ buff.writeInt(i);
+ conn.write(buff);
+ }
+ acceptorLatch.await(100, TimeUnit.SECONDS);
+ connectorLatch.await(0, TimeUnit.SECONDS);
+ conn.close();
+ assertEquals(acceptorHandler.messagesReceieved, numPackets);
+ assertEquals(connectorHandler.messagesReceieved, 0);
+ int i = 0;
+ for (Integer j : acceptorHandler.messages)
+ {
+ assertTrue(i == j);
+ i++;
+ }
+ }
+
@Override
protected void tearDown() throws Exception
{
More information about the jboss-cvs-commits
mailing list