Author: ron.sigal(a)jboss.com
Date: 2009-08-17 17:10:24 -0400 (Mon, 17 Aug 2009)
New Revision: 5348
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/timeout/WriteTimeoutTestParent.java
Log:
JBREM-1120: Various fixes.
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/timeout/WriteTimeoutTestParent.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/timeout/WriteTimeoutTestParent.java 2009-08-16
01:48:47 UTC (rev 5347)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/timeout/WriteTimeoutTestParent.java 2009-08-17
21:10:24 UTC (rev 5348)
@@ -102,6 +102,7 @@
}
TestOutputStream.counter = 0;
+ callbackTest = false;
}
@@ -110,7 +111,7 @@
}
- public void xtestClientWriteTimeout() throws Throwable
+ public void testClientWriteTimeout() throws Throwable
{
log.info("entering " + getName());
@@ -122,7 +123,7 @@
HashMap clientConfig = new HashMap();
clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
clientConfig.put(SocketWrapper.WRITE_TIMEOUT, "1000");
- SocketFactory sf = (SocketFactory) getSocketFactoryConstructor().newInstance(new
Object[]{new Integer(5000), new Integer(-1)});
+ SocketFactory sf = (SocketFactory) getSocketFactoryConstructor().newInstance(new
Object[]{new Integer(5000), new Integer(1)});
clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sf);
addExtraClientConfig(clientConfig);
Client client = new Client(clientLocator, clientConfig);
@@ -160,12 +161,12 @@
}
- public void xtestServerWriteTimeout() throws Throwable
+ public void testServerWriteTimeout() throws Throwable
{
log.info("entering " + getName());
// Start server.
- setupServer(true, false, "1000", 5000, -1);
+ setupServer(true, false, "1000", 5000, 1);
// Create client.
InvokerLocator clientLocator = new InvokerLocator(locatorURI);
@@ -219,12 +220,27 @@
log.info("entering " + getName());
// Start server.
+ if (isBisocket(getTransport()))
+ {
+ callbackTest = true;
+ }
setupServer(false, false, "", -1, -1);
// Create client.
InvokerLocator clientLocator = new InvokerLocator(locatorURI);
HashMap clientConfig = new HashMap();
clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(SocketWrapper.WRITE_TIMEOUT, "1000");
+ if (isBisocket(getTransport()))
+ {
+ SocketFactory sf = (SocketFactory) getSocketFactoryConstructor().newInstance(new
Object[]{new Integer(5000), new Integer(1)});
+ clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sf);
+ }
+ else
+ {
+ ServerSocketFactory ssf = (ServerSocketFactory)
getServerSocketFactoryConstructor().newInstance(new Object[]{new Integer(5000), new
Integer(-1)});
+ clientConfig.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf);
+ }
addExtraClientConfig(clientConfig);
Client client = new Client(clientLocator, clientConfig);
client.connect();
@@ -243,7 +259,7 @@
HashMap metadata = new HashMap();
if (isBisocket(getTransport()))
{
- metadata.put(SocketWrapper.WRITE_TIMEOUT, "1000");
+// metadata.put(SocketWrapper.WRITE_TIMEOUT, "1000");
metadata.put(Remoting.SOCKET_FACTORY_NAME, getSocketFactoryClassName());
metadata.put("numberOfCallRetries", "1");
metadata.put(Bisocket.IS_CALLBACK_SERVER, "true");
@@ -251,7 +267,7 @@
}
else
{
- metadata.put(SocketWrapper.WRITE_TIMEOUT, "1000");
+// metadata.put(SocketWrapper.WRITE_TIMEOUT, "1000");
metadata.put(ServerInvoker.SERVER_SOCKET_FACTORY,
getServerSocketFactoryClassName());
metadata.put("numberOfCallRetries", "1");
}
@@ -278,7 +294,7 @@
}
- public void xtestServerCallbackWriteTimeout() throws Throwable
+ public void testServerCallbackWriteTimeout() throws Throwable
{
log.info("entering " + getName());
@@ -290,7 +306,7 @@
}
else
{
- setupServer(false, true, "1000", 5000, -1);
+ setupServer(false, true, "1000", 5000, 1);
}
// Create client.
@@ -341,7 +357,10 @@
assertTrue(t.getCause() instanceof CannotConnectException);
log.info("t.getCause().getCause(): ", t.getCause().getCause());
assertTrue(t.getCause().getCause() instanceof InvocationTargetException);
- assertTrue(t.getCause().getCause().getCause() instanceof SSLProtocolException);
+ log.info("t.getCause().getCause().getCause(): ",
t.getCause().getCause().getCause());
+// assertTrue(t.getCause().getCause().getCause() instanceof
SSLProtocolException);
+ assertTrue(t.getCause().getCause().getCause() instanceof IOException);
+ assertEquals("closed",
t.getCause().getCause().getCause().getMessage());
}
log.info("got expected Exception");
@@ -611,26 +630,81 @@
}
public Socket createSocket()
{
- return new TestSocket(timeout, initialWrites);
+ log.info("callbackTest: " + callbackTest);
+ Socket s = null;
+ if (callbackTest)
+ {
+ s = new Socket();
+ }
+ else
+ {
+ s = new TestSocket(timeout, initialWrites);
+ }
+ log.info(this + " returning " + s);
+ return s;
}
public Socket createSocket(String arg0, int arg1) throws IOException,
UnknownHostException
{
- return new TestSocket(arg0, arg1, timeout, initialWrites);
+ log.info("callbackTest: " + callbackTest + ", port: " +
arg1);
+ Socket s = null;
+ if (callbackTest && arg1 != secondaryServerSocketPort)
+ {
+ s = new Socket(arg0, arg1);
+ }
+ else
+ {
+ s = new TestSocket(arg0, arg1, timeout, initialWrites);
+ }
+ log.info(this + " returning " + s);
+ return s;
}
public Socket createSocket(InetAddress arg0, int arg1) throws IOException
{
- return new TestSocket(arg0, arg1, timeout, initialWrites);
+ log.info("callbackTest: " + callbackTest + ", port: " +
arg1);
+ Socket s = null;
+ if (callbackTest && arg1 != secondaryServerSocketPort)
+ {
+ s = new Socket(arg0, arg1);
+ }
+ else
+ {
+ s = new TestSocket(arg0, arg1, timeout, initialWrites);
+ }
+ log.info(this + " returning " + s);
+ return s;
}
public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3)
throws IOException, UnknownHostException
{
- return new TestSocket(arg0, arg1, arg2, arg3, timeout, initialWrites);
+ log.info("callbackTest: " + callbackTest + ", port: " +
arg1);
+ Socket s = null;
+ if (callbackTest && arg1 != secondaryServerSocketPort)
+ {
+ s = new Socket(arg0, arg1);
+ }
+ else
+ {
+ s = new TestSocket(arg0, arg1, arg2, arg3, timeout, initialWrites);
+ }
+ log.info(this + " returning " + s);
+ return s;
}
public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3)
throws IOException
{
- return new TestSocket(arg0, arg1, arg2, arg3, timeout, initialWrites);
+ log.info("callbackTest: " + callbackTest + ", port: " +
arg1);
+ Socket s = null;
+ if (callbackTest && arg1 != secondaryServerSocketPort)
+ {
+ s = new Socket(arg0, arg1);
+ }
+ else
+ {
+ s = new TestSocket(arg0, arg1, arg2, arg3, timeout, initialWrites);
+ }
+ log.info(this + " returning " + s);
+ return s;
}
}
@@ -701,6 +775,7 @@
}
public void write(int b) throws IOException
{
+ System.out.print("b: " + b);
if (closed)
{
log.info("TestOutputStream closed, cannot write");
@@ -722,6 +797,12 @@
}
public void write(byte b[], int off, int len) throws IOException
{
+ System.out.print("b: ");
+ for (int i = 0; i < len; i++)
+ {
+ System.out.print(b[i] + " ");
+ }
+ System.out.println("");
if (closed)
{
log.info("TestOutputStream closed, cannot write");
@@ -740,13 +821,19 @@
e.printStackTrace();
}
}
+ if (closed)
+ {
+ log.info("TestOutputStream closed, cannot write");
+ throw new IOException("closed");
+ }
try
{
- log.info(this + " writing");
+ log.info(this + " calling write()");
doWait = false;
os.write(b, off, len);
+ os.flush();
doWait = true;
- log.info(this + " back from writing");
+ log.info(this + " back from write()");
}
catch (IOException e)
{