1 5 package com.tc.util.runtime; 6 7 import com.tc.process.LinkedJavaProcess; 8 import com.tc.process.StreamCollector; 9 import com.tc.test.TCTestCase; 10 import com.tc.test.TestConfigObject; 11 12 import java.io.IOException ; 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 public class ThreadDumpTest extends TCTestCase { 17 18 22 public void testDump() throws IOException , InterruptedException { 23 LinkedJavaProcess process = new LinkedJavaProcess(ThreadDump.class.getName()); 24 25 List args = new ArrayList (); 26 String libPath = System.getProperty("java.library.path", ""); 27 if (!"".equals(libPath)) { 28 args.add("-Djava.library.path=" + libPath); 29 } 30 31 args.add("-D" + TestConfigObject.TC_BASE_DIR + "=" + System.getProperty(TestConfigObject.TC_BASE_DIR)); 32 args.add("-D" + TestConfigObject.PROPERTY_FILE_LIST_PROPERTY_NAME + "=" 33 + System.getProperty(TestConfigObject.PROPERTY_FILE_LIST_PROPERTY_NAME)); 34 process.setJavaArguments((String []) args.toArray(new String [args.size()])); 35 36 System.err.println("JAVA ARGS: " + args); 37 38 process.start(); 39 40 StreamCollector err = new StreamCollector(process.STDERR()); 41 StreamCollector out = new StreamCollector(process.STDOUT()); 42 43 err.start(); 44 out.start(); 45 46 process.waitFor(); 47 48 err.join(); 49 out.join(); 50 51 String stderr = err.toString(); 52 String stdout = out.toString(); 53 54 System.out.println("**** STDOUT BEGIN ****\n" + stdout + "\n**** STDOUT END ****"); 55 System.out.println("**** STDERR BEGIN ****\n" + stderr + "\n**** STDERR END ****"); 56 57 assertTrue(stderr.toLowerCase().indexOf("full thread dump") >= 0 58 || stdout.toLowerCase().indexOf("full thread dump") >= 0); 59 } 60 } 61 | Popular Tags |