org.onap migration
[vid.git] / vid-automation / src / main / java / vid / automation / test / StartTest.java
1 package vid.automation.test;
2
3 import org.testng.TestNG;
4 import org.apache.log4j.Logger;
5 import org.apache.log4j.PropertyConfigurator;
6
7 import java.io.IOException;
8 import java.util.ArrayList;
9 import java.util.List;
10 import java.util.concurrent.atomic.AtomicBoolean;
11
12 /**
13  * Created by itzikliderman on 21/06/2017.
14  */
15 public class StartTest {
16     public static boolean debug = false;
17
18     public static AtomicBoolean loggerInitialized = new AtomicBoolean(false);
19
20     protected static Logger logger = null;
21
22     public static void main (String[] args) throws IOException {
23         String debugEnabled = System.getProperty("debug");
24         if (debugEnabled != null && debugEnabled.equalsIgnoreCase("true")) {
25             debug = true;
26         }
27         System.out.println("Debug mode is " + (debug ? "enabled" : "disabled"));
28
29         enableLogger();
30
31         TestNG testng = new TestNG();
32
33         List<String> suites = new ArrayList<String>();
34         suites.add(args[0]);
35         testng.setTestSuites(suites);
36         testng.setUseDefaultListeners(true);
37         testng.setOutputDirectory("target/");
38
39         testng.run();
40     }
41
42     public StartTest() {
43         logger = Logger.getLogger(StartTest.class.getName());
44     }
45
46     public static void enableLogger() {
47
48         if (false == loggerInitialized.get()) {
49
50             loggerInitialized.set(true);
51
52             String log4jPropsFile = System.getProperty("log4j.configuration");
53 //            if (System.getProperty("os.name").contains("Windows")) {
54                 String logProps = "src/main/resources/ci/conf/log4j.properties";
55                 if (log4jPropsFile == null) {
56                     System.setProperty("targetlog", "target/");
57                     log4jPropsFile = logProps;
58                 }
59
60 //            }
61             PropertyConfigurator.configureAndWatch(log4jPropsFile);
62
63         }
64     }
65
66 }