JBoss Remoting SVN: r6186 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/identity.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-12-18 17:02:27 -0500 (Sat, 18 Dec 2010)
New Revision: 6186
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/identity/ServerIdentityTestCase.java
Log:
JBREM-1144: (1) Added log search for "detected new serverId"; (2) sped up LeasePinger.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/identity/ServerIdentityTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/identity/ServerIdentityTestCase.java 2010-12-18 18:36:02 UTC (rev 6185)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/identity/ServerIdentityTestCase.java 2010-12-18 22:02:27 UTC (rev 6186)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.remoting.connection.identity;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
import java.lang.reflect.Field;
import java.net.InetAddress;
import java.util.ConcurrentModificationException;
@@ -50,11 +52,9 @@
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.transport.PortUtil;
import org.jboss.remoting.transport.socket.LRUPool;
-import org.jboss.remoting.transport.socket.MicroSocketClientInvoker;
import org.jboss.remoting.transport.socket.ServerSocketWrapper;
import org.jboss.remoting.transport.socket.ServerThread;
import org.jboss.remoting.transport.socket.SocketServerInvoker;
-import org.jboss.remoting.transport.socket.SocketWrapper;
/**
@@ -70,29 +70,36 @@
{
private static Logger log = Logger.getLogger(ServerIdentityTestCase.class);
- private static boolean firstTime = true;
-
protected String host;
protected int port;
protected String locatorURI;
protected InvokerLocator serverLocator;
protected Connector connector;
protected TestInvocationHandler invocationHandler;
-
+ protected ByteArrayOutputStream baosOut;
+ protected PrintStream originalOutPrintStream;
+ protected ByteArrayOutputStream baosErr;
+ protected PrintStream originalErrPrintStream;
public void setUp() throws Exception
{
- if (firstTime)
- {
- firstTime = false;
- Logger.getLogger("org.jboss.remoting").setLevel(XLevel.TRACE);
- Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
- String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
- PatternLayout layout = new PatternLayout(pattern);
- ConsoleAppender consoleAppender = new ConsoleAppender(layout);
- Logger.getRootLogger().addAppender(consoleAppender);
- }
+ originalOutPrintStream = System.out;
+ baosOut = new ByteArrayOutputStream();
+ PrintStream ps = new PrintStream(baosOut);
+ setOut(ps);
+ originalErrPrintStream = System.err;
+ baosErr = new ByteArrayOutputStream();
+ ps = new PrintStream(baosErr);
+ setErr(ps);
+
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.TRACE);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+
host = InetAddress.getLocalHost().getHostAddress();
port = PortUtil.findFreePort(host);
}
@@ -143,6 +150,14 @@
Thread.sleep(10000);
log.info(this + " listener.connectionFailed: " + listener.connectionFailed);
assertTrue(listener.connectionFailed);
+
+ setOut(originalOutPrintStream);
+ String sOut = new String(baosOut.toByteArray());
+ System.out.println(sOut);
+ setErr(originalErrPrintStream);
+ String sErr = new String(baosErr.toByteArray());
+ System.out.println(sErr);
+ assertTrue(sOut.indexOf("detected new serverId:") > -1 || sErr.indexOf("detected new serverId:") > -1);
client.disconnect();
shutdownServer();
@@ -187,9 +202,17 @@
log.info("SHUT DOWN SERVER");
setupServer(true);
log.info("SET UP NEW SERVER");
- Thread.sleep(10000);
+ Thread.sleep(15000);
log.info(this + " listener.connectionFailed: " + listener.connectionFailed);
assertTrue(listener.connectionFailed);
+
+ setOut(originalOutPrintStream);
+ String sOut = new String(baosOut.toByteArray());
+// System.out.println(sOut);
+ setErr(originalErrPrintStream);
+ String sErr = new String(baosErr.toByteArray());
+// System.out.println(sErr);
+ assertTrue(sOut.indexOf("detected new serverId:") > -1 || sErr.indexOf("detected new serverId:") > -1);
client.disconnect();
shutdownServer();
@@ -208,13 +231,25 @@
protected void addExtraServerConfig(Map config) {}
+ private void setOut(final PrintStream ps)
+ {
+ System.setOut(ps);
+ }
+
+
+ private void setErr(final PrintStream ps)
+ {
+ System.setErr(ps);
+ }
+
+
protected void setupServer(boolean useLeasing) throws Exception
{
locatorURI = getTransport() + "://" + host + ":" + port + "?" + Remoting.USE_SERVER_CONNECTION_IDENTITY + "=true";
if (useLeasing)
{
locatorURI += "&" + InvokerLocator.CLIENT_LEASE + "=true";
- locatorURI += "&" + InvokerLocator.CLIENT_LEASE_PERIOD + "=20000";
+ locatorURI += "&" + InvokerLocator.CLIENT_LEASE_PERIOD + "=2000";
}
String metadata = System.getProperty("remoting.metadata");
if (metadata != null)