Clover coverage report -
Coverage timestamp: Sat Jul 7 2007 16:41:13 CEST
file stats: LOC: 115   Methods: 4
NCLOC: 60   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Test.java 50% 65.6% 75% 65%
coverage coverage
 1    /**
 2    * JTRunner is free software; you can redistribute it and/or modify it under the
 3    * terms of the GNU General Public License as published by the Free Software
 4    * Foundation; either version 2, or (at your option) any later version.
 5    */
 6   
 7    package jtr.test;
 8   
 9    import java.io.*;
 10   
 11    import jtr.config.ConfigDeserializer;
 12    import jtr.config.TestConfig;
 13    import org.apache.log4j.Logger;
 14   
 15    import org.apache.log4j.xml.*;
 16    import org.xml.sax.*;
 17   
 18    import jtr.remote.utils.RmiUtil;
 19   
 20    /**
 21    * This class represents one of the two entry points to a JTRunner test.<br>
 22    * It contains a main method that synchronously starts the main thread of the
 23    * current test.
 24    *
 25    * @author Francesco Russo (frusso@dev.java.net)
 26    * @version 4.0
 27    * @since 1.0
 28    * @see jtr.test.SystemProperties
 29    * @see jtr.config.TestConfig
 30    * @see jtr.test.TestRunManager
 31    */
 32    public class Test extends Thread {
 33    /**
 34    * The constructor.
 35    *
 36    * @param name
 37    * The name of the JTR main thread
 38    */
 39  1 public Test(String name) {
 40  1 super(name);
 41    }
 42   
 43    /**
 44    * The constructor.
 45    *
 46    * @param group
 47    * A thread group for the JTR main thread
 48    * @param name
 49    * The name of the JTR main thread
 50    */
 51  0 public Test(ThreadGroup group, String name) {
 52  0 super(group, name);
 53    }
 54   
 55    /**
 56    * This method uses the provided system properties for reading in the
 57    * configuration files.<br>
 58    * After that it creates a <code>TestRunManager</code> using the
 59    * <code>TestConfig</code> representing the provided <code>jtr.xml</code>
 60    * file and starts the test.
 61    */
 62  1 public void run() {
 63  1 String jtrConfig = System.getProperty(SystemProperties.JTR_TEST_CONFIGURATION);
 64  1 String log4jConfig = System.getProperty(SystemProperties.LOG4J_CONFIGURATION);
 65   
 66  1 if (jtrConfig == null) {
 67  0 System.err.println("\nJTR 4.0 - Wrong argument(s) in call. Usage is:\n" + "if using log4j's default initialization just specify the test xml configuration file, "
 68    + "otherwise specify as first parametr the log4j xml configuration file followed by the test xml configuration file.\n\n");
 69  0 System.exit(1);
 70    } else {
 71  1 if (log4jConfig != null) {
 72  1 DOMConfigurator.configure(log4jConfig);
 73    }
 74  1 Logger logger = Logger.getLogger(Test.class);
 75  1 try {
 76  1 InputStream is = new BufferedInputStream(new FileInputStream(new File(jtrConfig)));
 77  1 ConfigDeserializer cDes = new ConfigDeserializer(is);
 78  1 try {
 79  1 TestConfig test = cDes.getConfigTree();
 80  1 cDes = null;
 81  1 is.close();
 82  1 is = null;
 83  1 TestRunManager trm = new TestRunManager(test);
 84  1 try {
 85  1 trm.startTest();
 86    } catch (TestFailedException e) {
 87  0 logger.fatal("Test failed: ", e);
 88  0 e.printStackTrace();
 89    }
 90    } catch (IOException e) {
 91  0 logger.fatal("Error while reading in the test configuration: ", e);
 92  0 e.printStackTrace();
 93    } catch (SAXException e) {
 94  0 logger.fatal("Error while reading in the test configuration: ", e);
 95  0 e.printStackTrace();
 96    }
 97    } catch (IOException e) {
 98  0 logger.fatal("Error while reading in the test configuration: ", e);
 99  0 e.printStackTrace();
 100    }
 101    }
 102    }
 103   
 104    /**
 105    * Starts the test.
 106    *
 107    * @param args
 108    * String[]
 109    */
 110  1 public static void main(String[] args) {
 111  1 RmiUtil.setSystemProperties();
 112  1 Test test = new Test("Test-Thread");
 113  1 test.run();
 114    }
 115    }