Author: ron.sigal(a)jboss.com
Date: 2010-02-17 20:16:41 -0500 (Wed, 17 Feb 2010)
New Revision: 5729
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/RemoteClassloaderTestCase.java
Log:
JBREM-1184: Captured System.out to look for NPE.
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/RemoteClassloaderTestCase.java
===================================================================
---
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/RemoteClassloaderTestCase.java 2010-02-18
01:14:52 UTC (rev 5728)
+++
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/classloader/RemoteClassloaderTestCase.java 2010-02-18
01:16:41 UTC (rev 5729)
@@ -22,6 +22,8 @@
package org.jboss.test.remoting.classloader;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
import java.lang.reflect.Field;
import java.net.InetAddress;
import java.util.HashMap;
@@ -65,10 +67,10 @@
*/
public class RemoteClassloaderTestCase extends TestCase
{
- private static Logger log = Logger.getLogger(RemoteClassloaderTestCase.class);
+ private ByteArrayOutputStream baos;
+ private PrintStream originalPrintStream;
+ private Logger log;
- private static boolean firstTime = true;
-
protected String host;
protected int port;
protected String locatorURI;
@@ -79,16 +81,18 @@
public void setUp() throws Exception
{
- if (firstTime)
- {
- firstTime = false;
- Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
- 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);
- }
+ originalPrintStream = System.out;
+ baos = new ByteArrayOutputStream();
+ PrintStream ps = new PrintStream(baos);
+ System.setOut(ps);
+
+ Logger.getLogger("org.jboss.remoting").setLevel(Level.DEBUG);
+ 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);
+ log = Logger.getLogger(RemoteClassloaderTestCase.class);
}
@@ -122,6 +126,12 @@
fail("expected ClassNotFoundException: got " + t);
}
+ System.setOut(originalPrintStream);
+ String s = new String(baos.toByteArray());
+ System.out.println(s);
+ assertTrue(s.indexOf("java.lang.NullPointerException") == -1);
+ assertTrue(s.indexOf("Can not load remote class bytes: server returned null
class") >= 0);
+
shutdownServer();
log.info(getName() + " PASSES");
}
Show replies by date