1 18 19 package org.apache.jmeter.junit; 20 21 import java.io.File ; 22 import java.util.MissingResourceException ; 23 24 import junit.framework.TestCase; 25 import org.apache.jmeter.util.JMeterUtils; 26 import org.apache.jorphan.logging.LoggingManager; 27 import org.apache.log.Logger; 28 29 35 public abstract class JMeterTestCase extends TestCase 36 { 37 private static final String filePrefix; 39 public JMeterTestCase(){ 40 super(); 41 } 42 43 public JMeterTestCase(String name) 44 { 45 super(name); 46 } 47 48 57 static { 58 if (JMeterUtils.getJMeterProperties() == null){ 59 String file="jmetertest.properties"; 60 File f = new File (file); 61 if (!f.canRead()){ 62 System.out.println("Can't find "+file+" - trying bin directory"); 63 file="bin/"+file; System.setProperty("user.dir",System.getProperty("user.dir")+File.separatorChar+"bin"); 66 System.out.println("Setting user.dir="+System.getProperty("user.dir")); 67 filePrefix="bin/"; 68 } else { 69 filePrefix=""; 70 } 71 JMeterUtils jmu = new JMeterUtils(); 72 try { 73 jmu.initializeProperties(file); 74 } catch (MissingResourceException e){ 75 System.out.println("** Can't find resources - continuing anyway **"); 76 } 77 logprop("java.version"); 78 logprop("java.vendor"); 79 logprop("java.home"); 80 logprop("user.home"); 81 logprop("user.dir"); 82 logprop("java.class.version"); 83 logprop("os.name"); 84 logprop("os.version"); 85 logprop("os.arch"); 86 logprop("java.class.path"); 87 } else { 94 filePrefix=""; 95 } 96 } 97 98 private static void logprop(String prop) 99 { 100 System.out.println(prop+"="+System.getProperty(prop)); 101 } 102 103 protected static File findTestFile(String file) 105 { 106 File f= new File (file); 107 if (filePrefix.length() > 0 && !f.isAbsolute()) 108 { 109 f= new File (filePrefix+file); } 111 return f; 112 } 113 114 protected static final Logger testLog = LoggingManager.getLoggerForClass(); 115 } 116 117 | Popular Tags |